From 395f08109533cb7d023a56b73a852e3a6be16bd6 Mon Sep 17 00:00:00 2001 From: fesiong Date: Mon, 13 May 2019 11:31:09 +0800 Subject: [PATCH 01/25] add phalcon 4.0 version files to ide-strubs --- src/Phalcon/Container.php | 34 + src/Phalcon/Plugin.php | 14 + src/Phalcon/Url.php | 188 +++ src/Phalcon/Urlinterface.php | 44 + src/Phalcon/acl/Component.php | 57 + src/Phalcon/acl/Componentaware.php | 16 + src/Phalcon/acl/Componentinterface.php | 27 + src/Phalcon/assets/Asset.php | 178 +++ src/Phalcon/assets/Assetinterface.php | 46 + src/Phalcon/assets/asset/Css.php | 20 + src/Phalcon/assets/asset/Js.php | 20 + .../exception/Serviceresolutionexception.php | 11 + src/Phalcon/filter/Filterlocator.php | 51 + src/Phalcon/filter/Filterlocatorfactory.php | 42 + src/Phalcon/filter/sanitize/Absint.php | 18 + src/Phalcon/filter/sanitize/Alnum.php | 18 + src/Phalcon/filter/sanitize/Alpha.php | 18 + src/Phalcon/filter/sanitize/Boolval.php | 18 + src/Phalcon/filter/sanitize/Email.php | 18 + src/Phalcon/filter/sanitize/Floatval.php | 18 + src/Phalcon/filter/sanitize/Intval.php | 18 + src/Phalcon/filter/sanitize/Lower.php | 18 + src/Phalcon/filter/sanitize/Lowerfirst.php | 18 + src/Phalcon/filter/sanitize/Regex.php | 18 + src/Phalcon/filter/sanitize/Remove.php | 18 + src/Phalcon/filter/sanitize/Replace.php | 18 + src/Phalcon/filter/sanitize/Special.php | 18 + src/Phalcon/filter/sanitize/Specialfull.php | 18 + src/Phalcon/filter/sanitize/Stringval.php | 18 + src/Phalcon/filter/sanitize/Striptags.php | 18 + src/Phalcon/filter/sanitize/Trim.php | 18 + src/Phalcon/filter/sanitize/Upper.php | 18 + src/Phalcon/filter/sanitize/Upperfirst.php | 18 + src/Phalcon/filter/sanitize/Upperwords.php | 18 + src/Phalcon/filter/sanitize/Url.php | 18 + src/Phalcon/helper/Arr.php | 33 + src/Phalcon/helper/Exception.php | 14 + src/Phalcon/html/Breadcrumbs.php | 95 ++ src/Phalcon/html/Exception.php | 14 + src/Phalcon/html/Tag.php | 1064 +++++++++++++++++ src/Phalcon/html/Taglocator.php | 14 + src/Phalcon/html/Taglocatorfactory.php | 42 + src/Phalcon/html/helper/Abstracthelper.php | 54 + src/Phalcon/html/helper/Anchor.php | 22 + src/Phalcon/html/helper/Button.php | 21 + src/Phalcon/html/helper/Element.php | 22 + src/Phalcon/html/helper/Form.php | 20 + src/Phalcon/html/helper/Formclose.php | 20 + src/Phalcon/html/helper/Textarea.php | 21 + .../logger/adapter/Abstractadapter.php | 100 ++ .../logger/adapter/Adapterinterface.php | 54 + src/Phalcon/logger/adapter/Noop.php | 36 + .../logger/formatter/Abstractformatter.php | 19 + .../logger/formatter/Formatterinterface.php | 23 + src/Phalcon/messages/Exception.php | 14 + src/Phalcon/messages/Message.php | 138 +++ src/Phalcon/messages/Messageinterface.php | 72 ++ src/Phalcon/messages/Messages.php | 171 +++ src/Phalcon/paginator/Repository.php | 110 ++ src/Phalcon/paginator/Repositoryinterface.php | 75 ++ src/Phalcon/service/Exception.php | 12 + src/Phalcon/service/Locator.php | 59 + .../service/Locatorfactoryinterface.php | 18 + src/Phalcon/service/Locatorinterface.php | 27 + src/Phalcon/session/Manager.php | 239 ++++ src/Phalcon/session/Managerinterface.php | 139 +++ src/Phalcon/session/adapter/Noop.php | 106 ++ src/Phalcon/url/Exception.php | 13 + src/Phalcon/validation/validator/Ip.php | 73 ++ 69 files changed, 4080 insertions(+) create mode 100644 src/Phalcon/Container.php create mode 100644 src/Phalcon/Plugin.php create mode 100644 src/Phalcon/Url.php create mode 100644 src/Phalcon/Urlinterface.php create mode 100644 src/Phalcon/acl/Component.php create mode 100644 src/Phalcon/acl/Componentaware.php create mode 100644 src/Phalcon/acl/Componentinterface.php create mode 100644 src/Phalcon/assets/Asset.php create mode 100644 src/Phalcon/assets/Assetinterface.php create mode 100644 src/Phalcon/assets/asset/Css.php create mode 100644 src/Phalcon/assets/asset/Js.php create mode 100644 src/Phalcon/di/exception/Serviceresolutionexception.php create mode 100644 src/Phalcon/filter/Filterlocator.php create mode 100644 src/Phalcon/filter/Filterlocatorfactory.php create mode 100644 src/Phalcon/filter/sanitize/Absint.php create mode 100644 src/Phalcon/filter/sanitize/Alnum.php create mode 100644 src/Phalcon/filter/sanitize/Alpha.php create mode 100644 src/Phalcon/filter/sanitize/Boolval.php create mode 100644 src/Phalcon/filter/sanitize/Email.php create mode 100644 src/Phalcon/filter/sanitize/Floatval.php create mode 100644 src/Phalcon/filter/sanitize/Intval.php create mode 100644 src/Phalcon/filter/sanitize/Lower.php create mode 100644 src/Phalcon/filter/sanitize/Lowerfirst.php create mode 100644 src/Phalcon/filter/sanitize/Regex.php create mode 100644 src/Phalcon/filter/sanitize/Remove.php create mode 100644 src/Phalcon/filter/sanitize/Replace.php create mode 100644 src/Phalcon/filter/sanitize/Special.php create mode 100644 src/Phalcon/filter/sanitize/Specialfull.php create mode 100644 src/Phalcon/filter/sanitize/Stringval.php create mode 100644 src/Phalcon/filter/sanitize/Striptags.php create mode 100644 src/Phalcon/filter/sanitize/Trim.php create mode 100644 src/Phalcon/filter/sanitize/Upper.php create mode 100644 src/Phalcon/filter/sanitize/Upperfirst.php create mode 100644 src/Phalcon/filter/sanitize/Upperwords.php create mode 100644 src/Phalcon/filter/sanitize/Url.php create mode 100644 src/Phalcon/helper/Arr.php create mode 100644 src/Phalcon/helper/Exception.php create mode 100644 src/Phalcon/html/Breadcrumbs.php create mode 100644 src/Phalcon/html/Exception.php create mode 100644 src/Phalcon/html/Tag.php create mode 100644 src/Phalcon/html/Taglocator.php create mode 100644 src/Phalcon/html/Taglocatorfactory.php create mode 100644 src/Phalcon/html/helper/Abstracthelper.php create mode 100644 src/Phalcon/html/helper/Anchor.php create mode 100644 src/Phalcon/html/helper/Button.php create mode 100644 src/Phalcon/html/helper/Element.php create mode 100644 src/Phalcon/html/helper/Form.php create mode 100644 src/Phalcon/html/helper/Formclose.php create mode 100644 src/Phalcon/html/helper/Textarea.php create mode 100644 src/Phalcon/logger/adapter/Abstractadapter.php create mode 100644 src/Phalcon/logger/adapter/Adapterinterface.php create mode 100644 src/Phalcon/logger/adapter/Noop.php create mode 100644 src/Phalcon/logger/formatter/Abstractformatter.php create mode 100644 src/Phalcon/logger/formatter/Formatterinterface.php create mode 100644 src/Phalcon/messages/Exception.php create mode 100644 src/Phalcon/messages/Message.php create mode 100644 src/Phalcon/messages/Messageinterface.php create mode 100644 src/Phalcon/messages/Messages.php create mode 100644 src/Phalcon/paginator/Repository.php create mode 100644 src/Phalcon/paginator/Repositoryinterface.php create mode 100644 src/Phalcon/service/Exception.php create mode 100644 src/Phalcon/service/Locator.php create mode 100644 src/Phalcon/service/Locatorfactoryinterface.php create mode 100644 src/Phalcon/service/Locatorinterface.php create mode 100644 src/Phalcon/session/Manager.php create mode 100644 src/Phalcon/session/Managerinterface.php create mode 100644 src/Phalcon/session/adapter/Noop.php create mode 100644 src/Phalcon/url/Exception.php create mode 100644 src/Phalcon/validation/validator/Ip.php diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php new file mode 100644 index 00000000..73a9f388 --- /dev/null +++ b/src/Phalcon/Container.php @@ -0,0 +1,34 @@ + + */ + protected $container; + + /** + * Phalcon\Di constructor + */ + public function __construct(DiInterface $container) + { + } + + /** + * Return the service + */ + public function get($name) { + } + + /** + * Whether a service exists or not in the container + */ + public function has($name) : bool + { + } +} diff --git a/src/Phalcon/Plugin.php b/src/Phalcon/Plugin.php new file mode 100644 index 00000000..5689dbdb --- /dev/null +++ b/src/Phalcon/Plugin.php @@ -0,0 +1,14 @@ + + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2012", + * ] + * ); + * + */ +class Url implements UrlInterface, InjectionAwareInterface +{ + + /** + * @var null | string + */ + protected $baseUri = null; + + /** + * @var null | string + */ + protected $basePath = null; + + /** + * @var + */ + protected $container; + + protected $router; + + /** + * @var null | string + */ + protected $staticBaseUri = null; + + /** + * Generates a URL + * + * + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2015", + * ] + * ); + * + * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) + * echo $url->get( + * "show/products", + * [ + * "id" => 1, + * "name" => "Carrots", + * ] + * ); + * + * // Generate an absolute URL by setting the third parameter as false. + * echo $url->get( + * "https://phalconphp.com/", + * null, + * false + * ); + * + */ + public function get($uri = null, $args = null, bool $local = null, $baseUri = null) : string + { + } + + /** + * Returns the base path + */ + public function getBasePath() : string + { + } + + /** + * Returns the prefix for all the generated urls. By default / + */ + public function getBaseUri() : string + { + } + + /** + * Returns the DependencyInjector container + */ + public function getDI() : DiInterface + { + } + + /** + * Generates a URL for a static resource + * + * + * // Generate a URL for a static resource + * echo $url->getStatic("img/logo.png"); + * + * // Generate a URL for a static predefined route + * echo $url->getStatic( + * [ + * "for" => "logo-cdn", + * ] + * ); + * + */ + public function getStatic($uri = null) : string + { + } + + /** + * Returns the prefix for all the generated static urls. By default / + */ + public function getStaticBaseUri() : string + { + } + + /** + * Sets a base path for all the generated paths + * + * + * $url->setBasePath("/var/www/htdocs/"); + * + */ + public function setBasePath(string $basePath) : UrlInterface + { + } + + /** + * Sets a prefix for all the URIs to be generated + * + * + * $url->setBaseUri("/invo/"); + * + * $url->setBaseUri("/invo/index.php/"); + * + */ + public function setBaseUri(string $baseUri) : UrlInterface + { + } + + /** + * Sets the DependencyInjector container + */ + public function setDI(DiInterface $dependencyInjector) + { + } + + /** + * Sets a prefix for all static URLs generated + * + * + * $url->setStaticBaseUri("/invo/"); + * + */ + public function setStaticBaseUri(string $staticBaseUri) : UrlInterface + { + } + + /** + * Generates a local path + */ + public function path(string $path = null) : string + { + } +} diff --git a/src/Phalcon/Urlinterface.php b/src/Phalcon/Urlinterface.php new file mode 100644 index 00000000..d107d252 --- /dev/null +++ b/src/Phalcon/Urlinterface.php @@ -0,0 +1,44 @@ + + * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); + * + */ +class Asset implements AssetInterface +{ + /** + * @var array | null + */ + protected $attributes; + + /** + * @var bool + */ + protected $filter; + + /** + * @var bool + */ + protected $local; + + /** + * @var string + */ + protected $path; + + /** + * @var string + */ + protected $sourcePath; + + /** + * @var string + */ + protected $targetPath; + + /** + * @var string + */ + protected $targetUri; + + /** + * @var string + */ + protected $type; + + /** + * Phalcon\Assets\Asset constructor + */ + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = []) + { + } + + /** + * Sets the asset's type + */ + public function setType(string $type) : AssetInterface + { + } + + /** + * Sets the asset's path + */ + public function setPath(string $path) : AssetInterface + { + } + + /** + * Sets if the asset is local or external + */ + public function setLocal(bool $local) : AssetInterface + { + } + + /** + * Sets if the asset must be filtered or not + */ + public function setFilter(bool $filter) : AssetInterface + { + } + + /** + * Sets extra HTML attributes + */ + public function setAttributes(array $attributes) : AssetInterface + { + } + + /** + * Sets a target uri for the generated HTML + */ + public function setTargetUri(string $targetUri) : AssetInterface + { + } + + /** + * Sets the asset's source path + */ + public function setSourcePath(string $sourcePath) : AssetInterface + { + } + + /** + * Sets the asset's target path + */ + public function setTargetPath(string $targetPath) : AssetInterface + { + } + + /** + * Returns the content of the asset as an string + * Optionally a base path where the asset is located can be set + */ + public function getContent(string $basePath = null) : string + { + } + + /** + * Returns the real target uri for the generated HTML + */ + public function getRealTargetUri() : string + { + } + + /** + * Returns the complete location where the asset is located + */ + public function getRealSourcePath(string $basePath = null) : string + { + } + + /** + * Returns the complete location where the asset must be written + */ + public function getRealTargetPath(string $basePath = null) : string + { + } + + /** + * Gets the asset's key. + */ + public function getAssetKey() : string + { + } + + /** + * Gets the asset's type. + */ + public function getType(): string + { + // TODO: Implement getType() method. + } + + /** + * Gets if the asset must be filtered or not. + */ + public function getFilter(): bool + { + // TODO: Implement getFilter() method. + } + + /** + * Gets extra HTML attributes. + */ + public function getAttributes(): array + { + // TODO: Implement getAttributes() method. + } +} diff --git a/src/Phalcon/assets/Assetinterface.php b/src/Phalcon/assets/Assetinterface.php new file mode 100644 index 00000000..f9a82da8 --- /dev/null +++ b/src/Phalcon/assets/Assetinterface.php @@ -0,0 +1,46 @@ +` tags, while the whole string is enclosed in `
` tags. + */ +class Breadcrumbs +{ + /** + * Keeps all the breadcrumbs + * + * @var array + */ + private $elements = []; + + /** + * Crumb separator + * + * @var string + */ + private $separator = " / "; + + /** + * The HTML template to use to render the breadcrumbs. + * + * @var string + */ + private $template = "
%label%
"; + + /** + * Adds a new crumb. + * + * + * // Adding a crumb with a link + * $breadcrumbs->add("Home", "/"); + * + * // Adding a crumb without a link (normally the last one) + * $breadcrumbs->add("Users"); + * + */ + public function add(string $label, string $link = "") : Breadcrumbs + { + } + + /** + * Clears the crumbx + * + * + * $breadcrumbs->clear() + * + */ + public function clear() : void + { + } + + /** + * Removes crumb by url. + * + * + * $breadcrumbs->remove("/admin/user/create"); + * + * // remove a crumb without an url (last link) + * $breadcrumbs->remove(); + * + */ + public function remove(string $link) : void + { + } + + /** + * Renders and outputs breadcrumbs based on previously set template. + * + * + * // Php Engine + * echo $breadcrumbs->render(); + * + */ + public function render() : string + { + } + + /** + * Returns the internal breadcrumbs array + */ + public function toArray() : array + { + } +} diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php new file mode 100644 index 00000000..1a22c6d9 --- /dev/null +++ b/src/Phalcon/html/Exception.php @@ -0,0 +1,14 @@ + + */ + protected $container; + + /** + * @var array + */ + private $append = []; + + /** + * @var int + */ + private $docType = 5; // HTML5 + + /** + * @var + */ + private $escaper; + + /** + * @var array + */ + private $prepend = []; + + /** + * @var string + */ + private $separator = ""; + + /** + * @var string + */ + private $title = ""; + + /** + * @var array + */ + private $values = []; + + /** + * @var + */ + private $url; + + /** + * Constants + */ + const HTML32 = 1; + const HTML401_STRICT = 2; + const HTML401_TRANSITIONAL = 3; + const HTML401_FRAMESET = 4; + const HTML5 = 5; + const XHTML10_STRICT = 6; + const XHTML10_TRANSITIONAL = 7; + const XHTML10_FRAMESET = 8; + const XHTML11 = 9; + const XHTML20 = 10; + const XHTML5 = 11; + + /** + * Appends a text to current document title + */ + public function appendTitle(array $title) : Tag + { + } + + /** + * Builds a HTML input[type="button"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->button('Click Me') + * + * + * Volt syntax: + * + * {{ button('Click Me) }} + * + */ + public function button(string $name, array $parameters = []) : string + { + } + + /** + * Resets the request and internal values to avoid those fields will have + * any default value. + */ + public function clear() : void + { + } + + /** + * Builds a HTML tag + * + * Parameters + * `onlyStart` Only process the start of th element + * `selfClose` It is a self close element + * `useEol` Append PHP_EOL at the end + * + */ + public function element(string $tag, array $parameters = []) : string + { + } + + /** + * Builds the closing tag of an html element + * + * Parameters + * `useEol` Append PHP_EOL at the end + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', + * ] + * ); // + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', + * 'useEol' => true, + * ] + * ); // '' . PHP_EOL + * + * + */ + public function elementClose(string $tag, array $parameters = []) : string + { + } + + /** + * Returns the closing tag of a form element + */ + public function endForm(bool $eol = true) : string + { + } + + /** + * Builds a HTML FORM tag + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->form('posts/save'); + * + * echo $tag->form( + * 'posts/save', + * [ + * "method" => "post", + * ] + * ); + * + * + * Volt syntax: + * + * {{ form('posts/save') }} + * {{ form('posts/save', ['method': 'post') }} + * + */ + public function form(string $action, array $parameters = []) : string + { + } + + /** + * Converts text to URL-friendly strings + * + * Parameters + * `text` The text to be processed + * `separator` Separator to use (default '-') + * `lowercase` Convert to lowercase + * `replace` + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->friendlyTitle( + * [ + * 'text' => 'These are big important news', + * 'separator' => '-', + * ] + * ); + * + * + * Volt Syntax: + * + * {{ friendly_title(['text': 'These are big important news', 'separator': '-']) }} + * + */ + public function friendlyTitle(string $text, array $parameters = []) : string + { + } + + /** + * Returns the internal dependency injector + */ + public function getDI() : DiInterface + { + } + + /** + * Get the document type declaration of content. If the docType has not + * been set properly, XHTML5 is returned + */ + public function getDocType() : string + { + } + + /** + * Gets the current document title. The title will be automatically escaped. + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->getTitle(); // Hello World from Phalcon + * echo $tag->getTitle(false); // World from Phalcon + * echo $tag->getTitle(true, false); // Hello World + * echo $tag->getTitle(false, false); // World + * + * + * Volt syntax: + * + * {{ get_title() }} + * + */ + public function getTitle(bool $prepend = true, bool $append = true) : string + { + } + + /** + * Gets the current document title separator + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->getTitleSeparator(); + * + * + * Volt syntax: + * + * {{ get_title_separator() }} + * + */ + public function getTitleSeparator() : string + { + } + + /** + * Every helper calls this function to check whether a component has a predefined + * value using `setAttribute` or value from $_POST + */ + public function getValue(string $name, array $parameters = []) { + } + + /** + * Check if a helper has a default value set using `setAttribute()` or + * value from $_POST + */ + public function hasValue(string $name) : bool + { + } + + /** + * Builds HTML IMG tags + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->image('img/bg.png'); + * + * echo $tag->image( + * 'img/photo.jpg', + * [ + * 'alt' => 'Some Photo', + * ] + * ); + * + * echo $tag->image( + * 'http://static.mywebsite.com/img/bg.png', + * [ + * 'local' => false, + * ] + * ); + * + * + * Volt Syntax: + * + * {{ image('img/bg.png') }} + * {{ image('img/photo.jpg', ['alt': 'Some Photo') }} + * {{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }} + * + */ + public function image(string $url = "", array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="check"] tag + * + * + * echo $tag->inputCheckbox( + * [ + * 'name' => 'terms, + * 'value' => 'Y', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_checkbox(['name': 'terms, 'value': 'Y']) }} + * + * + * @param array parameters + */ + public function inputCheckbox(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='color'] tag + */ + public function inputColor(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='date'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDate( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDate(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='datetime'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTime( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date_time(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDateTime(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='datetime-local'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTimeLocal( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDateTimeLocal(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='email'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputEmail( + * [ + * 'name' => 'email', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_email(['name': 'email']); + * + */ + public function inputEmail(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='file'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputFile( + * [ + * 'name' => 'file', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_file(['name': 'file']); + * + */ + public function inputFile(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='hidden'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputHidden( + * [ + * 'name' => 'my-field', + * 'value' => 'mike', + * ] + * ); + * + */ + public function inputHidden(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="image"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->inputImage( + * [ + * 'src' => '/img/button.png', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_image(['src': '/img/button.png']) }} + * + */ + public function inputImage(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='month'] tag + */ + public function inputMonth(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='number'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->numericField( + * [ + * 'name' => 'price', + * 'min' => '1', + * 'max' => '5', + * ] + * ); + * + */ + public function inputNumeric(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='password'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->passwordField( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * + */ + public function inputPassword(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="radio"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputRadio( + * [ + * 'name' => 'weather', + * 'value" => 'hot', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_radio(['name': 'weather', 'value": 'hot']) }} + * + */ + public function inputRadio(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='range'] tag + */ + public function inputRange(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='search'] tag + */ + public function inputSearch(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='tel'] tag + */ + public function inputTel(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='text'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputText( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * + */ + public function inputText(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='time'] tag + */ + public function inputTime(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='url'] tag + */ + public function inputUrl(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='week'] tag + */ + public function inputWeek(string $name, array $parameters = []) : string + { + } + + /** + * Builds a script[type="javascript"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->javascript( + * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', + * ['local' => false] + * ); + * echo $tag->javascript('javascript/jquery.js'); + * + * + * Volt syntax: + * + * {{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }} + * {{ javascript('javascript/jquery.js') }} + * + */ + public function javascript(string $url, array $parameters = []) : string + { + } + + /** + * Builds a HTML A tag using framework conventions + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->link('signup/register', 'Register Here!'); + * + * echo $tag->link( + * 'signup/register', + * 'Register Here!', + * [ + * 'class' => 'btn-primary', + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->linkTo( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * 'target' => '_new' + * ] + * ); + * + * + */ + public function link(string $url, string $text = "", array $parameters = []) : string + { + } + + /** + * Prepends a text to current document title + */ + public function prependTitle(array $title) : Tag + { + } + + /** + * Renders the title with title tags. The title is automaticall escaped + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->renderTitle(); // Hello World from Phalcon + * echo $tag->renderTitle(false); // World from Phalcon + * echo $tag->renderTitle(true, false); // Hello World + * echo $tag->renderTitle(false, false); // World + * + * + * + * {{ render_title() }} + * + */ + public function renderTitle(bool $prepend = true, bool $append = true) : string + { + } + + /** + * Builds a HTML input[type="reset"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->reset('Reset') + * + * + * Volt syntax: + * + * {{ reset('Save') }} + * + */ + public function reset(string $name, array $parameters = []) : string + { + } + + /** + * Builds a select element. It accepts an array or a resultset from + * a Phalcon\Mvc\Model + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Status...', + * ], + * [ + * 'A' => 'Active', + * 'I' => 'Inactive', + * ] + * ); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Type...', + * 'using' => [ + * 'id, + * 'name', + * ], + * ], + * Robots::find( + * [ + * 'conditions' => 'type = :type:', + * 'bind' => [ + * 'type' => 'mechanical', + * ] + * ] + * ) + * ); + * + * + * + * @param array parameters + * @param array data + */ + public function select(string $name, array $parameters = [], $data = null) : string + { + } + + /** + * Assigns default values to generated tags by helpers + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute('name', 'peter'); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * + */ + public function setAttribute(string $name, $value) : Tag + { + } + + /** + * Assigns default values to generated tags by helpers + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute( + * [ + * 'name' => 'peter', + * ] + * ); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * + */ + public function setAttributes(array $values, bool $merge = false) : Tag + { + } + + /** + * Sets the dependency injector + */ + public function setDI(DiInterface $container) : void + { + } + + /** + * Set the document type of content + * + * @param int doctype A valid doctype for the content + * + * @return + */ + public function setDocType(int $doctype) : Tag + { + } + + /** + * Set the title separator of view content + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag->setTitle('Phalcon Framework'); + * + */ + public function setTitle(string $title) : Tag + { + } + + /** + * Set the title separator of view content + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->setTitleSeparator('-'); + * + */ + public function setTitleSeparator(string $separator) : Tag + { + } + + /** + * Builds a LINK[rel="stylesheet"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->stylesheet( + * 'http://fonts.googleapis.com/css?family=Rosario', + * ['local' => false] + * ); + * echo $tag->stylesheet('css/style.css'); + * + * + * Volt syntax: + * + * {{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }} + * {{ stylesheet('css/style.css') }} + * + */ + public function stylesheet(string $url, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="submit"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + *public + * echo $tag->submit('Save') + * + * + * Volt syntax: + * + * {{ submit('Save') }} + * + */ + public function submit(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML TEXTAREA tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->textArea( + * 'comments', + * [ + * 'cols' => 10, + * 'rows' => 4, + * ] + * ); + * + * + * Volt syntax: + * + * {{ text_area('comments', ['cols': 10, 'rows': 4]) }} + * + */ + public function textArea(string $name, array $parameters = []) : string + { + } + + /** + * Returns the escaper service from the DI container + */ + private function getService(string $name) + { + } + + /** + * Renders the attributes of an HTML element + */ + private function renderAttributes(string $code, array $attributes) : string + { + } + + /** + * Returns the closing tag depending on the doctype + */ + private function renderCloseTag(bool $addEol = false) : string + { + } + + /** + * Builds `input` elements + */ + private function renderInput(string $type, string $name, array $parameters = []) : string + { + } + /** + * Builds INPUT tags that implements the checked attribute + */ + private function renderInputChecked(string $type, string $name, array $parameters = []) : string + { + } + + /** + * Generates the option values or optgroup from an array + */ + private function renderSelectArray(array $options, $value, string $closeOption) : string + { + } + + /** + * Generates the option values from a resultset + */ + private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption) : string + { + } +} diff --git a/src/Phalcon/html/Taglocator.php b/src/Phalcon/html/Taglocator.php new file mode 100644 index 00000000..2cebb261 --- /dev/null +++ b/src/Phalcon/html/Taglocator.php @@ -0,0 +1,14 @@ + + */ + protected $escaper; + + /** + * Constructor + */ + public function __construct(EscaperInterface $escaper) + { + } + + /** + * Keeps all the attributes sorted - same order all the tome + */ + protected function orderAttributes(array $overrides, array $attributes) : array + { + } + + /** + * Renders all the attributes + */ + protected function renderAttributes(array $attributes) : string + { + } + + /** + * Renders an element + */ + protected function renderElement(string $tag, string $text, array $attributes = []) + { + } + + /** + * Produces a self close tag i.e. + */ + protected function selfClose(string $tag, array $attributes = []) + { + } +} diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php new file mode 100644 index 00000000..b4ecb01d --- /dev/null +++ b/src/Phalcon/html/helper/Anchor.php @@ -0,0 +1,22 @@ + + */ + protected $formatter; + + /** + * Tells if there is an active transaction or not + * + * @var bool + */ + protected $inTransaction = false; + + /** + * Array with messages queued in the transaction + * + * @var array + */ + protected $queue = []; + + /** + * Destructor cleanup + */ + public function __destruct() + { + } + + /** + * Adds a message to the queue + */ + public function add(Item $item) : void + { + } + + /** + * Starts a transaction + */ + public function begin() : AdapterInterface + { + } + + /** + * Commits the internal transaction + */ + public function commit() : AdapterInterface + { + } + + public function getFormatter() : FormatterInterface + { + } + + /** + * Returns the whether the logger is currently in an active transaction or not + */ + public function inTransaction() : bool + { + } + + /** + * Processes the message in the adapter + */ + public function process(Item $item) : void + { + } + + /** + * Rollbacks the internal transaction + */ + public function rollback() : AdapterInterface + { + } + + /** + * Sets the message formatter + */ + public function setFormatter(FormatterInterface $formatter) : AdapterInterface + { + } +} diff --git a/src/Phalcon/logger/adapter/Adapterinterface.php b/src/Phalcon/logger/adapter/Adapterinterface.php new file mode 100644 index 00000000..2cd5f6c0 --- /dev/null +++ b/src/Phalcon/logger/adapter/Adapterinterface.php @@ -0,0 +1,54 @@ + + * $logger = new \Phalcon\Logger\Adapter\Noop(); + * + * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); + * $logger->error("This is another error"); + * + * $logger->close(); + * + */ +class Noop extends AbstractAdapter +{ + /** + * Closes the stream + */ + public function close() : bool + { + } + + /** + * Processes the message i.e. writes it to the file + */ + public function process(Item $item) : void + { + } +} diff --git a/src/Phalcon/logger/formatter/Abstractformatter.php b/src/Phalcon/logger/formatter/Abstractformatter.php new file mode 100644 index 00000000..1079548e --- /dev/null +++ b/src/Phalcon/logger/formatter/Abstractformatter.php @@ -0,0 +1,19 @@ + item + * + * @return string|array + */ + public function format(Item $item); +} + diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php new file mode 100644 index 00000000..b1978f3b --- /dev/null +++ b/src/Phalcon/messages/Exception.php @@ -0,0 +1,14 @@ + + * $messages->appendMessage( + * new \Phalcon\Messages\Message("This is a message") + * ); + * + */ + public function appendMessage(MessageInterface $message) + { + } + + /** + * Appends an array of messages to the collection + * + * + * $messages->appendMessages($messagesArray); + * + * + * @param \Phalcon\Messages\MessageInterface[] messages + */ + public function appendMessages($messages) + { + } + + /** + * Returns the number of messages in the list + */ + public function count() : int + { + } + + /** + * Returns the current message in the iterator + */ + public function current() : MessageInterface + { + } + + /** + * Filters the message collection by field name + */ + public function filter(string $fieldName) : array + { + } + + /** + * Returns serialised message objects as array for json_encode. Calls + * jsonSerialize on each object if present + * + * + * $data = $messages->jsonSerialize(); + * echo json_encode($data); + * + */ + public function jsonSerialize() : array + { + } + + /** + * Returns the current position/key in the iterator + */ + public function key() : int + { + } + + /** + * Moves the internal iteration pointer to the next position + */ + public function next() : void + { + } + + /** + * Checks if an index exists + * + * + * var_dump( + * isset($message["database"]) + * ); + * + * + * @param int index + */ + public function offsetExists($index) : boolean + { + } + + /** + * Gets an attribute a message using the array syntax + * + * + * print_r( + * $messages[0] + * ); + * + */ + public function offsetGet($index) { + } + + /** + * Sets an attribute using the array-syntax + * + * + * $messages[0] = new \Phalcon\Messages\Message("This is a message"); + * + * + * @param \Phalcon\Messages\Message message + */ + public function offsetSet($index, $message) : void + { + } + + /** + * Removes a message from the list + * + * + * unset($message["database"]); + * + */ + public function offsetUnset($index) : void + { + } + + /** + * Rewinds the internal iterator + */ + public function rewind() : void + { + } + + /** + * Check if the current message in the iterator is valid + */ + public function valid() : boolean + { + } +} diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php new file mode 100644 index 00000000..03fc7b1c --- /dev/null +++ b/src/Phalcon/paginator/Repository.php @@ -0,0 +1,110 @@ + + */ + private $container; + + /** + * @var |null + */ + private $handler = null; + + /** + * @var string + */ + private $name = ""; + + /** + * @var array + */ + private $options = []; + + /** + * @var string + */ + private $uniqueId = ""; + + /** + * Manager constructor. + * + * @param array options + */ + public function __construct(array $options = []) + { + } + + + /** + * Alias: Gets a session variable from an application context + */ + public function __get(string $key) { + } + + /** + * Alias: Check whether a session variable is set in an application context + */ + public function __isset(string $key) : bool + { + } + + /** + * Alias: Sets a session variable in an application context + */ + public function __set(string $key, $value) : void + { + } + + /** + * Alias: Removes a session variable from an application context + */ + public function __unset(string $key) + { + } + + /** + * Destroy/end a session + */ + public function destroy() : void + { + } + + /** + * Check whether the session has been started + */ + public function exists() : bool + { + } + + /** + * Gets a session variable from an application context + */ + public function get(string $key, $defaultValue = null, bool $remove = false) { + } + + /** + * Returns the DependencyInjector container + */ + public function getDI() : DiInterface + { + } + + /** + * Returns the stored session handler + */ + public function getHandler() : SessionHandlerInterface + { + } + + /** + * Returns the session id + */ + public function getId() : string + { + } + + /** + * Returns the name of the session + */ + public function getName() : string + { + } + + /** + * Check whether a session variable is set in an application context + */ + public function has(string $key) : bool + { + } + + /** + * Get internal options + */ + public function getOptions() : array + { + } + + /** + * Regenerates the session id using the handler. + */ + public function regenerateId($deleteOldSession = true) : ManagerInterface + { + } + + /** + * Registers a handler with the session + */ + public function registerHandler(SessionHandlerInterface $handler) : bool + { + } + + /** + * Removes a session variable from an application context + */ + public function remove(string $key) + { + } + + /** + * Sets a session variable in an application context + */ + public function set(string $key, $value) : void + { + } + + /** + * Sets the DependencyInjector container + */ + public function setDI(DiInterface $container) + { + } + + /** + * Set the handler for the session + */ + public function setHandler(SessionHandlerInterface $handler) : ManagerInterface + { + } + + /** + * Set session Id + */ + public function setId(string $id) : ManagerInterface + { + } + + /** + * Set the session name. Throw exception if the session has started + * and do not allow poop names + * + * @param string name + * + * @throws InvalidArgumentException + * + * @return Manager + */ + public function setName(string $name) : ManagerInterface + { + } + + /** + * Sets session's options + * + * @param array options + */ + public function setOptions(array $options) : void + { + } + + /** + * Starts the session (if headers are already sent the session will not be + * started) + */ + public function start() : bool + { + } + + /** + * Returns the status of the current session. + * + * @return int + */ + public function status() : int + { + } + + /** + * Returns the key prefixed + */ + private function getUniqueKey(string $key) : string + { + } +} diff --git a/src/Phalcon/session/Managerinterface.php b/src/Phalcon/session/Managerinterface.php new file mode 100644 index 00000000..0d681704 --- /dev/null +++ b/src/Phalcon/session/Managerinterface.php @@ -0,0 +1,139 @@ + + * setHandler(new Noop()); + * + */ +class Noop implements SessionHandlerInterface +{ + /** + * The connection of some adapters + */ + protected $connection; + + /** + * Session options + * + * @var array + */ + protected $options = []; + + /** + * Session prefix + * + * @var string + */ + protected $prefix = ""; + + /** + * Time To Live + * + * @var int + */ + protected $ttl = 8600; + + /** + * Constructor + */ + public function __construct(array $options = []) + { + } + + /** + * Close + */ + public function close() : bool + { + } + + /** + * Destroy + */ + public function destroy($id) : bool + { + } + + /** + * Garbage Collector + */ + public function gc($maxlifetime) : bool + { + } + + /** + * Read + */ + public function read($id) : string + { + } + + /** + * Open + */ + public function open($savePath, $sessionName) : bool + { + } + + /** + * Write + */ + public function write($id, $data) : bool + { + } + + /** + * Helper method to get the name prefixed + */ + protected function getPrefixedName($name) : string + { + } +} diff --git a/src/Phalcon/url/Exception.php b/src/Phalcon/url/Exception.php new file mode 100644 index 00000000..806bb1bb --- /dev/null +++ b/src/Phalcon/url/Exception.php @@ -0,0 +1,13 @@ + + * use Phalcon\Validation\Validator\Ip as IpValidator; + * + * $validator->add( + * "ip_address", + * new IpValidator( + * [ + * "message" => ":field must contain only ip addresses", + * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified + * "allowReserved" => false, // False if not specified. Ignored for v6 + * "allowPrivate" => false, // False if not specified + * "allowEmpty" => false, + * ] + * ) + * ); + * + * $validator->add( + * [ + * "source_address", + * "destination_address", + * ], + * new IpValidator( + * [ + * "message" => [ + * "source_address" => "source_address must contain only ip addresses", + * "destination_address" => "destination_address must contain only ip addresses", + * ], + * "version" => [ + * "source_address" => Ip::VERSION_4 | IP::VERSION_6, + * "destination_address" => Ip::VERSION_4, + * ], + * "allowReserved" => [ + * "source_address" => false, + * "destination_address" => true, + * ], + * "allowPrivate" => [ + * "source_address" => false, + * "destination_address" => true, + * ], + * "allowEmpty" => [ + * "source_address" => false, + * "destination_address" => true, + * ], + * ] + * ) + * ); + * + */ +class Ip extends Validator +{ + const VERSION_4 = FILTER_FLAG_IPV4; + const VERSION_6 = FILTER_FLAG_IPV6; + + /** + * Executes the validation + */ + public function validate(Validation $validation, $field) : bool + { + } +} From 0fd634a2329a3a07b4f0606d3fac4fc58b626360 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 13 May 2019 14:49:22 +0300 Subject: [PATCH 02/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56e73162..89ac6bb9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Phalcon IDE Stubs +# Phalcon IDE Stubs v4 This repo provide the most complete Phalcon Framework stubs which enables autocompletion in modern IDEs. From 3947bfd982694573de132063a64cdf8f4c03eec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20SCHNEKENBURGER?= Date: Mon, 24 Jun 2019 21:27:40 +0200 Subject: [PATCH 03/25] Phalcon 4.x required php >= 7.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ca80d5cb..2ef2e113 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,6 @@ "forum": "https://forum.phalconphp.com/" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" } } From b2f4b0af5879a614e8764be7dd294e5a32d5a2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20SCHNEKENBURGER?= Date: Mon, 24 Jun 2019 21:29:20 +0200 Subject: [PATCH 04/25] Update Interface with right type hint & update doc bloc --- src/Phalcon/di/InjectionAwareInterface.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index 87817d1e..84b720ef 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -14,14 +14,15 @@ interface InjectionAwareInterface * Sets the dependency injector * * @param \Phalcon\DiInterface $dependencyInjector + * @return void */ - public function setDI(\Phalcon\DiInterface $dependencyInjector); + public function setDI(\Phalcon\DiInterface $dependencyInjector) : void; /** * Returns the internal dependency injector * - * @return null|\Phalcon\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(); + public function getDI() : \Phalcon\DiInterface; } From 1372048f2961ab03bed930d5f8574a3cdcbce4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20SCHNEKENBURGER?= Date: Mon, 24 Jun 2019 22:17:13 +0200 Subject: [PATCH 05/25] Implement IDE Stubs 4.x & delete old resources --- src/Phalcon/acl/Adapter.php | 35 +-- src/Phalcon/acl/AdapterInterface.php | 181 ++++++-------- src/Phalcon/acl/Component.php | 28 +-- src/Phalcon/acl/Resource.php | 56 ----- src/Phalcon/acl/ResourceAware.php | 20 -- src/Phalcon/acl/ResourceInterface.php | 35 --- src/Phalcon/acl/Role.php | 8 +- src/Phalcon/acl/RoleAware.php | 3 +- src/Phalcon/acl/RoleInterface.php | 6 +- src/Phalcon/acl/adapter/Memory.php | 341 +++++++++++++------------- 10 files changed, 290 insertions(+), 423 deletions(-) delete mode 100644 src/Phalcon/acl/Resource.php delete mode 100644 src/Phalcon/acl/ResourceAware.php delete mode 100644 src/Phalcon/acl/ResourceInterface.php diff --git a/src/Phalcon/acl/Adapter.php b/src/Phalcon/acl/Adapter.php index 087a0ff2..a2997aab 100644 --- a/src/Phalcon/acl/Adapter.php +++ b/src/Phalcon/acl/Adapter.php @@ -2,54 +2,57 @@ namespace Phalcon\Acl; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Phalcon\Acl\Adapter * * Adapter for Phalcon\Acl adapters */ -abstract class Adapter implements \Phalcon\Acl\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class Adapter implements AdapterInterface, EventsAwareInterface { /** * Events manager * * @var mixed */ - protected $_eventsManager; + protected $eventsManager; /** * Default access * * @var bool */ - protected $_defaultAccess = true; + protected $defaultAccess = true; /** * Access Granted * * @var bool */ - protected $_accessGranted = false; + protected $accessGranted = false; /** * Role which the list is checking if it's allowed to certain resource/access * * @var string */ - protected $_activeRole; + protected $activeRole; /** * Resource which the list is checking if some role can access it * * @var string */ - protected $_activeResource; + protected $activeComponent; /** * Active access which the list is checking if some role can access it * * @var string */ - protected $_activeAccess; + protected $activeAccess; /** @@ -57,48 +60,48 @@ abstract class Adapter implements \Phalcon\Acl\AdapterInterface, \Phalcon\Events * * @return string */ - public function getActiveRole() {} + public function getActiveRole() : string {} /** * Resource which the list is checking if some role can access it * * @return string */ - public function getActiveResource() {} + public function getActiveComponents() {} /** * Active access which the list is checking if some role can access it * * @return string */ - public function getActiveAccess() {} + public function getActiveAccess() : string {} /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(ManagerInterface $eventsManager) {} /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ - public function getEventsManager() {} + public function getEventsManager() : ManagerInterface {} /** * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) * * @param int $defaultAccess */ - public function setDefaultAction($defaultAccess) {} + public function setDefaultAction(int $defaultAccess) : void {} /** * Returns the default ACL access level * * @return int */ - public function getDefaultAction() {} + public function getDefaultAction() : int {} } diff --git a/src/Phalcon/acl/AdapterInterface.php b/src/Phalcon/acl/AdapterInterface.php index c3a95bb5..51eb3540 100644 --- a/src/Phalcon/acl/AdapterInterface.php +++ b/src/Phalcon/acl/AdapterInterface.php @@ -11,161 +11,142 @@ interface AdapterInterface { /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * - * @param int $defaultAccess + * Do a role inherit from another existing role + * @param string $roleName + * @param $roleToInherit + * @return bool */ - public function setDefaultAction($defaultAccess); + public function addInherit(string $roleName, $roleToInherit) : bool; /** - * Returns the default ACL access level - * - * @return int + * Adds a role to the ACL list. Second parameter lets to inherit access data + * from other existing role + * @param $role + * @param null $accessInherits + * @return bool */ - public function getDefaultAction(); + public function addRole($role, $accessInherits = null) : bool; /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * for no arguments provided in isAllowed action if there exists func for accessKey + * Adds a component to the ACL list * - * @param int $defaultAccess + * Access names can be a particular action, by example + * search, update, delete, etc or a list of them + * @param $componentObject + * @param $accessList + * @return bool */ - public function setNoArgumentsDefaultAction($defaultAccess); + public function addComponent($componentObject, $accessList) : bool; /** - * Returns the default ACL access level for no arguments provided in - * isAllowed action if there exists func for accessKey - * - * @return int + * Adds access to components + * @param $componentName + * @param $accessList + * @return bool */ - public function getNoArgumentsDefaultAction(); + public function addComponentAccess(string $componentName, $accessList) : bool; /** - * Adds a role to the ACL list. Second parameter lets to inherit access data from other existing role - * - * @param mixed $role - * @param mixed $accessInherits - * @return bool + * Allow access to a role on a component + * @param $roleName + * @param $componentName + * @param $access + * @param null $func */ - public function addRole($role, $accessInherits = null); + public function allow(string $roleName, string $componentName, $access, $func = null) : void; /** - * Do a role inherit from another existing role - * - * @param string $roleName - * @param mixed $roleToInherit - * @return bool + * Deny access to a role on a component + * @param $roleName + * @param $componentName + * @param $access + * @param null $func */ - public function addInherit($roleName, $roleToInherit); + public function deny(string $roleName, string $componentName, $access, $func = null) : void; /** - * Check whether role exist in the roles list - * - * @param string $roleName - * @return bool + * Removes an access from a component + * @param string $componentName + * @param $accessList */ - public function isRole($roleName); + public function dropComponentAccess(string $componentName, $accessList) : void; /** - * Check whether resource exist in the resources list - * - * @param string $resourceName - * @return bool + * Returns the access which the list is checking if some role can access it */ - public function isResource($resourceName); + public function getActiveAccess() : string; /** - * Adds a resource to the ACL list - * - * Access names can be a particular action, by example - * search, update, delete, etc or a list of them - * - * @param mixed $resourceObject - * @param mixed $accessList - * @return bool + * Returns the role which the list is checking if it's allowed to certain + * component/access */ - public function addResource($resourceObject, $accessList); + public function getActiveRole() : string; /** - * Adds access to resources - * - * @param string $resourceName - * @param mixed $accessList + * Returns the component which the list is checking if some role can access + * it */ - public function addResourceAccess($resourceName, $accessList); + public function getActiveComponent() : string; /** - * Removes an access from a resource - * - * @param string $resourceName - * @param mixed $accessList + * Returns the default ACL access level */ - public function dropResourceAccess($resourceName, $accessList); + public function getDefaultAction() : int; /** - * Allow access to a role on a resource - * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * Returns the default ACL access level for no arguments provided in + * isAllowed action if there exists func for accessKey */ - public function allow($roleName, $resourceName, $access, $func = null); + public function getNoArgumentsDefaultAction() : int; /** - * Deny access to a role on a resource - * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * Return an array with every role registered in the list + * @return RoleInterface[] */ - public function deny($roleName, $resourceName, $access, $func = null); + public function getRoles() : array; /** - * Check whether a role is allowed to access an action from a resource - * - * @param mixed $roleName - * @param mixed $resourceName - * @param string $access - * @param array $parameters - * @return bool + * Return an array with every component registered in the list + * return ComponentInterface[] */ - public function isAllowed($roleName, $resourceName, $access, array $parameters = null); + public function getComponents() : array; /** - * Returns the role which the list is checking if it's allowed to certain resource/access - * - * @return string + * Check whether a role is allowed to access an action from a component + * @param $roleName + * @param $componentName + * @param string $access + * @param array|null $parameters + * @return bool */ - public function getActiveRole(); + public function isAllowed($roleName, $componentName, string $access, ?array $parameters = null) : bool; /** - * Returns the resource which the list is checking if some role can access it - * - * @return string + * Check whether component exist in the components list + * @param string $componentName + * @return bool */ - public function getActiveResource(); + public function isComponent(string $componentName) : bool; /** - * Returns the access which the list is checking if some role can access it - * - * @return string + * Check whether role exist in the roles list + * @param string $roleName + * @return bool */ - public function getActiveAccess(); + public function isRole(string $roleName) : bool; /** - * Return an array with every role registered in the list - * - * @return RoleInterface[] + * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) + * @param int $defaultAccess */ - public function getRoles(); + public function setDefaultAction(int $defaultAccess) : void; /** - * Return an array with every resource registered in the list - * - * @return ResourceInterface[] + * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) + * for no arguments provided in isAllowed action if there exists func for + * accessKey + * @param int $defaultAccess */ - public function getResources(); + public function setNoArgumentsDefaultAction(int $defaultAccess) : void; } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 59ca67cf..0730e294 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -11,7 +11,6 @@ */ class Component implements ComponentInterface { - /** * Component description * @var string @@ -24,34 +23,25 @@ class Component implements ComponentInterface */ private $name; - /** - * Phalcon\Acl\Component constructor - */ - public function __construct(string $name, string $description = null) - { - } + /** + * Phalcon\Acl\Component constructor + * @param string $name + * @param string|null $description + */ + public function __construct(string $name, string $description = null) {} /** * Returns component description */ - public function getDescription(): string - { - // TODO: Implement getDescription() method. - } + public function getDescription(): string {} /** * Returns the component name */ - public function getName(): string - { - // TODO: Implement getName() method. - } + public function getName(): string {} /** * Magic method __toString */ - public function __toString(): string - { - // TODO: Implement __toString() method. - } + public function __toString(): string {} } diff --git a/src/Phalcon/acl/Resource.php b/src/Phalcon/acl/Resource.php deleted file mode 100644 index f1e38660..00000000 --- a/src/Phalcon/acl/Resource.php +++ /dev/null @@ -1,56 +0,0 @@ - + *```php * $acl = new \Phalcon\Acl\Adapter\Memory(); * * $acl->setDefaultAction( @@ -23,335 +26,337 @@ * $acl->addRole($role); * } * - * // Private area resources - * $privateResources = [ + * // Private area components + * $privateComponents = [ * "companies" => ["index", "search", "new", "edit", "save", "create", "delete"], * "products" => ["index", "search", "new", "edit", "save", "create", "delete"], * "invoices" => ["index", "profile"], * ]; * - * foreach ($privateResources as $resourceName => $actions) { - * $acl->addResource( - * new \Phalcon\Acl\Resource($resourceName), + * foreach ($privateComponents as $componentName => $actions) { + * $acl->addComponent( + * new \Phalcon\Acl\Component($componentName), * $actions * ); * } * - * // Public area resources - * $publicResources = [ + * // Public area components + * $publicComponents = [ * "index" => ["index"], * "about" => ["index"], * "session" => ["index", "register", "start", "end"], * "contact" => ["index", "send"], * ]; * - * foreach ($publicResources as $resourceName => $actions) { - * $acl->addResource( - * new \Phalcon\Acl\Resource($resourceName), + * foreach ($publicComponents as $componentName => $actions) { + * $acl->addComponent( + * new \Phalcon\Acl\Component($componentName), * $actions * ); * } * * // Grant access to public areas to both users and guests * foreach ($roles as $role){ - * foreach ($publicResources as $resource => $actions) { - * $acl->allow($role->getName(), $resource, ""); + * foreach ($publicComponents as $component => $actions) { + * $acl->allow($role->getName(), $component, "*"); * } * } * * // Grant access to private area to role Users - * foreach ($privateResources as $resource => $actions) { + * foreach ($privateComponents as $component => $actions) { * foreach ($actions as $action) { - * $acl->allow("Users", $resource, $action); + * $acl->allow("Users", $component, $action); * } * } - * + *``` */ -class Memory extends \Phalcon\Acl\Adapter +class Memory extends Adapter { /** - * Roles Names + * Access * * @var mixed */ - protected $_rolesNames; + protected $access; /** - * Roles + * Access List * * @var mixed */ - protected $_roles; + protected $accessList; - /** - * Resource Names - * - * @var mixed - */ - protected $_resourcesNames; + /** + * Returns latest function used to acquire access + * + * @var mixed + */ + protected $activeFunction; /** - * Resources + * Returns number of additional arguments(excluding role and resource) for active function * - * @var mixed + * @var int */ - protected $_resources; + protected $activeFunctionCustomArgumentsCount; /** - * Access + * Returns latest key used to acquire access * - * @var mixed + * @var string|null */ - protected $_access; + protected $activeKey; /** - * Role Inherits + * Components * * @var mixed */ - protected $_roleInherits; + protected $components; /** - * Access List + * Component Names * * @var mixed */ - protected $_accessList; + protected $componentsNames; /** * Function List * * @var mixed */ - protected $_func; + protected $func; /** * Default action for no arguments is allow * * @var mixed */ - protected $_noArgumentsDefaultAction = Acl::ALLOW; - - - /** - * Phalcon\Acl\Adapter\Memory constructor - */ - public function __construct() {} + protected $noArgumentsDefaultAction = Acl::DENY; /** - * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role - * - * Example: - * - * $acl->addRole( - * new Phalcon\Acl\Role("administrator"), - * "consultant" - * ); - * - * $acl->addRole("administrator", "consultant"); - * + * Roles * - * @param RoleInterface|string $role - * @param array|string $accessInherits - * @return bool + * @var mixed */ - public function addRole($role, $accessInherits = null) {} + protected $roles; /** - * Do a role inherit from another existing role + * Role Inherits * - * @param string $roleName - * @param mixed $roleToInherit - * @return bool + * @var mixed */ - public function addInherit($roleName, $roleToInherit) {} + protected $roleInherits; /** - * Check whether role exist in the roles list + * Roles Names * - * @param string $roleName - * @return bool + * @var mixed */ - public function isRole($roleName) {} + protected $rolesNames; + /** - * Check whether resource exist in the resources list - * - * @param string $resourceName - * @return bool + * Phalcon\Acl\Adapter\Memory constructor */ - public function isResource($resourceName) {} + public function __construct() {} /** - * Adds a resource to the ACL list + * Adds a component to the ACL list * * Access names can be a particular action, by example * search, update, delete, etc or a list of them * * Example: - * - * // Add a resource to the the list allowing access to an action - * $acl->addResource( - * new Phalcon\Acl\Resource("customers"), + * ```php + * // Add a component to the the list allowing access to an action + * $acl->addComponent( + * new Phalcon\Acl\Component("customers"), * "search" * ); * - * $acl->addResource("customers", "search"); + * $acl->addComponent("customers", "search"); * - * // Add a resource with an access list - * $acl->addResource( - * new Phalcon\Acl\Resource("customers"), + * // Add a component with an access list + * $acl->addComponent( + * new Phalcon\Acl\Component("customers"), * [ * "create", * "search", * ] * ); * - * $acl->addResource( + * $acl->addComponent( * "customers", * [ * "create", * "search", * ] * ); - * - * - * @param \Phalcon\Acl\Resource|string $resourceValue - * @param array|string $accessList + * ``` + * @param $componentValue + * @param $accessList * @return bool */ - public function addResource($resourceValue, $accessList) {} + public function addComponent($componentValue, $accessList) : bool {} /** - * Adds access to resources + * Adds access to components * - * @param string $resourceName - * @param array|string $accessList + * @param $componentName + * @param $accessList * @return bool */ - public function addResourceAccess($resourceName, $accessList) {} + public function addComponentAccess(string $componentName, $accessList) : bool {} /** - * Removes an access from a resource + * Do a role inherit from another existing role + * + * ```php + * $acl->addRole("administrator", "consultant"); + * $acl->addRole("administrator", ["consultant", "consultant2"]); + * ``` * - * @param string $resourceName - * @param array|string $accessList + * @param string $roleName + * @param $roleToInherits + * @return bool */ - public function dropResourceAccess($resourceName, $accessList) {} + public function addInherit(string $roleName, $roleToInherits) : bool {} /** - * Checks if a role has access to a resource + * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $action - * @param mixed $func + * ```php + * $acl->addRole( + * new Phalcon\Acl\Role("administrator"), + * "consultant" + * ); + * + * $acl->addRole("administrator", "consultant"); + * $acl->addRole("administrator", ["consultant", "consultant2"]); + * ``` + * + * @param $role + * @param null $accessInherits + * @return bool */ - protected function _allowOrDeny($roleName, $resourceName, $access, $action, $func = null) {} + public function addRole($role, $accessInherits = null) : bool {} /** - * Allow access to a role on a resource - * - * You can use '' as wildcard + * Allow access to a role on a component. You can use `*` as wildcard * - * Example: - * - * //Allow access to guests to search on customers + * ```php + * // Allow access to guests to search on customers * $acl->allow("guests", "customers", "search"); * - * //Allow access to guests to search or create on customers + * // Allow access to guests to search or create on customers * $acl->allow("guests", "customers", ["search", "create"]); * - * //Allow access to any role to browse on products - * $acl->allow("", "products", "browse"); + * // Allow access to any role to browse on products + * $acl->allow("*", "products", "browse"); * - * //Allow access to any role to browse on any resource - * $acl->allow("", "", "browse"); - * + * // Allow access to any role to browse on any component + * $acl->allow("*", "*", "browse"); * * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * @param string $componentName + * @param $access + * @param null $func */ - public function allow($roleName, $resourceName, $access, $func = null) {} + public function allow(string $roleName, string $componentName, $access, $func = null) : void {} /** - * Deny access to a role on a resource - * - * You can use '' as wildcard + * Deny access to a role on a component. You can use `*` as wildcard * - * Example: - * - * //Deny access to guests to search on customers + * ```php + * // Deny access to guests to search on customers * $acl->deny("guests", "customers", "search"); * - * //Deny access to guests to search or create on customers + * // Deny access to guests to search or create on customers * $acl->deny("guests", "customers", ["search", "create"]); * - * //Deny access to any role to browse on products - * $acl->deny("", "products", "browse"); + * // Deny access to any role to browse on products + * $acl->deny("*", "products", "browse"); * - * //Deny access to any role to browse on any resource - * $acl->deny("", "", "browse"); - * + * // Deny access to any role to browse on any component + * $acl->deny("*", "*", "browse"); + * ``` * * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * @param string $componentName + * @param $access + * @param null $func */ - public function deny($roleName, $resourceName, $access, $func = null) {} + public function deny(string $roleName, string $componentName, $access, $func = null) : void {} /** - * Check whether a role is allowed to access an action from a resource - * - * - * //Does andres have access to the customers resource to create? - * $acl->isAllowed("andres", "Products", "create"); - * - * //Do guests have access to any resource to edit? - * $acl->isAllowed("guests", "", "edit"); - * + * Removes an access from a component + * @param string $componentName + * @param $accessList + */ + public function dropComponentAccess(string $componentName, $accessList) : void {} + + /** + * Returns the default ACL access level for no arguments provided in + * `isAllowed` action if a `func` (callable) exists for `accessKey` + */ + public function getNoArgumentsDefaultAction() : int {} + + /** + * Return an array with every role registered in the list * - * @param RoleInterface|RoleAware|string $roleName - * @param ResourceInterface|ResourceAware|string $resourceName - * @param string $access - * @param array $parameters - * @return bool + * @return RoleInterface[] */ - public function isAllowed($roleName, $resourceName, $access, array $parameters = null) {} + public function getRoles() : array {} /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * for no arguments provided in isAllowed action if there exists func for - * accessKey + * Return an array with every component registered in the list * - * @param int $defaultAccess + * @return ComponentInterface[] */ - public function setNoArgumentsDefaultAction($defaultAccess) {} + public function getComponents() : array {} /** - * Returns the default ACL access level for no arguments provided in - * isAllowed action if there exists func for accessKey + * Check whether a role is allowed to access an action from a component + * + * ```php + * // Does andres have access to the customers component to create? + * $acl->isAllowed("andres", "Products", "create"); * - * @return int + * // Do guests have access to any component to edit? + * $acl->isAllowed("guests", "*", "edit"); + * ``` + * @param $roleName + * @param $componentName + * @param $access + * @param array|null $parameters + * @return bool */ - public function getNoArgumentsDefaultAction() {} + public function isAllowed($roleName, $componentName, $access, ?array $parameters = null) : bool {} /** - * Return an array with every role registered in the list + * Check whether role exist in the roles list * - * @return \Phalcon\Acl\RoleInterface[] + * @param string $roleName + * @return bool */ - public function getRoles() {} + public function isRole(string $roleName) : bool {} /** - * Return an array with every resource registered in the list + * Check whether component exist in the components list * - * @return \Phalcon\Acl\ResourceInterface[] + * @param string $componentName + * @return bool */ - public function getResources() {} + public function isComponent(string $componentName) : bool {} + /** + * Sets the default access level (`Phalcon\Acl::ALLOW` or `Phalcon\Acl::DENY`) + * for no arguments provided in isAllowed action if there exists func for + * accessKey + * + * @param int $defaultAccess + */ + public function setNoArgumentsDefaultAction(int $defaultAccess) : void {} } From 78c6884d73ab30b534174e418f117d62b2043eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ke=CC=81vin=20SCHNEKENBURGER?= Date: Mon, 24 Jun 2019 22:17:13 +0200 Subject: [PATCH 06/25] Implement IDE Stubs 4.x & delete old resources --- src/Phalcon/acl/Adapter.php | 35 +-- src/Phalcon/acl/AdapterInterface.php | 181 ++++++-------- src/Phalcon/acl/Component.php | 28 +-- src/Phalcon/acl/Resource.php | 56 ----- src/Phalcon/acl/ResourceAware.php | 20 -- src/Phalcon/acl/ResourceInterface.php | 35 --- src/Phalcon/acl/Role.php | 8 +- src/Phalcon/acl/RoleAware.php | 3 +- src/Phalcon/acl/RoleInterface.php | 6 +- src/Phalcon/acl/adapter/Memory.php | 341 +++++++++++++------------- 10 files changed, 290 insertions(+), 423 deletions(-) delete mode 100644 src/Phalcon/acl/Resource.php delete mode 100644 src/Phalcon/acl/ResourceAware.php delete mode 100644 src/Phalcon/acl/ResourceInterface.php diff --git a/src/Phalcon/acl/Adapter.php b/src/Phalcon/acl/Adapter.php index 087a0ff2..a2997aab 100644 --- a/src/Phalcon/acl/Adapter.php +++ b/src/Phalcon/acl/Adapter.php @@ -2,54 +2,57 @@ namespace Phalcon\Acl; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Phalcon\Acl\Adapter * * Adapter for Phalcon\Acl adapters */ -abstract class Adapter implements \Phalcon\Acl\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class Adapter implements AdapterInterface, EventsAwareInterface { /** * Events manager * * @var mixed */ - protected $_eventsManager; + protected $eventsManager; /** * Default access * * @var bool */ - protected $_defaultAccess = true; + protected $defaultAccess = true; /** * Access Granted * * @var bool */ - protected $_accessGranted = false; + protected $accessGranted = false; /** * Role which the list is checking if it's allowed to certain resource/access * * @var string */ - protected $_activeRole; + protected $activeRole; /** * Resource which the list is checking if some role can access it * * @var string */ - protected $_activeResource; + protected $activeComponent; /** * Active access which the list is checking if some role can access it * * @var string */ - protected $_activeAccess; + protected $activeAccess; /** @@ -57,48 +60,48 @@ abstract class Adapter implements \Phalcon\Acl\AdapterInterface, \Phalcon\Events * * @return string */ - public function getActiveRole() {} + public function getActiveRole() : string {} /** * Resource which the list is checking if some role can access it * * @return string */ - public function getActiveResource() {} + public function getActiveComponents() {} /** * Active access which the list is checking if some role can access it * * @return string */ - public function getActiveAccess() {} + public function getActiveAccess() : string {} /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(ManagerInterface $eventsManager) {} /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ - public function getEventsManager() {} + public function getEventsManager() : ManagerInterface {} /** * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) * * @param int $defaultAccess */ - public function setDefaultAction($defaultAccess) {} + public function setDefaultAction(int $defaultAccess) : void {} /** * Returns the default ACL access level * * @return int */ - public function getDefaultAction() {} + public function getDefaultAction() : int {} } diff --git a/src/Phalcon/acl/AdapterInterface.php b/src/Phalcon/acl/AdapterInterface.php index c3a95bb5..51eb3540 100644 --- a/src/Phalcon/acl/AdapterInterface.php +++ b/src/Phalcon/acl/AdapterInterface.php @@ -11,161 +11,142 @@ interface AdapterInterface { /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * - * @param int $defaultAccess + * Do a role inherit from another existing role + * @param string $roleName + * @param $roleToInherit + * @return bool */ - public function setDefaultAction($defaultAccess); + public function addInherit(string $roleName, $roleToInherit) : bool; /** - * Returns the default ACL access level - * - * @return int + * Adds a role to the ACL list. Second parameter lets to inherit access data + * from other existing role + * @param $role + * @param null $accessInherits + * @return bool */ - public function getDefaultAction(); + public function addRole($role, $accessInherits = null) : bool; /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * for no arguments provided in isAllowed action if there exists func for accessKey + * Adds a component to the ACL list * - * @param int $defaultAccess + * Access names can be a particular action, by example + * search, update, delete, etc or a list of them + * @param $componentObject + * @param $accessList + * @return bool */ - public function setNoArgumentsDefaultAction($defaultAccess); + public function addComponent($componentObject, $accessList) : bool; /** - * Returns the default ACL access level for no arguments provided in - * isAllowed action if there exists func for accessKey - * - * @return int + * Adds access to components + * @param $componentName + * @param $accessList + * @return bool */ - public function getNoArgumentsDefaultAction(); + public function addComponentAccess(string $componentName, $accessList) : bool; /** - * Adds a role to the ACL list. Second parameter lets to inherit access data from other existing role - * - * @param mixed $role - * @param mixed $accessInherits - * @return bool + * Allow access to a role on a component + * @param $roleName + * @param $componentName + * @param $access + * @param null $func */ - public function addRole($role, $accessInherits = null); + public function allow(string $roleName, string $componentName, $access, $func = null) : void; /** - * Do a role inherit from another existing role - * - * @param string $roleName - * @param mixed $roleToInherit - * @return bool + * Deny access to a role on a component + * @param $roleName + * @param $componentName + * @param $access + * @param null $func */ - public function addInherit($roleName, $roleToInherit); + public function deny(string $roleName, string $componentName, $access, $func = null) : void; /** - * Check whether role exist in the roles list - * - * @param string $roleName - * @return bool + * Removes an access from a component + * @param string $componentName + * @param $accessList */ - public function isRole($roleName); + public function dropComponentAccess(string $componentName, $accessList) : void; /** - * Check whether resource exist in the resources list - * - * @param string $resourceName - * @return bool + * Returns the access which the list is checking if some role can access it */ - public function isResource($resourceName); + public function getActiveAccess() : string; /** - * Adds a resource to the ACL list - * - * Access names can be a particular action, by example - * search, update, delete, etc or a list of them - * - * @param mixed $resourceObject - * @param mixed $accessList - * @return bool + * Returns the role which the list is checking if it's allowed to certain + * component/access */ - public function addResource($resourceObject, $accessList); + public function getActiveRole() : string; /** - * Adds access to resources - * - * @param string $resourceName - * @param mixed $accessList + * Returns the component which the list is checking if some role can access + * it */ - public function addResourceAccess($resourceName, $accessList); + public function getActiveComponent() : string; /** - * Removes an access from a resource - * - * @param string $resourceName - * @param mixed $accessList + * Returns the default ACL access level */ - public function dropResourceAccess($resourceName, $accessList); + public function getDefaultAction() : int; /** - * Allow access to a role on a resource - * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * Returns the default ACL access level for no arguments provided in + * isAllowed action if there exists func for accessKey */ - public function allow($roleName, $resourceName, $access, $func = null); + public function getNoArgumentsDefaultAction() : int; /** - * Deny access to a role on a resource - * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * Return an array with every role registered in the list + * @return RoleInterface[] */ - public function deny($roleName, $resourceName, $access, $func = null); + public function getRoles() : array; /** - * Check whether a role is allowed to access an action from a resource - * - * @param mixed $roleName - * @param mixed $resourceName - * @param string $access - * @param array $parameters - * @return bool + * Return an array with every component registered in the list + * return ComponentInterface[] */ - public function isAllowed($roleName, $resourceName, $access, array $parameters = null); + public function getComponents() : array; /** - * Returns the role which the list is checking if it's allowed to certain resource/access - * - * @return string + * Check whether a role is allowed to access an action from a component + * @param $roleName + * @param $componentName + * @param string $access + * @param array|null $parameters + * @return bool */ - public function getActiveRole(); + public function isAllowed($roleName, $componentName, string $access, ?array $parameters = null) : bool; /** - * Returns the resource which the list is checking if some role can access it - * - * @return string + * Check whether component exist in the components list + * @param string $componentName + * @return bool */ - public function getActiveResource(); + public function isComponent(string $componentName) : bool; /** - * Returns the access which the list is checking if some role can access it - * - * @return string + * Check whether role exist in the roles list + * @param string $roleName + * @return bool */ - public function getActiveAccess(); + public function isRole(string $roleName) : bool; /** - * Return an array with every role registered in the list - * - * @return RoleInterface[] + * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) + * @param int $defaultAccess */ - public function getRoles(); + public function setDefaultAction(int $defaultAccess) : void; /** - * Return an array with every resource registered in the list - * - * @return ResourceInterface[] + * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) + * for no arguments provided in isAllowed action if there exists func for + * accessKey + * @param int $defaultAccess */ - public function getResources(); + public function setNoArgumentsDefaultAction(int $defaultAccess) : void; } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 59ca67cf..0730e294 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -11,7 +11,6 @@ */ class Component implements ComponentInterface { - /** * Component description * @var string @@ -24,34 +23,25 @@ class Component implements ComponentInterface */ private $name; - /** - * Phalcon\Acl\Component constructor - */ - public function __construct(string $name, string $description = null) - { - } + /** + * Phalcon\Acl\Component constructor + * @param string $name + * @param string|null $description + */ + public function __construct(string $name, string $description = null) {} /** * Returns component description */ - public function getDescription(): string - { - // TODO: Implement getDescription() method. - } + public function getDescription(): string {} /** * Returns the component name */ - public function getName(): string - { - // TODO: Implement getName() method. - } + public function getName(): string {} /** * Magic method __toString */ - public function __toString(): string - { - // TODO: Implement __toString() method. - } + public function __toString(): string {} } diff --git a/src/Phalcon/acl/Resource.php b/src/Phalcon/acl/Resource.php deleted file mode 100644 index f1e38660..00000000 --- a/src/Phalcon/acl/Resource.php +++ /dev/null @@ -1,56 +0,0 @@ - + *```php * $acl = new \Phalcon\Acl\Adapter\Memory(); * * $acl->setDefaultAction( @@ -23,335 +26,337 @@ * $acl->addRole($role); * } * - * // Private area resources - * $privateResources = [ + * // Private area components + * $privateComponents = [ * "companies" => ["index", "search", "new", "edit", "save", "create", "delete"], * "products" => ["index", "search", "new", "edit", "save", "create", "delete"], * "invoices" => ["index", "profile"], * ]; * - * foreach ($privateResources as $resourceName => $actions) { - * $acl->addResource( - * new \Phalcon\Acl\Resource($resourceName), + * foreach ($privateComponents as $componentName => $actions) { + * $acl->addComponent( + * new \Phalcon\Acl\Component($componentName), * $actions * ); * } * - * // Public area resources - * $publicResources = [ + * // Public area components + * $publicComponents = [ * "index" => ["index"], * "about" => ["index"], * "session" => ["index", "register", "start", "end"], * "contact" => ["index", "send"], * ]; * - * foreach ($publicResources as $resourceName => $actions) { - * $acl->addResource( - * new \Phalcon\Acl\Resource($resourceName), + * foreach ($publicComponents as $componentName => $actions) { + * $acl->addComponent( + * new \Phalcon\Acl\Component($componentName), * $actions * ); * } * * // Grant access to public areas to both users and guests * foreach ($roles as $role){ - * foreach ($publicResources as $resource => $actions) { - * $acl->allow($role->getName(), $resource, ""); + * foreach ($publicComponents as $component => $actions) { + * $acl->allow($role->getName(), $component, "*"); * } * } * * // Grant access to private area to role Users - * foreach ($privateResources as $resource => $actions) { + * foreach ($privateComponents as $component => $actions) { * foreach ($actions as $action) { - * $acl->allow("Users", $resource, $action); + * $acl->allow("Users", $component, $action); * } * } - * + *``` */ -class Memory extends \Phalcon\Acl\Adapter +class Memory extends Adapter { /** - * Roles Names + * Access * * @var mixed */ - protected $_rolesNames; + protected $access; /** - * Roles + * Access List * * @var mixed */ - protected $_roles; + protected $accessList; - /** - * Resource Names - * - * @var mixed - */ - protected $_resourcesNames; + /** + * Returns latest function used to acquire access + * + * @var mixed + */ + protected $activeFunction; /** - * Resources + * Returns number of additional arguments(excluding role and resource) for active function * - * @var mixed + * @var int */ - protected $_resources; + protected $activeFunctionCustomArgumentsCount; /** - * Access + * Returns latest key used to acquire access * - * @var mixed + * @var string|null */ - protected $_access; + protected $activeKey; /** - * Role Inherits + * Components * * @var mixed */ - protected $_roleInherits; + protected $components; /** - * Access List + * Component Names * * @var mixed */ - protected $_accessList; + protected $componentsNames; /** * Function List * * @var mixed */ - protected $_func; + protected $func; /** * Default action for no arguments is allow * * @var mixed */ - protected $_noArgumentsDefaultAction = Acl::ALLOW; - - - /** - * Phalcon\Acl\Adapter\Memory constructor - */ - public function __construct() {} + protected $noArgumentsDefaultAction = Acl::DENY; /** - * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role - * - * Example: - * - * $acl->addRole( - * new Phalcon\Acl\Role("administrator"), - * "consultant" - * ); - * - * $acl->addRole("administrator", "consultant"); - * + * Roles * - * @param RoleInterface|string $role - * @param array|string $accessInherits - * @return bool + * @var mixed */ - public function addRole($role, $accessInherits = null) {} + protected $roles; /** - * Do a role inherit from another existing role + * Role Inherits * - * @param string $roleName - * @param mixed $roleToInherit - * @return bool + * @var mixed */ - public function addInherit($roleName, $roleToInherit) {} + protected $roleInherits; /** - * Check whether role exist in the roles list + * Roles Names * - * @param string $roleName - * @return bool + * @var mixed */ - public function isRole($roleName) {} + protected $rolesNames; + /** - * Check whether resource exist in the resources list - * - * @param string $resourceName - * @return bool + * Phalcon\Acl\Adapter\Memory constructor */ - public function isResource($resourceName) {} + public function __construct() {} /** - * Adds a resource to the ACL list + * Adds a component to the ACL list * * Access names can be a particular action, by example * search, update, delete, etc or a list of them * * Example: - * - * // Add a resource to the the list allowing access to an action - * $acl->addResource( - * new Phalcon\Acl\Resource("customers"), + * ```php + * // Add a component to the the list allowing access to an action + * $acl->addComponent( + * new Phalcon\Acl\Component("customers"), * "search" * ); * - * $acl->addResource("customers", "search"); + * $acl->addComponent("customers", "search"); * - * // Add a resource with an access list - * $acl->addResource( - * new Phalcon\Acl\Resource("customers"), + * // Add a component with an access list + * $acl->addComponent( + * new Phalcon\Acl\Component("customers"), * [ * "create", * "search", * ] * ); * - * $acl->addResource( + * $acl->addComponent( * "customers", * [ * "create", * "search", * ] * ); - * - * - * @param \Phalcon\Acl\Resource|string $resourceValue - * @param array|string $accessList + * ``` + * @param $componentValue + * @param $accessList * @return bool */ - public function addResource($resourceValue, $accessList) {} + public function addComponent($componentValue, $accessList) : bool {} /** - * Adds access to resources + * Adds access to components * - * @param string $resourceName - * @param array|string $accessList + * @param $componentName + * @param $accessList * @return bool */ - public function addResourceAccess($resourceName, $accessList) {} + public function addComponentAccess(string $componentName, $accessList) : bool {} /** - * Removes an access from a resource + * Do a role inherit from another existing role + * + * ```php + * $acl->addRole("administrator", "consultant"); + * $acl->addRole("administrator", ["consultant", "consultant2"]); + * ``` * - * @param string $resourceName - * @param array|string $accessList + * @param string $roleName + * @param $roleToInherits + * @return bool */ - public function dropResourceAccess($resourceName, $accessList) {} + public function addInherit(string $roleName, $roleToInherits) : bool {} /** - * Checks if a role has access to a resource + * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role * - * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $action - * @param mixed $func + * ```php + * $acl->addRole( + * new Phalcon\Acl\Role("administrator"), + * "consultant" + * ); + * + * $acl->addRole("administrator", "consultant"); + * $acl->addRole("administrator", ["consultant", "consultant2"]); + * ``` + * + * @param $role + * @param null $accessInherits + * @return bool */ - protected function _allowOrDeny($roleName, $resourceName, $access, $action, $func = null) {} + public function addRole($role, $accessInherits = null) : bool {} /** - * Allow access to a role on a resource - * - * You can use '' as wildcard + * Allow access to a role on a component. You can use `*` as wildcard * - * Example: - * - * //Allow access to guests to search on customers + * ```php + * // Allow access to guests to search on customers * $acl->allow("guests", "customers", "search"); * - * //Allow access to guests to search or create on customers + * // Allow access to guests to search or create on customers * $acl->allow("guests", "customers", ["search", "create"]); * - * //Allow access to any role to browse on products - * $acl->allow("", "products", "browse"); + * // Allow access to any role to browse on products + * $acl->allow("*", "products", "browse"); * - * //Allow access to any role to browse on any resource - * $acl->allow("", "", "browse"); - * + * // Allow access to any role to browse on any component + * $acl->allow("*", "*", "browse"); * * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * @param string $componentName + * @param $access + * @param null $func */ - public function allow($roleName, $resourceName, $access, $func = null) {} + public function allow(string $roleName, string $componentName, $access, $func = null) : void {} /** - * Deny access to a role on a resource - * - * You can use '' as wildcard + * Deny access to a role on a component. You can use `*` as wildcard * - * Example: - * - * //Deny access to guests to search on customers + * ```php + * // Deny access to guests to search on customers * $acl->deny("guests", "customers", "search"); * - * //Deny access to guests to search or create on customers + * // Deny access to guests to search or create on customers * $acl->deny("guests", "customers", ["search", "create"]); * - * //Deny access to any role to browse on products - * $acl->deny("", "products", "browse"); + * // Deny access to any role to browse on products + * $acl->deny("*", "products", "browse"); * - * //Deny access to any role to browse on any resource - * $acl->deny("", "", "browse"); - * + * // Deny access to any role to browse on any component + * $acl->deny("*", "*", "browse"); + * ``` * * @param string $roleName - * @param string $resourceName - * @param mixed $access - * @param mixed $func + * @param string $componentName + * @param $access + * @param null $func */ - public function deny($roleName, $resourceName, $access, $func = null) {} + public function deny(string $roleName, string $componentName, $access, $func = null) : void {} /** - * Check whether a role is allowed to access an action from a resource - * - * - * //Does andres have access to the customers resource to create? - * $acl->isAllowed("andres", "Products", "create"); - * - * //Do guests have access to any resource to edit? - * $acl->isAllowed("guests", "", "edit"); - * + * Removes an access from a component + * @param string $componentName + * @param $accessList + */ + public function dropComponentAccess(string $componentName, $accessList) : void {} + + /** + * Returns the default ACL access level for no arguments provided in + * `isAllowed` action if a `func` (callable) exists for `accessKey` + */ + public function getNoArgumentsDefaultAction() : int {} + + /** + * Return an array with every role registered in the list * - * @param RoleInterface|RoleAware|string $roleName - * @param ResourceInterface|ResourceAware|string $resourceName - * @param string $access - * @param array $parameters - * @return bool + * @return RoleInterface[] */ - public function isAllowed($roleName, $resourceName, $access, array $parameters = null) {} + public function getRoles() : array {} /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * for no arguments provided in isAllowed action if there exists func for - * accessKey + * Return an array with every component registered in the list * - * @param int $defaultAccess + * @return ComponentInterface[] */ - public function setNoArgumentsDefaultAction($defaultAccess) {} + public function getComponents() : array {} /** - * Returns the default ACL access level for no arguments provided in - * isAllowed action if there exists func for accessKey + * Check whether a role is allowed to access an action from a component + * + * ```php + * // Does andres have access to the customers component to create? + * $acl->isAllowed("andres", "Products", "create"); * - * @return int + * // Do guests have access to any component to edit? + * $acl->isAllowed("guests", "*", "edit"); + * ``` + * @param $roleName + * @param $componentName + * @param $access + * @param array|null $parameters + * @return bool */ - public function getNoArgumentsDefaultAction() {} + public function isAllowed($roleName, $componentName, $access, ?array $parameters = null) : bool {} /** - * Return an array with every role registered in the list + * Check whether role exist in the roles list * - * @return \Phalcon\Acl\RoleInterface[] + * @param string $roleName + * @return bool */ - public function getRoles() {} + public function isRole(string $roleName) : bool {} /** - * Return an array with every resource registered in the list + * Check whether component exist in the components list * - * @return \Phalcon\Acl\ResourceInterface[] + * @param string $componentName + * @return bool */ - public function getResources() {} + public function isComponent(string $componentName) : bool {} + /** + * Sets the default access level (`Phalcon\Acl::ALLOW` or `Phalcon\Acl::DENY`) + * for no arguments provided in isAllowed action if there exists func for + * accessKey + * + * @param int $defaultAccess + */ + public function setNoArgumentsDefaultAction(int $defaultAccess) : void {} } From 7612b0b80fd95ef4d8b074a516faa9d57dc5cb4d Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Wed, 24 Jul 2019 22:46:05 +0300 Subject: [PATCH 07/25] Generated stubs for Phalcon v4.0.0-beta.1 --- src/Phalcon/Acl.php | 60 - src/Phalcon/Cache.php | 164 ++ src/Phalcon/Collection.php | 217 ++ src/Phalcon/Config.php | 180 +- src/Phalcon/Container.php | 55 +- src/Phalcon/Crypt.php | 306 ++- src/Phalcon/CryptInterface.php | 86 - src/Phalcon/Db.php | 108 - src/Phalcon/Debug.php | 191 +- src/Phalcon/Di.php | 363 ++- src/Phalcon/Escaper.php | 130 +- src/Phalcon/Exception.php | 8 +- src/Phalcon/Factory.php | 15 - src/Phalcon/FactoryInterface.php | 15 - src/Phalcon/Filter.php | 103 - src/Phalcon/FilterInterface.php | 38 - src/Phalcon/Flash.php | 181 -- src/Phalcon/FlashInterface.php | 49 - src/Phalcon/Image.php | 36 - src/Phalcon/Kernel.php | 4 +- src/Phalcon/Loader.php | 214 +- src/Phalcon/Logger.php | 55 - src/Phalcon/Plugin.php | 4 +- src/Phalcon/Registry.php | 184 +- src/Phalcon/Security.php | 202 +- src/Phalcon/Tag.php | 932 +++---- src/Phalcon/Text.php | 250 +- src/Phalcon/Translate.php | 14 - src/Phalcon/Url.php | 334 +-- src/Phalcon/Urlinterface.php | 44 - src/Phalcon/Validation.php | 153 +- src/Phalcon/Version.php | 50 +- src/Phalcon/acl/Component.php | 53 +- ...{Componentaware.php => ComponentAware.php} | 10 +- src/Phalcon/acl/ComponentInterface.php | 32 + src/Phalcon/acl/Componentinterface.php | 27 - src/Phalcon/acl/Enum.php | 17 + src/Phalcon/acl/Exception.php | 2 - src/Phalcon/acl/Role.php | 16 +- src/Phalcon/acl/RoleAware.php | 5 +- src/Phalcon/acl/RoleInterface.php | 8 +- .../AbstractAdapter.php} | 72 +- .../acl/{ => adapter}/AdapterInterface.php | 112 +- src/Phalcon/acl/adapter/Memory.php | 159 +- src/Phalcon/annotations/Annotation.php | 74 +- .../annotations/AnnotationsFactory.php | 42 + src/Phalcon/annotations/Collection.php | 87 +- src/Phalcon/annotations/Exception.php | 4 +- src/Phalcon/annotations/Factory.php | 28 - src/Phalcon/annotations/Reader.php | 8 +- src/Phalcon/annotations/ReaderInterface.php | 10 +- src/Phalcon/annotations/Reflection.php | 37 +- .../AbstractAdapter.php} | 64 +- .../{ => adapter}/AdapterInterface.php | 52 +- src/Phalcon/annotations/adapter/Apc.php | 51 - src/Phalcon/annotations/adapter/Apcu.php | 27 +- src/Phalcon/annotations/adapter/Memory.php | 15 +- .../adapter/{Files.php => Stream.php} | 26 +- src/Phalcon/annotations/adapter/Xcache.php | 33 - .../AbstractApplication.php} | 98 +- src/Phalcon/application/Exception.php | 2 - src/Phalcon/assets/Asset.php | 405 +-- src/Phalcon/assets/AssetInterface.php | 63 + src/Phalcon/assets/Assetinterface.php | 46 - src/Phalcon/assets/Collection.php | 376 +-- src/Phalcon/assets/Exception.php | 2 - src/Phalcon/assets/FilterInterface.php | 4 +- src/Phalcon/assets/Inline.php | 78 +- src/Phalcon/assets/Manager.php | 271 +- src/Phalcon/assets/Resource.php | 199 -- src/Phalcon/assets/ResourceInterface.php | 65 - src/Phalcon/assets/asset/Css.php | 25 +- src/Phalcon/assets/asset/Js.php | 25 +- src/Phalcon/assets/filters/Cssmin.php | 8 +- src/Phalcon/assets/filters/Jsmin.php | 11 +- src/Phalcon/assets/filters/None.php | 6 +- src/Phalcon/assets/inline/Css.php | 10 +- src/Phalcon/assets/inline/Js.php | 12 +- src/Phalcon/assets/resource/Css.php | 23 - src/Phalcon/assets/resource/Js.php | 23 - src/Phalcon/cache/AdapterFactory.php | 40 + src/Phalcon/cache/Backend.php | 103 - src/Phalcon/cache/BackendInterface.php | 116 - src/Phalcon/cache/CacheFactory.php | 40 + src/Phalcon/cache/Exception.php | 13 - src/Phalcon/cache/FrontendInterface.php | 58 - src/Phalcon/cache/Multiple.php | 139 -- .../cache/adapter/AdapterInterface.php | 11 + src/Phalcon/cache/adapter/Apcu.php | 11 + src/Phalcon/cache/adapter/Libmemcached.php | 11 + src/Phalcon/cache/adapter/Memory.php | 11 + src/Phalcon/cache/adapter/Redis.php | 11 + src/Phalcon/cache/adapter/Stream.php | 11 + src/Phalcon/cache/backend/Apc.php | 129 - src/Phalcon/cache/backend/Apcu.php | 126 - src/Phalcon/cache/backend/Factory.php | 35 - src/Phalcon/cache/backend/File.php | 152 -- src/Phalcon/cache/backend/Libmemcached.php | 162 -- src/Phalcon/cache/backend/Memcache.php | 148 -- src/Phalcon/cache/backend/Memory.php | 123 - src/Phalcon/cache/backend/Mongo.php | 146 -- src/Phalcon/cache/backend/Redis.php | 147 -- src/Phalcon/cache/backend/Xcache.php | 123 - src/Phalcon/cache/exception/Exception.php | 11 + .../exception/InvalidArgumentException.php | 11 + src/Phalcon/cache/frontend/Base64.php | 110 - src/Phalcon/cache/frontend/Data.php | 114 - src/Phalcon/cache/frontend/Factory.php | 33 - src/Phalcon/cache/frontend/Igbinary.php | 109 - src/Phalcon/cache/frontend/Json.php | 102 - src/Phalcon/cache/frontend/Msgpack.php | 115 - src/Phalcon/cache/frontend/None.php | 98 - src/Phalcon/cache/frontend/Output.php | 120 - src/Phalcon/cli/Console.php | 35 +- src/Phalcon/cli/Dispatcher.php | 133 +- src/Phalcon/cli/DispatcherInterface.php | 57 +- src/Phalcon/cli/Router.php | 195 +- src/Phalcon/cli/RouterInterface.php | 106 +- src/Phalcon/cli/Task.php | 16 +- src/Phalcon/cli/TaskInterface.php | 2 - src/Phalcon/cli/console/Exception.php | 2 - src/Phalcon/cli/dispatcher/Exception.php | 4 +- src/Phalcon/cli/router/Exception.php | 2 - src/Phalcon/cli/router/Route.php | 162 +- src/Phalcon/cli/router/RouteInterface.php | 75 +- src/Phalcon/collection/Exception.php | 11 + src/Phalcon/collection/ReadOnly.php | 26 + src/Phalcon/config/ConfigFactory.php | 55 + src/Phalcon/config/Exception.php | 2 - src/Phalcon/config/Factory.php | 33 - src/Phalcon/config/adapter/Grouped.php | 19 +- src/Phalcon/config/adapter/Ini.php | 56 +- src/Phalcon/config/adapter/Json.php | 16 +- src/Phalcon/config/adapter/Php.php | 16 +- src/Phalcon/config/adapter/Yaml.php | 17 +- src/Phalcon/crypt/CryptInterface.php | 137 + src/Phalcon/crypt/Exception.php | 2 - src/Phalcon/crypt/Mismatch.php | 2 - src/Phalcon/db/AbstractDb.php | 58 + src/Phalcon/db/Column.php | 317 +-- src/Phalcon/db/ColumnInterface.php | 97 +- src/Phalcon/db/Dialect.php | 254 +- src/Phalcon/db/DialectInterface.php | 242 +- src/Phalcon/db/Enum.php | 62 + src/Phalcon/db/Exception.php | 2 - src/Phalcon/db/Index.php | 50 +- src/Phalcon/db/IndexInterface.php | 22 +- src/Phalcon/db/Profiler.php | 62 +- src/Phalcon/db/RawValue.php | 12 +- src/Phalcon/db/Reference.php | 106 +- src/Phalcon/db/ReferenceInterface.php | 44 +- src/Phalcon/db/ResultInterface.php | 63 +- .../AbstractAdapter.php} | 958 +++---- .../db/{ => adapter}/AdapterInterface.php | 559 +++-- src/Phalcon/db/adapter/PdoFactory.php | 47 + .../adapter/{Pdo.php => pdo/AbstractPdo.php} | 341 +-- src/Phalcon/db/adapter/pdo/Factory.php | 31 - src/Phalcon/db/adapter/pdo/Mysql.php | 61 +- src/Phalcon/db/adapter/pdo/Postgresql.php | 113 +- src/Phalcon/db/adapter/pdo/Sqlite.php | 85 +- src/Phalcon/db/dialect/Mysql.php | 220 +- src/Phalcon/db/dialect/Postgresql.php | 208 +- src/Phalcon/db/dialect/Sqlite.php | 219 +- src/Phalcon/db/profiler/Item.php | 80 +- src/Phalcon/db/result/Pdo.php | 165 +- src/Phalcon/debug/Dump.php | 120 +- src/Phalcon/debug/Exception.php | 2 - src/Phalcon/{ => di}/DiInterface.php | 114 +- src/Phalcon/di/Exception.php | 2 - src/Phalcon/di/FactoryDefault.php | 7 +- src/Phalcon/di/Injectable.php | 53 +- src/Phalcon/di/InjectionAwareInterface.php | 14 +- src/Phalcon/di/Service.php | 99 +- src/Phalcon/di/ServiceInterface.php | 48 +- src/Phalcon/di/ServiceProviderInterface.php | 25 +- .../exception/ServiceResolutionException.php | 11 + .../exception/Serviceresolutionexception.php | 11 - src/Phalcon/di/service/Builder.php | 28 +- .../AbstractDispatcher.php} | 421 ++-- .../{ => dispatcher}/DispatcherInterface.php | 127 +- src/Phalcon/dispatcher/Exception.php | 29 + src/Phalcon/domain/payload/Payload.php | 121 + src/Phalcon/domain/payload/PayloadFactory.php | 18 + .../domain/payload/PayloadInterface.php | 11 + .../domain/payload/ReadableInterface.php | 47 + src/Phalcon/domain/payload/Status.php | 76 + .../domain/payload/WriteableInterface.php | 54 + .../{ => escaper}/EscaperInterface.php | 56 +- src/Phalcon/escaper/Exception.php | 2 - src/Phalcon/events/Event.php | 95 +- src/Phalcon/events/EventInterface.php | 38 +- src/Phalcon/events/EventsAwareInterface.php | 15 +- src/Phalcon/events/Manager.php | 116 +- src/Phalcon/events/ManagerInterface.php | 28 +- src/Phalcon/factory/AbstractFactory.php | 55 + src/Phalcon/factory/Exception.php | 7 +- src/Phalcon/filter/Filter.php | 154 ++ src/Phalcon/filter/FilterFactory.php | 29 + src/Phalcon/filter/FilterInterface.php | 21 + src/Phalcon/filter/Filterlocator.php | 51 - src/Phalcon/filter/Filterlocatorfactory.php | 42 - src/Phalcon/filter/UserFilterInterface.php | 20 - .../sanitize/{Absint.php => AbsInt.php} | 12 +- src/Phalcon/filter/sanitize/Alnum.php | 12 +- src/Phalcon/filter/sanitize/Alpha.php | 12 +- .../sanitize/{Boolval.php => BoolVal.php} | 12 +- src/Phalcon/filter/sanitize/Email.php | 12 +- .../sanitize/{Floatval.php => FloatVal.php} | 12 +- .../sanitize/{Intval.php => IntVal.php} | 12 +- src/Phalcon/filter/sanitize/Lower.php | 12 +- .../{Lowerfirst.php => LowerFirst.php} | 12 +- src/Phalcon/filter/sanitize/Regex.php | 14 +- src/Phalcon/filter/sanitize/Remove.php | 13 +- src/Phalcon/filter/sanitize/Replace.php | 14 +- src/Phalcon/filter/sanitize/Special.php | 12 +- .../{Specialfull.php => SpecialFull.php} | 12 +- .../sanitize/{Stringval.php => StringVal.php} | 12 +- src/Phalcon/filter/sanitize/Striptags.php | 12 +- src/Phalcon/filter/sanitize/Trim.php | 12 +- src/Phalcon/filter/sanitize/Upper.php | 12 +- .../{Upperfirst.php => UpperFirst.php} | 12 +- .../{Upperwords.php => UpperWords.php} | 12 +- src/Phalcon/filter/sanitize/Url.php | 12 +- src/Phalcon/firewall/Exception.php | 11 + .../firewall/adapter/AbstractAdapter.php | 190 ++ src/Phalcon/firewall/adapter/Acl.php | 174 ++ .../firewall/adapter/AdapterInterface.php | 61 + src/Phalcon/firewall/adapter/Annotations.php | 108 + src/Phalcon/firewall/adapter/micro/Acl.php | 197 ++ src/Phalcon/flash/AbstractFlash.php | 234 ++ src/Phalcon/flash/Direct.php | 11 +- src/Phalcon/flash/Exception.php | 2 - src/Phalcon/flash/FlashInterface.php | 53 + src/Phalcon/flash/Session.php | 53 +- src/Phalcon/forms/Exception.php | 2 - src/Phalcon/forms/Form.php | 258 +- src/Phalcon/forms/Manager.php | 12 +- .../AbstractElement.php} | 253 +- src/Phalcon/forms/element/Check.php | 4 +- src/Phalcon/forms/element/Date.php | 6 +- .../forms/{ => element}/ElementInterface.php | 224 +- src/Phalcon/forms/element/Email.php | 4 +- src/Phalcon/forms/element/File.php | 6 +- src/Phalcon/forms/element/Hidden.php | 4 +- src/Phalcon/forms/element/Numeric.php | 4 +- src/Phalcon/forms/element/Password.php | 4 +- src/Phalcon/forms/element/Radio.php | 4 +- src/Phalcon/forms/element/Select.php | 30 +- src/Phalcon/forms/element/Submit.php | 6 +- src/Phalcon/forms/element/Text.php | 4 +- src/Phalcon/forms/element/TextArea.php | 6 +- src/Phalcon/helper/Arr.php | 241 +- src/Phalcon/helper/Exception.php | 3 - src/Phalcon/helper/Number.php | 23 + src/Phalcon/helper/Str.php | 413 +++ src/Phalcon/html/Attributes.php | 25 + src/Phalcon/html/Breadcrumbs.php | 79 +- src/Phalcon/html/Exception.php | 1 - src/Phalcon/html/Tag.php | 2222 +++++++++-------- src/Phalcon/html/TagFactory.php | 38 + src/Phalcon/html/Taglocator.php | 14 - src/Phalcon/html/Taglocatorfactory.php | 42 - .../html/attributes/AttributesInterface.php | 28 + .../html/attributes/RenderInterface.php | 20 + src/Phalcon/html/helper/AbstractHelper.php | 73 + src/Phalcon/html/helper/Abstracthelper.php | 54 - src/Phalcon/html/helper/Anchor.php | 21 +- src/Phalcon/html/helper/AnchorRaw.php | 21 + src/Phalcon/html/helper/Body.php | 19 + src/Phalcon/html/helper/Button.php | 19 +- src/Phalcon/html/helper/Close.php | 21 + src/Phalcon/html/helper/Element.php | 21 +- src/Phalcon/html/helper/ElementRaw.php | 24 + src/Phalcon/html/helper/Form.php | 17 +- src/Phalcon/html/helper/Formclose.php | 20 - src/Phalcon/html/helper/Img.php | 23 + src/Phalcon/html/helper/Label.php | 22 + src/Phalcon/html/helper/TextArea.php | 20 + src/Phalcon/html/helper/Textarea.php | 21 - src/Phalcon/http/Cookie.php | 201 +- src/Phalcon/http/CookieInterface.php | 118 +- src/Phalcon/http/Request.php | 715 +++--- src/Phalcon/http/RequestInterface.php | 418 +++- src/Phalcon/http/Response.php | 382 +-- src/Phalcon/http/ResponseInterface.php | 122 +- src/Phalcon/http/message/AbstractCommon.php | 41 + src/Phalcon/http/message/AbstractMessage.php | 369 +++ src/Phalcon/http/message/AbstractRequest.php | 165 ++ src/Phalcon/http/message/Request.php | 21 + src/Phalcon/http/message/RequestFactory.php | 22 + src/Phalcon/http/message/Response.php | 123 + src/Phalcon/http/message/ResponseFactory.php | 25 + src/Phalcon/http/message/ServerRequest.php | 331 +++ .../http/message/ServerRequestFactory.php | 209 ++ src/Phalcon/http/message/Stream.php | 195 ++ src/Phalcon/http/message/StreamFactory.php | 52 + src/Phalcon/http/message/UploadedFile.php | 240 ++ .../http/message/UploadedFileFactory.php | 34 + src/Phalcon/http/message/Uri.php | 432 ++++ src/Phalcon/http/message/UriFactory.php | 20 + .../exception/InvalidArgumentException.php | 16 + src/Phalcon/http/message/stream/Input.php | 76 + src/Phalcon/http/message/stream/Memory.php | 22 + src/Phalcon/http/message/stream/Temp.php | 22 + src/Phalcon/http/request/File.php | 80 +- src/Phalcon/http/request/FileInterface.php | 28 +- src/Phalcon/http/response/Cookies.php | 129 +- .../http/response/CookiesInterface.php | 66 +- src/Phalcon/http/response/Headers.php | 46 +- .../http/response/HeadersInterface.php | 34 +- .../http/server/AbstractMiddleware.php | 28 + .../http/server/AbstractRequestHandler.php | 24 + src/Phalcon/image/AdapterInterface.php | 98 - src/Phalcon/image/Enum.php | 43 + src/Phalcon/image/Exception.php | 9 +- src/Phalcon/image/Factory.php | 35 - src/Phalcon/image/ImageFactory.php | 42 + .../AbstractAdapter.php} | 193 +- .../image/adapter/AdapterInterface.php | 105 + src/Phalcon/image/adapter/Gd.php | 130 +- src/Phalcon/image/adapter/Imagick.php | 183 +- src/Phalcon/logger/Adapter.php | 174 -- src/Phalcon/logger/AdapterFactory.php | 38 + src/Phalcon/logger/AdapterInterface.php | 144 -- src/Phalcon/logger/Factory.php | 33 - src/Phalcon/logger/Formatter.php | 30 - src/Phalcon/logger/FormatterInterface.php | 24 - src/Phalcon/logger/Item.php | 47 +- src/Phalcon/logger/Logger.php | 268 ++ src/Phalcon/logger/LoggerFactory.php | 42 + src/Phalcon/logger/Multiple.php | 125 - .../logger/adapter/AbstractAdapter.php | 105 + .../logger/adapter/Abstractadapter.php | 100 - .../logger/adapter/AdapterInterface.php | 70 + .../logger/adapter/Adapterinterface.php | 54 - src/Phalcon/logger/adapter/Blackhole.php | 37 - src/Phalcon/logger/adapter/File.php | 82 - src/Phalcon/logger/adapter/Firephp.php | 55 - src/Phalcon/logger/adapter/Noop.php | 34 +- src/Phalcon/logger/adapter/Stream.php | 71 +- src/Phalcon/logger/adapter/Syslog.php | 56 +- .../logger/formatter/AbstractFormatter.php | 25 + .../logger/formatter/Abstractformatter.php | 19 - src/Phalcon/logger/formatter/Firephp.php | 72 - ...erinterface.php => FormatterInterface.php} | 20 +- src/Phalcon/logger/formatter/Json.php | 37 +- src/Phalcon/logger/formatter/Line.php | 23 +- src/Phalcon/logger/formatter/Syslog.php | 9 +- src/Phalcon/messages/Exception.php | 3 +- src/Phalcon/messages/Message.php | 244 +- src/Phalcon/messages/MessageInterface.php | 95 + src/Phalcon/messages/Messageinterface.php | 72 - src/Phalcon/messages/Messages.php | 299 ++- src/Phalcon/mvc/Application.php | 43 +- src/Phalcon/mvc/Collection.php | 857 +++---- src/Phalcon/mvc/CollectionInterface.php | 143 +- src/Phalcon/mvc/Controller.php | 16 +- src/Phalcon/mvc/Dispatcher.php | 175 +- src/Phalcon/mvc/DispatcherInterface.php | 38 +- src/Phalcon/mvc/EntityInterface.php | 6 +- src/Phalcon/mvc/Micro.php | 308 +-- src/Phalcon/mvc/Model.php | 2067 ++++++++------- src/Phalcon/mvc/ModelInterface.php | 314 +-- src/Phalcon/mvc/ModuleDefinitionInterface.php | 8 +- src/Phalcon/mvc/Router.php | 467 ++-- src/Phalcon/mvc/RouterInterface.php | 188 +- src/Phalcon/mvc/Url.php | 184 -- src/Phalcon/mvc/View.php | 708 +++--- src/Phalcon/mvc/ViewBaseInterface.php | 69 +- src/Phalcon/mvc/ViewInterface.php | 176 +- src/Phalcon/mvc/collection/Behavior.php | 34 +- .../mvc/collection/BehaviorInterface.php | 14 +- src/Phalcon/mvc/collection/Document.php | 45 +- src/Phalcon/mvc/collection/Manager.php | 142 +- .../mvc/collection/ManagerInterface.php | 74 +- .../mvc/collection/behavior/SoftDelete.php | 2 +- .../mvc/collection/behavior/Timestampable.php | 2 +- .../mvc/controller/BindModelInterface.php | 2 +- src/Phalcon/mvc/dispatcher/Exception.php | 2 +- src/Phalcon/mvc/micro/Collection.php | 154 +- src/Phalcon/mvc/micro/CollectionInterface.php | 110 +- src/Phalcon/mvc/micro/Exception.php | 2 - src/Phalcon/mvc/micro/LazyLoader.php | 20 +- src/Phalcon/mvc/micro/MiddlewareInterface.php | 2 - src/Phalcon/mvc/model/Behavior.php | 38 +- src/Phalcon/mvc/model/BehaviorInterface.php | 14 +- src/Phalcon/mvc/model/Binder.php | 48 +- src/Phalcon/mvc/model/BinderInterface.php | 32 +- src/Phalcon/mvc/model/Criteria.php | 246 +- src/Phalcon/mvc/model/CriteriaInterface.php | 273 +- src/Phalcon/mvc/model/Manager.php | 374 ++- src/Phalcon/mvc/model/ManagerInterface.php | 426 ++-- src/Phalcon/mvc/model/Message.php | 147 -- src/Phalcon/mvc/model/MessageInterface.php | 70 - src/Phalcon/mvc/model/MetaData.php | 465 ++-- src/Phalcon/mvc/model/MetaDataInterface.php | 170 +- src/Phalcon/mvc/model/Query.php | 263 +- src/Phalcon/mvc/model/QueryInterface.php | 94 +- src/Phalcon/mvc/model/Relation.php | 124 +- src/Phalcon/mvc/model/RelationInterface.php | 89 +- src/Phalcon/mvc/model/ResultInterface.php | 5 +- src/Phalcon/mvc/model/Resultset.php | 227 +- src/Phalcon/mvc/model/ResultsetInterface.php | 88 +- src/Phalcon/mvc/model/Row.php | 54 +- src/Phalcon/mvc/model/Transaction.php | 102 +- .../mvc/model/TransactionInterface.php | 69 +- src/Phalcon/mvc/model/ValidationFailed.php | 20 +- src/Phalcon/mvc/model/Validator.php | 73 - src/Phalcon/mvc/model/ValidatorInterface.php | 31 - src/Phalcon/mvc/model/behavior/SoftDelete.php | 6 +- .../mvc/model/behavior/Timestampable.php | 11 +- .../mvc/model/binder/BindableInterface.php | 3 +- src/Phalcon/mvc/model/metadata/Apc.php | 61 - src/Phalcon/mvc/model/metadata/Apcu.php | 34 +- .../mvc/model/metadata/Libmemcached.php | 48 +- src/Phalcon/mvc/model/metadata/Memcache.php | 64 - src/Phalcon/mvc/model/metadata/Memory.php | 9 +- src/Phalcon/mvc/model/metadata/Redis.php | 35 +- src/Phalcon/mvc/model/metadata/Session.php | 50 - .../mvc/model/metadata/StrategyInterface.php | 23 +- .../model/metadata/{Files.php => Stream.php} | 26 +- src/Phalcon/mvc/model/metadata/Xcache.php | 58 - .../model/metadata/strategy/Annotations.php | 21 +- .../model/metadata/strategy/Introspection.php | 12 +- src/Phalcon/mvc/model/query/Builder.php | 835 ++++--- .../mvc/model/query/BuilderInterface.php | 319 ++- src/Phalcon/mvc/model/query/Lang.php | 10 +- src/Phalcon/mvc/model/query/Status.php | 26 +- .../mvc/model/query/StatusInterface.php | 14 +- src/Phalcon/mvc/model/resultset/Complex.php | 21 +- src/Phalcon/mvc/model/resultset/Simple.php | 36 +- src/Phalcon/mvc/model/transaction/Failed.php | 12 +- src/Phalcon/mvc/model/transaction/Manager.php | 133 +- .../model/transaction/ManagerInterface.php | 66 +- src/Phalcon/mvc/model/validator/Email.php | 49 - .../mvc/model/validator/Exclusionin.php | 50 - .../mvc/model/validator/Inclusionin.php | 50 - src/Phalcon/mvc/model/validator/Ip.php | 82 - .../mvc/model/validator/Numericality.php | 49 - .../mvc/model/validator/PresenceOf.php | 50 - src/Phalcon/mvc/model/validator/Regex.php | 50 - .../mvc/model/validator/StringLength.php | 53 - .../mvc/model/validator/Uniqueness.php | 52 - src/Phalcon/mvc/model/validator/Url.php | 49 - src/Phalcon/mvc/router/Annotations.php | 50 +- src/Phalcon/mvc/router/Group.php | 195 +- src/Phalcon/mvc/router/GroupInterface.php | 179 +- src/Phalcon/mvc/router/Route.php | 332 ++- src/Phalcon/mvc/router/RouteInterface.php | 93 +- src/Phalcon/mvc/url/Exception.php | 13 - src/Phalcon/mvc/user/Component.php | 14 - src/Phalcon/mvc/user/Module.php | 14 - src/Phalcon/mvc/user/Plugin.php | 14 - src/Phalcon/mvc/view/Simple.php | 255 +- .../{Engine.php => engine/AbstractEngine.php} | 30 +- .../mvc/view/{ => engine}/EngineInterface.php | 10 +- src/Phalcon/mvc/view/engine/Php.php | 6 +- src/Phalcon/mvc/view/engine/Volt.php | 80 +- src/Phalcon/mvc/view/engine/volt/Compiler.php | 433 ++-- .../mvc/view/engine/volt/Exception.php | 6 +- src/Phalcon/paginator/Adapter.php | 44 - src/Phalcon/paginator/Factory.php | 33 - src/Phalcon/paginator/PaginatorFactory.php | 65 + src/Phalcon/paginator/Repository.php | 217 +- src/Phalcon/paginator/RepositoryInterface.php | 117 + src/Phalcon/paginator/Repositoryinterface.php | 75 - .../paginator/adapter/AbstractAdapter.php | 79 + .../{ => adapter}/AdapterInterface.php | 25 +- src/Phalcon/paginator/adapter/Model.php | 35 +- src/Phalcon/paginator/adapter/NativeArray.php | 30 +- .../paginator/adapter/QueryBuilder.php | 41 +- src/Phalcon/queue/Beanstalk.php | 269 -- src/Phalcon/queue/beanstalk/Exception.php | 13 - src/Phalcon/queue/beanstalk/Job.php | 104 - src/Phalcon/security/Random.php | 167 +- src/Phalcon/service/Exception.php | 12 - src/Phalcon/service/Locator.php | 59 - .../service/Locatorfactoryinterface.php | 18 - src/Phalcon/service/Locatorinterface.php | 27 - src/Phalcon/session/Adapter.php | 251 -- src/Phalcon/session/AdapterInterface.php | 108 - src/Phalcon/session/Bag.php | 186 +- src/Phalcon/session/BagInterface.php | 73 - src/Phalcon/session/Factory.php | 32 - src/Phalcon/session/Manager.php | 445 ++-- src/Phalcon/session/ManagerInterface.php | 189 ++ src/Phalcon/session/Managerinterface.php | 139 -- .../session/adapter/AbstractAdapter.php | 70 + src/Phalcon/session/adapter/Files.php | 29 - src/Phalcon/session/adapter/Libmemcached.php | 92 +- src/Phalcon/session/adapter/Memcache.php | 95 - src/Phalcon/session/adapter/Noop.php | 152 +- src/Phalcon/session/adapter/Redis.php | 90 +- src/Phalcon/session/adapter/Stream.php | 70 + src/Phalcon/storage/AdapterFactory.php | 43 + src/Phalcon/storage/Exception.php | 13 + src/Phalcon/storage/SerializerFactory.php | 37 + .../storage/adapter/AbstractAdapter.php | 195 ++ .../storage/adapter/AdapterInterface.php | 92 + src/Phalcon/storage/adapter/Apcu.php | 112 + src/Phalcon/storage/adapter/Libmemcached.php | 125 + src/Phalcon/storage/adapter/Memory.php | 116 + src/Phalcon/storage/adapter/Redis.php | 128 + src/Phalcon/storage/adapter/Stream.php | 156 ++ .../storage/serializer/AbstractSerializer.php | 46 + src/Phalcon/storage/serializer/Base64.php | 30 + src/Phalcon/storage/serializer/Igbinary.php | 30 + src/Phalcon/storage/serializer/Json.php | 30 + src/Phalcon/storage/serializer/Msgpack.php | 30 + src/Phalcon/storage/serializer/None.php | 30 + src/Phalcon/storage/serializer/Php.php | 30 + .../serializer/SerializerInterface.php | 27 + src/Phalcon/tag/Select.php | 22 +- src/Phalcon/translate/Factory.php | 30 - src/Phalcon/translate/InterpolatorFactory.php | 46 + .../translate/InterpolatorInterface.php | 22 - src/Phalcon/translate/TranslateFactory.php | 51 + .../AbstractAdapter.php} | 58 +- .../{ => adapter}/AdapterInterface.php | 32 +- src/Phalcon/translate/adapter/Csv.php | 33 +- src/Phalcon/translate/adapter/Gettext.php | 102 +- src/Phalcon/translate/adapter/NativeArray.php | 34 +- .../interpolator/AssociativeArray.php | 15 +- .../translate/interpolator/IndexedArray.php | 15 +- .../interpolator/InterpolatorInterface.php | 22 + src/Phalcon/{mvc => url}/UrlInterface.php | 45 +- .../AbstractCombinedFieldsValidator.php | 11 + src/Phalcon/validation/AbstractValidator.php | 132 + .../validation/AbstractValidatorComposite.php | 30 + .../validation/CombinedFieldsValidator.php | 13 - src/Phalcon/validation/Exception.php | 2 - src/Phalcon/validation/Message.php | 110 - src/Phalcon/validation/MessageInterface.php | 73 - .../{ => validation}/ValidationInterface.php | 121 +- src/Phalcon/validation/Validator.php | 97 - .../ValidatorCompositeInterface.php | 27 + src/Phalcon/validation/ValidatorFactory.php | 36 + src/Phalcon/validation/ValidatorInterface.php | 56 +- src/Phalcon/validation/message/Group.php | 155 -- src/Phalcon/validation/validator/Alnum.php | 15 +- src/Phalcon/validation/validator/Alpha.php | 15 +- src/Phalcon/validation/validator/Between.php | 15 +- src/Phalcon/validation/validator/Callback.php | 15 +- .../validation/validator/Confirmation.php | 17 +- .../validation/validator/CreditCard.php | 20 +- src/Phalcon/validation/validator/Date.php | 17 +- src/Phalcon/validation/validator/Digit.php | 15 +- src/Phalcon/validation/validator/Email.php | 15 +- .../validation/validator/Exception.php | 5 +- .../validation/validator/ExclusionIn.php | 15 +- src/Phalcon/validation/validator/File.php | 29 +- .../validation/validator/Identical.php | 15 +- .../validation/validator/InclusionIn.php | 15 +- src/Phalcon/validation/validator/Ip.php | 60 +- .../validation/validator/Numericality.php | 15 +- .../validation/validator/PresenceOf.php | 15 +- src/Phalcon/validation/validator/Regex.php | 15 +- .../validation/validator/StringLength.php | 35 +- .../validation/validator/Uniqueness.php | 53 +- src/Phalcon/validation/validator/Url.php | 15 +- .../validator/file/AbstractFile.php | 151 ++ .../validation/validator/file/MimeType.php | 68 + .../validator/file/resolution/Equal.php | 59 + .../validator/file/resolution/Max.php | 64 + .../validator/file/resolution/Min.php | 64 + .../validation/validator/file/size/Equal.php | 64 + .../validation/validator/file/size/Max.php | 64 + .../validation/validator/file/size/Min.php | 64 + .../validation/validator/stringlength/Max.php | 66 + .../validation/validator/stringlength/Min.php | 66 + 570 files changed, 28064 insertions(+), 25274 deletions(-) delete mode 100644 src/Phalcon/Acl.php create mode 100644 src/Phalcon/Cache.php create mode 100644 src/Phalcon/Collection.php delete mode 100644 src/Phalcon/CryptInterface.php delete mode 100644 src/Phalcon/Db.php delete mode 100644 src/Phalcon/Factory.php delete mode 100644 src/Phalcon/FactoryInterface.php delete mode 100644 src/Phalcon/Filter.php delete mode 100644 src/Phalcon/FilterInterface.php delete mode 100644 src/Phalcon/Flash.php delete mode 100644 src/Phalcon/FlashInterface.php delete mode 100644 src/Phalcon/Image.php delete mode 100644 src/Phalcon/Logger.php delete mode 100644 src/Phalcon/Translate.php delete mode 100644 src/Phalcon/Urlinterface.php rename src/Phalcon/acl/{Componentaware.php => ComponentAware.php} (66%) create mode 100644 src/Phalcon/acl/ComponentInterface.php delete mode 100644 src/Phalcon/acl/Componentinterface.php create mode 100644 src/Phalcon/acl/Enum.php rename src/Phalcon/acl/{Adapter.php => adapter/AbstractAdapter.php} (58%) rename src/Phalcon/acl/{ => adapter}/AdapterInterface.php (57%) create mode 100644 src/Phalcon/annotations/AnnotationsFactory.php delete mode 100644 src/Phalcon/annotations/Factory.php rename src/Phalcon/annotations/{Adapter.php => adapter/AbstractAdapter.php} (63%) rename src/Phalcon/annotations/{ => adapter}/AdapterInterface.php (72%) delete mode 100644 src/Phalcon/annotations/adapter/Apc.php rename src/Phalcon/annotations/adapter/{Files.php => Stream.php} (55%) delete mode 100644 src/Phalcon/annotations/adapter/Xcache.php rename src/Phalcon/{Application.php => application/AbstractApplication.php} (58%) create mode 100644 src/Phalcon/assets/AssetInterface.php delete mode 100644 src/Phalcon/assets/Assetinterface.php delete mode 100644 src/Phalcon/assets/Resource.php delete mode 100644 src/Phalcon/assets/ResourceInterface.php delete mode 100644 src/Phalcon/assets/resource/Css.php delete mode 100644 src/Phalcon/assets/resource/Js.php create mode 100644 src/Phalcon/cache/AdapterFactory.php delete mode 100644 src/Phalcon/cache/Backend.php delete mode 100644 src/Phalcon/cache/BackendInterface.php create mode 100644 src/Phalcon/cache/CacheFactory.php delete mode 100644 src/Phalcon/cache/Exception.php delete mode 100644 src/Phalcon/cache/FrontendInterface.php delete mode 100644 src/Phalcon/cache/Multiple.php create mode 100644 src/Phalcon/cache/adapter/AdapterInterface.php create mode 100644 src/Phalcon/cache/adapter/Apcu.php create mode 100644 src/Phalcon/cache/adapter/Libmemcached.php create mode 100644 src/Phalcon/cache/adapter/Memory.php create mode 100644 src/Phalcon/cache/adapter/Redis.php create mode 100644 src/Phalcon/cache/adapter/Stream.php delete mode 100644 src/Phalcon/cache/backend/Apc.php delete mode 100644 src/Phalcon/cache/backend/Apcu.php delete mode 100644 src/Phalcon/cache/backend/Factory.php delete mode 100644 src/Phalcon/cache/backend/File.php delete mode 100644 src/Phalcon/cache/backend/Libmemcached.php delete mode 100644 src/Phalcon/cache/backend/Memcache.php delete mode 100644 src/Phalcon/cache/backend/Memory.php delete mode 100644 src/Phalcon/cache/backend/Mongo.php delete mode 100644 src/Phalcon/cache/backend/Redis.php delete mode 100644 src/Phalcon/cache/backend/Xcache.php create mode 100644 src/Phalcon/cache/exception/Exception.php create mode 100644 src/Phalcon/cache/exception/InvalidArgumentException.php delete mode 100644 src/Phalcon/cache/frontend/Base64.php delete mode 100644 src/Phalcon/cache/frontend/Data.php delete mode 100644 src/Phalcon/cache/frontend/Factory.php delete mode 100644 src/Phalcon/cache/frontend/Igbinary.php delete mode 100644 src/Phalcon/cache/frontend/Json.php delete mode 100644 src/Phalcon/cache/frontend/Msgpack.php delete mode 100644 src/Phalcon/cache/frontend/None.php delete mode 100644 src/Phalcon/cache/frontend/Output.php create mode 100644 src/Phalcon/collection/Exception.php create mode 100644 src/Phalcon/collection/ReadOnly.php create mode 100644 src/Phalcon/config/ConfigFactory.php delete mode 100644 src/Phalcon/config/Factory.php create mode 100644 src/Phalcon/crypt/CryptInterface.php create mode 100644 src/Phalcon/db/AbstractDb.php create mode 100644 src/Phalcon/db/Enum.php rename src/Phalcon/db/{Adapter.php => adapter/AbstractAdapter.php} (68%) rename src/Phalcon/db/{ => adapter}/AdapterInterface.php (52%) create mode 100644 src/Phalcon/db/adapter/PdoFactory.php rename src/Phalcon/db/adapter/{Pdo.php => pdo/AbstractPdo.php} (75%) delete mode 100644 src/Phalcon/db/adapter/pdo/Factory.php rename src/Phalcon/{ => di}/DiInterface.php (63%) create mode 100644 src/Phalcon/di/exception/ServiceResolutionException.php delete mode 100644 src/Phalcon/di/exception/Serviceresolutionexception.php rename src/Phalcon/{Dispatcher.php => dispatcher/AbstractDispatcher.php} (54%) rename src/Phalcon/{ => dispatcher}/DispatcherInterface.php (63%) create mode 100644 src/Phalcon/dispatcher/Exception.php create mode 100644 src/Phalcon/domain/payload/Payload.php create mode 100644 src/Phalcon/domain/payload/PayloadFactory.php create mode 100644 src/Phalcon/domain/payload/PayloadInterface.php create mode 100644 src/Phalcon/domain/payload/ReadableInterface.php create mode 100644 src/Phalcon/domain/payload/Status.php create mode 100644 src/Phalcon/domain/payload/WriteableInterface.php rename src/Phalcon/{ => escaper}/EscaperInterface.php (65%) create mode 100644 src/Phalcon/factory/AbstractFactory.php create mode 100644 src/Phalcon/filter/Filter.php create mode 100644 src/Phalcon/filter/FilterFactory.php create mode 100644 src/Phalcon/filter/FilterInterface.php delete mode 100644 src/Phalcon/filter/Filterlocator.php delete mode 100644 src/Phalcon/filter/Filterlocatorfactory.php delete mode 100644 src/Phalcon/filter/UserFilterInterface.php rename src/Phalcon/filter/sanitize/{Absint.php => AbsInt.php} (61%) rename src/Phalcon/filter/sanitize/{Boolval.php => BoolVal.php} (60%) rename src/Phalcon/filter/sanitize/{Floatval.php => FloatVal.php} (60%) rename src/Phalcon/filter/sanitize/{Intval.php => IntVal.php} (59%) rename src/Phalcon/filter/sanitize/{Lowerfirst.php => LowerFirst.php} (59%) rename src/Phalcon/filter/sanitize/{Specialfull.php => SpecialFull.php} (67%) rename src/Phalcon/filter/sanitize/{Stringval.php => StringVal.php} (60%) rename src/Phalcon/filter/sanitize/{Upperfirst.php => UpperFirst.php} (59%) rename src/Phalcon/filter/sanitize/{Upperwords.php => UpperWords.php} (64%) create mode 100644 src/Phalcon/firewall/Exception.php create mode 100644 src/Phalcon/firewall/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/firewall/adapter/Acl.php create mode 100644 src/Phalcon/firewall/adapter/AdapterInterface.php create mode 100644 src/Phalcon/firewall/adapter/Annotations.php create mode 100644 src/Phalcon/firewall/adapter/micro/Acl.php create mode 100644 src/Phalcon/flash/AbstractFlash.php create mode 100644 src/Phalcon/flash/FlashInterface.php rename src/Phalcon/forms/{Element.php => element/AbstractElement.php} (58%) rename src/Phalcon/forms/{ => element}/ElementInterface.php (67%) create mode 100644 src/Phalcon/helper/Number.php create mode 100644 src/Phalcon/helper/Str.php create mode 100644 src/Phalcon/html/Attributes.php create mode 100644 src/Phalcon/html/TagFactory.php delete mode 100644 src/Phalcon/html/Taglocator.php delete mode 100644 src/Phalcon/html/Taglocatorfactory.php create mode 100644 src/Phalcon/html/attributes/AttributesInterface.php create mode 100644 src/Phalcon/html/attributes/RenderInterface.php create mode 100644 src/Phalcon/html/helper/AbstractHelper.php delete mode 100644 src/Phalcon/html/helper/Abstracthelper.php create mode 100644 src/Phalcon/html/helper/AnchorRaw.php create mode 100644 src/Phalcon/html/helper/Body.php create mode 100644 src/Phalcon/html/helper/Close.php create mode 100644 src/Phalcon/html/helper/ElementRaw.php delete mode 100644 src/Phalcon/html/helper/Formclose.php create mode 100644 src/Phalcon/html/helper/Img.php create mode 100644 src/Phalcon/html/helper/Label.php create mode 100644 src/Phalcon/html/helper/TextArea.php delete mode 100644 src/Phalcon/html/helper/Textarea.php create mode 100644 src/Phalcon/http/message/AbstractCommon.php create mode 100644 src/Phalcon/http/message/AbstractMessage.php create mode 100644 src/Phalcon/http/message/AbstractRequest.php create mode 100644 src/Phalcon/http/message/Request.php create mode 100644 src/Phalcon/http/message/RequestFactory.php create mode 100644 src/Phalcon/http/message/Response.php create mode 100644 src/Phalcon/http/message/ResponseFactory.php create mode 100644 src/Phalcon/http/message/ServerRequest.php create mode 100644 src/Phalcon/http/message/ServerRequestFactory.php create mode 100644 src/Phalcon/http/message/Stream.php create mode 100644 src/Phalcon/http/message/StreamFactory.php create mode 100644 src/Phalcon/http/message/UploadedFile.php create mode 100644 src/Phalcon/http/message/UploadedFileFactory.php create mode 100644 src/Phalcon/http/message/Uri.php create mode 100644 src/Phalcon/http/message/UriFactory.php create mode 100644 src/Phalcon/http/message/exception/InvalidArgumentException.php create mode 100644 src/Phalcon/http/message/stream/Input.php create mode 100644 src/Phalcon/http/message/stream/Memory.php create mode 100644 src/Phalcon/http/message/stream/Temp.php create mode 100644 src/Phalcon/http/server/AbstractMiddleware.php create mode 100644 src/Phalcon/http/server/AbstractRequestHandler.php delete mode 100644 src/Phalcon/image/AdapterInterface.php create mode 100644 src/Phalcon/image/Enum.php delete mode 100644 src/Phalcon/image/Factory.php create mode 100644 src/Phalcon/image/ImageFactory.php rename src/Phalcon/image/{Adapter.php => adapter/AbstractAdapter.php} (63%) create mode 100644 src/Phalcon/image/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/logger/Adapter.php create mode 100644 src/Phalcon/logger/AdapterFactory.php delete mode 100644 src/Phalcon/logger/AdapterInterface.php delete mode 100644 src/Phalcon/logger/Factory.php delete mode 100644 src/Phalcon/logger/Formatter.php delete mode 100644 src/Phalcon/logger/FormatterInterface.php create mode 100644 src/Phalcon/logger/Logger.php create mode 100644 src/Phalcon/logger/LoggerFactory.php delete mode 100644 src/Phalcon/logger/Multiple.php create mode 100644 src/Phalcon/logger/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/logger/adapter/Abstractadapter.php create mode 100644 src/Phalcon/logger/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/logger/adapter/Adapterinterface.php delete mode 100644 src/Phalcon/logger/adapter/Blackhole.php delete mode 100644 src/Phalcon/logger/adapter/File.php delete mode 100644 src/Phalcon/logger/adapter/Firephp.php create mode 100644 src/Phalcon/logger/formatter/AbstractFormatter.php delete mode 100644 src/Phalcon/logger/formatter/Abstractformatter.php delete mode 100644 src/Phalcon/logger/formatter/Firephp.php rename src/Phalcon/logger/formatter/{Formatterinterface.php => FormatterInterface.php} (51%) create mode 100644 src/Phalcon/messages/MessageInterface.php delete mode 100644 src/Phalcon/messages/Messageinterface.php delete mode 100644 src/Phalcon/mvc/Url.php delete mode 100644 src/Phalcon/mvc/model/Message.php delete mode 100644 src/Phalcon/mvc/model/MessageInterface.php delete mode 100644 src/Phalcon/mvc/model/Validator.php delete mode 100644 src/Phalcon/mvc/model/ValidatorInterface.php delete mode 100644 src/Phalcon/mvc/model/metadata/Apc.php delete mode 100644 src/Phalcon/mvc/model/metadata/Memcache.php delete mode 100644 src/Phalcon/mvc/model/metadata/Session.php rename src/Phalcon/mvc/model/metadata/{Files.php => Stream.php} (57%) delete mode 100644 src/Phalcon/mvc/model/metadata/Xcache.php delete mode 100644 src/Phalcon/mvc/model/validator/Email.php delete mode 100644 src/Phalcon/mvc/model/validator/Exclusionin.php delete mode 100644 src/Phalcon/mvc/model/validator/Inclusionin.php delete mode 100644 src/Phalcon/mvc/model/validator/Ip.php delete mode 100644 src/Phalcon/mvc/model/validator/Numericality.php delete mode 100644 src/Phalcon/mvc/model/validator/PresenceOf.php delete mode 100644 src/Phalcon/mvc/model/validator/Regex.php delete mode 100644 src/Phalcon/mvc/model/validator/StringLength.php delete mode 100644 src/Phalcon/mvc/model/validator/Uniqueness.php delete mode 100644 src/Phalcon/mvc/model/validator/Url.php delete mode 100644 src/Phalcon/mvc/url/Exception.php delete mode 100644 src/Phalcon/mvc/user/Component.php delete mode 100644 src/Phalcon/mvc/user/Module.php delete mode 100644 src/Phalcon/mvc/user/Plugin.php rename src/Phalcon/mvc/view/{Engine.php => engine/AbstractEngine.php} (62%) rename src/Phalcon/mvc/view/{ => engine}/EngineInterface.php (68%) delete mode 100644 src/Phalcon/paginator/Adapter.php delete mode 100644 src/Phalcon/paginator/Factory.php create mode 100644 src/Phalcon/paginator/PaginatorFactory.php create mode 100644 src/Phalcon/paginator/RepositoryInterface.php delete mode 100644 src/Phalcon/paginator/Repositoryinterface.php create mode 100644 src/Phalcon/paginator/adapter/AbstractAdapter.php rename src/Phalcon/paginator/{ => adapter}/AdapterInterface.php (62%) delete mode 100644 src/Phalcon/queue/Beanstalk.php delete mode 100644 src/Phalcon/queue/beanstalk/Exception.php delete mode 100644 src/Phalcon/queue/beanstalk/Job.php delete mode 100644 src/Phalcon/service/Exception.php delete mode 100644 src/Phalcon/service/Locator.php delete mode 100644 src/Phalcon/service/Locatorfactoryinterface.php delete mode 100644 src/Phalcon/service/Locatorinterface.php delete mode 100644 src/Phalcon/session/Adapter.php delete mode 100644 src/Phalcon/session/AdapterInterface.php delete mode 100644 src/Phalcon/session/BagInterface.php delete mode 100644 src/Phalcon/session/Factory.php create mode 100644 src/Phalcon/session/ManagerInterface.php delete mode 100644 src/Phalcon/session/Managerinterface.php create mode 100644 src/Phalcon/session/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/session/adapter/Files.php delete mode 100644 src/Phalcon/session/adapter/Memcache.php create mode 100644 src/Phalcon/session/adapter/Stream.php create mode 100644 src/Phalcon/storage/AdapterFactory.php create mode 100644 src/Phalcon/storage/Exception.php create mode 100644 src/Phalcon/storage/SerializerFactory.php create mode 100644 src/Phalcon/storage/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/storage/adapter/AdapterInterface.php create mode 100644 src/Phalcon/storage/adapter/Apcu.php create mode 100644 src/Phalcon/storage/adapter/Libmemcached.php create mode 100644 src/Phalcon/storage/adapter/Memory.php create mode 100644 src/Phalcon/storage/adapter/Redis.php create mode 100644 src/Phalcon/storage/adapter/Stream.php create mode 100644 src/Phalcon/storage/serializer/AbstractSerializer.php create mode 100644 src/Phalcon/storage/serializer/Base64.php create mode 100644 src/Phalcon/storage/serializer/Igbinary.php create mode 100644 src/Phalcon/storage/serializer/Json.php create mode 100644 src/Phalcon/storage/serializer/Msgpack.php create mode 100644 src/Phalcon/storage/serializer/None.php create mode 100644 src/Phalcon/storage/serializer/Php.php create mode 100644 src/Phalcon/storage/serializer/SerializerInterface.php delete mode 100644 src/Phalcon/translate/Factory.php create mode 100644 src/Phalcon/translate/InterpolatorFactory.php delete mode 100644 src/Phalcon/translate/InterpolatorInterface.php create mode 100644 src/Phalcon/translate/TranslateFactory.php rename src/Phalcon/translate/{Adapter.php => adapter/AbstractAdapter.php} (58%) rename src/Phalcon/translate/{ => adapter}/AdapterInterface.php (53%) create mode 100644 src/Phalcon/translate/interpolator/InterpolatorInterface.php rename src/Phalcon/{mvc => url}/UrlInterface.php (61%) create mode 100644 src/Phalcon/validation/AbstractCombinedFieldsValidator.php create mode 100644 src/Phalcon/validation/AbstractValidator.php create mode 100644 src/Phalcon/validation/AbstractValidatorComposite.php delete mode 100644 src/Phalcon/validation/CombinedFieldsValidator.php delete mode 100644 src/Phalcon/validation/Message.php delete mode 100644 src/Phalcon/validation/MessageInterface.php rename src/Phalcon/{ => validation}/ValidationInterface.php (56%) delete mode 100644 src/Phalcon/validation/Validator.php create mode 100644 src/Phalcon/validation/ValidatorCompositeInterface.php create mode 100644 src/Phalcon/validation/ValidatorFactory.php delete mode 100644 src/Phalcon/validation/message/Group.php create mode 100644 src/Phalcon/validation/validator/file/AbstractFile.php create mode 100644 src/Phalcon/validation/validator/file/MimeType.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Equal.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Max.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Min.php create mode 100644 src/Phalcon/validation/validator/file/size/Equal.php create mode 100644 src/Phalcon/validation/validator/file/size/Max.php create mode 100644 src/Phalcon/validation/validator/file/size/Min.php create mode 100644 src/Phalcon/validation/validator/stringlength/Max.php create mode 100644 src/Phalcon/validation/validator/stringlength/Min.php diff --git a/src/Phalcon/Acl.php b/src/Phalcon/Acl.php deleted file mode 100644 index 498be5ea..00000000 --- a/src/Phalcon/Acl.php +++ /dev/null @@ -1,60 +0,0 @@ - - * use Phalcon\Acl; - * use Phalcon\Acl\Role; - * use Phalcon\Acl\Resource; - * use Phalcon\Acl\Adapter\Memory; - * - * $acl = new Memory(); - * - * // Default action is deny access - * $acl->setDefaultAction(Acl::DENY); - * - * // Create some roles - * $roleAdmins = new Role("Administrators", "Super-User role"); - * $roleGuests = new Role("Guests"); - * - * // Add "Guests" role to acl - * $acl->addRole($roleGuests); - * - * // Add "Designers" role to acl - * $acl->addRole("Designers"); - * - * // Define the "Customers" resource - * $customersResource = new Resource("Customers", "Customers management"); - * - * // Add "customers" resource with a couple of operations - * $acl->addResource($customersResource, "search"); - * $acl->addResource($customersResource, ["create", "update"]); - * - * // Set access level for roles into resources - * $acl->allow("Guests", "Customers", "search"); - * $acl->allow("Guests", "Customers", "create"); - * $acl->deny("Guests", "Customers", "update"); - * - * // Check whether role has access to the operations - * $acl->isAllowed("Guests", "Customers", "edit"); // Returns 0 - * $acl->isAllowed("Guests", "Customers", "search"); // Returns 1 - * $acl->isAllowed("Guests", "Customers", "create"); // Returns 1 - * - */ -abstract class Acl -{ - - const ALLOW = 1; - - - const DENY = 0; - - -} diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php new file mode 100644 index 00000000..444fa3d7 --- /dev/null +++ b/src/Phalcon/Cache.php @@ -0,0 +1,164 @@ + value pairs. Cache keys that do not exist or are stale will have $default as value. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + * @param iterable $keys A list of keys that can obtained in a single operation. + * @param mixed $defaultValue + * @return mixed + */ + public function getMultiple($keys, $defaultValue = null) {} + + /** + * Determines whether an item is present in the cache. + * + * @param string $key The cache item key. + * + * @return bool + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + * @param mixed $key + * @return bool + */ + public function has($key): bool {} + + /** + * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. + * + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + * @param string $key The key of the item to store. + * @param mixed $value The value of the item to store. Must be serializable. + * @param mixed $ttl + * @return bool + */ + public function set($key, $value, $ttl = null): bool {} + + /** + * Persists a set of key => value pairs in the cache, with an optional TTL. + * + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if $values is neither an array nor a Traversable, + * or if any of the $values are not a legal value. + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param mixed $ttl + * @return bool + */ + public function setMultiple($values, $ttl = null): bool {} + + /** + * Checks the key. If it contains invalid characters an exception is thrown + * + * @param mixed $key + */ + protected function checkKey($key) {} + + /** + * Checks the key. If it contains invalid characters an exception is thrown + * + * @param mixed $keys + */ + protected function checkKeys($keys) {} + +} diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php new file mode 100644 index 00000000..ecde5727 --- /dev/null +++ b/src/Phalcon/Collection.php @@ -0,0 +1,217 @@ + + * ```php * $config = new \Phalcon\Config( * [ * "database" => [ @@ -26,109 +25,30 @@ * ], * ] * ); - * + * ``` */ -class Config implements \ArrayAccess, \Countable +class Config extends \Phalcon\Collection { const DEFAULT_PATH_DELIMITER = '.'; - - static protected $_pathDelimiter; - - /** - * Phalcon\Config constructor - * - * @param array $arrayConfig + * @var string */ - public function __construct(array $arrayConfig = null) {} + protected $pathDelimiter = null; - /** - * Allows to check whether an attribute is defined using the array-syntax - * - * - * var_dump( - * isset($config["database"]) - * ); - * - * - * @param mixed $index - * @return bool - */ - public function offsetExists($index) {} /** - * Returns a value from current config using a dot separated path. - * - * - * echo $config->path("unknown.path", "default", "."); - * - * - * @param string $path - * @param mixed $defaultValue - * @param mixed $delimiter - * @return mixed - */ - public function path($path, $defaultValue = null, $delimiter = null) {} - - /** - * Gets an attribute from the configuration, if the attribute isn't defined returns null - * If the value is exactly null or is not defined the default value will be used instead - * - * - * echo $config->get("controllersDir", "../app/controllers/"); - * - * - * @param mixed $index - * @param mixed $defaultValue - * @return mixed - */ - public function get($index, $defaultValue = null) {} - - /** - * Gets an attribute using the array-syntax - * - * - * print_r( - * $config["database"] - * ); - * + * Gets the default path delimiter * - * @param mixed $index * @return string */ - public function offsetGet($index) {} - - /** - * Sets an attribute using the array-syntax - * - * - * $config["database"] = [ - * "type" => "Sqlite", - * ]; - * - * - * @param mixed $index - * @param mixed $value - */ - public function offsetSet($index, $value) {} - - /** - * Unsets an attribute using the array-syntax - * - * - * unset($config["database"]); - * - * - * @param mixed $index - */ - public function offsetUnset($index) {} + public function getPathDelimiter(): string {} /** * Merges a configuration into the current one * - * + * ```php * $appConfig = new \Phalcon\Config( * [ * "database" => [ @@ -138,74 +58,62 @@ public function offsetUnset($index) {} * ); * * $globalConfig->merge($appConfig); - * + * ``` * - * @param Config $config + * @param mixed $toMerge * @return Config */ - public function merge(Config $config) {} + public function merge($toMerge): Config {} /** - * Converts recursively the object to an array - * - * - * print_r( - * $config->toArray() - * ); - * - * - * @return array - */ - public function toArray() {} - - /** - * Returns the count of properties set in the config - * - * - * print count($config); - * - * - * or + * Returns a value from current config using a dot separated path. * - * - * print $config->count(); - * + * ```php + * echo $config->path("unknown.path", "default", "."); + * ``` * - * @return int + * @param string $path + * @param mixed $defaultValue + * @param mixed $delimiter */ - public function count() {} + public function path(string $path, $defaultValue = null, $delimiter = null) {} /** - * Restores the state of a Phalcon\Config object + * Sets the default path delimiter * - * @param array $data + * @param string $delimiter * @return Config */ - public static function __set_state(array $data) {} + public function setPathDelimiter(string $delimiter = null): Config {} /** - * Sets the default path delimiter + * Converts recursively the object to an array * - * @param string $delimiter + * ```php + * print_r( + * $config->toArray() + * ); + * ``` + * + * @return array */ - public static function setPathDelimiter($delimiter = null) {} + public function toArray(): array {} /** - * Gets the default path delimiter + * Performs a merge recursively * - * @return string + * @param array $source + * @param array $target + * @return array */ - public static function getPathDelimiter() {} + final protected function internalMerge(array $source, array $target): array {} /** - * Helper method for merge configs (forwarding nested config instance) - * - * @param Config instance = null + * Sets the collection data * - * @param Config $config - * @param mixed $instance - * @return Config + * @param mixed $element + * @param mixed $value */ - protected final function _merge(Config $config, $instance = null) {} + protected function setData($element, $value) {} } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 73a9f388..22b70ee1 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -2,33 +2,38 @@ namespace Phalcon; -use Psr\Container\ContainerInterface; -use Phalcon\DiInterface; - -class Container implements ContainerInterface +/** + * PSR-11 Wrapper for `Phalcon\Di` + */ +class Container implements \Psr\Container\ContainerInterface { - /** - * @var - */ - protected $container; + /** + * @var + */ + protected $container; + + + /** + * Phalcon\Container constructor + * + * @param \Phalcon\Di\DiInterface $container + */ + public function __construct(\Phalcon\Di\DiInterface $container) {} - /** - * Phalcon\Di constructor - */ - public function __construct(DiInterface $container) - { - } + /** + * Return the service + * + * @param mixed $name + * @return mixed + */ + public function get($name) {} - /** - * Return the service - */ - public function get($name) { - } + /** + * Whether a service exists or not in the container + * + * @param mixed $name + * @return bool + */ + public function has($name): bool {} - /** - * Whether a service exists or not in the container - */ - public function has($name) : bool - { - } } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 722ef5af..9a547569 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Crypt + * Provides encryption capabilities to Phalcon applications. * - * Provides encryption facilities to Phalcon applications. - * - * + * ```php * use Phalcon\Crypt; * * $crypt = new Crypt(); @@ -20,18 +18,15 @@ * $encrypted = $crypt->encrypt($text, $key); * * echo $crypt->decrypt($encrypted, $key); - * + * ``` */ -class Crypt implements \Phalcon\CryptInterface +class Crypt implements \Phalcon\Crypt\CryptInterface { - const PADDING_DEFAULT = 0; - - const PADDING_ANSI_X_923 = 1; - const PADDING_PKCS7 = 2; + const PADDING_DEFAULT = 0; const PADDING_ISO_10126 = 3; @@ -40,19 +35,43 @@ class Crypt implements \Phalcon\CryptInterface const PADDING_ISO_IEC_7816_4 = 4; - const PADDING_ZERO = 5; + const PADDING_PKCS7 = 2; const PADDING_SPACE = 6; - protected $_key; + const PADDING_ZERO = 5; + /** + * @var string + */ + protected $authTag; - protected $_padding = 0; + /** + * @var string + */ + protected $authData = ''; + + /** + * @var int + */ + protected $authTagLength = 16; + /** + * @var string + */ + protected $key; + + /** + * @var int + */ + protected $padding = 0; - protected $_cipher = 'aes-256-cfb'; + /** + * @var string + */ + protected $cipher = 'aes-256-cfb'; /** * Available cipher methods. @@ -77,224 +96,249 @@ class Crypt implements \Phalcon\CryptInterface /** * Whether calculating message digest enabled or not. - * NOTE: This feature will be enabled by default in Phalcon 4.0.0 * * @var bool */ - protected $useSigning = false; + protected $useSigning = true; + /** + * @return string + */ + public function getAuthTag(): string {} + + /** + * @return string + */ + public function getAuthData(): string {} + + /** + * @return int + */ + public function getAuthTagLength(): int {} + /** * Phalcon\Crypt constructor. * * @param string $cipher * @param bool $useSigning */ - public function __construct($cipher = 'aes-256-cfb', $useSigning = false) {} + public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = false) {} /** - * Changes the padding scheme used. + * Decrypts an encrypted text. * - * @param int $scheme - * @return \Phalcon\CryptInterface + * ```php + * $encrypted = $crypt->decrypt( + * $encrypted, + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * ``` + * + * @param string $text + * @param string $key + * @return string */ - public function setPadding($scheme) {} + public function decrypt(string $text, string $key = null): string {} /** - * Sets the cipher algorithm for data encryption and decryption. + * Decrypt a text that is coded as a base64 string. * - * The `aes-256-gcm' is the preferable cipher, but it is not usable - * until the openssl library is upgraded, which is available in PHP 7.1. + * @throws \Phalcon\Crypt\Mismatch + * @param string $text + * @param mixed $key + * @param bool $safe + * @return string + */ + public function decryptBase64(string $text, $key = null, bool $safe = false): string {} + + /** + * Encrypts a text. * - * The `aes-256-ctr' is arguably the best choice for cipher - * algorithm for current openssl library version. + * ```php + * $encrypted = $crypt->encrypt( + * "Top secret", + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * ``` * - * @param string $cipher - * @return \Phalcon\CryptInterface + * @param string $text + * @param string $key + * @return string */ - public function setCipher($cipher) {} + public function encrypt(string $text, string $key = null): string {} /** - * Returns the current cipher + * Encrypts a text returning the result as a base64 string. * + * @param string $text + * @param mixed $key + * @param bool $safe * @return string */ - public function getCipher() {} + public function encryptBase64(string $text, $key = null, bool $safe = false): string {} /** - * Sets the encryption key. - * - * The `$key' should have been previously generated in a cryptographically safe way. - * - * Bad key: - * "le password" - * - * Better (but still unsafe): - * "#1dj8$=dp?.ak//j1V$~%0X" - * - * Good key: - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * Returns a list of available ciphers. * - * @see \Phalcon\Security\Random - * @param string $key - * @return \Phalcon\CryptInterface + * @return array */ - public function setKey($key) {} + public function getAvailableCiphers(): array {} /** - * Returns the encryption key + * Return a list of registered hashing algorithms suitable for hash_hmac. * - * @return string + * @return array */ - public function getKey() {} + public function getAvailableHashAlgos(): array {} /** - * Set the name of hashing algorithm. + * Returns the current cipher * - * @throws \Phalcon\Crypt\Exception - * @param string $hashAlgo - * @return Crypt + * @return string */ - public function setHashAlgo($hashAlgo) {} + public function getCipher(): string {} /** * Get the name of hashing algorithm. * * @return string */ - public function getHashAlgo() {} + public function getHashAlgo(): string {} /** - * Sets if the calculating message digest must used. - * - * NOTE: This feature will be enabled by default in Phalcon 4.0.0 + * Returns the encryption key * - * @param bool $useSigning - * @return Crypt + * @return string */ - public function useSigning($useSigning) {} + public function getKey(): string {} /** - * Pads texts before encryption. - * - * @link http://www.di-mgt.com.au/cryptopad.html - * @param string $text - * @param string $mode - * @param int $blockSize - * @param int $paddingType + * @param string $tag + * @return \Phalcon\Crypt\CryptInterface */ - protected function _cryptPadText($text, $mode, $blockSize, $paddingType) {} + public function setAuthTag(string $tag): CryptInterface {} /** - * Removes a padding from a text. - * - * If the function detects that the text was not padded, it will return it unmodified. - * - * @param string $text Message to be unpadded - * @param string $mode Encryption mode; unpadding is applied only in CBC or ECB mode - * @param int $blockSize Cipher block size - * @param int $paddingType Padding scheme + * @param string $data + * @return \Phalcon\Crypt\CryptInterface */ - protected function _cryptUnpadText($text, $mode, $blockSize, $paddingType) {} + public function setAuthData(string $data): CryptInterface {} /** - * Encrypts a text. - * - * - * $encrypted = $crypt->encrypt( - * "Top secret", - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * - * - * @param string $text - * @param string $key - * @return string + * @param int $length + * @return \Phalcon\Crypt\CryptInterface */ - public function encrypt($text, $key = null) {} + public function setAuthTagLength(int $length): CryptInterface {} /** - * Decrypts an encrypted text. + * Sets the cipher algorithm for data encryption and decryption. * - * - * $encrypted = $crypt->decrypt( - * $encrypted, - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * + * The `aes-256-gcm' is the preferable cipher, but it is not usable + * until the openssl library is upgraded, which is available in PHP 7.1. * - * @throws \Phalcon\Crypt\Mismatch - * @param string $text - * @param string $key - * @return string + * The `aes-256-ctr' is arguably the best choice for cipher + * algorithm for current openssl library version. + * + * @param string $cipher + * @return \Phalcon\Crypt\CryptInterface */ - public function decrypt($text, $key = null) {} + public function setCipher(string $cipher): CryptInterface {} /** - * Encrypts a text returning the result as a base64 string. + * Set the name of hashing algorithm. * - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string + * @throws \Phalcon\Crypt\Exception + * @param string $hashAlgo + * @return \Phalcon\Crypt\CryptInterface */ - public function encryptBase64($text, $key = null, $safe = false) {} + public function setHashAlgo(string $hashAlgo): CryptInterface {} /** - * Decrypt a text that is coded as a base64 string. + * Sets the encryption key. * - * @throws \Phalcon\Crypt\Mismatch - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string + * The `$key' should have been previously generated in a cryptographically + * safe way. + * + * Bad key: + * "le password" + * + * Better (but still unsafe): + * "#1dj8$=dp?.ak//j1V$~%0X" + * + * Good key: + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * + * @param string $key + * @return \Phalcon\Crypt\CryptInterface */ - public function decryptBase64($text, $key = null, $safe = false) {} + public function setKey(string $key): CryptInterface {} /** - * Returns a list of available ciphers. + * Changes the padding scheme used. * - * @return array + * @param int $scheme + * @return \Phalcon\Crypt\CryptInterface */ - public function getAvailableCiphers() {} + public function setPadding(int $scheme): CryptInterface {} /** - * Return a list of registered hashing algorithms suitable for hash_hmac. + * Sets if the calculating message digest must used. * - * @return array + * @param bool $useSigning + * @return \Phalcon\Crypt\CryptInterface */ - public function getAvailableHashAlgos() {} + public function useSigning(bool $useSigning): CryptInterface {} /** * Assert the cipher is available. * - * @throws \Phalcon\Crypt\Exception * @param string $cipher */ - protected function assertCipherIsAvailable($cipher) {} + protected function assertCipherIsAvailable(string $cipher) {} /** * Assert the hash algorithm is available. * - * @throws \Phalcon\Crypt\Exception * @param string $hashAlgo */ - protected function assertHashAlgorithmAvailable($hashAlgo) {} + protected function assertHashAlgorithmAvailable(string $hashAlgo) {} /** * Initialize available cipher algorithms. * - * @throws \Phalcon\Crypt\Exception * @param string $cipher * @return int */ - protected function getIvLength($cipher) {} + protected function getIvLength(string $cipher): int {} /** * Initialize available cipher algorithms. - * - * @throws \Phalcon\Crypt\Exception */ protected function initializeAvailableCiphers() {} + /** + * Pads texts before encryption. See [cryptopad](http://www.di-mgt.com.au/cryptopad.html) + * + * @param string $text + * @param string $mode + * @param int $blockSize + * @param int $paddingType + * @return string + */ + protected function cryptPadText(string $text, string $mode, int $blockSize, int $paddingType): string {} + + /** + * Removes a padding from a text. + * + * If the function detects that the text was not padded, it will return it + * unmodified. + * + * @param string $text + * @param string $mode + * @param int $blockSize + * @param int $paddingType + */ + protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) {} + } diff --git a/src/Phalcon/CryptInterface.php b/src/Phalcon/CryptInterface.php deleted file mode 100644 index d79c16f8..00000000 --- a/src/Phalcon/CryptInterface.php +++ /dev/null @@ -1,86 +0,0 @@ - - * use Phalcon\Db; - * use Phalcon\Db\Exception; - * use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; - * - * try { - * $connection = new MysqlConnection( - * [ - * "host" => "192.168.0.11", - * "username" => "sigma", - * "password" => "secret", - * "dbname" => "blog", - * "port" => "3306", - * ] - * ); - * - * $result = $connection->query( - * "SELECT FROM robots LIMIT 5" - * ); - * - * $result->setFetchMode(Db::FETCH_NUM); - * - * while ($robot = $result->fetch()) { - * print_r($robot); - * } - * } catch (Exception $e) { - * echo $e->getMessage(), PHP_EOL; - * } - * - */ -abstract class Db -{ - - const FETCH_LAZY = 1; - - - const FETCH_ASSOC = 2; - - - const FETCH_NAMED = 11; - - - const FETCH_NUM = 3; - - - const FETCH_BOTH = 4; - - - const FETCH_OBJ = 5; - - - const FETCH_BOUND = 6; - - - const FETCH_COLUMN = 7; - - - const FETCH_CLASS = 8; - - - const FETCH_INTO = 9; - - - const FETCH_FUNC = 10; - - - const FETCH_GROUP = 65536; - - - const FETCH_UNIQUE = 196608; - - - const FETCH_KEY_PAIR = 12; - - - const FETCH_CLASSTYPE = 262144; - - - const FETCH_SERIALIZE = 524288; - - - const FETCH_PROPS_LATE = 1048576; - - - /** - * Enables/disables options in the Database component - * - * @param array $options - */ - public static function setup(array $options) {} - -} diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index cfe5cfe6..291d4d30 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -3,69 +3,90 @@ namespace Phalcon; /** - * Phalcon\Debug - * * Provides debug capabilities to Phalcon applications */ class Debug { - - public $_uri = '//static.phalconphp.com/www/debug/3.0.x/'; - - - public $_theme = 'default'; - - - protected $_hideDocumentRoot = false; - - - protected $_showBackTrace = true; + /** + * @var array + */ + protected $blacklist = array('request' => array(), 'server' => array()); - protected $_showFiles = true; + protected $data; + /** + * @var bool + */ + protected $hideDocumentRoot = false; - protected $_showFileFragment = false; + /** + * @var bool + */ + static protected $isActive; + /** + * @var bool + */ + protected $showBackTrace = true; - protected $_data; + /** + * @var bool + */ + protected $showFileFragment = false; + /** + * @var bool + */ + protected $showFiles = true; - static protected $_isActive; + /** + * @var string + */ + protected $uri = 'https://assets.phalconphp.com/debug/4.0.x/'; /** - * Change the base URI for static resources + * Clears are variables added previously * - * @param string $uri * @return Debug */ - public function setUri($uri) {} + public function clearVars(): Debug {} /** - * Sets if files the exception's backtrace must be showed + * Adds a variable to the debug output * - * @param bool $showBackTrace + * @param mixed $varz + * @param string $key * @return Debug */ - public function setShowBackTrace($showBackTrace) {} + public function debugVar($varz, string $key = null): Debug {} /** - * Set if files part of the backtrace must be shown in the output + * Returns the css sources * - * @param bool $showFiles - * @return Debug + * @return string */ - public function setShowFiles($showFiles) {} + public function getCssSources(): string {} /** - * Sets if files must be completely opened and showed in the output - * or just the fragment related to the exception + * Returns the javascript sources * - * @param bool $showFileFragment - * @return Debug + * @return string */ - public function setShowFileFragment($showFileFragment) {} + public function getJsSources(): string {} + + /** + * Generates a link to the current version documentation + * + * @return string + */ + public function getVersion(): string {} + + /** + * Halts the request showing a backtrace + */ + public function halt() {} /** * Listen for uncaught exceptions and unsilent notices or warnings @@ -74,124 +95,114 @@ public function setShowFileFragment($showFileFragment) {} * @param bool $lowSeverity * @return Debug */ - public function listen($exceptions = true, $lowSeverity = false) {} + public function listen(bool $exceptions = true, bool $lowSeverity = false): Debug {} /** * Listen for uncaught exceptions * * @return Debug */ - public function listenExceptions() {} + public function listenExceptions(): Debug {} /** * Listen for unsilent notices or warnings * * @return Debug */ - public function listenLowSeverity() {} + public function listenLowSeverity(): Debug {} /** - * Halts the request showing a backtrace + * Handles uncaught exceptions + * + * @param \Exception $exception + * @return bool */ - public function halt() {} + public function onUncaughtException(\Exception $exception): bool {} /** - * Adds a variable to the debug output + * Throws an exception when a notice or warning is raised * - * @param mixed $varz - * @param string $key - * @return Debug + * @param mixed $severity + * @param mixed $message + * @param mixed $file + * @param mixed $line + * @param mixed $context */ - public function debugVar($varz, $key = null) {} + public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} /** - * Clears are variables added previously + * Sets if files the exception's backtrace must be showed * + * @param array $blacklist * @return Debug */ - public function clearVars() {} + public function setBlacklist(array $blacklist): Debug {} /** - * Escapes a string with htmlentities + * Sets if files the exception's backtrace must be showed * - * @param mixed $value - * @return string + * @param bool $showBackTrace + * @return Debug */ - protected function _escapeString($value) {} + public function setShowBackTrace(bool $showBackTrace): Debug {} /** - * Produces a recursive representation of an array + * Sets if files must be completely opened and showed in the output + * or just the fragment related to the exception * - * @param array $argument - * @param mixed $n - * @return string|null + * @param bool $showFileFragment + * @return Debug */ - protected function _getArrayDump(array $argument, $n = 0) {} + public function setShowFileFragment(bool $showFileFragment): Debug {} /** - * Produces an string representation of a variable + * Set if files part of the backtrace must be shown in the output * - * @param mixed $variable - * @return string + * @param bool $showFiles + * @return Debug */ - protected function _getVarDump($variable) {} + public function setShowFiles(bool $showFiles): Debug {} /** - * Returns the major framework's version + * Change the base URI for static resources * - * @deprecated Will be removed in 4.0.0 - * @see Phalcon\Version::getPart() - * @deprecated - * @return string + * @param string $uri + * @return Debug */ - public function getMajorVersion() {} + public function setUri(string $uri): Debug {} /** - * Generates a link to the current version documentation + * Escapes a string with htmlentities * + * @param mixed $value * @return string */ - public function getVersion() {} + protected function escapeString($value): string {} /** - * Returns the css sources + * Produces a recursive representation of an array * - * @return string + * @param array $argument + * @param mixed $n + * @return string|null */ - public function getCssSources() {} + protected function getArrayDump(array $argument, $n = 0): ?string {} /** - * Returns the javascript sources + * Produces an string representation of a variable * + * @param mixed $variable * @return string */ - public function getJsSources() {} + protected function getVarDump($variable): string {} /** * Shows a backtrace item * * @param int $n * @param array $trace + * @return string */ - protected final function showTraceItem($n, array $trace) {} - - /** - * Throws an exception when a notice or warning is raised - * - * @param mixed $severity - * @param mixed $message - * @param mixed $file - * @param mixed $line - * @param mixed $context - */ - public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} - - /** - * Handles uncaught exceptions - * - * @param \Exception $exception - * @return bool - */ - public function onUncaughtException(\Exception $exception) {} + final protected function showTraceItem(int $n, array $trace): string {} } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 1ebe86df..4f4d7bb0 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -3,23 +3,24 @@ namespace Phalcon; /** - * Phalcon\Di + * Phalcon\Di is a component that implements Dependency Injection/Service + * Location of services and it's itself a container for them. * - * Phalcon\Di is a component that implements Dependency Injection/Service Location - * of services and it's itself a container for them. + * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the + * different components of the framework. The developer can also use this + * component to inject dependencies and manage global instances of the different + * classes used in the application. * - * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the different - * components of the framework. The developer can also use this component to inject dependencies - * and manage global instances of the different classes used in the application. + * Basically, this component implements the `Inversion of Control` pattern. + * Applying this, the objects do not receive their dependencies using setters or + * constructors, but requesting a service dependency injector. This reduces the + * overall complexity, since there is only one way to get the required + * dependencies within a component. * - * Basically, this component implements the `Inversion of Control` pattern. Applying this, - * the objects do not receive their dependencies using setters or constructors, but requesting - * a service dependency injector. This reduces the overall complexity, since there is only one - * way to get the required dependencies within a component. + * Additionally, this pattern increases testability in the code, thus making it + * less prone to errors. * - * Additionally, this pattern increases testability in the code, thus making it less prone to errors. - * - * + * ```php * use Phalcon\Di; * use Phalcon\Http\Request; * @@ -37,31 +38,26 @@ * ); * * $request = $di->getRequest(); - * + * ``` */ -class Di implements \Phalcon\DiInterface +class Di implements \Phalcon\Di\DiInterface { /** * List of registered services */ - protected $_services; + protected $services; /** * List of shared instances */ - protected $_sharedInstances; - - /** - * To know if the latest resolved instance was shared or not - */ - protected $_freshInstance = false; + protected $sharedInstances; /** * Events Manager * - * @var \Phalcon\Events\ManagerInterface + * @var ManagerInterface */ - protected $_eventsManager; + protected $eventsManager; /** * Latest DI build @@ -75,66 +71,48 @@ class Di implements \Phalcon\DiInterface public function __construct() {} /** - * Sets the internal event manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Returns the internal event manager + * Magic method to get or set services using setters/getters * - * @return \Phalcon\Events\ManagerInterface + * @param string $method + * @param array $arguments + * @return mixed|null */ - public function getInternalEventsManager() {} + public function __call(string $method, array $arguments = array()): ? {} /** - * Registers a service in the services container + * Attempts to register a service in the services container + * Only is successful if a service hasn't been registered previously + * with the same name * * @param string $name * @param mixed $definition * @param bool $shared - * @return \Phalcon\Di\ServiceInterface - */ - public function set($name, $definition, $shared = false) {} - - /** - * Registers an "always shared" service in the services container - * - * @param string $name - * @param mixed $definition - * @return \Phalcon\Di\ServiceInterface + * @return bool|\Phalcon\Di\ServiceInterface */ - public function setShared($name, $definition) {} + public function attempt(string $name, $definition, bool $shared = false) {} /** - * Removes a service in the services container - * It also removes any shared instance created for the service + * Resolves the service based on its configuration * * @param string $name + * @param mixed $parameters + * @return mixed */ - public function remove($name) {} + public function get(string $name, $parameters = null) {} /** - * Attempts to register a service in the services container - * Only is successful if a service hasn't been registered previously - * with the same name + * Return the latest DI created * - * @param string $name - * @param mixed $definition - * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return null|\Phalcon\Di\DiInterface */ - public function attempt($name, $definition, $shared = false) {} + public static function getDefault(): ?DiInterface {} /** - * Sets a service using a raw Phalcon\Di\Service definition + * Returns the internal event manager * - * @param string $name - * @param \Phalcon\Di\ServiceInterface $rawDefinition - * @return \Phalcon\Di\ServiceInterface + * @return \Phalcon\Events\ManagerInterface */ - public function setRaw($name, \Phalcon\Di\ServiceInterface $rawDefinition) {} + public function getInternalEventsManager(): ManagerInterface {} /** * Returns a service definition without resolving @@ -142,7 +120,7 @@ public function setRaw($name, \Phalcon\Di\ServiceInterface $rawDefinition) {} * @param string $name * @return mixed */ - public function getRaw($name) {} + public function getRaw(string $name) {} /** * Returns a Phalcon\Di\Service instance @@ -150,76 +128,118 @@ public function getRaw($name) {} * @param string $name * @return \Phalcon\Di\ServiceInterface */ - public function getService($name) {} + public function getService(string $name): ServiceInterface {} /** - * Resolves the service based on its configuration + * Return the services registered in the DI * - * @param string $name - * @param mixed $parameters - * @return mixed + * @return array|\Phalcon\Di\ServiceInterface[] */ - public function get($name, $parameters = null) {} + public function getServices(): array {} /** * Resolves a service, the resolved service is stored in the DI, subsequent * requests for this service will return the same instance * * @param string $name - * @param array $parameters + * @param mixed $parameters * @return mixed */ - public function getShared($name, $parameters = null) {} + public function getShared(string $name, $parameters = null) {} /** - * Check whether the DI contains a service by a name + * Loads services from a Config object. * - * @param string $name - * @return bool + * @param \Phalcon\Config $config */ - public function has($name) {} + protected function loadFromConfig(\Phalcon\Config $config) {} /** - * Check whether the last service obtained via getShared produced a fresh instance or an existing one + * Loads services from a php config file. * - * @return bool - */ - public function wasFreshInstance() {} - - /** - * Return the services registered in the DI + * ```php + * $di->loadFromPhp("path/services.php"); + * ``` + * + * And the services can be specified in the file as: + * + * ```php + * return [ + * 'myComponent' => [ + * 'className' => '\Acme\Components\MyComponent', + * 'shared' => true, + * ], + * 'group' => [ + * 'className' => '\Acme\Group', + * 'arguments' => [ + * [ + * 'type' => 'service', + * 'service' => 'myComponent', + * ], + * ], + * ], + * 'user' => [ + * 'className' => '\Acme\User', + * ], + * ]; + * ``` * - * @return \Phalcon\Di\Service[] + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath */ - public function getServices() {} + public function loadFromPhp(string $filePath) {} /** - * Check if a service is registered using the array syntax + * Loads services from a yaml file. * - * @param mixed $name - * @return bool + * ```php + * $di->loadFromYaml( + * "path/services.yaml", + * [ + * "!approot" => function ($value) { + * return dirname(__DIR__) . $value; + * } + * ] + * ); + * ``` + * + * And the services can be specified in the file as: + * + * ```php + * myComponent: + * className: \Acme\Components\MyComponent + * shared: true + * + * group: + * className: \Acme\Group + * arguments: + * - type: service + * name: myComponent + * + * user: + * className: \Acme\User + * ``` + * + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath + * @param array $callbacks */ - public function offsetExists($name) {} + public function loadFromYaml(string $filePath, array $callbacks = null) {} /** - * Allows to register a shared service using the array syntax - * - * - * $di["request"] = new \Phalcon\Http\Request(); - * + * Check whether the DI contains a service by a name * - * @param mixed $name - * @param mixed $definition + * @param string $name * @return bool */ - public function offsetSet($name, $definition) {} + public function has(string $name): bool {} /** * Allows to obtain a shared service using the array syntax * - * + * ```php * var_dump($di["request"]); - * + * ``` * * @param mixed $name * @return mixed @@ -227,57 +247,64 @@ public function offsetSet($name, $definition) {} public function offsetGet($name) {} /** - * Removes a service from the services container using the array syntax + * Check if a service is registered using the array syntax * * @param mixed $name * @return bool */ - public function offsetUnset($name) {} + public function offsetExists($name): bool {} /** - * Magic method to get or set services using setters/getters + * Allows to register a shared service using the array syntax * - * @param string $method - * @param mixed $arguments - * @return mixed|null + * ```php + * $di["request"] = new \Phalcon\Http\Request(); + * ``` + * + * @param mixed $name + * @param mixed $definition */ - public function __call($method, $arguments = null) {} + public function offsetSet($name, $definition) {} + + /** + * Removes a service from the services container using the array syntax + * + * @param mixed $name + */ + public function offsetUnset($name) {} /** * Registers a service provider. * - * - * use Phalcon\DiInterface; + * ```php + * use Phalcon\Di\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared('service', function () { - * // ... - * }); + * $di->setShared( + * 'service', + * function () { + * // ... + * } + * ); * } * } - * + * ``` * * @param \Phalcon\Di\ServiceProviderInterface $provider */ public function register(\Phalcon\Di\ServiceProviderInterface $provider) {} /** - * Set a default dependency injection container to be obtained into static methods - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public static function setDefault(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Return the latest DI created + * Removes a service in the services container + * It also removes any shared instance created for the service * - * @return null|\Phalcon\DiInterface + * @param string $name */ - public static function getDefault() {} + public function remove(string $name) {} /** * Resets the internal default DI @@ -285,82 +312,46 @@ public static function getDefault() {} public static function reset() {} /** - * Loads services from a yaml file. - * - * - * $di->loadFromYaml( - * "path/services.yaml", - * [ - * "!approot" => function ($value) { - * return dirname(__DIR__) . $value; - * } - * ] - * ); - * - * - * And the services can be specified in the file as: - * - * - * myComponent: - * className: \Acme\Components\MyComponent - * shared: true - * - * group: - * className: \Acme\Group - * arguments: - * - type: service - * name: myComponent - * - * user: - * className: \Acme\User - * + * Registers a service in the services container * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath - * @param array $callbacks + * @param string $name + * @param mixed $definition + * @param bool $shared + * @return \Phalcon\Di\ServiceInterface */ - public function loadFromYaml($filePath, array $callbacks = null) {} + public function set(string $name, $definition, bool $shared = false): ServiceInterface {} /** - * Loads services from a php config file. + * Set a default dependency injection container to be obtained into static + * methods * - * - * $di->loadFromPhp("path/services.php"); - * - * - * And the services can be specified in the file as: + * @param \Phalcon\Di\DiInterface $container + */ + public static function setDefault(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets the internal event manager * - * - * return [ - * 'myComponent' => [ - * 'className' => '\Acme\Components\MyComponent', - * 'shared' => true, - * ], - * 'group' => [ - * 'className' => '\Acme\Group', - * 'arguments' => [ - * [ - * 'type' => 'service', - * 'service' => 'myComponent', - * ], - * ], - * ], - * 'user' => [ - * 'className' => '\Acme\User', - * ], - * ]; - * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + + /** + * Sets a service using a raw Phalcon\Di\Service definition * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath + * @param string $name + * @param \Phalcon\Di\ServiceInterface $rawDefinition + * @return \Phalcon\Di\ServiceInterface */ - public function loadFromPhp($filePath) {} + public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface {} /** - * Loads services from a Config object. + * Registers an "always shared" service in the services container * - * @param \Phalcon\Config $config + * @param string $name + * @param mixed $definition + * @return \Phalcon\Di\ServiceInterface */ - protected function loadFromConfig(\Phalcon\Config $config) {} + public function setShared(string $name, $definition): ServiceInterface {} } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index 82b6b066..ea0b9e58 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -5,129 +5,137 @@ /** * Phalcon\Escaper * - * Escapes different kinds of text securing them. By using this component you may - * prevent XSS attacks. + * Escapes different kinds of text securing them. By using this component you + * may prevent XSS attacks. * - * This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support. + * This component only works with UTF-8. The PREG extension needs to be compiled + * with UTF-8 support. * - * + * ```php * $escaper = new \Phalcon\Escaper(); * * $escaped = $escaper->escapeCss("font-family: "); * * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E - * + * ``` */ -class Escaper implements \Phalcon\EscaperInterface +class Escaper implements \Phalcon\Escaper\EscaperInterface { + /** + * @var bool + */ + protected $doubleEncode = true; - protected $_encoding = 'utf-8'; - - - protected $_htmlEscapeMap = null; + /** + * @var string + */ + protected $encoding = 'utf-8'; - protected $_htmlQuoteType = 3; + protected $htmlEscapeMap = null; - protected $_doubleEncode = true; + protected $htmlQuoteType = 3; /** - * Sets the encoding to be used by the escaper - * - * - * $escaper->setEncoding("utf-8"); - * + * Detect the character encoding of a string to be handled by an encoder. + * Special-handling for chr(172) and chr(128) to chr(159) which fail to be + * detected by mb_detect_encoding() * - * @param string $encoding + * @param string $str + * @return string|null */ - public function setEncoding($encoding) {} + final public function detectEncoding(string $str): ?string {} /** - * Returns the internal encoding used by the escaper + * Escape CSS strings by replacing non-alphanumeric chars by their + * hexadecimal escaped representation * + * @param string $css * @return string */ - public function getEncoding() {} + public function escapeCss(string $css): string {} /** - * Sets the HTML quoting type for htmlspecialchars + * Escape javascript strings by replacing non-alphanumeric chars by their + * hexadecimal escaped representation * - * - * $escaper->setHtmlQuoteType(ENT_XHTML); - * - * - * @param int $quoteType + * @param string $js + * @return string */ - public function setHtmlQuoteType($quoteType) {} + public function escapeJs(string $js): string {} /** - * Sets the double_encode to be used by the escaper - * - * - * $escaper->setDoubleEncode(false); - * + * Escapes a HTML string. Internally uses htmlspecialchars * - * @param bool $doubleEncode + * @param string $text + * @return string */ - public function setDoubleEncode($doubleEncode) {} + public function escapeHtml(string $text): string {} /** - * Detect the character encoding of a string to be handled by an encoder - * Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding() + * Escapes a HTML attribute string * - * @param string $str - * @return string|null + * @param string $attribute + * @return string */ - public final function detectEncoding($str) {} + public function escapeHtmlAttr(string $attribute): string {} /** - * Utility to normalize a string's encoding to UTF-32. + * Escapes a URL. Internally uses rawurlencode * - * @param string $str + * @param string $url * @return string */ - public final function normalizeEncoding($str) {} + public function escapeUrl(string $url): string {} /** - * Escapes a HTML string. Internally uses htmlspecialchars + * Returns the internal encoding used by the escaper * - * @param string $text * @return string */ - public function escapeHtml($text) {} + public function getEncoding(): string {} /** - * Escapes a HTML attribute string + * Utility to normalize a string's encoding to UTF-32. * - * @param string $attribute + * @param string $str * @return string */ - public function escapeHtmlAttr($attribute) {} + final public function normalizeEncoding(string $str): string {} /** - * Escape CSS strings by replacing non-alphanumeric chars by their hexadecimal escaped representation + * Sets the double_encode to be used by the escaper * - * @param string $css - * @return string + * ```php + * $escaper->setDoubleEncode(false); + * ``` + * + * @param bool $doubleEncode */ - public function escapeCss($css) {} + public function setDoubleEncode(bool $doubleEncode) {} /** - * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation + * Sets the encoding to be used by the escaper * - * @param string $js - * @return string + * ```php + * $escaper->setEncoding("utf-8"); + * ``` + * + * @param string $encoding */ - public function escapeJs($js) {} + public function setEncoding(string $encoding) {} /** - * Escapes a URL. Internally uses rawurlencode + * Sets the HTML quoting type for htmlspecialchars * - * @param string $url - * @return string + * ```php + * $escaper->setHtmlQuoteType(ENT_XHTML); + * ``` + * + * @param int $quoteType */ - public function escapeUrl($url) {} + public function setHtmlQuoteType(int $quoteType) {} } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 95f9e054..1cbf0b74 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -7,7 +7,13 @@ * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception +class Exception extends Exception implements \Throwable { + /** + * @param string $service + * @return string + */ + public static function containerServiceNotFound(string $service): string {} + } diff --git a/src/Phalcon/Factory.php b/src/Phalcon/Factory.php deleted file mode 100644 index ace96d42..00000000 --- a/src/Phalcon/Factory.php +++ /dev/null @@ -1,15 +0,0 @@ - - * $filter = new \Phalcon\Filter(); - * - * $filter->sanitize("some(one)@exa\\mple.com", "email"); // returns "someone@example.com" - * $filter->sanitize("hello<<", "string"); // returns "hello" - * $filter->sanitize("!100a019", "int"); // returns "100019" - * $filter->sanitize("!100a019.01a", "float"); // returns "100019.01" - * - */ -class Filter implements \Phalcon\FilterInterface -{ - - const FILTER_EMAIL = 'email'; - - - const FILTER_ABSINT = 'absint'; - - - const FILTER_INT = 'int'; - - - const FILTER_INT_CAST = 'int!'; - - - const FILTER_STRING = 'string'; - - - const FILTER_FLOAT = 'float'; - - - const FILTER_FLOAT_CAST = 'float!'; - - - const FILTER_ALPHANUM = 'alphanum'; - - - const FILTER_TRIM = 'trim'; - - - const FILTER_STRIPTAGS = 'striptags'; - - - const FILTER_LOWER = 'lower'; - - - const FILTER_UPPER = 'upper'; - - - const FILTER_URL = 'url'; - - - const FILTER_SPECIAL_CHARS = 'special_chars'; - - - protected $_filters; - - - /** - * Adds a user-defined filter - * - * @param string $name - * @param mixed $handler - * @return \Phalcon\FilterInterface - */ - public function add($name, $handler) {} - - /** - * Sanitizes a value with a specified single or set of filters - * - * @param mixed $value - * @param mixed $filters - * @param bool $noRecursive - * @return mixed - */ - public function sanitize($value, $filters, $noRecursive = false) {} - - /** - * Internal sanitize wrapper to filter_var - * - * @param mixed $value - * @param string $filter - */ - protected function _sanitize($value, $filter) {} - - /** - * Return the user-defined filters in the instance - * - * @return array - */ - public function getFilters() {} - -} diff --git a/src/Phalcon/FilterInterface.php b/src/Phalcon/FilterInterface.php deleted file mode 100644 index 6ffc77e2..00000000 --- a/src/Phalcon/FilterInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * $flash->success("The record was successfully deleted"); - * $flash->error("Cannot open the file"); - * - */ -abstract class Flash implements \Phalcon\FlashInterface, \Phalcon\Di\InjectionAwareInterface -{ - - protected $_cssClasses; - - - protected $_implicitFlush = true; - - - protected $_automaticHtml = true; - - - protected $_escaperService = null; - - - protected $_autoescape = true; - - - protected $_dependencyInjector = null; - - - protected $_messages; - - - /** - * Phalcon\Flash constructor - * - * @param mixed $cssClasses - */ - public function __construct($cssClasses = null) {} - - /** - * Returns the autoescape mode in generated html - * - * @return bool - */ - public function getAutoescape() {} - - /** - * Set the autoescape mode in generated html - * - * @param bool $autoescape - * @return Flash - */ - public function setAutoescape($autoescape) {} - - /** - * Returns the Escaper Service - * - * @return EscaperInterface - */ - public function getEscaperService() {} - - /** - * Sets the Escaper Service - * - * @param EscaperInterface $escaperService - * @return Flash - */ - public function setEscaperService(EscaperInterface $escaperService) {} - - /** - * Sets the dependency injector - * - * @param DiInterface $dependencyInjector - * @return Flash - */ - public function setDI(DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector - * - * @return DiInterface - */ - public function getDI() {} - - /** - * Set whether the output must be implicitly flushed to the output or returned as string - * - * @param bool $implicitFlush - * @return FlashInterface - */ - public function setImplicitFlush($implicitFlush) {} - - /** - * Set if the output must be implicitly formatted with HTML - * - * @param bool $automaticHtml - * @return FlashInterface - */ - public function setAutomaticHtml($automaticHtml) {} - - /** - * Set an array with CSS classes to format the messages - * - * @param array $cssClasses - * @return FlashInterface - */ - public function setCssClasses(array $cssClasses) {} - - /** - * Shows a HTML error message - * - * - * $flash->error("This is an error"); - * - * - * @param mixed $message - * @return string - */ - public function error($message) {} - - /** - * Shows a HTML notice/information message - * - * - * $flash->notice("This is an information"); - * - * - * @param mixed $message - * @return string - */ - public function notice($message) {} - - /** - * Shows a HTML success message - * - * - * $flash->success("The process was finished successfully"); - * - * - * @param mixed $message - * @return string - */ - public function success($message) {} - - /** - * Shows a HTML warning message - * - * - * $flash->warning("Hey, this is important"); - * - * - * @param mixed $message - * @return string - */ - public function warning($message) {} - - /** - * Outputs a message formatting it with HTML - * - * - * $flash->outputMessage("error", $message); - * - * - * @param string $type - * @param string|array $message - * @return string|void - */ - public function outputMessage($type, $message) {} - - /** - * Clears accumulated messages when implicit flush is disabled - */ - public function clear() {} - -} diff --git a/src/Phalcon/FlashInterface.php b/src/Phalcon/FlashInterface.php deleted file mode 100644 index 9353fd25..00000000 --- a/src/Phalcon/FlashInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - + * ```php * use Phalcon\Loader; * * // Creates the autoloader @@ -27,144 +26,131 @@ * * // Requiring this class will automatically include file vendor/example/adapter/Some.php * $adapter = new \Example\Adapter\Some(); - * + * ``` */ class Loader implements \Phalcon\Events\EventsAwareInterface { - protected $_eventsManager = null; - - - protected $_foundPath = null; - - - protected $_checkedPath = null; - - - protected $_classes = array(); - - - protected $_extensions = array('php'); + protected $checkedPath = null; + /** + * @var array + */ + protected $classes = array(); - protected $_namespaces = array(); - + /** + * @var array + */ + protected $directories = array(); - protected $_directories = array(); + protected $eventsManager = null; - protected $_files = array(); + /** + * @var array + */ + protected $extensions = array('php'); - protected $_registered = false; + protected $fileCheckingCallback = 'is_file'; + /** + * @var array + */ + protected $files = array(); - protected $fileCheckingCallback = 'is_file'; + /** + * @var bool + */ + protected $foundPath = null; + /** + * @var array + */ + protected $namespaces = array(); /** - * Sets the file check callback. - * - * - * // Default behavior. - * $loader->setFileCheckingCallback("is_file"); - * - * // Faster than `is_file()`, but implies some issues if - * // the file is removed from the filesystem. - * $loader->setFileCheckingCallback("stream_resolve_include_path"); - * - * // Do not check file existence. - * $loader->setFileCheckingCallback(null); - * - * - * @param mixed $callback - * @return Loader + * @var bool */ - public function setFileCheckingCallback($callback = null) {} + protected $registered = false; + /** - * Sets the events manager + * Autoloads the registered classes * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $className + * @return bool */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function autoLoad(string $className): bool {} /** - * Returns the internal event manager + * Get the path the loader is checking for a path * - * @return \Phalcon\Events\ManagerInterface + * @return string */ - public function getEventsManager() {} + public function getCheckedPath(): string {} /** - * Sets an array of file extensions that the loader must try in each attempt to locate the file + * Returns the class-map currently registered in the autoloader * - * @param array $extensions - * @return Loader + * @return array */ - public function setExtensions(array $extensions) {} + public function getClasses(): array {} /** - * Returns the file extensions registered in the loader + * Returns the directories currently registered in the autoloader * * @return array */ - public function getExtensions() {} + public function getDirs(): array {} /** - * Register namespaces and their related directories + * Returns the internal event manager * - * @param array $namespaces - * @param bool $merge - * @return Loader + * @return \Phalcon\Events\ManagerInterface */ - public function registerNamespaces(array $namespaces, $merge = false) {} + public function getEventsManager(): ManagerInterface {} /** - * @param array $namespace + * Returns the file extensions registered in the loader + * * @return array */ - protected function prepareNamespace(array $namespace) {} + public function getExtensions(): array {} /** - * Returns the namespaces currently registered in the autoloader + * Returns the files currently registered in the autoloader * * @return array */ - public function getNamespaces() {} + public function getFiles(): array {} /** - * Register directories in which "not found" classes could be found + * Get the path when a class was found * - * @param array $directories - * @param bool $merge - * @return Loader + * @return string */ - public function registerDirs(array $directories, $merge = false) {} + public function getFoundPath(): string {} /** - * Returns the directories currently registered in the autoloader + * Returns the namespaces currently registered in the autoloader * * @return array */ - public function getDirs() {} + public function getNamespaces(): array {} /** - * Registers files that are "non-classes" hence need a "require". This is very useful for including files that only - * have functions - * - * @param array $files - * @param bool $merge - * @return Loader + * Checks if a file exists and then adds the file by doing virtual require */ - public function registerFiles(array $files, $merge = false) {} + public function loadFiles() {} /** - * Returns the files currently registered in the autoloader + * Register the autoload method * - * @return array + * @param bool $prepend + * @return Loader */ - public function getFiles() {} + public function register(bool $prepend = false): Loader {} /** * Register classes and their locations @@ -173,55 +159,83 @@ public function getFiles() {} * @param bool $merge * @return Loader */ - public function registerClasses(array $classes, $merge = false) {} + public function registerClasses(array $classes, bool $merge = false): Loader {} /** - * Returns the class-map currently registered in the autoloader + * Register directories in which "not found" classes could be found * - * @return array + * @param array $directories + * @param bool $merge + * @return Loader */ - public function getClasses() {} + public function registerDirs(array $directories, bool $merge = false): Loader {} /** - * Register the autoload method + * Registers files that are "non-classes" hence need a "require". This is + * very useful for including files that only have functions * - * @param bool $prepend + * @param array $files + * @param bool $merge * @return Loader */ - public function register($prepend = false) {} + public function registerFiles(array $files, bool $merge = false): Loader {} /** - * Unregister the autoload method + * Register namespaces and their related directories * + * @param array $namespaces + * @param bool $merge * @return Loader */ - public function unregister() {} + public function registerNamespaces(array $namespaces, bool $merge = false): Loader {} /** - * Checks if a file exists and then adds the file by doing virtual require + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function loadFiles() {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Autoloads the registered classes + * Sets an array of file extensions that the loader must try in each attempt + * to locate the file * - * @param string $className - * @return bool + * @param array $extensions + * @return Loader */ - public function autoLoad($className) {} + public function setExtensions(array $extensions): Loader {} /** - * Get the path when a class was found + * Sets the file check callback. * - * @return string + * ```php + * // Default behavior. + * $loader->setFileCheckingCallback("is_file"); + * + * // Faster than `is_file()`, but implies some issues if + * // the file is removed from the filesystem. + * $loader->setFileCheckingCallback("stream_resolve_include_path"); + * + * // Do not check file existence. + * $loader->setFileCheckingCallback(null); + * ``` + * + * @param mixed $callback + * @return Loader */ - public function getFoundPath() {} + public function setFileCheckingCallback($callback = null): Loader {} /** - * Get the path the loader is checking for a path + * Unregister the autoload method * - * @return string + * @return Loader + */ + public function unregister(): Loader {} + + /** + * @param array $namespaceName + * @return array */ - public function getCheckedPath() {} + protected function prepareNamespace(array $namespaceName): array {} } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php deleted file mode 100644 index 332e012a..00000000 --- a/src/Phalcon/Logger.php +++ /dev/null @@ -1,55 +0,0 @@ - - * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); - * $logger->log("This is a message"); - * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - */ -abstract class Logger -{ - - const SPECIAL = 9; - - - const CUSTOM = 8; - - - const DEBUG = 7; - - - const INFO = 6; - - - const NOTICE = 5; - - - const WARNING = 4; - - - const ERROR = 3; - - - const ALERT = 2; - - - const CRITICAL = 1; - - - const EMERGENCE = 0; - - - const EMERGENCY = 0; - - -} diff --git a/src/Phalcon/Plugin.php b/src/Phalcon/Plugin.php index 5689dbdb..ddc7559e 100644 --- a/src/Phalcon/Plugin.php +++ b/src/Phalcon/Plugin.php @@ -3,12 +3,10 @@ namespace Phalcon; /** - * Phalcon\Plugin - * * This class can be used to provide user plugins an easy access to services * in the application */ -class Plugin extends \Phalcon\Di\Injectable +abstract class Plugin extends \Phalcon\Di\Injectable { } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 5f4d660d..c86bd440 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -5,11 +5,11 @@ /** * Phalcon\Registry * - * A registry is a container for storing objects and values in the application space. - * By storing the value in a registry, the same object is always available throughout - * your application. + * A registry is a container for storing objects and values in the application + * space. By storing the value in a registry, the same object is always + * available throughout your application. * - * + * ```php * $registry = new \Phalcon\Registry(); * * // Set value @@ -31,13 +31,13 @@ * unset($registry->something); * // or * unset($registry["something"]); - * + * ``` * * In addition to ArrayAccess, Phalcon\Registry also implements Countable * (count($registry) will return the number of elements in the registry), - * Serializable and Iterator (you can iterate over the registry - * using a foreach loop) interfaces. For PHP 5.4 and higher, JsonSerializable - * interface is implemented. + * Serializable and Iterator (you can iterate over the registry using a foreach + * loop) interfaces. For PHP 5.4 and higher, JsonSerializable interface is + * implemented. * * Phalcon\Registry is very fast (it is typically faster than any userspace * implementation of the registry); however, this comes at a price: @@ -49,112 +49,186 @@ * is several times slower than $registry->property. * * Internally all the magic methods (and interfaces except JsonSerializable) - * are implemented using object handlers or similar techniques: this allows - * to bypass relatively slow method calls. + * are implemented using object handlers or similar techniques: this allows to + * bypass relatively slow method calls. */ -final class Registry implements \ArrayAccess, \Countable, \Iterator +final class Registry extends \Phalcon\Collection { - protected $_data; - - /** - * Registry constructor + * Constructor + * + * @param array $data */ - public final function __construct() {} + final public function __construct(array $data = null) {} /** - * Checks if the element is present in the registry + * Magic getter to get an element from the collection * - * @param mixed $offset - * @return bool + * @param string $element + * @return mixed */ - public final function offsetExists($offset) {} + final public function __get(string $element) {} /** - * Returns an index in the registry + * Magic isset to check whether an element exists or not * - * @param mixed $offset - * @return mixed + * @param string $element + * @return bool */ - public final function offsetGet($offset) {} + final public function __isset(string $element): bool {} /** - * Sets an element in the registry + * Magic setter to assign values to an element * - * @param mixed $offset + * @param string $element * @param mixed $value */ - public final function offsetSet($offset, $value) {} + final public function __set(string $element, $value) {} /** - * Unsets an element in the registry + * Magic unset to remove an element from the collection * - * @param mixed $offset + * @param string $element + */ + final public function __unset(string $element) {} + + /** + * Clears the internal collection */ - public final function offsetUnset($offset) {} + final public function clear() {} /** - * Checks how many elements are in the register + * Count elements of an object * + * @link https://php.net/manual/en/countable.count.php * @return int */ - public final function count() {} + final public function count(): int {} + + /** + * Get the element from the collection + * + * @param string $element + * @param mixed $defaultValue + * @return mixed + */ + final public function get(string $element, $defaultValue = null) {} /** - * Moves cursor to next row in the registry + * Returns the iterator of the class + * + * @return \Traversable */ - public final function next() {} + final public function getIterator(): Traversable {} /** - * Gets pointer number of active row in the registry + * Get the element from the collection * - * @return int + * @param string $element + * @return bool */ - public final function key() {} + final public function has(string $element): bool {} /** - * Rewinds the registry cursor to its beginning + * Initialize internal array + * + * @param array $data + */ + final public function init(array $data = array()) {} + + /** + * Specify data which should be serialized to JSON + * + * @link https://php.net/manual/en/jsonserializable.jsonserialize.php + * @return array */ - public final function rewind() {} + final public function jsonSerialize(): array {} /** - * Checks if the iterator is valid + * Whether a offset exists * + * @link https://php.net/manual/en/arrayaccess.offsetexists.php + * @param mixed $element * @return bool */ - public function valid() {} + final public function offsetExists($element): bool {} + + /** + * Offset to retrieve + * + * @link https://php.net/manual/en/arrayaccess.offsetget.php + * @param mixed $element + * @return mixed + */ + final public function offsetGet($element) {} + + /** + * Offset to set + * + * @link https://php.net/manual/en/arrayaccess.offsetset.php + * @param mixed $element + * @param mixed $value + */ + final public function offsetSet($element, $value) {} + + /** + * Offset to unset + * + * @link https://php.net/manual/en/arrayaccess.offsetunset.php + * @param mixed $element + */ + final public function offsetUnset($element) {} + + /** + * Delete the element from the collection + * + * @param string $element + */ + final public function remove(string $element) {} /** - * Obtains the current value in the internal iterator + * String representation of object + * + * @link https://php.net/manual/en/serializable.serialize.php + * @return string */ - public function current() {} + final public function serialize(): string {} /** - * Sets an element in the registry + * Set an element in the collection * - * @param string $key + * @param string $element * @param mixed $value */ - public final function __set($key, $value) {} + final public function set(string $element, $value) {} /** - * Returns an index in the registry + * Returns the object in an array format * - * @param string $key - * @return mixed + * @return array */ - public final function __get($key) {} + final public function toArray(): array {} /** - * @param string $key - * @return bool + * Returns the object in a JSON format + * + * The default string uses the following options for json_encode + * + * JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES + * + * @see https://www.ietf.org/rfc/rfc4627.txt + * @param int $options + * @return string */ - public final function __isset($key) {} + final public function toJson(int $options = 79): string {} /** - * @param string $key + * Constructs the object + * + * @link https://php.net/manual/en/serializable.unserialize.php + * @param mixed $serialized */ - public final function __unset($key) {} + final public function unserialize($serialized) {} } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 03661177..8a79b6be 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -3,11 +3,10 @@ namespace Phalcon; /** - * Phalcon\Security + * This component provides a set of functions to improve the security in Phalcon + * applications * - * This component provides a set of functions to improve the security in Phalcon applications - * - * + * ```php * $login = $this->request->getPost("login"); * $password = $this->request->getPost("password"); * @@ -18,7 +17,7 @@ * // The password is valid * } * } - * + * ``` */ class Security implements \Phalcon\Di\InjectionAwareInterface { @@ -26,15 +25,6 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_DEFAULT = 0; - const CRYPT_STD_DES = 1; - - - const CRYPT_EXT_DES = 2; - - - const CRYPT_MD5 = 3; - - const CRYPT_BLOWFISH = 4; @@ -47,37 +37,49 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_BLOWFISH_Y = 7; + const CRYPT_EXT_DES = 2; + + + const CRYPT_MD5 = 3; + + const CRYPT_SHA256 = 8; const CRYPT_SHA512 = 9; - protected $_dependencyInjector; + const CRYPT_STD_DES = 1; + + + protected $container; - protected $_workFactor = 8; + protected $defaultHash; - protected $_numberBytes = 16; + protected $numberBytes = 16; - protected $_tokenKeySessionID = '$PHALCON/CSRF/KEY$'; + protected $random; - protected $_tokenValueSessionID = '$PHALCON/CSRF$'; + protected $requestToken; - protected $_token; + protected $token; - protected $_tokenKey; + protected $tokenKey; - protected $_random; + protected $tokenKeySessionId = '$PHALCON/CSRF/KEY$'; - protected $_defaultHash; + protected $tokenValueSessionId = '$PHALCON/CSRF$'; + + + protected $workFactor = 8; /** @@ -94,124 +96,129 @@ public function getWorkFactor() {} public function __construct() {} /** - * Sets the dependency injector + * Checks a plain text password and its hash version to check if the + * password matches * - * @param \Phalcon\DiInterface $dependencyInjector + * @param string $password + * @param string $passwordHash + * @param int $maxPassLength + * @return bool */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool {} /** - * Returns the internal dependency injector + * Check if the CSRF token sent in the request is the same that the current + * in session * - * @return \Phalcon\DiInterface + * @param mixed $tokenKey + * @param mixed $tokenValue + * @param bool $destroyIfValid + * @return bool */ - public function getDI() {} + public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool {} /** - * Sets a number of bytes to be generated by the openssl pseudo random generator + * Computes a HMAC * - * @param long $randomBytes - * @return Security + * @param string $data + * @param string $key + * @param string $algo + * @param bool $raw + * @return string */ - public function setRandomBytes($randomBytes) {} + public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string {} /** - * Returns a number of bytes to be generated by the openssl pseudo random generator + * Removes the value of the CSRF token and key from session * - * @return string + * @return Security */ - public function getRandomBytes() {} + public function destroyToken(): Security {} /** - * Returns a secure random number generator instance + * Returns the default hash * - * @return \Phalcon\Security\Random + * @return int|null */ - public function getRandom() {} + public function getDefaultHash(): ?int {} /** - * Generate a >22-length pseudo random string to be used as salt for passwords + * Returns the internal dependency injector * - * @param int $numberBytes - * @return string + * @return \Phalcon\Di\DiInterface */ - public function getSaltBytes($numberBytes = 0) {} + public function getDI(): DiInterface {} /** - * Creates a password hash using bcrypt with a pseudo random salt + * Returns a secure random number generator instance * - * @param string $password - * @param int $workFactor - * @return string + * @return \Phalcon\Security\Random */ - public function hash($password, $workFactor = 0) {} + public function getRandom(): Random {} /** - * Checks a plain text password and its hash version to check if the password matches + * Returns a number of bytes to be generated by the openssl pseudo random + * generator * - * @param string $password - * @param string $passwordHash - * @param int $maxPassLength - * @return bool + * @return string */ - public function checkHash($password, $passwordHash, $maxPassLength = 0) {} + public function getRandomBytes(): string {} /** - * Checks if a password hash is a valid bcrypt's hash + * Returns the value of the CSRF token for the current request. * - * @param string $passwordHash - * @return bool + * @return string */ - public function isLegacyHash($passwordHash) {} + public function getRequestToken(): string {} /** - * Generates a pseudo random token key to be used as input's name in a CSRF check + * Returns the value of the CSRF token in session * * @return string */ - public function getTokenKey() {} + public function getSessionToken(): string {} /** - * Generates a pseudo random token value to be used as input's value in a CSRF check + * Generate a >22-length pseudo random string to be used as salt for + * passwords * + * @param int $numberBytes * @return string */ - public function getToken() {} + public function getSaltBytes(int $numberBytes = 0): string {} /** - * Check if the CSRF token sent in the request is the same that the current in session + * Generates a pseudo random token value to be used as input's value in a + * CSRF check * - * @param mixed $tokenKey - * @param mixed $tokenValue - * @param bool $destroyIfValid - * @return bool + * @return string */ - public function checkToken($tokenKey = null, $tokenValue = null, $destroyIfValid = true) {} + public function getToken(): string {} /** - * Returns the value of the CSRF token in session + * Generates a pseudo random token key to be used as input's name in a CSRF + * check * * @return string */ - public function getSessionToken() {} + public function getTokenKey(): string {} /** - * Removes the value of the CSRF token and key from session + * Creates a password hash using bcrypt with a pseudo random salt * - * @return Security + * @param string $password + * @param int $workFactor + * @return string */ - public function destroyToken() {} + public function hash(string $password, int $workFactor = 0): string {} /** - * Computes a HMAC + * Checks if a password hash is a valid bcrypt's hash * - * @param string $data - * @param string $key - * @param string $algo - * @param bool $raw - * @return string + * @param string $passwordHash + * @return bool */ - public function computeHmac($data, $key, $algo, $raw = false) {} + public function isLegacyHash(string $passwordHash): bool {} /** * Sets the default hash @@ -219,39 +226,22 @@ public function computeHmac($data, $key, $algo, $raw = false) {} * @param int $defaultHash * @return Security */ - public function setDefaultHash($defaultHash) {} + public function setDefaultHash(int $defaultHash): Security {} /** - * Returns the default hash - * - * @return int|null - */ - public function getDefaultHash() {} - - /** - * Testing for LibreSSL + * Sets the dependency injector * - * @deprecated Will be removed in 4.0.0 - * @return bool + * @param \Phalcon\Di\DiInterface $container */ - public function hasLibreSsl() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Getting OpenSSL or LibreSSL version. - * - * Parse OPENSSL_VERSION_TEXT because OPENSSL_VERSION_NUMBER is no use for LibreSSL. - * This constant show not the current system openssl library version but version PHP was compiled with. + * Sets a number of bytes to be generated by the openssl pseudo random + * generator * - * @deprecated Will be removed in 4.0.0 - * @link https://bugs.php.net/bug.php?id=71143 - * - * - * if ($security->getSslVersionNumber() >= 20105) { - * // ... - * } - * - * @return int + * @param long $randomBytes + * @return Security */ - public function getSslVersionNumber() {} + public function setRandomBytes(int $randomBytes): Security {} } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index cc253c01..75c84096 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Tag - * * Phalcon\Tag is designed to simplify building of HTML tags. * It provides a set of helpers to generate HTML in a dynamic way. - * This component is an abstract class that you can extend to add more helpers. + * This component is a class that you can extend to add more helpers. */ class Tag { @@ -44,539 +42,570 @@ class Tag const XHTML5 = 11; + + static protected $autoEscape = true; + /** - * Pre-assigned values for components + * Framework Dispatcher */ - static protected $_displayValues; + static protected $container; /** - * HTML document title + * Pre-assigned values for components */ - static protected $_documentTitle = null; + static protected $displayValues; - static protected $_documentAppendTitle = null; + static protected $dispatcherService = null; - static protected $_documentPrependTitle = null; + static protected $documentAppendTitle = null; - static protected $_documentTitleSeparator = null; - - - static protected $_documentType = 11; + static protected $documentPrependTitle = null; /** - * Framework Dispatcher + * HTML document title */ - static protected $_dependencyInjector; + static protected $documentTitle = null; - static protected $_urlService = null; + static protected $documentTitleSeparator = null; - static protected $_dispatcherService = null; + static protected $documentType = 11; - static protected $_escaperService = null; + static protected $escaperService = null; - static protected $_autoEscape = true; + static protected $urlService = null; /** - * Obtains the 'escaper' service if required + * Appends a text to current document title * - * @param array $params - * @return EscaperInterface + * @param mixed $title */ - public static function getEscaper(array $params) {} + public static function appendTitle($title) {} /** - * Renders parameters keeping order in their HTML attributes + * Builds a HTML input[type="check"] tag * - * @param string $code - * @param array $attributes + * ```php + * echo Phalcon\Tag::checkField( + * [ + * "terms", + * "value" => "Y", + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {{ check_field("terms") }} + * ``` + * + * @param array $parameters * @return string */ - public static function renderAttributes($code, array $attributes) {} + public static function checkField($parameters): string {} /** - * Sets the dependency injector container. + * Builds a HTML input[type="color"] tag * - * @param DiInterface $dependencyInjector + * @param array $parameters + * @return string */ - public static function setDI(DiInterface $dependencyInjector) {} + public static function colorField($parameters): string {} /** - * Internally gets the request dispatcher + * Builds a HTML input[type="date"] tag * - * @return DiInterface + * ```php + * echo Phalcon\Tag::dateField( + * [ + * "born", + * "value" => "14-12-1980", + * ] + * ); + * ``` + * + * @param array $parameters + * @return string */ - public static function getDI() {} + public static function dateField($parameters): string {} /** - * Returns a URL service from the default DI + * Builds a HTML input[type="datetime"] tag * - * @return \Phalcon\Mvc\UrlInterface + * @param array $parameters + * @return string */ - public static function getUrlService() {} + public static function dateTimeField($parameters): string {} /** - * Returns an Escaper service from the default DI + * Builds a HTML input[type="datetime-local"] tag * - * @return EscaperInterface + * @param array $parameters + * @return string */ - public static function getEscaperService() {} + public static function dateTimeLocalField($parameters): string {} /** - * Set autoescape mode in generated html + * Alias of Phalcon\Tag::setDefault() * - * @param bool $autoescape + * @param string $id + * @param string $value */ - public static function setAutoescape($autoescape) {} + public static function displayTo(string $id, $value) {} /** - * Assigns default values to generated tags by helpers + * Builds a HTML input[type="email"] tag * - * - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefault("name", "peter"); + * ```php + * echo Phalcon\Tag::emailField("email"); + * ``` * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * + * @param array $parameters + * @return string + */ + public static function emailField($parameters): string {} + + /** + * Builds a HTML close FORM tag * - * @param string $id - * @param string $value + * @return string */ - public static function setDefault($id, $value) {} + public static function endForm(): string {} /** - * Assigns default values to generated tags by helpers + * Builds a HTML input[type="file"] tag * - * - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefaults( + * ```php + * echo Phalcon\Tag::fileField("file"); + * ``` + * + * @param array $parameters + * @return string + */ + public static function fileField($parameters): string {} + + /** + * Builds a HTML FORM tag + * + * ```php + * echo Phalcon\Tag::form("posts/save"); + * + * echo Phalcon\Tag::form( * [ - * "name" => "peter", + * "posts/save", + * "method" => "post", * ] * ); + * ``` * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * + * Volt syntax: + * ```php + * {{ form("posts/save") }} + * {{ form("posts/save", "method": "post") }} + * ``` * - * @param array $values - * @param bool $merge + * @param array $parameters + * @return string */ - public static function setDefaults(array $values, $merge = false) {} + public static function form($parameters): string {} /** - * Alias of Phalcon\Tag::setDefault + * Converts texts into URL-friendly titles * - * @param string $id - * @param string $value + * ```php + * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") + * ``` + * + * @param string $text + * @param string $separator + * @param bool $lowercase + * @param mixed $replace + * @return string */ - public static function displayTo($id, $value) {} + public static function friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string {} /** - * Check if a helper has a default value set using Phalcon\Tag::setDefault or value from $_POST + * Get the document type declaration of content * - * @param string $name - * @return bool + * @return string */ - public static function hasValue($name) {} + public static function getDocType(): string {} /** - * Every helper calls this function to check whether a component has a predefined - * value using Phalcon\Tag::setDefault or value from $_POST + * Obtains the 'escaper' service if required * - * @param string $name * @param array $params - * @return mixed + * @return null|\Phalcon\Escaper\EscaperInterface */ - public static function getValue($name, $params = null) {} + public static function getEscaper(array $params): ?EscaperInterface {} /** - * Resets the request and internal values to avoid those fields will have any default value. + * Internally gets the request dispatcher * - * @deprecated Will be removed in 4.0.0 - * @deprecated + * @return \Phalcon\Di\DiInterface */ - public static function resetInput() {} + public static function getDI(): DiInterface {} /** - * Builds a HTML A tag using framework conventions - * - * - * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); + * Returns an Escaper service from the default DI * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!" - * ] - * ); + * @return \Phalcon\Escaper\EscaperInterface + */ + public static function getEscaperService(): EscaperInterface {} + + /** + * Gets the current document title. + * The title will be automatically escaped. * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!", - * "class" => "btn-primary", - * ] - * ); + * ```php + * Tag::prependTitle('Hello'); + * Tag::setTitle('World'); + * Tag::appendTitle('from Phalcon'); * - * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); + * echo Tag::getTitle(); // Hello World from Phalcon + * echo Tag::getTitle(false); // World from Phalcon + * echo Tag::getTitle(true, false); // Hello World + * echo Tag::getTitle(false, false); // World + * ``` * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * false, - * ] - * ); + * ```php + * {{ get_title() }} + * ``` * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * "local" => false, - * ] - * ); + * @param bool $prepend + * @param bool $append + * @return string + */ + public static function getTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Gets the current document title separator * - * echo Phalcon\Tag::linkTo( - * [ - * "action" => "http://phalconphp.com/", - * "text" => "Phalcon Home", - * "local" => false, - * "target" => "_new" - * ] - * ); + * ```php + * echo Phalcon\Tag::getTitleSeparator(); + * ``` * - * + * ```php + * {{ get_title_separator() }} + * ``` * - * @param array|string $parameters - * @param string $text - * @param boolean $local * @return string */ - public static function linkTo($parameters, $text = null, $local = true) {} + public static function getTitleSeparator(): string {} /** - * Builds generic INPUT tags + * Returns a URL service from the default DI * - * @param string $type - * @param array $parameters - * @param boolean $asValue - * @return string + * @return \Phalcon\Url\UrlInterface */ - static protected final function _inputField($type, $parameters, $asValue = false) {} + public static function getUrlService(): UrlInterface {} /** - * Builds INPUT tags that implements the checked attribute + * Every helper calls this function to check whether a component has a + * predefined value using Phalcon\Tag::setDefault() or value from $_POST * - * @param string $type - * @param array $parameters - * @return string + * @param string $name + * @param array $params + * @return mixed */ - static protected final function _inputFieldChecked($type, $parameters) {} + public static function getValue($name, array $params = array()) {} /** - * Builds a HTML input[type="color"] tag + * Check if a helper has a default value set using Phalcon\Tag::setDefault() + * or value from $_POST * - * @param array $parameters - * @return string + * @param string $name + * @return bool */ - public static function colorField($parameters) {} + public static function hasValue($name): bool {} /** - * Builds a HTML input[type="text"] tag + * Builds a HTML input[type="hidden"] tag * - * - * echo Phalcon\Tag::textField( + * ```php + * echo Phalcon\Tag::hiddenField( * [ * "name", - * "size" => 30, + * "value" => "mike", * ] * ); - * + * ``` * * @param array $parameters * @return string */ - public static function textField($parameters) {} + public static function hiddenField($parameters): string {} /** - * Builds a HTML input[type="number"] tag + * Builds HTML IMG tags * - * - * echo Phalcon\Tag::numericField( + * ```php + * echo Phalcon\Tag::image("img/bg.png"); + * + * echo Phalcon\Tag::image( * [ - * "price", - * "min" => "1", - * "max" => "5", + * "img/photo.jpg", + * "alt" => "Some Photo", * ] * ); - * - * - * @param array $parameters - * @return string - */ - public static function numericField($parameters) {} - - /** - * Builds a HTML input[type="range"] tag - * - * @param array $parameters - * @return string - */ - public static function rangeField($parameters) {} - - /** - * Builds a HTML input[type="email"] tag + * ``` * - * - * echo Phalcon\Tag::emailField("email"); - * + * Volt Syntax: + * ```php + * {{ image("img/bg.png") }} + * {{ image("img/photo.jpg", "alt": "Some Photo") }} + * {{ image("http://static.mywebsite.com/img/bg.png", false) }} + * ``` * * @param array $parameters + * @param bool $local * @return string */ - public static function emailField($parameters) {} + public static function image($parameters = null, bool $local = true): string {} /** - * Builds a HTML input[type="date"] tag + * Builds a HTML input[type="image"] tag * - * - * echo Phalcon\Tag::dateField( + * ```php + * echo Phalcon\Tag::imageInput( * [ - * "born", - * "value" => "14-12-1980", + * "src" => "/img/button.png", * ] * ); - * + * ``` * - * @param array $parameters - * @return string - */ - public static function dateField($parameters) {} - - /** - * Builds a HTML input[type="datetime"] tag + * Volt syntax: + * ```php + * {{ image_input("src": "/img/button.png") }} + * ``` * * @param array $parameters * @return string */ - public static function dateTimeField($parameters) {} + public static function imageInput($parameters): string {} /** - * Builds a HTML input[type="datetime-local"] tag + * Builds a SCRIPT[type="javascript"] tag * - * @param array $parameters - * @return string - */ - public static function dateTimeLocalField($parameters) {} - - /** - * Builds a HTML input[type="month"] tag + * ```php + * echo Phalcon\Tag::javascriptInclude( + * "http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", + * false + * ); * - * @param array $parameters - * @return string - */ - public static function monthField($parameters) {} - - /** - * Builds a HTML input[type="time"] tag + * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); + * ``` * - * @param array $parameters - * @return string - */ - public static function timeField($parameters) {} - - /** - * Builds a HTML input[type="week"] tag + * Volt syntax: + * ```php + * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} + * {{ javascript_include("javascript/jquery.js") }} + * ``` * * @param array $parameters + * @param bool $local * @return string */ - public static function weekField($parameters) {} + public static function javascriptInclude($parameters = null, bool $local = true): string {} /** - * Builds a HTML input[type="password"] tag + * Builds a HTML A tag using framework conventions * - * - * echo Phalcon\Tag::passwordField( + * ```php + * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); + * + * echo Phalcon\Tag::linkTo( * [ - * "name", - * "size" => 30, + * "signup/register", + * "Register Here!" * ] * ); - * * - * @param array $parameters - * @return string - */ - public static function passwordField($parameters) {} - - /** - * Builds a HTML input[type="hidden"] tag + * echo Phalcon\Tag::linkTo( + * [ + * "signup/register", + * "Register Here!", + * "class" => "btn-primary", + * ] + * ); * - * - * echo Phalcon\Tag::hiddenField( + * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); + * + * echo Phalcon\Tag::linkTo( * [ - * "name", - * "value" => "mike", + * "http://phalconphp.com/", + * "Phalcon Home", + * false, * ] * ); - * * - * @param array $parameters - * @return string - */ - public static function hiddenField($parameters) {} - - /** - * Builds a HTML input[type="file"] tag + * echo Phalcon\Tag::linkTo( + * [ + * "http://phalconphp.com/", + * "Phalcon Home", + * "local" => false, + * ] + * ); + * + * echo Phalcon\Tag::linkTo( + * [ + * "action" => "http://phalconphp.com/", + * "text" => "Phalcon Home", + * "local" => false, + * "target" => "_new" + * ] + * ); * - * - * echo Phalcon\Tag::fileField("file"); - * + * ``` * - * @param array $parameters + * @param array|string $parameters + * @param string $text + * @param bool $local * @return string */ - public static function fileField($parameters) {} + public static function linkTo($parameters, $text = null, $local = true): string {} /** - * Builds a HTML input[type="search"] tag + * Builds a HTML input[type="month"] tag * * @param array $parameters * @return string */ - public static function searchField($parameters) {} + public static function monthField($parameters): string {} /** - * Builds a HTML input[type="tel"] tag + * Builds a HTML input[type="number"] tag * - * @param array $parameters - * @return string - */ - public static function telField($parameters) {} - - /** - * Builds a HTML input[type="url"] tag + * ```php + * echo Phalcon\Tag::numericField( + * [ + * "price", + * "min" => "1", + * "max" => "5", + * ] + * ); + * ``` * * @param array $parameters * @return string */ - public static function urlField($parameters) {} + public static function numericField($parameters): string {} /** - * Builds a HTML input[type="check"] tag + * Builds a HTML input[type="password"] tag * - * - * echo Phalcon\Tag::checkField( + * ```php + * echo Phalcon\Tag::passwordField( * [ - * "terms", - * "value" => "Y", + * "name", + * "size" => 30, * ] * ); - * - * - * Volt syntax: - * - * {{ check_field("terms") }} - * + * ``` * * @param array $parameters * @return string */ - public static function checkField($parameters) {} + public static function passwordField($parameters): string {} + + /** + * Prepends a text to current document title + * + * @param mixed $title + */ + public static function prependTitle($title) {} /** * Builds a HTML input[type="radio"] tag * - * + * ```php * echo Phalcon\Tag::radioField( * [ * "weather", * "value" => "hot", * ] * ); - * + * ``` * * Volt syntax: - * + * ```php * {{ radio_field("Save") }} - * + * ``` * * @param array $parameters * @return string */ - public static function radioField($parameters) {} + public static function radioField($parameters): string {} /** - * Builds a HTML input[type="image"] tag - * - * - * echo Phalcon\Tag::imageInput( - * [ - * "src" => "/img/button.png", - * ] - * ); - * - * - * Volt syntax: - * - * {{ image_input("src": "/img/button.png") }} - * + * Builds a HTML input[type="range"] tag * * @param array $parameters * @return string */ - public static function imageInput($parameters) {} + public static function rangeField($parameters): string {} /** - * Builds a HTML input[type="submit"] tag + * Renders parameters keeping order in their HTML attributes * - * - * echo Phalcon\Tag::submitButton("Save") - * + * @param string $code + * @param array $attributes + * @return string + */ + public static function renderAttributes(string $code, array $attributes): string {} + + /** + * Renders the title with title tags. The title is automaticall escaped * - * Volt syntax: - * - * {{ submit_button("Save") }} - * + * ```php + * Tag::prependTitle('Hello'); + * Tag::setTitle('World'); + * Tag::appendTitle('from Phalcon'); * - * @param array $parameters + * echo Tag::renderTitle(); // Hello World from Phalcon + * echo Tag::renderTitle(false); // World from Phalcon + * echo Tag::renderTitle(true, false); // Hello World + * echo Tag::renderTitle(false, false); // World + * ``` + * + * ```php + * {{ render_title() }} + * ``` + * + * @param bool $prepend + * @param bool $append * @return string */ - public static function submitButton($parameters) {} + public static function renderTitle(bool $prepend = true, bool $append = true): string {} /** - * Builds a HTML SELECT tag using a PHP array for options + * Resets the request and internal values to avoid those fields will have + * any default value. * - * - * echo Phalcon\Tag::selectStatic( - * "status", - * [ - * "A" => "Active", - * "I" => "Inactive", - * ] - * ); - * + * @deprecated Will be removed in 4.0.0 + * @deprecated + */ + public static function resetInput() {} + + /** + * Builds a HTML input[type="search"] tag * * @param array $parameters - * @param array $data * @return string */ - public static function selectStatic($parameters, $data = null) {} + public static function searchField($parameters): string {} /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * - * + * ```php * echo Phalcon\Tag::select( * [ * "robotId", @@ -584,261 +613,272 @@ public static function selectStatic($parameters, $data = null) {} * "using" => ["id", "name"], * ] * ); - * + * ``` * * Volt syntax: - * + * ```php * {{ select("robotId", robots, "using": ["id", "name"]) }} - * + * ``` * * @param array $parameters * @param array $data * @return string */ - public static function select($parameters, $data = null) {} + public static function select($parameters, $data = null): string {} /** - * Builds a HTML TEXTAREA tag + * Builds a HTML SELECT tag using a PHP array for options * - * - * echo Phalcon\Tag::textArea( + * ```php + * echo Phalcon\Tag::selectStatic( + * "status", * [ - * "comments", - * "cols" => 10, - * "rows" => 4, + * "A" => "Active", + * "I" => "Inactive", * ] * ); - * - * - * Volt syntax: - * - * {{ text_area("comments", "cols": 10, "rows": 4) }} - * + * ``` * * @param array $parameters + * @param array $data * @return string */ - public static function textArea($parameters) {} + public static function selectStatic($parameters, $data = null): string {} /** - * Builds a HTML FORM tag + * Set autoescape mode in generated html * - * - * echo Phalcon\Tag::form("posts/save"); + * @param bool $autoescape + */ + public static function setAutoescape(bool $autoescape) {} + + /** + * Assigns default values to generated tags by helpers * - * echo Phalcon\Tag::form( + * ```php + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefault("name", "peter"); + * + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * ``` + * + * @param string $id + * @param string $value + */ + public static function setDefault(string $id, $value) {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefaults( * [ - * "posts/save", - * "method" => "post", + * "name" => "peter", * ] * ); - * * - * Volt syntax: - * - * {{ form("posts/save") }} - * {{ form("posts/save", "method": "post") }} - * + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * ``` * - * @param array $parameters - * @return string + * @param array $values + * @param bool $merge */ - public static function form($parameters) {} + public static function setDefaults(array $values, bool $merge = false) {} /** - * Builds a HTML close FORM tag + * Sets the dependency injector container. * - * @return string + * @param \Phalcon\Di\DiInterface $container */ - public static function endForm() {} + public static function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the document type of content + * + * @param int $doctype + */ + public static function setDocType(int $doctype) {} /** * Set the title of view content * - * + * ```php * Phalcon\Tag::setTitle("Welcome to my Page"); - * + * ``` * * @param string $title */ - public static function setTitle($title) {} + public static function setTitle(string $title) {} /** * Set the title separator of view content * - * + * ```php * Phalcon\Tag::setTitleSeparator("-"); - * + * ``` * * @param string $titleSeparator */ - public static function setTitleSeparator($titleSeparator) {} + public static function setTitleSeparator(string $titleSeparator) {} /** - * Appends a text to current document title + * Builds a LINK[rel="stylesheet"] tag * - * @param mixed $title - */ - public static function appendTitle($title) {} - - /** - * Prepends a text to current document title + * ```php + * echo Phalcon\Tag::stylesheetLink( + * "http://fonts.googleapis.com/css?family=Rosario", + * false + * ); * - * @param mixed $title + * echo Phalcon\Tag::stylesheetLink("css/style.css"); + * ``` + * + * Volt Syntax: + * ```php + * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} + * {{ stylesheet_link("css/style.css") }} + * ``` + * + * @param array $parameters + * @param bool $local + * @return string */ - public static function prependTitle($title) {} + public static function stylesheetLink($parameters = null, bool $local = true): string {} /** - * Gets the current document title. - * The title will be automatically escaped. + * Builds a HTML input[type="submit"] tag * - * - * echo Phalcon\Tag::getTitle(); - * + * ```php + * echo Phalcon\Tag::submitButton("Save") + * ``` * - * - * {{ get_title() }} - * + * Volt syntax: + * ```php + * {{ submit_button("Save") }} + * ``` * - * @param bool $tags + * @param array $parameters * @return string */ - public static function getTitle($tags = true) {} + public static function submitButton($parameters): string {} /** - * Gets the current document title separator - * - * - * echo Phalcon\Tag::getTitleSeparator(); - * - * - * - * {{ get_title_separator() }} - * + * Builds a HTML tag * + * @param string $tagName + * @param mixed $parameters + * @param bool $selfClose + * @param bool $onlyStart + * @param bool $useEol * @return string */ - public static function getTitleSeparator() {} + public static function tagHtml(string $tagName, $parameters = null, bool $selfClose = false, bool $onlyStart = false, bool $useEol = false): string {} /** - * Builds a LINK[rel="stylesheet"] tag + * Builds a HTML tag closing tag * - * - * echo Phalcon\Tag::stylesheetLink("http://fonts.googleapis.com/css?family=Rosario", false); - * echo Phalcon\Tag::stylesheetLink("css/style.css"); - * + * ```php + * echo Phalcon\Tag::tagHtmlClose("script", true); + * ``` * - * Volt Syntax: - * - * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} - * {{ stylesheet_link("css/style.css") }} - * + * @param string $tagName + * @param bool $useEol + * @return string + */ + public static function tagHtmlClose(string $tagName, bool $useEol = false): string {} + + /** + * Builds a HTML input[type="tel"] tag * * @param array $parameters - * @param boolean $local * @return string */ - public static function stylesheetLink($parameters = null, $local = true) {} + public static function telField($parameters): string {} /** - * Builds a SCRIPT[type="javascript"] tag + * Builds a HTML TEXTAREA tag * - * - * echo Phalcon\Tag::javascriptInclude("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false); - * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); - * + * ```php + * echo Phalcon\Tag::textArea( + * [ + * "comments", + * "cols" => 10, + * "rows" => 4, + * ] + * ); + * ``` * * Volt syntax: - * - * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} - * {{ javascript_include("javascript/jquery.js") }} - * + * ```php + * {{ text_area("comments", "cols": 10, "rows": 4) }} + * ``` * * @param array $parameters - * @param boolean $local * @return string */ - public static function javascriptInclude($parameters = null, $local = true) {} + public static function textArea($parameters): string {} /** - * Builds HTML IMG tags - * - * - * echo Phalcon\Tag::image("img/bg.png"); + * Builds a HTML input[type="text"] tag * - * echo Phalcon\Tag::image( + * ```php + * echo Phalcon\Tag::textField( * [ - * "img/photo.jpg", - * "alt" => "Some Photo", + * "name", + * "size" => 30, * ] * ); - * - * - * Volt Syntax: - * - * {{ image("img/bg.png") }} - * {{ image("img/photo.jpg", "alt": "Some Photo") }} - * {{ image("http://static.mywebsite.com/img/bg.png", false) }} - * + * ``` * * @param array $parameters - * @param boolean $local * @return string */ - public static function image($parameters = null, $local = true) {} + public static function textField($parameters): string {} /** - * Converts texts into URL-friendly titles - * - * - * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") - * + * Builds a HTML input[type="time"] tag * - * @param string $text - * @param string $separator - * @param bool $lowercase - * @param mixed $replace + * @param array $parameters * @return string */ - public static function friendlyTitle($text, $separator = '-', $lowercase = true, $replace = null) {} + public static function timeField($parameters): string {} /** - * Set the document type of content + * Builds a HTML input[type="url"] tag * - * @param int $doctype + * @param array $parameters + * @return string */ - public static function setDocType($doctype) {} + public static function urlField($parameters): string {} /** - * Get the document type declaration of content + * Builds a HTML input[type="week"] tag * + * @param array $parameters * @return string */ - public static function getDocType() {} + public static function weekField($parameters): string {} /** - * Builds a HTML tag + * Builds generic INPUT tags * - * @param string $tagName - * @param mixed $parameters - * @param bool $selfClose - * @param bool $onlyStart - * @param bool $useEol + * @param string $type + * @param array $parameters + * @param bool $asValue * @return string */ - public static function tagHtml($tagName, $parameters = null, $selfClose = false, $onlyStart = false, $useEol = false) {} + static final protected function inputField(string $type, $parameters, bool $asValue = false): string {} /** - * Builds a HTML tag closing tag - * - * - * echo Phalcon\Tag::tagHtmlClose("script", true); - * + * Builds INPUT tags that implements the checked attribute * - * @param string $tagName - * @param bool $useEol + * @param string $type + * @param array $parameters * @return string */ - public static function tagHtmlClose($tagName, $useEol = false) {} + static final protected function inputFieldChecked(string $type, $parameters): string {} } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 70eb7d2c..14589c93 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Text - * * Provides utilities to work with texts */ -abstract class Text +class Text { const RANDOM_ALNUM = 0; @@ -16,221 +14,233 @@ abstract class Text const RANDOM_ALPHA = 1; - const RANDOM_HEXDEC = 2; + const RANDOM_DISTINCT = 5; - const RANDOM_NUMERIC = 3; + const RANDOM_HEXDEC = 2; const RANDOM_NOZERO = 4; - const RANDOM_DISTINCT = 5; + const RANDOM_NUMERIC = 3; /** * Converts strings to camelize style * - * + * ```php * echo Phalcon\Text::camelize("coco_bongo"); // CocoBongo * echo Phalcon\Text::camelize("co_co-bon_go", "-"); // Co_coBon_go * echo Phalcon\Text::camelize("co_co-bon_go", "_-"); // CoCoBonGo - * + * ``` * - * @param string $str + * @param string $text * @param mixed $delimiter * @return string */ - public static function camelize($str, $delimiter = null) {} + public static function camelize(string $text, $delimiter = null): string {} /** - * Uncamelize strings which are camelized + * Concatenates strings using the separator only once without duplication in + * places concatenation * - * - * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo - * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo - * - * - * @param string $str - * @param mixed $delimiter - * @return string - */ - public static function uncamelize($str, $delimiter = null) {} - - /** - * Adds a number to a string or increment that number if it already is defined + * ```php + * $str = Phalcon\Text::concat( + * "/", + * "/tmp/", + * "/folder_1/", + * "/folder_2", + * "folder_3/" + * ); * - * - * echo Phalcon\Text::increment("a"); // "a_1" - * echo Phalcon\Text::increment("a_1"); // "a_2" - * + * // /tmp/folder_1/folder_2/folder_3/ + * echo $str; + * ``` * - * @param string $str * @param string $separator + * @param string $a + * @param string $b + * @param string $...N * @return string */ - public static function increment($str, $separator = '_') {} + public static function concat(): string {} /** - * Generates a random string based on the given type. Type is one of the RANDOM_ constants + * Generates random text in accordance with the template * - * - * use Phalcon\Text; + * ```php + * // Hi my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * // "aloiwkqz" - * echo Text::random(Text::RANDOM_ALNUM); - * + * // Hi my name is a Jon + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * @param int $type - * @param long $length - * @return string - */ - public static function random($type = 0, $length = 8) {} - - /** - * Check if a string starts with a given string + * // Hello my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * - * echo Phalcon\Text::startsWith("Hello", "He"); // true - * echo Phalcon\Text::startsWith("Hello", "he", false); // false - * echo Phalcon\Text::startsWith("Hello", "he"); // true - * + * // Hello my name is a Zyxep + * echo Phalcon\Text::dynamic( + * "[Hi/Hello], my name is a [Zyxep/Mark]!", + * "[", "]", + * "/" + * ); + * ``` * - * @param string $str - * @param string $start - * @param bool $ignoreCase - * @return bool + * @param string $text + * @param string $leftDelimiter + * @param string $rightDelimiter + * @param string $separator + * @return string */ - public static function startsWith($str, $start, $ignoreCase = true) {} + public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string {} /** * Check if a string ends with a given string * - * + * ```php * echo Phalcon\Text::endsWith("Hello", "llo"); // true * echo Phalcon\Text::endsWith("Hello", "LLO", false); // false * echo Phalcon\Text::endsWith("Hello", "LLO"); // true - * + * ``` * - * @param string $str + * @param string $text * @param string $end * @param bool $ignoreCase * @return bool */ - public static function endsWith($str, $end, $ignoreCase = true) {} + public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool {} /** - * Lowercases a string, this function makes use of the mbstring extension if available + * Makes an underscored or dashed phrase human-readable * - * - * echo Phalcon\Text::lower("HELLO"); // hello - * + * ```php + * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" + * echo Phalcon\Text::humanize("five_cats"); // "five cats" + * ``` * - * @param string $str - * @param string $encoding + * @param string $text * @return string */ - public static function lower($str, $encoding = 'UTF-8') {} + public static function humanize(string $text): string {} /** - * Uppercases a string, this function makes use of the mbstring extension if available + * Adds a number to a string or increment that number if it already is + * defined * - * - * echo Phalcon\Text::upper("hello"); // HELLO - * + * ```php + * echo Phalcon\Text::increment("a"); // "a_1" + * echo Phalcon\Text::increment("a_1"); // "a_2" + * ``` * - * @param string $str - * @param string $encoding + * @param string $text + * @param string $separator * @return string */ - public static function upper($str, $encoding = 'UTF-8') {} + public static function increment(string $text, string $separator = '_'): string {} /** - * Reduces multiple slashes in a string to single slashes + * Lowercases a string, this function makes use of the mbstring extension if + * available * - * - * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); // foo/bar/baz - * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); // http://foo.bar/baz/buz - * + * ```php + * echo Phalcon\Text::lower("HELLO"); // hello + * ``` * - * @param string $str + * @param string $text + * @param string $encoding * @return string */ - public static function reduceSlashes($str) {} + public static function lower(string $text, string $encoding = 'UTF-8'): string {} /** - * Concatenates strings using the separator only once without duplication in places concatenation + * Check if a string starts with a given string * - * - * $str = Phalcon\Text::concat( - * "/", - * "/tmp/", - * "/folder_1/", - * "/folder_2", - * "folder_3/" - * ); + * ```php + * echo Phalcon\Text::startsWith("Hello", "He"); // true + * echo Phalcon\Text::startsWith("Hello", "he", false); // false + * echo Phalcon\Text::startsWith("Hello", "he"); // true + * ``` * - * // /tmp/folder_1/folder_2/folder_3/ - * echo $str; - * + * @param string $text + * @param string $start + * @param bool $ignoreCase + * @return bool + */ + public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool {} + + /** + * Generates a random string based on the given type. Type is one of the + * RANDOM_ constants * - * @param string $separator - * @param string $a - * @param string $b - * @param string $...N + * ```php + * use Phalcon\Text; + * + * // "aloiwkqz" + * echo Text::random(Text::RANDOM_ALNUM); + * ``` + * + * @param int $type + * @param long $length * @return string */ - public static function concat() {} + public static function random(int $type = 0, int $length = 8): string {} /** - * Generates random text in accordance with the template + * Reduces multiple slashes in a string to single slashes * - * - * // Hi my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * ```php + * // foo/bar/baz + * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); * - * // Hi my name is a Jon - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * // http://foo.bar/baz/buz + * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); + * ``` * - * // Hello my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * @param string $text + * @return string + */ + public static function reduceSlashes(string $text): string {} + + /** + * Uncamelize strings which are camelized * - * // Hello my name is a Zyxep - * echo Phalcon\Text::dynamic("[Hi/Hello], my name is a [Zyxep/Mark]!", "[", "]", "/"); - * + * ```php + * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo + * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo + * ``` * * @param string $text - * @param string $leftDelimiter - * @param string $rightDelimiter - * @param string $separator + * @param mixed $delimiter * @return string */ - public static function dynamic($text, $leftDelimiter = '{', $rightDelimiter = '}', $separator = '|') {} + public static function uncamelize(string $text, $delimiter = null): string {} /** * Makes a phrase underscored instead of spaced * - * + * ```php * echo Phalcon\Text::underscore("look behind"); // "look_behind" * echo Phalcon\Text::underscore("Awesome Phalcon"); // "Awesome_Phalcon" - * + * ``` * * @param string $text * @return string */ - public static function underscore($text) {} + public static function underscore(string $text): string {} /** - * Makes an underscored or dashed phrase human-readable + * Uppercases a string, this function makes use of the mbstring extension if + * available * - * - * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" - * echo Phalcon\Text::humanize("five_cats"); // "five cats" - * + * ```php + * echo Phalcon\Text::upper("hello"); // HELLO + * ``` * * @param string $text + * @param string $encoding * @return string */ - public static function humanize($text) {} + public static function upper(string $text, string $encoding = 'UTF-8'): string {} } diff --git a/src/Phalcon/Translate.php b/src/Phalcon/Translate.php deleted file mode 100644 index ad8cc91c..00000000 --- a/src/Phalcon/Translate.php +++ /dev/null @@ -1,14 +0,0 @@ - + * ```php * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * @@ -26,163 +17,174 @@ * "year" => "2012", * ] * ); - * + * ``` */ -class Url implements UrlInterface, InjectionAwareInterface +class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterface { + /** + * @var null | string + */ + protected $baseUri = null; + + /** + * @var null | string + */ + protected $basePath = null; + + /** + * @var + */ + protected $container; + + + protected $router; + + /** + * @var null | string + */ + protected $staticBaseUri = null; + + + /** + * Generates a URL + * + * ```php + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2015", + * ] + * ); + * + * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) + * echo $url->get( + * "show/products", + * [ + * "id" => 1, + * "name" => "Carrots", + * ] + * ); + * + * // Generate an absolute URL by setting the third parameter as false. + * echo $url->get( + * "https://phalconphp.com/", + * null, + * false + * ); + * ``` + * + * @param mixed $uri + * @param mixed $args + * @param bool $local + * @param mixed $baseUri + * @return string + */ + public function get($uri = null, $args = null, bool $local = null, $baseUri = null): string {} + + /** + * Returns the base path + * + * @return string + */ + public function getBasePath(): string {} + + /** + * Returns the prefix for all the generated urls. By default / + * + * @return string + */ + public function getBaseUri(): string {} + + /** + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Generates a URL for a static resource + * + * ```php + * // Generate a URL for a static resource + * echo $url->getStatic("img/logo.png"); + * + * // Generate a URL for a static predefined route + * echo $url->getStatic( + * [ + * "for" => "logo-cdn", + * ] + * ); + * ``` + * + * @param mixed $uri + * @return string + */ + public function getStatic($uri = null): string {} + + /** + * Returns the prefix for all the generated static urls. By default / + * + * @return string + */ + public function getStaticBaseUri(): string {} + + /** + * Sets a base path for all the generated paths + * + * ```php + * $url->setBasePath("/var/www/htdocs/"); + * ``` + * + * @param string $basePath + * @return \Phalcon\Url\UrlInterface + */ + public function setBasePath(string $basePath): UrlInterface {} + + /** + * Sets a prefix for all the URIs to be generated + * + * ```php + * $url->setBaseUri("/invo/"); + * + * $url->setBaseUri("/invo/index.php/"); + * ``` + * + * @param string $baseUri + * @return \Phalcon\Url\UrlInterface + */ + public function setBaseUri(string $baseUri): UrlInterface {} + + /** + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets a prefix for all static URLs generated + * + * ```php + * $url->setStaticBaseUri("/invo/"); + * ``` + * + * @param string $staticBaseUri + * @return \Phalcon\Url\UrlInterface + */ + public function setStaticBaseUri(string $staticBaseUri): UrlInterface {} + + /** + * Generates a local path + * + * @param string $path + * @return string + */ + public function path(string $path = null): string {} - /** - * @var null | string - */ - protected $baseUri = null; - - /** - * @var null | string - */ - protected $basePath = null; - - /** - * @var - */ - protected $container; - - protected $router; - - /** - * @var null | string - */ - protected $staticBaseUri = null; - - /** - * Generates a URL - * - * - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2015", - * ] - * ); - * - * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) - * echo $url->get( - * "show/products", - * [ - * "id" => 1, - * "name" => "Carrots", - * ] - * ); - * - * // Generate an absolute URL by setting the third parameter as false. - * echo $url->get( - * "https://phalconphp.com/", - * null, - * false - * ); - * - */ - public function get($uri = null, $args = null, bool $local = null, $baseUri = null) : string - { - } - - /** - * Returns the base path - */ - public function getBasePath() : string - { - } - - /** - * Returns the prefix for all the generated urls. By default / - */ - public function getBaseUri() : string - { - } - - /** - * Returns the DependencyInjector container - */ - public function getDI() : DiInterface - { - } - - /** - * Generates a URL for a static resource - * - * - * // Generate a URL for a static resource - * echo $url->getStatic("img/logo.png"); - * - * // Generate a URL for a static predefined route - * echo $url->getStatic( - * [ - * "for" => "logo-cdn", - * ] - * ); - * - */ - public function getStatic($uri = null) : string - { - } - - /** - * Returns the prefix for all the generated static urls. By default / - */ - public function getStaticBaseUri() : string - { - } - - /** - * Sets a base path for all the generated paths - * - * - * $url->setBasePath("/var/www/htdocs/"); - * - */ - public function setBasePath(string $basePath) : UrlInterface - { - } - - /** - * Sets a prefix for all the URIs to be generated - * - * - * $url->setBaseUri("/invo/"); - * - * $url->setBaseUri("/invo/index.php/"); - * - */ - public function setBaseUri(string $baseUri) : UrlInterface - { - } - - /** - * Sets the DependencyInjector container - */ - public function setDI(DiInterface $dependencyInjector) - { - } - - /** - * Sets a prefix for all static URLs generated - * - * - * $url->setStaticBaseUri("/invo/"); - * - */ - public function setStaticBaseUri(string $staticBaseUri) : UrlInterface - { - } - - /** - * Generates a local path - */ - public function path(string $path = null) : string - { - } } diff --git a/src/Phalcon/Urlinterface.php b/src/Phalcon/Urlinterface.php deleted file mode 100644 index d107d252..00000000 --- a/src/Phalcon/Urlinterface.php +++ /dev/null @@ -1,44 +0,0 @@ - + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * + * ``` */ const VERSION_MAJOR = 0; /** * The constant referencing the major version. Returns 1 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MEDIUM * ); - * + * ``` */ const VERSION_MEDIUM = 1; /** * The constant referencing the major version. Returns 2 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MINOR * ); - * + * ``` */ const VERSION_MINOR = 2; /** * The constant referencing the major version. Returns 3 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL * ); - * + * ``` */ const VERSION_SPECIAL = 3; /** * The constant referencing the major version. Returns 4 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL_NUMBER * ); - * + * ``` */ const VERSION_SPECIAL_NUMBER = 4; @@ -72,58 +70,56 @@ class Version * A - Major version * B - Med version (two digits) * C - Min version (two digits) - * D - Special release: 1 = Alpha, 2 = Beta, 3 = RC, 4 = Stable + * D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable * E - Special release version i.e. RC1, Beta2 etc. * * @return array */ - protected static function _getVersion() {} + protected static function _getVersion(): array {} /** - * Translates a number to a special release - * - * If Special release = 1 this function will return ALPHA + * Translates a number to a special release. * * @param int $special * @return string */ - protected final static function _getSpecial($special) {} + protected final static function _getSpecial(int $special): string {} /** * Returns the active version (string) * - * + * ```php * echo Phalcon\Version::get(); - * + * ``` * * @return string */ - public static function get() {} + public static function get(): string {} /** * Returns the numeric active version * - * + * ```php * echo Phalcon\Version::getId(); - * + * ``` * * @return string */ - public static function getId() {} + public static function getId(): string {} /** * Returns a specific part of the version. If the wrong parameter is passed * it will return the full version * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * + * ``` * * @param int $part * @return string */ - public static function getPart($part) {} + public static function getPart(int $part): string {} } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 0730e294..4928abdd 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -2,46 +2,53 @@ namespace Phalcon\Acl; -use Phalcon\Acl\Exception; - /** - * Phalcon\Acl\Component - * * This class defines component entity and its description */ -class Component implements ComponentInterface +class Component implements \Phalcon\Acl\ComponentInterface { - /** - * Component description - * @var string - */ - private $description; - - /** - * Component name - * @var string - */ - private $name; + /** + * Component description + * + * @var string + */ + private $description; /** - * Phalcon\Acl\Component constructor - * @param string $name - * @param string|null $description + * Component name + * + * @var string */ - public function __construct(string $name, string $description = null) {} + private $name; + /** - * Returns component description + * Component description + * + * @return string */ public function getDescription(): string {} /** - * Returns the component name + * Component name + * + * @return string */ public function getName(): string {} /** - * Magic method __toString + * Component name + * + * @return string */ public function __toString(): string {} + + /** + * Phalcon\Acl\Component constructor + * + * @param string $name + * @param string $description + */ + public function __construct(string $name, string $description = null) {} + } diff --git a/src/Phalcon/acl/Componentaware.php b/src/Phalcon/acl/ComponentAware.php similarity index 66% rename from src/Phalcon/acl/Componentaware.php rename to src/Phalcon/acl/ComponentAware.php index 1f191edd..3539eb59 100644 --- a/src/Phalcon/acl/Componentaware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -3,14 +3,16 @@ namespace Phalcon\Acl; /** - * Phalcon\Acl\ComponentAware - * * Interface for classes which could be used in allow method as RESOURCE */ interface ComponentAware { + /** * Returns component name - */ - public function getComponentName() : string; + * + * @return string + */ + public function getComponentName(): string; + } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php new file mode 100644 index 00000000..b1e0960c --- /dev/null +++ b/src/Phalcon/acl/ComponentInterface.php @@ -0,0 +1,32 @@ +setDefaultAction( - * \Phalcon\Acl::DENY + * \Phalcon\Acl\Enum::DENY * ); * * // Register roles @@ -56,9 +51,9 @@ * } * * // Grant access to public areas to both users and guests - * foreach ($roles as $role){ + * foreach ($roles as $role) { * foreach ($publicComponents as $component => $actions) { - * $acl->allow($role->getName(), $component, "*"); + * $acl->allow($role->getName(), $component, ""); * } * } * @@ -68,9 +63,9 @@ * $acl->allow("Users", $component, $action); * } * } - *``` + * ``` */ -class Memory extends Adapter +class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter { /** * Access @@ -86,11 +81,11 @@ class Memory extends Adapter */ protected $accessList; - /** - * Returns latest function used to acquire access - * - * @var mixed - */ + /** + * Returns latest function used to acquire access + * + * @var mixed + */ protected $activeFunction; /** @@ -98,7 +93,7 @@ class Memory extends Adapter * * @var int */ - protected $activeFunctionCustomArgumentsCount; + protected $activeFunctionCustomArgumentsCount = 0; /** * Returns latest key used to acquire access @@ -133,7 +128,7 @@ class Memory extends Adapter * * @var mixed */ - protected $noArgumentsDefaultAction = Acl::DENY; + protected $noArgumentsDefaultAction = Enum::DENY; /** * Roles @@ -157,6 +152,27 @@ class Memory extends Adapter protected $rolesNames; + /** + * Returns latest function used to acquire access + * + * @return mixed + */ + public function getActiveFunction() {} + + /** + * Returns number of additional arguments(excluding role and resource) for active function + * + * @return int + */ + public function getActiveFunctionCustomArgumentsCount(): int {} + + /** + * Returns latest key used to acquire access + * + * @return string|null + */ + public function getActiveKey(): ?string {} + /** * Phalcon\Acl\Adapter\Memory constructor */ @@ -195,20 +211,21 @@ public function __construct() {} * ] * ); * ``` - * @param $componentValue - * @param $accessList + * + * @param mixed $componentValue + * @param mixed $accessList * @return bool */ - public function addComponent($componentValue, $accessList) : bool {} + public function addComponent($componentValue, $accessList): bool {} /** * Adds access to components * - * @param $componentName - * @param $accessList + * @param string $componentName + * @param mixed $accessList * @return bool */ - public function addComponentAccess(string $componentName, $accessList) : bool {} + public function addComponentAccess(string $componentName, $accessList): bool {} /** * Do a role inherit from another existing role @@ -219,10 +236,10 @@ public function addComponentAccess(string $componentName, $accessList) : bool {} * ``` * * @param string $roleName - * @param $roleToInherits + * @param mixed $roleToInherits * @return bool */ - public function addInherit(string $roleName, $roleToInherits) : bool {} + public function addInherit(string $roleName, $roleToInherits): bool {} /** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role @@ -237,14 +254,14 @@ public function addInherit(string $roleName, $roleToInherits) : bool {} * $acl->addRole("administrator", ["consultant", "consultant2"]); * ``` * - * @param $role - * @param null $accessInherits + * @param mixed $role + * @param mixed $accessInherits * @return bool */ - public function addRole($role, $accessInherits = null) : bool {} + public function addRole($role, $accessInherits = null): bool {} /** - * Allow access to a role on a component. You can use `*` as wildcard + * Allow access to a role on a component. You can use `` as wildcard * * ```php * // Allow access to guests to search on customers @@ -254,20 +271,20 @@ public function addRole($role, $accessInherits = null) : bool {} * $acl->allow("guests", "customers", ["search", "create"]); * * // Allow access to any role to browse on products - * $acl->allow("*", "products", "browse"); + * $acl->allow("", "products", "browse"); * * // Allow access to any role to browse on any component - * $acl->allow("*", "*", "browse"); + * $acl->allow("", "", "browse"); * * @param string $roleName * @param string $componentName - * @param $access - * @param null $func + * @param mixed $access + * @param mixed $func */ - public function allow(string $roleName, string $componentName, $access, $func = null) : void {} + public function allow(string $roleName, string $componentName, $access, $func = null) {} /** - * Deny access to a role on a component. You can use `*` as wildcard + * Deny access to a role on a component. You can use `` as wildcard * * ```php * // Deny access to guests to search on customers @@ -277,45 +294,48 @@ public function allow(string $roleName, string $componentName, $access, $func = * $acl->deny("guests", "customers", ["search", "create"]); * * // Deny access to any role to browse on products - * $acl->deny("*", "products", "browse"); + * $acl->deny("", "products", "browse"); * * // Deny access to any role to browse on any component - * $acl->deny("*", "*", "browse"); + * $acl->deny("", "", "browse"); * ``` * * @param string $roleName * @param string $componentName - * @param $access - * @param null $func + * @param mixed $access + * @param mixed $func */ - public function deny(string $roleName, string $componentName, $access, $func = null) : void {} + public function deny(string $roleName, string $componentName, $access, $func = null) {} /** * Removes an access from a component + * * @param string $componentName - * @param $accessList + * @param mixed $accessList */ - public function dropComponentAccess(string $componentName, $accessList) : void {} + public function dropComponentAccess(string $componentName, $accessList) {} /** * Returns the default ACL access level for no arguments provided in * `isAllowed` action if a `func` (callable) exists for `accessKey` + * + * @return int */ - public function getNoArgumentsDefaultAction() : int {} + public function getNoArgumentsDefaultAction(): int {} /** * Return an array with every role registered in the list * - * @return RoleInterface[] + * @return array|\Phalcon\Acl\RoleInterface[] */ - public function getRoles() : array {} + public function getRoles(): array {} /** * Return an array with every component registered in the list * - * @return ComponentInterface[] + * @return array|\Phalcon\Acl\ComponentInterface[] */ - public function getComponents() : array {} + public function getComponents(): array {} /** * Check whether a role is allowed to access an action from a component @@ -325,15 +345,16 @@ public function getComponents() : array {} * $acl->isAllowed("andres", "Products", "create"); * * // Do guests have access to any component to edit? - * $acl->isAllowed("guests", "*", "edit"); + * $acl->isAllowed("guests", "", "edit"); * ``` - * @param $roleName - * @param $componentName - * @param $access - * @param array|null $parameters + * + * @param mixed $roleName + * @param mixed $componentName + * @param string $access + * @param array $parameters * @return bool */ - public function isAllowed($roleName, $componentName, $access, ?array $parameters = null) : bool {} + public function isAllowed($roleName, $componentName, string $access, array $parameters = null): bool {} /** * Check whether role exist in the roles list @@ -341,7 +362,7 @@ public function isAllowed($roleName, $componentName, $access, ?array $parameters * @param string $roleName * @return bool */ - public function isRole(string $roleName) : bool {} + public function isRole(string $roleName): bool {} /** * Check whether component exist in the components list @@ -349,14 +370,36 @@ public function isRole(string $roleName) : bool {} * @param string $componentName * @return bool */ - public function isComponent(string $componentName) : bool {} + public function isComponent(string $componentName): bool {} /** - * Sets the default access level (`Phalcon\Acl::ALLOW` or `Phalcon\Acl::DENY`) + * Sets the default access level (`Phalcon\Enum::ALLOW` or `Phalcon\Enum::DENY`) * for no arguments provided in isAllowed action if there exists func for * accessKey * * @param int $defaultAccess */ - public function setNoArgumentsDefaultAction(int $defaultAccess) : void {} + public function setNoArgumentsDefaultAction(int $defaultAccess) {} + + /** + * Checks if a role has access to a component + * + * @param string $roleName + * @param string $componentName + * @param mixed $access + * @param mixed $action + * @param mixed $func + */ + private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) {} + + /** + * Check whether a role is allowed to access an action from a component + * + * @param string $roleName + * @param string $componentName + * @param string $access + * @return string|bool + */ + private function canAccess(string $roleName, string $componentName, string $access) {} + } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index 0819c6fd..09c42994 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -3,32 +3,30 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Annotation - * * Represents a single annotation in an annotations collection */ class Annotation { /** - * Annotation Name + * Annotation Arguments * - * @var string + * @var array */ - protected $_name; + protected $arguments; /** - * Annotation Arguments + * Annotation ExprArguments * * @var string */ - protected $_arguments; + protected $exprArguments; /** - * Annotation ExprArguments + * Annotation Name * * @var string */ - protected $_exprArguments; + protected $name; /** @@ -39,71 +37,69 @@ class Annotation public function __construct(array $reflectionData) {} /** - * Returns the annotation's name + * Returns an argument in a specific position * - * @return string + * @param mixed $position */ - public function getName() {} + public function getArgument($position) {} /** - * Resolves an annotation expression + * Returns the expression arguments * - * @param array $expr - * @return mixed + * @return array */ - public function getExpression(array $expr) {} + public function getArguments(): array {} /** * Returns the expression arguments without resolving * * @return array */ - public function getExprArguments() {} + public function getExprArguments(): array {} /** - * Returns the expression arguments + * Resolves an annotation expression * - * @return array + * @param array $expr + * @return mixed */ - public function getArguments() {} + public function getExpression(array $expr) {} /** - * Returns the number of arguments that the annotation has + * Returns the annotation's name * - * @return int + * @return string */ - public function numberArguments() {} + public function getName(): string {} /** - * Returns an argument in a specific position + * Returns a named argument * - * @param int|string $position - * @return mixed + * @param string $name */ - public function getArgument($position) {} + public function getNamedArgument(string $name) {} /** - * Returns an argument in a specific position + * Returns a named parameter * - * @param int|string $position - * @return bool + * @param string $name + * @return mixed */ - public function hasArgument($position) {} + public function getNamedParameter(string $name) {} /** - * Returns a named argument + * Returns an argument in a specific position * - * @param string $name - * @return mixed + * @param mixed $position + * @return bool */ - public function getNamedArgument($name) {} + public function hasArgument($position): bool {} /** - * Returns a named parameter + * Returns the number of arguments that the annotation has * - * @param string $name - * @return mixed + * @return int */ - public function getNamedParameter($name) {} + public function numberArguments(): int {} } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php new file mode 100644 index 00000000..474b8c63 --- /dev/null +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -0,0 +1,42 @@ + - * //Traverse annotations + * ```php + * // Traverse annotations * foreach ($classAnnotations as $annotation) { * echo "Name=", $annotation->getName(), PHP_EOL; * } * - * //Check if the annotations has a specific + * // Check if the annotations has a specific * var_dump($classAnnotations->has("Cacheable")); * - * //Get an specific annotation in the collection + * // Get an specific annotation in the collection * $annotation = $classAnnotations->get("Cacheable"); - * + * ``` */ class Collection implements \Iterator, \Countable { + /** + * @var array + */ + protected $annotations; - protected $_position = 0; - - - protected $_annotations; + /** + * @var int + */ + protected $position = 0; /** @@ -34,19 +37,14 @@ class Collection implements \Iterator, \Countable * * @param array $reflectionData */ - public function __construct($reflectionData = null) {} + public function __construct(array $reflectionData = array()) {} /** * Returns the number of annotations in the collection * * @return int */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} + public function count(): int {} /** * Returns the current annotation in the iterator @@ -56,53 +54,58 @@ public function rewind() {} public function current() {} /** - * Returns the current position/key in the iterator + * Returns the first annotation that match a name * - * @return int - */ - public function key() {} - - /** - * Moves the internal iteration pointer to the next position + * @param string $name + * @return \Phalcon\Annotations\Annotation */ - public function next() {} + public function get(string $name): Annotation {} /** - * Check if the current annotation in the iterator is valid + * Returns all the annotations that match a name * - * @return bool + * @param string $name + * @return array|\Phalcon\Annotations\Annotation[] */ - public function valid() {} + public function getAll(string $name): array {} /** * Returns the internal annotations as an array * - * @return \Phalcon\Annotations\Annotation[] + * @return array|\Phalcon\Annotations\Annotation[] */ - public function getAnnotations() {} + public function getAnnotations(): array {} /** - * Returns the first annotation that match a name + * Check if an annotation exists in a collection * * @param string $name - * @return \Phalcon\Annotations\Annotation + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Returns all the annotations that match a name + * Returns the current position/key in the iterator * - * @param string $name - * @return \Phalcon\Annotations\Annotation[] + * @return int */ - public function getAll($name) {} + public function key(): int {} /** - * Check if an annotation exists in a collection + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Check if the current annotation in the iterator is valid * - * @param string $name * @return bool */ - public function has($name) {} + public function valid(): bool {} } diff --git a/src/Phalcon/annotations/Exception.php b/src/Phalcon/annotations/Exception.php index 22e5decf..8864d544 100644 --- a/src/Phalcon/annotations/Exception.php +++ b/src/Phalcon/annotations/Exception.php @@ -3,11 +3,9 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Exception - * * Class for exceptions thrown by Phalcon\Annotations */ -class Exception extends \Exception +class Exception extends \Phalcon\Exception { } diff --git a/src/Phalcon/annotations/Factory.php b/src/Phalcon/annotations/Factory.php deleted file mode 100644 index 63dd2a8a..00000000 --- a/src/Phalcon/annotations/Factory.php +++ /dev/null @@ -1,28 +0,0 @@ - - * use Phalcon\Annotations\Factory; - * - * $options = [ - * "prefix" => "annotations", - * "lifetime" => "3600", - * "adapter" => "apc", - * ]; - * $annotations = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index 3208daf9..fdc95680 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -3,20 +3,18 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reader - * * Parses docblocks returning an array with the found annotations */ class Reader implements \Phalcon\Annotations\ReaderInterface { /** - * Reads annotations from the class dockblocks, its methods and/or properties + * Reads annotations from the class docblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse($className) {} + public function parse(string $className): array {} /** * Parses a raw doc block returning the annotations found @@ -26,6 +24,6 @@ public function parse($className) {} * @param mixed $line * @return array */ - public static function parseDocBlock($docBlock, $file = null, $line = null) {} + public static function parseDocBlock(string $docBlock, $file = null, $line = null): array {} } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index 1e6ce946..5ba4b965 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -3,29 +3,27 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reader - * * Parses docblocks returning an array with the found annotations */ interface ReaderInterface { /** - * Reads annotations from the class dockblocks, its methods and/or properties + * Reads annotations from the class docblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse($className); + public function parse(string $className): array; /** - * Parses a raw doc block returning the annotations found + * Parses a raw docblock returning the annotations found * * @param string $docBlock * @param mixed $file * @param mixed $line * @return array */ - public static function parseDocBlock($docBlock, $file = null, $line = null); + public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index 6bca75ff..97072543 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -3,11 +3,9 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reflection - * * Allows to manipulate the annotations reflection in an OO manner * - * + * ```php * use Phalcon\Annotations\Reader; * use Phalcon\Annotations\Reflection; * @@ -20,21 +18,23 @@ * * // Get the annotations in the class docblock * $classAnnotations = $reflection->getClassAnnotations(); - * + * ``` */ class Reflection { - protected $_reflectionData; - + protected $classAnnotations; - protected $_classAnnotations; + protected $methodAnnotations; - protected $_methodAnnotations; + protected $propertyAnnotations; - protected $_propertyAnnotations; + /** + * @var array + */ + protected $reflectionData; /** @@ -42,7 +42,7 @@ class Reflection * * @param array $reflectionData */ - public function __construct($reflectionData = null) {} + public function __construct(array $reflectionData = array()) {} /** * Returns the annotations found in the class docblock @@ -54,30 +54,23 @@ public function getClassAnnotations() {} /** * Returns the annotations found in the methods' docblocks * - * @return bool|\Phalcon\Annotations\Collection[] + * @return array|bool|\Phalcon\Annotations\Collection[] */ public function getMethodsAnnotations() {} /** * Returns the annotations found in the properties' docblocks * - * @return bool|\Phalcon\Annotations\Collection[] + * @return array|bool|\Phalcon\Annotations\Collection[] */ public function getPropertiesAnnotations() {} /** - * Returns the raw parsing intermediate definitions used to construct the reflection + * Returns the raw parsing intermediate definitions used to construct the + * reflection * * @return array */ - public function getReflectionData() {} - - /** - * Restores the state of a Phalcon\Annotations\Reflection variable export - * - * @param mixed $data - * @return Reflection - */ - public static function __set_state($data) {} + public function getReflectionData(): array {} } diff --git a/src/Phalcon/annotations/Adapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php similarity index 63% rename from src/Phalcon/annotations/Adapter.php rename to src/Phalcon/annotations/adapter/AbstractAdapter.php index 2b9a8b55..e20924a3 100644 --- a/src/Phalcon/annotations/Adapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -1,42 +1,39 @@ - * use Phalcon\Annotations\Adapter\Apc; - * - * $annotations = new Apc(); - * - * - * @see \Phalcon\Annotations\Adapter\Apcu - * @deprecated - */ -class Apc extends \Phalcon\Annotations\Adapter -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - /** - * Phalcon\Annotations\Adapter\Apc constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads parsed annotations from APC - * - * @param string $key - * @return bool|\Phalcon\Annotations\Reflection - */ - public function read($key) {} - - /** - * Writes parsed annotations to APC - * - * @param string $key - * @param \Phalcon\Annotations\Reflection $data - */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} - -} diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index 0eabb8a8..3eedce01 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -3,23 +3,25 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Apcu - * * Stores the parsed annotations in APCu. This adapter is suitable for production * - * + * ```php * use Phalcon\Annotations\Adapter\Apcu; * * $annotations = new Apcu(); - * + * ``` */ -class Apcu extends \Phalcon\Annotations\Adapter +class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter { + /** + * @var string + */ + protected $prefix = ''; - protected $_prefix = ''; - - - protected $_ttl = 172800; + /** + * @var int + */ + protected $ttl = 172800; /** @@ -27,7 +29,7 @@ class Apcu extends \Phalcon\Annotations\Adapter * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** * Reads parsed annotations from APCu @@ -35,14 +37,15 @@ public function __construct($options = null) {} * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to APCu * * @param string $key * @param \Phalcon\Annotations\Reflection $data + * @return bool */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data): bool {} } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index 421aa079..dff5586e 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -3,18 +3,15 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Memory - * - * Stores the parsed annotations in memory. This adapter is the suitable development/testing + * Stores the parsed annotations in memory. This adapter is the suitable + * development/testing */ -class Memory extends \Phalcon\Annotations\Adapter +class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter { /** - * Data - * * @var mixed */ - protected $_data; + protected $data; /** @@ -23,7 +20,7 @@ class Memory extends \Phalcon\Annotations\Adapter * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to memory @@ -31,6 +28,6 @@ public function read($key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Files.php b/src/Phalcon/annotations/adapter/Stream.php similarity index 55% rename from src/Phalcon/annotations/adapter/Files.php rename to src/Phalcon/annotations/adapter/Stream.php index fc5be66d..1ceda655 100644 --- a/src/Phalcon/annotations/adapter/Files.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -3,32 +3,32 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Files - * * Stores the parsed annotations in files. This adapter is suitable for production * - * - * use Phalcon\Annotations\Adapter\Files; + * ```php + * use Phalcon\Annotations\Adapter\Stream; * - * $annotations = new Files( + * $annotations = new Stream( * [ * "annotationsDir" => "app/cache/annotations/", * ] * ); - * + * ``` */ -class Files extends \Phalcon\Annotations\Adapter +class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter { - - protected $_annotationsDir = './'; + /** + * @var string + */ + protected $annotationsDir = './'; /** - * Phalcon\Annotations\Adapter\Files constructor + * Phalcon\Annotations\Adapter\Stream constructor * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** * Reads parsed annotations from files @@ -36,7 +36,7 @@ public function __construct($options = null) {} * @param string $key * @return bool|int|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to files @@ -44,6 +44,6 @@ public function read($key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Xcache.php b/src/Phalcon/annotations/adapter/Xcache.php deleted file mode 100644 index 504b2674..00000000 --- a/src/Phalcon/annotations/adapter/Xcache.php +++ /dev/null @@ -1,33 +0,0 @@ - - * $annotations = new \Phalcon\Annotations\Adapter\Xcache(); - * - */ -class Xcache extends \Phalcon\Annotations\Adapter -{ - - /** - * Reads parsed annotations from XCache - * - * @param string $key - * @return bool|\Phalcon\Annotations\Reflection - */ - public function read($key) {} - - /** - * Writes parsed annotations to XCache - * - * @param string $key - * @param \Phalcon\Annotations\Reflection $data - */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} - -} diff --git a/src/Phalcon/Application.php b/src/Phalcon/application/AbstractApplication.php similarity index 58% rename from src/Phalcon/Application.php rename to src/Phalcon/application/AbstractApplication.php index 6b5b964a..b0376906 100644 --- a/src/Phalcon/Application.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -1,91 +1,97 @@ + * ```php * $this->registerModules( * [ * "frontend" => [ - * "className" => "Multiple\\Frontend\\Module", + * "className" => \Multiple\Frontend\Module::class, * "path" => "../apps/frontend/Module.php", * ], * "backend" => [ - * "className" => "Multiple\\Backend\\Module", + * "className" => \Multiple\Backend\Module::class, * "path" => "../apps/backend/Module.php", * ], * ] * ); - * + * ``` * * @param array $modules * @param bool $merge * @return Application */ - public function registerModules(array $modules, $merge = false) {} - - /** - * Return the modules registered in the application - * - * @return array - */ - public function getModules() {} - - /** - * Gets the module definition registered in the application via module name - * - * @param string $name - * @return array|object - */ - public function getModule($name) {} + public function registerModules(array $modules, bool $merge = false): Application {} /** * Sets the module name to be used if the router doesn't return a valid module @@ -93,18 +99,14 @@ public function getModule($name) {} * @param string $defaultModule * @return Application */ - public function setDefaultModule($defaultModule) {} + public function setDefaultModule(string $defaultModule): Application {} /** - * Returns the default module name + * Sets the events manager * - * @return string - */ - public function getDefaultModule() {} - - /** - * Handles a request + * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return Application */ - abstract public function handle(); + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): Application {} } diff --git a/src/Phalcon/application/Exception.php b/src/Phalcon/application/Exception.php index f400d62a..9e2d5a57 100644 --- a/src/Phalcon/application/Exception.php +++ b/src/Phalcon/application/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Application; /** - * Phalcon\Application\Exception - * * Exceptions thrown in Phalcon\Application class will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 16acb66d..431db7dc 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -3,176 +3,247 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Asset - * * Represents an asset asset * - * + * ```php * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); - * + * ``` */ -class Asset implements AssetInterface +class Asset implements \Phalcon\Assets\AssetInterface { - /** - * @var array | null - */ - protected $attributes; - - /** - * @var bool - */ - protected $filter; - - /** - * @var bool - */ - protected $local; - - /** - * @var string - */ - protected $path; - - /** - * @var string - */ - protected $sourcePath; - - /** - * @var string - */ - protected $targetPath; - - /** - * @var string - */ - protected $targetUri; - - /** - * @var string - */ - protected $type; - - /** - * Phalcon\Assets\Asset constructor - */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = []) - { - } - - /** - * Sets the asset's type - */ - public function setType(string $type) : AssetInterface - { - } - - /** - * Sets the asset's path - */ - public function setPath(string $path) : AssetInterface - { - } - - /** - * Sets if the asset is local or external - */ - public function setLocal(bool $local) : AssetInterface - { - } - - /** - * Sets if the asset must be filtered or not - */ - public function setFilter(bool $filter) : AssetInterface - { - } - - /** - * Sets extra HTML attributes - */ - public function setAttributes(array $attributes) : AssetInterface - { - } - - /** - * Sets a target uri for the generated HTML - */ - public function setTargetUri(string $targetUri) : AssetInterface - { - } - - /** - * Sets the asset's source path - */ - public function setSourcePath(string $sourcePath) : AssetInterface - { - } - - /** - * Sets the asset's target path - */ - public function setTargetPath(string $targetPath) : AssetInterface - { - } - - /** - * Returns the content of the asset as an string - * Optionally a base path where the asset is located can be set - */ - public function getContent(string $basePath = null) : string - { - } - - /** - * Returns the real target uri for the generated HTML - */ - public function getRealTargetUri() : string - { - } - - /** - * Returns the complete location where the asset is located - */ - public function getRealSourcePath(string $basePath = null) : string - { - } - - /** - * Returns the complete location where the asset must be written - */ - public function getRealTargetPath(string $basePath = null) : string - { - } - - /** - * Gets the asset's key. - */ - public function getAssetKey() : string - { - } - - /** - * Gets the asset's type. - */ - public function getType(): string - { - // TODO: Implement getType() method. - } - - /** - * Gets if the asset must be filtered or not. - */ - public function getFilter(): bool - { - // TODO: Implement getFilter() method. - } - - /** - * Gets extra HTML attributes. - */ - public function getAttributes(): array - { - // TODO: Implement getAttributes() method. - } + /** + * @var array | null + */ + protected $attributes; + + /** + * @var bool + */ + protected $autoVersion = false; + + /** + * @var bool + */ + protected $filter; + + /** + * @var bool + */ + protected $local; + + /** + * @var string + */ + protected $path; + + /** + * @var string + */ + protected $sourcePath; + + /** + * @var string + */ + protected $targetPath; + + /** + * @var string + */ + protected $targetUri; + + /** + * @var string + */ + protected $type; + + /** + * Version of resource + * + * @var string + */ + protected $version; + + + /** + * @return array|null + */ + public function getAttributes(): ?array {} + + /** + * @param bool $autoVersion + */ + public function setAutoVersion(bool $autoVersion) {} + + /** + * @return bool + */ + public function getFilter(): bool {} + + /** + * @return bool + */ + public function getLocal(): bool {} + + /** + * @return string + */ + public function getPath(): string {} + + /** + * @return string + */ + public function getSourcePath(): string {} + + /** + * @return string + */ + public function getTargetPath(): string {} + + /** + * @return string + */ + public function getTargetUri(): string {} + + /** + * @return string + */ + public function getType(): string {} + + /** + * Version of resource + * + * @return string + */ + public function getVersion(): string {} + + /** + * Version of resource + * + * @param string $version + */ + public function setVersion(string $version) {} + + /** + * Phalcon\Assets\Asset constructor + * + * @param string $type + * @param string $path + * @param bool $local + * @param bool $filter + * @param array $attributes + * @param string $version + * @param bool $autoVersion + */ + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} + + /** + * Gets the asset's key. + * + * @return string + */ + public function getAssetKey(): string {} + + /** + * Returns the content of the asset as an string + * Optionally a base path where the asset is located can be set + * + * @param string $basePath + * @return string + */ + public function getContent(string $basePath = null): string {} + + /** + * Returns the complete location where the asset is located + * + * @param string $basePath + * @return string + */ + public function getRealSourcePath(string $basePath = null): string {} + + /** + * Returns the complete location where the asset must be written + * + * @param string $basePath + * @return string + */ + public function getRealTargetPath(string $basePath = null): string {} + + /** + * Returns the real target uri for the generated HTML + * + * @return string + */ + public function getRealTargetUri(): string {} + + /** + * Checks if resource is using auto version + * + * @return bool + */ + public function isAutoVersion(): bool {} + + /** + * Sets extra HTML attributes + * + * @param array $attributes + * @return AssetInterface + */ + public function setAttributes(array $attributes): AssetInterface {} + + /** + * Sets if the asset must be filtered or not + * + * @param bool $filter + * @return AssetInterface + */ + public function setFilter(bool $filter): AssetInterface {} + + /** + * Sets if the asset is local or external + * + * @param bool $local + * @return AssetInterface + */ + public function setLocal(bool $local): AssetInterface {} + + /** + * Sets the asset's source path + * + * @param string $sourcePath + * @return AssetInterface + */ + public function setSourcePath(string $sourcePath): AssetInterface {} + + /** + * Sets the asset's target path + * + * @param string $targetPath + * @return AssetInterface + */ + public function setTargetPath(string $targetPath): AssetInterface {} + + /** + * Sets a target uri for the generated HTML + * + * @param string $targetUri + * @return AssetInterface + */ + public function setTargetUri(string $targetUri): AssetInterface {} + + /** + * Sets the asset's type + * + * @param string $type + * @return AssetInterface + */ + public function setType(string $type): AssetInterface {} + + /** + * Sets the asset's path + * + * @param string $path + * @return AssetInterface + */ + public function setPath(string $path): AssetInterface {} + } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php new file mode 100644 index 00000000..c7bdf739 --- /dev/null +++ b/src/Phalcon/assets/AssetInterface.php @@ -0,0 +1,63 @@ + - * use Phalcon\Assets\Resource; - * use Phalcon\Assets\Collection; - * - * $collection = new Collection(); - * $resource = new Resource("js", "js/jquery.js"); - * $collection->add($resource); - * $collection->has($resource); // true - * + * Adds a filter to the collection * - * @param ResourceInterface $resource - * @return bool + * @param \Phalcon\Assets\FilterInterface $filter + * @return Collection */ - public function has(ResourceInterface $resource) {} + public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection {} /** - * Adds a CSS resource to the collection + * Adds an inline code to the collection * - * @param string $path - * @param mixed $local - * @param bool $filter - * @param mixed $attributes + * @param \Phalcon\Assets\Inline $code * @return Collection */ - public function addCss($path, $local = null, $filter = true, $attributes = null) {} + public function addInline(\Phalcon\Assets\Inline $code): Collection {} /** * Adds an inline CSS to the collection @@ -143,122 +218,138 @@ public function addCss($path, $local = null, $filter = true, $attributes = null) * @param mixed $attributes * @return Collection */ - public function addInlineCss($content, $filter = true, $attributes = null) {} + public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection {} /** - * Adds a javascript resource to the collection + * Adds an inline javascript to the collection * - * @param string $path - * @param boolean $local - * @param boolean $filter - * @param array $attributes + * @param string $content + * @param bool $filter + * @param mixed $attributes * @return Collection */ - public function addJs($path, $local = null, $filter = true, $attributes = null) {} + public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection {} /** - * Adds an inline javascript to the collection + * Adds a javascript asset to the collection * - * @param string $content + * @param string $path + * @param mixed $local * @param bool $filter - * @param mixed $attributes + * @param array $attributes + * @param string $version + * @param bool $autoVersion * @return Collection */ - public function addInlineJs($content, $filter = true, $attributes = null) {} + public function addJs(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection {} /** * Returns the number of elements in the form * * @return int */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} + public function count(): int {} /** - * Returns the current resource in the iterator + * Returns the current asset in the iterator * - * @return \Phalcon\Assets\Resource + * @return \Phalcon\Assets\Asset */ - public function current() {} + public function current(): Asset {} /** - * Returns the current position/key in the iterator + * Returns the complete location where the joined/filtered collection must + * be written * - * @return int + * @param string $basePath + * @return string */ - public function key() {} + public function getRealTargetPath(string $basePath): string {} /** - * Moves the internal iteration pointer to the next position + * Checks this the asset is added to the collection. + * + * ```php + * use Phalcon\Assets\Asset; + * use Phalcon\Assets\Collection; + * + * $collection = new Collection(); + * + * $asset = new Asset("js", "js/jquery.js"); + * + * $collection->add($asset); + * $collection->has($asset); // true + * ``` + * + * @param AssetInterface $asset + * @return bool */ - public function next() {} + public function has(AssetInterface $asset): bool {} /** - * Check if the current element in the iterator is valid + * Checks if collection is using auto version * * @return bool */ - public function valid() {} + public function isAutoVersion(): bool {} /** - * Sets the target path of the file for the filtered/join output + * Sets if all filtered assets in the collection must be joined in a single + * result file * - * @param string $targetPath + * @param bool $join * @return Collection */ - public function setTargetPath($targetPath) {} + public function join(bool $join): Collection {} /** - * Sets a base source path for all the resources in this collection + * Returns the current position/key in the iterator * - * @param string $sourcePath - * @return Collection + * @return int */ - public function setSourcePath($sourcePath) {} + public function key(): int {} /** - * Sets a target uri for the generated HTML - * - * @param string $targetUri - * @return Collection + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Rewinds the internal iterator */ - public function setTargetUri($targetUri) {} + public function rewind() {} /** - * Sets a common prefix for all the resources + * Sets extra HTML attributes * - * @param string $prefix + * @param array $attributes * @return Collection */ - public function setPrefix($prefix) {} + public function setAttributes(array $attributes): Collection {} /** - * Sets if the collection uses local resources by default + * Sets an array of filters in the collection * - * @param bool $local + * @param array $filters * @return Collection */ - public function setLocal($local) {} + public function setFilters(array $filters): Collection {} /** - * Sets extra HTML attributes + * Sets if the collection uses local assets by default * - * @param array $attributes + * @param bool $local * @return Collection */ - public function setAttributes(array $attributes) {} + public function setLocal(bool $local): Collection {} /** - * Sets an array of filters in the collection + * Sets a common prefix for all the assets * - * @param array $filters + * @param string $prefix * @return Collection */ - public function setFilters(array $filters) {} + public function setPrefix(string $prefix): Collection {} /** * Sets the target local @@ -266,38 +357,45 @@ public function setFilters(array $filters) {} * @param bool $targetLocal * @return Collection */ - public function setTargetLocal($targetLocal) {} + public function setTargetLocal(bool $targetLocal): Collection {} /** - * Sets if all filtered resources in the collection must be joined in a single result file + * Sets the target path of the file for the filtered/join output * - * @param bool $join + * @param string $targetPath * @return Collection */ - public function join($join) {} + public function setTargetPath(string $targetPath): Collection {} /** - * Returns the complete location where the joined/filtered collection must be written + * Sets a target uri for the generated HTML * - * @param string $basePath - * @return string + * @param string $targetUri + * @return Collection */ - public function getRealTargetPath($basePath) {} + public function setTargetUri(string $targetUri): Collection {} /** - * Adds a filter to the collection + * Sets a base source path for all the assets in this collection * - * @param \Phalcon\Assets\FilterInterface $filter + * @param string $sourcePath * @return Collection */ - public function addFilter(\Phalcon\Assets\FilterInterface $filter) {} + public function setSourcePath(string $sourcePath): Collection {} + + /** + * Check if the current element in the iterator is valid + * + * @return bool + */ + public function valid(): bool {} /** - * Adds a resource or inline-code to the collection + * Adds a asset or inline-code to the collection * - * @param ResourceInterface $resource + * @param AssetInterface $asset * @return bool */ - protected final function addResource(ResourceInterface $resource) {} + final protected function addAsset(AssetInterface $asset): bool {} } diff --git a/src/Phalcon/assets/Exception.php b/src/Phalcon/assets/Exception.php index c3104d8d..49148351 100644 --- a/src/Phalcon/assets/Exception.php +++ b/src/Phalcon/assets/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Exception - * * Exceptions thrown in Phalcon\Assets will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index 4d1d4911..e0ba66c2 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\FilterInterface - * * Interface for custom Phalcon\Assets filters */ interface FilterInterface @@ -16,6 +14,6 @@ interface FilterInterface * @param string $content * @return string */ - public function filter($content); + public function filter(string $content): string; } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index 15b0be65..de5d3bef 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -3,92 +3,94 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Inline - * * Represents an inline asset * - * + * ```php * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); - * + * ``` */ -class Inline implements \Phalcon\Assets\ResourceInterface +class Inline implements \Phalcon\Assets\AssetInterface { /** - * @var string + * @var array | null */ - protected $_type; + protected $attributes; - - protected $_content; + /** + * @var string + */ + protected $content; /** * @var bool */ - protected $_filter; + protected $filter; + /** + * @var string + */ + protected $type; - protected $_attributes; + /** + * @return array|null + */ + public function getAttributes(): ?array {} /** * @return string */ - public function getType() {} - - - public function getContent() {} + public function getContent(): string {} /** * @return bool */ - public function getFilter() {} + public function getFilter(): bool {} /** - * Phalcon\Assets\Inline constructor - * - * @param string $type - * @param string $content - * @param boolean $filter - * @param array $attributes + * @return string */ - public function __construct($type, $content, $filter = true, $attributes = null) {} + public function getType(): string {} /** - * Sets the inline's type + * Phalcon\Assets\Inline constructor * * @param string $type - * @return ResourceInterface + * @param string $content + * @param bool $filter + * @param array $attributes */ - public function setType($type) {} + public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) {} /** - * Sets if the resource must be filtered or not + * Gets the asset's key. * - * @param bool $filter - * @return ResourceInterface + * @return string */ - public function setFilter($filter) {} + public function getAssetKey(): string {} /** * Sets extra HTML attributes * * @param array $attributes - * @return ResourceInterface + * @return AssetInterface */ - public function setAttributes(array $attributes) {} + public function setAttributes(array $attributes): AssetInterface {} /** - * returns extra HTML attributes + * Sets if the asset must be filtered or not * - * @return array|null + * @param bool $filter + * @return AssetInterface */ - public function getAttributes() {} + public function setFilter(bool $filter): AssetInterface {} /** - * Gets the resource's key. + * Sets the inline's type * - * @return string + * @param string $type + * @return AssetInterface */ - public function getResourceKey() {} + public function setType(string $type): AssetInterface {} } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index d93e5abb..f34300b8 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -7,203 +7,217 @@ * * Manages collections of CSS/Javascript assets */ -class Manager +class Manager implements \Phalcon\Di\InjectionAwareInterface { + + protected $collections; + + /** + * @var DiInterface + */ + protected $container; + /** * Options configure * * @var array */ - protected $_options; + protected $options; - - protected $_collections; - - - protected $_implicitOutput = true; + /** + * @var bool + */ + protected $implicitOutput = true; /** - * Phalcon\Assets\Manager + * Phalcon\Assets\Manager constructor * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Sets the manager options + * Adds a raw asset to the manager * - * @param array $options + * ```php + * $assets->addAsset( + * new Phalcon\Assets\Asset("css", "css/style.css") + * ); + * ``` + * + * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function setOptions(array $options) {} + public function addAsset(\Phalcon\Assets\Asset $asset): Manager {} /** - * Returns the manager options + * Adds a asset by its type * - * @return array - */ - public function getOptions() {} - - /** - * Sets if the HTML generated must be directly printed or returned + * ```php + * $assets->addAssetByType( + * "css", + * new \Phalcon\Assets\Asset\Css("css/style.css") + * ); + * ``` * - * @param bool $implicitOutput + * @param string $type + * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function useImplicitOutput($implicitOutput) {} + public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager {} /** - * Adds a Css resource to the 'css' collection + * Adds a Css asset to the 'css' collection * - * + * ```php * $assets->addCss("css/bootstrap.css"); * $assets->addCss("http://bootstrap.my-cdn.com/style.css", false); - * + * ``` * * @param string $path * @param mixed $local - * @param mixed $filter + * @param bool $filter * @param mixed $attributes + * @param string $version + * @param bool $autoVersion * @return Manager */ - public function addCss($path, $local = true, $filter = true, $attributes = null) {} + public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} /** - * Adds an inline Css to the 'css' collection + * Adds a raw inline code to the manager * - * @param string $content - * @param mixed $filter - * @param mixed $attributes + * @param Inline $code * @return Manager */ - public function addInlineCss($content, $filter = true, $attributes = null) {} + public function addInlineCode(Inline $code): Manager {} /** - * Adds a javascript resource to the 'js' collection - * - * - * $assets->addJs("scripts/jquery.js"); - * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); - * + * Adds an inline code by its type * - * @param string $path - * @param mixed $local - * @param mixed $filter - * @param mixed $attributes + * @param string $type + * @param Inline $code * @return Manager */ - public function addJs($path, $local = true, $filter = true, $attributes = null) {} + public function addInlineCodeByType(string $type, Inline $code): Manager {} /** - * Adds an inline javascript to the 'js' collection + * Adds an inline Css to the 'css' collection * * @param string $content * @param mixed $filter * @param mixed $attributes * @return Manager */ - public function addInlineJs($content, $filter = true, $attributes = null) {} + public function addInlineCss(string $content, $filter = true, $attributes = null): Manager {} /** - * Adds a resource by its type - * - * - * $assets->addResourceByType("css", - * new \Phalcon\Assets\Resource\Css("css/style.css") - * ); - * + * Adds an inline javascript to the 'js' collection * - * @param string $type - * @param \Phalcon\Assets\Resource $resource + * @param string $content + * @param mixed $filter + * @param mixed $attributes * @return Manager */ - public function addResourceByType($type, \Phalcon\Assets\Resource $resource) {} + public function addInlineJs(string $content, $filter = true, $attributes = null): Manager {} /** - * Adds an inline code by its type + * Adds a javascript asset to the 'js' collection * - * @param string $type - * @param Inline $code + * ```php + * $assets->addJs("scripts/jquery.js"); + * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); + * ``` + * + * @param string $path + * @param mixed $local + * @param bool $filter + * @param mixed $attributes + * @param string $version + * @param bool $autoVersion * @return Manager */ - public function addInlineCodeByType($type, Inline $code) {} + public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} /** - * Adds a raw resource to the manager + * Creates/Returns a collection of assets * - * - * $assets->addResource( - * new Phalcon\Assets\Resource("css", "css/style.css") - * ); - * - * - * @param \Phalcon\Assets\Resource $resource - * @return Manager + * @param string $name + * @return \Phalcon\Assets\Collection */ - public function addResource(\Phalcon\Assets\Resource $resource) {} + public function collection(string $name): Collection {} /** - * Adds a raw inline code to the manager + * Creates/Returns a collection of assets by type * - * @param Inline $code - * @return Manager + * @param array $assets + * @param string $type + * @return array */ - public function addInlineCode(Inline $code) {} + public function collectionAssetsByType(array $assets, string $type): array {} /** - * Sets a collection in the Assets Manager + * Returns true or false if collection exists. * - * - * $assets->set("js", $collection); - * + * ```php + * if ($assets->exists("jsHeader")) { + * // \Phalcon\Assets\Collection + * $collection = $assets->get("jsHeader"); + * } + * ``` * * @param string $id - * @param \Phalcon\Assets\Collection $collection - * @return Manager + * @return bool */ - public function set($id, \Phalcon\Assets\Collection $collection) {} + public function exists(string $id): bool {} /** * Returns a collection by its id. * - * + * ```php * $scripts = $assets->get("js"); - * + * ``` * * @param string $id * @return \Phalcon\Assets\Collection */ - public function get($id) {} + public function get(string $id): Collection {} /** - * Returns the CSS collection of assets + * Returns existing collections in the manager * - * @return \Phalcon\Assets\Collection + * @return array|\Phalcon\Assets\Collection[] */ - public function getCss() {} + public function getCollections(): array {} /** * Returns the CSS collection of assets * * @return \Phalcon\Assets\Collection */ - public function getJs() {} + public function getCss(): Collection {} /** - * Creates/Returns a collection of resources + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the CSS collection of assets * - * @param string $name * @return \Phalcon\Assets\Collection */ - public function collection($name) {} + public function getJs(): Collection {} /** - * @param array $resources - * @param string $type + * Returns the manager options + * * @return array */ - public function collectionResourcesByType(array $resources, $type) {} + public function getOptions(): array {} /** * Traverses a collection calling the callback to generate its HTML @@ -213,7 +227,15 @@ public function collectionResourcesByType(array $resources, $type) {} * @param string $type * @return string|null */ - public function output(\Phalcon\Assets\Collection $collection, $callback, $type) {} + public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string {} + + /** + * Prints the HTML for CSS assets + * + * @param string $collectionName + * @return string + */ + public function outputCss(string $collectionName = null): string {} /** * Traverses a collection and generate its HTML @@ -222,60 +244,75 @@ public function output(\Phalcon\Assets\Collection $collection, $callback, $type) * @param string $type * @return string */ - public function outputInline(\Phalcon\Assets\Collection $collection, $type) {} + public function outputInline(\Phalcon\Assets\Collection $collection, $type): string {} /** - * Prints the HTML for CSS resources + * Prints the HTML for inline CSS * * @param string $collectionName * @return string */ - public function outputCss($collectionName = null) {} + public function outputInlineCss(string $collectionName = null): string {} /** - * Prints the HTML for inline CSS + * Prints the HTML for inline JS * * @param string $collectionName * @return string */ - public function outputInlineCss($collectionName = null) {} + public function outputInlineJs(string $collectionName = null): string {} /** - * Prints the HTML for JS resources + * Prints the HTML for JS assets * * @param string $collectionName * @return string */ - public function outputJs($collectionName = null) {} + public function outputJs(string $collectionName = null): string {} /** - * Prints the HTML for inline JS + * Sets a collection in the Assets Manager * - * @param string $collectionName - * @return string + * ```php + * $assets->set("js", $collection); + * ``` + * + * @param string $id + * @param \Phalcon\Assets\Collection $collection + * @return Manager */ - public function outputInlineJs($collectionName = null) {} + public function set(string $id, \Phalcon\Assets\Collection $collection): Manager {} /** - * Returns existing collections in the manager + * Sets the dependency injector * - * @return \Phalcon\Assets\Collection[] + * @param \Phalcon\Di\DiInterface $container */ - public function getCollections() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns true or false if collection exists. + * Sets the manager options * - * - * if ($assets->exists("jsHeader")) { - * // \Phalcon\Assets\Collection - * $collection = $assets->get("jsHeader"); - * } - * + * @param array $options + * @return Manager + */ + public function setOptions(array $options): Manager {} + + /** + * Sets if the HTML generated must be directly printed or returned * - * @param string $id - * @return bool + * @param bool $implicitOutput + * @return Manager + */ + public function useImplicitOutput(bool $implicitOutput): Manager {} + + /** + * Returns the prefixed path + * + * @param \Phalcon\Assets\Collection $collection + * @param string $path + * @return string */ - public function exists($id) {} + private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string {} } diff --git a/src/Phalcon/assets/Resource.php b/src/Phalcon/assets/Resource.php deleted file mode 100644 index 82a0acf8..00000000 --- a/src/Phalcon/assets/Resource.php +++ /dev/null @@ -1,199 +0,0 @@ - - * $resource = new \Phalcon\Assets\Resource("js", "javascripts/jquery.js"); - * - */ -class Resource implements \Phalcon\Assets\ResourceInterface -{ - /** - * @var string - */ - protected $_type; - - /** - * @var string - */ - protected $_path; - - /** - * @var boolean - */ - protected $_local; - - /** - * @var bool - */ - protected $_filter; - - /** - * @var array | null - */ - protected $_attributes; - - - protected $_sourcePath; - - - protected $_targetPath; - - - protected $_targetUri; - - - /** - * @return string - */ - public function getType() {} - - /** - * @return string - */ - public function getPath() {} - - /** - * @return boolean - */ - public function getLocal() {} - - /** - * @return bool - */ - public function getFilter() {} - - /** - * @return array|null - */ - public function getAttributes() {} - - - public function getSourcePath() {} - - - public function getTargetPath() {} - - - public function getTargetUri() {} - - /** - * Phalcon\Assets\Resource constructor - * - * @param string $type - * @param string $path - * @param boolean $local - * @param boolean $filter - * @param array $attributes - */ - public function __construct($type, $path, $local = true, $filter = true, $attributes = null) {} - - /** - * Sets the resource's type - * - * @param string $type - * @return ResourceInterface - */ - public function setType($type) {} - - /** - * Sets the resource's path - * - * @param string $path - * @return Resource - */ - public function setPath($path) {} - - /** - * Sets if the resource is local or external - * - * @param bool $local - * @return Resource - */ - public function setLocal($local) {} - - /** - * Sets if the resource must be filtered or not - * - * @param bool $filter - * @return ResourceInterface - */ - public function setFilter($filter) {} - - /** - * Sets extra HTML attributes - * - * @param array $attributes - * @return ResourceInterface - */ - public function setAttributes(array $attributes) {} - - /** - * Sets a target uri for the generated HTML - * - * @param string $targetUri - * @return Resource - */ - public function setTargetUri($targetUri) {} - - /** - * Sets the resource's source path - * - * @param string $sourcePath - * @return Resource - */ - public function setSourcePath($sourcePath) {} - - /** - * Sets the resource's target path - * - * @param string $targetPath - * @return Resource - */ - public function setTargetPath($targetPath) {} - - /** - * Returns the content of the resource as an string - * Optionally a base path where the resource is located can be set - * - * @param string $basePath - * @return string - */ - public function getContent($basePath = null) {} - - /** - * Returns the real target uri for the generated HTML - * - * @return string - */ - public function getRealTargetUri() {} - - /** - * Returns the complete location where the resource is located - * - * @param string $basePath - * @return string - */ - public function getRealSourcePath($basePath = null) {} - - /** - * Returns the complete location where the resource must be written - * - * @param string $basePath - * @return string - */ - public function getRealTargetPath($basePath = null) {} - - /** - * Gets the resource's key. - * - * @return string - */ - public function getResourceKey() {} - -} diff --git a/src/Phalcon/assets/ResourceInterface.php b/src/Phalcon/assets/ResourceInterface.php deleted file mode 100644 index c34ad4b7..00000000 --- a/src/Phalcon/assets/ResourceInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * use Phalcon\Cache\Frontend\Data as DataFrontend; - * use Phalcon\Cache\Multiple; - * use Phalcon\Cache\Backend\Apc as ApcCache; - * use Phalcon\Cache\Backend\Memcache as MemcacheCache; - * use Phalcon\Cache\Backend\File as FileCache; - * - * $ultraFastFrontend = new DataFrontend( - * [ - * "lifetime" => 3600, - * ] - * ); - * - * $fastFrontend = new DataFrontend( - * [ - * "lifetime" => 86400, - * ] - * ); - * - * $slowFrontend = new DataFrontend( - * [ - * "lifetime" => 604800, - * ] - * ); - * - * //Backends are registered from the fastest to the slower - * $cache = new Multiple( - * [ - * new ApcCache( - * $ultraFastFrontend, - * [ - * "prefix" => "cache", - * ] - * ), - * new MemcacheCache( - * $fastFrontend, - * [ - * "prefix" => "cache", - * "host" => "localhost", - * "port" => "11211", - * ] - * ), - * new FileCache( - * $slowFrontend, - * [ - * "prefix" => "cache", - * "cacheDir" => "../app/cache/", - * ] - * ), - * ] - * ); - * - * //Save, saves in every backend - * $cache->save("my-key", $data); - * - */ -class Multiple -{ - - protected $_backends; - - - /** - * Phalcon\Cache\Multiple constructor - * - * @param Phalcon\Cache\BackendInterface[] backends - * @param mixed $backends - */ - public function __construct($backends = null) {} - - /** - * Adds a backend - * - * @param \Phalcon\Cache\BackendInterface $backend - * @return Multiple - */ - public function push(\Phalcon\Cache\BackendInterface $backend) {} - - /** - * Returns a cached content reading the internal backends - * - * @param string|int $keyName - * @param int $lifetime - * @return mixed - */ - public function get($keyName, $lifetime = null) {} - - /** - * Starts every backend - * - * @param string|int $keyName - * @param int $lifetime - */ - public function start($keyName, $lifetime = null) {} - - /** - * Stores cached content into all backends and stops the frontend - * - * @param string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = null) {} - - /** - * Deletes a value from each backend - * - * @param string|int $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Checks if cache exists in at least one backend - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Flush all backend(s) - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php new file mode 100644 index 00000000..0acab0d8 --- /dev/null +++ b/src/Phalcon/cache/adapter/AdapterInterface.php @@ -0,0 +1,11 @@ + - * use Phalcon\Cache\Backend\Apc; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Apc( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - * - * @see \Phalcon\Cache\Backend\Apcu - * @deprecated - */ -class Apc extends \Phalcon\Cache\Backend -{ - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the APC backend and stops the frontend - * - * @param string|int $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Immediately invalidates all existing items. - * - * - * use Phalcon\Cache\Backend\Apc; - * - * $cache = new Apc($frontCache, ["prefix" => "app-data"]); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Apcu.php b/src/Phalcon/cache/backend/Apcu.php deleted file mode 100644 index 66151d00..00000000 --- a/src/Phalcon/cache/backend/Apcu.php +++ /dev/null @@ -1,126 +0,0 @@ - - * use Phalcon\Cache\Backend\Apcu; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Apcu( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Apcu extends \Phalcon\Cache\Backend -{ - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the APCu backend and stops the frontend - * - * @param string|int $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Immediately invalidates all existing items. - * - * - * use Phalcon\Cache\Backend\Apcu; - * - * $cache = new Apcu($frontCache, ["prefix" => "app-data"]); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Factory.php b/src/Phalcon/cache/backend/Factory.php deleted file mode 100644 index ffb31f6b..00000000 --- a/src/Phalcon/cache/backend/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ - - * use Phalcon\Cache\Backend\Factory; - * use Phalcon\Cache\Frontend\Data; - * - * $options = [ - * "prefix" => "app-data", - * "frontend" => new Data(), - * "adapter" => "apc", - * ]; - * $backendCache = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Cache\BackendInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/cache/backend/File.php b/src/Phalcon/cache/backend/File.php deleted file mode 100644 index 06837215..00000000 --- a/src/Phalcon/cache/backend/File.php +++ /dev/null @@ -1,152 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Output as FrontOutput; - * - * // Cache the file for 2 days - * $frontendOptions = [ - * "lifetime" => 172800, - * ]; - * - * // Create an output cache - * $frontCache = FrontOutput($frontOptions); - * - * // Set the cache directory - * $backendOptions = [ - * "cacheDir" => "../app/cache/", - * ]; - * - * // Create the File backend - * $cache = new File($frontCache, $backendOptions); - * - * $content = $cache->start("my-cache"); - * - * if ($content === null) { - * echo "

", time(), "

"; - * - * $cache->save(); - * } else { - * echo $content; - * } - * - */ -class File extends \Phalcon\Cache\Backend -{ - /** - * Default to false for backwards compatibility - * - * @var boolean - */ - private $_useSafeKey = false; - - - /** - * Phalcon\Cache\Backend\File constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, array $options) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of a given key, by number $value - * - * @param string|int $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string|int $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - - /** - * Return a file-system safe identifier for a given key - * - * @param mixed $key - * @return string - */ - public function getKey($key) {} - - /** - * Set whether to use the safekey or not - * - * @param bool $useSafeKey - * @return File - */ - public function useSafeKey($useSafeKey) {} - -} diff --git a/src/Phalcon/cache/backend/Libmemcached.php b/src/Phalcon/cache/backend/Libmemcached.php deleted file mode 100644 index 89bb77a9..00000000 --- a/src/Phalcon/cache/backend/Libmemcached.php +++ /dev/null @@ -1,162 +0,0 @@ - - * use Phalcon\Cache\Backend\Libmemcached; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new Libmemcached( - * $frontCache, - * [ - * "servers" => [ - * [ - * "host" => "127.0.0.1", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * \Memcached::OPT_HASH => \Memcached::HASH_MD5, - * \Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Libmemcached extends \Phalcon\Cache\Backend -{ - - protected $_memcache = null; - - - /** - * Phalcon\Cache\Backend\Memcache constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to memcached - */ - public function _connect() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * Memcached does not support flush() per default. If you require flush() support, set $config["statsKey"]. - * All modified keys are stored in "statsKey". Note: statsKey has a negative performance impact. - * - * - * $cache = new \Phalcon\Cache\Backend\Libmemcached( - * $frontCache, - * [ - * "statsKey" => "_PHCM", - * ] - * ); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Memcache.php b/src/Phalcon/cache/backend/Memcache.php deleted file mode 100644 index 446c7c63..00000000 --- a/src/Phalcon/cache/backend/Memcache.php +++ /dev/null @@ -1,148 +0,0 @@ - - * use Phalcon\Cache\Backend\Memcache; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new Memcache( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Memcache extends \Phalcon\Cache\Backend -{ - - protected $_memcache = null; - - - /** - * Phalcon\Cache\Backend\Memcache constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to memcached - */ - public function _connect() {} - - /** - * Add servers to memcache pool - * - * @param string $host - * @param int $port - * @param bool $persistent - * @return bool - */ - public function addServers($host, $port, $persistent = false) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Memory.php b/src/Phalcon/cache/backend/Memory.php deleted file mode 100644 index f4ca7853..00000000 --- a/src/Phalcon/cache/backend/Memory.php +++ /dev/null @@ -1,123 +0,0 @@ - - * use Phalcon\Cache\Backend\Memory; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data - * $frontCache = new FrontData(); - * - * $cache = new Memory($frontCache); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Memory extends \Phalcon\Cache\Backend implements \Serializable -{ - - protected $_data; - - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the backend and stops the frontend - * - * @param string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - - /** - * Required for interface \Serializable - * - * @return string - */ - public function serialize() {} - - /** - * Required for interface \Serializable - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/cache/backend/Mongo.php b/src/Phalcon/cache/backend/Mongo.php deleted file mode 100644 index fe92cb29..00000000 --- a/src/Phalcon/cache/backend/Mongo.php +++ /dev/null @@ -1,146 +0,0 @@ - - * use Phalcon\Cache\Backend\Mongo; - * use Phalcon\Cache\Frontend\Base64; - * - * // Cache data for 2 days - * $frontCache = new Base64( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create a MongoDB cache - * $cache = new Mongo( - * $frontCache, - * [ - * "server" => "mongodb://localhost", - * "db" => "caches", - * "collection" => "images", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save( - * "my-data", - * file_get_contents("some-image.jpg") - * ); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Mongo extends \Phalcon\Cache\Backend -{ - - protected $_collection = null; - - - /** - * Phalcon\Cache\Backend\Mongo constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Returns a MongoDb collection based on the backend parameters - * - * @return MongoCollection - */ - protected final function _getCollection() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * gc - * - * @return collection->remove(...) - */ - public function gc() {} - - /** - * Increment of a given key by $value - * - * @param int|string $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName, $value = 1) {} - - /** - * Decrement of a given key by $value - * - * @param int|string $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Redis.php b/src/Phalcon/cache/backend/Redis.php deleted file mode 100644 index 731df280..00000000 --- a/src/Phalcon/cache/backend/Redis.php +++ /dev/null @@ -1,147 +0,0 @@ - - * use Phalcon\Cache\Backend\Redis; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting redis connection options - * $cache = new Redis( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 6379, - * "auth" => "foobared", - * "persistent" => false, - * "index" => 0, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Redis extends \Phalcon\Cache\Backend -{ - - protected $_redis = null; - - - /** - * Phalcon\Cache\Backend\Redis constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to redis - */ - public function _connect() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * - * $cache->save("my-key", $data); - * - * // Save data termlessly - * $cache->save("my-key", $data, -1); - * - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Xcache.php b/src/Phalcon/cache/backend/Xcache.php deleted file mode 100644 index f1ef2761..00000000 --- a/src/Phalcon/cache/backend/Xcache.php +++ /dev/null @@ -1,123 +0,0 @@ - - * use Phalcon\Cache\Backend\Xcache; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Xcache( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Xcache extends \Phalcon\Cache\Backend -{ - - /** - * Phalcon\Cache\Backend\Xcache constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Atomic increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function increment($keyName, $value = 1) {} - - /** - * Atomic decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function decrement($keyName, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php new file mode 100644 index 00000000..cd483e0a --- /dev/null +++ b/src/Phalcon/cache/exception/Exception.php @@ -0,0 +1,11 @@ + - * 172800, - * ] - * ); - * - * //Create a MongoDB cache - * $cache = new \Phalcon\Cache\Backend\Mongo( - * $frontCache, - * [ - * "server" => "mongodb://localhost", - * "db" => "caches", - * "collection" => "images", - * ] - * ); - * - * $cacheKey = "some-image.jpg.cache"; - * - * // Try to get cached image - * $image = $cache->get($cacheKey); - * - * if ($image === null) { - * // Store the image in the cache - * $cache->save( - * $cacheKey, - * file_get_contents("tmp-dir/some-image.jpg") - * ); - * } - * - * header("Content-Type: image/jpeg"); - * - * echo $image; - * - */ -class Base64 implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Base64 constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing in this adapter - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Data.php b/src/Phalcon/cache/frontend/Data.php deleted file mode 100644 index 4ea0ef05..00000000 --- a/src/Phalcon/cache/frontend/Data.php +++ /dev/null @@ -1,114 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Data; - * - * // Cache the files for 2 days using a Data frontend - * $frontCache = new Data( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Data" to a 'File' backend - * // Set the cache file directory - important to keep the '/' at the end of - * // of the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data does not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Data implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Data constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Factory.php b/src/Phalcon/cache/frontend/Factory.php deleted file mode 100644 index 61fd18e3..00000000 --- a/src/Phalcon/cache/frontend/Factory.php +++ /dev/null @@ -1,33 +0,0 @@ - - * use Phalcon\Cache\Frontend\Factory; - * - * $options = [ - * "lifetime" => 172800, - * "adapter" => "data", - * ]; - * $frontendCache = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Cache\FrontendInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/cache/frontend/Igbinary.php b/src/Phalcon/cache/frontend/Igbinary.php deleted file mode 100644 index 3b366e4f..00000000 --- a/src/Phalcon/cache/frontend/Igbinary.php +++ /dev/null @@ -1,109 +0,0 @@ - - * // Cache the files for 2 days using Igbinary frontend - * $frontCache = new \Phalcon\Cache\Frontend\Igbinary( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Igbinary" to a "File" backend - * // Set the cache file directory - important to keep the "/" at the end of - * // of the value for the folder - * $cache = new \Phalcon\Cache\Backend\File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data do not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Igbinary extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Phalcon\Cache\Frontend\Data constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Json.php b/src/Phalcon/cache/frontend/Json.php deleted file mode 100644 index 05bf6fc5..00000000 --- a/src/Phalcon/cache/frontend/Json.php +++ /dev/null @@ -1,102 +0,0 @@ - - * 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new \Phalcon\Cache\Backend\Memcache( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Json implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Base64 constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Msgpack.php b/src/Phalcon/cache/frontend/Msgpack.php deleted file mode 100644 index 66bb57fe..00000000 --- a/src/Phalcon/cache/frontend/Msgpack.php +++ /dev/null @@ -1,115 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Msgpack; - * - * // Cache the files for 2 days using Msgpack frontend - * $frontCache = new Msgpack( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Msgpack" to a "File" backend - * // Set the cache file directory - important to keep the "/" at the end of - * // of the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data do not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Msgpack extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Phalcon\Cache\Frontend\Msgpack constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return null - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/None.php b/src/Phalcon/cache/frontend/None.php deleted file mode 100644 index acce1cd2..00000000 --- a/src/Phalcon/cache/frontend/None.php +++ /dev/null @@ -1,98 +0,0 @@ - - * "localhost", - * "port" => "11211", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // This Frontend always return the data as it's returned by the backend - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // This cache doesn't perform any expiration checking, so the data is always expired - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class None implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Returns cache lifetime, always one second expiring content - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output, always false - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Prepare data to be stored - * - * @param mixed $data - */ - public function beforeStore($data) {} - - /** - * Prepares data to be retrieved to user - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Output.php b/src/Phalcon/cache/frontend/Output.php deleted file mode 100644 index eddcb223..00000000 --- a/src/Phalcon/cache/frontend/Output.php +++ /dev/null @@ -1,120 +0,0 @@ - - * use Phalcon\Tag; - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Output; - * - * // Create an Output frontend. Cache the files for 2 days - * $frontCache = new Output( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache from the "Output" to a "File" backend - * // Set the cache file directory - it's important to keep the "/" at the end of - * // the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * // Get/Set the cache file to ../app/cache/my-cache.html - * $content = $cache->start("my-cache.html"); - * - * // If $content is null then the content will be generated for the cache - * if (null === $content) { - * // Print date and time - * echo date("r"); - * - * // Generate a link to the sign-up action - * echo Tag::linkTo( - * [ - * "user/signup", - * "Sign Up", - * "class" => "signup-button", - * ] - * ); - * - * // Store the output into the cache file - * $cache->save(); - * } else { - * // Echo the cached output - * echo $content; - * } - * - */ -class Output implements \Phalcon\Cache\FrontendInterface -{ - - protected $_buffering = false; - - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Output constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Currently, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 01123b6d..2da7a60c 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -3,37 +3,20 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Console - * * This component allows to create CLI applications using Phalcon */ -class Console extends \Phalcon\Application +class Console extends \Phalcon\Application\AbstractApplication { - - protected $_arguments = array(); - - - protected $_options = array(); - + /** + * @var array + */ + protected $arguments = array(); /** - * Merge modules with the existing ones - * - * - * $application->addModules( - * [ - * "admin" => [ - * "className" => "Multiple\\Admin\\Module", - * "path" => "../apps/admin/Module.php", - * ], - * ] - * ); - * - * - * @param array $modules - * @deprecated + * @var array */ - public function addModules(array $modules) {} + protected $options = array(); + /** * Handle the whole command-line tasks @@ -50,6 +33,6 @@ public function handle(array $arguments = null) {} * @param bool $shift * @return Console */ - public function setArgument(array $arguments = null, $str = true, $shift = true) {} + public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console {} } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index 28f105ea..3771ce22 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -3,18 +3,18 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Dispatcher + * Dispatching is the process of taking the command-line arguments, extracting + * the module name, task name, action name, and optional parameters contained in + * it, and then instantiating a task and calling an action on it. * - * Dispatching is the process of taking the command-line arguments, extracting the module name, - * task name, action name, and optional parameters contained in it, and then - * instantiating a task and calling an action on it. - * - * + * ```php * use Phalcon\Di; * use Phalcon\Cli\Dispatcher; * * $di = new Di(); + * * $dispatcher = new Dispatcher(); + * * $dispatcher->setDi($di); * * $dispatcher->setTaskName("posts"); @@ -22,79 +22,100 @@ * $dispatcher->setParams([]); * * $handle = $dispatcher->dispatch(); - * + * ``` */ -class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface { + /** + * @var string + */ + protected $defaultHandler = 'main'; - protected $_handlerSuffix = 'Task'; - - - protected $_defaultHandler = 'main'; - + /** + * @var string + */ + protected $defaultAction = 'main'; - protected $_defaultAction = 'main'; + /** + * @var string + */ + protected $handlerSuffix = 'Task'; + /** + * @var array + */ + protected $options = array(); - protected $_options = array(); + /** + * Calls the action method. + * + * @param mixed $handler + * @param string $actionMethod + * @param array $params + * @return mixed + */ + public function callActionMethod($handler, string $actionMethod, array $params = array()) {} /** - * Sets the default task suffix + * Returns the active task in the dispatcher * - * @param string $taskSuffix + * @return TaskInterface */ - public function setTaskSuffix($taskSuffix) {} + public function getActiveTask(): TaskInterface {} /** - * Sets the default task name + * Returns the latest dispatched controller * - * @param string $taskName + * @return TaskInterface */ - public function setDefaultTask($taskName) {} + public function getLastTask(): TaskInterface {} /** - * Sets the task name to be dispatched + * Gets an option by its name or numeric index * - * @param string $taskName + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setTaskName($taskName) {} + public function getOption($option, $filters = null, $defaultValue = null) {} /** - * Gets last dispatched task name + * Get dispatched options * - * @return string + * @return array */ - public function getTaskName() {} + public function getOptions(): array {} /** - * Throws an internal exception + * Gets last dispatched task name * - * @param string $message - * @param int $exceptionCode + * @return string */ - protected function _throwDispatchException($message, $exceptionCode = 0) {} + public function getTaskName(): string {} /** - * Handles a user exception + * Gets the default task suffix * - * @param \Exception $exception + * @return string */ - protected function _handleException(\Exception $exception) {} + public function getTaskSuffix(): string {} /** - * Returns the latest dispatched controller + * Check if an option exists * - * @return TaskInterface + * @param mixed $option + * @return bool */ - public function getLastTask() {} + public function hasOption($option): bool {} /** - * Returns the active task in the dispatcher + * Sets the default task name * - * @return TaskInterface + * @param string $taskName */ - public function getActiveTask() {} + public function setDefaultTask(string $taskName) {} /** * Set the options to be dispatched @@ -104,38 +125,32 @@ public function getActiveTask() {} public function setOptions(array $options) {} /** - * Get dispatched options + * Sets the task name to be dispatched * - * @return array + * @param string $taskName */ - public function getOptions() {} + public function setTaskName(string $taskName) {} /** - * Gets an option by its name or numeric index + * Sets the default task suffix * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @param string $taskSuffix */ - public function getOption($option, $filters = null, $defaultValue = null) {} + public function setTaskSuffix(string $taskSuffix) {} /** - * Check if an option exists + * Handles a user exception * - * @param mixed $option - * @return bool + * @param \Exception $exception */ - public function hasOption($option) {} + protected function handleException(\Exception $exception) {} /** - * Calls the action method. + * Throws an internal exception * - * @param mixed $handler - * @param string $actionMethod - * @param array $params - * @return mixed + * @param string $message + * @param int $exceptionCode */ - public function callActionMethod($handler, $actionMethod, array $params = array()) {} + protected function throwDispatchException(string $message, int $exceptionCode = 0) {} } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index 99a31ecc..eed77c38 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -3,53 +3,72 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\DispatcherInterface - * * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends \Phalcon\DispatcherInterface +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** - * Sets the default task suffix + * Returns the active task in the dispatcher * - * @param string $taskSuffix + * @return TaskInterface */ - public function setTaskSuffix($taskSuffix); + public function getActiveTask(): TaskInterface; /** - * Sets the default task name + * Returns the latest dispatched controller * - * @param string $taskName + * @return TaskInterface */ - public function setDefaultTask($taskName); + public function getLastTask(): TaskInterface; /** - * Sets the task name to be dispatched + * Get dispatched options * - * @param string $taskName + * @return array */ - public function setTaskName($taskName); + public function getOptions(): array; /** * Gets last dispatched task name * * @return string */ - public function getTaskName(); + public function getTaskName(): string; /** - * Returns the latest dispatched controller + * Gets default task suffix * - * @return TaskInterface + * @return string */ - public function getLastTask(); + public function getTaskSuffix(): string; /** - * Returns the active task in the dispatcher + * Sets the default task name * - * @return TaskInterface + * @param string $taskName + */ + public function setDefaultTask(string $taskName); + + /** + * Set the options to be dispatched + * + * @param array $options + */ + public function setOptions(array $options); + + /** + * Sets the task name to be dispatched + * + * @param string $taskName + */ + public function setTaskName(string $taskName); + + /** + * Sets the default task suffix + * + * @param string $taskSuffix */ - public function getActiveTask(); + public function setTaskSuffix(string $taskSuffix); } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 09c0cf0c..541e64b1 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -3,14 +3,12 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Router + * Phalcon\Cli\Router is the standard framework router. Routing is the process + * of taking a command-line arguments and decomposing it into parameters to + * determine which module, task, and action of that task should receive the + * request. * - *

Phalcon\Cli\Router is the standard framework router. Routing is the - * process of taking a command-line arguments and - * decomposing it into parameters to determine which module, task, and - * action of that task should receive the request

- * - * + * ```php * $router = new \Phalcon\Cli\Router(); * * $router->handle( @@ -22,48 +20,52 @@ * ); * * echo $router->getTaskName(); - * + * ``` */ class Router implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $action; - protected $_module; + protected $container; - protected $_task; + protected $defaultAction = null; - protected $_action; + protected $defaultModule = null; - protected $_params = array(); - + /** + * @var array + */ + protected $defaultParams = array(); - protected $_defaultModule = null; + protected $defaultTask = null; - protected $_defaultTask = null; + protected $matchedRoute; - protected $_defaultAction = null; + protected $matches; - protected $_defaultParams = array(); + protected $module; - protected $_routes; + /** + * @var array + */ + protected $params = array(); - protected $_matchedRoute; + protected $routes; - protected $_matches; + protected $task; - protected $_wasMatched = false; + protected $wasMatched = false; /** @@ -71,151 +73,152 @@ class Router implements \Phalcon\Di\InjectionAwareInterface * * @param bool $defaultRoutes */ - public function __construct($defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) {} /** - * Sets the dependency injector + * Adds a route to the router + * + * ```php + * $router->add("/about", "About::main"); + * ``` * - * @param \Phalcon\DiInterface $dependencyInjector + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function add(string $pattern, $paths = null): RouteInterface {} /** - * Returns the internal dependency injector + * Returns processed action name * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getActionName(): string {} /** - * Sets the name of the default module + * Returns the internal dependency injector * - * @param string $moduleName + * @return \Phalcon\Di\DiInterface */ - public function setDefaultModule($moduleName) {} + public function getDI(): DiInterface {} /** - * Sets the default controller name + * Returns the route that matches the handled URI * - * @param string $taskName + * @return RouteInterface */ - public function setDefaultTask($taskName) {} + public function getMatchedRoute(): RouteInterface {} /** - * Sets the default action name + * Returns the sub expressions in the regular expression matched * - * @param string $actionName + * @return array */ - public function setDefaultAction($actionName) {} + public function getMatches(): array {} /** - * Sets an array of default paths. If a route is missing a path the router will use the defined here - * This method must not be used to set a 404 route - * - * - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * + * Returns processed module name * - * @param array $defaults - * @return Router + * @return string */ - public function setDefaults(array $defaults) {} + public function getModuleName(): string {} /** - * Handles routing information received from command-line arguments + * Returns processed extra params * - * @param array $arguments + * @return array */ - public function handle($arguments = null) {} + public function getParams(): array {} /** - * Adds a route to the router - * - * - * $router->add("/about", "About::main"); - * + * Returns a route object by its id * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @param int $id + * @return bool|RouteInterface */ - public function add($pattern, $paths = null) {} + public function getRouteById($id) {} /** - * Returns processed module name + * Returns a route object by its name * - * @return string + * @param string $name + * @return bool|RouteInterface */ - public function getModuleName() {} + public function getRouteByName(string $name) {} /** - * Returns processed task name + * Returns all the routes defined in the router * - * @return string + * @return array|\Phalcon\Cli\Router\Route[] */ - public function getTaskName() {} + public function getRoutes(): array {} /** - * Returns processed action name + * Returns processed task name * * @return string */ - public function getActionName() {} + public function getTaskName(): string {} /** - * Returns processed extra params + * Handles routing information received from command-line arguments * - * @return array + * @param array $arguments */ - public function getParams() {} + public function handle($arguments = null) {} /** - * Returns the route that matches the handled URI + * Sets the default action name * - * @return RouteInterface + * @param string $actionName */ - public function getMatchedRoute() {} + public function setDefaultAction(string $actionName) {} /** - * Returns the sub expressions in the regular expression matched + * Sets the name of the default module * - * @return array + * @param string $moduleName */ - public function getMatches() {} + public function setDefaultModule(string $moduleName) {} /** - * Checks if the router matches any of the defined routes + * Sets an array of default paths. If a route is missing a path the router + * will use the defined here. This method must not be used to set a 404 + * route * - * @return bool + * ```php + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * ``` + * + * @param array $defaults + * @return Router */ - public function wasMatched() {} + public function setDefaults(array $defaults): Router {} /** - * Returns all the routes defined in the router + * Sets the default controller name * - * @return \Phalcon\Cli\Router\Route[] + * @param string $taskName */ - public function getRoutes() {} + public function setDefaultTask(string $taskName) {} /** - * Returns a route object by its id + * Sets the dependency injector * - * @param int $id - * @return bool|RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getRouteById($id) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns a route object by its name + * Checks if the router matches any of the defined routes * - * @param string $name - * @return bool|RouteInterface + * @return bool */ - public function getRouteByName($name) {} + public function wasMatched(): bool {} } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 1d28c053..7f3d4abe 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -3,127 +3,125 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\RouterInterface - * * Interface for Phalcon\Cli\Router */ interface RouterInterface { /** - * Sets the name of the default module + * Adds a route to the router on any HTTP method * - * @param string $moduleName + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Cli\Router\RouteInterface */ - public function setDefaultModule($moduleName); + public function add(string $pattern, $paths = null): RouteInterface; /** - * Sets the default task name + * Returns processed action name * - * @param string $taskName + * @return string */ - public function setDefaultTask($taskName); + public function getActionName(): string; /** - * Sets the default action name + * Returns the route that matches the handled URI * - * @param string $actionName + * @return \Phalcon\Cli\Router\RouteInterface */ - public function setDefaultAction($actionName); + public function getMatchedRoute(): RouteInterface; /** - * Sets an array of default paths + * Return the sub expressions in the regular expression matched * - * @param array $defaults + * @return array */ - public function setDefaults(array $defaults); + public function getMatches(): array; /** - * Handles routing information received from the rewrite engine + * Returns processed module name * - * @param array $arguments + * @return string */ - public function handle($arguments = null); + public function getModuleName(): string; /** - * Adds a route to the router on any HTTP method + * Returns processed extra params * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Cli\Router\RouteInterface + * @return array */ - public function add($pattern, $paths = null); + public function getParams(): array; /** - * Returns processed module name + * Returns a route object by its id * - * @return string + * @param mixed $id + * @return \Phalcon\Cli\Router\RouteInterface */ - public function getModuleName(); + public function getRouteById($id): RouteInterface; /** - * Returns processed task name + * Returns a route object by its name * - * @return string + * @param string $name + * @return \Phalcon\Cli\Router\RouteInterface */ - public function getTaskName(); + public function getRouteByName(string $name): RouteInterface; /** - * Returns processed action name + * Return all the routes defined in the router * - * @return string + * @return array|\Phalcon\Cli\Router\RouteInterface[] */ - public function getActionName(); + public function getRoutes(): array; /** - * Returns processed extra params + * Returns processed task name * - * @return array + * @return string */ - public function getParams(); + public function getTaskName(): string; /** - * Returns the route that matches the handled URI + * Handles routing information received from the rewrite engine * - * @return \Phalcon\Cli\Router\RouteInterface + * @param array $arguments */ - public function getMatchedRoute(); + public function handle($arguments = null); /** - * Return the sub expressions in the regular expression matched + * Sets the default action name * - * @return array + * @param string $actionName */ - public function getMatches(); + public function setDefaultAction(string $actionName); /** - * Check if the router matches any of the defined routes + * Sets the name of the default module * - * @return bool + * @param string $moduleName */ - public function wasMatched(); + public function setDefaultModule(string $moduleName); /** - * Return all the routes defined in the router + * Sets an array of default paths * - * @return \Phalcon\Cli\Router\RouteInterface[] + * @param array $defaults */ - public function getRoutes(); + public function setDefaults(array $defaults); /** - * Returns a route object by its id + * Sets the default task name * - * @param mixed $id - * @return \Phalcon\Cli\Router\RouteInterface + * @param string $taskName */ - public function getRouteById($id); + public function setDefaultTask(string $taskName); /** - * Returns a route object by its name + * Check if the router matches any of the defined routes * - * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return bool */ - public function getRouteByName($name); + public function wasMatched(): bool; } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 038a6603..41ba3342 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -3,14 +3,14 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Task + * Every command-line task should extend this class that encapsulates all the + * task functionality * - * Every command-line task should extend this class that encapsulates all the task functionality + * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, + * or anything that you want. The Task class should at least have a "mainAction" + * method. * - * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that you want. - * The Task class should at least have a "mainAction" method - * - * + * ```php * class HelloTask extends \Phalcon\Cli\Task * { * // This action will be executed by default @@ -24,7 +24,7 @@ * * } * } - * + * ``` */ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface { @@ -32,6 +32,6 @@ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface /** * Phalcon\Cli\Task constructor */ - public final function __construct() {} + final public function __construct() {} } diff --git a/src/Phalcon/cli/TaskInterface.php b/src/Phalcon/cli/TaskInterface.php index 2b561c82..9ceb7d69 100644 --- a/src/Phalcon/cli/TaskInterface.php +++ b/src/Phalcon/cli/TaskInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\TaskInterface - * * Interface for task handlers */ interface TaskInterface diff --git a/src/Phalcon/cli/console/Exception.php b/src/Phalcon/cli/console/Exception.php index 602a4879..09649fa2 100644 --- a/src/Phalcon/cli/console/Exception.php +++ b/src/Phalcon/cli/console/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Console; /** - * Phalcon\Cli\Console\Exception - * * Exceptions thrown in Phalcon\Cli\Console will use this class */ class Exception extends \Phalcon\Application\Exception diff --git a/src/Phalcon/cli/dispatcher/Exception.php b/src/Phalcon/cli/dispatcher/Exception.php index 416f26a6..d03f5450 100644 --- a/src/Phalcon/cli/dispatcher/Exception.php +++ b/src/Phalcon/cli/dispatcher/Exception.php @@ -3,11 +3,9 @@ namespace Phalcon\Cli\Dispatcher; /** - * Phalcon\Cli\Dispatcher\Exception - * * Exceptions thrown in Phalcon\Cli\Dispatcher will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Phalcon\Dispatcher\Exception { } diff --git a/src/Phalcon/cli/router/Exception.php b/src/Phalcon/cli/router/Exception.php index 6b6d0485..06f5a678 100644 --- a/src/Phalcon/cli/router/Exception.php +++ b/src/Phalcon/cli/router/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\Exception - * * Exceptions thrown in Phalcon\Cli\Router will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 5b5e8ca6..5e0e0997 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\Route - * * This class represents every route added to the router */ class Route @@ -13,159 +11,166 @@ class Route const DEFAULT_DELIMITER = ' '; - protected $_pattern; + protected $beforeMatch; - protected $_compiledPattern; + protected $compiledPattern; - protected $_paths; + protected $converters; - protected $_converters; + protected $delimiter; - protected $_id; + static protected $delimiterPath = self::DEFAULT_DELIMITER; - protected $_name; + protected $description; - protected $_beforeMatch; + protected $id; - protected $_delimiter; + protected $name; - static protected $_uniqueId; + protected $paths; - static protected $_delimiterPath; + protected $pattern; + + + static protected $uniqueId = 0; /** - * Phalcon\Cli\Router\Route constructor - * * @param string $pattern - * @param array $paths + * @param array|string $paths */ - public function __construct($pattern, $paths = null) {} + public function __construct(string $pattern, $paths = null) {} /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @return string + * @param callback $callback + * @return RouteInterface */ - public function compilePattern($pattern) {} + public function beforeMatch($callback): RouteInterface {} /** - * Extracts parameters from a string + * Replaces placeholders from pattern returning a valid PCRE regular + * expression * * @param string $pattern - * @return array|boolean + * @return string */ - public function extractNamedParams($pattern) {} + public function compilePattern(string $pattern): string {} /** - * Reconfigure the route adding a new pattern and a set of paths + * Adds a converter to perform an additional transformation for certain + * parameter * - * @param string $pattern - * @param array $paths + * @param string $name + * @param callable $converter + * @return RouteInterface */ - public function reConfigure($pattern, $paths = null) {} + public function convert(string $name, $converter): RouteInterface {} /** - * Returns the route's name + * Set the routing delimiter * - * @return string + * @param string $delimiter */ - public function getName() {} + public static function delimiter(string $delimiter = null) {} /** - * Sets the route's name + * Extracts parameters from a string * - * - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * + * @param string $pattern + * @return array|bool + */ + public function extractNamedParams(string $pattern) {} + + /** + * Returns the 'before match' callback if any * - * @param string $name - * @return Route + * @return mixed */ - public function setName($name) {} + public function getBeforeMatch() {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Returns the route's compiled pattern * - * @param callback $callback - * @return Route + * @return string */ - public function beforeMatch($callback) {} + public function getCompiledPattern(): string {} /** - * Returns the 'before match' callback if any + * Returns the router converter * - * @return mixed + * @return array */ - public function getBeforeMatch() {} + public function getConverters(): array {} /** - * Returns the route's id + * Get routing delimiter * * @return string */ - public function getRouteId() {} + public static function getDelimiter(): string {} /** - * Returns the route's pattern + * Returns the route's description * * @return string */ - public function getPattern() {} + public function getDescription(): string {} /** - * Returns the route's compiled pattern + * Returns the route's name * * @return string */ - public function getCompiledPattern() {} + public function getName(): string {} /** * Returns the paths * * @return array */ - public function getPaths() {} + public function getPaths(): array {} + + /** + * Returns the route's pattern + * + * @return string + */ + public function getPattern(): string {} /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths() {} + public function getReversedPaths(): array {} /** - * Adds a converter to perform an additional transformation for certain parameter + * Returns the route's id * - * @param string $name - * @param callable $converter - * @return Route + * @return string */ - public function convert($name, $converter) {} + public function getRouteId(): string {} /** - * Returns the router converter + * Reconfigure the route adding a new pattern and a set of paths * - * @return array + * @param string $pattern + * @param array|string $paths */ - public function getConverters() {} + public function reConfigure(string $pattern, $paths = null) {} /** * Resets the internal route id generator @@ -173,17 +178,28 @@ public function getConverters() {} public static function reset() {} /** - * Set the routing delimiter + * Sets the route's description * - * @param string $delimiter + * @param string $description + * @return RouteInterface */ - public static function delimiter($delimiter = null) {} + public function setDescription(string $description): RouteInterface {} /** - * Get routing delimiter + * Sets the route's name * - * @return string + * ```php + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * ``` + * + * @param string $name + * @return RouteInterface */ - public static function getDelimiter() {} + public function setName(string $name): RouteInterface {} } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index cec93a31..d5cff844 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -3,81 +3,110 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\RouteInterface - * * Interface for Phalcon\Cli\Router\Route */ interface RouteInterface { /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Replaces placeholders from pattern returning a valid PCRE regular + * expression * * @param string $pattern * @return string */ - public function compilePattern($pattern); + public function compilePattern(string $pattern): string; /** - * Reconfigure the route adding a new pattern and a set of paths + * Set the routing delimiter * - * @param string $pattern - * @param mixed $paths + * @param string $delimiter */ - public function reConfigure($pattern, $paths = null); + public static function delimiter(string $delimiter = null); /** - * Returns the route's name + * Returns the route's pattern * * @return string */ - public function getName(); + public function getCompiledPattern(): string; /** - * Sets the route's name + * Get routing delimiter * - * @param string $name + * @return string */ - public function setName($name); + public static function getDelimiter(): string; /** - * Returns the route's id + * Returns the route's description * * @return string */ - public function getRouteId(); + public function getDescription(): string; /** - * Returns the route's pattern + * Returns the route's name * * @return string */ - public function getPattern(); + public function getName(): string; + + /** + * Returns the paths + * + * @return array + */ + public function getPaths(): array; /** * Returns the route's pattern * * @return string */ - public function getCompiledPattern(); + public function getPattern(): string; /** - * Returns the paths + * Returns the paths using positions as keys and names as values * * @return array */ - public function getPaths(); + public function getReversedPaths(): array; /** - * Returns the paths using positions as keys and names as values + * Returns the route's id * - * @return array + * @return string + */ + public function getRouteId(): string; + + /** + * Reconfigure the route adding a new pattern and a set of paths + * + * @param string $pattern + * @param mixed $paths */ - public function getReversedPaths(); + public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator */ public static function reset(); + /** + * Sets the route's description + * + * @param string $description + * @return RouteInterface + */ + public function setDescription(string $description): RouteInterface; + + /** + * Sets the route's name + * + * @param string $name + * @return RouteInterface + */ + public function setName(string $name): RouteInterface; + } diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php new file mode 100644 index 00000000..58194464 --- /dev/null +++ b/src/Phalcon/collection/Exception.php @@ -0,0 +1,11 @@ + "path/config", + * "adapter" => "php", + * ]; + * + * $config = (new ConfigFactory())->load($options); + * ``` + */ +class ConfigFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * ConfigFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Load a config to create a new instance + * + * @param mixed $config + * @return object + */ + public function load($config) {} + + /** + * Returns a new Config instance + * + * @param string $name + * @param string $fileName + * @param mixed $params + * @return object + */ + public function newInstance(string $name, string $fileName, $params = null) {} + + /** + * Returns the adapters for the factory + * + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/config/Exception.php b/src/Phalcon/config/Exception.php index f365baad..80954ccc 100644 --- a/src/Phalcon/config/Exception.php +++ b/src/Phalcon/config/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Config; /** - * Phalcon\Config\Exception - * * Exceptions thrown in Phalcon\Config will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/config/Factory.php b/src/Phalcon/config/Factory.php deleted file mode 100644 index 1fe15287..00000000 --- a/src/Phalcon/config/Factory.php +++ /dev/null @@ -1,33 +0,0 @@ - - * use Phalcon\Config\Factory; - * - * $options = [ - * "filePath" => "path/config", - * "adapter" => "php", - * ]; - * $config = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Config - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 348b9b5f..5de00ac0 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Grouped - * * Reads multiple files (or arrays) and merges them all together. * - * @see Phalcon\Config\Factory::load To load Config Adapter class using 'adapter' option. + * See `Phalcon\Config\Factory::load` To load Config Adapter class using 'adapter' option. * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -18,9 +16,9 @@ * "path/to/config.dist.php", * ] * ); - * + * ``` * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -30,9 +28,9 @@ * ], * "json" * ); - * + * ``` * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -49,10 +47,11 @@ * "adapter" => "array", * "config" => [ * "property" => "value", + * ], * ], * ], * ); - * + * ``` */ class Grouped extends \Phalcon\Config { @@ -63,6 +62,6 @@ class Grouped extends \Phalcon\Config * @param array $arrayConfig * @param string $defaultAdapter */ - public function __construct(array $arrayConfig, $defaultAdapter = 'php') {} + public function __construct(array $arrayConfig, string $defaultAdapter = 'php') {} } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 63694376..d2679230 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Ini - * * Reads ini files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * + * ```ini * [database] * adapter = Mysql * host = localhost @@ -21,68 +19,58 @@ * controllersDir = "../app/controllers/" * modelsDir = "../app/models/" * viewsDir = "../app/views/" - * + * ``` * * You can read it as follows: * - * - * $config = new \Phalcon\Config\Adapter\Ini("path/config.ini"); + * ```php + * use Phalcon\Config\Adapter\Ini; + * + * $config = new Ini("path/config.ini"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * + * ``` * * PHP constants may also be parsed in the ini file, so if you define a constant * as an ini value before calling the constructor, the constant's value will be * integrated into the results. To use it this way you must specify the optional - * second parameter as INI_SCANNER_NORMAL when calling the constructor: + * second parameter as `INI_SCANNER_NORMAL` when calling the constructor: * - * + * ```php * $config = new \Phalcon\Config\Adapter\Ini( * "path/config-with-constants.ini", * INI_SCANNER_NORMAL * ); - * + * ``` */ class Ini extends \Phalcon\Config { /** - * Phalcon\Config\Adapter\Ini constructor + * Ini constructor. * * @param string $filePath * @param mixed $mode */ - public function __construct($filePath, $mode = null) {} + public function __construct(string $filePath, $mode = null) {} /** - * Build multidimensional array from string - * - * - * $this->_parseIniString("path.hello.world", "value for last key"); + * We have to cast values manually because parse_ini_file() has a poor + * implementation. * - * // result - * [ - * "path" => [ - * "hello" => [ - * "world" => "value for last key", - * ], - * ], - * ]; - * - * - * @param string $path - * @param mixed $value - * @return array + * @param mixed $ini + * @return bool|null|double|int|string */ - protected function _parseIniString($path, $value) {} + protected function cast($ini) {} /** - * We have to cast values manually because parse_ini_file() has a poor implementation. + * Build multidimensional array from string * - * @param mixed $ini The array casted by `parse_ini_file` - * @return bool|null|double|int|string + * @param string $path + * @param mixed $value + * @return array */ - protected function _cast($ini) {} + protected function parseIniString(string $path, $value): array {} } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 5c9f5761..6f20d09f 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -3,24 +3,24 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Json - * * Reads JSON files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * + * ```json * {"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"}} - * + * ``` * * You can read it as follows: * - * - * $config = new Phalcon\Config\Adapter\Json("path/config.json"); + * ```php + * use Phalcon\Config\Adapter\Json; + * + * $config = new Json("path/config.json"); * * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * + * ``` */ class Json extends \Phalcon\Config { @@ -30,6 +30,6 @@ class Json extends \Phalcon\Config * * @param string $filePath */ - public function __construct($filePath) {} + public function __construct(string $filePath) {} } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index 844d44e6..cea8c07c 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Php - * * Reads php files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * + * ```php * "../app/views/", * ], * ]; - * + * ``` * * You can read it as follows: * - * - * $config = new \Phalcon\Config\Adapter\Php("path/config.php"); + * ```php + * use Phalcon\Config\Adapter\Php; + * + * $config = new Php("path/config.php"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * + * ``` */ class Php extends \Phalcon\Config { @@ -45,6 +45,6 @@ class Php extends \Phalcon\Config * * @param string $filePath */ - public function __construct($filePath) {} + public function __construct(string $filePath) {} } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index a0beca14..b0d7dc11 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -3,29 +3,29 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Yaml - * * Reads YAML files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * + * ```yaml * phalcon: * baseuri: /phalcon/ * controllersDir: !approot /app/controllers/ * models: * metadata: memory - * + * ``` * * You can read it as follows: * - * + * ```php * define( * "APPROOT", * dirname(__DIR__) * ); * - * $config = new \Phalcon\Config\Adapter\Yaml( + * use Phalcon\Config\Adapter\Yaml; + * + * $config = new Yaml( * "path/config.yaml", * [ * "!approot" => function($value) { @@ -37,7 +37,7 @@ * echo $config->phalcon->controllersDir; * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * + * ``` */ class Yaml extends \Phalcon\Config { @@ -45,10 +45,9 @@ class Yaml extends \Phalcon\Config /** * Phalcon\Config\Adapter\Yaml constructor * - * @throws \Phalcon\Config\Exception * @param string $filePath * @param array $callbacks */ - public function __construct($filePath, array $callbacks = null) {} + public function __construct(string $filePath, array $callbacks = null) {} } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php new file mode 100644 index 00000000..2758e631 --- /dev/null +++ b/src/Phalcon/crypt/CryptInterface.php @@ -0,0 +1,137 @@ + "192.168.0.11", + * "username" => "sigma", + * "password" => "secret", + * "dbname" => "blog", + * "port" => "3306", + * ] + * ); + * + * $result = $connection->query( + * "SELECT FROM robots LIMIT 5" + * ); + * + * $result->setFetchMode(Enum::FETCH_NUM); + * + * while ($robot = $result->fetch()) { + * print_r($robot); + * } + * } catch (Exception $e) { + * echo $e->getMessage(), PHP_EOL; + * } + * ``` + */ +abstract class AbstractDb +{ + + /** + * Enables/disables options in the Database component + * + * @param array $options + */ + public static function setup(array $options) {} + +} diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 4c08e763..30f71f34 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -3,11 +3,9 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Column - * * Allows to define columns to be used on create or alter table operations * - * + * ```php * use Phalcon\Db\Column as Column; * * // Column definition @@ -25,188 +23,198 @@ * * // Add column to existing table * $connection->addColumn("robots", null, $column); - * + * ``` */ class Column implements \Phalcon\Db\ColumnInterface { /** - * Integer abstract type + * Bind Type Blob */ - const TYPE_INTEGER = 0; + const BIND_PARAM_BLOB = 3; /** - * Date abstract type + * Bind Type Bool */ - const TYPE_DATE = 1; + const BIND_PARAM_BOOL = 5; /** - * Varchar abstract type + * Bind Type Decimal */ - const TYPE_VARCHAR = 2; + const BIND_PARAM_DECIMAL = 32; /** - * Decimal abstract type + * Bind Type Integer */ - const TYPE_DECIMAL = 3; + const BIND_PARAM_INT = 1; /** - * Datetime abstract type + * Bind Type Null */ - const TYPE_DATETIME = 4; + const BIND_PARAM_NULL = 0; /** - * Char abstract type + * Bind Type String */ - const TYPE_CHAR = 5; + const BIND_PARAM_STR = 2; /** - * Text abstract data type + * Skip binding by type */ - const TYPE_TEXT = 6; + const BIND_SKIP = 1024; /** - * Float abstract data type + * Big integer abstract data type */ - const TYPE_FLOAT = 7; + const TYPE_BIGINTEGER = 14; /** - * Boolean abstract data type + * Bit abstract data type + */ + const TYPE_BIT = 19; + + /** + * Blob abstract data type + */ + const TYPE_BLOB = 11; + + /** + * Bool abstract data type */ const TYPE_BOOLEAN = 8; /** - * Double abstract data type + * Char abstract data type */ - const TYPE_DOUBLE = 9; + const TYPE_CHAR = 5; /** - * Tinyblob abstract data type + * Date abstract data type */ - const TYPE_TINYBLOB = 10; + const TYPE_DATE = 1; /** - * Blob abstract data type + * Datetime abstract data type */ - const TYPE_BLOB = 11; + const TYPE_DATETIME = 4; /** - * Mediumblob abstract data type + * Decimal abstract data type */ - const TYPE_MEDIUMBLOB = 12; + const TYPE_DECIMAL = 3; /** - * Longblob abstract data type + * Double abstract data type */ - const TYPE_LONGBLOB = 13; + const TYPE_DOUBLE = 9; /** - * Big integer abstract data type + * Enum abstract data type */ - const TYPE_BIGINTEGER = 14; + const TYPE_ENUM = 18; /** - * Json abstract type + * Float abstract data type + */ + const TYPE_FLOAT = 7; + + /** + * Int abstract data type + */ + const TYPE_INTEGER = 0; + + /** + * Json abstract data type */ const TYPE_JSON = 15; /** - * Jsonb abstract type + * Jsonb abstract data type */ const TYPE_JSONB = 16; /** - * Datetime abstract type + * Longblob abstract data type */ - const TYPE_TIMESTAMP = 17; + const TYPE_LONGBLOB = 13; /** - * Bind Type Null + * Longtext abstract data type */ - const BIND_PARAM_NULL = 0; + const TYPE_LONGTEXT = 24; /** - * Bind Type Integer + * Mediumblob abstract data type */ - const BIND_PARAM_INT = 1; + const TYPE_MEDIUMBLOB = 12; /** - * Bind Type String + * Mediumintegerr abstract data type */ - const BIND_PARAM_STR = 2; + const TYPE_MEDIUMINTEGER = 21; /** - * Bind Type Blob + * Mediumtext abstract data type */ - const BIND_PARAM_BLOB = 3; + const TYPE_MEDIUMTEXT = 23; /** - * Bind Type Bool + * Smallint abstract data type */ - const BIND_PARAM_BOOL = 5; + const TYPE_SMALLINTEGER = 22; /** - * Bind Type Decimal + * Text abstract data type */ - const BIND_PARAM_DECIMAL = 32; + const TYPE_TEXT = 6; /** - * Skip binding by type + * Time abstract data type */ - const BIND_SKIP = 1024; + const TYPE_TIME = 20; /** - * Column's name - * - * @var string + * Timestamp abstract data type */ - protected $_name; + const TYPE_TIMESTAMP = 17; /** - * Schema which table related is - * - * @var string + * Tinyblob abstract data type */ - protected $_schemaName; + const TYPE_TINYBLOB = 10; /** - * Column data type - * - * @var int|string + * Tinyint abstract data type */ - protected $_type; + const TYPE_TINYINTEGER = 26; /** - * Column data type reference - * - * @var int + * Tinytext abstract data type */ - protected $_typeReference = -1; + const TYPE_TINYTEXT = 25; /** - * Column data type values - * - * @var array|string + * Varchar abstract data type */ - protected $_typeValues; + const TYPE_VARCHAR = 2; /** - * The column have some numeric type? + * Column Position + * + * @var string */ - protected $_isNumeric = false; + protected $after; /** - * Integer column size + * Column is autoIncrement? * - * @var int + * @var bool */ - protected $_size = 0; + protected $autoIncrement = false; /** - * Integer column number scale - * - * @var int + * Bind Type */ - protected $_scale = 0; + protected $bindType = 2; /** * Default column value @@ -214,104 +222,125 @@ class Column implements \Phalcon\Db\ColumnInterface protected $_default = null; /** - * Integer column unsigned? + * Position is first + * + * @var bool + */ + protected $first = false; + + /** + * The column have some numeric type? + */ + protected $isNumeric = false; + + /** + * Column's name * - * @var boolean + * @var string */ - protected $_unsigned = false; + protected $name; /** * Column not nullable? * - * @var boolean + * @var bool */ - protected $_notNull = false; + protected $notNull = false; /** * Column is part of the primary key? */ - protected $_primary = false; + protected $primary = false; /** - * Column is autoIncrement? + * Integer column number scale * - * @var boolean + * @var int */ - protected $_autoIncrement = false; + protected $scale = 0; /** - * Position is first + * Integer column size * - * @var boolean + * @var int */ - protected $_first = false; + protected $size = 0; /** - * Column Position + * Column data type * - * @var string + * @var int */ - protected $_after; + protected $type; /** - * Bind Type + * Column data type reference + * + * @var int */ - protected $_bindType = 2; - + protected $typeReference = -1; /** - * Column's name + * Column data type values * - * @return string + * @var array|string */ - public function getName() {} + protected $typeValues; /** - * Schema which table related is + * Integer column unsigned? * - * @return string + * @var bool */ - public function getSchemaName() {} + protected $unsigned = false; + /** - * Column data type + * Default column value + */ + public function getDefault() {} + + /** + * Column's name * - * @return int|string + * @return string */ - public function getType() {} + public function getName(): string {} /** - * Column data type reference + * Integer column number scale * * @return int */ - public function getTypeReference() {} + public function getScale(): int {} /** - * Column data type values + * Integer column size * - * @return array|string + * @return int */ - public function getTypeValues() {} + public function getSize(): int {} /** - * Integer column size + * Column data type * * @return int */ - public function getSize() {} + public function getType(): int {} /** - * Integer column number scale + * Column data type reference * * @return int */ - public function getScale() {} + public function getTypeReference(): int {} /** - * Default column value + * Column data type values + * + * @return array|string */ - public function getDefault() {} + public function getTypeValues() {} /** * Phalcon\Db\Column constructor @@ -319,77 +348,69 @@ public function getDefault() {} * @param string $name * @param array $definition */ - public function __construct($name, array $definition) {} + public function __construct(string $name, array $definition) {} /** - * Returns true if number column is unsigned + * Check whether field absolute to position in table * - * @return bool + * @return string */ - public function isUnsigned() {} + public function getAfterPosition(): string {} /** - * Not null + * Returns the type of bind handling * - * @return bool + * @return int */ - public function isNotNull() {} + public function getBindType(): int {} /** - * Column is part of the primary key? + * Check whether column has default value * * @return bool */ - public function isPrimary() {} + public function hasDefault(): bool {} /** * Auto-Increment * * @return bool */ - public function isAutoIncrement() {} - - /** - * Check whether column have an numeric type - * - * @return bool - */ - public function isNumeric() {} + public function isAutoIncrement(): bool {} /** * Check whether column have first position in table * * @return bool */ - public function isFirst() {} + public function isFirst(): bool {} /** - * Check whether field absolute to position in table + * Not null * - * @return string + * @return bool */ - public function getAfterPosition() {} + public function isNotNull(): bool {} /** - * Returns the type of bind handling + * Check whether column have an numeric type * - * @return int + * @return bool */ - public function getBindType() {} + public function isNumeric(): bool {} /** - * Restores the internal state of a Phalcon\Db\Column object + * Column is part of the primary key? * - * @param array $data - * @return \Phalcon\Db\ColumnInterface + * @return bool */ - public static function __set_state(array $data) {} + public function isPrimary(): bool {} /** - * Check whether column has default value + * Returns true if number column is unsigned * * @return bool */ - public function hasDefault() {} + public function isUnsigned(): bool {} } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index dcf8d0c1..2fc8226d 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -3,138 +3,121 @@ namespace Phalcon\Db; /** - * Phalcon\Db\ColumnInterface - * * Interface for Phalcon\Db\Column */ interface ColumnInterface { /** - * Returns schema's table related to column + * Check whether field absolute to position in table * * @return string */ - public function getSchemaName(); + public function getAfterPosition(): string; /** - * Returns column name + * Returns the type of bind handling * - * @return string + * @return int */ - public function getName(); + public function getBindType(): int; /** - * Returns column type + * Returns default value of column * - * @return int + * @return mixed */ - public function getType(); + public function getDefault(); /** - * Returns column type reference + * Returns column name * - * @return int + * @return string */ - public function getTypeReference(); + public function getName(): string; /** - * Returns column type values + * Returns column scale * * @return int */ - public function getTypeValues(); + public function getScale(): int; /** * Returns column size * * @return int */ - public function getSize(); + public function getSize(): int; /** - * Returns column scale + * Returns column type * * @return int */ - public function getScale(); + public function getType(): int; /** - * Returns true if number column is unsigned + * Returns column type reference * - * @return boolean + * @return int */ - public function isUnsigned(); + public function getTypeReference(): int; /** - * Not null + * Returns column type values * - * @return boolean + * @return array|string */ - public function isNotNull(); + public function getTypeValues(); /** - * Column is part of the primary key? + * Check whether column has default value * - * @return boolean + * @return bool */ - public function isPrimary(); + public function hasDefault(): bool; /** * Auto-Increment * - * @return boolean - */ - public function isAutoIncrement(); - - /** - * Check whether column have an numeric type - * - * @return boolean + * @return bool */ - public function isNumeric(); + public function isAutoIncrement(): bool; /** * Check whether column have first position in table * - * @return boolean - */ - public function isFirst(); - - /** - * Check whether field absolute to position in table - * - * @return string + * @return bool */ - public function getAfterPosition(); + public function isFirst(): bool; /** - * Returns the type of bind handling + * Not null * - * @return int + * @return bool */ - public function getBindType(); + public function isNotNull(): bool; /** - * Returns default value of column + * Check whether column have an numeric type * - * @return int + * @return bool */ - public function getDefault(); + public function isNumeric(): bool; /** - * Check whether column has default value + * Column is part of the primary key? * * @return bool */ - public function hasDefault(); + public function isPrimary(): bool; /** - * Restores the internal state of a Phalcon\Db\Column object + * Returns true if number column is unsigned * - * @param array $data - * @return ColumnInterface + * @return bool */ - public static function __set_state(array $data); + public function isUnsigned(): bool; } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index d6021102..f72935c0 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -3,44 +3,25 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Dialect - * * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ abstract class Dialect implements \Phalcon\Db\DialectInterface { - protected $_escapeChar; + protected $escapeChar; - protected $_customFunctions; + protected $customFunctions; /** - * Registers custom SQL functions + * Generate SQL to create a new savepoint * * @param string $name - * @param callable $customFunction - * @return Dialect - */ - public function registerCustomFunction($name, $customFunction) {} - - /** - * Returns registered functions - * - * @return array - */ - public function getCustomFunctions() {} - - /** - * Escape Schema - * - * @param string $str - * @param string $escapeChar * @return string */ - public final function escapeSchema($str, $escapeChar = null) {} + public function createSavepoint(string $name): string {} /** * Escape identifiers @@ -49,56 +30,56 @@ public final function escapeSchema($str, $escapeChar = null) {} * @param string $escapeChar * @return string */ - public final function escape($str, $escapeChar = null) {} + final public function escape(string $str, string $escapeChar = null): string {} /** - * Generates the SQL for LIMIT clause - * - * - * $sql = $dialect->limit("SELECT FROM robots", 10); - * echo $sql; // SELECT FROM robots LIMIT 10 - * - * $sql = $dialect->limit("SELECT FROM robots", [10, 50]); - * echo $sql; // SELECT FROM robots LIMIT 10 OFFSET 50 - * + * Escape Schema * - * @param string $sqlQuery - * @param mixed $number + * @param string $str + * @param string $escapeChar * @return string */ - public function limit($sqlQuery, $number) {} + final public function escapeSchema(string $str, string $escapeChar = null): string {} /** * Returns a SQL modified with a FOR UPDATE clause * - * + * ```php * $sql = $dialect->forUpdate("SELECT FROM robots"); + * * echo $sql; // SELECT FROM robots FOR UPDATE - * + * ``` * * @param string $sqlQuery * @return string */ - public function forUpdate($sqlQuery) {} + public function forUpdate(string $sqlQuery): string {} /** * Gets a list of columns with escaped identifiers * - * + * ```php * echo $dialect->getColumnList( * [ * "column1", * "column", * ] * ); - * + * ``` * * @param array $columnList * @param string $escapeChar * @param mixed $bindCounts * @return string */ - public final function getColumnList(array $columnList, $escapeChar = null, $bindCounts = null) {} + final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string {} + + /** + * Returns registered functions + * + * @return array + */ + public function getCustomFunctions(): array {} /** * Resolve Column expressions @@ -108,7 +89,7 @@ public final function getColumnList(array $columnList, $escapeChar = null, $bind * @param mixed $bindCounts * @return string */ - public final function getSqlColumn($column, $escapeChar = null, $bindCounts = null) {} + final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string {} /** * Transforms an intermediate representation for an expression into a database system valid expression @@ -118,16 +99,65 @@ public final function getSqlColumn($column, $escapeChar = null, $bindCounts = nu * @param mixed $bindCounts * @return string */ - public function getSqlExpression(array $expression, $escapeChar = null, $bindCounts = null) {} + public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Transform an intermediate representation of a schema/table into a database system valid expression + * Transform an intermediate representation of a schema/table into a + * database system valid expression * * @param mixed $table * @param string $escapeChar * @return string */ - public final function getSqlTable($table, $escapeChar = null) {} + final public function getSqlTable($table, string $escapeChar = null): string {} + + /** + * Generates the SQL for LIMIT clause + * + * ```php + * // SELECT FROM robots LIMIT 10 + * echo $dialect->limit( + * "SELECT FROM robots", + * 10 + * ); + * + * // SELECT FROM robots LIMIT 10 OFFSET 50 + * echo $dialect->limit( + * "SELECT FROM robots", + * [10, 50] + * ); + * ``` + * + * @param string $sqlQuery + * @param mixed $number + * @return string + */ + public function limit(string $sqlQuery, $number): string {} + + /** + * Registers custom SQL functions + * + * @param string $name + * @param callable $customFunction + * @return Dialect + */ + public function registerCustomFunction(string $name, $customFunction): Dialect {} + + /** + * Generate SQL to release a savepoint + * + * @param string $name + * @return string + */ + public function releaseSavepoint(string $name): string {} + + /** + * Generate SQL to rollback a savepoint + * + * @param string $name + * @return string + */ + public function rollbackSavepoint(string $name): string {} /** * Builds a SELECT statement @@ -135,222 +165,230 @@ public final function getSqlTable($table, $escapeChar = null) {} * @param array $definition * @return string */ - public function select(array $definition) {} + public function select(array $definition): string {} /** * Checks whether the platform supports savepoints * * @return bool */ - public function supportsSavepoints() {} + public function supportsSavepoints(): bool {} /** * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsReleaseSavepoints() {} + public function supportsReleaseSavepoints(): bool {} /** - * Generate SQL to create a new savepoint + * Returns the size of the column enclosed in parentheses * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function createSavepoint($name) {} + protected function getColumnSize(ColumnInterface $column): string {} /** - * Generate SQL to release a savepoint + * Returns the column size and scale enclosed in parentheses * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function releaseSavepoint($name) {} + protected function getColumnSizeAndScale(ColumnInterface $column): string {} /** - * Generate SQL to rollback a savepoint + * Checks the column type and if not string it returns the type reference * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function rollbackSavepoint($name) {} + protected function checkColumnType(ColumnInterface $column): string {} /** - * Resolve Column expressions + * Checks the column type and returns the updated SQL statement * - * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param ColumnInterface $column * @return string */ - protected final function getSqlExpressionScalar(array $expression, $escapeChar = null, $bindCounts = null) {} + protected function checkColumnTypeSql(ColumnInterface $column): string {} /** - * Resolve object expressions + * Resolve * * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionObject(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionAll(array $expression, string $escapeChar = null): string {} /** - * Resolve qualified expressions + * Resolve binary operations expressions * * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionQualified(array $expression, $escapeChar = null) {} + final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve binary operations expressions + * Resolve CASE expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionBinaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve unary operations expressions + * Resolve CAST of values * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionUnaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve function calls + * Resolve CONVERT of values encodings * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionFunctionCall(array $expression, $escapeChar = null, $bindCounts) {} + final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve Lists + * Resolve a FROM clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionList(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionFrom($expression, string $escapeChar = null): string {} /** - * Resolve + * Resolve function calls * * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionAll(array $expression, $escapeChar = null) {} + final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string {} /** - * Resolve CAST of values + * Resolve a GROUP BY clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionCastValue(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve CONVERT of values encodings + * Resolve a HAVING clause * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionConvertValue(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve CASE expressions + * Resolve a JOINs clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionCase(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a FROM clause + * Resolve a LIMIT clause * * @param mixed $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionFrom($expression, $escapeChar = null) {} + final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a JOINs clause + * Resolve Lists * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionJoins($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a WHERE clause + * Resolve object expressions * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionWhere($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a GROUP BY clause + * Resolve an ORDER BY clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionGroupBy($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a HAVING clause + * Resolve qualified expressions + * + * @param array $expression + * @param string $escapeChar + * @return string + */ + final protected function getSqlExpressionQualified(array $expression, string $escapeChar = null): string {} + + /** + * Resolve Column expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionHaving(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve an ORDER BY clause + * Resolve unary operations expressions * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionOrderBy($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a LIMIT clause + * Resolve a WHERE clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionLimit($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string {} /** * Prepares column for this RDBMS @@ -360,7 +398,7 @@ protected final function getSqlExpressionLimit($expression, $escapeChar = null, * @param string $escapeChar * @return string */ - protected function prepareColumnAlias($qualified, $alias = null, $escapeChar = null) {} + protected function prepareColumnAlias(string $qualified, string $alias = null, string $escapeChar = null): string {} /** * Prepares table for this RDBMS @@ -371,7 +409,7 @@ protected function prepareColumnAlias($qualified, $alias = null, $escapeChar = n * @param string $escapeChar * @return string */ - protected function prepareTable($table, $schema = null, $alias = null, $escapeChar = null) {} + protected function prepareTable(string $table, string $schema = null, string $alias = null, string $escapeChar = null): string {} /** * Prepares qualified for this RDBMS @@ -381,6 +419,6 @@ protected function prepareTable($table, $schema = null, $alias = null, $escapeCh * @param string $escapeChar * @return string */ - protected function prepareQualified($column, $domain = null, $escapeChar = null) {} + protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string {} } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 5345aabd..0e8e587d 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -3,82 +3,105 @@ namespace Phalcon\Db; /** - * Phalcon\Db\DialectInterface - * * Interface for Phalcon\Db dialects */ interface DialectInterface { /** - * Generates the SQL for LIMIT clause + * Generates SQL to add a column to a table * - * @param string $sqlQuery - * @param mixed $number + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function limit($sqlQuery, $number); + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string; /** - * Returns a SQL modified with a FOR UPDATE clause + * Generates SQL to add an index to a table * - * @param string $sqlQuery + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function forUpdate($sqlQuery); + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string; /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Generates SQL to add an index to a table * - * @param string $sqlQuery + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function sharedLock($sqlQuery); + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; /** - * Builds a SELECT statement + * Generates SQL to add the primary key to a table * - * @param array $definition + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function select(array $definition); + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; /** - * Gets a list of columns + * Generate SQL to create a new savepoint * - * @param array $columnList + * @param string $name * @return string */ - public function getColumnList(array $columnList); + public function createSavepoint(string $name): string; /** - * Gets the column name in RDBMS + * Generates SQL to create a table * - * @param \Phalcon\Db\ColumnInterface $column + * @param string $tableName + * @param string $schemaName + * @param array $definition * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column); + public function createTable(string $tableName, string $schemaName, array $definition): string; /** - * Generates SQL to add a column to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column); + public function createView(string $viewName, array $definition, string $schemaName = null): string; /** - * Generates SQL to modify a column in a table + * Generates SQL to describe a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param string $table + * @param string $schema * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null); + public function describeColumns(string $table, string $schema = null): string; + + /** + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string; + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string; /** * Generates SQL to delete a column from a table @@ -88,17 +111,17 @@ public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterfac * @param string $columnName * @return string */ - public function dropColumn($tableName, $schemaName, $columnName); + public function dropColumn(string $tableName, string $schemaName, string $columnName): string; /** - * Generates SQL to add an index to a table + * Generates SQL to delete a foreign key from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $referenceName * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string; /** * Generates SQL to delete an index from a table @@ -108,183 +131,186 @@ public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $in * @param string $indexName * @return string */ - public function dropIndex($tableName, $schemaName, $indexName); + public function dropIndex(string $tableName, string $schemaName, string $indexName): string; /** - * Generates SQL to add the primary key to a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); + public function dropPrimaryKey(string $tableName, string $schemaName): string; /** - * Generates SQL to delete primary key from a table + * Generates SQL to drop a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropPrimaryKey($tableName, $schemaName); + public function dropTable(string $tableName, string $schemaName): string; /** - * Generates SQL to add an index to a table + * Generates SQL to drop a view * - * @param string $tableName + * @param string $viewName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param bool $ifExists * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference); + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string; /** - * Generates SQL to delete a foreign key from a table + * Returns a SQL modified with a FOR UPDATE clause * - * @param string $tableName - * @param string $schemaName - * @param string $referenceName + * @param string $sqlQuery * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName); + public function forUpdate(string $sqlQuery): string; /** - * Generates SQL to create a table + * Gets the column name in RDBMS * - * @param string $tableName - * @param string $schemaName - * @param array $definition + * @param \Phalcon\Db\ColumnInterface $column + * @return string */ - public function createTable($tableName, $schemaName, array $definition); + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; /** - * Generates SQL to create a view + * Gets a list of columns * - * @param string $viewName - * @param array $definition - * @param string $schemaName + * @param array $columnList * @return string */ - public function createView($viewName, array $definition, $schemaName = null); + public function getColumnList(array $columnList): string; /** - * Generates SQL to drop a table + * Returns registered functions * - * @param string $tableName - * @param string $schemaName + * @return array + */ + public function getCustomFunctions(): array; + + /** + * Transforms an intermediate representation for an expression into a + * database system valid expression + * + * @param array $expression + * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - public function dropTable($tableName, $schemaName); + public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string; /** - * Generates SQL to drop a view + * Generates the SQL for LIMIT clause * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param string $sqlQuery + * @param mixed $number * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true); + public function limit(string $sqlQuery, $number): string; /** - * Generates SQL checking for the existence of a schema.table + * List all tables in database * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null); + public function listTables(string $schemaName = null): string; /** - * Generates SQL checking for the existence of a schema.view + * Generates SQL to modify a column in a table * - * @param string $viewName + * @param string $tableName * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function viewExists($viewName, $schemaName = null); + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string; /** - * Generates SQL to describe a table + * Registers custom SQL functions * - * @param string $table - * @param string $schema - * @return string + * @param string $name + * @param callable $customFunction + * @return Dialect */ - public function describeColumns($table, $schema = null); + public function registerCustomFunction(string $name, $customFunction): Dialect; /** - * List all tables in database + * Generate SQL to release a savepoint * - * @param string $schemaName + * @param string $name * @return string */ - public function listTables($schemaName = null); + public function releaseSavepoint(string $name): string; /** - * Generates SQL to query indexes on a table + * Generate SQL to rollback a savepoint * - * @param string $table - * @param string $schema + * @param string $name * @return string */ - public function describeIndexes($table, $schema = null); + public function rollbackSavepoint(string $name): string; /** - * Generates SQL to query foreign keys on a table + * Builds a SELECT statement * - * @param string $table - * @param string $schema + * @param array $definition * @return string */ - public function describeReferences($table, $schema = null); + public function select(array $definition): string; /** - * Generates the SQL to describe the table creation options + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $table - * @param string $schema + * @param string $sqlQuery * @return string */ - public function tableOptions($table, $schema = null); + public function sharedLock(string $sqlQuery): string; /** - * Checks whether the platform supports savepoints + * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsSavepoints(); + public function supportsReleaseSavepoints(): bool; /** - * Checks whether the platform supports releasing savepoints. + * Checks whether the platform supports savepoints * * @return bool */ - public function supportsReleaseSavepoints(); + public function supportsSavepoints(): bool; /** - * Generate SQL to create a new savepoint + * Generates SQL checking for the existence of a schema.table * - * @param string $name + * @param string $tableName + * @param string $schemaName * @return string */ - public function createSavepoint($name); + public function tableExists(string $tableName, string $schemaName = null): string; /** - * Generate SQL to release a savepoint + * Generates the SQL to describe the table creation options * - * @param string $name + * @param string $table + * @param string $schema * @return string */ - public function releaseSavepoint($name); + public function tableOptions(string $table, string $schema = null): string; /** - * Generate SQL to rollback a savepoint + * Generates SQL checking for the existence of a schema.view * - * @param string $name + * @param string $viewName + * @param string $schemaName * @return string */ - public function rollbackSavepoint($name); + public function viewExists(string $viewName, string $schemaName = null): string; } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php new file mode 100644 index 00000000..3049c8f7 --- /dev/null +++ b/src/Phalcon/db/Enum.php @@ -0,0 +1,62 @@ + + * ```php * // Define new unique index * $index_unique = new \Phalcon\Db\Index( * 'column_UNIQUE', * [ * 'column', - * 'column' + * 'column', * ], * 'UNIQUE' * ); @@ -24,75 +22,67 @@ * $index_primary = new \Phalcon\Db\Index( * 'PRIMARY', * [ - * 'column' + * 'column', * ] * ); * * // Add index to existing table * $connection->addIndex("robots", null, $index_unique); * $connection->addIndex("robots", null, $index_primary); - * + * ``` */ class Index implements \Phalcon\Db\IndexInterface { /** - * Index name + * Index columns * - * @var string + * @var array */ - protected $_name; + protected $columns; /** - * Index columns + * Index name * - * @var array + * @var string */ - protected $_columns; + protected $name; /** * Index type * * @var string */ - protected $_type; + protected $type; /** - * Index name + * Index columns * - * @return string + * @return array */ - public function getName() {} + public function getColumns(): array {} /** - * Index columns + * Index name * - * @return array + * @return string */ - public function getColumns() {} + public function getName(): string {} /** * Index type * * @return string */ - public function getType() {} + public function getType(): string {} /** * Phalcon\Db\Index constructor * * @param string $name * @param array $columns - * @param mixed $type - */ - public function __construct($name, array $columns, $type = null) {} - - /** - * Restore a Phalcon\Db\Index object from export - * - * @param array $data - * @return IndexInterface + * @param string $type */ - public static function __set_state(array $data) {} + public function __construct(string $name, array $columns, string $type = '') {} } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index 46e8eea8..036ed333 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -3,40 +3,30 @@ namespace Phalcon\Db; /** - * Phalcon\Db\IndexInterface - * * Interface for Phalcon\Db\Index */ interface IndexInterface { - /** - * Gets the index name - * - * @return string - */ - public function getName(); - /** * Gets the columns that corresponds the index * * @return array */ - public function getColumns(); + public function getColumns(): array; /** - * Gets the index type + * Gets the index name * * @return string */ - public function getType(); + public function getName(): string; /** - * Restore a Phalcon\Db\Index object from export + * Gets the index type * - * @param array $data - * @return IndexInterface + * @return string */ - public static function __set_state(array $data); + public function getType(): string; } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index 17e3ecad..c0e49136 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -3,14 +3,12 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Profiler - * * Instances of Phalcon\Db can generate execution profiles * on SQL statements sent to the relational database. Profiled * information includes execution time in milliseconds. * This helps you to identify bottlenecks in your applications. * - * + * ```php * use Phalcon\Db\Profiler; * use Phalcon\Events\Event; * use Phalcon\Events\Manager; @@ -52,82 +50,82 @@ * echo "Start Time: ", $profile->getInitialTime(), "\n"; * echo "Final Time: ", $profile->getFinalTime(), "\n"; * echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n"; - * + * ``` */ class Profiler { /** - * All the Phalcon\Db\Profiler\Item in the active profile + * Active Phalcon\Db\Profiler\Item * - * @var \Phalcon\Db\Profiler\Item[] + * @var Phalcon\Db\Profiler\Item */ - protected $_allProfiles; + protected $activeProfile; /** - * Active Phalcon\Db\Profiler\Item + * All the Phalcon\Db\Profiler\Item in the active profile * - * @var Phalcon\Db\Profiler\Item + * @var \Phalcon\Db\Profiler\Item[] */ - protected $_activeProfile; + protected $allProfiles; /** * Total time spent by all profiles to complete * * @var float */ - protected $_totalSeconds = 0; + protected $totalSeconds = 0; /** - * Starts the profile of a SQL sentence - * - * @param string $sqlStatement - * @param mixed $sqlVariables - * @param mixed $sqlBindTypes - * @return Profiler - */ - public function startProfile($sqlStatement, $sqlVariables = null, $sqlBindTypes = null) {} - - /** - * Stops the active profile + * Returns the last profile executed in the profiler * - * @return Profiler + * @return \Phalcon\Db\Profiler\Item */ - public function stopProfile() {} + public function getLastProfile(): Item {} /** * Returns the total number of SQL statements processed * * @return int */ - public function getNumberTotalStatements() {} + public function getNumberTotalStatements(): int {} /** * Returns the total time in seconds spent by the profiles * * @return double */ - public function getTotalElapsedSeconds() {} + public function getTotalElapsedSeconds(): float {} /** * Returns all the processed profiles * - * @return \Phalcon\Db\Profiler\Item[] + * @return array|\Phalcon\Db\Profiler\Item[] */ - public function getProfiles() {} + public function getProfiles(): array {} /** * Resets the profiler, cleaning up all the profiles * * @return Profiler */ - public function reset() {} + public function reset(): Profiler {} /** - * Returns the last profile executed in the profiler + * Starts the profile of a SQL sentence * - * @return \Phalcon\Db\Profiler\Item + * @param string $sqlStatement + * @param mixed $sqlVariables + * @param mixed $sqlBindTypes + * @return Profiler + */ + public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBindTypes = null): Profiler {} + + /** + * Stops the active profile + * + * @return Profiler */ - public function getLastProfile() {} + public function stopProfile(): Profiler {} } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index 84723bd0..e4f65201 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -3,20 +3,18 @@ namespace Phalcon\Db; /** - * Phalcon\Db\RawValue - * * This class allows to insert/update raw data without quoting or formatting. * * The next example shows how to use the MySQL now() function as a field value. * - * + * ```php * $subscriber = new Subscribers(); * * $subscriber->email = "andres@phalconphp.com"; * $subscriber->createdAt = new \Phalcon\Db\RawValue("now()"); * * $subscriber->save(); - * + * ``` */ class RawValue { @@ -25,7 +23,7 @@ class RawValue * * @var string */ - protected $_value; + protected $value; /** @@ -33,14 +31,14 @@ class RawValue * * @return string */ - public function getValue() {} + public function getValue(): string {} /** * Raw value without quoting or formatting * * @return string */ - public function __toString() {} + public function __toString(): string {} /** * Phalcon\Db\RawValue constructor diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index c9874b1a..43eb5a35 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -3,18 +3,16 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Reference - * * Allows to define reference constraints on tables * - * + * ```php * $reference = new \Phalcon\Db\Reference( * "field_fk", * [ * "referencedSchema" => "invoicing", * "referencedTable" => "products", * "columns" => [ - * "product_type", + * "producttype", * "product_code", * ], * "referencedColumns" => [ @@ -23,106 +21,122 @@ * ], * ] * ); - * + * ``` */ class Reference implements \Phalcon\Db\ReferenceInterface { + /** + * Local reference columns + * + * @var array + */ + protected $columns; + /** * Constraint name * * @var string */ - protected $_name; - + protected $name; - protected $_schemaName; - - - protected $_referencedSchema; + /** + * Referenced Columns + * + * @var array + */ + protected $referencedColumns; /** - * Referenced Table + * Referenced Schema * * @var string */ - protected $_referencedTable; + protected $referencedSchema; /** - * Local reference columns + * Referenced Table * - * @var array + * @var string */ - protected $_columns; + protected $referencedTable; /** - * Referenced Columns + * Schema name * - * @var array + * @var string */ - protected $_referencedColumns; + protected $schemaName; /** * ON DELETE * - * @var array + * @var string */ - protected $_onDelete; + protected $onDelete; /** * ON UPDATE * - * @var array + * @var string */ - protected $_onUpdate; + protected $onUpdate; + /** + * Local reference columns + * + * @return array + */ + public function getColumns(): array {} + /** * Constraint name * * @return string */ - public function getName() {} - - - public function getSchemaName() {} - + public function getName(): string {} - public function getReferencedSchema() {} + /** + * Referenced Columns + * + * @return array + */ + public function getReferencedColumns(): array {} /** - * Referenced Table + * Referenced Schema * * @return string */ - public function getReferencedTable() {} + public function getReferencedSchema(): string {} /** - * Local reference columns + * Referenced Table * - * @return array + * @return string */ - public function getColumns() {} + public function getReferencedTable(): string {} /** - * Referenced Columns + * Schema name * - * @return array + * @return string */ - public function getReferencedColumns() {} + public function getSchemaName(): string {} /** * ON DELETE * - * @return array + * @return string */ - public function getOnDelete() {} + public function getOnDelete(): string {} /** * ON UPDATE * - * @return array + * @return string */ - public function getOnUpdate() {} + public function getOnUpdate(): string {} /** * Phalcon\Db\Reference constructor @@ -130,14 +144,6 @@ public function getOnUpdate() {} * @param string $name * @param array $definition */ - public function __construct($name, array $definition) {} - - /** - * Restore a Phalcon\Db\Reference object from export - * - * @param array $data - * @return ReferenceInterface - */ - public static function __set_state(array $data) {} + public function __construct(string $name, array $definition) {} } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 735af8e1..738157ac 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -3,75 +3,65 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Reference - * * Interface for Phalcon\Db\Reference */ interface ReferenceInterface { /** - * Gets the index name + * Gets local columns which reference is based * - * @return string + * @return array */ - public function getName(); + public function getColumns(): array; /** - * Gets the schema where referenced table is + * Gets the index name * * @return string */ - public function getSchemaName(); + public function getName(): string; /** - * Gets the schema where referenced table is + * Gets the referenced on delete * * @return string */ - public function getReferencedSchema(); - - /** - * Gets local columns which reference is based - * - * @return array - */ - public function getColumns(); + public function getOnDelete(): string; /** - * Gets the referenced table + * Gets the referenced on update * * @return string */ - public function getReferencedTable(); + public function getOnUpdate(): string; /** * Gets referenced columns * * @return array */ - public function getReferencedColumns(); + public function getReferencedColumns(): array; /** - * Gets the referenced on delete + * Gets the schema where referenced table is * * @return string */ - public function getOnDelete(); + public function getReferencedSchema(): string; /** - * Gets the referenced on update + * Gets the referenced table * * @return string */ - public function getOnUpdate(); + public function getReferencedTable(): string; /** - * Restore a Phalcon\Db\Reference object from export + * Gets the schema where referenced table is * - * @param array $data - * @return ReferenceInterface + * @return string */ - public static function __set_state(array $data); + public function getSchemaName(): string; } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index 368397cc..a6baa4b2 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -3,74 +3,75 @@ namespace Phalcon\Db; /** - * Phalcon\Db\ResultInterface - * * Interface for Phalcon\Db\Result objects */ interface ResultInterface { /** - * Allows to executes the statement again. Some database systems don't support scrollable cursors, - * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining + * Moves internal resultset cursor to another position letting us to fetch a + * certain row * - * @return boolean + * @param long $number */ - public function execute(); + public function dataSeek(int $number); /** - * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Allows to executes the statement again. Some database systems don't + * support scrollable cursors. So, as cursors are forward only, we need to + * execute the cursor again to fetch rows from the begining * - * @return mixed + * @return bool */ - public function fetch(); + public function execute(): bool; /** - * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Fetches an array/object of strings that corresponds to the fetched row, + * or FALSE if there are no more rows. This method is affected by the active + * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * * @return mixed */ - public function fetchArray(); + public function fetch(); /** - * Returns an array of arrays containing all the records in the result - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Returns an array of arrays containing all the records in the result. This + * method is affected by the active fetch flag set using + * `Phalcon\Db\Result\Pdo::setFetchMode()` * * @return array */ - public function fetchAll(); + public function fetchAll(): array; /** - * Gets number of rows returned by a resultset + * Returns an array of strings that corresponds to the fetched row, or FALSE + * if there are no more rows. This method is affected by the active fetch + * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * @return int + * @return mixed */ - public function numRows(); + public function fetchArray(); /** - * Moves internal resultset cursor to another position letting us to fetch a certain row + * Gets the internal PDO result object * - * @param int $number + * @return \PDOStatement */ - public function dataSeek($number); + public function getInternalResult(): \PDOStatement; /** - * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() + * Gets number of rows returned by a resultset * - * @param int $fetchMode - * @param mixed $colNoOrClassNameOrObject - * @param mixed $ctorargs - * @return bool + * @return int */ - public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null); + public function numRows(): int; /** - * Gets the internal PDO result object + * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * @return \PDOStatement + * @param int $fetchMode + * @return bool */ - public function getInternalResult(); + public function setFetchMode(int $fetchMode): bool; } diff --git a/src/Phalcon/db/Adapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php similarity index 68% rename from src/Phalcon/db/Adapter.php rename to src/Phalcon/db/adapter/AbstractAdapter.php index 2de182e2..e6cbc176 100644 --- a/src/Phalcon/db/Adapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -1,101 +1,107 @@ - * // Getting first robot - * $robot = $connection->fetchOne("SELECT FROM robots"); - * print_r($robot); + * @param string $name + * @return bool + */ + public function createSavepoint(string $name): bool {} + + /** + * Creates a table * - * // Getting first robot with associative indexes only - * $robot = $connection->fetchOne("SELECT FROM robots", \Phalcon\Db::FETCH_ASSOC); - * print_r($robot); - * + * @param string $tableName + * @param string $schemaName + * @param array $definition + * @return bool + */ + public function createTable(string $tableName, string $schemaName, array $definition): bool {} + + /** + * Creates a view * - * @param string $sqlQuery - * @param mixed $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes - * @return array + * @param string $viewName + * @param array $definition + * @param string $schemaName + * @return bool + */ + public function createView(string $viewName, array $definition, string $schemaName = null): bool {} + + /** + * Deletes data from a table using custom RBDM SQL syntax + * + * ```php + * // Deleting existing robot + * $success = $connection->delete( + * "robots", + * "id = 101" + * ); + * + * // Next SQL sentence is generated + * DELETE FROM `robots` WHERE `id` = 101 + * ``` + * + * @param mixed $table + * @param mixed $whereCondition + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool + */ + public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool {} + + /** + * Lists table indexes + * + * ```php + * print_r( + * $connection->describeIndexes("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\IndexInterface[] */ - public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} + public function describeIndexes(string $table, string $schema = null): array {} + + /** + * Lists table references + * + * ```php + * print_r( + * $connection->describeReferences("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ReferenceInterface[] + */ + public function describeReferences(string $table, string $schema = null): array {} + + /** + * Drops a column from a table + * + * @param string $tableName + * @param string $schemaName + * @param string $columnName + * @return bool + */ + public function dropColumn(string $tableName, string $schemaName, string $columnName): bool {} + + /** + * Drops a foreign key from a table + * + * @param string $tableName + * @param string $schemaName + * @param string $referenceName + * @return bool + */ + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): bool {} + + /** + * Drop an index from a table + * + * @param string $tableName + * @param string $schemaName + * @param mixed $indexName + * @return bool + */ + public function dropIndex(string $tableName, string $schemaName, $indexName): bool {} + + /** + * Drops a table's primary key + * + * @param string $tableName + * @param string $schemaName + * @return bool + */ + public function dropPrimaryKey(string $tableName, string $schemaName): bool {} + + /** + * Drops a table from a schema/database + * + * @param string $tableName + * @param string $schemaName + * @param bool $ifExists + * @return bool + */ + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): bool {} + + /** + * Drops a view + * + * @param string $viewName + * @param string $schemaName + * @param bool $ifExists + * @return bool + */ + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): bool {} + + /** + * Escapes a column/table/schema name + * + * ```php + * $escapedTable = $connection->escapeIdentifier( + * "robots" + * ); + * + * $escapedTable = $connection->escapeIdentifier( + * [ + * "store", + * "robots", + * ] + * ); + * ``` + * + * @param mixed $identifier + * @return string + */ + public function escapeIdentifier($identifier): string {} /** * Dumps the complete result of a query into an array * - * + * ```php * // Getting all robots with associative indexes only * $robots = $connection->fetchAll( * "SELECT FROM robots", - * \Phalcon\Db::FETCH_ASSOC + * \Phalcon\Db\Enum::FETCH_ASSOC * ); * * foreach ($robots as $robot) { @@ -170,7 +327,7 @@ public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * // Getting all robots that contains word "robot" withing the name * $robots = $connection->fetchAll( * "SELECT FROM robots WHERE name LIKE :name", - * \Phalcon\Db::FETCH_ASSOC, + * \Phalcon\Db\Enum::FETCH_ASSOC, * [ * "name" => "%robot%", * ] @@ -178,20 +335,20 @@ public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * foreach($robots as $robot) { * print_r($robot); * } - * + * ``` * * @param string $sqlQuery * @param int $fetchMode - * @param array $bindParams - * @param array $bindTypes + * @param mixed $bindParams + * @param mixed $bindTypes * @return array */ - public function fetchAll($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} + public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} /** * Returns the n'th field of first row in a SQL query result * - * + * ```php * // Getting count of robots * $robotsCount = $connection->fetchColumn("SELECT count() FROM robots"); * print_r($robotsCount); @@ -202,603 +359,446 @@ public function fetchAll($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * 1 * ); * print_r($robot); - * + * ``` * * @param string $sqlQuery * @param array $placeholders - * @param int|string $column + * @param mixed $column * @return string|bool */ - public function fetchColumn($sqlQuery, $placeholders = null, $column = 0) {} + public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) {} /** - * Inserts data into a table using custom RDBMS SQL syntax + * Returns the first row in a SQL query result * - * - * // Inserting a new robot - * $success = $connection->insert( - * "robots", - * ["Astro Boy", 1952], - * ["name", "year"] - * ); + * ```php + * // Getting first robot + * $robot = $connection->fetchOne("SELECT FROM robots"); + * print_r($robot); * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * + * // Getting first robot with associative indexes only + * $robot = $connection->fetchOne( + * "SELECT FROM robots", + * \Phalcon\Db\Enum::FETCH_ASSOC + * ); + * print_r($robot); + * ``` * - * @param string|array $table - * @param array $values - * @param mixed $fields - * @param mixed $dataTypes - * @param $array dataTypes - * @return bool + * @param string $sqlQuery + * @param mixed $fetchMode + * @param mixed $bindParams + * @param mixed $bindTypes + * @return array */ - public function insert($table, array $values, $fields = null, $dataTypes = null) {} + public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} /** - * Inserts data into a table using custom RBDM SQL syntax - * - * - * // Inserting a new robot - * $success = $connection->insertAsDict( - * "robots", - * [ - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); + * Returns a SQL modified with a FOR UPDATE clause * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * + * @param string $sqlQuery + * @return string + */ + public function forUpdate(string $sqlQuery): string {} + + /** + * Returns the SQL column definition from a column * - * @param mixed $table - * @param mixed $data - * @param mixed $dataTypes - * @param $string table - * @param $array dataTypes - * @return bool + * @param \Phalcon\Db\ColumnInterface $column + * @return string */ - public function insertAsDict($table, $data, $dataTypes = null) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Updates data on a table using custom RBDM SQL syntax + * Gets a list of columns * - * - * // Updating existing robot - * $success = $connection->update( - * "robots", - * ["name"], - * ["New Astro Boy"], - * "id = 101" - * ); + * @param mixed $columnList + * @return string + */ + public function getColumnList($columnList): string {} + + /** + * Gets the active connection unique identifier * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * @return string + */ + public function getConnectionId(): string {} + + /** + * Returns the default identity value to be inserted in an identity column * - * // Updating existing robot with array condition and $dataTypes - * $success = $connection->update( + * ```php + * // Inserting a new robot with a valid default value for the column 'id' + * $success = $connection->insert( * "robots", - * ["name"], - * ["New Astro Boy"], * [ - * "conditions" => "id = ?", - * "bind" => [$some_unsafe_id], - * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param + * $connection->getDefaultIdValue(), + * "Astro Boy", + * 1952, * ], * [ - * PDO::PARAM_STR + * "id", + * "name", + * "year", * ] * ); + * ``` * - * - * - * Warning! If $whereCondition is string it not escaped. - * - * @param string|array $table - * @param mixed $fields - * @param mixed $values - * @param mixed $whereCondition - * @param mixed $dataTypes - * @param $array dataTypes - * @param $string|array whereCondition - * @return bool + * @return \Phalcon\Db\RawValue */ - public function update($table, $fields, $values, $whereCondition = null, $dataTypes = null) {} + public function getDefaultIdValue(): RawValue {} /** - * Updates data on a table using custom RBDM SQL syntax - * Another, more convenient syntax + * Returns the default value to make the RBDM use the default value declared + * in the table definition * - * - * // Updating existing robot - * $success = $connection->updateAsDict( + * ```php + * // Inserting a new robot with a valid default value for the column 'year' + * $success = $connection->insert( * "robots", * [ - * "name" => "New Astro Boy", + * "Astro Boy", + * $connection->getDefaultValue() * ], - * "id = 101" + * [ + * "name", + * "year", + * ] * ); + * ``` * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 - * - * - * @param mixed $table - * @param mixed $data - * @param mixed $whereCondition - * @param mixed $dataTypes - * @param $string whereCondition - * @param $array dataTypes - * @return bool + * @return \Phalcon\Db\RawValue */ - public function updateAsDict($table, $data, $whereCondition = null, $dataTypes = null) {} + public function getDefaultValue(): RawValue {} /** - * Deletes data from a table using custom RBDM SQL syntax - * - * - * // Deleting existing robot - * $success = $connection->delete( - * "robots", - * "id = 101" - * ); - * - * // Next SQL sentence is generated - * DELETE FROM `robots` WHERE `id` = 101 - * + * Return descriptor used to connect to the active database * - * @param string|array $table - * @param string $whereCondition - * @param array $placeholders - * @param array $dataTypes - * @return bool + * @return array */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null) {} + public function getDescriptor(): array {} /** - * Escapes a column/table/schema name - * - * - * $escapedTable = $connection->escapeIdentifier( - * "robots" - * ); - * - * $escapedTable = $connection->escapeIdentifier( - * [ - * "store", - * "robots", - * ] - * ); - * + * Returns internal dialect instance * - * @param array|string $identifier - * @return string + * @return DialectInterface */ - public function escapeIdentifier($identifier) {} + public function getDialect(): DialectInterface {} /** - * Gets a list of columns + * Returns the internal event manager * - * @param array columnList - * @return string - * @param mixed $columnList - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getColumnList($columnList) {} + public function getEventsManager(): ManagerInterface {} /** - * Appends a LIMIT clause to $sqlQuery argument - * - * - * echo $connection->limit("SELECT FROM robots", 5); - * + * Returns the savepoint name to use for nested transactions * - * @param string $sqlQuery - * @param int $number * @return string */ - public function limit($sqlQuery, $number) {} + public function getNestedTransactionSavepointName(): string {} /** - * Generates SQL checking for the existence of a schema.table - * - * - * var_dump( - * $connection->tableExists("blog", "posts") - * ); - * + * Active SQL statement in the object without replace bound parameters * - * @param string $tableName - * @param string $schemaName - * @return bool + * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function getRealSQLStatement(): string {} /** - * Generates SQL checking for the existence of a schema.view - * - * - * var_dump( - * $connection->viewExists("active_users", "posts") - * ); - * + * Active SQL statement in the object * - * @param string $viewName - * @param string $schemaName - * @return bool + * @return array */ - public function viewExists($viewName, $schemaName = null) {} + public function getSQLBindTypes(): array {} /** - * Returns a SQL modified with a FOR UPDATE clause + * Active SQL statement in the object * - * @param string $sqlQuery * @return string */ - public function forUpdate($sqlQuery) {} + public function getSQLStatement(): string {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Inserts data into a table using custom RDBMS SQL syntax * - * @param string $sqlQuery - * @return string - */ - public function sharedLock($sqlQuery) {} - - /** - * Creates a table + * ```php + * // Inserting a new robot + * $success = $connection->insert( + * "robots", + * ["Astro Boy", 1952], + * ["name", "year"] + * ); * - * @param string $tableName - * @param string $schemaName - * @param array $definition - * @return bool - */ - public function createTable($tableName, $schemaName, array $definition) {} - - /** - * Drops a table from a schema/database + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` * - * @param string $tableName - * @param string $schemaName - * @param bool $ifExists + * @param string $table + * @param array $values + * @param mixed $fields + * @param mixed $dataTypes * @return bool */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool {} /** - * Creates a view + * Inserts data into a table using custom RBDM SQL syntax * - * @param string $viewName - * @param array $definition - * @param string $schemaName - * @return bool - */ - public function createView($viewName, array $definition, $schemaName = null) {} - - /** - * Drops a view + * ```php + * // Inserting a new robot + * $success = $connection->insertAsDict( + * "robots", + * [ + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists - * @return bool - */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} - - /** - * Adds a column to a table + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param string $table + * @param mixed $data + * @param mixed $dataTypes * @return bool */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function insertAsDict(string $table, $data, $dataTypes = null): bool {} /** - * Modifies a table column based on a definition + * Returns if nested transactions should use savepoints * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function isNestedTransactionsWithSavepoints(): bool {} /** - * Drops a column from a table + * Appends a LIMIT clause to $sqlQuery argument * - * @param string $tableName - * @param string $schemaName - * @param string $columnName - * @return bool + * ```php + * echo $connection->limit("SELECT FROM robots", 5); + * ``` + * + * @param string $sqlQuery + * @param int $number + * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function limit(string $sqlQuery, int $number): string {} /** - * Adds an index to a table + * List all tables on a database + * + * ```php + * print_r( + * $connection->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName - * @param IndexInterface $index - * @return bool + * @return array */ - public function addIndex($tableName, $schemaName, IndexInterface $index) {} + public function listTables(string $schemaName = null): array {} /** - * Drop an index from a table + * List all views on a database + * + * ```php + * print_r( + * $connection->listViews("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName - * @param mixed $indexName - * @return bool + * @return array */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function listViews(string $schemaName = null): array {} /** - * Adds a primary key to a table + * Modifies a table column based on a definition * * @param string $tableName * @param string $schemaName - * @param IndexInterface $index + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function addPrimaryKey($tableName, $schemaName, IndexInterface $index) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} /** - * Drops a table's primary key + * Releases given savepoint * - * @param string $tableName - * @param string $schemaName + * @param string $name * @return bool */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function releaseSavepoint(string $name): bool {} /** - * Adds a foreign key to a table + * Rollbacks given savepoint * - * @param string $tableName - * @param string $schemaName - * @param ReferenceInterface $reference + * @param string $name * @return bool */ - public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference) {} + public function rollbackSavepoint(string $name): bool {} /** - * Drops a foreign key from a table + * Sets the event manager * - * @param string $tableName - * @param string $schemaName - * @param string $referenceName - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns the SQL column definition from a column + * Sets the dialect used to produce the SQL * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @param DialectInterface $dialect */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + public function setDialect(DialectInterface $dialect) {} /** - * List all tables on a database - * - * - * print_r( - * $connection->listTables("blog") - * ); - * + * Set if nested transactions should use savepoints * - * @param string $schemaName - * @return array + * @param bool $nestedTransactionsWithSavepoints + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function listTables($schemaName = null) {} + public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface {} /** - * List all views on a database - * - * - * print_r( - * $connection->listViews("blog") - * ); - * + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $schemaName - * @return array + * @param string $sqlQuery + * @return string */ - public function listViews($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Lists table indexes + * Check whether the database system requires a sequence to produce + * auto-numeric values * - * - * print_r( - * $connection->describeIndexes("robots_parts") - * ); - * - * - * @param string table - * @param string schema - * @return Phalcon\Db\Index[] - * @param string $table - * @param string $schema - * @return IndexInterface[] + * @return bool */ - public function describeIndexes($table, $schema = null) {} + public function supportSequences(): bool {} /** - * Lists table references + * Generates SQL checking for the existence of a schema.table * - * - * print_r( - * $connection->describeReferences("robots_parts") + * ```php + * var_dump( + * $connection->tableExists("blog", "posts") * ); - * + * ``` * - * @param string $table - * @param string $schema - * @return ReferenceInterface[] + * @param string $tableName + * @param string $schemaName + * @return bool */ - public function describeReferences($table, $schema = null) {} + public function tableExists(string $tableName, string $schemaName = null): bool {} /** * Gets creation options from a table * - * + * ```php * print_r( * $connection->tableOptions("robots") * ); - * + * ``` * * @param string $tableName * @param string $schemaName * @return array */ - public function tableOptions($tableName, $schemaName = null) {} - - /** - * Creates a new savepoint - * - * @param string $name - * @return bool - */ - public function createSavepoint($name) {} - - /** - * Releases given savepoint - * - * @param string $name - * @return bool - */ - public function releaseSavepoint($name) {} - - /** - * Rollbacks given savepoint - * - * @param string $name - * @return bool - */ - public function rollbackSavepoint($name) {} - - /** - * Set if nested transactions should use savepoints - * - * @param bool $nestedTransactionsWithSavepoints - * @return AdapterInterface - */ - public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints) {} + public function tableOptions(string $tableName, string $schemaName = null): array {} /** - * Returns if nested transactions should use savepoints + * Updates data on a table using custom RBDM SQL syntax * - * @return bool - */ - public function isNestedTransactionsWithSavepoints() {} - - /** - * Returns the savepoint name to use for nested transactions + * ```php + * // Updating existing robot + * $success = $connection->update( + * "robots", + * ["name"], + * ["New Astro Boy"], + * "id = 101" + * ); * - * @return string - */ - public function getNestedTransactionSavepointName() {} - - /** - * Returns the default identity value to be inserted in an identity column + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 * - * - * // Inserting a new robot with a valid default value for the column 'id' - * $success = $connection->insert( + * // Updating existing robot with array condition and $dataTypes + * $success = $connection->update( * "robots", + * ["name"], + * ["New Astro Boy"], * [ - * $connection->getDefaultIdValue(), - * "Astro Boy", - * 1952, + * "conditions" => "id = ?", + * "bind" => [$some_unsafe_id], + * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param * ], * [ - * "id", - * "name", - * "year", + * PDO::PARAM_STR * ] * ); - * * - * @return RawValue + * ``` + * + * Warning! If $whereCondition is string it not escaped. + * + * @param string $table + * @param mixed $fields + * @param mixed $values + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool */ - public function getDefaultIdValue() {} + public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool {} /** - * Returns the default value to make the RBDM use the default value declared in the table definition + * Updates data on a table using custom RBDM SQL syntax + * Another, more convenient syntax * - * - * // Inserting a new robot with a valid default value for the column 'year' - * $success = $connection->insert( + * ```php + * // Updating existing robot + * $success = $connection->updateAsDict( * "robots", * [ - * "Astro Boy", - * $connection->getDefaultValue() + * "name" => "New Astro Boy", * ], - * [ - * "name", - * "year", - * ] + * "id = 101" * ); - * * - * @return RawValue - */ - public function getDefaultValue() {} - - /** - * Check whether the database system requires a sequence to produce auto-numeric values + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * ``` * + * @param string $table + * @param mixed $data + * @param mixed $whereCondition + * @param mixed $dataTypes * @return bool */ - public function supportSequences() {} + public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool {} /** - * Check whether the database system requires an explicit value for identity columns + * Check whether the database system requires an explicit value for identity + * columns * * @return bool */ - public function useExplicitIdValue() {} - - /** - * Return descriptor used to connect to the active database - * - * @return array - */ - public function getDescriptor() {} - - /** - * Gets the active connection unique identifier - * - * @return string - */ - public function getConnectionId() {} + public function useExplicitIdValue(): bool {} /** - * Active SQL statement in the object - * - * @return string - */ - public function getSQLStatement() {} - - /** - * Active SQL statement in the object without replace bound parameters + * Generates SQL checking for the existence of a schema.view * - * @return string - */ - public function getRealSQLStatement() {} - - /** - * Active SQL statement in the object + * ```php + * var_dump( + * $connection->viewExists("active_users", "posts") + * ); + * ``` * - * @return array + * @param string $viewName + * @param string $schemaName + * @return bool */ - public function getSQLBindTypes() {} + public function viewExists(string $viewName, string $schemaName = null): bool {} } diff --git a/src/Phalcon/db/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php similarity index 52% rename from src/Phalcon/db/AdapterInterface.php rename to src/Phalcon/db/adapter/AdapterInterface.php index d207a62d..e136e02f 100644 --- a/src/Phalcon/db/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -1,126 +1,101 @@ fetchColumn("SELECT count() FROM robots"); + * print_r($robotsCount); + * + * // Getting name of last edited robot + * $robot = $connection->fetchColumn( + * "SELECT id, name FROM robots order by modified desc", + * 1 + * ); + * print_r($robot); + * ``` + * + * @param string $sqlQuery + * @param array $placeholders + * @param mixed $column + * @return string|bool + */ + public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0); + + /** + * Returns the first row in a SQL query result * + * @param string $sqlQuery + * @param int $fetchMode + * @param mixed $placeholders * @return array */ - public function getDescriptor(); + public function fetchOne(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array; /** - * Gets the active connection unique identifier + * Returns a SQL modified with a FOR UPDATE clause * + * @param string $sqlQuery * @return string */ - public function getConnectionId(); + public function forUpdate(string $sqlQuery): string; /** - * Active SQL statement in the object + * Returns the SQL column definition from a column * + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getSQLStatement(); + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; /** - * Active SQL statement in the object without replace bound parameters + * Gets a list of columns * + * @param mixed $columnList * @return string */ - public function getRealSQLStatement(); + public function getColumnList($columnList): string; /** - * Active SQL statement in the object + * Gets the active connection unique identifier * - * @return array + * @return string */ - public function getSQLVariables(); + public function getConnectionId(): string; /** - * Active SQL statement in the object + * Return descriptor used to connect to the active database * * @return array */ - public function getSQLBindTypes(); + public function getDescriptor(): array; /** - * Returns type of database system the adapter is used for + * Returns internal dialect instance * - * @return string + * @return DialectInterface */ - public function getType(); + public function getDialect(): DialectInterface; /** * Returns the name of the dialect used * * @return string */ - public function getDialectType(); + public function getDialectType(): string; /** - * Returns internal dialect instance + * Return the default identity value to insert in an identity column * - * @return DialectInterface + * @return \Phalcon\Db\RawValue */ - public function getDialect(); + public function getDefaultIdValue(): RawValue; /** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection + * Return internal PDO handler * - * @param array $descriptor - * @return bool + * @return \Pdo */ - public function connect(array $descriptor = null); + public function getInternalHandler(): \Pdo; /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server return rows + * Returns the savepoint name to use for nested transactions * - * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool|ResultInterface + * @return string */ - public function query($sqlStatement, $placeholders = null, $dataTypes = null); + public function getNestedTransactionSavepointName(): string; /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't return any rows + * Active SQL statement in the object without replace bound parameters * - * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool + * @return string */ - public function execute($sqlStatement, $placeholders = null, $dataTypes = null); + public function getRealSQLStatement(): string; /** - * Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system + * Active SQL statement in the object * - * @return int + * @return string */ - public function affectedRows(); + public function getSQLStatement(): string; /** - * Closes active connection returning success. Phalcon automatically closes - * and destroys active connections within Phalcon\Db\Pool + * Active SQL statement in the object * - * @return bool + * @return array */ - public function close(); + public function getSQLBindTypes(): array; /** - * Escapes a column/table/schema name + * Active SQL statement in the object * - * @param string $identifier - * @return string + * @return array */ - public function escapeIdentifier($identifier); + public function getSQLVariables(): array; /** - * Escapes a value to avoid SQL injections + * Returns type of database system the adapter is used for * - * @param string $str * @return string */ - public function escapeString($str); + public function getType(): string; /** - * Returns insert id for the auto_increment column inserted in the last SQL statement - * - * @param string $sequenceName - * @return int - */ - public function lastInsertId($sequenceName = null); - - /** - * Starts a transaction in the connection + * Inserts data into a table using custom RDBMS SQL syntax * - * @param bool $nesting + * @param string $table + * @param array $values + * @param mixed $fields + * @param mixed $dataTypes * @return bool */ - public function begin($nesting = true); + public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool; /** - * Rollbacks the active transaction in the connection + * Inserts data into a table using custom RBDM SQL syntax * - * @param bool $nesting + * ```php + * // Inserting a new robot + * $success = $connection->insertAsDict( + * "robots", + * [ + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); + * + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` + * + * @param string $table + * @param mixed $data + * @param mixed $dataTypes * @return bool */ - public function rollback($nesting = true); + public function insertAsDict(string $table, $data, $dataTypes = null): bool; /** - * Commits the active transaction in the connection + * Returns if nested transactions should use savepoints * - * @param bool $nesting * @return bool */ - public function commit($nesting = true); + public function isNestedTransactionsWithSavepoints(): bool; /** * Checks whether connection is under database transaction * * @return bool */ - public function isUnderTransaction(); + public function isUnderTransaction(): bool; /** - * Return internal PDO handler + * Returns insert id for the auto_increment column inserted in the last SQL + * statement * - * @return \Pdo + * @param mixed $sequenceName */ - public function getInternalHandler(); + public function lastInsertId($sequenceName = null); /** - * Lists table indexes + * Appends a LIMIT clause to sqlQuery argument * - * @param string $table - * @param string $schema - * @return IndexInterface[] + * @param string $sqlQuery + * @param int $number + * @return string */ - public function describeIndexes($table, $schema = null); + public function limit(string $sqlQuery, int $number): string; /** - * Lists table references + * List all tables on a database * - * @param string $table - * @param string $schema - * @return ReferenceInterface[] + * @param string $schemaName + * @return array */ - public function describeReferences($table, $schema = null); + public function listTables(string $schemaName = null): array; /** - * Gets creation options from a table + * List all views on a database * - * @param string $tableName * @param string $schemaName * @return array */ - public function tableOptions($tableName, $schemaName = null); + public function listViews(string $schemaName = null): array; /** - * Check whether the database system requires an explicit value for identity columns + * Modifies a table column based on a definition * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function useExplicitIdValue(); + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool; /** - * Return the default identity value to insert in an identity column + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server returns + * rows * - * @return RawValue + * @param string $sqlStatement + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool|ResultInterface */ - public function getDefaultIdValue(); + public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); /** - * Check whether the database system requires a sequence to produce auto-numeric values + * Releases given savepoint * + * @param string $name * @return bool */ - public function supportSequences(); + public function releaseSavepoint(string $name): bool; /** - * Creates a new savepoint + * Rollbacks the active transaction in the connection * - * @param string $name + * @param bool $nesting * @return bool */ - public function createSavepoint($name); + public function rollback(bool $nesting = true): bool; /** - * Releases given savepoint + * Rollbacks given savepoint * * @param string $name * @return bool */ - public function releaseSavepoint($name); + public function rollbackSavepoint(string $name): bool; /** - * Rollbacks given savepoint + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $name - * @return bool + * @param string $sqlQuery + * @return string */ - public function rollbackSavepoint($name); + public function sharedLock(string $sqlQuery): string; /** * Set if nested transactions should use savepoints @@ -525,29 +536,87 @@ public function rollbackSavepoint($name); * @param bool $nestedTransactionsWithSavepoints * @return AdapterInterface */ - public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints); + public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface; /** - * Returns if nested transactions should use savepoints + * Check whether the database system requires a sequence to produce + * auto-numeric values * * @return bool */ - public function isNestedTransactionsWithSavepoints(); + public function supportSequences(): bool; /** - * Returns the savepoint name to use for nested transactions + * Generates SQL checking for the existence of a schema.table * - * @return string + * @param string $tableName + * @param string $schemaName + * @return bool */ - public function getNestedTransactionSavepointName(); + public function tableExists(string $tableName, string $schemaName = null): bool; /** - * Returns an array of Phalcon\Db\Column objects describing a table + * Gets creation options from a table + * + * @param string $tableName + * @param string $schemaName + * @return array + */ + public function tableOptions(string $tableName, string $schemaName = null): array; + + /** + * Updates data on a table using custom RDBMS SQL syntax * * @param string $table - * @param string $schema - * @return ColumnInterface[] + * @param mixed $fields + * @param mixed $values + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool + */ + public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool; + + /** + * Updates data on a table using custom RBDM SQL syntax + * Another, more convenient syntax + * + * ```php + * // Updating existing robot + * $success = $connection->updateAsDict( + * "robots", + * [ + * "name" => "New Astro Boy", + * ], + * "id = 101" + * ); + * + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * ``` + * + * @param string $table + * @param mixed $data + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool + */ + public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool; + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool; + + /** + * Generates SQL checking for the existence of a schema.view + * + * @param string $viewName + * @param string $schemaName + * @return bool */ - public function describeColumns($table, $schema = null); + public function viewExists(string $viewName, string $schemaName = null): bool; } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php new file mode 100644 index 00000000..1d71f837 --- /dev/null +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class PdoFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * Constructor + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Annotations\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * Returns the available adapters + * + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/db/adapter/Pdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php similarity index 75% rename from src/Phalcon/db/adapter/Pdo.php rename to src/Phalcon/db/adapter/pdo/AbstractPdo.php index 81eb783d..80be64a0 100644 --- a/src/Phalcon/db/adapter/Pdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -1,13 +1,12 @@ + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -19,21 +18,21 @@ * ]; * * $connection = new Mysql($config); - * + * ``` */ -abstract class Pdo extends \Phalcon\Db\Adapter +abstract class AbstractPdo extends \Phalcon\Db\Adapter\AbstractAdapter { /** - * PDO Handler - * - * @var \Pdo + * Last affected rows */ - protected $_pdo; + protected $affectedRows; /** - * Last affected rows + * PDO Handler + * + * @var \Pdo */ - protected $_affectedRows; + protected $pdo; /** @@ -44,11 +43,52 @@ abstract class Pdo extends \Phalcon\Db\Adapter public function __construct(array $descriptor) {} /** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. + * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE + * executed in the database system + * + * ```php + * $connection->execute( + * "DELETE FROM robots" + * ); + * + * echo $connection->affectedRows(), " were deleted"; + * ``` + * + * @return int + */ + public function affectedRows(): int {} + + /** + * Starts a transaction in the connection + * + * @param bool $nesting + * @return bool + */ + public function begin(bool $nesting = true): bool {} + + /** + * Commits the active transaction in the connection + * + * @param bool $nesting + * @return bool + */ + public function commit(bool $nesting = true): bool {} + + /** + * Closes the active connection returning success. Phalcon automatically + * closes and destroys active connections when the request ends + * + * @return bool + */ + public function close(): bool {} + + /** + * This method is automatically called in \Phalcon\Db\Adapter\Pdo + * constructor. * * Call it when you need to restore a database connection. * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * // Make a connection @@ -64,97 +104,52 @@ public function __construct(array $descriptor) {} * * // Reconnect * $connection->connect(); - * + * ``` * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null) {} - - /** - * Returns a PDO prepared statement to be executed with 'executePrepared' - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT FROM robots WHERE name = :name" - * ); - * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] - * ); - * - * - * @param string $sqlStatement - * @return \PDOStatement - */ - public function prepare($sqlStatement) {} + public function connect(array $descriptor = null): bool {} /** - * Executes a prepared statement binding. This function uses integer indexes starting from zero - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT FROM robots WHERE name = :name" - * ); + * Converts bound parameters such as :name: or ?1 into PDO bind params ? * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] + * ```php + * print_r( + * $connection->convertBoundParams( + * "SELECT FROM robots WHERE name = :name:", + * [ + * "Bender", + * ] + * ) * ); - * + * ``` * - * @param \PDOStatement $statement - * @param array $placeholders - * @param array $dataTypes - * @return \PDOStatement + * @param string $sql + * @param array $params + * @return array */ - public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes) {} + public function convertBoundParams(string $sql, array $params = array()): array {} /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server is returning rows + * Escapes a value to avoid SQL injections according to the active charset + * in the connection * - * - * // Querying data - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = 'mechanical'" - * ); - * - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = ?", - * [ - * "mechanical", - * ] - * ); - * + * ```php + * $escapedStr = $connection->escapeString("some dangerous value"); + * ``` * - * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes - * @return bool|\Phalcon\Db\ResultInterface + * @param string $str + * @return string */ - public function query($sqlStatement, $bindParams = null, $bindTypes = null) {} + public function escapeString(string $str): string {} /** * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't return any rows + * Use this method only when the SQL statement sent to the server doesn't + * return any rows * - * + * ```php * // Inserting data * $success = $connection->execute( * "INSERT INTO robots VALUES (1, 'Astro Boy')" @@ -167,74 +162,84 @@ public function query($sqlStatement, $bindParams = null, $bindTypes = null) {} * "Astro Boy", * ] * ); - * + * ``` * * @param string $sqlStatement * @param mixed $bindParams * @param mixed $bindTypes * @return bool */ - public function execute($sqlStatement, $bindParams = null, $bindTypes = null) {} + public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool {} /** - * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system + * Executes a prepared statement binding. This function uses integer indexes + * starting from zero * - * - * $connection->execute( - * "DELETE FROM robots" + * ```php + * use Phalcon\Db\Column; + * + * $statement = $db->prepare( + * "SELECT FROM robots WHERE name = :name" * ); * - * echo $connection->affectedRows(), " were deleted"; - * + * $result = $connection->executePrepared( + * $statement, + * [ + * "name" => "Voltron", + * ], + * [ + * "name" => Column::BIND_PARAM_INT, + * ] + * ); + * ``` * - * @return int + * @param \PDOStatement $statement + * @param array $placeholders + * @param mixed $dataTypes + * @return \PDOStatement */ - public function affectedRows() {} + public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement {} /** - * Closes the active connection returning success. Phalcon automatically closes and destroys - * active connections when the request ends - * - * @return bool + * Return the error info, if any */ - public function close() {} + public function getErrorInfo() {} /** - * Escapes a value to avoid SQL injections according to the active charset in the connection + * Return internal PDO handler * - * - * $escapedStr = $connection->escapeString("some dangerous value"); - * + * @return \Pdo + */ + public function getInternalHandler(): \Pdo {} + + /** + * Returns the current transaction nesting level * - * @param string $str - * @return string + * @return int */ - public function escapeString($str) {} + public function getTransactionLevel(): int {} /** - * Converts bound parameters such as :name: or ?1 into PDO bind params ? + * Checks whether the connection is under a transaction * - * - * print_r( - * $connection->convertBoundParams( - * "SELECT FROM robots WHERE name = :name:", - * [ - * "Bender", - * ] - * ) + * ```php + * $connection->begin(); + * + * // true + * var_dump( + * $connection->isUnderTransaction() * ); - * + * ``` * - * @param string $sql - * @param array $params - * @return array + * @return bool */ - public function convertBoundParams($sql, array $params = array()) {} + public function isUnderTransaction(): bool {} /** - * Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement + * Returns the insert id for the auto_increment/serial column inserted in + * the latest executed SQL statement * - * + * ```php * // Inserting a new robot * $success = $connection->insert( * "robots", @@ -250,72 +255,78 @@ public function convertBoundParams($sql, array $params = array()) {} * * // Getting the generated id * $id = $connection->lastInsertId(); - * + * ``` * - * @param string $sequenceName + * @param mixed $sequenceName * @return int|bool */ public function lastInsertId($sequenceName = null) {} /** - * Starts a transaction in the connection + * Returns a PDO prepared statement to be executed with 'executePrepared' * - * @param bool $nesting - * @return bool - */ - public function begin($nesting = true) {} - - /** - * Rollbacks the active transaction in the connection + * ```php + * use Phalcon\Db\Column; * - * @param bool $nesting - * @return bool - */ - public function rollback($nesting = true) {} - - /** - * Commits the active transaction in the connection + * $statement = $db->prepare( + * "SELECT FROM robots WHERE name = :name" + * ); * - * @param bool $nesting - * @return bool - */ - public function commit($nesting = true) {} - - /** - * Returns the current transaction nesting level + * $result = $connection->executePrepared( + * $statement, + * [ + * "name" => "Voltron", + * ], + * [ + * "name" => Column::BIND_PARAM_INT, + * ] + * ); + * ``` * - * @return int + * @param string $sqlStatement + * @return \PDOStatement */ - public function getTransactionLevel() {} + public function prepare(string $sqlStatement): \PDOStatement {} /** - * Checks whether the connection is under a transaction + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server is + * returning rows * - * - * $connection->begin(); + * ```php + * // Querying data + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = 'mechanical'" + * ); * - * // true - * var_dump( - * $connection->isUnderTransaction() + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = ?", + * [ + * "mechanical", + * ] * ); - * + * ``` * - * @return bool + * @param string $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes + * @return bool|\Phalcon\Db\ResultInterface */ - public function isUnderTransaction() {} + public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) {} /** - * Return internal PDO handler + * Rollbacks the active transaction in the connection * - * @return \Pdo + * @param bool $nesting + * @return bool */ - public function getInternalHandler() {} + public function rollback(bool $nesting = true): bool {} /** - * Return the error info, if any + * Returns PDO adapter DSN defaults as a key-value map. * * @return array */ - public function getErrorInfo() {} + abstract protected function getDsnDefaults(): array; } diff --git a/src/Phalcon/db/adapter/pdo/Factory.php b/src/Phalcon/db/adapter/pdo/Factory.php deleted file mode 100644 index 1a089408..00000000 --- a/src/Phalcon/db/adapter/pdo/Factory.php +++ /dev/null @@ -1,31 +0,0 @@ - - * use Phalcon\Db\Adapter\Pdo\Factory; - * - * $options = [ - * "host" => "localhost", - * "dbname" => "blog", - * "port" => 3306, - * "username" => "sigma", - * "password" => "secret", - * "adapter" => "mysql", - * ]; - * $db = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Db\AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index 9f505dd2..7e03f623 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Mysql - * * Specific functions for the Mysql database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -19,70 +17,81 @@ * ]; * * $connection = new Mysql($config); - * + * ``` */ -class Mysql extends \Phalcon\Db\Adapter\Pdo +class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'mysql'; - protected $_type = 'mysql'; - + /** + * @var string + */ + protected $type = 'mysql'; - protected $_dialectType = 'mysql'; + /** + * Adds a foreign key to a table + * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ReferenceInterface $reference + * @return bool + */ + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool {} /** * Returns an array of Phalcon\Db\Column objects describing a table * - * + * ```php * print_r( * $connection->describeColumns("posts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns($table, $schema = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** * Lists table indexes * - * + * ```php * print_r( * $connection->describeIndexes("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\IndexInterface[] + * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes($table, $schema = null) {} + public function describeIndexes(string $table, string $schema = null): array {} /** * Lists table references * - * + * ```php * print_r( * $connection->describeReferences("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ReferenceInterface[] + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences($table, $schema = null) {} + public function describeReferences(string $table, string $schema = null): array {} /** - * Adds a foreign key to a table + * Returns PDO adapter DSN defaults as a key-value map. * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference - * @return bool + * @return array */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 25eacf0b..16662427 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Postgresql - * * Specific functions for the Postgresql database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Postgresql; * * $config = [ @@ -19,40 +17,36 @@ * ]; * * $connection = new Postgresql($config); - * + * ``` */ -class Postgresql extends \Phalcon\Db\Adapter\Pdo +class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'postgresql'; - protected $_type = 'pgsql'; - - - protected $_dialectType = 'postgresql'; + /** + * @var string + */ + protected $type = 'pgsql'; /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection. + * Constructor for Phalcon\Db\Adapter\Pdo\Postgresql * * @param array $descriptor - * @return bool */ - public function connect(array $descriptor = null) {} + public function __construct(array $descriptor) {} /** - * Returns an array of Phalcon\Db\Column objects describing a table + * This method is automatically called in Phalcon\Db\Adapter\Pdo + * constructor. Call it when you need to restore a database connection. * - * - * print_r( - * $connection->describeColumns("posts") - * ); - * - * - * @param string $table - * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @param array $descriptor + * @return bool */ - public function describeColumns($table, $schema = null) {} + public function connect(array $descriptor = null): bool {} /** * Creates a table @@ -62,30 +56,42 @@ public function describeColumns($table, $schema = null) {} * @param array $definition * @return bool */ - public function createTable($tableName, $schemaName, array $definition) {} + public function createTable(string $tableName, string $schemaName, array $definition): bool {} /** - * Modifies a table column based on a definition + * Returns an array of Phalcon\Db\Column objects describing a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn - * @return bool + * ```php + * print_r( + * $connection->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** - * Check whether the database system requires an explicit value for identity columns + * Lists table references * - * @return bool + * ```php + * print_r( + * $connection->describeReferences("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function useExplicitIdValue() {} + public function describeReferences(string $table, string $schema = null): array {} /** * Returns the default identity value to be inserted in an identity column * - * + * ```php * // Inserting a new robot with a valid default value for the column 'id' * $success = $connection->insert( * "robots", @@ -100,17 +106,44 @@ public function useExplicitIdValue() {} * "year", * ] * ); - * + * ``` * * @return \Phalcon\Db\RawValue */ - public function getDefaultIdValue() {} + public function getDefaultIdValue(): RawValue {} /** - * Check whether the database system requires a sequence to produce auto-numeric values + * Modifies a table column based on a definition * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function supportSequences() {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} + + /** + * Check whether the database system requires a sequence to produce + * auto-numeric values + * + * @return bool + */ + public function supportSequences(): bool {} + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool {} + + /** + * Returns PDO adapter DSN defaults as a key-value map. + * + * @return array + */ + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index bcf551fa..8acf592d 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Sqlite - * * Specific functions for the Sqlite database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Sqlite; * * $connection = new Sqlite( @@ -15,79 +13,81 @@ * "dbname" => "/tmp/test.sqlite", * ] * ); - * + * ``` */ -class Sqlite extends \Phalcon\Db\Adapter\Pdo +class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'sqlite'; - protected $_type = 'sqlite'; - + /** + * @var string + */ + protected $type = 'sqlite'; - protected $_dialectType = 'sqlite'; + /** + * Constructor for Phalcon\Db\Adapter\Pdo\Sqlite + * + * @param array $descriptor + */ + public function __construct(array $descriptor) {} /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection. + * This method is automatically called in Phalcon\Db\Adapter\Pdo + * constructor. Call it when you need to restore a database connection. * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null) {} + public function connect(array $descriptor = null): bool {} /** * Returns an array of Phalcon\Db\Column objects describing a table * - * + * ```php * print_r( * $connection->describeColumns("posts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns($table, $schema = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** * Lists table indexes * - * + * ```php * print_r( * $connection->describeIndexes("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\IndexInterface[] + * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes($table, $schema = null) {} + public function describeIndexes(string $table, string $schema = null): array {} /** * Lists table references * - * @param string table - * @param string schema - * @return Phalcon\Db\ReferenceInterface[] * @param string $table * @param string $schema - * @return \Phalcon\Db\ReferenceInterface[] - */ - public function describeReferences($table, $schema = null) {} - - /** - * Check whether the database system requires an explicit value for identity columns - * - * @return bool + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function useExplicitIdValue() {} + public function describeReferences(string $table, string $schema = null): array {} /** - * Returns the default value to make the RBDM use the default value declared in the table definition + * Returns the default value to make the RBDM use the default value declared + * in the table definition * - * + * ```php * // Inserting a new robot with a valid default value for the column 'year' * $success = $connection->insert( * "robots", @@ -100,10 +100,25 @@ public function useExplicitIdValue() {} * "year", * ] * ); - * + * ``` * * @return \Phalcon\Db\RawValue */ - public function getDefaultValue() {} + public function getDefaultValue(): RawValue {} + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool {} + + /** + * Returns PDO adapter DSN defaults as a key-value map. + * + * @return array + */ + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 7f2170b0..85905487 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Mysql - * * Generates database specific SQL for the MySQL RDBMS */ class Mysql extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '`'; - - /** - * Gets the column name in MySQL - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '`'; + /** * Generates SQL to add a column to a table @@ -29,77 +21,100 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $columnName * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** * Generates SQL to delete a foreign key from a table @@ -109,26 +124,26 @@ public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInte * @param string $referenceName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param string $indexName * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** * Generates SQL to drop a table @@ -138,115 +153,121 @@ public function truncateTable($tableName, $schemaName) {} * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a view * * @param string $viewName - * @param array $definition * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to drop a view + * Gets the column name in MySQL * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL checking for the existence of a schema.table + * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. * - * - * echo $dialect->tableExists("posts", "blog"); + * @return string + */ + public function getForeignKeyChecks(): string {} + + /** + * List all tables in database * - * echo $dialect->tableExists("posts"); - * + * ```php + * print_r( + * $dialect->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to list all views of a schema or user * - * @param string $viewName * @param string $schemaName * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates SQL describing a table - * - * - * print_r( - * $dialect->describeColumns("posts") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function describeColumns($table, $schema = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * List all tables in database + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * - * print_r( - * $dialect->listTables("blog") - * ); - * + * ```php + * $sql = $dialect->sharedLock("SELECT FROM robots"); * - * @param string $schemaName + * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE + * ``` + * + * @param string $sqlQuery * @return string */ - public function listTables($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.table + * + * ```php + * echo $dialect->tableExists("posts", "blog"); + * + * echo $dialect->tableExists("posts"); + * ``` * + * @param string $tableName * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query indexes on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeIndexes($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL checking for the existence of a schema.view * - * @param string $table - * @param string $schema + * @param string $viewName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function viewExists(string $viewName, string $schemaName = null): string {} /** * Generates SQL to add the table creation options @@ -254,26 +275,23 @@ public function tableOptions($table, $schema = null) {} * @param array $definition * @return string */ - protected function _getTableOptions(array $definition) {} + protected function getTableOptions(array $definition): string {} /** - * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. + * Checks if the size and/or scale are present and encloses those values + * in parentheses if need be * + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getForeignKeyChecks() {} + private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause - * - * - * $sql = $dialect->sharedLock("SELECT FROM robots"); - * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE - * + * Checks if a column is unsigned or not and returns the relevant SQL syntax * - * @param string $sqlQuery + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function sharedLock($sqlQuery) {} + private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string {} } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index ff800073..2ef5c5ff 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Postgresql - * * Generates database specific SQL for the PostgreSQL RDBMS */ class Postgresql extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '\\\"'; - - /** - * Gets the column name in PostgreSQL - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '\\\"'; + /** * Generates SQL to add a column to a table @@ -29,77 +21,100 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $columnName * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** * Generates SQL to delete a foreign key from a table @@ -109,26 +124,26 @@ public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInte * @param string $referenceName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName - * @param array $definition - * @return string|array + * @param string $indexName + * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** * Generates SQL to drop a table @@ -138,135 +153,120 @@ public function truncateTable($tableName, $schemaName) {} * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a view * * @param string $viewName - * @param array $definition * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to drop a view + * Gets the column name in PostgreSQL * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL checking for the existence of a schema.table - * - * - * echo $dialect->tableExists("posts", "blog"); + * List all tables in database * - * echo $dialect->tableExists("posts"); - * + * ```php + * print_r( + * $dialect->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to list all views of a schema or user * - * @param string $viewName * @param string $schemaName * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates SQL describing a table - * - * - * print_r( - * $dialect->describeColumns("posts") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function describeColumns($table, $schema = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * List all tables in database - * - * - * print_r( - * $dialect->listTables("blog") - * ); - * + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query * - * @param string $schemaName + * @param string $sqlQuery * @return string */ - public function listTables($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.table + * + * ```php + * echo $dialect->tableExists("posts", "blog"); * + * echo $dialect->tableExists("posts"); + * ``` + * + * @param string $tableName * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query indexes on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeIndexes($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL checking for the existence of a schema.view * - * @param string $table - * @param string $schema + * @param string $viewName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function viewExists(string $viewName, string $schemaName = null): string {} /** * @param \Phalcon\Db\ColumnInterface $column * @return string */ - protected function _castDefault(\Phalcon\Db\ColumnInterface $column) {} + protected function castDefault(\Phalcon\Db\ColumnInterface $column): string {} /** * @param array $definition * @return string */ - protected function _getTableOptions(array $definition) {} - - /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query - * - * @param string $sqlQuery - * @return string - */ - public function sharedLock($sqlQuery) {} + protected function getTableOptions(array $definition): string {} } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index f71e0ab8..f00fed05 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Sqlite - * - * Generates database specific SQL for the Sqlite RDBMS + * Generates database specific SQL for the SQLite RDBMS */ class Sqlite extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '\\\"'; - - /** - * Gets the column name in SQLite - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '\\\"'; + /** * Generates SQL to add a column to a table @@ -29,126 +21,147 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes detail on a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $index * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function describeIndex(string $index): string {} /** - * Generates SQL to delete a foreign key from a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param string $referenceName + * @param string $columnName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete a foreign key from a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param string $referenceName * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName + * @param string $indexName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to drop a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName - * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a table * - * @param string $viewName - * @param array $definition + * @param string $tableName * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** * Generates SQL to drop a view @@ -158,60 +171,54 @@ public function createView($viewName, array $definition, $schemaName = null) {} * @param bool $ifExists * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL checking for the existence of a schema.table + * Returns a SQL modified with a FOR UPDATE clause. For SQLite it returns + * the original query * - * - * echo $dialect->tableExists("posts", "blog"); - * - * echo $dialect->tableExists("posts"); - * - * - * @param string $tableName - * @param string $schemaName + * @param string $sqlQuery * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function forUpdate(string $sqlQuery): string {} /** - * Generates SQL checking for the existence of a schema.view + * Gets the column name in SQLite * - * @param string $viewName - * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL describing a table + * Generates the SQL to get query list of indexes * - * + * ```php * print_r( - * $dialect->describeColumns("posts") + * $dialect->listIndexesSql("blog") * ); - * + * ``` * * @param string $table * @param string $schema + * @param string $keyName * @return string */ - public function describeColumns($table, $schema = null) {} + public function listIndexesSql(string $table, string $schema = null, string $keyName = null): string {} /** * List all tables in database * - * + * ```php * print_r( * $dialect->listTables("blog") * ); - * + * ``` * * @param string $schemaName * @return string */ - public function listTables($schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** * Generates the SQL to list all views of a schema or user @@ -219,66 +226,68 @@ public function listTables($schemaName = null) {} * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates the SQL to get query list of indexes - * - * - * print_r( - * $dialect->listIndexesSql("blog") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema - * @param string $keyName + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function listIndexesSql($table, $schema = null, $keyName = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * Generates SQL to query indexes on a table + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query * - * @param string $table - * @param string $schema + * @param string $sqlQuery * @return string */ - public function describeIndexes($table, $schema = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates SQL to query indexes detail on a table + * Generates SQL checking for the existence of a schema.table * - * @param string $index + * ```php + * echo $dialect->tableExists("posts", "blog"); + * + * echo $dialect->tableExists("posts"); + * ``` + * + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeIndex($index) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeReferences($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query + * Generates SQL checking for the existence of a schema.view * - * @param string $sqlQuery + * @param string $viewName + * @param string $schemaName * @return string */ - public function sharedLock($sqlQuery) {} + public function viewExists(string $viewName, string $schemaName = null): string {} } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 80149305..8e0bce9e 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -3,75 +3,73 @@ namespace Phalcon\Db\Profiler; /** - * Phalcon\Db\Profiler\Item - * * This class identifies each profile in a Phalcon\Db\Profiler */ class Item { /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @var string + * @var double */ - protected $_sqlStatement; + protected $finalTime; /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @var array + * @var double */ - protected $_sqlVariables; + protected $initialTime; /** * SQL bind types related to the profile * * @var array */ - protected $_sqlBindTypes; + protected $sqlBindTypes; /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @var double + * @var string */ - protected $_initialTime; + protected $sqlStatement; /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @var double + * @var array */ - protected $_finalTime; + protected $sqlVariables; /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @param string $sqlStatement + * @param double $finalTime */ - public function setSqlStatement($sqlStatement) {} + public function setFinalTime(float $finalTime) {} /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @return string + * @return double */ - public function getSqlStatement() {} + public function getFinalTime(): float {} /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @param array $sqlVariables + * @param double $initialTime */ - public function setSqlVariables(array $sqlVariables) {} + public function setInitialTime(float $initialTime) {} /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @return array + * @return double */ - public function getSqlVariables() {} + public function getInitialTime(): float {} /** * SQL bind types related to the profile @@ -85,41 +83,41 @@ public function setSqlBindTypes(array $sqlBindTypes) {} * * @return array */ - public function getSqlBindTypes() {} + public function getSqlBindTypes(): array {} /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @param double $initialTime + * @param string $sqlStatement */ - public function setInitialTime($initialTime) {} + public function setSqlStatement(string $sqlStatement) {} /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @return double + * @return string */ - public function getInitialTime() {} + public function getSqlStatement(): string {} /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @param double $finalTime + * @param array $sqlVariables */ - public function setFinalTime($finalTime) {} + public function setSqlVariables(array $sqlVariables) {} /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @return double + * @return array */ - public function getFinalTime() {} + public function getSqlVariables(): array {} /** * Returns the total time in seconds spent by the profile * * @return double */ - public function getTotalElapsedSeconds() {} + public function getTotalElapsedSeconds(): float {} } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index b7d9bdfa..42675919 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -3,89 +3,109 @@ namespace Phalcon\Db\Result; /** - * Phalcon\Db\Result\Pdo - * * Encapsulates the resultset internals * - * + * ```php * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM + * \Phalcon\Db\Enum::FETCH_NUM * ); * * while ($robot = $result->fetchArray()) { * print_r($robot); * } - * + * ``` */ class Pdo implements \Phalcon\Db\ResultInterface { - protected $_connection; + protected $bindParams; + + + protected $bindTypes; - protected $_result; + protected $connection; /** * Active fetch mode */ - protected $_fetchMode = Db::FETCH_OBJ; + protected $fetchMode = Enum::FETCH_OBJ; /** * Internal resultset * * @var \PDOStatement */ - protected $_pdoStatement; - - - protected $_sqlStatement; + protected $pdoStatement; - protected $_bindParams; + protected $result; - protected $_bindTypes; + protected $rowCount = false; - protected $_rowCount = false; + protected $sqlStatement; /** * Phalcon\Db\Result\Pdo constructor * - * @param \Phalcon\Db\AdapterInterface $connection + * @param Db\AdapterInterface $connection * @param \PDOStatement $result - * @param string $sqlStatement - * @param array $bindParams - * @param array $bindTypes + * @param mixed $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes */ public function __construct(Db\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} /** - * Allows to execute the statement again. Some database systems don't support scrollable cursors, - * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining + * Moves internal resultset cursor to another position letting us to fetch a + * certain row + * + * ```php + * $result = $connection->query( + * "SELECT FROM robots ORDER BY name" + * ); + * + * // Move to third row on result + * $result->dataSeek(2); + * + * // Fetch third row + * $row = $result->fetch(); + * ``` + * + * @param long $number + */ + public function dataSeek(int $number) {} + + /** + * Allows to execute the statement again. Some database systems don't + * support scrollable cursors. So, as cursors are forward only, we need to + * execute the cursor again to fetch rows from the begining * * @return bool */ - public function execute() {} + public function execute(): bool {} /** - * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Fetches an array/object of strings that corresponds to the fetched row, + * or FALSE if there are no more rows. This method is affected by the active + * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * + * ```php * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Db::FETCH_OBJ + * \Phalcon\Enum::FETCH_OBJ * ); * * while ($robot = $result->fetch()) { * echo $robot->name; * } - * + * ``` * * @param mixed $fetchStyle * @param mixed $cursorOrientation @@ -93,114 +113,97 @@ public function execute() {} */ public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) {} - /** - * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode - * - * - * $result = $connection->query("SELECT FROM robots ORDER BY name"); - * - * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM - * ); - * - * while ($robot = result->fetchArray()) { - * print_r($robot); - * } - * - */ - public function fetchArray() {} - /** * Returns an array of arrays containing all the records in the result - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * This method is affected by the active fetch flag set using + * `Phalcon\Db\Result\Pdo::setFetchMode()` * - * + * ```php * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * * $robots = $result->fetchAll(); - * + * ``` * * @param mixed $fetchStyle * @param mixed $fetchArgument * @param mixed $ctorArgs * @return array */ - public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null) {} + public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null): array {} /** - * Gets number of rows returned by a resultset + * Returns an array of strings that corresponds to the fetched row, or FALSE + * if there are no more rows. This method is affected by the active fetch + * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * - * $result = $connection->query( - * "SELECT FROM robots ORDER BY name" + * ```php + * $result = $connection->query("SELECT FROM robots ORDER BY name"); + * + * $result->setFetchMode( + * \Phalcon\Enum::FETCH_NUM * ); * - * echo "There are ", $result->numRows(), " rows in the resultset"; - * + * while ($robot = result->fetchArray()) { + * print_r($robot); + * } + * ``` + */ + public function fetchArray() {} + + /** + * Gets the internal PDO result object * - * @return int + * @return \PDOStatement */ - public function numRows() {} + public function getInternalResult(): \PDOStatement {} /** - * Moves internal resultset cursor to another position letting us to fetch a certain row + * Gets number of rows returned by a resultset * - * + * ```php * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * - * // Move to third row on result - * $result->dataSeek(2); - * - * // Fetch third row - * $row = $result->fetch(); - * + * echo "There are ", $result->numRows(), " rows in the resultset"; + * ``` * - * @param long $number + * @return int */ - public function dataSeek($number) {} + public function numRows(): int {} /** * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * + * ```php * // Return array with integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM + * \Phalcon\Enum::FETCH_NUM * ); * * // Return associative array without integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_ASSOC + * \Phalcon\Enum::FETCH_ASSOC * ); * * // Return associative array together with integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_BOTH + * \Phalcon\Enum::FETCH_BOTH * ); * * // Return an object * $result->setFetchMode( - * \Phalcon\Db::FETCH_OBJ + * \Phalcon\Enum::FETCH_OBJ * ); - * + * ``` * * @param int $fetchMode * @param mixed $colNoOrClassNameOrObject * @param mixed $ctorargs * @return bool */ - public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null) {} - - /** - * Gets the internal PDO result object - * - * @return \PDOStatement - */ - public function getInternalResult() {} + public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool {} } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index a1bc563f..96186819 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -3,68 +3,73 @@ namespace Phalcon\Debug; /** - * Phalcon\Debug\Dump - * * Dumps information about a variable(s) * - * + * ```php * $foo = 123; * * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * + * ``` * - * + * ```php * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * + * ``` */ class Dump { + /** + * @var bool + */ + protected $detailed = false; - protected $_detailed = false; - - - protected $_methods = array(); - - - protected $_styles; + /** + * @var array + */ + protected $methods = array(); + /** + * @var array + */ + protected $styles = array(); - public function getDetailed() {} + /** + * @return bool + */ + public function getDetailed(): bool {} /** - * @param mixed $detailed + * @param bool $detailed */ - public function setDetailed($detailed) {} + public function setDetailed(bool $detailed) {} /** * Phalcon\Debug\Dump constructor * * @param array $styles - * @param boolean $detailed debug object's private and protected properties + * @param bool $detailed */ - public function __construct(array $styles = array(), $detailed = false) {} + public function __construct(array $styles = array(), bool $detailed = false) {} /** * Alias of variables() method * - * @param mixed $variable - * @param ... * @return string */ - public function all() {} + public function all(): string {} /** - * Get style for type + * Alias of variable() method * - * @param string $type + * @param mixed $variable + * @param string $name * @return string */ - protected function getStyle($type) {} + public function one($variable, string $name = null): string {} /** * Set styles for vars type @@ -72,77 +77,74 @@ protected function getStyle($type) {} * @param array $styles * @return array */ - public function setStyles(array $styles = array()) {} + public function setStyles(array $styles = array()): array {} /** - * Alias of variable() method + * Returns an JSON string of information about a single variable. * - * @param mixed $variable - * @param string $name - * @return string - */ - public function one($variable, $name = null) {} - - /** - * Prepare an HTML string of information about a single variable. + * ```php + * $foo = [ + * "key" => "value", + * ]; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * + * $foo = new stdClass(); + * $foo->bar = "buz"; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * ``` * * @param mixed $variable - * @param string $name - * @param int $tab * @return string */ - protected function output($variable, $name = null, $tab = 1) {} + public function toJson($variable): string {} /** * Returns an HTML string of information about a single variable. * - * + * ```php * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * + * ``` * * @param mixed $variable * @param string $name * @return string */ - public function variable($variable, $name = null) {} + public function variable($variable, string $name = null): string {} /** * Returns an HTML string of debugging information about any number of * variables, each wrapped in a "pre" tag. * - * + * ```php * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * + * ``` * - * @param mixed $variable - * @param ... * @return string */ - public function variables() {} + public function variables(): string {} /** - * Returns an JSON string of information about a single variable. - * - * - * $foo = [ - * "key" => "value", - * ]; - * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * - * $foo = new stdClass(); - * $foo->bar = "buz"; + * Get style for type * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * + * @param string $type + * @return string + */ + protected function getStyle(string $type): string {} + + /** + * Prepare an HTML string of information about a single variable. * * @param mixed $variable + * @param string $name + * @param int $tab * @return string */ - public function toJson($variable) {} + protected function output($variable, string $name = null, int $tab = 1): string {} } diff --git a/src/Phalcon/debug/Exception.php b/src/Phalcon/debug/Exception.php index ea6c9862..9616f511 100644 --- a/src/Phalcon/debug/Exception.php +++ b/src/Phalcon/debug/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Debug; /** - * Phalcon\Debug\Exception - * * Exceptions thrown in Phalcon\Debug will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/DiInterface.php b/src/Phalcon/di/DiInterface.php similarity index 63% rename from src/Phalcon/DiInterface.php rename to src/Phalcon/di/DiInterface.php index a250d834..0e63ebd8 100644 --- a/src/Phalcon/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -1,41 +1,13 @@ + * ```php * $service = new \Phalcon\Di\Service( * "request", - * "Phalcon\\Http\\Request" + * \Phalcon\Http\Request::class * ); * * $request = service->resolve(); - * + * ``` */ class Service implements \Phalcon\Di\ServiceInterface { - protected $_name; - - - protected $_definition; - - - protected $_shared = false; + protected $definition; + /** + * @var bool + */ + protected $resolved = false; - protected $_resolved = false; + /** + * @var bool + */ + protected $shared = false; - protected $_sharedInstance; + protected $sharedInstance; /** * Phalcon\Di\Service * - * @param string $name * @param mixed $definition - * @param boolean $shared + * @param bool $shared */ - public final function __construct($name, $definition, $shared = false) {} + final public function __construct($definition, bool $shared = false) {} /** - * Returns the service's name + * Returns the service definition * - * @return string + * @return mixed */ - public function getName() {} + public function getDefinition() {} /** - * Sets if the service is shared or not + * Returns a parameter in a specific position * - * @param bool $shared + * @param int $position + * @return array */ - public function setShared($shared) {} + public function getParameter(int $position) {} /** - * Check whether the service is shared or not + * Returns true if the service was resolved * * @return bool */ - public function isShared() {} - - /** - * Sets/Resets the shared instance related to the service - * - * @param mixed $sharedInstance - */ - public function setSharedInstance($sharedInstance) {} + public function isResolved(): bool {} /** - * Set the service definition + * Check whether the service is shared or not * - * @param mixed $definition + * @return bool */ - public function setDefinition($definition) {} + public function isShared(): bool {} /** - * Returns the service definition + * Resolves the service * + * @param array $parameters + * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function getDefinition() {} + public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) {} /** - * Resolves the service + * Set the service definition * - * @param array $parameters - * @param \Phalcon\DiInterface $dependencyInjector - * @return mixed + * @param mixed $definition */ - public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null) {} + public function setDefinition($definition) {} /** * Changes a parameter in the definition without resolve the service @@ -101,29 +93,20 @@ public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInje * @param array $parameter * @return \Phalcon\Di\ServiceInterface */ - public function setParameter($position, array $parameter) {} - - /** - * Returns a parameter in a specific position - * - * @param int $position - * @return array - */ - public function getParameter($position) {} + public function setParameter(int $position, array $parameter): ServiceInterface {} /** - * Returns true if the service was resolved + * Sets if the service is shared or not * - * @return bool + * @param bool $shared */ - public function isResolved() {} + public function setShared(bool $shared) {} /** - * Restore the internal state of a service + * Sets/Resets the shared instance related to the service * - * @param array $attributes - * @return \Phalcon\Di\ServiceInterface + * @param mixed $sharedInstance */ - public static function __set_state(array $attributes) {} + public function setSharedInstance($sharedInstance) {} } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index 9277779a..a7447ae8 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -3,56 +3,55 @@ namespace Phalcon\Di; /** - * Phalcon\Di\ServiceInterface - * * Represents a service in the services container */ interface ServiceInterface { /** - * Returns the service's name + * Returns the service definition * - * @param string + * @return mixed */ - public function getName(); + public function getDefinition(); /** - * Sets if the service is shared or not + * Returns a parameter in a specific position * - * @param bool $shared + * @param int $position + * @return array */ - public function setShared($shared); + public function getParameter(int $position); /** - * Check whether the service is shared or not + * Returns true if the service was resolved * * @return bool */ - public function isShared(); + public function isResolved(): bool; /** - * Set the service definition + * Check whether the service is shared or not * - * @param mixed $definition + * @return bool */ - public function setDefinition($definition); + public function isShared(): bool; /** - * Returns the service definition + * Resolves the service * + * @param array $parameters + * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function getDefinition(); + public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null); /** - * Resolves the service + * Set the service definition * - * @param array $parameters - * @param \Phalcon\DiInterface $dependencyInjector - * @return mixed + * @param mixed $definition */ - public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null); + public function setDefinition($definition); /** * Changes a parameter in the definition without resolve the service @@ -61,14 +60,13 @@ public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInje * @param array $parameter * @return ServiceInterface */ - public function setParameter($position, array $parameter); + public function setParameter(int $position, array $parameter): ServiceInterface; /** - * Restore the internal state of a service + * Sets if the service is shared or not * - * @param array $attributes - * @return ServiceInterface + * @param bool $shared */ - public static function __set_state(array $attributes); + public function setShared(bool $shared); } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index 61c53270..e61eaedb 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -3,27 +3,28 @@ namespace Phalcon\Di; /** - * Phalcon\Di\ServiceProviderInterface + * Should be implemented by service providers, or such components, which + * register a service in the service container. * - * Should be implemented by service providers, or such components, - * which register a service in the service container. - * - * + * ```php * namespace Acme; * - * use Phalcon\DiInterface; + * use Phalcon\Di\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared('service', function () { - * // ... - * }); + * $di->setShared( + * 'service', + * function () { + * // ... + * } + * ); * } * } - * + * ``` */ interface ServiceProviderInterface { @@ -31,8 +32,8 @@ interface ServiceProviderInterface /** * Registers a service provider. * - * @param \Phalcon\DiInterface $di + * @param \Phalcon\Di\DiInterface $di */ - public function register(\Phalcon\DiInterface $di); + public function register(\Phalcon\Di\DiInterface $di); } diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php new file mode 100644 index 00000000..15c7d6b3 --- /dev/null +++ b/src/Phalcon/di/exception/ServiceResolutionException.php @@ -0,0 +1,11 @@ +false if an exception occurred and the operation was + * stopped by returning false in the exception handler. + * + * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. + * @return object|bool + */ + public function dispatch(): bool {} /** - * Sets the dependency injector + * Forwards the execution flow to another controller/action. * - * @param \Phalcon\DiInterface $dependencyInjector + * ```php + * $this->dispatcher->forward( + * [ + * "controller" => "posts", + * "action" => "index", + * ] + * ); + * ``` + * + * @throws \Phalcon\Exception + * @param array $forward */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function forward(array $forward) {} /** - * Returns the internal dependency injector + * Gets the latest dispatched action name * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getActionName(): string {} /** - * Sets the events manager + * Gets the default action suffix * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return string */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function getActionSuffix(): string {} /** - * Returns the internal event manager + * Returns the current method to be/executed in the dispatcher * - * @return \Phalcon\Events\ManagerInterface + * @return string */ - public function getEventsManager() {} + public function getActiveMethod(): string {} /** - * Sets the default action suffix + * Returns bound models from binder instance * - * @param string $actionSuffix + * ```php + * class UserController extends Controller + * { + * public function showAction(User $user) + * { + * // return array with $user + * $boundModels = $this->dispatcher->getBoundModels(); + * } + * } + * ``` + * + * @return array */ - public function setActionSuffix($actionSuffix) {} + public function getBoundModels(): array {} /** - * Gets the default action suffix + * Returns the default namespace * * @return string */ - public function getActionSuffix() {} + public function getDefaultNamespace(): string {} /** - * Sets the module where the controller is (only informative) + * Returns the internal dependency injector * - * @param string $moduleName + * @return \Phalcon\Di\DiInterface */ - public function setModuleName($moduleName) {} + public function getDI(): DiInterface {} /** - * Gets the module where the controller class is + * Returns the internal event manager * - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getModuleName() {} + public function getEventsManager(): ManagerInterface {} /** - * Sets the namespace where the controller class is + * Gets the default handler suffix * - * @param string $namespaceName + * @return string */ - public function setNamespaceName($namespaceName) {} + public function getHandlerSuffix(): string {} /** - * Gets a namespace to be prepended to the current handler name + * Gets model binder * - * @return string + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getNamespaceName() {} + public function getModelBinder(): ?BinderInterface {} /** - * Sets the default namespace + * Gets the module where the controller class is * - * @param string $namespaceName + * @return string */ - public function setDefaultNamespace($namespaceName) {} + public function getModuleName(): string {} /** - * Returns the default namespace + * Gets a namespace to be prepended to the current handler name * * @return string */ - public function getDefaultNamespace() {} + public function getNamespaceName(): string {} /** - * Sets the default action name + * Gets a param by its name or numeric index * - * @param string $actionName + * @param mixed $param + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setDefaultAction($actionName) {} + public function getParam($param, $filters = null, $defaultValue = null) {} /** - * Sets the action name to be dispatched + * Gets action params * - * @param string $actionName + * @return array */ - public function setActionName($actionName) {} + public function getParams(): array {} /** - * Gets the latest dispatched action name + * Check if a param exists * - * @return string + * @param mixed $param + * @return bool */ - public function getActionName() {} + public function hasParam($param): bool {} /** - * Sets action params to be dispatched + * Checks if the dispatch loop is finished or has more pendent + * controllers/tasks to dispatch * - * @param array $params + * @return bool */ - public function setParams($params) {} + public function isFinished(): bool {} /** - * Gets action params + * Sets the action name to be dispatched * - * @return array + * @param string $actionName */ - public function getParams() {} + public function setActionName(string $actionName) {} /** - * Set a param by its name or numeric index + * Sets the default action name * - * @param mixed $param - * @param mixed $value + * @param string $actionName */ - public function setParam($param, $value) {} + public function setDefaultAction(string $actionName) {} /** - * Gets a param by its name or numeric index + * Sets the default namespace * - * @param mixed $param - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @param string $namespaceName */ - public function getParam($param, $filters = null, $defaultValue = null) {} + public function setDefaultNamespace(string $namespaceName) {} /** - * Check if a param exists + * Sets the dependency injector * - * @param mixed $param - * @return bool + * @param \Phalcon\Di\DiInterface $container */ - public function hasParam($param) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns the current method to be/executed in the dispatcher + * Possible class name that will be located to dispatch the request * * @return string */ - public function getActiveMethod() {} + public function getHandlerClass(): string {} /** - * Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch + * Set a param by its name or numeric index * - * @return bool + * @param mixed $param + * @param mixed $value + */ + public function setParam($param, $value) {} + + /** + * Sets action params to be dispatched + * + * @param array $params */ - public function isFinished() {} + public function setParams(array $params) {} /** * Sets the latest returned value by an action manually @@ -265,130 +326,88 @@ public function isFinished() {} public function setReturnedValue($value) {} /** - * Returns value returned by the latest dispatched action + * Sets the default action suffix * - * @return mixed + * @param string $actionSuffix */ - public function getReturnedValue() {} + public function setActionSuffix(string $actionSuffix) {} /** - * Enable/Disable model binding during dispatch - * - * - * $di->set('dispatcher', function() { - * $dispatcher = new Dispatcher(); + * Sets the events manager * - * $dispatcher->setModelBinding(true, 'cache'); - * return $dispatcher; - * }); - * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + + /** + * Sets the default suffix for the handler * - * @deprecated 3.1.0 Use setModelBinder method - * @see Phalcon\Dispatcher::setModelBinder() - * @param bool $value - * @param mixed $cache - * @deprecated - * @return Dispatcher + * @param string $handlerSuffix */ - public function setModelBinding($value, $cache = null) {} + public function setHandlerSuffix(string $handlerSuffix) {} /** * Enable model binding during dispatch * - * - * $di->set('dispatcher', function() { - * $dispatcher = new Dispatcher(); + * ```php + * $di->set( + * 'dispatcher', + * function() { + * $dispatcher = new Dispatcher(); * - * $dispatcher->setModelBinder(new Binder(), 'cache'); - * return $dispatcher; - * }); - * + * $dispatcher->setModelBinder( + * new Binder(), + * 'cache' + * ); + * + * return $dispatcher; + * } + * ); + * ``` * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Dispatcher */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher {} /** - * Gets model binder + * Sets the module where the controller is (only informative) * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param string $moduleName */ - public function getModelBinder() {} + public function setModuleName(string $moduleName) {} /** - * Process the results of the router by calling into the appropriate controller action(s) - * including any routing data or injected parameters. - * - * @return object|false Returns the dispatched handler class (the Controller for Mvc dispatching or a Task - * for CLI dispatching) or false if an exception occurred and the operation was - * stopped by returning false in the exception handler. + * Sets the namespace where the controller class is * - * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. + * @param string $namespaceName */ - public function dispatch() {} + public function setNamespaceName(string $namespaceName) {} /** - * Forwards the execution flow to another controller/action. - * - * - * $this->dispatcher->forward( - * [ - * "controller" => "posts", - * "action" => "index", - * ] - * ); - * - * - * @param array forward + * Returns value returned by the latest dispatched action * - * @throws \Phalcon\Exception - * @param mixed $forward + * @return mixed */ - public function forward($forward) {} + public function getReturnedValue() {} /** * Check if the current executed action was forwarded by another one * * @return bool */ - public function wasForwarded() {} - - /** - * Possible class name that will be located to dispatch the request - * - * @return string - */ - public function getHandlerClass() {} - - /** - * @param mixed $handler - * @param string $actionMethod - * @param array $params - */ - public function callActionMethod($handler, $actionMethod, array $params = array()) {} + public function wasForwarded(): bool {} /** - * Returns bound models from binder instance - * - * - * class UserController extends Controller - * { - * public function showAction(User $user) - * { - * $boundModels = $this->dispatcher->getBoundModels(); // return array with $user - * } - * } - * - * - * @return array + * Set empty properties to their defaults (where defaults are available) */ - public function getBoundModels() {} + protected function resolveEmptyProperties() {} /** - * Set empty properties to their defaults (where defaults are available) + * @param string $input + * @return string */ - protected function _resolveEmptyProperties() {} + protected function toCamelCase(string $input): string {} } diff --git a/src/Phalcon/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php similarity index 63% rename from src/Phalcon/DispatcherInterface.php rename to src/Phalcon/dispatcher/DispatcherInterface.php index c7858384..e28b1de8 100644 --- a/src/Phalcon/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -1,136 +1,149 @@ isCancelable()) { + * $event->stop(); + * } + * ``` + * + * @return bool */ - public function setData($data = null) {} + public function isCancelable(): bool {} /** - * Sets event type. + * Check whether the event is currently stopped. * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType($type) {} + public function isStopped(): bool {} /** - * Stops the event preventing propagation. - * - * - * if ($event->isCancelable()) { - * $event->stop(); - * } - * + * Sets event data. * + * @param mixed $data * @return EventInterface */ - public function stop() {} + public function setData($data = null): EventInterface {} /** - * Check whether the event is currently stopped. + * Sets event type. * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped() {} + public function setType(string $type): EventInterface {} /** - * Check whether the event is cancelable. + * Stops the event preventing propagation. * - * + * ```php * if ($event->isCancelable()) { * $event->stop(); * } - * + * ``` * - * @return bool + * @return EventInterface */ - public function isCancelable() {} + public function stop(): EventInterface {} } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index de3427cc..92f60516 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -18,47 +18,47 @@ interface EventInterface public function getData(); /** - * Sets event data + * Gets event type * - * @param mixed $data - * @return EventInterface + * @return mixed */ - public function setData($data = null); + public function getType(); /** - * Gets event type + * Check whether the event is cancelable * - * @return mixed + * @return bool */ - public function getType(); + public function isCancelable(): bool; /** - * Sets event type + * Check whether the event is currently stopped * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType($type); + public function isStopped(): bool; /** - * Stops the event preventing propagation + * Sets event data * + * @param mixed $data * @return EventInterface */ - public function stop(); + public function setData($data = null): EventInterface; /** - * Check whether the event is currently stopped + * Sets event type * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped(); + public function setType(string $type): EventInterface; /** - * Check whether the event is cancelable + * Stops the event preventing propagation * - * @return bool + * @return EventInterface */ - public function isCancelable(); + public function stop(): EventInterface; } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index 903a9bb8..a7fcff43 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -5,23 +5,24 @@ /** * Phalcon\Events\EventsAwareInterface * - * This interface must for those classes that accept an EventsManager and dispatch events + * This interface must for those classes that accept an EventsManager and + * dispatch events */ interface EventsAwareInterface { /** - * Sets the events manager + * Returns the internal event manager * - * @param ManagerInterface $eventsManager + * @return ManagerInterface */ - public function setEventsManager(ManagerInterface $eventsManager); + public function getEventsManager(): ManagerInterface; /** - * Returns the internal event manager + * Sets the events manager * - * @return ManagerInterface + * @param ManagerInterface $eventsManager */ - public function getEventsManager(); + public function setEventsManager(ManagerInterface $eventsManager); } diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index d1227745..39b3fb35 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -5,23 +5,31 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, - * the normal flow of operation. With the EventsManager the developer can create hooks or - * plugins that will offer monitoring of data, manipulation, conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if + * needed, the normal flow of operation. With the EventsManager the developer + * can create hooks or plugins that will offer monitoring of data, manipulation, + * conditional execution and much more. */ class Manager implements \Phalcon\Events\ManagerInterface { - protected $_events = null; + const DEFAULT_PRIORITY = 100; + /** + * @var bool + */ + protected $collect = false; - protected $_collect = false; + /** + * @var bool + */ + protected $enablePriorities = false; - protected $_enablePriorities = false; + protected $events = null; - protected $_responses; + protected $responses; /** @@ -31,83 +39,85 @@ class Manager implements \Phalcon\Events\ManagerInterface * @param object|callable $handler * @param int $priority */ - public function attach($eventType, $handler, $priority = 100) {} + public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) {} /** - * Detach the listener from the events manager + * Returns if priorities are enabled * - * @param string $eventType - * @param object $handler + * @return bool */ - public function detach($eventType, $handler) {} + public function arePrioritiesEnabled(): bool {} /** - * Set if priorities are enabled in the EventsManager + * Tells the event manager if it needs to collect all the responses returned + * by every registered listener in a single fire * - * @param bool $enablePriorities + * @param bool $collect */ - public function enablePriorities($enablePriorities) {} + public function collectResponses(bool $collect) {} /** - * Returns if priorities are enabled + * Detach the listener from the events manager * - * @return bool + * @param string $eventType + * @param object $handler */ - public function arePrioritiesEnabled() {} + public function detach(string $eventType, $handler) {} /** - * Tells the event manager if it needs to collect all the responses returned by every - * registered listener in a single fire + * Removes all events from the EventsManager * - * @param bool $collect + * @param string $type */ - public function collectResponses($collect) {} + public function detachAll(string $type = null) {} /** - * Check if the events manager is collecting all all the responses returned by every - * registered listener in a single fire + * Set if priorities are enabled in the EventsManager * - * @return bool + * @param bool $enablePriorities */ - public function isCollecting() {} + public function enablePriorities(bool $enablePriorities) {} /** - * Returns all the responses returned by every handler executed by the last 'fire' executed + * Fires an event in the events manager causing the active listeners to be + * notified about it * - * @return array - */ - public function getResponses() {} - - /** - * Removes all events from the EventsManager + * ```php + * $eventsManager->fire("db", $connection); + * ``` * - * @param string $type + * @param string $eventType + * @param object $source + * @param mixed $data + * @param bool $cancelable + * @return mixed */ - public function detachAll($type = null) {} + public function fire(string $eventType, $source, $data = null, bool $cancelable = true) {} /** * Internal handler to call a queue of events * - * @param \SplPriorityQueue|array $queue - * @param \Phalcon\Events\Event $event + * @param \SplPriorityQueue $queue + * @param EventInterface $event * @return mixed */ - public final function fireQueue($queue, EventInterface $event) {} + final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) {} /** - * Fires an event in the events manager causing the active listeners to be notified about it + * Returns all the attached listeners of a certain type * - * - * $eventsManager->fire("db", $connection); - * + * @param string $type + * @return array + */ + public function getListeners(string $type): array {} + + /** + * Returns all the responses returned by every handler executed by the last + * 'fire' executed * - * @param string $eventType - * @param object $source - * @param mixed $data - * @param boolean $cancelable - * @return mixed + * @return array */ - public function fire($eventType, $source, $data = null, $cancelable = true) {} + public function getResponses(): array {} /** * Check whether certain type of event has listeners @@ -115,14 +125,14 @@ public function fire($eventType, $source, $data = null, $cancelable = true) {} * @param string $type * @return bool */ - public function hasListeners($type) {} + public function hasListeners(string $type): bool {} /** - * Returns all the attached listeners of a certain type + * Check if the events manager is collecting all all the responses returned + * by every registered listener in a single fire * - * @param string $type - * @return array + * @return bool */ - public function getListeners($type) {} + public function isCollecting(): bool {} } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 0598a8c4..048672ab 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -5,9 +5,10 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, - * the normal flow of operation. With the EventsManager the developer can create hooks or - * plugins that will offer monitoring of data, manipulation, conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if + * needed, the normal flow of operation. With the EventsManager the developer + * can create hooks or plugins that will offer monitoring of data, manipulation, + * conditional execution and much more. */ interface ManagerInterface { @@ -18,7 +19,7 @@ interface ManagerInterface * @param string $eventType * @param object|callable $handler */ - public function attach($eventType, $handler); + public function attach(string $eventType, $handler); /** * Detach the listener from the events manager @@ -26,24 +27,25 @@ public function attach($eventType, $handler); * @param string $eventType * @param object $handler */ - public function detach($eventType, $handler); + public function detach(string $eventType, $handler); /** * Removes all events from the EventsManager * * @param string $type */ - public function detachAll($type = null); + public function detachAll(string $type = null); /** - * Fires an event in the events manager causing the active listeners to be notified about it + * Fires an event in the events manager causing the active listeners to be + * notified about it * * @param string $eventType * @param object $source * @param mixed $data * @return mixed */ - public function fire($eventType, $source, $data = null); + public function fire(string $eventType, $source, $data = null); /** * Returns all the attached listeners of a certain type @@ -51,6 +53,14 @@ public function fire($eventType, $source, $data = null); * @param string $type * @return array */ - public function getListeners($type); + public function getListeners(string $type): array; + + /** + * Check whether certain type of event has listeners + * + * @param string $type + * @return bool + */ + public function hasListeners(string $type): bool; } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php new file mode 100644 index 00000000..b54cb01b --- /dev/null +++ b/src/Phalcon/factory/AbstractFactory.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AbstractFactory +{ + /** + * @var array + */ + protected $mapper = array(); + + /** + * @var array + */ + protected $services = array(); + + + /** + * Checks if a service exists and throws an exception + * + * @param string $name + */ + protected function checkService(string $name) {} + + /** + * Checks the config if it is a valid object + * + * @param mixed $config + * @return array + */ + protected function checkConfig($config): array {} + + /** + * Returns the adapters for the factory + * + * @return array + */ + abstract protected function getAdapters(): array; + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + protected function init(array $services = array()) {} + +} diff --git a/src/Phalcon/factory/Exception.php b/src/Phalcon/factory/Exception.php index 25a41d41..15f9cdc3 100644 --- a/src/Phalcon/factory/Exception.php +++ b/src/Phalcon/factory/Exception.php @@ -3,9 +3,12 @@ namespace Phalcon\Factory; /** - * Phalcon\Factory\Exception + * This file is part of the Phalcon Framework. * - * Exceptions thrown in Phalcon\Factory will use this class + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/filter/Filter.php b/src/Phalcon/filter/Filter.php new file mode 100644 index 00000000..ad2a7516 --- /dev/null +++ b/src/Phalcon/filter/Filter.php @@ -0,0 +1,154 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class FilterFactory +{ + + /** + * Returns a Locator object with all the helpers defined in anonynous + * functions + * + * @return LocatorInterface + */ + public function newInstance(): LocatorInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php new file mode 100644 index 00000000..067ba31c --- /dev/null +++ b/src/Phalcon/filter/FilterInterface.php @@ -0,0 +1,21 @@ + + */ + protected $cache; + + /** + * Default access + * + * @var int + */ + protected $defaultAccess = Enum::DENY; + + /** + * Events manager + * + * @var mixed + */ + protected $eventsManager; + + /** + * Internal cache for caching access during request time + * + * @var mixed + */ + protected $internalCache; + + /** + * Anonymous function for getting user identity - this function must + * return string, array or object implementing Phalcon\Acl\RoleAware + * + * @var mixed + */ + protected $roleCallback; + + + /** + * Storing active identity object implementing Phalcon/Acl/RoleAware + */ + public function getActiveIdentity() {} + + /** + * Storing active user role + */ + public function getActiveRole() {} + + /** + * Should role always be resolved using role callback or just once? + * + * @param bool $alwaysResolvingRole + */ + public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} + + /** + * Default access + * + * @return int + */ + public function getDefaultAccess(): int {} + + /** + * Returns the internal event manager + * + * @return \Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ManagerInterface {} + + /** + * Gets role callback to fetch role name + * + * @return \Closure + */ + public function getRoleCallback(): Closure {} + + /** + * Gets always resolving role option + * + * @return bool + */ + public function isAlwaysResolvingRole(): bool {} + + /** + * Sets the cache adapter + * + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return AdapterInterface + */ + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface {} + + /** + * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) + * + * @param int $defaultAccess + * @return AdapterInterface + */ + public function setDefaultAccess(int $defaultAccess): AdapterInterface {} + + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return AdapterInterface + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AdapterInterface {} + + /** + * Sets role callback to fetch role name + * + * @param mixed $callback + * @return AdapterInterface + */ + public function setRoleCallback($callback): AdapterInterface {} + + /** + * @param \Phalcon\Di\DiInterface $container + */ + protected function callRoleCallback(\Phalcon\Di\DiInterface $container) {} + + /** + * Gets access from cache + * + * @param string $key + * @param array $originalValues + * @param string $roleCacheKey + * @return bool|null + */ + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + + /** + * Handles a user exception + * + * @param \Exception $exception + */ + protected function handleException(\Exception $exception) {} + + /** + * Fires event or throwing exception + * + * @param mixed $role + * @param string $actionName + * @param string $controllerName + * @param bool $access + */ + protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) {} + + /** + * Saves access in cache and internal cache + * + * @param string $key + * @param bool $access + */ + protected function saveAccessInCache(string $key, bool $access) {} + + /** + * Throws an internal exception + * + * @param string $message + * @param int $exceptionCode + * @return bool + */ + protected function throwFirewallException(string $message, int $exceptionCode = 0): bool {} + +} diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php new file mode 100644 index 00000000..7ac99290 --- /dev/null +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -0,0 +1,174 @@ +success("The record was successfully deleted"); + * $flash->error("Cannot open the file"); + * ``` + */ +abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\Di\InjectionAwareInterface +{ + /** + * @var bool + */ + protected $autoescape = true; + + /** + * @var bool + */ + protected $automaticHtml = true; + + /** + * @var array + */ + protected $cssClasses = array(); + + /** + * @var string + */ + protected $customTemplate = ''; + + + protected $container = null; + + + protected $escaperService = null; + + /** + * @var bool + */ + protected $implicitFlush = true; + + + protected $messages = array(); + + + /** + * Phalcon\Flash constructor + * + * @param mixed $cssClasses + */ + public function __construct($cssClasses = null) {} + + /** + * Clears accumulated messages when implicit flush is disabled + */ + public function clear() {} + + /** + * Shows a HTML error message + * + * ```php + * $flash->error("This is an error"); + * ``` + * + * @param string $message + * @return string + */ + public function error(string $message): string {} + + /** + * Returns the autoescape mode in generated html + * + * @return bool + */ + public function getAutoescape(): bool {} + + /** + * Returns the custom template set + * + * @return string + */ + public function getCustomTemplate(): string {} + + /** + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the Escaper Service + * + * @return \Phalcon\Escaper\EscaperInterface + */ + public function getEscaperService(): EscaperInterface {} + + /** + * Shows a HTML notice/information message + * + * ```php + * $flash->notice("This is an information"); + * ``` + * + * @param string $message + * @return string + */ + public function notice(string $message): string {} + + /** + * Set the autoescape mode in generated html + * + * @param bool $autoescape + * @return Flash + */ + public function setAutoescape(bool $autoescape): Flash {} + + /** + * Set if the output must be implicitly formatted with HTML + * + * @param bool $automaticHtml + * @return FlashInterface + */ + public function setAutomaticHtml(bool $automaticHtml): FlashInterface {} + + /** + * Set an array with CSS classes to format the messages + * + * @param array $cssClasses + * @return FlashInterface + */ + public function setCssClasses(array $cssClasses): FlashInterface {} + + /** + * Set an custom template for showing the messages + * + * @param string $customTemplate + * @return FlashInterface + */ + public function setCustomTemplate(string $customTemplate): FlashInterface {} + + /** + * Sets the dependency injector + * + * @param \Phalcon\Di\DiInterface $container + * @return FlashInterface + */ + public function setDI(\Phalcon\Di\DiInterface $container): FlashInterface {} + + /** + * Sets the Escaper Service + * + * @param \Phalcon\Escaper\EscaperInterface $escaperService + * @return FlashInterface + */ + public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface {} + + /** + * Set whether the output must be implicitly flushed to the output or + * returned as string + * + * @param bool $implicitFlush + * @return FlashInterface + */ + public function setImplicitFlush(bool $implicitFlush): FlashInterface {} + + /** + * Shows a HTML success message + * + * ```php + * $flash->success("The process was finished successfully"); + * ``` + * + * @param string $message + * @return string + */ + public function success(string $message): string {} + + /** + * Outputs a message formatting it with HTML + * + * ```php + * $flash->outputMessage("error", $message); + * ``` + * + * @param string $type + * @param string|array $message + * @return string|void + */ + public function outputMessage(string $type, $message) {} + + /** + * Shows a HTML warning message + * + * ```php + * $flash->warning("Hey, this is important"); + * ``` + * + * @param string $message + * @return string + */ + public function warning(string $message): string {} + + /** + * @param string $cssClassses + * @return string + */ + private function getTemplate(string $cssClassses): string {} + + /** + * Returns the message escaped if the autoEscape is true, otherwise the + * original message is returned + * + * @param string $message + * @return string + */ + private function prepareEscapedMessage(string $message): string {} + + /** + * Prepares the HTML output for the message. If automaticHtml is not set + * then the original message is returned + * + * @param string $type + * @param string $message + * @return string + */ + private function prepareHtmlMessage(string $type, string $message): string {} + +} diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index bfe09e23..fda928b6 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -3,11 +3,10 @@ namespace Phalcon\Flash; /** - * Phalcon\Flash\Direct - * - * This is a variant of the Phalcon\Flash that immediately outputs any message passed to it + * This is a variant of the Phalcon\Flash that immediately outputs any message + * passed to it */ -class Direct extends \Phalcon\Flash +class Direct extends \Phalcon\Flash\AbstractFlash { /** @@ -17,13 +16,13 @@ class Direct extends \Phalcon\Flash * @param mixed $message * @return string */ - public function message($type, $message) {} + public function message(string $type, $message): string {} /** * Prints the messages accumulated in the flasher * * @param bool $remove */ - public function output($remove = true) {} + public function output(bool $remove = true) {} } diff --git a/src/Phalcon/flash/Exception.php b/src/Phalcon/flash/Exception.php index fece45ed..6a123e85 100644 --- a/src/Phalcon/flash/Exception.php +++ b/src/Phalcon/flash/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Flash; /** - * Phalcon\Flash\Exception - * * Exceptions thrown in Phalcon\Flash will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php new file mode 100644 index 00000000..8faa3dea --- /dev/null +++ b/src/Phalcon/flash/FlashInterface.php @@ -0,0 +1,53 @@ + + * ```php * if ($form->isValid($_POST) == false) { - * // Get messages separated by the item name - * // $messages is an array of Group object - * $messages = $form->getMessages(true); - * - * foreach ($messages as $message) { - * echo $message, "
"; - * } - * - * // Default behavior. - * // $messages is a Group object * $messages = $form->getMessages(); * * foreach ($messages as $message) { * echo $message, "
"; * } * } - * + * ``` * - * @param bool $byItemName - * @return array|\Phalcon\Validation\Message\Group + * @return array|\Phalcon\Messages\Messages */ - public function getMessages($byItemName = false) {} + public function getMessages() {} /** * Returns the messages generated for a specific element * * @param string $name - * @return \Phalcon\Validation\Message\Group + * @return \Phalcon\Messages\Messages */ - public function getMessagesFor($name) {} + public function getMessagesFor(string $name): Messages {} /** - * Check if messages were generated for a specific element + * Returns the value of an option if present * - * @param string $name - * @return bool + * @param string $option + * @param mixed $defaultValue + * @return mixed */ - public function hasMessagesFor($name) {} + public function getUserOption(string $option, $defaultValue = null) {} /** - * Adds an element to the form + * Returns the options for the element * - * @param \Phalcon\Forms\ElementInterface $element - * @param string $position - * @param bool $type - * @return Form + * @return array */ - public function add(\Phalcon\Forms\ElementInterface $element, $position = null, $type = null) {} + public function getUserOptions(): array {} /** - * Renders a specific item in the form + * Gets a value from the internal related entity or from the default value * * @param string $name - * @param array $attributes - * @return string + * @return mixed|null */ - public function render($name, $attributes = null) {} + public function getValue(string $name): ? {} /** - * Returns an element added to the form by its name + * Check if the form contains an element * * @param string $name - * @return \Phalcon\Forms\ElementInterface + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Generate the label of an element added to the form including HTML + * Check if messages were generated for a specific element * * @param string $name - * @param array $attributes - * @return string + * @return bool */ - public function label($name, array $attributes = null) {} + public function hasMessagesFor(string $name): bool {} /** - * Returns a label for an element + * Validates the form * - * @param string $name - * @return string + * @param array $data + * @param object $entity + * @return bool */ - public function getLabel($name) {} + public function isValid($data = null, $entity = null): bool {} /** - * Gets a value from the internal related entity or from the default value + * Returns the current position/key in the iterator + * + * @return int + */ + public function key(): int {} + + /** + * Generate the label of an element added to the form including HTML * * @param string $name - * @return mixed|null + * @param array $attributes + * @return string */ - public function getValue($name) {} + public function label(string $name, array $attributes = null): string {} /** - * Check if the form contains an element + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Renders a specific item in the form * * @param string $name - * @return bool + * @param array $attributes + * @return string */ - public function has($name) {} + public function render(string $name, array $attributes = array()): string {} /** * Removes an element from the form @@ -252,52 +240,66 @@ public function has($name) {} * @param string $name * @return bool */ - public function remove($name) {} + public function remove(string $name): bool {} /** - * Clears every element in the form to its default value + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Sets the form's action * - * @param array $fields + * @param string $action * @return Form */ - public function clear($fields = null) {} + public function setAction(string $action): Form {} /** - * Returns the number of elements in the form + * Sets the entity related to the model * - * @return int + * @param object $entity + * @return Form */ - public function count() {} + public function setEntity($entity): Form {} /** - * Rewinds the internal iterator + * Sets an option for the form + * + * @param string $option + * @param mixed $value + * @return Form */ - public function rewind() {} + public function setUserOption(string $option, $value): Form {} /** - * Returns the current element in the iterator + * Sets options for the element * - * @return bool|\Phalcon\Forms\ElementInterface + * @param array $options + * @return Form */ - public function current() {} + public function setUserOptions(array $options): Form {} /** - * Returns the current position/key in the iterator + * Check if the current element in the iterator is valid * - * @return int + * @return bool */ - public function key() {} + public function valid(): bool {} /** - * Moves the internal iteration pointer to the next position + * Get Form attributes collection + * + * @return \Phalcon\Html\Attributes */ - public function next() {} + public function getAttributes(): Attributes {} /** - * Check if the current element in the iterator is valid + * Set form attributes collection * - * @return bool + * @param \Phalcon\Html\Attributes $attributes + * @return \Phalcon\Html\Attributes\AttributesInterface */ - public function valid() {} + public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface {} } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index 7a74031c..df4e51a2 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -3,12 +3,12 @@ namespace Phalcon\Forms; /** - * Phalcon\Forms\Manager + * Forms Manager */ class Manager { - protected $_forms; + protected $forms = array(); /** @@ -18,7 +18,7 @@ class Manager * @param object $entity * @return Form */ - public function create($name, $entity = null) {} + public function create(string $name, $entity = null): Form {} /** * Returns a form by its name @@ -26,7 +26,7 @@ public function create($name, $entity = null) {} * @param string $name * @return Form */ - public function get($name) {} + public function get(string $name): Form {} /** * Checks if a form is registered in the forms manager @@ -34,7 +34,7 @@ public function get($name) {} * @param string $name * @return bool */ - public function has($name) {} + public function has(string $name): bool {} /** * Registers a form in the Forms Manager @@ -43,6 +43,6 @@ public function has($name) {} * @param Form $form * @return FormManager */ - public function set($name, Form $form) {} + public function set(string $name, Form $form): FormManager {} } diff --git a/src/Phalcon/forms/Element.php b/src/Phalcon/forms/element/AbstractElement.php similarity index 58% rename from src/Phalcon/forms/Element.php rename to src/Phalcon/forms/element/AbstractElement.php index 6c832bf0..5a9385cd 100644 --- a/src/Phalcon/forms/Element.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -1,226 +1,227 @@ %label%"; + private $template = '
%label%
'; + + + /** + * Crumb separator + * + * @return string + */ + public function getSeparator(): string {} + + /** + * Crumb separator + * + * @param string $separator + */ + public function setSeparator(string $separator) {} /** * Adds a new crumb. * - * + * ```php * // Adding a crumb with a link * $breadcrumbs->add("Home", "/"); * * // Adding a crumb without a link (normally the last one) * $breadcrumbs->add("Users"); - * + * ``` + * + * @param string $label + * @param string $link + * @return Breadcrumbs */ - public function add(string $label, string $link = "") : Breadcrumbs - { - } + public function add(string $label, string $link = ''): Breadcrumbs {} /** - * Clears the crumbx + * Clears the crumbs * - * + * ```php * $breadcrumbs->clear() - * + * ``` */ - public function clear() : void - { - } + public function clear() {} /** * Removes crumb by url. * - * + * ```php * $breadcrumbs->remove("/admin/user/create"); * * // remove a crumb without an url (last link) * $breadcrumbs->remove(); - * + * ``` + * + * @param string $link */ - public function remove(string $link) : void - { - } + public function remove(string $link) {} /** * Renders and outputs breadcrumbs based on previously set template. * - * - * // Php Engine + * ```php * echo $breadcrumbs->render(); - * + * ``` + * + * @return string */ - public function render() : string - { - } + public function render(): string {} /** * Returns the internal breadcrumbs array + * + * @return array */ - public function toArray() : array - { - } + public function toArray(): array {} + } diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php index 1a22c6d9..2a33e680 100644 --- a/src/Phalcon/html/Exception.php +++ b/src/Phalcon/html/Exception.php @@ -6,7 +6,6 @@ * Phalcon\Html\Tag\Exception * * Exceptions thrown in Phalcon\Html\Tag will use this class - * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/html/Tag.php b/src/Phalcon/html/Tag.php index 864cb02b..ee523d93 100644 --- a/src/Phalcon/html/Tag.php +++ b/src/Phalcon/html/Tag.php @@ -2,1063 +2,1181 @@ namespace Phalcon\Html; -use Phalcon\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Escaper; -use Phalcon\EscaperInterface; -use Phalcon\Helper\Arr; -use Phalcon\Html\Exception; -use Phalcon\UrlInterface; - /** * Phalcon\Html\Tag * - * Phalcon\Tag is designed to simplify building of HTML tags. It provides a set - * of helpers to dynamically generate HTML. + * Phalcon\Html\Tag is designed to simplify building of HTML tags. It provides a + * set of helpers to dynamically generate HTML. */ -class Tag implements InjectionAwareInterface +class Tag implements \Phalcon\Di\InjectionAwareInterface { - /** - * @var - */ - protected $container; - - /** - * @var array - */ - private $append = []; - - /** - * @var int - */ - private $docType = 5; // HTML5 - - /** - * @var - */ - private $escaper; - - /** - * @var array - */ - private $prepend = []; - - /** - * @var string - */ - private $separator = ""; - - /** - * @var string - */ - private $title = ""; - - /** - * @var array - */ - private $values = []; - - /** - * @var - */ - private $url; - - /** - * Constants - */ - const HTML32 = 1; - const HTML401_STRICT = 2; - const HTML401_TRANSITIONAL = 3; - const HTML401_FRAMESET = 4; - const HTML5 = 5; - const XHTML10_STRICT = 6; - const XHTML10_TRANSITIONAL = 7; - const XHTML10_FRAMESET = 8; - const XHTML11 = 9; - const XHTML20 = 10; - const XHTML5 = 11; - - /** - * Appends a text to current document title - */ - public function appendTitle(array $title) : Tag - { - } - - /** - * Builds a HTML input[type="button"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->button('Click Me') - * - * - * Volt syntax: - * - * {{ button('Click Me) }} - * - */ - public function button(string $name, array $parameters = []) : string - { - } - - /** - * Resets the request and internal values to avoid those fields will have - * any default value. - */ - public function clear() : void - { - } - - /** - * Builds a HTML tag - * - * Parameters - * `onlyStart` Only process the start of th element - * `selfClose` It is a self close element - * `useEol` Append PHP_EOL at the end - * - */ - public function element(string $tag, array $parameters = []) : string - { - } - - /** - * Builds the closing tag of an html element - * - * Parameters - * `useEol` Append PHP_EOL at the end - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', + /** + * Constants + */ + const HTML32 = 1; + + + const HTML401_STRICT = 2; + + + const HTML401_TRANSITIONAL = 3; + + + const HTML401_FRAMESET = 4; + + + const HTML5 = 5; + + + const XHTML10_STRICT = 6; + + + const XHTML10_TRANSITIONAL = 7; + + + const XHTML10_FRAMESET = 8; + + + const XHTML11 = 9; + + + const XHTML20 = 10; + + + const XHTML5 = 11; + + /** + * @var DiInterface + */ + protected $container; + + /** + * @var array + */ + private $append = array(); + + /** + * @var int + */ + private $docType = 5; + + /** + * @var + */ + private $escaper; + + /** + * @var array + */ + private $prepend = array(); + + /** + * @var string + */ + private $separator = ''; + + /** + * @var string + */ + private $title = ''; + + /** + * @var array + */ + private $values = array(); + + /** + * @var + */ + private $url; + + + /** + * Constructor + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param \Phalcon\Url\UrlInterface $url + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Url\UrlInterface $url = null) {} + + /** + * Appends a text to current document title + * + * @param mixed $title + * @return Tag + */ + public function appendTitle($title): Tag {} + + /** + * Builds a HTML input[type="button"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->button('Click Me'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ button('Click Me') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function button(string $name, array $parameters = array()): string {} + + /** + * Resets the request and internal values to avoid those fields will have + * any default value. + */ + public function clear() {} + + /** + * Builds a HTML tag + * + * Parameters + * `onlyStart` Only process the start of th element + * `selfClose` It is a self close element + * `useEol` Append PHP_EOL at the end + * + * @param string $tag + * @param array $parameters + * @return string + */ + public function element(string $tag, array $parameters = array()): string {} + + /** + * Builds the closing tag of an html element + * + * Parameters + * `useEol` Append PHP_EOL at the end + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', * ] * ); // - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', - * 'useEol' => true, - * ] - * ); // '' . PHP_EOL - * - * - */ - public function elementClose(string $tag, array $parameters = []) : string - { - } - - /** - * Returns the closing tag of a form element - */ - public function endForm(bool $eol = true) : string - { - } - - /** - * Builds a HTML FORM tag - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->form('posts/save'); - * - * echo $tag->form( - * 'posts/save', - * [ - * "method" => "post", - * ] - * ); - * - * - * Volt syntax: - * - * {{ form('posts/save') }} - * {{ form('posts/save', ['method': 'post') }} - * - */ - public function form(string $action, array $parameters = []) : string - { - } - - /** - * Converts text to URL-friendly strings - * - * Parameters - * `text` The text to be processed - * `separator` Separator to use (default '-') - * `lowercase` Convert to lowercase - * `replace` - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->friendlyTitle( - * [ - * 'text' => 'These are big important news', - * 'separator' => '-', - * ] - * ); - * - * - * Volt Syntax: - * - * {{ friendly_title(['text': 'These are big important news', 'separator': '-']) }} - * - */ - public function friendlyTitle(string $text, array $parameters = []) : string - { - } - - /** - * Returns the internal dependency injector - */ - public function getDI() : DiInterface - { - } - - /** - * Get the document type declaration of content. If the docType has not - * been set properly, XHTML5 is returned - */ - public function getDocType() : string - { - } - - /** - * Gets the current document title. The title will be automatically escaped. - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->getTitle(); // Hello World from Phalcon - * echo $tag->getTitle(false); // World from Phalcon - * echo $tag->getTitle(true, false); // Hello World - * echo $tag->getTitle(false, false); // World - * - * - * Volt syntax: - * - * {{ get_title() }} - * - */ - public function getTitle(bool $prepend = true, bool $append = true) : string - { - } - - /** - * Gets the current document title separator - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->getTitleSeparator(); - * - * - * Volt syntax: - * - * {{ get_title_separator() }} - * - */ - public function getTitleSeparator() : string - { - } - - /** - * Every helper calls this function to check whether a component has a predefined - * value using `setAttribute` or value from $_POST - */ - public function getValue(string $name, array $parameters = []) { - } - - /** - * Check if a helper has a default value set using `setAttribute()` or - * value from $_POST - */ - public function hasValue(string $name) : bool - { - } - - /** - * Builds HTML IMG tags - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->image('img/bg.png'); - * - * echo $tag->image( - * 'img/photo.jpg', - * [ - * 'alt' => 'Some Photo', - * ] - * ); - * - * echo $tag->image( - * 'http://static.mywebsite.com/img/bg.png', - * [ - * 'local' => false, - * ] - * ); - * - * - * Volt Syntax: - * - * {{ image('img/bg.png') }} - * {{ image('img/photo.jpg', ['alt': 'Some Photo') }} - * {{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }} - * - */ - public function image(string $url = "", array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="check"] tag - * - * - * echo $tag->inputCheckbox( - * [ - * 'name' => 'terms, - * 'value' => 'Y', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_checkbox(['name': 'terms, 'value': 'Y']) }} - * - * - * @param array parameters - */ - public function inputCheckbox(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='color'] tag - */ - public function inputColor(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='date'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDate( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDate(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='datetime'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTime( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date_time(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDateTime(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='datetime-local'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTimeLocal( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDateTimeLocal(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='email'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputEmail( - * [ - * 'name' => 'email', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_email(['name': 'email']); - * - */ - public function inputEmail(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='file'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputFile( - * [ - * 'name' => 'file', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_file(['name': 'file']); - * - */ - public function inputFile(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='hidden'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputHidden( - * [ - * 'name' => 'my-field', - * 'value' => 'mike', - * ] - * ); - * - */ - public function inputHidden(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="image"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->inputImage( - * [ - * 'src' => '/img/button.png', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_image(['src': '/img/button.png']) }} - * - */ - public function inputImage(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='month'] tag - */ - public function inputMonth(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='number'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->numericField( - * [ - * 'name' => 'price', - * 'min' => '1', - * 'max' => '5', - * ] - * ); - * - */ - public function inputNumeric(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='password'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->passwordField( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * - */ - public function inputPassword(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="radio"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputRadio( - * [ - * 'name' => 'weather', - * 'value" => 'hot', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_radio(['name': 'weather', 'value": 'hot']) }} - * - */ - public function inputRadio(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='range'] tag - */ - public function inputRange(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='search'] tag - */ - public function inputSearch(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='tel'] tag - */ - public function inputTel(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='text'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputText( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * - */ - public function inputText(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='time'] tag - */ - public function inputTime(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='url'] tag - */ - public function inputUrl(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='week'] tag - */ - public function inputWeek(string $name, array $parameters = []) : string - { - } - - /** - * Builds a script[type="javascript"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->javascript( - * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', - * ['local' => false] - * ); - * echo $tag->javascript('javascript/jquery.js'); - * - * - * Volt syntax: - * - * {{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }} - * {{ javascript('javascript/jquery.js') }} - * - */ - public function javascript(string $url, array $parameters = []) : string - { - } - - /** - * Builds a HTML A tag using framework conventions - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->link('signup/register', 'Register Here!'); - * - * echo $tag->link( - * 'signup/register', - * 'Register Here!', - * [ - * 'class' => 'btn-primary', - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->linkTo( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * 'target' => '_new' - * ] - * ); - * - * - */ - public function link(string $url, string $text = "", array $parameters = []) : string - { - } - - /** - * Prepends a text to current document title - */ - public function prependTitle(array $title) : Tag - { - } - - /** - * Renders the title with title tags. The title is automaticall escaped - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->renderTitle(); // Hello World from Phalcon - * echo $tag->renderTitle(false); // World from Phalcon - * echo $tag->renderTitle(true, false); // Hello World - * echo $tag->renderTitle(false, false); // World - * - * - * - * {{ render_title() }} - * - */ - public function renderTitle(bool $prepend = true, bool $append = true) : string - { - } - - /** - * Builds a HTML input[type="reset"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->reset('Reset') - * - * - * Volt syntax: - * - * {{ reset('Save') }} - * - */ - public function reset(string $name, array $parameters = []) : string - { - } - - /** - * Builds a select element. It accepts an array or a resultset from - * a Phalcon\Mvc\Model - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Status...', - * ], - * [ - * 'A' => 'Active', - * 'I' => 'Inactive', - * ] - * ); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Type...', - * 'using' => [ - * 'id, - * 'name', - * ], - * ], - * Robots::find( - * [ - * 'conditions' => 'type = :type:', - * 'bind' => [ - * 'type' => 'mechanical', - * ] - * ] - * ) - * ); - * - * - * - * @param array parameters - * @param array data - */ - public function select(string $name, array $parameters = [], $data = null) : string - { - } - - /** - * Assigns default values to generated tags by helpers - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute('name', 'peter'); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * - */ - public function setAttribute(string $name, $value) : Tag - { - } - - /** - * Assigns default values to generated tags by helpers - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute( - * [ - * 'name' => 'peter', - * ] - * ); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * - */ - public function setAttributes(array $values, bool $merge = false) : Tag - { - } - - /** - * Sets the dependency injector - */ - public function setDI(DiInterface $container) : void - { - } - - /** - * Set the document type of content - * - * @param int doctype A valid doctype for the content - * - * @return - */ - public function setDocType(int $doctype) : Tag - { - } - - /** - * Set the title separator of view content - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag->setTitle('Phalcon Framework'); - * - */ - public function setTitle(string $title) : Tag - { - } - - /** - * Set the title separator of view content - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->setTitleSeparator('-'); - * - */ - public function setTitleSeparator(string $separator) : Tag - { - } - - /** - * Builds a LINK[rel="stylesheet"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->stylesheet( - * 'http://fonts.googleapis.com/css?family=Rosario', - * ['local' => false] - * ); - * echo $tag->stylesheet('css/style.css'); - * - * - * Volt syntax: - * - * {{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }} - * {{ stylesheet('css/style.css') }} - * - */ - public function stylesheet(string $url, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="submit"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - *public - * echo $tag->submit('Save') - * - * - * Volt syntax: - * - * {{ submit('Save') }} - * - */ - public function submit(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML TEXTAREA tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->textArea( - * 'comments', - * [ - * 'cols' => 10, - * 'rows' => 4, - * ] - * ); - * - * - * Volt syntax: - * - * {{ text_area('comments', ['cols': 10, 'rows': 4]) }} - * - */ - public function textArea(string $name, array $parameters = []) : string - { - } - - /** - * Returns the escaper service from the DI container - */ - private function getService(string $name) - { - } - - /** - * Renders the attributes of an HTML element - */ - private function renderAttributes(string $code, array $attributes) : string - { - } - - /** - * Returns the closing tag depending on the doctype - */ - private function renderCloseTag(bool $addEol = false) : string - { - } - - /** - * Builds `input` elements - */ - private function renderInput(string $type, string $name, array $parameters = []) : string - { - } - /** - * Builds INPUT tags that implements the checked attribute - */ - private function renderInputChecked(string $type, string $name, array $parameters = []) : string - { - } - - /** - * Generates the option values or optgroup from an array - */ - private function renderSelectArray(array $options, $value, string $closeOption) : string - { - } - - /** - * Generates the option values from a resultset - */ - private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption) : string - { - } + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', + * 'useEol' => true, + * ] + * ); // '' . PHP_EOL + * ``` + * + * @param string $tag + * @param array $parameters + * @return string + */ + public function elementClose(string $tag, array $parameters = array()): string {} + + /** + * Returns the closing tag of a form element + * + * @param bool $eol + * @return string + */ + public function endForm(bool $eol = true): string {} + + /** + * Builds a HTML FORM tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->form('posts/save'); + * + * echo $tag->form( + * 'posts/save', + * [ + * "method" => "post", + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ form('posts/save') }}{% endraw %} + * {% raw %}{{ form('posts/save', ['method': 'post') }}{% endraw %} + * ``` + * + * @param string $action + * @param array $parameters + * @return string + */ + public function form(string $action, array $parameters = array()): string {} + + /** + * Converts text to URL-friendly strings + * + * Parameters + * `text` The text to be processed + * `separator` Separator to use (default '-') + * `lowercase` Convert to lowercase + * `replace` + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->friendlyTitle( + * [ + * 'text' => 'These are big important news', + * 'separator' => '-', + * ] + * ); + * ``` + * + * Volt Syntax: + * ```php + * {% raw %}{{ friendly_title(['text': 'These are big important news', 'separator': '-']) }}{% endraw %} + * ``` + * + * @param string $text + * @param array $parameters + * @return string + */ + public function friendlyTitle(string $text, array $parameters = array()): string {} + + /** + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Get the document type declaration of content. If the docType has not + * been set properly, XHTML5 is returned + * + * @return string + */ + public function getDocType(): string {} + + /** + * Gets the current document title. The title will be automatically escaped. + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->getTitle(); // Hello World from Phalcon + * echo $tag->getTitle(false); // World from Phalcon + * echo $tag->getTitle(true, false); // Hello World + * echo $tag->getTitle(false, false); // World + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ get_title() }}{% endraw %} + * ``` + * + * @param bool $prepend + * @param bool $append + * @return string + */ + public function getTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Gets the current document title separator + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->getTitleSeparator(); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ get_title_separator() }}{% endraw %} + * ``` + * + * @return string + */ + public function getTitleSeparator(): string {} + + /** + * Every helper calls this function to check whether a component has a + * predefined value using `setAttribute` or value from $_POST + * + * @param string $name + * @param array $parameters + * @return mixed|null + */ + public function getValue(string $name, array $parameters = array()): ? {} + + /** + * Check if a helper has a default value set using `setAttribute()` or + * value from $_POST + * + * @param string $name + * @return bool + */ + public function hasValue(string $name): bool {} + + /** + * Builds HTML IMG tags + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->image('img/bg.png'); + * + * echo $tag->image( + * 'img/photo.jpg', + * [ + * 'alt' => 'Some Photo', + * ] + * ); + * + * echo $tag->image( + * 'http://static.mywebsite.com/img/bg.png', + * [ + * 'local' => false, + * ] + * ); + * ``` + * + * Volt Syntax: + * ```php + * {% raw %}{{ image('img/bg.png') }}{% endraw %} + * {% raw %}{{ image('img/photo.jpg', ['alt': 'Some Photo') }}{% endraw %} + * {% raw %}{{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function image(string $url = '', array $parameters = array()): string {} + + /** + * Builds a HTML input[type="check"] tag + * + * ```php + * echo $tag->inputCheckbox( + * [ + * 'name' => 'terms, + * 'value' => 'Y', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_checkbox(['name': 'terms, 'value': 'Y']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputCheckbox(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='color'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputColor(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='date'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDate( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDate(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='datetime'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTime( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date_time(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDateTime(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='datetime-local'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTimeLocal( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDateTimeLocal(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='email'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputEmail( + * [ + * 'name' => 'email', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_email(['name': 'email']);{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputEmail(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='file'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputFile( + * [ + * 'name' => 'file', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_file(['name': 'file']){% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputFile(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='hidden'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputHidden( + * [ + * 'name' => 'my-field', + * 'value' => 'mike', + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputHidden(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="image"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->inputImage( + * [ + * 'src' => '/img/button.png', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_image(['src': '/img/button.png']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputImage(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='month'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputMonth(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='number'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->numericField( + * [ + * 'name' => 'price', + * 'min' => '1', + * 'max' => '5', + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputNumeric(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='password'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->passwordField( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputPassword(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="radio"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputRadio( + * [ + * 'name' => 'weather', + * 'value" => 'hot', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_radio(['name': 'weather', 'value": 'hot']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputRadio(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='range'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputRange(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='search'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputSearch(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='tel'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputTel(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='text'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputText( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputText(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='time'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputTime(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='url'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputUrl(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='week'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputWeek(string $name, array $parameters = array()): string {} + + /** + * Builds a script[type="javascript"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->javascript( + * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->javascript('javascript/jquery.js'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }}{% endraw %} + * {% raw %}{{ javascript('javascript/jquery.js') }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function javascript(string $url, array $parameters = array()): string {} + + /** + * Builds a HTML A tag using framework conventions + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->link('signup/register', 'Register Here!'); + * + * echo $tag->link( + * 'signup/register', + * 'Register Here!', + * [ + * 'class' => 'btn-primary', + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * 'target' => '_new', + * ] + * ); + * ``` + * + * @param string $url + * @param string $text + * @param array $parameters + * @return string + */ + public function link(string $url, string $text = '', array $parameters = array()): string {} + + /** + * Prepends a text to current document title + * + * @param mixed $title + * @return Tag + */ + public function prependTitle($title): Tag {} + + /** + * Renders the title with title tags. The title is automaticall escaped + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->renderTitle(); // Hello World from Phalcon + * echo $tag->renderTitle(false); // World from Phalcon + * echo $tag->renderTitle(true, false); // Hello World + * echo $tag->renderTitle(false, false); // World + * ``` + * + * ```php + * {% raw %}{{ render_title() }}{% endraw %} + * ``` + * + * @param bool $prepend + * @param bool $append + * @return string + */ + public function renderTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Builds a HTML input[type="reset"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->reset('Reset') + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ reset('Save') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function reset(string $name, array $parameters = array()): string {} + + /** + * Builds a select element. It accepts an array or a resultset from + * a Phalcon\Mvc\Model + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Status...', + * ], + * [ + * 'A' => 'Active', + * 'I' => 'Inactive', + * ] + * ); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Type...', + * 'using' => [ + * 'id, + * 'name', + * ], + * ], + * Robots::find( + * [ + * 'conditions' => 'type = :type:', + * 'bind' => [ + * 'type' => 'mechanical', + * ] + * ] + * ) + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @param mixed $data + * @return string + */ + public function select(string $name, array $parameters = array(), $data = null): string {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute('name', 'peter'); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * ``` + * + * @param string $name + * @param mixed $value + * @return Tag + */ + public function setAttribute(string $name, $value): Tag {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute( + * [ + * 'name' => 'peter', + * ] + * ); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * ``` + * + * @param array $values + * @param bool $merge + * @return Tag + */ + public function setAttributes(array $values, bool $merge = false): Tag {} + + /** + * Sets the dependency injector + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the document type of content + * + * @param int $doctype + * @return Tag + */ + public function setDocType(int $doctype): Tag {} + + /** + * Set the title separator of view content + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag->setTitle('Phalcon Framework'); + * ``` + * + * @param string $title + * @return Tag + */ + public function setTitle(string $title): Tag {} + + /** + * Set the title separator of view content + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->setTitleSeparator('-'); + * ``` + * + * @param string $separator + * @return Tag + */ + public function setTitleSeparator(string $separator): Tag {} + + /** + * Builds a LINK[rel="stylesheet"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->stylesheet( + * 'http://fonts.googleapis.com/css?family=Rosario', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->stylesheet('css/style.css'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }}{% endraw %} + * {% raw %}{{ stylesheet('css/style.css') }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function stylesheet(string $url, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="submit"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->submit('Save'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ submit('Save') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function submit(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML TEXTAREA tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->textArea( + * 'comments', + * [ + * 'cols' => 10, + * 'rows' => 4, + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ text_area('comments', ['cols': 10, 'rows': 4]) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function textArea(string $name, array $parameters = array()): string {} + + /** + * Returns the escaper service from the DI container + * + * @param string $name + */ + private function getService(string $name) {} + + /** + * Renders the attributes of an HTML element + * + * @param string $code + * @param array $attributes + * @return string + */ + private function renderAttributes(string $code, array $attributes): string {} + + /** + * Returns the closing tag depending on the doctype + * + * @param bool $addEol + * @return string + */ + private function renderCloseTag(bool $addEol = false): string {} + + /** + * Builds `input` elements + * + * @param string $type + * @param string $name + * @param array $parameters + * @return string + */ + private function renderInput(string $type, string $name, array $parameters = array()): string {} + + /** + * Builds INPUT tags that implements the checked attribute + * + * @param string $type + * @param string $name + * @param array $parameters + * @return string + */ + private function renderInputChecked(string $type, string $name, array $parameters = array()): string {} + + /** + * Generates the option values or optgroup from an array + * + * @param array $options + * @param mixed $value + * @param string $closeOption + * @return string + */ + private function renderSelectArray(array $options, $value, string $closeOption): string {} + + /** + * Generates the option values from a resultset + * + * @param ResulsetInterface $resultset + * @param mixed $using + * @param mixed $value + * @param string $closeOption + * @return string + */ + private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption): string {} + } diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php new file mode 100644 index 00000000..3621c52c --- /dev/null +++ b/src/Phalcon/html/TagFactory.php @@ -0,0 +1,38 @@ + + */ + private $escaper; + + + /** + * TagFactory constructor. + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param array $services + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) {} + + /** + * @param string name + * + * @throws Exception + * @param string $name + * @return mixed + */ + public function newInstance(string $name) {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/html/Taglocator.php b/src/Phalcon/html/Taglocator.php deleted file mode 100644 index 2cebb261..00000000 --- a/src/Phalcon/html/Taglocator.php +++ /dev/null @@ -1,14 +0,0 @@ - + */ + protected $escaper; + + + /** + * Constructor + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) {} + + /** + * Renders an element + * + * @param string $tag + * @param string $text + * @param array $attributes + * @param bool $raw + * @return string + */ + protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string {} + + /** + * Renders an element + * + * @param string $tag + * @param array $attributes + * @return string + */ + protected function renderElement(string $tag, array $attributes = array()): string {} + + /** + * Keeps all the attributes sorted - same order all the tome + * + * @param array attributes + * + * @param array $overrides + * @param array $attributes + * @return array + */ + protected function orderAttributes(array $overrides, array $attributes): array {} + + /** + * Renders all the attributes + * + * @param array $attributes + * @return string + */ + protected function renderAttributes(array $attributes): string {} + + /** + * Produces a self close tag i.e. + * + * @param string $tag + * @param array $attributes + * @return string + */ + protected function selfClose(string $tag, array $attributes = array()): string {} + +} diff --git a/src/Phalcon/html/helper/Abstracthelper.php b/src/Phalcon/html/helper/Abstracthelper.php deleted file mode 100644 index cf39440c..00000000 --- a/src/Phalcon/html/helper/Abstracthelper.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ - protected $escaper; - - /** - * Constructor - */ - public function __construct(EscaperInterface $escaper) - { - } - - /** - * Keeps all the attributes sorted - same order all the tome - */ - protected function orderAttributes(array $overrides, array $attributes) : array - { - } - - /** - * Renders all the attributes - */ - protected function renderAttributes(array $attributes) : string - { - } - - /** - * Renders an element - */ - protected function renderElement(string $tag, string $text, array $attributes = []) - { - } - - /** - * Produces a self close tag i.e. - */ - protected function selfClose(string $tag, array $attributes = []) - { - } -} diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index b4ecb01d..5e8646d1 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -2,21 +2,20 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Anchor * * Creates an anchor */ -class Anchor extends AbstractHelper +class Anchor extends \Phalcon\Html\Helper\AbstractHelper { - /** - * @var string href The href tag - * @var string text The text for the anchor - * @var array attributes Any additional attributes - */ - public function __invoke(string $href, string $text, array $attributes = []) : string - { - } + + /** + * @param string $href + * @param string $text + * @param array $attributes + * @return string + */ + public function __invoke(string $href, string $text, array $attributes = array()): string {} + } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php new file mode 100644 index 00000000..1bdb84b7 --- /dev/null +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -0,0 +1,21 @@ + + * ```php * use Phalcon\Http\Request; * * $request = new Request(); @@ -19,65 +18,67 @@ * echo "Request was made using POST and AJAX"; * } * - * $request->getServer("HTTP_HOST"); // Retrieve SERVER variables - * $request->getMethod(); // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT - * $request->getLanguages(); // An array of languages the client accepts - * + * // Retrieve SERVER variables + * $request->getServer("HTTP_HOST"); + * + * // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT + * $request->getMethod(); + * + * // An array of languages the client accepts + * $request->getLanguages(); + * ``` */ class Request implements \Phalcon\Http\RequestInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - - - protected $_rawBody; - - - protected $_filter; + private $container; - protected $_putCache; + private $filterService; + /** + * @var bool + */ + private $httpMethodParameterOverride = false; - protected $_httpMethodParameterOverride = false; - + /** + * @var array + */ + private $queryFilters = array(); - protected $_strictHostCheck = false; + private $putCache; - public function getHttpMethodParameterOverride() {} + private $rawBody; /** - * @param mixed $httpMethodParameterOverride + * @var bool */ - public function setHttpMethodParameterOverride($httpMethodParameterOverride) {} + private $strictHostCheck = false; + /** - * Sets the dependency injector - * - * @param \Phalcon\DiInterface $dependencyInjector + * @return bool */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function getHttpMethodParameterOverride(): bool {} /** - * Returns the internal dependency injector - * - * @return \Phalcon\DiInterface + * @param bool $httpMethodParameterOverride */ - public function getDI() {} + public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride) {} /** - * Gets a variable from the $_REQUEST superglobal applying filters if needed. - * If no parameters are given the $_REQUEST superglobal is returned + * Gets a variable from the $_REQUEST superglobal applying filters if + * needed. If no parameters are given the $_REQUEST superglobal is returned * - * + * ```php * // Returns value from $_REQUEST["user_email"] without sanitizing * $userEmail = $request->get("user_email"); * * // Returns value from $_REQUEST["user_email"] with sanitizing * $userEmail = $request->get("user_email", "email"); - * + * ``` * * @param string $name * @param mixed $filters @@ -86,142 +87,120 @@ public function getDI() {} * @param bool $noRecursive * @return mixed */ - public function get($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Gets a variable from the $_POST superglobal applying filters if needed - * If no parameters are given the $_POST superglobal is returned + * Gets an array with mime/types and their quality accepted by the + * browser/client from _SERVER["HTTP_ACCEPT"] * - * - * // Returns value from $_POST["user_email"] without sanitizing - * $userEmail = $request->getPost("user_email"); - * - * // Returns value from $_POST["user_email"] with sanitizing - * $userEmail = $request->getPost("user_email", "email"); - * - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return array */ - public function getPost($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getAcceptableContent(): array {} /** - * Gets a variable from put request - * - * - * // Returns value from $_PUT["user_email"] without sanitizing - * $userEmail = $request->getPut("user_email"); + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_USER"] * - * // Returns value from $_PUT["user_email"] with sanitizing - * $userEmail = $request->getPut("user_email", "email"); - * - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return array|null */ - public function getPut($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getBasicAuth(): ?array {} /** - * Gets variable from $_GET superglobal applying filters if needed - * If no parameters are given the $_GET superglobal is returned + * Gets best mime/type accepted by the browser/client from + * _SERVER["HTTP_ACCEPT"] * - * - * // Returns value from $_GET["id"] without sanitizing - * $id = $request->getQuery("id"); - * - * // Returns value from $_GET["id"] with sanitizing - * $id = $request->getQuery("id", "int"); + * @return string + */ + public function getBestAccept(): string {} + + /** + * Gets best charset accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_CHARSET"] * - * // Returns value from $_GET["id"] with a default value - * $id = $request->getQuery("id", null, 150); - * + * @return string + */ + public function getBestCharset(): string {} + + /** + * Gets best language accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return string */ - public function getQuery($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getBestLanguage(): string {} /** - * Helper to get data from superglobals, applying filters if needed. - * If no parameters are given the superglobal is returned. + * Gets most possible client IPv4 Address. This method searches in + * `$_SERVER["REMOTE_ADDR"]` and optionally in + * `$_SERVER["HTTP_X_FORWARDED_FOR"]` * - * @param array $source - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @param bool $trustForwardedHeader + * @return string|bool */ - protected final function getHelper(array $source, $name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getClientAddress(bool $trustForwardedHeader = false) {} /** - * Gets variable from $_SERVER superglobal + * Gets a charsets array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return string|null + * @return array */ - public function getServer($name) {} + public function getClientCharsets(): array {} /** - * Checks whether $_REQUEST superglobal has certain index + * Gets content type which request has been made * - * @param string $name - * @return bool + * @return string|null */ - public function has($name) {} + public function getContentType(): ?string {} /** - * Checks whether $_POST superglobal has certain index + * Returns the internal dependency injector * - * @param string $name - * @return bool + * @return \Phalcon\Di\DiInterface */ - public function hasPost($name) {} + public function getDI(): DiInterface {} /** - * Checks whether the PUT data has certain index + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_DIGEST"] * - * @param string $name - * @return bool + * @return array */ - public function hasPut($name) {} + public function getDigestAuth(): array {} /** - * Checks whether $_GET superglobal has certain index + * Retrieves a query/get value always sanitized with the preset filters * * @param string $name - * @return bool + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function hasQuery($name) {} + public function getFilteredQuery(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Checks whether $_SERVER superglobal has certain index + * Retrieves a post value always sanitized with the preset filters * * @param string $name - * @return bool + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public final function hasServer($name) {} + public function getFilteredPost(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Checks whether headers has certain index + * Retrieves a put value always sanitized with the preset filters * - * @param string $header - * @return bool + * @param string $name + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public final function hasHeader($header) {} + public function getFilteredPut(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** * Gets HTTP header from request data @@ -229,58 +208,70 @@ public final function hasHeader($header) {} * @param string $header * @return string */ - public final function getHeader($header) {} + final public function getHeader(string $header): string {} /** - * Gets HTTP schema (http/https) + * Returns the available headers in the request * - * @return string - */ - public function getScheme() {} - - /** - * Checks whether request has been made using ajax + * + * $_SERVER = [ + * "PHP_AUTH_USER" => "phalcon", + * "PHP_AUTH_PW" => "secret", + * ]; * - * @return bool - */ - public function isAjax() {} - - /** - * Checks whether request has been made using SOAP + * $headers = $request->getHeaders(); * - * @return bool - */ - public function isSoap() {} - - /** - * Alias of isSoap(). It will be deprecated in future versions + * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= + * * - * @deprecated - * @return bool + * @return array */ - public function isSoapRequested() {} + public function getHeaders(): array {} /** - * Checks whether request has been made using any secure layer + * Gets host name used by the request. * - * @return bool - */ - public function isSecure() {} - - /** - * Alias of isSecure(). It will be deprecated in future versions + * `Request::getHttpHost` trying to find host name in following order: * - * @deprecated - * @return bool + * - `$_SERVER["HTTP_HOST"]` + * - `$_SERVER["SERVER_NAME"]` + * - `$_SERVER["SERVER_ADDR"]` + * + * Optionally `Request::getHttpHost` validates and clean host name. + * The `Request::$strictHostCheck` can be used to validate host name. + * + * Note: validation and cleaning have a negative performance impact because + * they use regular expressions. + * + * ```php + * use Phalcon\Http\Request; + * + * $request = new Request; + * + * $_SERVER["HTTP_HOST"] = "example.com"; + * $request->getHttpHost(); // example.com + * + * $_SERVER["HTTP_HOST"] = "example.com:8080"; + * $request->getHttpHost(); // example.com:8080 + * + * $request->setStrictHostCheck(true); + * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; + * $request->getHttpHost(); // UnexpectedValueException + * + * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; + * $request->getHttpHost(); // example.com + * ``` + * + * @return string */ - public function isSecureRequest() {} + public function getHttpHost(): string {} /** - * Gets HTTP raw request body + * Gets web page that refers active request. ie: http://www.google.com * * @return string */ - public function getRawBody() {} + public function getHTTPReferer(): string {} /** * Gets decoded JSON HTTP raw request body @@ -288,357 +279,445 @@ public function getRawBody() {} * @param bool $associative * @return array|bool|\stdClass */ - public function getJsonRawBody($associative = false) {} + public function getJsonRawBody(bool $associative = false) {} /** - * Gets active server address IP + * Gets languages array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return string + * @return array */ - public function getServerAddress() {} + public function getLanguages(): array {} /** - * Gets active server name + * Gets HTTP method which request has been made + * + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP + * method, but only if setHttpMethodParameterOverride(true) has been called. + * + * The method is always an uppercased string. * * @return string */ - public function getServerName() {} + final public function getMethod(): string {} /** - * Gets host name used by the request. + * Gets information about the port on which the request is made. * - * `Request::getHttpHost` trying to find host name in following order: + * @return int + */ + public function getPort(): int {} + + /** + * Gets a variable from the $_POST superglobal applying filters if needed + * If no parameters are given the $_POST superglobal is returned * - * - `$_SERVER["HTTP_HOST"]` - * - `$_SERVER["SERVER_NAME"]` - * - `$_SERVER["SERVER_ADDR"]` + * ```php + * // Returns value from $_POST["user_email"] without sanitizing + * $userEmail = $request->getPost("user_email"); * - * Optionally `Request::getHttpHost` validates and clean host name. - * The `Request::$_strictHostCheck` can be used to validate host name. + * // Returns value from $_POST["user_email"] with sanitizing + * $userEmail = $request->getPost("user_email", "email"); + * ``` * - * Note: validation and cleaning have a negative performance impact because - * they use regular expressions. + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + + /** + * Gets a variable from put request * - * - * use Phalcon\Http\Request; + * ```php + * // Returns value from $_PUT["user_email"] without sanitizing + * $userEmail = $request->getPut("user_email"); * - * $request = new Request; + * // Returns value from $_PUT["user_email"] with sanitizing + * $userEmail = $request->getPut("user_email", "email"); + * ``` * - * $_SERVER["HTTP_HOST"] = "example.com"; - * $request->getHttpHost(); // example.com + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + + /** + * Gets variable from $_GET superglobal applying filters if needed + * If no parameters are given the $_GET superglobal is returned * - * $_SERVER["HTTP_HOST"] = "example.com:8080"; - * $request->getHttpHost(); // example.com:8080 + * ```php + * // Returns value from $_GET["id"] without sanitizing + * $id = $request->getQuery("id"); * - * $request->setStrictHostCheck(true); - * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; - * $request->getHttpHost(); // UnexpectedValueException + * // Returns value from $_GET["id"] with sanitizing + * $id = $request->getQuery("id", "int"); * - * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; - * $request->getHttpHost(); // example.com - * + * // Returns value from $_GET["id"] with a default value + * $id = $request->getQuery("id", null, 150); + * ``` * - * @return string + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getHttpHost() {} + public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Sets if the `Request::getHttpHost` method must be use strict validation of host name or not + * Gets HTTP raw request body * - * @param bool $flag - * @return Request + * @return string */ - public function setStrictHostCheck($flag = true) {} + public function getRawBody(): string {} /** - * Checks if the `Request::getHttpHost` method will be use strict validation of host name or not + * Gets HTTP schema (http/https) * - * @return bool + * @return string */ - public function isStrictHostCheck() {} + public function getScheme(): string {} /** - * Gets information about the port on which the request is made. + * Gets variable from $_SERVER superglobal * - * @return int + * @param string $name + * @return string|null */ - public function getPort() {} + public function getServer(string $name): ?string {} /** - * Gets HTTP URI which request has been made + * Gets active server address IP * * @return string */ - public final function getURI() {} + public function getServerAddress(): string {} /** - * Gets most possible client IPv4 Address. This method searches in - * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] + * Gets active server name * - * @param bool $trustForwardedHeader - * @return string|bool + * @return string */ - public function getClientAddress($trustForwardedHeader = false) {} + public function getServerName(): string {} /** - * Gets HTTP method which request has been made - * - * If the X-HTTP-Method-Override header is set, and if the method is a POST, - * then it is used to determine the "real" intended HTTP method. - * - * The _method request parameter can also be used to determine the HTTP method, - * but only if setHttpMethodParameterOverride(true) has been called. + * Gets attached files as Phalcon\Http\Request\File instances * - * The method is always an uppercased string. + * @param bool $onlySuccessful + * @param bool $namedKeys + * @return array|\Phalcon\Http\Request\FileInterface[] + */ + public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array {} + + /** + * Gets HTTP URI which request has been made * * @return string */ - public final function getMethod() {} + final public function getURI(): string {} /** * Gets HTTP user agent used to made the request * * @return string */ - public function getUserAgent() {} + public function getUserAgent(): string {} /** - * Checks if a method is a valid HTTP method + * Checks whether $_REQUEST superglobal has certain index * - * @param string $method + * @param string $name * @return bool */ - public function isValidHttpMethod($method) {} + public function has(string $name): bool {} /** - * Check if HTTP method match any of the passed methods - * When strict is true it checks if validated methods are real HTTP methods + * Returns the number of files available * - * @param mixed $methods - * @param bool $strict + * TODO: Check this + * + * @param bool $onlySuccessful + * @return long + */ + public function hasFiles(bool $onlySuccessful = false): int {} + + /** + * Checks whether headers has certain index + * + * @param string $header * @return bool */ - public function isMethod($methods, $strict = false) {} + final public function hasHeader(string $header): bool {} /** - * Checks whether HTTP method is POST. if _SERVER["REQUEST_METHOD"]==="POST" + * Checks whether $_POST superglobal has certain index * + * @param string $name * @return bool */ - public function isPost() {} + public function hasPost(string $name): bool {} /** - * Checks whether HTTP method is GET. if _SERVER["REQUEST_METHOD"]==="GET" + * Checks whether the PUT data has certain index * + * @param string $name * @return bool */ - public function isGet() {} + public function hasPut(string $name): bool {} /** - * Checks whether HTTP method is PUT. if _SERVER["REQUEST_METHOD"]==="PUT" + * Checks whether $_GET superglobal has certain index * + * @param string $name * @return bool */ - public function isPut() {} + public function hasQuery(string $name): bool {} /** - * Checks whether HTTP method is PATCH. if _SERVER["REQUEST_METHOD"]==="PATCH" + * Checks whether $_SERVER superglobal has certain index * + * @param string $name * @return bool */ - public function isPatch() {} + final public function hasServer(string $name): bool {} /** - * Checks whether HTTP method is HEAD. if _SERVER["REQUEST_METHOD"]==="HEAD" + * Checks whether request has been made using ajax * * @return bool */ - public function isHead() {} + public function isAjax(): bool {} /** - * Checks whether HTTP method is DELETE. if _SERVER["REQUEST_METHOD"]==="DELETE" + * Checks whether HTTP method is CONNECT. + * if _SERVER["REQUEST_METHOD"]==="CONNECT" * * @return bool */ - public function isDelete() {} + public function isConnect(): bool {} /** - * Checks whether HTTP method is OPTIONS. if _SERVER["REQUEST_METHOD"]==="OPTIONS" + * Checks whether HTTP method is DELETE. + * if _SERVER["REQUEST_METHOD"]==="DELETE" * * @return bool */ - public function isOptions() {} + public function isDelete(): bool {} /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). if _SERVER["REQUEST_METHOD"]==="PURGE" + * Checks whether HTTP method is GET. + * if _SERVER["REQUEST_METHOD"]==="GET" * * @return bool */ - public function isPurge() {} + public function isGet(): bool {} /** - * Checks whether HTTP method is TRACE. if _SERVER["REQUEST_METHOD"]==="TRACE" + * Checks whether HTTP method is HEAD. + * if _SERVER["REQUEST_METHOD"]==="HEAD" * * @return bool */ - public function isTrace() {} + public function isHead(): bool {} /** - * Checks whether HTTP method is CONNECT. if _SERVER["REQUEST_METHOD"]==="CONNECT" + * Check if HTTP method match any of the passed methods + * When strict is true it checks if validated methods are real HTTP methods * + * @param mixed $methods + * @param bool $strict * @return bool */ - public function isConnect() {} + public function isMethod($methods, bool $strict = false): bool {} /** - * Checks whether request include attached files + * Checks whether HTTP method is OPTIONS. + * if _SERVER["REQUEST_METHOD"]==="OPTIONS" * - * @param bool $onlySuccessful - * @return long + * @return bool */ - public function hasFiles($onlySuccessful = false) {} + public function isOptions(): bool {} /** - * Recursively counts file in an array of files + * Checks whether HTTP method is PATCH. + * if _SERVER["REQUEST_METHOD"]==="PATCH" * - * @param mixed $data - * @param bool $onlySuccessful - * @return long + * @return bool */ - protected final function hasFileHelper($data, $onlySuccessful) {} + public function isPatch(): bool {} /** - * Gets attached files as Phalcon\Http\Request\File instances + * Checks whether HTTP method is POST. + * if _SERVER["REQUEST_METHOD"]==="POST" * - * @param bool $onlySuccessful - * @return \Phalcon\Http\Request\FileInterface[] + * @return bool */ - public function getUploadedFiles($onlySuccessful = false) {} + public function isPost(): bool {} /** - * Smooth out $_FILES to have plain array with all files uploaded + * Checks whether HTTP method is PUT. + * if _SERVER["REQUEST_METHOD"]==="PUT" * - * @param array $names - * @param array $types - * @param array $tmp_names - * @param array $sizes - * @param array $errors - * @param string $prefix - * @return array + * @return bool */ - protected final function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, $prefix) {} + public function isPut(): bool {} /** - * Returns the available headers in the request + * Checks whether HTTP method is PURGE (Squid and Varnish support). + * if _SERVER["REQUEST_METHOD"]==="PURGE" * - * - * $_SERVER = [ - * "PHP_AUTH_USER" => "phalcon", - * "PHP_AUTH_PW" => "secret", - * ]; + * @return bool + */ + public function isPurge(): bool {} + + /** + * Checks whether request has been made using any secure layer * - * $headers = $request->getHeaders(); + * @return bool + */ + public function isSecure(): bool {} + + /** + * Checks if the `Request::getHttpHost` method will be use strict validation + * of host name or not * - * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= - * + * @return bool + */ + public function isStrictHostCheck(): bool {} + + /** + * Checks whether request has been made using SOAP * - * @return array + * @return bool */ - public function getHeaders() {} + public function isSoap(): bool {} /** - * Resolve authorization headers. + * Checks whether HTTP method is TRACE. + * if _SERVER["REQUEST_METHOD"]==="TRACE" * - * @return array + * @return bool */ - protected function resolveAuthorizationHeaders() {} + public function isTrace(): bool {} /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks if a method is a valid HTTP method * - * @return string + * @param string $method + * @return bool */ - public function getHTTPReferer() {} + public function isValidHttpMethod(string $method): bool {} /** - * Process a request header and return the one with best quality + * Sets the dependency injector * - * @param array $qualityParts - * @param string $name - * @return string + * @param \Phalcon\Di\DiInterface $container */ - protected final function _getBestQuality(array $qualityParts, $name) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Gets content type which request has been made + * Sets automatic sanitizers/filters for a particular field and for + * particular methods * - * @return string|null + * @param string $name + * @param array $filters + * @param array $scope + * @return RequestInterface */ - public function getContentType() {} + public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface {} /** - * Gets an array with mime/types and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT"] + * Sets if the `Request::getHttpHost` method must be use strict validation + * of host name or not * - * @return array + * @param bool $flag + * @return RequestInterface */ - public function getAcceptableContent() {} + public function setStrictHostCheck(bool $flag = true): RequestInterface {} /** - * Gets best mime/type accepted by the browser/client from _SERVER["HTTP_ACCEPT"] + * Process a request header and return the one with best quality * + * @param array $qualityParts + * @param string $name * @return string */ - public function getBestAccept() {} + final protected function getBestQuality(array $qualityParts, string $name): string {} /** - * Gets a charsets array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] + * Helper to get data from superglobals, applying filters if needed. + * If no parameters are given the superglobal is returned. * - * @return array + * @param array $source + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getClientCharsets() {} + final protected function getHelper(array $source, string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Gets best charset accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] + * Recursively counts file in an array of files * - * @return string + * @param mixed $data + * @param bool $onlySuccessful + * @return long */ - public function getBestCharset() {} + final protected function hasFileHelper($data, bool $onlySuccessful): int {} /** - * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Process a request header and return an array of values with their qualities * + * @param string $serverIndex + * @param string $name * @return array */ - public function getLanguages() {} + final protected function getQualityHeader(string $serverIndex, string $name): array {} /** - * Gets best language accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Resolve authorization headers. * - * @return string + * @return array */ - public function getBestLanguage() {} + protected function resolveAuthorizationHeaders(): array {} /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] + * Smooth out $_FILES to have plain array with all files uploaded * - * @return array|null + * @param array $names + * @param array $types + * @param array $tmp_names + * @param array $sizes + * @param array $errors + * @param string $prefix + * @return array */ - public function getBasicAuth() {} + final protected function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, string $prefix): array {} /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] + * Checks the filter service and assigns it to the class parameter * - * @return array + * @return \Phalcon\Filter\FilterInterface */ - public function getDigestAuth() {} + private function getFilterService(): FilterInterface {} /** - * Process a request header and return an array of values with their qualities - * - * @param string $serverIndex - * @param string $name * @return array */ - protected final function _getQualityHeader($serverIndex, $name) {} + private function getServerArray(): array {} } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 493883ff..853091b0 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -3,90 +3,104 @@ namespace Phalcon\Http; /** - * Phalcon\Http\RequestInterface - * * Interface for Phalcon\Http\Request */ interface RequestInterface { /** - * Gets a variable from the $_REQUEST superglobal applying filters if needed + * Gets a variable from the $_REQUEST superglobal applying filters if + * needed. If no parameters are given the $_REQUEST superglobal is returned + * + * ```php + * // Returns value from $_REQUEST["user_email"] without sanitizing + * $userEmail = $request->get("user_email"); + * + * // Returns value from $_REQUEST["user_email"] with sanitizing + * $userEmail = $request->get("user_email", "email"); + * ``` * * @param string $name - * @param string|array $filters + * @param mixed $filters * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive * @return mixed */ - public function get($name = null, $filters = null, $defaultValue = null); + public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); /** - * Gets a variable from the $_POST superglobal applying filters if needed + * Gets an array with mime/types and their quality accepted by the + * browser/client from _SERVER["HTTP_ACCEPT"] * - * @param string $name - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @return array */ - public function getPost($name = null, $filters = null, $defaultValue = null); + public function getAcceptableContent(): array; /** - * Gets variable from $_GET superglobal applying filters if needed + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_USER"] * - * @param string $name - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @return array|null */ - public function getQuery($name = null, $filters = null, $defaultValue = null); + public function getBasicAuth(): ?array; /** - * Gets variable from $_SERVER superglobal + * Gets best mime/type accepted by the browser/client from + * _SERVER["HTTP_ACCEPT"] * - * @param string $name - * @return mixed + * @return string */ - public function getServer($name); + public function getBestAccept(): string; /** - * Checks whether $_REQUEST superglobal has certain index + * Gets best charset accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return bool + * @return string */ - public function has($name); + public function getBestCharset(): string; /** - * Checks whether $_POST superglobal has certain index + * Gets best language accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @param string $name - * @return bool + * @return string */ - public function hasPost($name); + public function getBestLanguage(): string; /** - * Checks whether the PUT data has certain index + * Gets most possible client IPv4 Address. This method searches in + * $_SERVER["REMOTE_ADDR"] and optionally in + * $_SERVER["HTTP_X_FORWARDED_FOR"] * - * @param string $name - * @return bool + * @param bool $trustForwardedHeader + * @return string|bool */ - public function hasPut($name); + public function getClientAddress(bool $trustForwardedHeader = false); /** - * Checks whether $_GET superglobal has certain index + * Gets a charsets array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return bool + * @return array */ - public function hasQuery($name); + public function getClientCharsets(): array; /** - * Checks whether $_SERVER superglobal has certain index + * Gets content type which request has been made * - * @param string $name - * @return bool + * @return string|null + */ + public function getContentType(): ?string; + + /** + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_DIGEST"] + * + * @return array */ - public function hasServer($name); + public function getDigestAuth(): array; /** * Gets HTTP header from request data @@ -94,243 +108,383 @@ public function hasServer($name); * @param string $header * @return string */ - public function getHeader($header); + public function getHeader(string $header): string; /** - * Gets HTTP schema (http/https) + * Returns the available headers in the request + * + * ```php + * $_SERVER = [ + * "PHP_AUTH_USER" => "phalcon", + * "PHP_AUTH_PW" => "secret", + * ]; + * + * $headers = $request->getHeaders(); + * + * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= + * ``` + * + * @return array + */ + public function getHeaders(): array; + + /** + * Gets host name used by the request. + * + * `Request::getHttpHost` trying to find host name in following order: + * + * - `$_SERVER["HTTP_HOST"]` + * - `$_SERVER["SERVER_NAME"]` + * - `$_SERVER["SERVER_ADDR"]` + * + * Optionally `Request::getHttpHost` validates and clean host name. + * The `Request::$_strictHostCheck` can be used to validate host name. + * + * Note: validation and cleaning have a negative performance impact because + * they use regular expressions. + * + * ```php + * use Phalcon\Http\Request; + * + * $request = new Request; + * + * $_SERVER["HTTP_HOST"] = "example.com"; + * $request->getHttpHost(); // example.com + * + * $_SERVER["HTTP_HOST"] = "example.com:8080"; + * $request->getHttpHost(); // example.com:8080 + * + * $request->setStrictHostCheck(true); + * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; + * $request->getHttpHost(); // UnexpectedValueException + * + * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; + * $request->getHttpHost(); // example.com + * ``` * * @return string */ - public function getScheme(); + public function getHttpHost(): string; /** - * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" + * Gets web page that refers active request. ie: http://www.google.com * - * @return bool + * @return string */ - public function isAjax(); + public function getHTTPReferer(): string; /** - * Checks whether request has been made using SOAP + * Gets decoded JSON HTTP raw request body * - * @return bool + * @param bool $associative + * @return array|bool|\stdClass */ - public function isSoapRequested(); + public function getJsonRawBody(bool $associative = false); /** - * Checks whether request has been made using any secure layer + * Gets languages array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return bool + * @return array */ - public function isSecureRequest(); + public function getLanguages(): array; /** - * Gets HTTP raw request body + * Gets HTTP method which request has been made + * + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP + * method, but only if setHttpMethodParameterOverride(true) has been called. + * + * The method is always an uppercased string. * * @return string */ - public function getRawBody(); + public function getMethod(): string; /** - * Gets active server address IP + * Gets information about the port on which the request is made * - * @return string + * @return int */ - public function getServerAddress(); + public function getPort(): int; /** - * Gets active server name + * Gets HTTP URI which request has been made * * @return string */ - public function getServerName(); + final public function getURI(): string; + + /** + * Gets a variable from the $_POST superglobal applying filters if needed + * If no parameters are given the $_POST superglobal is returned + * + * ```php + * // Returns value from $_POST["user_email"] without sanitizing + * $userEmail = $request->getPost("user_email"); + * + * // Returns value from $_POST["user_email"] with sanitizing + * $userEmail = $request->getPost("user_email", "email"); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); + + /** + * Gets a variable from put request + * + * ```php + * // Returns value from $_PUT["user_email"] without sanitizing + * $userEmail = $request->getPut("user_email"); + * + * // Returns value from $_PUT["user_email"] with sanitizing + * $userEmail = $request->getPut("user_email", "email"); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); + + /** + * Gets variable from $_GET superglobal applying filters if needed + * If no parameters are given the $_GET superglobal is returned + * + * ```php + * // Returns value from $_GET["id"] without sanitizing + * $id = $request->getQuery("id"); + * + * // Returns value from $_GET["id"] with sanitizing + * $id = $request->getQuery("id", "int"); + * + * // Returns value from $_GET["id"] with a default value + * $id = $request->getQuery("id", null, 150); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); /** - * Gets host name used by the request + * Gets HTTP raw request body * * @return string */ - public function getHttpHost(); + public function getRawBody(): string; /** - * Gets information about the port on which the request is made + * Gets HTTP schema (http/https) * - * @return int + * @return string */ - public function getPort(); + public function getScheme(): string; /** - * Gets most possibly client IPv4 Address. This methods searches in - * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] + * Gets variable from $_SERVER superglobal * - * @param bool $trustForwardedHeader - * @return string|bool + * @param string $name + * @return string|null */ - public function getClientAddress($trustForwardedHeader = false); + public function getServer(string $name): ?string; /** - * Gets HTTP method which request has been made + * Gets active server address IP * * @return string */ - public function getMethod(); + public function getServerAddress(): string; /** - * Gets HTTP user agent used to made the request + * Gets active server name * * @return string */ - public function getUserAgent(); + public function getServerName(): string; /** - * Check if HTTP method match any of the passed methods + * Gets attached files as Phalcon\Http\Request\FileInterface compatible + * instances * - * @param string|array $methods - * @param bool $strict - * @return bool + * @param bool $onlySuccessful + * @param bool $namedKeys + * @return array|\Phalcon\Http\Request\FileInterface[] */ - public function isMethod($methods, $strict = false); + public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; /** - * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" + * Gets HTTP user agent used to made the request * - * @return bool + * @return string */ - public function isPost(); + public function getUserAgent(): string; /** - * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" + * Checks whether $_REQUEST superglobal has certain index * + * @param string $name * @return bool */ - public function isGet(); + public function has(string $name): bool; /** - * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" + * Checks whether request include attached files + * TODO: We need to check the name. Not very intuitive + * + * @param bool $onlySuccessful + * @return long + */ + public function hasFiles(bool $onlySuccessful = false): int; + + /** + * Checks whether headers has certain index * + * @param string $header * @return bool */ - public function isPut(); + public function hasHeader(string $header): bool; /** - * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" + * Checks whether $_GET superglobal has certain index * + * @param string $name * @return bool */ - public function isHead(); + public function hasQuery(string $name): bool; /** - * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" + * Checks whether $_POST superglobal has certain index * + * @param string $name * @return bool */ - public function isDelete(); + public function hasPost(string $name): bool; /** - * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" + * Checks whether the PUT data has certain index * + * @param string $name * @return bool */ - public function isOptions(); + public function hasPut(string $name): bool; /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" + * Checks whether $_SERVER superglobal has certain index * + * @param string $name * @return bool */ - public function isPurge(); + public function hasServer(string $name): bool; /** - * Checks whether HTTP method is TRACE. if $_SERVER["REQUEST_METHOD"] === "TRACE" + * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" * * @return bool */ - public function isTrace(); + public function isAjax(): bool; /** * Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT" * * @return bool */ - public function isConnect(); + public function isConnect(): bool; /** - * Checks whether request include attached files + * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" * - * @param boolean $onlySuccessful - * @return int + * @return bool */ - public function hasFiles($onlySuccessful = false); + public function isDelete(): bool; /** - * Gets attached files as Phalcon\Http\Request\FileInterface compatible instances + * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" * - * @param bool $onlySuccessful - * @return \Phalcon\Http\Request\FileInterface[] + * @return bool */ - public function getUploadedFiles($onlySuccessful = false); + public function isGet(): bool; /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" * - * @return string + * @return bool */ - public function getHTTPReferer(); + public function isHead(): bool; /** - * Gets array with mime/types and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] + * Check if HTTP method match any of the passed methods * - * @return array + * @param string|array $methods + * @param bool $strict + * @return bool */ - public function getAcceptableContent(); + public function isMethod($methods, bool $strict = false): bool; /** - * Gets best mime/type accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] + * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" * - * @return string + * @return bool */ - public function getBestAccept(); + public function isOptions(): bool; /** - * Gets charsets array and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] + * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" * - * @return array + * @return bool */ - public function getClientCharsets(); + public function isPost(): bool; /** - * Gets best charset accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] + * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" * - * @return string + * @return bool */ - public function getBestCharset(); + public function isPurge(): bool; /** - * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" * - * @return array + * @return bool */ - public function getLanguages(); + public function isPut(): bool; /** - * Gets best language accepted by the browser/client from $_SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether request has been made using any secure layer * - * @return string + * @return bool */ - public function getBestLanguage(); + public function isSecure(): bool; /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] + * Checks whether request has been made using SOAP * - * @return array + * @return bool */ - public function getBasicAuth(); + public function isSoap(): bool; /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] + * Checks whether HTTP method is TRACE. + * if $_SERVER["REQUEST_METHOD"] === "TRACE" * - * @return array + * @return bool */ - public function getDigestAuth(); + public function isTrace(): bool; } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 31dd3efe..31051ef3 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -3,40 +3,46 @@ namespace Phalcon\Http; /** - * Phalcon\Http\Response - * * Part of the HTTP cycle is return responses to the clients. * Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. * HTTP responses are usually composed by headers and body. * - * + * ```php * $response = new \Phalcon\Http\Response(); * * $response->setStatusCode(200, "OK"); * $response->setContent("Hello"); * * $response->send(); - * + * ``` */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface +class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_sent = false; + protected $container; + + protected $content; - protected $_content; + protected $cookies; - protected $_headers; + protected $eventsManager; - protected $_cookies; + protected $file; - protected $_file; + protected $headers; - protected $_dependencyInjector; + /** + * @var bool + */ + protected $sent = false; + + + protected $statusCodes; /** @@ -49,321 +55,351 @@ class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\Injection public function __construct($content = null, $code = null, $status = null) {} /** - * Sets the dependency injector + * Appends a string to the HTTP response body * - * @param \Phalcon\DiInterface $dependencyInjector + * @param mixed $content + * @return ResponseInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function appendContent($content): ResponseInterface {} /** - * Returns the internal dependency injector + * Gets the HTTP response body * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getContent(): string {} /** - * Sets the HTTP response code + * Returns cookies set by the user * - * - * $response->setStatusCode(404, "Not Found"); - * + * @return \Phalcon\Http\Response\CookiesInterface + */ + public function getCookies(): CookiesInterface {} + + /** + * Returns the internal dependency injector * - * @param int $code - * @param string $message - * @return ResponseInterface + * @return \Phalcon\Di\DiInterface */ - public function setStatusCode($code, $message = null) {} + public function getDI(): DiInterface {} /** - * Returns the status code + * Returns the internal event manager * - * - * echo $response->getStatusCode(); - * + * @return \Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ManagerInterface {} + + /** + * Returns headers set by the user * - * @return int|null + * @return \Phalcon\Http\Response\HeadersInterface */ - public function getStatusCode() {} + public function getHeaders(): HeadersInterface {} /** * Returns the reason phrase * - * + * ```php * echo $response->getReasonPhrase(); - * + * ``` * * @return string|null */ - public function getReasonPhrase() {} + public function getReasonPhrase(): ?string {} /** - * Sets a headers bag for the response externally + * Returns the status code * - * @param \Phalcon\Http\Response\HeadersInterface $headers - * @return ResponseInterface + * ```php + * echo $response->getStatusCode(); + * ``` + * + * @return int|null */ - public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers) {} + public function getStatusCode(): ?int {} /** - * Returns headers set by the user + * Checks if a header exists * - * @return \Phalcon\Http\Response\HeadersInterface + * ```php + * $response->hasHeader("Content-Type"); + * ``` + * + * @param string $name + * @return bool */ - public function getHeaders() {} + public function hasHeader(string $name): bool {} /** - * Sets a cookies bag for the response externally + * Check if the response is already sent * - * @param \Phalcon\Http\Response\CookiesInterface $cookies - * @return Response + * @return bool */ - public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies) {} + public function isSent(): bool {} /** - * Returns cookies set by the user + * Redirect by HTTP to another action or URL * - * @return \Phalcon\Http\Response\CookiesInterface + * ```php + * // Using a string redirect (internal/external) + * $response->redirect("posts/index"); + * $response->redirect("http://en.wikipedia.org", true); + * $response->redirect("http://www.example.com/new-location", true, 301); + * + * // Making a redirection based on a named route + * $response->redirect( + * [ + * "for" => "index-lang", + * "lang" => "jp", + * "controller" => "index", + * ] + * ); + * ``` + * + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode + * @return ResponseInterface */ - public function getCookies() {} + public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface {} /** - * Overwrites a header in the response + * Remove a header in the response * - * - * $response->setHeader("Content-Type", "text/plain"); - * + * ```php + * $response->removeHeader("Expires"); + * ``` * * @param string $name - * @param mixed $value * @return ResponseInterface */ - public function setHeader($name, $value) {} + public function removeHeader(string $name): ResponseInterface {} /** - * Send a raw header to the response - * - * - * $response->setRawHeader("HTTP/1.1 404 Not Found"); - * + * Resets all the established headers * - * @param string $header * @return ResponseInterface */ - public function setRawHeader($header) {} + public function resetHeaders(): ResponseInterface {} /** - * Resets all the established headers + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function resetHeaders() {} + public function send(): ResponseInterface {} /** - * Sets an Expires header in the response that allows to use the HTTP cache - * - * - * $this->response->setExpires( - * new DateTime() - * ); - * + * Sends cookies to the client * - * @param \DateTime $datetime * @return ResponseInterface */ - public function setExpires(\DateTime $datetime) {} + public function sendCookies(): ResponseInterface {} /** - * Sets Last-Modified header - * - * - * $this->response->setLastModified( - * new DateTime() - * ); - * + * Sends headers to the client * - * @param \DateTime $datetime - * @return Response + * @return bool|ResponseInterface */ - public function setLastModified(\DateTime $datetime) {} + public function sendHeaders() {} /** * Sets Cache headers to use HTTP cache * - * + * ```php * $this->response->setCache(60); - * + * ``` * * @param int $minutes - * @return Response + * @return ResponseInterface */ - public function setCache($minutes) {} + public function setCache(int $minutes): ResponseInterface {} /** - * Sends a Not-Modified response + * Sets HTTP response body + * + * ```php + * $response->setContent("

Hello!

"); + * ``` + * + * @param string $content + * @return ResponseInterface + */ + public function setContent(string $content): ResponseInterface {} + + /** + * Sets the response content-length * + * ```php + * $response->setContentLength(2048); + * ``` + * + * @param int $contentLength * @return ResponseInterface */ - public function setNotModified() {} + public function setContentLength(int $contentLength): ResponseInterface {} /** * Sets the response content-type mime, optionally the charset * - * + * ```php * $response->setContentType("application/pdf"); * $response->setContentType("text/plain", "UTF-8"); - * + * ``` * * @param string $contentType * @param mixed $charset * @return ResponseInterface */ - public function setContentType($contentType, $charset = null) {} + public function setContentType(string $contentType, $charset = null): ResponseInterface {} /** - * Sets the response content-length - * - * - * $response->setContentLength(2048); - * + * Sets a cookies bag for the response externally * - * @param int $contentLength + * @param \Phalcon\Http\Response\CookiesInterface $cookies * @return ResponseInterface */ - public function setContentLength($contentLength) {} + public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface {} /** - * Set a custom ETag - * - * - * $response->setEtag(md5(time())); - * + * Sets the dependency injector * - * @param string $etag - * @return Response + * @param \Phalcon\Di\DiInterface $container */ - public function setEtag($etag) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Redirect by HTTP to another action or URL - * - * - * // Using a string redirect (internal/external) - * $response->redirect("posts/index"); - * $response->redirect("http://en.wikipedia.org", true); - * $response->redirect("http://www.example.com/new-location", true, 301); + * Set a custom ETag * - * // Making a redirection based on a named route - * $response->redirect( - * [ - * "for" => "index-lang", - * "lang" => "jp", - * "controller" => "index", - * ] + * ```php + * $response->setEtag( + * md5( + * time() + * ) * ); - * + * ``` * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode + * @param string $etag * @return ResponseInterface */ - public function redirect($location = null, $externalRedirect = false, $statusCode = 302) {} + public function setEtag(string $etag): ResponseInterface {} /** - * Sets HTTP response body + * Sets an Expires header in the response that allows to use the HTTP cache * - * - * $response->setContent("

Hello!

"); - *
+ * ```php + * $this->response->setExpires( + * new DateTime() + * ); + * ``` * - * @param string $content + * @param \DateTime $datetime * @return ResponseInterface */ - public function setContent($content) {} + public function setExpires(\DateTime $datetime): ResponseInterface {} /** - * Sets HTTP response body. The parameter is automatically converted to JSON - * and also sets default header: Content-Type: "application/json; charset=UTF-8" + * Sets the events manager * - * - * $response->setJsonContent( - * [ - * "status" => "OK", - * ] - * ); - * - * - * @param mixed $content - * @param int $jsonOptions - * @param int $depth - * @return ResponseInterface + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setJsonContent($content, $jsonOptions = 0, $depth = 512) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Appends a string to the HTTP response body + * Sets an attached file to be sent at the end of the request * - * @param mixed $content + * @param string $filePath + * @param mixed $attachmentName + * @param mixed $attachment * @return ResponseInterface */ - public function appendContent($content) {} + public function setFileToSend(string $filePath, $attachmentName = null, $attachment = true): ResponseInterface {} /** - * Gets the HTTP response body + * Overwrites a header in the response * - * @return string + * ```php + * $response->setHeader("Content-Type", "text/plain"); + * ``` + * + * @param string $name + * @param mixed $value + * @return ResponseInterface */ - public function getContent() {} + public function setHeader(string $name, $value): ResponseInterface {} /** - * Check if the response is already sent + * Sets a headers bag for the response externally * - * @return bool + * @param \Phalcon\Http\Response\HeadersInterface $headers + * @return ResponseInterface */ - public function isSent() {} + public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface {} /** - * Sends headers to the client + * Sets HTTP response body. The parameter is automatically converted to JSON + * and also sets default header: Content-Type: "application/json; charset=UTF-8" * + * ```php + * $response->setJsonContent( + * [ + * "status" => "OK", + * ] + * ); + * ``` + * + * @param mixed $content + * @param int $jsonOptions + * @param int $depth * @return ResponseInterface */ - public function sendHeaders() {} + public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512): ResponseInterface {} /** - * Sends cookies to the client + * Sets Last-Modified header + * + * ```php + * $this->response->setLastModified( + * new DateTime() + * ); + * ``` * + * @param \DateTime $datetime * @return ResponseInterface */ - public function sendCookies() {} + public function setLastModified(\DateTime $datetime): ResponseInterface {} /** - * Prints out HTTP response to the client + * Sends a Not-Modified response * * @return ResponseInterface */ - public function send() {} + public function setNotModified(): ResponseInterface {} /** - * Sets an attached file to be sent at the end of the request + * Sets the HTTP response code * - * @param string $filePath - * @param mixed $attachmentName - * @param mixed $attachment + * ```php + * $response->setStatusCode(404, "Not Found"); + * ``` + * + * @param int $code + * @param string $message * @return ResponseInterface */ - public function setFileToSend($filePath, $attachmentName = null, $attachment = true) {} + public function setStatusCode(int $code, string $message = null): ResponseInterface {} /** - * Remove a header in the response + * Send a raw header to the response * - * - * $response->removeHeader("Expires"); - * + * ```php + * $response->setRawHeader("HTTP/1.1 404 Not Found"); + * ``` * - * @param string $name - * @return Response + * @param string $header + * @return ResponseInterface */ - public function removeHeader($name) {} + public function setRawHeader(string $header): ResponseInterface {} } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index 17f684bc..d3176976 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -11,59 +11,81 @@ interface ResponseInterface { /** - * Sets the HTTP response code + * Appends a string to the HTTP response body * - * @param int $code - * @param string $message + * @param mixed $content * @return ResponseInterface */ - public function setStatusCode($code, $message = null); + public function appendContent($content): ResponseInterface; + + /** + * Gets the HTTP response body + * + * @return string + */ + public function getContent(): string; + + /** + * Returns the status code + * + * @return int|null + */ + public function getStatusCode(): ?int; /** * Returns headers set by the user * * @return \Phalcon\Http\Response\HeadersInterface */ - public function getHeaders(); + public function getHeaders(): HeadersInterface; /** - * Overwrites a header in the response + * Checks if a header exists * * @param string $name - * @param mixed $value - * @return ResponseInterface + * @return bool */ - public function setHeader($name, $value); + public function hasHeader(string $name): bool; /** - * Send a raw header to the response + * Checks if the response was already sent * - * @param string $header + * @return bool + */ + public function isSent(): bool; + + /** + * Redirect by HTTP to another action or URL + * + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode * @return ResponseInterface */ - public function setRawHeader($header); + public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface; /** * Resets all the established headers * * @return ResponseInterface */ - public function resetHeaders(); + public function resetHeaders(): ResponseInterface; /** - * Sets output expire time header + * Sets HTTP response body * - * @param \DateTime $datetime + * @param string $content * @return ResponseInterface */ - public function setExpires(\DateTime $datetime); + public function setContent(string $content): ResponseInterface; /** - * Sends a Not-Modified response + * Sets the response content-length * + * @param int $contentLength * @return ResponseInterface */ - public function setNotModified(); + public function setContentLength(int $contentLength): ResponseInterface; /** * Sets the response content-type mime, optionally the charset @@ -72,93 +94,93 @@ public function setNotModified(); * @param string $charset * @return ResponseInterface */ - public function setContentType($contentType, $charset = null); + public function setContentType(string $contentType, $charset = null): ResponseInterface; /** - * Sets the response content-length + * Sets output expire time header * - * @param int $contentLength + * @param \DateTime $datetime * @return ResponseInterface */ - public function setContentLength($contentLength); + public function setExpires(\DateTime $datetime): ResponseInterface; /** - * Redirect by HTTP to another action or URL + * Sets an attached file to be sent at the end of the request * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode + * @param string $filePath + * @param mixed $attachmentName * @return ResponseInterface */ - public function redirect($location = null, $externalRedirect = false, $statusCode = 302); + public function setFileToSend(string $filePath, $attachmentName = null): ResponseInterface; /** - * Sets HTTP response body + * Overwrites a header in the response * - * @param string $content + * @param string $name + * @param mixed $value * @return ResponseInterface */ - public function setContent($content); + public function setHeader(string $name, $value): ResponseInterface; /** * Sets HTTP response body. The parameter is automatically converted to JSON * - * + * ```php * $response->setJsonContent( * [ * "status" => "OK", * ] * ); - * + * ``` * * @param mixed $content * @return ResponseInterface */ - public function setJsonContent($content); + public function setJsonContent($content): ResponseInterface; /** - * Appends a string to the HTTP response body + * Sends a Not-Modified response * - * @param mixed $content * @return ResponseInterface */ - public function appendContent($content); + public function setNotModified(): ResponseInterface; /** - * Gets the HTTP response body + * Send a raw header to the response * - * @return string + * @param string $header + * @return ResponseInterface */ - public function getContent(); + public function setRawHeader(string $header): ResponseInterface; /** - * Sends headers to the client + * Sets the HTTP response code * + * @param int $code + * @param string $message * @return ResponseInterface */ - public function sendHeaders(); + public function setStatusCode(int $code, string $message = null): ResponseInterface; /** - * Sends cookies to the client + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function sendCookies(); + public function send(): ResponseInterface; /** - * Prints out HTTP response to the client + * Sends cookies to the client * * @return ResponseInterface */ - public function send(); + public function sendCookies(): ResponseInterface; /** - * Sets an attached file to be sent at the end of the request + * Sends headers to the client * - * @param string $filePath - * @param mixed $attachmentName - * @return ResponseInterface + * @return bool|ResponseInterface */ - public function setFileToSend($filePath, $attachmentName = null); + public function sendHeaders(); } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php new file mode 100644 index 00000000..99f4f9c7 --- /dev/null +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -0,0 +1,41 @@ + + */ + protected $body; + + /** + * @var + */ + protected $headers; + + /** + * Retrieves the HTTP protocol version as a string. + * + * The string MUST contain only the HTTP version number (e.g., '1.1', + * '1.0'). + * + * @return string HTTP protocol version. + * + * @var string + */ + protected $protocolVersion = '1.1'; + + /** + * Retrieves the URI instance. + * + * This method MUST return a UriInterface instance. + * + * @see http://tools.ietf.org/html/rfc3986#section-4.3 + * + * @var UriInterface + */ + protected $uri; + + + /** + * Gets the body of the message. + * + * @return + */ + public function getBody() {} + + /** + * Retrieves the HTTP protocol version as a string. + * + * The string MUST contain only the HTTP version number (e.g., '1.1', + * '1.0'). + * + * @return string + */ + public function getProtocolVersion(): string {} + + /** + * Retrieves the URI instance. + * + * This method MUST return a UriInterface instance. + * + * @return UriInterface + */ + public function getUri() {} + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name + * + * @param mixed $name + * @return array + */ + public function getHeader($name): array {} + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name + * + * @param mixed $name + * @return string + */ + public function getHeaderLine($name): string {} + + /** + * Retrieves all message header values. + * + * The keys represent the header name as it will be sent over the wire, and + * each value is an array of strings associated with the header. + * + * // Represent the headers as a string + * foreach ($message->getHeaders() as $name => $values) { + * echo $name . ': ' . implode(', ', $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return array + */ + public function getHeaders(): array {} + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name + * + * @param mixed $name + * @return bool + */ + public function hasHeader($name): bool {} + + /** + * Return an instance with the specified header appended with the given + * value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string|string[] $value + * + * @param string $name + * @param mixed $value + * @return object + */ + public function withAddedHeader($name, $value) {} + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body + * + * @throws InvalidArgumentException When the body is not valid. + * + * @param \Psr\Http\Message\StreamInterface $body + * @return object + */ + public function withBody(\Psr\Http\Message\StreamInterface $body) {} + + /** + * Return an instance with the provided value replacing the specified + * header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string|string[] $value + * + * @throws InvalidArgumentException for invalid header names or values. + * + * @param string $name + * @param mixed $value + * @return object + */ + public function withHeader($name, $value) {} + + /** + * Return an instance with the specified HTTP protocol version. + * + * The version string MUST contain only the HTTP version number (e.g., + * '1.1', '1.0'). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new protocol version. + * + * @param string $version + * + * @param mixed $version + * @return object + */ + public function withProtocolVersion($version) {} + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name + * + * @param mixed $name + * @return object + */ + public function withoutHeader($name) {} + + /** + * Ensure Host is the first header. + * + * @see: http://tools.ietf.org/html/rfc7230#section-5.4 + * + * @param Collection $collection + * + * @param \Phalcon\Collection $collection + * @return \Phalcon\Collection + */ + final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection {} + + /** + * Check the name of the header. Throw exception if not valid + * + * @see http://tools.ietf.org/html/rfc7230#section-3.2 + * + * @param mixed $name + * @param $name + */ + final protected function checkHeaderName($name) {} + + /** + * Validates a header value + * + * Most HTTP header field values are defined using common syntax + * components (token, quoted-string, and comment) separated by + * whitespace or specific delimiting characters. Delimiters are chosen + * from the set of US-ASCII visual characters not allowed in a token + * (DQUOTE and '(),/:;<=>?@[\]{}'). + * + * token = 1tchar + * + * tchar = '!' / '#' / '$' / '%' / '&' / ''' / '' + * / '+' / '-' / '.' / '^' / '_' / '`' / '|' / '~' + * / DIGIT / ALPHA + * ; any VCHAR, except delimiters + * + * A string of text is parsed as a single value if it is quoted using + * double-quote marks. + * + * quoted-string = DQUOTE( qdtext / quoted-pair ) DQUOTE + * qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text + * obs-text = %x80-FF + * + * Comments can be included in some HTTP header fields by surrounding + * the comment text with parentheses. Comments are only allowed in + * fields containing 'comment' as part of their field value definition. + * + * comment = '('( ctext / quoted-pair / comment ) ')' + * ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text + * + * The backslash octet ('\') can be used as a single-octet quoting + * mechanism within quoted-string and comment constructs. Recipients + * that process the value of a quoted-string MUST handle a quoted-pair + * as if it were replaced by the octet following the backslash. + * + * quoted-pair = '\' ( HTAB / SP / VCHAR / obs-text ) + * + * A sender SHOULD NOT generate a quoted-pair in a quoted-string except + * where necessary to quote DQUOTE and backslash octets occurring within + * that string. A sender SHOULD NOT generate a quoted-pair in a comment + * except where necessary to quote parentheses ['(' and ')'] and + * backslash octets occurring within that comment. + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 + * + * @param mixed $value + * @param $value + */ + final protected function checkHeaderValue($value) {} + + /** + * Returns the header values checked for validity + * + * @param $values + * + * @param mixed $values + * @return array + */ + final protected function getHeaderValue($values): array {} + + /** + * Return the host and if applicable the port + * + * @param UriInterface $uri + * + * @param \Psr\Http\Message\UriInterface $uri + * @return string + */ + final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string {} + + /** + * Populates the header collection + * + * @param array $headers + * + * @param array $headers + * @return \Phalcon\Collection + */ + final protected function populateHeaderCollection(array $headers): Collection {} + + /** + * Set a valid stream + * + * @param string $mode + * + * @param StreamInterface|resource|string $body + * @param string $mode + * @return \Psr\Http\Message\StreamInterface + */ + final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface {} + + /** + * Sets the headers + * + * @param $headers + * + * @param mixed $headers + * @return \Phalcon\Collection + */ + final protected function processHeaders($headers): Collection {} + + /** + * Checks the protocol + * + * @param string $protocol + * + * @param mixed $protocol + * @return string + */ + final protected function processProtocol($protocol = ''): string {} + +} diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php new file mode 100644 index 00000000..3fdf32fd --- /dev/null +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -0,0 +1,165 @@ +getQuery()` or from the `QUERY_STRING` server param. + * + * @var array + */ + private $queryParams = array(); + + /** + * Retrieve server parameters. + * + * Retrieves data related to the incoming request environment, + * typically derived from PHP's $_SERVER superglobal. The data IS NOT + * REQUIRED to originate from $_SERVER. + * + * @var array + */ + private $serverParams = array(); + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @var array + */ + private $uploadedFiles = array(); + + + /** + * Retrieve cookies. + * + * Retrieves cookies sent by the client to the server. + * + * The data MUST be compatible with the structure of the $_COOKIE + * superglobal. + * + * @return array + */ + public function getCookieParams(): array {} + + /** + * Retrieve any parameters provided in the request body. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, this method MUST + * return the contents of $_POST. + * + * Otherwise, this method may return any results of deserializing + * the request body content; as parsing returns structured content, the + * potential types MUST be arrays or objects only. A null value indicates + * the absence of body content. + * + * @return mixed + */ + public function getParsedBody() {} + + /** + * Retrieve query string arguments. + * + * Retrieves the deserialized query string arguments, if any. + * + * Note: the query params might not be in sync with the URI or server + * params. If you need to ensure you are only getting the original + * values, you may need to parse the query string from + * `getUri()->getQuery()` or from the `QUERY_STRING` server param. + * + * @return array + */ + public function getQueryParams(): array {} + + /** + * Retrieve server parameters. + * + * Retrieves data related to the incoming request environment, + * typically derived from PHP's $_SERVER superglobal. The data IS NOT + * REQUIRED to originate from $_SERVER. + * + * @return array + */ + public function getServerParams(): array {} + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @return array + */ + public function getUploadedFiles(): array {} + + /** + * ServerRequest constructor. + * + * @param string $method + * @param UriInterface|string|null $uri + * @param array $serverParams + * @param StreamInterface|string $body + * @param array $headers + * @param array $cookies + * @param array $queryParams + * @param array $uploadFiles + * @param null|array|object $parsedBody + * @param string $protocol + */ + public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') {} + + /** + * Retrieve a single derived request attribute. + * + * Retrieves a single derived request attribute as described in + * getAttributes(). If the attribute has not been previously set, returns + * the default value as provided. + * + * This method obviates the need for a hasAttribute() method, as it allows + * specifying a default value to return if the attribute is not found. + * + * @param mixed|null $defaultValue + * + * @param string $name + * @param mixed $defaultValue + * @return mixed + */ + public function getAttribute($name, $defaultValue = null) {} + + /** + * Retrieve attributes derived from the request. + * + * The request 'attributes' may be used to allow injection of any + * parameters derived from the request: e.g., the results of path + * match operations; the results of decrypting cookies; the results of + * deserializing non-form-encoded message bodies; etc. Attributes + * will be application and request specific, and CAN be mutable. + * + * @return array + */ + public function getAttributes(): array {} + + /** + * Return an instance with the specified derived request attribute. + * + * This method allows setting a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated attribute. + * + * @param mixed $value + * + * @param string $name + * @param mixed $value + * @return ServerRequest + */ + public function withAttribute($name, $value): ServerRequest {} + + /** + * Return an instance with the specified cookies. + * + * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST + * be compatible with the structure of $_COOKIE. Typically, this data will + * be injected at instantiation. + * + * This method MUST NOT update the related Cookie header of the request + * instance, nor related values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated cookie values. + * + * @param array $cookies + * + * @param array $cookies + * @return ServerRequest + */ + public function withCookieParams(array $cookies): ServerRequest {} + + /** + * Return an instance with the specified body parameters. + * + * These MAY be injected during instantiation. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, use this method + * ONLY to inject the contents of $_POST. + * + * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of + * deserializing the request body content. Deserialization/parsing returns + * structured data, and, as such, this method ONLY accepts arrays or + * objects, or a null value if nothing was available to parse. + * + * As an example, if content negotiation determines that the request data + * is a JSON payload, this method could be used to create a request + * instance with the deserialized parameters. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array|object|null $data + * + * @throws InvalidArgumentException if an unsupported argument type is + * provided. + * + * @param mixed $data + * @return ServerRequest + */ + public function withParsedBody($data): ServerRequest {} + + /** + * Return an instance with the specified query string arguments. + * + * These values SHOULD remain immutable over the course of the incoming + * request. They MAY be injected during instantiation, such as from PHP's + * $_GET superglobal, or MAY be derived from some other value such as the + * URI. In cases where the arguments are parsed from the URI, the data + * MUST be compatible with what PHP's parse_str() would return for + * purposes of how duplicate query parameters are handled, and how nested + * sets are handled. + * + * Setting query string arguments MUST NOT change the URI stored by the + * request, nor the values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated query string arguments. + * + * @param array $query + * + * @param array $query + * @return ServerRequest + */ + public function withQueryParams(array $query): ServerRequest {} + + /** + * Create a new instance with the specified uploaded files. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array $uploadedFiles + * + * @throws InvalidArgumentException if an invalid structure is provided. + * + * @param array $uploadedFiles + * @return ServerRequest + */ + public function withUploadedFiles(array $uploadedFiles): ServerRequest {} + + /** + * Return an instance that removes the specified derived request attribute. + * + * This method allows removing a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the attribute. + * + * @param string $name + * + * @param mixed $name + * @return ServerRequest + */ + public function withoutAttribute($name): ServerRequest {} + + /** + * Checks the uploaded files + * + * @param array $files + */ + private function checkUploadedFiles(array $files) {} + +} diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php new file mode 100644 index 00000000..2821ea96 --- /dev/null +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class InvalidArgumentException extends InvalidArgumentException implements \Throwable +{ + +} diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php new file mode 100644 index 00000000..40b7b316 --- /dev/null +++ b/src/Phalcon/http/message/stream/Input.php @@ -0,0 +1,76 @@ + + * ```php * use Phalcon\Mvc\Controller; * * class PostsController extends Controller @@ -20,58 +20,58 @@ * foreach ($this->request->getUploadedFiles() as $file) { * echo $file->getName(), " ", $file->getSize(), "\n"; * } - * } + * } * } * } - * + * ``` */ class File implements \Phalcon\Http\Request\FileInterface { + /** + * @var string|null + */ + protected $error; - protected $_name; + /** + * @var string + */ + protected $extension; + /** + * @var string|null + */ + protected $key; - protected $_tmp; + protected $name; - protected $_size; + protected $realType; - protected $_type; + protected $size; - protected $_realType; - /** - * @var string|null - */ - protected $_error; + protected $tmp; - /** - * @var string|null - */ - protected $_key; - /** - * @var string - */ - protected $_extension; + protected $type; /** * @return string|null */ - public function getError() {} + public function getError(): ?string {} /** - * @return string|null + * @return string */ - public function getKey() {} + public function getExtension(): string {} /** - * @return string + * @return string|null */ - public function getExtension() {} + public function getKey(): ?string {} /** * Phalcon\Http\Request\File constructor @@ -82,47 +82,47 @@ public function getExtension() {} public function __construct(array $file, $key = null) {} /** - * Returns the file size of the uploaded file + * Returns the real name of the uploaded file * - * @return int + * @return string */ - public function getSize() {} + public function getName(): string {} /** - * Returns the real name of the uploaded file + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getName() {} + public function getRealType(): string {} /** - * Returns the temporary name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getTempName() {} + public function getSize(): int {} /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Returns the temporary name of the uploaded file * * @return string */ - public function getType() {} + public function getTempName(): string {} /** - * Gets the real mime type of the upload file using finfo + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getRealType() {} + public function getType(): string {} /** * Checks whether the file has been uploaded via Post. * * @return bool */ - public function isUploadedFile() {} + public function isUploadedFile(): bool {} /** * Moves the temporary file to a destination within the application @@ -130,6 +130,6 @@ public function isUploadedFile() {} * @param string $destination * @return bool */ - public function moveTo($destination) {} + public function moveTo(string $destination): bool {} } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 913d759b..69f37a10 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -11,40 +11,40 @@ interface FileInterface { /** - * Returns the file size of the uploaded file + * Returns the real name of the uploaded file * - * @return int + * @return string */ - public function getSize(); + public function getName(): string; /** - * Returns the real name of the uploaded file + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getName(); + public function getRealType(): string; /** - * Returns the temporal name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getTempName(); + public function getSize(): int; /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Returns the temporal name of the uploaded file * * @return string */ - public function getType(); + public function getTempName(): string; /** - * Gets the real mime type of the upload file using finfo + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getRealType(); + public function getType(): string; /** * Move the temporary file to a destination @@ -52,6 +52,6 @@ public function getRealType(); * @param string $destination * @return bool */ - public function moveTo($destination); + public function moveTo(string $destination): bool; } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 8f7c5f7a..8e63b483 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -7,12 +7,13 @@ * * This class is a bag to manage the cookies. * - * A cookies bag is automatically registered as part of the 'response' service in the DI. - * By default, cookies are automatically encrypted before being sent to the client and are - * decrypted when retrieved from the user. To set sign key used to generate a message - * authentication code use `Phalcon\Http\Response\Cookies::setSignKey`. + * A cookies bag is automatically registered as part of the 'response' service + * in the DI. By default, cookies are automatically encrypted before being sent + * to the client and are decrypted when retrieved from the user. To set sign key + * used to generate a message authentication code use + * `Phalcon\Http\Response\Cookies::setSignKey()`. * - * + * ```php * use Phalcon\Di; * use Phalcon\Crypt; * use Phalcon\Http\Response\Cookies; @@ -26,6 +27,7 @@ * * // The `$key' should have been previously generated in a cryptographically safe way. * $key = "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3"; + * * $crypt->setKey($key); * * return $crypt; @@ -40,26 +42,24 @@ * // The `$key' MUST be at least 32 characters long and generated using a * // cryptographically secure pseudo random generator. * $key = "#1dj8$=dp?.ak//j1V$~%0XaK\xb1\x8d\xa9\x98\x054t7w!z%CF-Jk\x98\x05\\\x5c"; + * * $cookies->setSignKey($key); * * return $cookies; * } * ); - * + * ``` */ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $container; - protected $_registered = false; + protected $cookies = array(); - protected $_useEncryption = true; - - protected $_cookies; + protected $registered = false; /** * The cookie's sign key. @@ -69,63 +69,85 @@ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\In protected $signKey = null; + protected $useEncryption = true; + + /** * Phalcon\Http\Response\Cookies constructor * * @param bool $useEncryption * @param string $signKey */ - public function __construct($useEncryption = true, $signKey = null) {} + public function __construct(bool $useEncryption = true, string $signKey = null) {} /** - * Sets the cookie's sign key. - * - * The `$signKey' MUST be at least 32 characters long - * and generated using a cryptographically secure pseudo random generator. + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * - * Use NULL to disable cookie signing. + * @param string $name + * @return bool + */ + public function delete(string $name): bool {} + + /** + * Gets a cookie from the bag * - * @see \Phalcon\Security\Random - * @param string $signKey + * @param string $name * @return \Phalcon\Http\CookieInterface */ - public function setSignKey($signKey = null) {} + public function get(string $name): CookieInterface {} /** - * Sets the dependency injector + * Gets all cookies from the bag * - * @param \Phalcon\DiInterface $dependencyInjector + * @return array */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function getCookies(): array {} /** * Returns the internal dependency injector * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** - * Set if cookies in the bag must be automatically encrypted/decrypted + * Check if a cookie is defined in the bag or exists in the _COOKIE + * superglobal * - * @param bool $useEncryption - * @return \Phalcon\Http\Response\CookiesInterface + * @param string $name + * @return bool */ - public function useEncryption($useEncryption) {} + public function has(string $name): bool {} /** * Returns if the bag is automatically encrypting/decrypting cookies * * @return bool */ - public function isUsingEncryption() {} + public function isUsingEncryption(): bool {} + + /** + * Reset set cookies + * + * @return \Phalcon\Http\Response\CookiesInterface + */ + public function reset(): CookiesInterface {} + + /** + * Sends the cookies to the client + * Cookies aren't sent if headers are sent in the current request + * + * @return bool + */ + public function send(): bool {} /** * Sets a cookie to be sent at the end of the request. * * This method overrides any cookie set before with the same name. * - * + * ```php * use Phalcon\Http\Response\Cookies; * * $now = new DateTimeImmutable(); @@ -137,7 +159,7 @@ public function isUsingEncryption() {} * json_encode(['user_id' => 1]), * (int) $tomorrow->format('U'), * ); - * + * ``` * * @param string $name * @param mixed $value @@ -148,46 +170,35 @@ public function isUsingEncryption() {} * @param bool $httpOnly * @return \Phalcon\Http\Response\CookiesInterface */ - public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null) {} + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface {} /** - * Gets a cookie from the bag + * Sets the dependency injector * - * @param string $name - * @return \Phalcon\Http\Response\CookiesInterface + * @param \Phalcon\Di\DiInterface $container */ - public function get($name) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal + * Sets the cookie's sign key. * - * @param string $name - * @return bool - */ - public function has($name) {} - - /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * The `$signKey' MUST be at least 32 characters long + * and generated using a cryptographically secure pseudo random generator. * - * @param string $name - * @return bool - */ - public function delete($name) {} - - /** - * Sends the cookies to the client - * Cookies aren't sent if headers are sent in the current request + * Use NULL to disable cookie signing. * - * @return bool + * @see \Phalcon\Security\Random + * @param string $signKey + * @return \Phalcon\Http\CookieInterface */ - public function send() {} + public function setSignKey(string $signKey = null): CookieInterface {} /** - * Reset set cookies + * Set if cookies in the bag must be automatically encrypted/decrypted * + * @param bool $useEncryption * @return \Phalcon\Http\Response\CookiesInterface */ - public function reset() {} + public function useEncryption(bool $useEncryption): CookiesInterface {} } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index cd1c100e..abe18b6f 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -11,71 +11,71 @@ interface CookiesInterface { /** - * Set if cookies in the bag must be automatically encrypted/decrypted - * - * @param bool $useEncryption - * @return CookiesInterface - */ - public function useEncryption($useEncryption); - - /** - * Returns if the bag is automatically encrypting/decrypting cookies + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * + * @param string $name * @return bool */ - public function isUsingEncryption(); + public function delete(string $name): bool; /** - * Sets a cookie to be sent at the end of the request + * Gets a cookie from the bag * * @param string $name - * @param mixed $value - * @param int $expire - * @param string $path - * @param bool $secure - * @param string $domain - * @param bool $httpOnly - * @return CookiesInterface + * @return \Phalcon\Http\CookieInterface */ - public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null); + public function get(string $name): CookieInterface; /** - * Gets a cookie from the bag + * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal * * @param string $name - * @return CookiesInterface + * @return bool */ - public function get($name); + public function has(string $name): bool; /** - * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal + * Returns if the bag is automatically encrypting/decrypting cookies * - * @param string $name * @return bool */ - public function has($name); + public function isUsingEncryption(): bool; /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * Reset set cookies * - * @param string $name - * @return bool + * @return CookiesInterface */ - public function delete($name); + public function reset(): CookiesInterface; /** * Sends the cookies to the client * * @return bool */ - public function send(); + public function send(): bool; /** - * Reset set cookies + * Sets a cookie to be sent at the end of the request + * + * @param string $name + * @param mixed $value + * @param int $expire + * @param string $path + * @param bool $secure + * @param string $domain + * @param bool $httpOnly + * @return CookiesInterface + */ + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface; + + /** + * Set if cookies in the bag must be automatically encrypted/decrypted * + * @param bool $useEncryption * @return CookiesInterface */ - public function reset(); + public function useEncryption(bool $useEncryption): CookiesInterface; } diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 7ccc1a96..31f52cbd 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -10,64 +10,64 @@ class Headers implements \Phalcon\Http\Response\HeadersInterface { - protected $_headers = array(); + protected $headers = array(); /** - * Sets a header to be sent at the end of the request + * Gets a header value from the internal bag * * @param string $name - * @param string $value + * @return string|bool */ - public function set($name, $value) {} + public function get(string $name) {} /** - * Gets a header value from the internal bag + * Sets a header to be sent at the end of the request * * @param string $name - * @return string|bool + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Sets a raw header to be sent at the end of the request + * Removes a header to be sent at the end of the request * * @param string $header */ - public function setRaw($header) {} + public function remove(string $header) {} /** - * Removes a header to be sent at the end of the request - * - * @param string $header + * Reset set headers */ - public function remove($header) {} + public function reset() {} /** * Sends the headers to the client * * @return bool */ - public function send() {} + public function send(): bool {} /** - * Reset set headers + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value */ - public function reset() {} + public function set(string $name, string $value) {} /** - * Returns the current headers as an array + * Sets a raw header to be sent at the end of the request * - * @return array + * @param string $header */ - public function toArray() {} + public function setRaw(string $header) {} /** - * Restore a \Phalcon\Http\Response\Headers object + * Returns the current headers as an array * - * @param array $data - * @return \Phalcon\Http\Response\HeadersInterface + * @return array */ - public static function __set_state(array $data) {} + public function toArray(): array {} } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index 9d7349ea..a2b439a8 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -11,46 +11,46 @@ interface HeadersInterface { /** - * Sets a header to be sent at the end of the request + * Gets a header value from the internal bag * * @param string $name - * @param string $value + * @return string|bool */ - public function set($name, $value); + public function get(string $name); /** - * Gets a header value from the internal bag + * Returns true if the header is set, false otherwise * * @param string $name - * @return string|bool + * @return bool */ - public function get($name); + public function has(string $name): bool; /** - * Sets a raw header to be sent at the end of the request - * - * @param string $header + * Reset set headers */ - public function setRaw($header); + public function reset(); /** * Sends the headers to the client * * @return bool */ - public function send(); + public function send(): bool; /** - * Reset set headers + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value */ - public function reset(); + public function set(string $name, string $value); /** - * Restore a \Phalcon\Http\Response\Headers object + * Sets a raw header to be sent at the end of the request * - * @param array $data - * @return HeadersInterface + * @param string $header */ - public static function __set_state(array $data); + public function setRaw(string $header); } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php new file mode 100644 index 00000000..8f3353b7 --- /dev/null +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Enum +{ + + const AUTO = 4; + + + const HEIGHT = 3; + + + const INVERSE = 5; + + + const NONE = 1; + + + const PRECISE = 6; + + + const TENSILE = 7; + + + const WIDTH = 2; + + + const HORIZONTAL = 11; + + + const VERTICAL = 12; + + +} diff --git a/src/Phalcon/image/Exception.php b/src/Phalcon/image/Exception.php index 7e881cbe..d590f857 100644 --- a/src/Phalcon/image/Exception.php +++ b/src/Phalcon/image/Exception.php @@ -2,7 +2,14 @@ namespace Phalcon\Image; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/image/Factory.php b/src/Phalcon/image/Factory.php deleted file mode 100644 index 36ef8eb9..00000000 --- a/src/Phalcon/image/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ - - * use Phalcon\Image\Factory; - * - * $options = [ - * "width" => 200, - * "height" => 200, - * "file" => "upload/test.jpg", - * "adapter" => "imagick", - * ]; - * $image = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php new file mode 100644 index 00000000..234d2713 --- /dev/null +++ b/src/Phalcon/image/ImageFactory.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +interface AdapterInterface +{ + + /** + * @param string $color + * @param int $opacity + */ + public function background(string $color, int $opacity = 100); + + /** + * @param int $radius + */ + public function blur(int $radius); + + /** + * @param int $width + * @param int $height + * @param int $offsetX + * @param int $offsetY + */ + public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null); + + /** + * @param int $direction + */ + public function flip(int $direction); + + /** + * @param AdapterInterface $watermark + */ + public function mask(AdapterInterface $watermark); + + /** + * @param int $amount + */ + public function pixelate(int $amount); + + /** + * @param int $height + * @param int $opacity + * @param bool $fadeIn + */ + public function reflection(int $height, int $opacity = 100, bool $fadeIn = false); + + /** + * @param string $ext + * @param int $quality + */ + public function render(string $ext = null, int $quality = 100); + + /** + * @param int $width + * @param int $height + * @param int $master + */ + public function resize(int $width = null, int $height = null, int $master = Image::AUTO); + + /** + * @param int $degrees + */ + public function rotate(int $degrees); + + /** + * @param string $file + * @param int $quality + */ + public function save(string $file = null, int $quality = 100); + + /** + * @param int $amount + */ + public function sharpen(int $amount); + + /** + * @param string $text + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + * @param string $color + * @param int $size + * @param string $fontfile + */ + public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null); + + /** + * @param AdapterInterface $watermark + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + */ + public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100); + +} diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index c162e8a3..e8769205 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -2,30 +2,58 @@ namespace Phalcon\Image\Adapter; - -class Gd extends \Phalcon\Image\Adapter +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $_checked = false; + static protected $checked = false; + + + /** + * @param string $file + * @param int $width + * @param int $height + */ + public function __construct(string $file, int $width = null, int $height = null) {} + + public function __destruct() {} /** * @return bool */ - public static function check() {} + public static function check(): bool {} /** - * @param string $file - * @param int $width - * @param int $height + * @return string + */ + public static function getVersion(): string {} + + /** + * @param int $r + * @param int $g + * @param int $b + * @param int $opacity */ - public function __construct($file, $width = null, $height = null) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) {} + + /** + * @param int $radius + */ + protected function processBlur(int $radius) {} /** * @param int $width * @param int $height */ - protected function _resize($width, $height) {} + protected function processCreate(int $width, int $height) {} /** * @param int $width @@ -33,93 +61,77 @@ protected function _resize($width, $height) {} * @param int $offsetX * @param int $offsetY */ - protected function _crop($width, $height, $offsetX, $offsetY) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} /** - * @param int $degrees + * @param int $direction */ - protected function _rotate($degrees) {} + protected function processFlip(int $direction) {} /** - * @param int $direction + * @param AdapterInterface $mask */ - protected function _flip($direction) {} + protected function processMask(AdapterInterface $mask) {} /** * @param int $amount */ - protected function _sharpen($amount) {} + protected function processPixelate(int $amount) {} /** * @param int $height * @param int $opacity * @param bool $fadeIn */ - protected function _reflection($height, $opacity, $fadeIn) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) {} /** - * @param \Phalcon\Image\Adapter $watermark - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - */ - protected function _watermark(\Phalcon\Image\Adapter $watermark, $offsetX, $offsetY, $opacity) {} - - /** - * @param string $text - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @param string $ext + * @param int $quality */ - protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} + protected function processRender(string $ext, int $quality) {} /** - * @param \Phalcon\Image\Adapter $mask + * @param int $width + * @param int $height */ - protected function _mask(\Phalcon\Image\Adapter $mask) {} + protected function processResize(int $width, int $height) {} /** - * @param int $r - * @param int $g - * @param int $b - * @param int $opacity + * @param int $degrees */ - protected function _background($r, $g, $b, $opacity) {} + protected function processRotate(int $degrees) {} /** - * @param int $radius + * @param string $file + * @param int $quality */ - protected function _blur($radius) {} + protected function processSave(string $file, int $quality) {} /** * @param int $amount */ - protected function _pixelate($amount) {} - - /** - * @param string $file - * @param int $quality - */ - protected function _save($file, $quality) {} + protected function processSharpen(int $amount) {} /** - * @param string $ext - * @param int $quality + * @param string $text + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - protected function _render($ext, $quality) {} + protected function processText(string $text, int $offsetX, int $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} /** - * @param int $width - * @param int $height + * @param AdapterInterface $watermark + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - protected function _create($width, $height) {} - - - public function __destruct() {} + protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) {} } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 2164b7f7..6164a769 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -7,7 +7,7 @@ * * Image manipulation support. Allows images to be resized, cropped, etc. * - * + * ```php * $image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg"); * * $image->resize(200, 200)->rotate(90)->crop(100, 100); @@ -15,24 +15,17 @@ * if ($image->save()) { * echo "success"; * } - * + * ``` */ -class Imagick extends \Phalcon\Image\Adapter +class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $_version = 0; + static protected $checked = false; - static protected $_checked = false; + static protected $version = 0; - /** - * Checks if Imagick is enabled - * - * @return bool - */ - public static function check() {} - /** * \Phalcon\Image\Adapter\Imagick constructor * @@ -40,158 +33,166 @@ public static function check() {} * @param int $width * @param int $height */ - public function __construct($file, $width = null, $height = null) {} + public function __construct(string $file, int $width = null, int $height = null) {} /** - * Execute a resize. - * - * @param int $width - * @param int $height + * Destroys the loaded image to free up resources. */ - protected function _resize($width, $height) {} + public function __destruct() {} /** - * This method scales the images using liquid rescaling method. Only support Imagick + * Checks if Imagick is enabled * - * @param int $width new width - * @param int $height new height - * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. - * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. + * @return bool */ - protected function _liquidRescale($width, $height, $deltaX, $rigidity) {} + public static function check(): bool {} /** - * Execute a crop. + * Get instance * - * @param int $width - * @param int $height - * @param int $offsetX - * @param int $offsetY + * @return \Imagick */ - protected function _crop($width, $height, $offsetX, $offsetY) {} + public function getInternalImInstance(): \Imagick {} /** - * Execute a rotation. + * Sets the limit for a particular resource in megabytes * - * @param int $degrees + * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes + * @param int $type + * @param int $limit */ - protected function _rotate($degrees) {} + public function setResourceLimit(int $type, int $limit) {} /** - * Execute a flip. + * Execute a background. * - * @param int $direction + * @param int $r + * @param int $g + * @param int $b + * @param int $opacity */ - protected function _flip($direction) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) {} /** - * Execute a sharpen. + * Blur image * - * @param int $amount + * @param int $radius Blur radius */ - protected function _sharpen($amount) {} + protected function processBlur(int $radius) {} /** - * Execute a reflection. + * Execute a crop. * + * @param int $width * @param int $height - * @param int $opacity - * @param bool $fadeIn + * @param int $offsetX + * @param int $offsetY */ - protected function _reflection($height, $opacity, $fadeIn) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} /** - * Execute a watermarking. + * Execute a flip. * - * @param \Phalcon\Image\Adapter $image - * @param int $offsetX - * @param int $offsetY - * @param int $opacity + * @param int $direction */ - protected function _watermark(\Phalcon\Image\Adapter $image, $offsetX, $offsetY, $opacity) {} + protected function processFlip(int $direction) {} /** - * Execute a text + * This method scales the images using liquid rescaling method. Only support + * Imagick * - * @param string $text - * @param mixed $offsetX - * @param mixed $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @param int $width new width + * @param int $height new height + * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. + * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ - protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} + protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) {} /** * Composite one image onto another * - * @param \Phalcon\Image\Adapter $image + * @param AdapterInterface $image */ - protected function _mask(\Phalcon\Image\Adapter $image) {} + protected function processMask(AdapterInterface $image) {} /** - * Execute a background. + * Pixelate image * - * @param int $r - * @param int $g - * @param int $b + * @param int $amount amount to pixelate + */ + protected function processPixelate(int $amount) {} + + /** + * Execute a reflection. + * + * @param int $height * @param int $opacity + * @param bool $fadeIn */ - protected function _background($r, $g, $b, $opacity) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) {} /** - * Blur image + * Execute a render. * - * @param int $radius Blur radius + * @param string $extension + * @param int $quality + * @return string */ - protected function _blur($radius) {} + protected function processRender(string $extension, int $quality): string {} /** - * Pixelate image + * Execute a resize. * - * @param int $amount amount to pixelate + * @param int $width + * @param int $height */ - protected function _pixelate($amount) {} + protected function processResize(int $width, int $height) {} /** - * Execute a save. + * Execute a rotation. * - * @param string $file - * @param int $quality + * @param int $degrees */ - protected function _save($file, $quality) {} + protected function processRotate(int $degrees) {} /** - * Execute a render. + * Execute a save. * - * @param string $extension + * @param string $file * @param int $quality - * @return string */ - protected function _render($extension, $quality) {} + protected function processSave(string $file, int $quality) {} /** - * Destroys the loaded image to free up resources. + * Execute a sharpen. + * + * @param int $amount */ - public function __destruct() {} + protected function processSharpen(int $amount) {} /** - * Get instance + * Execute a text * - * @return \Imagick + * @param string $text + * @param mixed $offsetX + * @param mixed $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - public function getInternalImInstance() {} + protected function processText(string $text, $offsetX, $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} /** - * Sets the limit for a particular resource in megabytes + * Execute a watermarking. * - * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes - * @param int $type - * @param int $limit + * @param AdapterInterface $image + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - public function setResourceLimit($type, $limit) {} + protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) {} } diff --git a/src/Phalcon/logger/Adapter.php b/src/Phalcon/logger/Adapter.php deleted file mode 100644 index 6332108c..00000000 --- a/src/Phalcon/logger/Adapter.php +++ /dev/null @@ -1,174 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AdapterFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param string $fileName + * @param array $options + * @return AdapterInterface + */ + public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/logger/AdapterInterface.php b/src/Phalcon/logger/AdapterInterface.php deleted file mode 100644 index a6ed7ba9..00000000 --- a/src/Phalcon/logger/AdapterInterface.php +++ /dev/null @@ -1,144 +0,0 @@ - - * use Phalcon\Logger\Factory; - * - * $options = [ - * "name" => "log.txt", - * "adapter" => "file", - * ]; - * $logger = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/logger/Formatter.php b/src/Phalcon/logger/Formatter.php deleted file mode 100644 index 24868d1c..00000000 --- a/src/Phalcon/logger/Formatter.php +++ /dev/null @@ -1,30 +0,0 @@ - $adapter1, + * 'remote' => $adapter2, + * 'manager' => $adapter3, + * ] + * ); + * + * // Log to all adapters + * $logger->error('Something went wrong'); + * + * // Log to specific adapters + * $logger + * ->excludeAdapters(['manager']) + * ->info('This does not go to the "manager" logger); + * ``` + */ +class Logger implements \Psr\Log\LoggerInterface +{ + + const ALERT = 2; + + + const CRITICAL = 1; + + + const CUSTOM = 8; + + + const DEBUG = 7; + + + const EMERGENCY = 0; + + + const ERROR = 3; + + + const INFO = 6; + + + const NOTICE = 5; + + + const WARNING = 4; + + /** + * The adapter stack + * + * @var AdapterInterface[] + */ + protected $adapters = array(); + + /** + * @var string + */ + protected $name = ''; + + /** + * The excluded adapters for this log process + * + * @var AdapterInterface[] + */ + protected $excluded = array(); + + + /** + * Constructor. + * + * @param string $name The name of the logger + * @param array $adapters The collection of adapters to be used for logging (default []) + */ + public function __construct(string $name, array $adapters = array()) {} + + /** + * Add an adapter to the stack. For processing we use FIFO + * + * @param string $name The name of the adapter + * @param $adapter The adapter to add to the stack + * @return Logger + */ + public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger {} + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + */ + public function alert($message, array $context = array()) {} + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + */ + public function critical($message, array $context = array()) {} + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + */ + public function debug($message, array $context = array()) {} + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + */ + public function error($message, array $context = array()) {} + + /** + * System is unusable. + * + * @param string $message + * @param array $context + */ + public function emergency($message, array $context = array()) {} + + /** + * Exclude certain adapters. + * + * @param array $adapters + * @return Logger + */ + public function excludeAdapters(array $adapters = array()): Logger {} + + /** + * Returns an adapter from the stack + * + * @param string name The name of the adapter + * + * @throws + * @param string $name + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function getAdapter(string $name): AdapterInterface {} + + /** + * Returns the adapter stack array + * + * @return array + */ + public function getAdapters(): array {} + + /** + * Returns the name of the logger + * + * @return string + */ + public function getName(): string {} + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + */ + public function info($message, array $context = array()) {} + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + */ + public function log($level, $message, array $context = array()) {} + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + */ + public function notice($message, array $context = array()) {} + + /** + * Removes an adapter from the stack + * + * @param string name The name of the adapter + * + * @throws + * @param string $name + * @return Logger + */ + public function removeAdapter(string $name): Logger {} + + /** + * Sets the adapters stack overriding what is already there + * + * @param array $adapters An array of adapters + * @return Logger + */ + public function setAdapters(array $adapters): Logger {} + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + */ + public function warning($message, array $context = array()) {} + + /** + * Adds a message to each handler for processing + * + * @param string message + * + * @throws + * @param int $level + * @param string $message + * @param array $context + * @return bool + */ + protected function addMessage(int $level, string $message, array $context = array()): bool {} + + /** + * Returns an array of log levels with integer to string conversion + * + * @return array + */ + protected function getLevels(): array {} + + /** + * Converts the level from string/word to an integer + * + * @param string|int $level + * @return int + */ + private function getLevelNumber($level): int {} + +} diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php new file mode 100644 index 00000000..a53c608b --- /dev/null +++ b/src/Phalcon/logger/LoggerFactory.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface +{ + /** + * Name of the default formatter class + * + * @var string + */ + protected $defaultFormatter = 'Line'; + + /** + * Formatter + * + * @var + */ + protected $formatter; + + /** + * Tells if there is an active transaction or not + * + * @var bool + */ + protected $inTransaction = false; + + /** + * Array with messages queued in the transaction + * + * @var array + */ + protected $queue = array(); + + + /** + * Destructor cleanup + */ + public function __destruct() {} + + /** + * Adds a message to the queue + * + * @param \Phalcon\Logger\Item $item + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function add(\Phalcon\Logger\Item $item): AdapterInterface {} + + /** + * Starts a transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function begin(): AdapterInterface {} + + /** + * Commits the internal transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function commit(): AdapterInterface {} + + /** + * @return \Phalcon\Logger\Formatter\FormatterInterface + */ + public function getFormatter(): FormatterInterface {} + + /** + * Returns the whether the logger is currently in an active transaction or not + * + * @return bool + */ + public function inTransaction(): bool {} + + /** + * Processes the message in the adapter + * + * @param \Phalcon\Logger\Item $item + */ + abstract public function process(\Phalcon\Logger\Item $item); + + /** + * Rollbacks the internal transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function rollback(): AdapterInterface {} + + /** + * Sets the message formatter + * + * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface {} + +} diff --git a/src/Phalcon/logger/adapter/Abstractadapter.php b/src/Phalcon/logger/adapter/Abstractadapter.php deleted file mode 100644 index 6abb00ee..00000000 --- a/src/Phalcon/logger/adapter/Abstractadapter.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ - protected $formatter; - - /** - * Tells if there is an active transaction or not - * - * @var bool - */ - protected $inTransaction = false; - - /** - * Array with messages queued in the transaction - * - * @var array - */ - protected $queue = []; - - /** - * Destructor cleanup - */ - public function __destruct() - { - } - - /** - * Adds a message to the queue - */ - public function add(Item $item) : void - { - } - - /** - * Starts a transaction - */ - public function begin() : AdapterInterface - { - } - - /** - * Commits the internal transaction - */ - public function commit() : AdapterInterface - { - } - - public function getFormatter() : FormatterInterface - { - } - - /** - * Returns the whether the logger is currently in an active transaction or not - */ - public function inTransaction() : bool - { - } - - /** - * Processes the message in the adapter - */ - public function process(Item $item) : void - { - } - - /** - * Rollbacks the internal transaction - */ - public function rollback() : AdapterInterface - { - } - - /** - * Sets the message formatter - */ - public function setFormatter(FormatterInterface $formatter) : AdapterInterface - { - } -} diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php new file mode 100644 index 00000000..b9317e56 --- /dev/null +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -0,0 +1,70 @@ + - * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); - * - * $logger->log("This is a message"); - * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - * $logger->close(); - * - */ -class File extends \Phalcon\Logger\Adapter -{ - /** - * File handler resource - * - * @var resource - */ - protected $_fileHandler; - - /** - * File Path - */ - protected $_path; - - /** - * Path options - */ - protected $_options; - - - /** - * File Path - */ - public function getPath() {} - - /** - * Phalcon\Logger\Adapter\File constructor - * - * @param string $name - * @param array $options - */ - public function __construct($name, $options = null) {} - - /** - * Returns the internal formatter - * - * @return \Phalcon\Logger\FormatterInterface - */ - public function getFormatter() {} - - /** - * Writes the log to the file itself - * - * @param string $message - * @param int $type - * @param int $time - * @param array $context - */ - public function logInternal($message, $type, $time, array $context) {} - - /** - * Closes the logger - * - * @return bool - */ - public function close() {} - - /** - * Opens the internal file handler after unserialization - */ - public function __wakeup() {} - -} diff --git a/src/Phalcon/logger/adapter/Firephp.php b/src/Phalcon/logger/adapter/Firephp.php deleted file mode 100644 index c509e369..00000000 --- a/src/Phalcon/logger/adapter/Firephp.php +++ /dev/null @@ -1,55 +0,0 @@ - - * use Phalcon\Logger\Adapter\Firephp; - * use Phalcon\Logger; - * - * $logger = new Firephp(); - * - * $logger->log(Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - * - * @deprecated Will be removed in 4.0.0 - */ -class Firephp extends \Phalcon\Logger\Adapter -{ - - private $_initialized = false; - - - private $_index = 1; - - - /** - * Returns the internal formatter - * - * @return \Phalcon\Logger\FormatterInterface - */ - public function getFormatter() {} - - /** - * Writes the log to the stream itself - * - * @param string $message - * @param int $type - * @param int $time - * @param array $context - */ - public function logInternal($message, $type, $time, array $context) {} - - /** - * Closes the logger - * - * @return bool - */ - public function close() {} - -} diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 76f9e1a9..9f2e6578 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -2,35 +2,35 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Noop * * Adapter to store logs in plain text files * - * + * ```php * $logger = new \Phalcon\Logger\Adapter\Noop(); * * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); * * $logger->close(); - * + * ``` */ -class Noop extends AbstractAdapter +class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter { - /** - * Closes the stream - */ - public function close() : bool - { - } - /** - * Processes the message i.e. writes it to the file - */ - public function process(Item $item) : void - { - } + /** + * Closes the stream + * + * @return bool + */ + public function close(): bool {} + + /** + * Processes the message i.e. writes it to the file + * + * @param \Phalcon\Logger\Item $item + */ + public function process(\Phalcon\Logger\Item $item) {} + } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 33279124..94b479a3 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -5,59 +5,76 @@ /** * Phalcon\Logger\Adapter\Stream * - * Sends logs to a valid PHP stream + * Adapter to store logs in plain text files * - * - * use Phalcon\Logger; - * use Phalcon\Logger\Adapter\Stream; - * - * $logger = new Stream("php://stderr"); + * ```php + * $logger = new \Phalcon\Logger\Adapter\Stream("app/logs/test.log"); * * $logger->log("This is a message"); - * $logger->log(Logger::ERROR, "This is an error"); + * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * + * + * $logger->close(); + * ``` */ -class Stream extends \Phalcon\Logger\Adapter +class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter { /** - * File handler resource + * Stream handler resource * - * @var resource + * @var resource|null */ - protected $_stream; + protected $handler = null; + /** + * The file open mode. Defaults to "ab" + * + * @var string + */ + protected $mode = 'ab'; /** - * Phalcon\Logger\Adapter\Stream constructor + * Stream name * - * @param string $name - * @param array $options + * @var string + */ + protected $name; + + /** + * Path options + * + * @var array */ - public function __construct($name, $options = null) {} + protected $options; + /** - * Returns the internal formatter + * Stream name * - * @return \Phalcon\Logger\FormatterInterface + * @return string */ - public function getFormatter() {} + public function getName(): string {} /** - * Writes the log to the stream itself + * Constructor. Accepts the name and some options * - * @param string $message - * @param int $type - * @param int $time - * @param array $context + * @param string $name + * @param array $options */ - public function logInternal($message, $type, $time, array $context) {} + public function __construct(string $name, array $options = array()) {} /** - * Closes the logger + * Closes the stream * * @return bool */ - public function close() {} + public function close(): bool {} + + /** + * Processes the message i.e. writes it to the file + * + * @param \Phalcon\Logger\Item $item + */ + public function process(\Phalcon\Logger\Item $item) {} } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index bf684c7c..14c95796 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -7,7 +7,7 @@ * * Sends logs to the system logger * - * + * ```php * use Phalcon\Logger; * use Phalcon\Logger\Adapter\Syslog; * @@ -23,12 +23,36 @@ * $logger->log("This is a message"); * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * + * ``` */ -class Syslog extends \Phalcon\Logger\Adapter +class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter { + /** + * Name of the default formatter class + * + * @var string + */ + protected $defaultFormatter = 'Syslog'; + + /** + * @var int + */ + protected $facility = 0; + + /** + * @var string + */ + protected $name = ''; - protected $_opened = false; + /** + * @var bool + */ + protected $opened = false; + + /** + * @var int + */ + protected $option = 0; /** @@ -37,30 +61,28 @@ class Syslog extends \Phalcon\Logger\Adapter * @param string $name * @param array $options */ - public function __construct($name, $options = null) {} + public function __construct(string $name, array $options = array()) {} /** - * Returns the internal formatter + * Closes the logger * - * @return \Phalcon\Logger\FormatterInterface + * @return bool */ - public function getFormatter() {} + public function close(): bool {} /** - * Writes the log to the stream itself + * Processes the message i.e. writes it to the syslog * - * @param string $message - * @param int $type - * @param int $time - * @param array $context + * @param \Phalcon\Logger\Item $item */ - public function logInternal($message, $type, $time, array $context) {} + public function process(\Phalcon\Logger\Item $item) {} /** - * Closes the logger + * Translates a Logger level to a Syslog level * - * @return bool + * @param string $level + * @return int */ - public function close() {} + private function logLevelToSyslog(string $level): int {} } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php new file mode 100644 index 00000000..9049eb11 --- /dev/null +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface +{ + + /** + * Interpolates context values into the message placeholders + * + * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message + * @param string $message + * @param array $context + */ + public function interpolate(string $message, $context = null) {} + +} diff --git a/src/Phalcon/logger/formatter/Abstractformatter.php b/src/Phalcon/logger/formatter/Abstractformatter.php deleted file mode 100644 index 1079548e..00000000 --- a/src/Phalcon/logger/formatter/Abstractformatter.php +++ /dev/null @@ -1,19 +0,0 @@ - item - * - * @return string|array - */ - public function format(Item $item); -} + /** + * Applies a format to an item + * + * @param \Phalcon\Logger\Item $item + * @return string|array + */ + public function format(\Phalcon\Logger\Item $item); + +} diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index 127cb1bd..a1552d6a 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -7,18 +7,43 @@ * * Formats messages using JSON encoding */ -class Json extends \Phalcon\Logger\Formatter +class Json extends \Phalcon\Logger\Formatter\AbstractFormatter { + /** + * Default date format + * + * @var string + */ + protected $dateFormat; + + + /** + * Default date format + * + * @return string + */ + public function getDateFormat(): string {} + + /** + * Default date format + * + * @param string $dateFormat + */ + public function setDateFormat(string $dateFormat) {} + + /** + * Phalcon\Logger\Formatter\Json construct + * + * @param string $dateFormat + */ + public function __construct(string $dateFormat = 'D, d M y H:i:s O') {} /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return string */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): string {} } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index 0387d9ed..b575d37d 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -7,21 +7,21 @@ * * Formats messages using an one-line string */ -class Line extends \Phalcon\Logger\Formatter +class Line extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Default date format * * @var string */ - protected $_dateFormat = 'D, d M y H:i:s O'; + protected $dateFormat; /** * Format applied to each message * * @var string */ - protected $_format = '[%date%][%type%] %message%'; + protected $format; /** @@ -29,28 +29,28 @@ class Line extends \Phalcon\Logger\Formatter * * @return string */ - public function getDateFormat() {} + public function getDateFormat(): string {} /** * Default date format * * @param string $dateFormat */ - public function setDateFormat($dateFormat) {} + public function setDateFormat(string $dateFormat) {} /** * Format applied to each message * * @return string */ - public function getFormat() {} + public function getFormat(): string {} /** * Format applied to each message * * @param string $format */ - public function setFormat($format) {} + public function setFormat(string $format) {} /** * Phalcon\Logger\Formatter\Line construct @@ -58,17 +58,14 @@ public function setFormat($format) {} * @param string $format * @param string $dateFormat */ - public function __construct($format = null, $dateFormat = null) {} + public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') {} /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return string */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): string {} } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index c37da150..6f886239 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -7,18 +7,15 @@ * * Prepares a message to be used in a Syslog backend */ -class Syslog extends \Phalcon\Logger\Formatter +class Syslog extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return array */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): array {} } diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php index b1978f3b..bca86886 100644 --- a/src/Phalcon/messages/Exception.php +++ b/src/Phalcon/messages/Exception.php @@ -5,8 +5,7 @@ /** * Phalcon\Validation\Exception * - * Exceptions thrown in Phalcon\Messages\* classes will use this class - * + * Exceptions thrown in Phalcon\Messages\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index 3cfe5cfe..e1d94052 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -2,137 +2,127 @@ namespace Phalcon\Messages; -use Phalcon\Messages\MessageInterface; - /** * Phalcon\Messages\Message * * Stores a message from various components */ -class Message implements MessageInterface, \JsonSerializable +class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable { - /** - * @var int - */ - protected $code; - - /** - * @var string - */ - protected $field; - - /** - * @var string - */ - protected $message; - - /** - * @var string - */ - protected $type; - - /** - * @var array - */ - protected $metaData = []; - - /** - * Phalcon\Messages\Message constructor - */ - public function __construct(string $message, $field = "", string $type = "", int $code = 0, array $metaData = []) - { - } - - /** - * Returns the message code - */ - public function getCode() : int - { - } - - /** - * Returns field name related to message - * - * @return mixed - */ - public function getField() - { - } - - /** - * Returns verbose message - */ - public function getMessage() : string - { - } - - /** - * Returns message type - */ - public function getType() : string - { - } - - /** - * Returns message metadata - */ - public function getMetaData() : array - { - } - - /** - * Serializes the object for json_encode - */ - public function jsonSerialize() : array - { - } - - /** - * Sets code for the message - */ - public function setCode(int $code) : MessageInterface - { - } - - /** - * Sets field name related to message - */ - public function setField($field) : MessageInterface - { - } - - /** - * Sets verbose message - */ - public function setMessage(string $message) : MessageInterface - { - } - - /** - * Sets message type - */ - public function setType(string $type) : MessageInterface - { - } - - /** - * Sets message metadata - */ - public function setMetaData(array $metaData) : MessageInterface - { - } - - /** - * Magic __toString method returns verbose message - */ - public function __toString() : string - { - } - - /** - * Magic __set_state helps to re-build messages variable exporting - */ - public static function __set_state(array $message) : MessageInterface - { - } + /** + * @var int + */ + protected $code; + + /** + * @var string + */ + protected $field; + + /** + * @var string + */ + protected $message; + + /** + * @var string + */ + protected $type; + + /** + * @var array + */ + protected $metaData = array(); + + + /** + * @return int + */ + public function getCode(): int {} + + /** + * @return string + */ + public function getField(): string {} + + /** + * @return string + */ + public function getMessage(): string {} + + /** + * @return string + */ + public function getType(): string {} + + /** + * @return array + */ + public function getMetaData(): array {} + + /** + * Phalcon\Messages\Message constructor + * + * @param string $message + * @param mixed $field + * @param string $type + * @param int $code + * @param array $metaData + */ + public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) {} + + /** + * Magic __toString method returns verbose message + * + * @return string + */ + public function __toString(): string {} + + /** + * Serializes the object for json_encode + * + * @return array + */ + public function jsonSerialize(): array {} + + /** + * Sets code for the message + * + * @param int $code + * @return \Phalcon\Messages\MessageInterface + */ + public function setCode(int $code): MessageInterface {} + + /** + * Sets field name related to message + * + * @param mixed $field + * @return \Phalcon\Messages\MessageInterface + */ + public function setField($field): MessageInterface {} + + /** + * Sets verbose message + * + * @param string $message + * @return \Phalcon\Messages\MessageInterface + */ + public function setMessage(string $message): MessageInterface {} + + /** + * Sets message metadata + * + * @param array $metaData + * @return \Phalcon\Messages\MessageInterface + */ + public function setMetaData(array $metaData): MessageInterface {} + + /** + * Sets message type + * + * @param string $type + * @return \Phalcon\Messages\MessageInterface + */ + public function setType(string $type): MessageInterface {} + } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php new file mode 100644 index 00000000..550abcfa --- /dev/null +++ b/src/Phalcon/messages/MessageInterface.php @@ -0,0 +1,95 @@ + - * $messages->appendMessage( - * new \Phalcon\Messages\Message("This is a message") - * ); - * - */ - public function appendMessage(MessageInterface $message) - { - } - - /** - * Appends an array of messages to the collection - * - * - * $messages->appendMessages($messagesArray); - * - * - * @param \Phalcon\Messages\MessageInterface[] messages - */ - public function appendMessages($messages) - { - } - - /** - * Returns the number of messages in the list - */ - public function count() : int - { - } - - /** - * Returns the current message in the iterator - */ - public function current() : MessageInterface - { - } - - /** - * Filters the message collection by field name - */ - public function filter(string $fieldName) : array - { - } + /** + * @var int + */ + protected $position = 0; + + /** + * @var array + */ + protected $messages; + + + /** + * Phalcon\Messages\Messages constructor + * + * @param array $messages + */ + public function __construct(array $messages = array()) {} + + /** + * Appends a message to the collection + * + * ```php + * $messages->appendMessage( + * new \Phalcon\Messages\Message("This is a message") + * ); + * ``` + * + * @param \Phalcon\Messages\MessageInterface $message + */ + public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} + + /** + * Appends an array of messages to the collection + * + * ```php + * $messages->appendMessages($messagesArray); + * ``` + * + * @param \Phalcon\Messages\MessageInterface[] $messages + */ + public function appendMessages($messages) {} + + /** + * Returns the number of messages in the list + * + * @return int + */ + public function count(): int {} + + /** + * Returns the current message in the iterator + * + * @return \Phalcon\Messages\MessageInterface + */ + public function current(): MessageInterface {} + + /** + * Filters the message collection by field name + * + * @param string $fieldName + * @return array + */ + public function filter(string $fieldName): array {} /** * Returns serialised message objects as array for json_encode. Calls * jsonSerialize on each object if present * - * + * ```php * $data = $messages->jsonSerialize(); * echo json_encode($data); - * - */ - public function jsonSerialize() : array - { - } - - /** - * Returns the current position/key in the iterator - */ - public function key() : int - { - } - - /** - * Moves the internal iteration pointer to the next position - */ - public function next() : void - { - } - - /** - * Checks if an index exists - * - * - * var_dump( - * isset($message["database"]) - * ); - * - * - * @param int index - */ - public function offsetExists($index) : boolean - { - } - - /** - * Gets an attribute a message using the array syntax - * - * - * print_r( - * $messages[0] - * ); - * - */ - public function offsetGet($index) { - } - - /** - * Sets an attribute using the array-syntax - * - * - * $messages[0] = new \Phalcon\Messages\Message("This is a message"); - * - * - * @param \Phalcon\Messages\Message message - */ - public function offsetSet($index, $message) : void - { - } - - /** - * Removes a message from the list - * - * - * unset($message["database"]); - * - */ - public function offsetUnset($index) : void - { - } - - /** - * Rewinds the internal iterator - */ - public function rewind() : void - { - } - - /** - * Check if the current message in the iterator is valid - */ - public function valid() : boolean - { - } + * ``` + * + * @return array + */ + public function jsonSerialize(): array {} + + /** + * Returns the current position/key in the iterator + * + * @return int + */ + public function key(): int {} + + /** + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Checks if an index exists + * + * ```php + * var_dump( + * isset($message["database"]) + * ); + * ``` + * + * @param int $index + * @return bool + */ + public function offsetExists($index): bool {} + + /** + * Gets an attribute a message using the array syntax + * + * ```php + * print_r( + * $messages[0] + * ); + * ``` + * + * @param mixed $index + * @return mixed + */ + public function offsetGet($index) {} + + /** + * Sets an attribute using the array-syntax + * + * ```php + * $messages[0] = new \Phalcon\Messages\Message("This is a message"); + * ``` + * + * @param mixed $index + * @param \Phalcon\Messages\Message $message + */ + public function offsetSet($index, $message) {} + + /** + * Removes a message from the list + * + * ```php + * unset($message["database"]); + * ``` + * + * @param mixed $index + */ + public function offsetUnset($index) {} + + /** + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Check if the current message in the iterator is valid + * + * @return bool + */ + public function valid(): bool {} + } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 293a9d9d..9faf4966 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -5,10 +5,11 @@ /** * Phalcon\Mvc\Application * - * This component encapsulates all the complex operations behind instantiating every component - * needed and integrating it with the rest to allow the MVC pattern to operate as desired. + * This component encapsulates all the complex operations behind instantiating + * every component needed and integrating it with the rest to allow the MVC + * pattern to operate as desired. * - * + * ```php * use Phalcon\Mvc\Application; * * class MyApp extends Application @@ -45,27 +46,27 @@ * $application = new MyApp(); * * $application->main(); - * + * ``` */ -class Application extends \Phalcon\Application +class Application extends \Phalcon\Application\AbstractApplication { - protected $_implicitView = true; + protected $implicitView = true; - protected $_sendHeaders = true; + protected $sendCookies = true; - protected $_sendCookies = true; + protected $sendHeaders = true; /** - * Enables or disables sending headers by each request handling + * Handles a MVC request * - * @param bool $sendHeaders - * @return Application + * @param string $uri + * @return bool|\Phalcon\Http\ResponseInterface */ - public function sendHeadersOnHandleRequest($sendHeaders) {} + public function handle(string $uri) {} /** * Enables or disables sending cookies by each request handling @@ -73,23 +74,23 @@ public function sendHeadersOnHandleRequest($sendHeaders) {} * @param bool $sendCookies * @return Application */ - public function sendCookiesOnHandleRequest($sendCookies) {} + public function sendCookiesOnHandleRequest(bool $sendCookies): Application {} /** - * By default. The view is implicitly buffering all the output - * You can full disable the view component using this method + * Enables or disables sending headers by each request handling * - * @param bool $implicitView + * @param bool $sendHeaders * @return Application */ - public function useImplicitView($implicitView) {} + public function sendHeadersOnHandleRequest(bool $sendHeaders): Application {} /** - * Handles a MVC request + * By default. The view is implicitly buffering all the output + * You can full disable the view component using this method * - * @param string $uri - * @return bool|\Phalcon\Http\ResponseInterface + * @param bool $implicitView + * @return Application */ - public function handle($uri = null) {} + public function useImplicitView(bool $implicitView): Application {} } diff --git a/src/Phalcon/mvc/Collection.php b/src/Phalcon/mvc/Collection.php index 14296c3d..a5dbf4ae 100644 --- a/src/Phalcon/mvc/Collection.php +++ b/src/Phalcon/mvc/Collection.php @@ -11,160 +11,336 @@ abstract class Collection implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\CollectionInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable { - const OP_NONE = 0; + const DIRTY_STATE_DETACHED = 2; - const OP_CREATE = 1; + const DIRTY_STATE_PERSISTENT = 0; - const OP_UPDATE = 2; + const DIRTY_STATE_TRANSIENT = 1; - const OP_DELETE = 3; + const OP_CREATE = 1; - const DIRTY_STATE_PERSISTENT = 0; + const OP_DELETE = 3; - const DIRTY_STATE_TRANSIENT = 1; + const OP_NONE = 0; - const DIRTY_STATE_DETACHED = 2; + const OP_UPDATE = 2; public $_id; - protected $_dependencyInjector; + protected $connection; - protected $_modelsManager; + protected $container; - protected $_source; + protected $dirtyState = 1; - protected $_operationMade = 0; + static protected $disableEvents; - protected $_dirtyState = 1; + protected $errorMessages = array(); - protected $_connection; + protected $modelsManager; - protected $_errorMessages = array(); + protected $operationMade = 0; - static protected $_reserved; + static protected $reserved; - static protected $_disableEvents; + protected $skipped = false; - protected $_skipped = false; + protected $source; /** * Phalcon\Mvc\Collection constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param \Phalcon\Mvc\Collection\ManagerInterface $modelsManager */ - public final function __construct(\Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} + final public function __construct(\Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} /** - * Sets a value for the _id property, creates a MongoId object if needed + * Sets up a behavior in a collection * - * @param mixed $id + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setId($id) {} + protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} /** - * Returns the value of the _id property + * Perform an aggregation using the Mongo aggregation framework * - * @return \MongoId + * @param array $parameters + * @param array $options + * @return array */ - public function getId() {} + public static function aggregate(array $parameters = null, array $options = null): array {} /** - * Sets the dependency injection container + * Appends a customized message on the validation process + * + * ```php + * use \Phalcon\Messages\Message as Message; + * + * class Robots extends \Phalcon\Mvc\Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); + * + * $this->appendMessage(message); + * } + * } + * } + * ``` * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Messages\MessageInterface $message */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} /** - * Returns the dependency injection container + * Returns a cloned collection * - * @return \Phalcon\DiInterface + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function getDI() {} + public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface {} /** - * Sets a custom events manager + * Creates a collection based on the values in the attributes * - * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager + * @return bool */ - protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} + public function create(): bool {} /** - * Returns the custom events manager + * Creates a document based on the values in the attributes, if not found by + * criteria. Preferred way to avoid duplication is to create index o + * attribute * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * ```php + * $robot = new Robot(); + * + * $robot->name = "MyRobot"; + * $robot->type = "Droid"; + * + * // Create only if robot with same name and type does not exist + * $robot->createIfNotExist( + * [ + * "name", + * "type", + * ] + * ); + * ``` + * + * @param array $criteria + * @return bool */ - protected function getEventsManager() {} + public function createIfNotExist(array $criteria): bool {} /** - * Returns the models manager related to the entity instance + * Perform a count over a collection * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * ```php + * echo "There are ", Robots::count(), " robots"; + * ``` + * + * @param array $parameters + * @return int + */ + public static function count(array $parameters = null): int {} + + /** + * Deletes a model instance. Returning true on success or false otherwise. + * + * ```php + * $robot = Robots::findFirst(); + * + * $robot->delete(); + * + * $robots = Robots::find(); + * + * foreach ($robots as $robot) { + * $robot->delete(); + * } + * ``` + * + * @return bool */ - public function getCollectionManager() {} + public function delete(): bool {} /** - * Returns an array with reserved properties that cannot be part of the insert/update + * Allows to query a set of records that match the specified conditions + * + * ```php + * // How many robots are there? + * $robots = Robots::find(); + * + * echo "There are ", count($robots), "\n"; + * + * // How many mechanical robots are there? + * $robots = Robots::find( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "There are ", count(robots), "\n"; + * + * // Get and print virtual robots ordered by name + * $robots = Robots::findFirst( + * [ + * [ + * "type" => "virtual" + * ], + * "order" => [ + * "name" => 1, + * ] + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + * // Get first 100 virtual robots ordered by name + * $robots = Robots::find( + * [ + * [ + * "type" => "virtual", + * ], + * "order" => [ + * "name" => 1, + * ], + * "limit" => 100, + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * ``` * + * @param array $parameters * @return array */ - public function getReservedAttributes() {} + public static function find(array $parameters = null): array {} /** - * Sets if a model must use implicit objects ids + * Find a document by its id (_id) * - * @param bool $useImplicitObjectIds + * ```php + * // Find user by using \MongoId object + * $user = Users::findById( + * new \MongoId("545eb081631d16153a293a66") + * ); + * + * // Find user by using id as sting + * $user = Users::findById("45cbc4a0e4123f6920000002"); + * + * // Validate input + * if ($user = Users::findById($_POST["id"])) { + * // ... + * } + * ``` + * + * @param mixed $id + * @return null|CollectionInterface */ - protected function useImplicitObjectIds($useImplicitObjectIds) {} + public static function findById($id): ?CollectionInterface {} /** - * Sets collection name which model should be mapped + * Allows to query the first record that match the specified conditions * - * @param string $source - * @return Collection + * ```php + * // What's the first robot in the robots table? + * $robot = Robots::findFirst(); + * + * echo "The robot name is ", $robot->name, "\n"; + * + * // What's the first mechanical robot in robots table? + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "The first mechanical robot name is ", $robot->name, "\n"; + * + * // Get first virtual robot ordered by name + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ], + * "order" => [ + * "name" => 1, + * ], + * ] + * ); + * + * echo "The first virtual robot name is ", $robot->name, "\n"; + * + * // Get first robot by id (_id) + * $robot = Robots::findFirst( + * [ + * [ + * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), + * ] + * ] + * ); + * + * echo "The robot id is ", $robot->_id, "\n"; + * ``` + * + * @param array $parameters + * @return array */ - protected function setSource($source) {} + public static function findFirst(array $parameters = null): array {} /** - * Returns collection name mapped in the model + * Fires an internal event * - * @return string + * @param string $eventName + * @return bool */ - public function getSource() {} + public function fireEvent(string $eventName): bool {} /** - * Sets the DependencyInjection connection service name + * Fires an internal event that cancels the operation * - * @param string $connectionService - * @return Collection + * @param string $eventName + * @return bool */ - public function setConnectionService($connectionService) {} + public function fireEventCancel(string $eventName): bool {} /** - * Returns DependencyInjection connection service + * Returns the models manager related to the entity instance * - * @return string + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - public function getConnectionService() {} + public function getCollectionManager(): ManagerInterface {} /** * Retrieves a database connection @@ -174,534 +350,315 @@ public function getConnectionService() {} public function getConnection() {} /** - * Reads an attribute value by its name - * - * - * echo $robot->readAttribute("name"); - * + * Returns DependencyInjection connection service * - * @param string $attribute - * @return mixed + * @return string */ - public function readAttribute($attribute) {} + public function getConnectionService(): string {} /** - * Writes an attribute value by its name - * - * - * $robot->writeAttribute("name", "Rosey"); - * + * Returns the dependency injection container * - * @param string $attribute - * @param mixed $value + * @return \Phalcon\Di\DiInterface */ - public function writeAttribute($attribute, $value) {} + public function getDI(): DiInterface {} /** - * Returns a cloned collection + * Returns one of the DIRTY_STATE_ constants telling if the document exists + * in the collection or not * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @return int */ - public static function cloneResult(CollectionInterface $collection, array $document) {} + public function getDirtyState(): int {} /** - * Returns a collection resultset + * Returns the custom events manager * - * @param array $params - * @param \Phalcon\Mvc\Collection $collection - * @param \MongoDb $connection - * @param boolean $unique - * @return array + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - protected static function _getResultset($params, CollectionInterface $collection, $connection, $unique) {} + protected function getEventsManager(): ManagerInterface {} /** - * Perform a count over a resultset + * Returns the value of the _id property * - * @param array $params - * @param \Phalcon\Mvc\Collection $collection - * @param \MongoDb $connection - * @return int + * @return \MongoId */ - protected static function _getGroupResultset($params, Collection $collection, $connection) {} + public function getId() {} /** - * Executes internal hooks before save a document + * Returns all the validation messages * - * @param \Phalcon\DiInterface $dependencyInjector - * @param boolean $disableEvents - * @param boolean $exists - * @return bool - */ - protected final function _preSave($dependencyInjector, $disableEvents, $exists) {} - - /** - * Executes internal events after save a document - * - * @param bool $disableEvents - * @param bool $success - * @param bool $exists - * @return bool - */ - protected final function _postSave($disableEvents, $success, $exists) {} - - /** - * Executes validators on every validation call - * - * - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * // Old, deprecated syntax, use new one below - * $this->validate( - * new ExclusionIn( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); + * ```php + * $robot = new Robots(); * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; * - * - * use Phalcon\Validation\Validator\ExclusionIn as ExclusionIn; - * use Phalcon\Validation; + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $validator = new Validation(); - * $validator->add("status", - * new ExclusionIn( - * [ - * "domain" => ["A", "I"] - * ] - * ) - * ); + * $messages = $robot->getMessages(); * - * return $this->validate($validator); + * foreach ($messages as $message) { + * echo $message; * } + * } else { + * echo "Great, a new robot was saved successfully!"; * } - * + * ``` * - * @param mixed $validator + * @return array|\Phalcon\Messages\MessageInterface[] */ - protected function validate($validator) {} + public function getMessages(): array {} /** - * Check whether validation process has generated any messages + * Returns an array with reserved properties that cannot be part of the + * insert/update * - * - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new ExclusionIn( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * - * - * @return bool + * @return array */ - public function validationHasFailed() {} + public function getReservedAttributes(): array {} /** - * Fires an internal event + * Returns collection name mapped in the model * - * @param string $eventName - * @return bool + * @return string */ - public function fireEvent($eventName) {} + public function getSource(): string {} /** - * Fires an internal event that cancels the operation + * Reads an attribute value by its name * - * @param string $eventName - * @return bool - */ - public function fireEventCancel($eventName) {} - - /** - * Cancel the current operation + * ```php + * echo $robot->readAttribute("name"); + * ``` * - * @param bool $disableEvents - * @return bool + * @param string $attribute + * @return mixed|null */ - protected function _cancelOperation($disableEvents) {} + public function readAttribute(string $attribute): ? {} /** - * Checks if the document exists in the collection + * Creates/Updates a collection based on the values in the attributes * - * @param \MongoCollection $collection * @return bool */ - protected function _exists($collection) {} + public function save(): bool {} /** - * Returns all the validation messages - * - * - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); - * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * + * Serializes the object ignoring connections or protected properties * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return string */ - public function getMessages() {} + public function serialize(): string {} /** - * Appends a customized message on the validation process - * - * - * use \Phalcon\Mvc\Model\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - * + * Sets the DependencyInjection connection service name * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @param string $connectionService + * @return Collection */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} + public function setConnectionService(string $connectionService): Collection {} /** - * Shared Code for CU Operations - * Prepares Collection + * Sets the dependency injection container + * + * @param \Phalcon\Di\DiInterface $container */ - protected function prepareCU() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Creates/Updates a collection based on the values in the attributes + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @return bool + * @param int $dirtyState + * @return CollectionInterface */ - public function save() {} + public function setDirtyState(int $dirtyState): CollectionInterface {} /** - * Creates a collection based on the values in the attributes + * Sets a custom events manager * - * @return bool + * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager */ - public function create() {} + protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} /** - * Creates a document based on the values in the attributes, if not found by criteria - * Preferred way to avoid duplication is to create index on attribute - * - * - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * + * Sets a value for the _id property, creates a MongoId object if needed * - * @param array $criteria - * @return bool + * @param mixed $id */ - public function createIfNotExist(array $criteria) {} + public function setId($id) {} /** - * Creates/Updates a collection based on the values in the attributes + * Sets collection name which model should be mapped * - * @return bool + * @param string $source + * @return Collection */ - public function update() {} + protected function setSource(string $source): Collection {} /** - * Find a document by its id (_id) - * - * - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * + * Skips the current operation forcing a success state * - * @param mixed $id - * @return null|CollectionInterface + * @param bool $skip */ - public static function findById($id) {} + public function skipOperation(bool $skip) {} /** - * Allows to query the first record that match the specified conditions - * - * - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * + * Allows to perform a summatory group for a column in the collection * - * @param array $parameters + * @param string $field + * @param mixed $conditions + * @param mixed $finalize * @return array */ - public static function findFirst(array $parameters = null) {} + public static function summatory(string $field, $conditions = null, $finalize = null): array {} /** - * Allows to query a set of records that match the specified conditions - * - * - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } + * Returns the instance as an array representation * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] + * ```php + * print_r( + * $robot->toArray() * ); + * ``` * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * - * @param array $parameters * @return array */ - public static function find(array $parameters = null) {} - - /** - * Perform a count over a collection - * - * - * echo "There are ", Robots::count(), " robots"; - * - * - * @param array $parameters - * @return int - */ - public static function count(array $parameters = null) {} + public function toArray(): array {} /** - * Perform an aggregation using the Mongo aggregation framework + * Unserializes the object from a serialized string * - * @param array $parameters - * @param array $options - * @return array + * @param mixed $data */ - public static function aggregate(array $parameters = null, array $options = null) {} + public function unserialize($data) {} /** - * Allows to perform a summatory group for a column in the collection + * Creates/Updates a collection based on the values in the attributes * - * @param string $field - * @param mixed $conditions - * @param mixed $finalize - * @return array + * @return bool */ - public static function summatory($field, $conditions = null, $finalize = null) {} + public function update(): bool {} /** - * Deletes a model instance. Returning true on success or false otherwise. + * Executes validators on every validation call * - * - * $robot = Robots::findFirst(); + * ```php + * use Phalcon\Mvc\Collection; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; * - * $robot->delete(); + * class Subscriptors extends Collection + * { + * public function validation() + * { + * $validator = new Validation(); * - * $robots = Robots::find(); + * $validator->add( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); * - * foreach ($robots as $robot) { - * $robot->delete(); + * return $this->validate($validator); + * } * } - * + * ``` * + * @param \Phalcon\Validation\ValidationInterface $validator * @return bool */ - public function delete() {} + protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Sets if a model must use implicit objects ids * - * @param int $dirtyState - * @return CollectionInterface + * @param bool $useImplicitObjectIds */ - public function setDirtyState($dirtyState) {} + protected function useImplicitObjectIds(bool $useImplicitObjectIds) {} /** - * Returns one of the DIRTY_STATE_ constants telling if the document exists in the collection or not + * Writes an attribute value by its name * - * @return int + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` + * + * @param string $attribute + * @param mixed $value */ - public function getDirtyState() {} + public function writeAttribute(string $attribute, $value) {} /** - * Sets up a behavior in a collection + * Cancel the current operation * - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param bool $disableEvents + * @return bool */ - protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + protected function cancelOperation(bool $disableEvents): bool {} /** - * Skips the current operation forcing a success state + * Checks if the document exists in the collection * - * @param bool $skip + * @param MongoCollection $collection + * @return bool */ - public function skipOperation($skip) {} + protected function exists($collection): bool {} /** - * Returns the instance as an array representation + * Perform a count over a resultset * - * - * print_r( - * $robot->toArray() - * ); - * + * @param array $params + * @param Collection $collection + * @param \MongoDb $connection + * @return int + */ + protected static function getGroupResultset($params, Collection $collection, $connection): int {} + + /** + * Returns a collection resultset * + * @param array $params + * @param CollectionInterface $collection + * @param \MongoDb $connection + * @param bool $unique * @return array */ - public function toArray() {} + protected static function getResultset($params, CollectionInterface $collection, $connection, bool $unique) {} /** - * Serializes the object ignoring connections or protected properties + * Executes internal hooks before save a document * - * @return string + * @param \Phalcon\Di\DiInterface $container + * @param bool $disableEvents + * @param bool $exists + * @return bool */ - public function serialize() {} + final protected function preSave(\Phalcon\Di\DiInterface $container, bool $disableEvents, bool $exists): bool {} /** - * Unserializes the object from a serialized string + * Executes internal events after save a document * - * @param mixed $data + * @param bool $disableEvents + * @param bool $success + * @param bool $exists + * @return bool */ - public function unserialize($data) {} + final protected function postSave(bool $disableEvents, bool $success, bool $exists): bool {} + + /** + * Shared Code for CU Operations + * Prepares Collection + */ + protected function prepareCU() {} } diff --git a/src/Phalcon/mvc/CollectionInterface.php b/src/Phalcon/mvc/CollectionInterface.php index ab22a531..ead5cdd5 100644 --- a/src/Phalcon/mvc/CollectionInterface.php +++ b/src/Phalcon/mvc/CollectionInterface.php @@ -3,162 +3,163 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\CollectionInterface - * * Interface for Phalcon\Mvc\Collection */ interface CollectionInterface { /** - * Sets a value for the _id property, creates a MongoId object if needed + * Appends a customized message on the validation process * - * @param mixed $id + * @param \Phalcon\Messages\MessageInterface $message */ - public function setId($id); + public function appendMessage(\Phalcon\Messages\MessageInterface $message); /** - * Returns the value of the _id property + * Returns a cloned collection * - * @return MongoId + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function getId(); + public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface; /** - * Returns an array with reserved properties that cannot be part of the insert/update + * Perform a count over a collection * - * @return array + * @param array $parameters + * @return int */ - public function getReservedAttributes(); + public static function count(array $parameters = null): int; /** - * Returns collection name mapped in the model + * Deletes a model instance. Returning true on success or false otherwise * - * @return string + * @return bool */ - public function getSource(); + public function delete(): bool; /** - * Sets a service in the services container that returns the Mongo database + * Allows to query a set of records that match the specified conditions * - * @param string $connectionService + * @param array $parameters + * @return array */ - public function setConnectionService($connectionService); + public static function find(array $parameters = null): array; /** - * Retrieves a database connection + * Find a document by its id * - * @return MongoDb + * @param string $id + * @return null|CollectionInterface */ - public function getConnection(); + public static function findById($id): ?CollectionInterface; /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Allows to query the first record that match the specified conditions * - * @param int $dirtyState - * @return \Phalcon\Mvc\CollectionInterface + * @param array $parameters + * @return array */ - public function setDirtyState($dirtyState); + public static function findFirst(array $parameters = null): array; /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @return int + * @param string $eventName + * @return bool */ - public function getDirtyState(); + public function fireEvent(string $eventName): bool; /** - * Returns a cloned collection + * Fires an event, implicitly listeners in the events manager are notified + * This method stops if one of the callbacks/listeners returns bool false * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @param string $eventName + * @return bool */ - public static function cloneResult(CollectionInterface $collection, array $document); + public function fireEventCancel(string $eventName): bool; /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Retrieves a database connection * - * @param string $eventName - * @return bool + * @return MongoDb */ - public function fireEvent($eventName); + public function getConnection(); /** - * Fires an event, implicitly listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param string $eventName - * @return bool + * @return int */ - public function fireEventCancel($eventName); + public function getDirtyState(): int; /** - * Check whether validation process has generated any messages + * Returns the value of the _id property * - * @return bool + * @return MongoId */ - public function validationHasFailed(); + public function getId(); /** * Returns all the validation messages * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getMessages(); + public function getMessages(): array; /** - * Appends a customized message on the validation process + * Returns an array with reserved properties that cannot be part of the + * insert/update * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @return array */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); + public function getReservedAttributes(): array; /** - * Creates/Updates a collection based on the values in the attributes + * Returns collection name mapped in the model * - * @return bool + * @return string */ - public function save(); + public function getSource(): string; /** - * Find a document by its id + * Creates/Updates a collection based on the values in the attributes * - * @param string $id - * @return null|CollectionInterface + * @return bool */ - public static function findById($id); + public function save(): bool; /** - * Allows to query the first record that match the specified conditions + * Sets a service in the services container that returns the Mongo database * - * @param array $parameters - * @return array + * @param string $connectionService */ - public static function findFirst(array $parameters = null); + public function setConnectionService(string $connectionService); /** - * Allows to query a set of records that match the specified conditions + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @param array $parameters - * @param $array parameters - * @return array + * @param int $dirtyState + * @return CollectionInterface */ - public static function find(array $parameters = null); + public function setDirtyState(int $dirtyState): CollectionInterface; /** - * Perform a count over a collection + * Sets a value for the _id property, creates a MongoId object if needed * - * @param array $parameters - * @return array + * @param mixed $id */ - public static function count(array $parameters = null); + public function setId($id); /** - * Deletes a model instance. Returning true on success or false otherwise + * Check whether validation process has generated any messages * * @return bool */ - public function delete(); + public function validationHasFailed(): bool; } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index f4089c53..e7f03779 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -5,13 +5,15 @@ /** * Phalcon\Mvc\Controller * - * Every application controller should extend this class that encapsulates all the controller functionality + * Every application controller should extend this class that encapsulates all + * the controller functionality * - * The controllers provide the “flow” between models and views. Controllers are responsible - * for processing the incoming requests from the web browser, interrogating the models for data, - * and passing that data on to the views for presentation. + * The controllers provide the “flow” between models and views. Controllers are + * responsible for processing the incoming requests from the web browser, + * interrogating the models for data, and passing that data on to the views for + * presentation. * - * + * ```php * + * ``` */ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ControllerInterface { @@ -46,6 +48,6 @@ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc /** * Phalcon\Mvc\Controller constructor */ - public final function __construct() {} + final public function __construct() {} } diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index f48fc6ad..50644e36 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -3,13 +3,12 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\Dispatcher + * Dispatching is the process of taking the request object, extracting the + * module name, controller name, action name, and optional parameters contained + * in it, and then instantiating a controller and calling an action of that + * controller. * - * Dispatching is the process of taking the request object, extracting the module name, - * controller name, action name, and optional parameters contained in it, and then - * instantiating a controller and calling an action of that controller. - * - * + * ```php * $di = new \Phalcon\Di(); * * $dispatcher = new \Phalcon\Mvc\Dispatcher(); @@ -21,88 +20,24 @@ * $dispatcher->setParams([]); * * $controller = $dispatcher->dispatch(); - * + * ``` */ -class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface { - protected $_handlerSuffix = 'Controller'; - - - protected $_defaultHandler = 'index'; - - - protected $_defaultAction = 'index'; - - - /** - * Sets the default controller suffix - * - * @param string $controllerSuffix - */ - public function setControllerSuffix($controllerSuffix) {} - - /** - * Sets the default controller name - * - * @param string $controllerName - */ - public function setDefaultController($controllerName) {} - - /** - * Sets the controller name to be dispatched - * - * @param string $controllerName - */ - public function setControllerName($controllerName) {} - - /** - * Gets last dispatched controller name - * - * @return string - */ - public function getControllerName() {} + protected $defaultAction = 'index'; - /** - * Gets previous dispatched namespace name - * - * @return string - */ - public function getPreviousNamespaceName() {} - /** - * Gets previous dispatched controller name - * - * @return string - */ - public function getPreviousControllerName() {} + protected $defaultHandler = 'index'; - /** - * Gets previous dispatched action name - * - * @return string - */ - public function getPreviousActionName() {} - /** - * Throws an internal exception - * - * @param string $message - * @param int $exceptionCode - */ - protected function _throwDispatchException($message, $exceptionCode = 0) {} + protected $handlerSuffix = 'Controller'; - /** - * Handles a user exception - * - * @param \Exception $exception - */ - protected function _handleException(\Exception $exception) {} /** * Forwards the execution flow to another controller/action. * - * + * ```php * use Phalcon\Events\Event; * use Phalcon\Mvc\Dispatcher; * use App\Backend\Bootstrap as Backend; @@ -136,8 +71,13 @@ protected function _handleException(\Exception $exception) {} * function(Event $event, Dispatcher $dispatcher, array $forward) use ($modules) { * $metadata = $modules[$forward["module"]]["metadata"]; * - * $dispatcher->setModuleName($forward["module"]); - * $dispatcher->setNamespaceName($metadata["controllersNamespace"]); + * $dispatcher->setModuleName( + * $forward["module"] + * ); + * + * $dispatcher->setNamespaceName( + * $metadata["controllersNamespace"] + * ); * } * ); * @@ -149,31 +89,96 @@ protected function _handleException(\Exception $exception) {} * "action" => "index", * ] * ); - * + * ``` * * @param array $forward */ public function forward($forward) {} /** - * Possible controller class name that will be located to dispatch the request + * Returns the active controller in the dispatcher + * + * @return \Phalcon\Mvc\ControllerInterface + */ + public function getActiveController(): ControllerInterface {} + + /** + * Possible controller class name that will be located to dispatch the + * request * * @return string */ - public function getControllerClass() {} + public function getControllerClass(): string {} + + /** + * Gets last dispatched controller name + * + * @return string + */ + public function getControllerName(): string {} /** * Returns the latest dispatched controller * * @return \Phalcon\Mvc\ControllerInterface */ - public function getLastController() {} + public function getLastController(): ControllerInterface {} /** - * Returns the active controller in the dispatcher + * Gets previous dispatched action name * - * @return \Phalcon\Mvc\ControllerInterface + * @return string + */ + public function getPreviousActionName(): string {} + + /** + * Gets previous dispatched controller name + * + * @return string + */ + public function getPreviousControllerName(): string {} + + /** + * Gets previous dispatched namespace name + * + * @return string + */ + public function getPreviousNamespaceName(): string {} + + /** + * Sets the controller name to be dispatched + * + * @param string $controllerName + */ + public function setControllerName(string $controllerName) {} + + /** + * Sets the default controller suffix + * + * @param string $controllerSuffix + */ + public function setControllerSuffix(string $controllerSuffix) {} + + /** + * Sets the default controller name + * + * @param string $controllerName + */ + public function setDefaultController(string $controllerName) {} + + /** + * Handles a user exception + * + * @param \Exception $exception + */ + protected function handleException(\Exception $exception) {} + + /** + * Throws an internal exception + * + * @param string $message + * @param int $exceptionCode */ - public function getActiveController() {} + protected function throwDispatchException(string $message, int $exceptionCode = 0) {} } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index d0625078..3019e142 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -7,49 +7,49 @@ * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends \Phalcon\DispatcherInterface +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** - * Sets the default controller suffix + * Returns the active controller in the dispatcher * - * @param string $controllerSuffix + * @return \Phalcon\Mvc\ControllerInterface */ - public function setControllerSuffix($controllerSuffix); + public function getActiveController(): ControllerInterface; /** - * Sets the default controller name + * Gets last dispatched controller name * - * @param string $controllerName + * @return string */ - public function setDefaultController($controllerName); + public function getControllerName(): string; /** - * Sets the controller name to be dispatched + * Returns the latest dispatched controller * - * @param string $controllerName + * @return \Phalcon\Mvc\ControllerInterface */ - public function setControllerName($controllerName); + public function getLastController(): ControllerInterface; /** - * Gets last dispatched controller name + * Sets the default controller suffix * - * @return string + * @param string $controllerSuffix */ - public function getControllerName(); + public function setControllerSuffix(string $controllerSuffix); /** - * Returns the latest dispatched controller + * Sets the controller name to be dispatched * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerName */ - public function getLastController(); + public function setControllerName(string $controllerName); /** - * Returns the active controller in the dispatcher + * Sets the default controller name * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerName */ - public function getActiveController(); + public function setDefaultController(string $controllerName); } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index 196e0b86..ccff1790 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -14,9 +14,9 @@ interface EntityInterface * Reads an attribute value by its name * * @param string $attribute - * @return mixed + * @return mixed|null */ - public function readAttribute($attribute); + public function readAttribute(string $attribute): ?; /** * Writes an attribute value by its name @@ -24,6 +24,6 @@ public function readAttribute($attribute); * @param string $attribute * @param mixed $value */ - public function writeAttribute($attribute, $value); + public function writeAttribute(string $attribute, $value); } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index 7f8ca591..b1fba1ac 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\Micro * - * With Phalcon you can create "Micro-Framework like" applications. By doing this, you only need to - * write a minimal amount of code to create a PHP application. Micro applications are suitable - * to small applications, APIs and prototypes in a practical way. + * With Phalcon you can create "Micro-Framework like" applications. By doing + * this, you only need to write a minimal amount of code to create a PHP + * application. Micro applications are suitable to small applications, APIs and + * prototypes in a practical way. * - * + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $app->get( @@ -19,185 +20,161 @@ * } * ); * - * $app->handle(); - * + * $app->handle("/say/welcome/Phalcon"); + * ``` */ class Micro extends \Phalcon\Di\Injectable implements \ArrayAccess { - protected $_dependencyInjector; + protected $activeHandler; - protected $_handlers = array(); + protected $afterBindingHandlers = array(); - protected $_router; + protected $afterHandlers = array(); - protected $_stopped; + protected $beforeHandlers = array(); - protected $_notFoundHandler; + protected $container; - protected $_errorHandler; + protected $errorHandler; - protected $_activeHandler; + protected $finishHandlers = array(); - protected $_beforeHandlers; + protected $handlers = array(); - protected $_afterHandlers; + protected $modelBinder; - protected $_finishHandlers; + protected $notFoundHandler; - protected $_returnedValue; + protected $responseHandler; - protected $_modelBinder; + protected $returnedValue; - protected $_afterBindingHandlers; + protected $router; - /** - * Phalcon\Mvc\Micro constructor - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} + protected $stopped; - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Maps a route to a handler without any HTTP method constraint + * Phalcon\Mvc\Micro constructor * - * @param string $routePattern - * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function map($routePattern, $handler) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Appends an 'after' middleware to be called after execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function get($routePattern, $handler) {} + public function after($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Appends a afterBinding middleware to be called after model binding * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function post($routePattern, $handler) {} + public function afterBinding($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Appends a before middleware to be called before execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function put($routePattern, $handler) {} + public function before($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Maps a route to a handler that only matches if the HTTP method is DELETE * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function patch($routePattern, $handler) {} + public function delete(string $routePattern, $handler): RouteInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets a handler that will be called when an exception is thrown handling + * the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function head($routePattern, $handler) {} + public function error($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Appends a 'finish' middleware to be called when the request is finished * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function delete($routePattern, $handler) {} + public function finish($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Maps a route to a handler that only matches if the HTTP method is GET * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function options($routePattern, $handler) {} + public function get(string $routePattern, $handler): RouteInterface {} /** - * Mounts a collection of handlers + * Return the handler that will be called for the matched route * - * @param \Phalcon\Mvc\Micro\CollectionInterface $collection - * @return Micro + * @return callable */ - public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection) {} + public function getActiveHandler() {} /** - * Sets a handler that will be called when the router doesn't match any of the defined routes + * Returns bound models from binder instance * - * @param callable $handler - * @return Micro + * @return array */ - public function notFound($handler) {} + public function getBoundModels(): array {} /** - * Sets a handler that will be called when an exception is thrown handling the route + * Returns the internal handlers attached to the application * - * @param callable $handler - * @return Micro + * @return array */ - public function error($handler) {} + public function getHandlers(): array {} /** - * Returns the internal router used by the application + * Gets model binder * - * @return RouterInterface + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getRouter() {} + public function getModelBinder(): ?BinderInterface {} /** - * Sets a service from the DI + * Returns the value returned by the executed handler * - * @param string $serviceName - * @param mixed $definition - * @param boolean $shared - * @return \Phalcon\Di\ServiceInterface + * @return mixed */ - public function setService($serviceName, $definition, $shared = false) {} + public function getReturnedValue() {} /** - * Checks if a service is registered in the DI + * Returns the internal router used by the application * - * @param string $serviceName - * @return bool + * @return RouterInterface */ - public function hasService($serviceName) {} + public function getRouter(): RouterInterface {} /** * Obtains a service from the DI @@ -205,7 +182,7 @@ public function hasService($serviceName) {} * @param string $serviceName * @return object */ - public function getService($serviceName) {} + public function getService(string $serviceName) {} /** * Obtains a shared service from the DI @@ -213,7 +190,7 @@ public function getService($serviceName) {} * @param string $serviceName * @return mixed */ - public function getSharedService($serviceName) {} + public function getSharedService(string $serviceName) {} /** * Handle the whole request @@ -221,140 +198,187 @@ public function getSharedService($serviceName) {} * @param string $uri * @return mixed */ - public function handle($uri = null) {} + public function handle(string $uri) {} /** - * Stops the middleware execution avoiding than other middlewares be executed + * Checks if a service is registered in the DI + * + * @param string $serviceName + * @return bool */ - public function stop() {} + public function hasService(string $serviceName): bool {} /** - * Sets externally the handler that must be called by the matched route + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param callable $activeHandler + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setActiveHandler($activeHandler) {} + public function head(string $routePattern, $handler): RouteInterface {} /** - * Return the handler that will be called for the matched route + * Maps a route to a handler without any HTTP method constraint * - * @return callable + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getActiveHandler() {} + public function map(string $routePattern, $handler): RouteInterface {} /** - * Returns the value returned by the executed handler + * Mounts a collection of handlers * - * @return mixed + * @param \Phalcon\Mvc\Micro\CollectionInterface $collection + * @return Micro */ - public function getReturnedValue() {} + public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro {} /** - * Check if a service is registered in the internal services container using the array syntax + * Sets a handler that will be called when the router doesn't match any of + * the defined routes * - * @param string $alias - * @return bool + * @param callable $handler + * @return Micro */ - public function offsetExists($alias) {} + public function notFound($handler): Micro {} /** - * Allows to register a shared service in the internal services container using the array syntax - * - * - * $app["request"] = new \Phalcon\Http\Request(); - * + * Check if a service is registered in the internal services container using + * the array syntax * - * @param string $alias - * @param mixed $definition + * @param mixed $alias + * @return bool */ - public function offsetSet($alias, $definition) {} + public function offsetExists($alias): bool {} /** - * Allows to obtain a shared service in the internal services container using the array syntax + * Allows to obtain a shared service in the internal services container + * using the array syntax * - * + * ```php * var_dump( * $app["request"] * ); - * + * ``` * - * @param string $alias + * @param mixed $alias * @return mixed */ public function offsetGet($alias) {} /** - * Removes a service from the internal services container using the array syntax + * Allows to register a shared service in the internal services container + * using the array syntax * - * @param string $alias + * ```php + * $app["request"] = new \Phalcon\Http\Request(); + * ``` + * + * @param mixed $alias + * @param mixed $definition + */ + public function offsetSet($alias, $definition) {} + + /** + * Removes a service from the internal services container using the array + * syntax + * + * @param mixed $alias */ public function offsetUnset($alias) {} /** - * Appends a before middleware to be called before execute the route + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function before($handler) {} + public function options(string $routePattern, $handler): RouteInterface {} /** - * Appends a afterBinding middleware to be called after model binding + * Maps a route to a handler that only matches if the HTTP method is PATCH * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function afterBinding($handler) {} + public function patch(string $routePattern, $handler): RouteInterface {} /** - * Appends an 'after' middleware to be called after execute the route + * Maps a route to a handler that only matches if the HTTP method is POST * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function after($handler) {} + public function post(string $routePattern, $handler): RouteInterface {} /** - * Appends a 'finish' middleware to be called when the request is finished + * Maps a route to a handler that only matches if the HTTP method is PUT * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function finish($handler) {} + public function put(string $routePattern, $handler): RouteInterface {} /** - * Returns the internal handlers attached to the application + * Sets externally the handler that must be called by the matched route * - * @return array + * @param callable $activeHandler */ - public function getHandlers() {} + public function setActiveHandler($activeHandler) {} /** - * Gets model binder + * Sets the DependencyInjector container * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getModelBinder() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Sets model binder * - * + * ```php * $micro = new Micro($di); - * $micro->setModelBinder(new Binder(), 'cache'); - * + * + * $micro->setModelBinder( + * new Binder(), + * 'cache' + * ); + * ``` * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Micro */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro {} /** - * Returns bound models from binder instance + * Appends a custom 'reponse' handler to be called insted of the default + * response handler * - * @return array + * @param callable $handler + * @return Micro */ - public function getBoundModels() {} + public function setResponseHandler($handler): Micro {} + + /** + * Sets a service from the DI + * + * @param string $serviceName + * @param mixed $definition + * @param bool $shared + * @return \Phalcon\Di\ServiceInterface + */ + public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface {} + + /** + * Stops the middleware execution avoiding than other middlewares be + * executed + */ + public function stop() {} } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 85fada49..4778080b 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -5,19 +5,21 @@ /** * Phalcon\Mvc\Model * - * Phalcon\Mvc\Model connects business objects and database tables to create - * a persistable domain model where logic and data are presented in one wrapping. + * Phalcon\Mvc\Model connects business objects and database tables to create a + * persistable domain model where logic and data are presented in one wrapping. * It‘s an implementation of the object-relational mapping (ORM). * - * A model represents the information (data) of the application and the rules to manipulate that data. - * Models are primarily used for managing the rules of interaction with a corresponding database table. - * In most cases, each table in your database will correspond to one model in your application. - * The bulk of your application's business logic will be concentrated in the models. + * A model represents the information (data) of the application and the rules to + * manipulate that data. Models are primarily used for managing the rules of + * interaction with a corresponding database table. In most cases, each table in + * your database will correspond to one model in your application. The bulk of + * your application's business logic will be concentrated in the models. * - * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, giving to developers high performance - * when interacting with databases while is also easy to use. + * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, + * giving to developers high performance when interacting with databases while + * is also easy to use. * - * + * ```php * $robot = new Robots(); * * $robot->type = "mechanical"; @@ -35,75 +37,78 @@ * } else { * echo "Great, a new robot was saved successfully!"; * } - * + * ``` */ abstract class Model implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable, \JsonSerializable { - const TRANSACTION_INDEX = 'transaction'; + const DIRTY_STATE_DETACHED = 2; - const OP_NONE = 0; + const DIRTY_STATE_PERSISTENT = 0; - const OP_CREATE = 1; + const DIRTY_STATE_TRANSIENT = 1; - const OP_UPDATE = 2; + const OP_CREATE = 1; const OP_DELETE = 3; - const DIRTY_STATE_PERSISTENT = 0; + const OP_NONE = 0; - const DIRTY_STATE_TRANSIENT = 1; + const OP_UPDATE = 2; - const DIRTY_STATE_DETACHED = 2; + const TRANSACTION_INDEX = 'transaction'; + + + protected $container; - protected $_dependencyInjector; + protected $dirtyState = 1; - protected $_modelsManager; + protected $dirtyRelated = array(); - protected $_modelsMetaData; + protected $errorMessages = array(); - protected $_errorMessages; + protected $modelsManager; - protected $_operationMade = 0; + protected $modelsMetaData; - protected $_dirtyState = 1; + protected $related = array(); - protected $_transaction; + protected $operationMade = 0; - protected $_uniqueKey; + protected $oldSnapshot = array(); - protected $_uniqueParams; + protected $skipped; - protected $_uniqueTypes; + protected $snapshot; - protected $_skipped; + protected $transaction; - protected $_related; + protected $uniqueKey; - protected $_snapshot; + protected $uniqueParams; - protected $_oldSnapshot; + protected $uniqueTypes; @@ -113,198 +118,114 @@ public function getTransaction() {} * Phalcon\Mvc\Model constructor * * @param mixed $data - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager */ - public final function __construct($data = null, \Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} + final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} /** - * Sets the dependency injection container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the dependency injection container + * Handles method calls when a method is not implemented * - * @return \Phalcon\DiInterface + * @param string $method + * @param array $arguments + * @return mixed */ - public function getDI() {} + public function __call(string $method, array $arguments) {} /** - * Sets a custom events manager + * Handles method calls when a static method is not implemented * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $method + * @param array $arguments + * @return mixed */ - protected function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public static function __callStatic(string $method, array $arguments) {} /** - * Returns the custom events manager + * Magic method to get related records using the relation alias as a + * property * - * @return \Phalcon\Events\ManagerInterface + * @param string $property + * @return mixed */ - protected function getEventsManager() {} + public function __get(string $property) {} /** - * Returns the models meta-data service related to the entity instance + * Magic method to check if a property is a valid relation * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @param string $property + * @return bool */ - public function getModelsMetaData() {} + public function __isset(string $property): bool {} /** - * Returns the models manager related to the entity instance + * Magic method to assign values to the the model * - * @return \Phalcon\Mvc\Model\ManagerInterface + * @param string $property + * @param mixed $value */ - public function getModelsManager() {} + public function __set(string $property, $value) {} /** - * Sets a transaction related to the Model instance - * - * - * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; - * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; - * - * try { - * $txManager = new TxManager(); - * - * $transaction = $txManager->get(); - * - * $robot = new Robots(); - * - * $robot->setTransaction($transaction); - * - * $robot->name = "WALL·E"; - * $robot->created_at = date("Y-m-d"); - * - * if ($robot->save() === false) { - * $transaction->rollback("Can't save robot"); - * } - * - * $robotPart = new RobotParts(); - * - * $robotPart->setTransaction($transaction); + * Setups a behavior in a model * - * $robotPart->type = "head"; + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Mvc\Model\Behavior\Timestampable; * - * if ($robotPart->save() === false) { - * $transaction->rollback("Robot part cannot be saved"); + * class Robots extends Model + * { + * public function initialize() + * { + * $this->addBehavior( + * new Timestampable( + * [ + * "onCreate" => [ + * "field" => "created_at", + * "format" => "Y-m-d", + * ], + * ] + * ) + * ); * } - * - * $transaction->commit(); - * } catch (TxFailed $e) { - * echo "Failed, reason: ", $e->getMessage(); * } - * - * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return ModelInterface - */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} - - /** - * Sets the table name to which model should be mapped - * - * @param string $source - * @return Model - */ - protected function setSource($source) {} - - /** - * Returns the table name mapped in the model - * - * @return string - */ - public function getSource() {} - - /** - * Sets schema name where the mapped table is located - * - * @param string $schema - * @return Model - */ - protected function setSchema($schema) {} - - /** - * Returns schema name where the mapped table is located - * - * @return string - */ - public function getSchema() {} - - /** - * Sets the DependencyInjection connection service name - * - * @param string $connectionService - * @return Model - */ - public function setConnectionService($connectionService) {} - - /** - * Sets the DependencyInjection connection service name used to read data + * ``` * - * @param string $connectionService - * @return Model - */ - public function setReadConnectionService($connectionService) {} - - /** - * Sets the DependencyInjection connection service name used to write data - * - * @param string $connectionService - * @return Model - */ - public function setWriteConnectionService($connectionService) {} - - /** - * Returns the DependencyInjection connection service name used to read data related the model - * - * @return string - */ - public function getReadConnectionService() {} - - /** - * Returns the DependencyInjection connection service name used to write data related to the model - * - * @return string + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function getWriteConnectionService() {} + public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Appends a customized message on the validation process * - * @param int $dirtyState - * @return ModelInterface - */ - public function setDirtyState($dirtyState) {} - - /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Messages\Message as Message; * - * @return int - */ - public function getDirtyState() {} - - /** - * Gets the connection used to read data for the model + * class Robots extends Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); * - * @return \Phalcon\Db\AdapterInterface - */ - public function getReadConnection() {} - - /** - * Gets the connection used to write data to the model + * $this->appendMessage($message); + * } + * } + * } + * ``` * - * @return \Phalcon\Db\AdapterInterface + * @param \Phalcon\Messages\MessageInterface $message + * @return \Phalcon\Mvc\ModelInterface */ - public function getWriteConnection() {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface {} /** * Assigns values to a model from an array * - * + * ```php * $robot->assign( * [ * "type" => "mechanical", @@ -345,20 +266,50 @@ public function getWriteConnection() {} * "year", * ] * ); - * + * ``` * * @param array $data * @param array $dataColumnMap array to transform keys of data to another * @param array $whiteList - * @return Model + * @return \Phalcon\Mvc\ModelInterface */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null) {} + public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface {} /** - * Assigns values to a model from an array, returning a new model. + * Returns the average value on a column for a result-set of rows matching + * the specified conditions * - * - * $robot = \Phalcon\Mvc\Model::cloneResultMap( + * ```php + * // What's the average price of robots? + * $average = Robots::average( + * [ + * "column" => "price", + * ] + * ); + * + * echo "The average price is ", $average, "\n"; + * + * // What's the average price of mechanical robots? + * $average = Robots::average( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); + * + * echo "The average price of mechanical robots is ", $average, "\n"; + * ``` + * + * @param array $parameters + * @return double + */ + public static function average($parameters = null): float {} + + /** + * Assigns values to a model from an array returning a new model + * + * ```php + * $robot = Phalcon\Mvc\Model::cloneResult( * new Robots(), * [ * "type" => "mechanical", @@ -366,32 +317,20 @@ public function assign(array $data, $dataColumnMap = null, $whiteList = null) {} * "year" => 1952, * ] * ); - * + * ``` * - * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface $base * @param array $data - * @param array $columnMap * @param int $dirtyState - * @param boolean $keepSnapshots - * @return Model - */ - public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null) {} - - /** - * Returns an hydrated result based on the data and the column map - * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode - * @return mixed + * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode) {} + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface {} /** - * Assigns values to a model from an array returning a new model + * Assigns values to a model from an array, returning a new model. * - * - * $robot = Phalcon\Mvc\Model::cloneResult( + * ```php + * $robot = \Phalcon\Mvc\Model::cloneResultMap( * new Robots(), * [ * "type" => "mechanical", @@ -399,41 +338,139 @@ public static function cloneResultMapHydrate(array $data, $columnMap, $hydration * "year" => 1952, * ] * ); - * + * ``` * - * @param \Phalcon\Mvc\ModelInterface $base + * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base * @param array $data + * @param array $columnMap * @param int $dirtyState + * @param bool $keepSnapshots * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResult(ModelInterface $base, array $data, $dirtyState = 0) {} + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface {} /** - * Query for a set of records that match the specified conditions + * Returns an hydrated result based on the data and the column map + * + * @param array $data + * @param array $columnMap + * @param int $hydrationMode + * @return mixed + */ + public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) {} + + /** + * Counts how many records match the specified conditions * - * + * ```php * // How many robots are there? - * $robots = Robots::find(); + * $number = Robots::count(); * - * echo "There are ", count($robots), "\n"; + * echo "There are ", $number, "\n"; * * // How many mechanical robots are there? - * $robots = Robots::find( - * "type = 'mechanical'" - * ); - * - * echo "There are ", count($robots), "\n"; + * $number = Robots::count("type = 'mechanical'"); * - * // Get and print virtual robots ordered by name - * $robots = Robots::find( - * [ - * "type = 'virtual'", - * "order" => "name", - * ] - * ); + * echo "There are ", $number, " mechanical robots\n"; + * ``` * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * @param array $parameters + * @return int + */ + public static function count($parameters = null): int {} + + /** + * Inserts a model instance. If the instance already exists in the + * persistence it will throw an exception + * Returning true on success or false otherwise. + * + * ```php + * // Creating a new robot + * $robot = new Robots(); + * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; + * + * $robot->create(); + * + * // Passing an array to create + * $robot = new Robots(); + * + * $robot->assign( + * [ + * "type" => "mechanical", + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); + * + * $robot->create(); + * ``` + * + * @return bool + */ + public function create(): bool {} + + /** + * Deletes a model instance. Returning true on success or false otherwise. + * + * ```php + * $robot = Robots::findFirst("id=100"); + * + * $robot->delete(); + * + * $robots = Robots::find("type = 'mechanical'"); + * + * foreach ($robots as $robot) { + * $robot->delete(); + * } + * ``` + * + * @return bool + */ + public function delete(): bool {} + + /** + * Returns a simple representation of the object that can be used with + * `var_dump()` + * + * ```php + * var_dump( + * $robot->dump() + * ); + * ``` + * + * @return array + */ + public function dump(): array {} + + /** + * Query for a set of records that match the specified conditions + * + * ```php + * // How many robots are there? + * $robots = Robots::find(); + * + * echo "There are ", count($robots), "\n"; + * + * // How many mechanical robots are there? + * $robots = Robots::find( + * "type = 'mechanical'" + * ); + * + * echo "There are ", count($robots), "\n"; + * + * // Get and print virtual robots ordered by name + * $robots = Robots::find( + * [ + * "type = 'virtual'", + * "order" => "name", + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; * } * * // Get first 100 virtual robots ordered by name @@ -446,7 +483,7 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * ); * * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * echo $robot->name, "\n"; * } * * // encapsulate find it into an running transaction esp. useful for application unit-tests @@ -454,11 +491,27 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); + * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); - * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); * - * $resultInsideTransaction = Robot::find(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); + * $newRobot->assign( + * [ + * 'name' => 'test', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * + * $newRobot->save(); + * + * $resultInsideTransaction = Robot::find( + * [ + * 'name' => 'test', + * Model::TRANSACTION_INDEX => $myTransaction, + * ] + * ); + * * $resultOutsideTransaction = Robot::find(['name' => 'test']); * * foreach ($setInsideTransaction as $robot) { @@ -481,39 +534,85 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * // add a new robots * $firstNewRobot = new Robot(); * $firstNewRobot->setTransaction($myTransaction1); - * $firstNewRobot->save(['name' => 'first-transaction-robot', 'type' => 'mechanical', 'year' => 1944]); + * $firstNewRobot->assign( + * [ + * 'name' => 'first-transaction-robot', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * $firstNewRobot->save(); * * $secondNewRobot = new Robot(); * $secondNewRobot->setTransaction($myTransaction2); - * $secondNewRobot->save(['name' => 'second-transaction-robot', 'type' => 'fictional', 'year' => 1984]); + * $secondNewRobot->assign( + * [ + * 'name' => 'second-transaction-robot', + * 'type' => 'fictional', + * 'year' => 1984, + * ] + * ); + * $secondNewRobot->save(); * * // this transaction will find the robot. - * $resultInFirstTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); + * $resultInFirstTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction1, + * ] + * ); + * * // this transaction won't find the robot. - * $resultInSecondTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); + * $resultInSecondTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction2, + * ] + * ); + * * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'first-transaction-robot']); + * $resultOutsideAnyExplicitTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * ] + * ); * * // this transaction won't find the robot. - * $resultInFirstTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); + * $resultInFirstTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction2, + * ] + * ); + * * // this transaction will find the robot. - * $resultInSecondTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); + * $resultInSecondTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction1, + * ] + * ); + * * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'second-transaction-robot']); + * $resultOutsideAnyExplicitTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * ] + * ); * * $transaction1->rollback(); * $transaction2->rollback(); - * + * ``` * * @param mixed $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public static function find($parameters = null) {} + public static function find($parameters = null): ResultsetInterface {} /** * Query the first record that matches the specified conditions * - * + * ```php * // What's the first robot in robots table? * $robot = Robots::findFirst(); * @@ -521,7 +620,7 @@ public static function find($parameters = null) {} * * // What's the first mechanical robot in robots table? * $robot = Robots::findFirst( - * "type = 'mechanical'" + * "type = 'mechanical'" * ); * * echo "The first mechanical robot name is ", $robot->name; @@ -539,431 +638,414 @@ public static function find($parameters = null) {} * // behaviour with transaction * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); + * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); - * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); + * $newRobot->assign( + * [ + * 'name' => 'test', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * $newRobot->save(); + * + * $findsARobot = Robot::findFirst( + * [ + * 'name' => 'test', + * Model::TRANSACTION_INDEX => $myTransaction, + * ] + * ); * - * $findsARobot = Robot::findFirst(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); - * $doesNotFindARobot = Robot::findFirst(['name' => 'test']); + * $doesNotFindARobot = Robot::findFirst( + * [ + * 'name' => 'test', + * ] + * ); * * var_dump($findARobot); * var_dump($doesNotFindARobot); * * $transaction->commit(); - * $doesFindTheRobotNow = Robot::findFirst(['name' => 'test']); - * * - * @param mixed $parameters - * @return Model + * $doesFindTheRobotNow = Robot::findFirst( + * [ + * 'name' => 'test', + * ] + * ); + * ``` + * + * @param string|array $parameters + * @return bool|\Phalcon\Mvc\ModelInterface */ public static function findFirst($parameters = null) {} /** - * shared prepare query logic for find and findFirst method + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @param mixed $params - * @param mixed $limit - * @return \Phalcon\Mvc\Model\Query + * @param string $eventName + * @return bool */ - private static function getPreparedQuery($params, $limit = null) {} + public function fireEvent(string $eventName): bool {} /** - * Create a criteria for a specific model + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified + * This method stops if one of the callbacks/listeners returns bool false * - * @param \Phalcon\DiInterface $dependencyInjector - * @return \Phalcon\Mvc\Model\Criteria + * @param string $eventName + * @return bool */ - public static function query(\Phalcon\DiInterface $dependencyInjector = null) {} + public function fireEventCancel(string $eventName): bool {} /** - * Checks whether the current record already exists + * Returns a list of changed values. * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @return bool + * ```php + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] + * + * $robots->deleted = 'Y'; + * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * ``` + * + * @return array */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table = null) {} + public function getChangedFields(): array {} /** - * Generate a PHQL SELECT statement for an aggregate + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param string $functionName - * @param string $alias - * @param array $parameters - * @param string $function - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return int */ - protected static function _groupResult($functionName, $alias, $parameters) {} + public function getDirtyState(): int {} /** - * Counts how many records match the specified conditions - * - * - * // How many robots are there? - * $number = Robots::count(); - * - * echo "There are ", $number, "\n"; - * - * // How many mechanical robots are there? - * $number = Robots::count("type = 'mechanical'"); + * Returns the dependency injection container * - * echo "There are ", $number, " mechanical robots\n"; - * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the custom events manager * - * @param array $parameters - * @return mixed + * @return \Phalcon\Events\ManagerInterface */ - public static function count($parameters = null) {} + public function getEventsManager(): EventsManagerInterface {} /** - * Calculates the sum on a column for a result-set of rows that match the specified conditions + * Returns array of validation messages * - * - * // How much are all robots? - * $sum = Robots::sum( - * [ - * "column" => "price", - * ] - * ); + * ```php + * $robot = new Robots(); * - * echo "The total price of robots is ", $sum, "\n"; + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; * - * // How much are mechanical robots? - * $sum = Robots::sum( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; * - * echo "The total price of mechanical robots is ", $sum, "\n"; - * + * $messages = $robot->getMessages(); * - * @param array $parameters - * @return mixed + * foreach ($messages as $message) { + * echo $message; + * } + * } else { + * echo "Great, a new robot was saved successfully!"; + * } + * ``` + * + * @param mixed $filter + * @return array|\Phalcon\Messages\MessageInterface[] */ - public static function sum($parameters = null) {} + public function getMessages($filter = null): array {} /** - * Returns the maximum value of a column for a result-set of rows that match the specified conditions - * - * - * // What is the maximum robot id? - * $id = Robots::maximum( - * [ - * "column" => "id", - * ] - * ); + * Returns the models manager related to the entity instance * - * echo "The maximum robot id is: ", $id, "\n"; + * @return \Phalcon\Mvc\Model\ManagerInterface + */ + public function getModelsManager(): ManagerInterface {} + + /** + * {@inheritdoc} * - * // What is the maximum id of mechanical robots? - * $sum = Robots::maximum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); + * @return \Phalcon\Mvc\Model\MetaDataInterface + */ + public function getModelsMetaData(): MetaDataInterface {} + + /** + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * echo "The maximum robot id of mechanical robots is ", $id, "\n"; - * + * @return int + */ + public function getOperationMade(): int {} + + /** + * Returns the internal old snapshot data * - * @param array $parameters - * @return mixed + * @return array */ - public static function maximum($parameters = null) {} + public function getOldSnapshotData(): array {} /** - * Returns the minimum value of a column for a result-set of rows that match the specified conditions + * Gets the connection used to read data for the model * - * - * // What is the minimum robot id? - * $id = Robots::minimum( - * [ - * "column" => "id", - * ] - * ); - * - * echo "The minimum robot id is: ", $id; - * - * // What is the minimum id of mechanical robots? - * $sum = Robots::minimum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); + * @return \Phalcon\Db\Adapter\AdapterInterface + */ + final public function getReadConnection(): AdapterInterface {} + + /** + * Returns the DependencyInjection connection service name used to read data + * related the model * - * echo "The minimum robot id of mechanical robots is ", $id; - * + * @return string + */ + final public function getReadConnectionService(): string {} + + /** + * Returns related records based on defined relations * - * @param array $parameters - * @return mixed + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ - public static function minimum($parameters = null) {} + public function getRelated(string $alias, $arguments = null) {} /** - * Returns the average value on a column for a result-set of rows matching the specified conditions + * Checks if saved related records have already been loaded. * - * - * // What's the average price of robots? - * $average = Robots::average( - * [ - * "column" => "price", - * ] - * ); + * Only returns true if the records were previously fetched + * through the model without any additional parameters. * - * echo "The average price is ", $average, "\n"; + * ```php + * $robot = Robots::findFirst(); + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false * - * // What's the average price of mechanical robots? - * $average = Robots::average( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); + * $robotsParts = $robot->getRobotsParts(['id > 0']); + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false * - * echo "The average price of mechanical robots is ", $average, "\n"; - * + * $robotsParts = $robot->getRobotsParts(); // or $robot->robotsParts + * var_dump($robot->isRelationshipLoaded('robotsParts')); // true * - * @param array $parameters - * @return double + * $robot->robotsParts = [new RobotsParts()]; + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false + * ``` + * + * @param string $relationshipAlias + * @return bool */ - public static function average($parameters = null) {} + public function isRelationshipLoaded(string $relationshipAlias): bool {} /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Returns schema name where the mapped table is located * - * @param string $eventName - * @return bool + * @return string */ - public function fireEvent($eventName) {} + final public function getSchema(): string {} /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Returns the internal snapshot data * - * @param string $eventName - * @return bool + * @return array */ - public function fireEventCancel($eventName) {} + public function getSnapshotData(): array {} /** - * Cancel the current operation + * Returns the table name mapped in the model + * + * @return string */ - protected function _cancelOperation() {} + final public function getSource(): string {} /** - * Appends a customized message on the validation process + * Returns a list of updated values. * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Mvc\Model\Message as Message; + * ```php + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] * - * class Robots extends Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); + * $robots->deleted = 'Y'; * - * $this->appendMessage($message); - * } - * } - * } - * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * $robots->save(); + * print_r($robots->getChangedFields()); // [] + * print_r($robots->getUpdatedFields()); // ["deleted"] + * ``` * - * @param \Phalcon\Mvc\Model\MessageInterface $message - * @return Model + * @return array */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} + public function getUpdatedFields(): array {} /** - * Executes validators on every validation call - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * + * Gets the connection used to write data to the model * - * @param \Phalcon\ValidationInterface $validator - * @return bool + * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function validate(\Phalcon\ValidationInterface $validator) {} + final public function getWriteConnection(): AdapterInterface {} /** - * Check whether validation process has generated any messages - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->validate( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * + * Returns the DependencyInjection connection service name used to write + * data related to the model * - * @return bool + * @return string */ - public function validationHasFailed() {} + final public function getWriteConnectionService(): string {} /** - * Returns array of validation messages + * Check if a specific attribute has changed + * This only works if the model is keeping data snapshots * - * + * ```php * $robot = new Robots(); * * $robot->type = "mechanical"; * $robot->name = "Astro Boy"; * $robot->year = 1952; * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); + * $robot->create(); * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * + * $robot->type = "hydraulic"; * - * @param mixed $filter - * @return \Phalcon\Mvc\Model\MessageInterface[] - */ - public function getMessages($filter = null) {} - - /** - * Reads "belongs to" relations and check the virtual foreign keys when inserting or updating records - * to verify that inserted/updated values are present in the related entity + * $hasChanged = $robot->hasChanged("type"); // returns true + * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true + * $hasChanged = $robot->hasChanged(["type", "name"], true); // returns false + * ``` * + * @param string|array $fieldName + * @param boolean $allFields * @return bool */ - protected final function _checkForeignKeysRestrict() {} + public function hasChanged($fieldName = null, bool $allFields = false): bool {} /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (cascade) when deleting records + * Checks if the object has internal snapshot data * * @return bool */ - protected final function _checkForeignKeysReverseCascade() {} + public function hasSnapshotData(): bool {} /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (restrict) when deleting records + * Check if a specific attribute was updated + * This only works if the model is keeping data snapshots * + * @param string|array $fieldName + * @param bool $allFields * @return bool */ - protected final function _checkForeignKeysReverseRestrict() {} + public function hasUpdated($fieldName = null, bool $allFields = false): bool {} /** - * Executes internal hooks before save a record + * Serializes the object for json_encode * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param bool $exists - * @param mixed $identityField - * @return bool + * ```php + * echo json_encode($robot); + * ``` + * + * @return array */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, $exists, $identityField) {} + public function jsonSerialize(): array {} /** - * Executes internal events after save a record + * Returns the maximum value of a column for a result-set of rows that match + * the specified conditions * - * @param bool $success - * @param bool $exists - * @return bool + * ```php + * // What is the maximum robot id? + * $id = Robots::maximum( + * [ + * "column" => "id", + * ] + * ); + * + * echo "The maximum robot id is: ", $id, "\n"; + * + * // What is the maximum id of mechanical robots? + * $sum = Robots::maximum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); + * + * echo "The maximum robot id of mechanical robots is ", $id, "\n"; + * ``` + * + * @param array $parameters + * @return mixed */ - protected function _postSave($success, $exists) {} + public static function maximum($parameters = null) {} /** - * Sends a pre-build INSERT SQL statement to the relational database system + * Returns the minimum value of a column for a result-set of rows that match + * the specified conditions * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @param boolean|string $identityField - * @return bool + * ```php + * // What is the minimum robot id? + * $id = Robots::minimum( + * [ + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id is: ", $id; + * + * // What is the minimum id of mechanical robots? + * $sum = Robots::minimum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id of mechanical robots is ", $id; + * ``` + * + * @param array $parameters + * @return mixed */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table, $identityField) {} + public static function minimum($parameters = null) {} /** - * Sends a pre-build UPDATE SQL statement to the relational database system + * Create a criteria for a specific model * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @return bool + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table) {} + public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface {} /** - * Saves related records that must be stored prior to save the master record + * Reads an attribute value by its name * - * @param \Phalcon\Db\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related - * @return bool + * ```php + * echo $robot->readAttribute("name"); + * ``` + * + * @param string $attribute + * @return mixed|null */ - protected function _preSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} + public function readAttribute(string $attribute): ? {} /** - * Save the related records assigned in the has-one/has-many relations + * Refreshes the model attributes re-querying the record from the database * - * @param \Phalcon\Db\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related - * @return bool + * @return \Phalcon\Mvc\ModelInterface */ - protected function _postSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} + public function refresh(): ModelInterface {} /** - * Inserts or updates a model instance. Returning true on success or false otherwise. + * Inserts or updates a model instance. Returning true on success or false + * otherwise. * - * + * ```php * // Creating a new robot * $robot = new Robots(); * @@ -979,648 +1061,697 @@ protected function _postSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connect * $robot->name = "Biomass"; * * $robot->save(); - * + * ``` * - * @param array $data - * @param array $whiteList * @return bool */ - public function save($data = null, $whiteList = null) {} + public function save(): bool {} /** - * Inserts a model instance. If the instance already exists in the persistence it will throw an exception - * Returning true on success or false otherwise. - * - * - * // Creating a new robot - * $robot = new Robots(); + * Serializes the object ignoring connections, services, related objects or + * static properties * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * $robot->create(); - * - * // Passing an array to create - * $robot = new Robots(); - * - * $robot->create( - * [ - * "type" => "mechanical", - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); - * - * - * @param mixed $data - * @param mixed $whiteList - * @return bool + * @return string */ - public function create($data = null, $whiteList = null) {} + public function serialize(): string {} /** - * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception - * Returning true on success or false otherwise. - * - * - * // Updating a robot name - * $robot = Robots::findFirst("id = 100"); - * - * $robot->name = "Biomass"; - * - * $robot->update(); - * + * Unserializes the object from a serialized string * * @param mixed $data - * @param mixed $whiteList - * @return bool */ - public function update($data = null, $whiteList = null) {} + public function unserialize($data) {} /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * - * $robot = Robots::findFirst("id=100"); - * - * $robot->delete(); - * - * $robots = Robots::find("type = 'mechanical'"); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * + * Sets the DependencyInjection connection service name * - * @return bool + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface */ - public function delete() {} + final public function setConnectionService(string $connectionService): ModelInterface {} /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * - * @return int + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getOperationMade() {} + public function setDirtyState(int $dirtyState) {} /** - * Refreshes the model attributes re-querying the record from the database + * Sets the dependency injection container * - * @return Model + * @param \Phalcon\Di\DiInterface $container */ - public function refresh() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Skips the current operation forcing a success state + * Sets a custom events manager * - * @param bool $skip + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function skipOperation($skip) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Reads an attribute value by its name - * - * - * echo $robot->readAttribute("name"); - * + * Sets the DependencyInjection connection service name used to read data * - * @param string $attribute + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface */ - public function readAttribute($attribute) {} + final public function setReadConnectionService(string $connectionService): ModelInterface {} /** - * Writes an attribute value by its name + * Sets the record's old snapshot data. + * This method is used internally to set old snapshot data when the model + * was set up to keep snapshot data * - * - * $robot->writeAttribute("name", "Rosey"); - * + * @param array $data + * @param array $columnMap + */ + public function setOldSnapshotData(array $data, $columnMap = null) {} + + /** + * Sets the record's snapshot data. + * This method is used internally to set snapshot data when the model was + * set up to keep snapshot data * - * @param string $attribute - * @param mixed $value + * @param array $data + * @param array $columnMap */ - public function writeAttribute($attribute, $value) {} + public function setSnapshotData(array $data, $columnMap = null) {} /** - * Sets a list of attributes that must be skipped from the - * generated INSERT/UPDATE statement + * Sets a transaction related to the Model instance * - * + * ```php + * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; + * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributes( - * [ - * "price", - * ] - * ); + * try { + * $txManager = new TxManager(); + * + * $transaction = $txManager->get(); + * + * $robot = new Robots(); + * + * $robot->setTransaction($transaction); + * + * $robot->name = "WALL·E"; + * $robot->created_at = date("Y-m-d"); + * + * if ($robot->save() === false) { + * $transaction->rollback("Can't save robot"); * } - * } - * * - * @param array $attributes - */ - protected function skipAttributes(array $attributes) {} - - /** - * Sets a list of attributes that must be skipped from the - * generated INSERT statement + * $robotPart = new RobotParts(); * - * + * $robotPart->setTransaction($transaction); * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnCreate( - * [ - * "created_at", - * ] - * ); + * $robotPart->type = "head"; + * + * if ($robotPart->save() === false) { + * $transaction->rollback("Robot part cannot be saved"); * } + * + * $transaction->commit(); + * } catch (TxFailed $e) { + * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` * - * @param array $attributes + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return \Phalcon\Mvc\ModelInterface */ - protected function skipAttributesOnCreate(array $attributes) {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Enables/disables options in the ORM * - * + * @param array $options + */ + public static function setup(array $options) {} + + /** + * Sets the DependencyInjection connection service name used to write data * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnUpdate( - * [ - * "modified_in", - * ] - * ); - * } - * } - * + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface + */ + final public function setWriteConnectionService(string $connectionService): ModelInterface {} + + /** + * Skips the current operation forcing a success state * - * @param array $attributes + * @param bool $skip */ - protected function skipAttributesOnUpdate(array $attributes) {} + public function skipOperation(bool $skip) {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Calculates the sum on a column for a result-set of rows that match the + * specified conditions * - * + * ```php + * // How much are all robots? + * $sum = Robots::sum( + * [ + * "column" => "price", + * ] + * ); * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->allowEmptyStringValues( - * [ - * "name", - * ] - * ); - * } - * } - * + * echo "The total price of robots is ", $sum, "\n"; * - * @param array $attributes + * // How much are mechanical robots? + * $sum = Robots::sum( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); + * + * echo "The total price of mechanical robots is ", $sum, "\n"; + * ``` + * + * @param array $parameters + * @return double */ - protected function allowEmptyStringValues(array $attributes) {} + public static function sum($parameters = null): float {} /** - * Setup a 1-1 relation between two models - * - * + * Returns the instance as an array representation * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasOne("id", "RobotsDescription", "robots_id"); - * } - * } - * + * ```php + * print_r( + * $robot->toArray() + * ); + * ``` * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $columns + * @return array */ - protected function hasOne($fields, $referenceModel, $referencedFields, $options = null) {} + public function toArray($columns = null): array {} /** - * Setup a reverse 1-1 or n-1 relation between two models + * Updates a model instance. If the instance doesn't exist in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. * - * + * ```php + * // Updating a robot name + * $robot = Robots::findFirst("id = 100"); * - * class RobotsParts extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->belongsTo("robots_id", "Robots", "id"); - * } - * } - * + * $robot->name = "Biomass"; * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * $robot->update(); + * ``` + * + * @return bool */ - protected function belongsTo($fields, $referenceModel, $referencedFields, $options = null) {} + public function update(): bool {} /** - * Setup a 1-n relation between two models - * - * + * Writes an attribute value by its name * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasMany("id", "RobotsParts", "robots_id"); - * } - * } - * + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param string $attribute + * @param mixed $value */ - protected function hasMany($fields, $referenceModel, $referencedFields, $options = null) {} + public function writeAttribute(string $attribute, $value) {} /** - * Setup an n-n relation between two models, through an intermediate relation + * Reads "belongs to" relations and check the virtual foreign keys when + * inserting or updating records to verify that inserted/updated values are + * present in the related entity * - * - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * // Setup a many-to-many relation to Parts through RobotsParts - * $this->hasManyToMany( - * "id", - * "RobotsParts", - * "robots_id", - * "parts_id", - * "Parts", - * "id", - * ); - * } - * } - * - * - * @param string|array fields - * @param string intermediateModel - * @param string|array intermediateFields - * @param string|array intermediateReferencedFields - * @param string referencedModel - * @param mixed $fields - * @param string $intermediateModel - * @param mixed $intermediateFields - * @param mixed $intermediateReferencedFields - * @param string $referenceModel - * @param string|array $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\Relation + * @return bool */ - protected function hasManyToMany($fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referenceModel, $referencedFields, $options = null) {} + final protected function _checkForeignKeysRestrict(): bool {} /** - * Setups a behavior in a model + * Reads both "hasMany" and "hasOne" relations and checks the virtual + * foreign keys (cascade) when deleting records * - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Mvc\Model\Behavior\Timestampable; - * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->addBehavior( - * new Timestampable( - * [ - * "onCreate" => [ - * "field" => "created_at", - * "format" => "Y-m-d", - * ], - * ] - * ) - * ); - * } - * } - * - * - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @return bool */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} + final protected function _checkForeignKeysReverseCascade(): bool {} /** - * Sets if the model must keep the original record snapshot in memory - * - * - * - * use Phalcon\Mvc\Model; - * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->keepSnapshots(true); - * } - * } - * + * Reads both "hasMany" and "hasOne" relations and checks the virtual + * foreign keys (restrict) when deleting records * - * @param bool $keepSnapshot + * @return bool */ - protected function keepSnapshots($keepSnapshot) {} + final protected function _checkForeignKeysReverseRestrict(): bool {} /** - * Sets the record's snapshot data. - * This method is used internally to set snapshot data when the model was set up to keep snapshot data + * Sends a pre-build INSERT SQL statement to the relational database system * - * @param array $data - * @param array $columnMap + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param string|array $table + * @param bool|string $identityField + * @return bool */ - public function setSnapshotData(array $data, $columnMap = null) {} + protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool {} /** - * Sets the record's old snapshot data. - * This method is used internally to set old snapshot data when the model was set up to keep snapshot data + * Sends a pre-build UPDATE SQL statement to the relational database system * - * @param array $data - * @param array $columnMap + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param string|array $table + * @return bool */ - public function setOldSnapshotData(array $data, $columnMap = null) {} + protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool {} /** - * Checks if the object has internal snapshot data + * Checks whether the current record already exists * + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @return bool */ - public function hasSnapshotData() {} + protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool {} /** - * Returns the internal snapshot data + * Returns related records defined relations depending on the method name * - * @return array + * @param string $modelName + * @param string $method + * @param array $arguments + * @return mixed */ - public function getSnapshotData() {} + protected function _getRelatedRecords(string $modelName, string $method, $arguments) {} /** - * Returns the internal old snapshot data + * Generate a PHQL SELECT statement for an aggregate * - * @return array + * @param string $functionName + * @param string $alias + * @param array $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getOldSnapshotData() {} + protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface {} /** - * Check if a specific attribute has changed - * This only works if the model is keeping data snapshots - * - * - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; + * Try to check if the query must invoke a finder * - * $robot->create(); - * $robot->type = "hydraulic"; - * $hasChanged = $robot->hasChanged("type"); // returns true - * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true - * $hasChanged = $robot->hasChanged(["type", "name", true]); // returns false - * + * @param string $method + * @param array $arguments + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool + */ + protected final static function _invokeFinder(string $method, array $arguments) {} + + /** + * Check for, and attempt to use, possible setter. * - * @param string|array $fieldName - * @param boolean $allFields + * @param string $property + * @param mixed $value * @return bool */ - public function hasChanged($fieldName = null, $allFields = false) {} + final protected function _possibleSetter(string $property, $value): bool {} /** - * Check if a specific attribute was updated - * This only works if the model is keeping data snapshots + * Executes internal hooks before save a record * - * @param string|array $fieldName - * @param bool $allFields + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param bool $exists + * @param mixed $identityField * @return bool */ - public function hasUpdated($fieldName = null, $allFields = false) {} + protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool {} /** - * Returns a list of changed values. - * - * - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] - * - * $robots->deleted = 'Y'; - * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * + * Saves related records that must be stored prior to save the master record * - * @return array + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool */ - public function getChangedFields() {} + protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} /** - * Returns a list of updated values. - * - * - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] - * - * $robots->deleted = 'Y'; + * Executes internal events after save a record * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * $robots->save(); - * print_r($robots->getChangedFields()); // [] - * print_r($robots->getUpdatedFields()); // ["deleted"] - * + * @param bool $success + * @param bool $exists + * @return bool */ - public function getUpdatedFields() {} + protected function _postSave(bool $success, bool $exists): bool {} /** - * Sets if a model must use dynamic update instead of the all-field update - * - * + * Save the related records assigned in the has-one/has-many relations * - * use Phalcon\Mvc\Model; + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool + */ + protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + + /** + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * class Robots extends Model + * ```php + * class Robots extends \Phalcon\Mvc\Model * { * public function initialize() * { - * $this->useDynamicUpdate(true); + * $this->allowEmptyStringValues( + * [ + * "name", + * ] + * ); * } * } - * + * ``` * - * @param bool $dynamicUpdate + * @param array $attributes */ - protected function useDynamicUpdate($dynamicUpdate) {} + protected function allowEmptyStringValues(array $attributes) {} /** - * Returns related records based on defined relations - * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\ResultsetInterface + * Cancel the current operation */ - public function getRelated($alias, $arguments = null) {} + protected function _cancelOperation() {} /** - * Returns related records defined relations depending on the method name + * Setup a reverse 1-1 or n-1 relation between two models * - * @param string $modelName - * @param string $method - * @param array $arguments - * @return mixed + * ```php + * class RobotsParts extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->belongsTo( + * "robots_id", + * Robots::class, + * "id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - protected function _getRelatedRecords($modelName, $method, $arguments) {} + protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Try to check if the query must invoke a finder + * shared prepare query logic for find and findFirst method * - * @param string $method - * @param array $arguments - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|boolean + * @param mixed $params + * @param mixed $limit + * @return \Phalcon\Mvc\Model\Query */ - protected final static function _invokeFinder($method, $arguments) {} + private static function getPreparedQuery($params, $limit = null): Query {} /** - * Handles method calls when a method is not implemented + * Setup a 1-n relation between two models * - * @param string method - * @param array arguments - * @return mixed - * @param string $method - * @param mixed $arguments + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasMany( + * "id", + * RobotsParts::class, + * "robots_id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function __call($method, $arguments) {} + protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Handles method calls when a static method is not implemented + * Setup an n-n relation between two models, through an intermediate + * relation * - * @param string method - * @param array arguments - * @return mixed - * @param string $method - * @param mixed $arguments + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * // Setup a many-to-many relation to Parts through RobotsParts + * $this->hasManyToMany( + * "id", + * RobotsParts::class, + * "robots_id", + * "parts_id", + * Parts::class, + * "id", + * ); + * } + * } + * ``` + * + * @param string|array $fields + * @param string $intermediateModel + * @param string|array $intermediateFields + * @param string|array $intermediateReferencedFields + * @param string $referenceModel + * @param string|array $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\Relation */ - public static function __callStatic($method, $arguments) {} + protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Magic method to assign values to the the model + * Setup a 1-1 relation between two models * - * @param string $property - * @param mixed $value + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasOne( + * "id", + * RobotsDescription::class, + * "robots_id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function __set($property, $value) {} + protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Check for, and attempt to use, possible setter. + * Sets if the model must keep the original record snapshot in memory * - * @param string $property - * @param mixed $value - * @return string + * ```php + * use Phalcon\Mvc\Model; + * + * class Robots extends Model + * { + * public function initialize() + * { + * $this->keepSnapshots(true); + * } + * } + * ``` + * + * @param bool $keepSnapshot */ - protected final function _possibleSetter($property, $value) {} + protected function keepSnapshots(bool $keepSnapshot) {} /** - * Magic method to get related records using the relation alias as a property + * Sets schema name where the mapped table is located * - * @param string $property - * @return \Phalcon\Mvc\Model\Resultset|Phalcon\Mvc\Model + * @param string $schema + * @return \Phalcon\Mvc\ModelInterface */ - public function __get($property) {} + final protected function setSchema(string $schema): ModelInterface {} /** - * Magic method to check if a property is a valid relation + * Sets the table name to which model should be mapped * - * @param string $property - * @return bool + * @param string $source + * @return \Phalcon\Mvc\ModelInterface */ - public function __isset($property) {} + final protected function setSource(string $source): ModelInterface {} /** - * Serializes the object ignoring connections, services, related objects or static properties + * Sets a list of attributes that must be skipped from the + * generated INSERT/UPDATE statement * - * @return string + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributes( + * [ + * "price", + * ] + * ); + * } + * } + * ``` + * + * @param array $attributes */ - public function serialize() {} + protected function skipAttributes(array $attributes) {} /** - * Unserializes the object from a serialized string + * Sets a list of attributes that must be skipped from the + * generated INSERT statement * - * @param mixed $data + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnCreate( + * [ + * "created_at", + * ] + * ); + * } + * } + * ``` + * + * @param array $attributes */ - public function unserialize($data) {} + protected function skipAttributesOnCreate(array $attributes) {} /** - * Returns a simple representation of the object that can be used with var_dump + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * - * var_dump( - * $robot->dump() - * ); - * + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnUpdate( + * [ + * "modified_in", + * ] + * ); + * } + * } + * ``` * - * @return array + * @param array $attributes */ - public function dump() {} + protected function skipAttributesOnUpdate(array $attributes) {} /** - * Returns the instance as an array representation + * Sets if a model must use dynamic update instead of the all-field update * - * - * print_r( - * $robot->toArray() - * ); - * + * ```php + * use Phalcon\Mvc\Model; * - * @param array $columns - * @return array + * class Robots extends Model + * { + * public function initialize() + * { + * $this->useDynamicUpdate(true); + * } + * } + * ``` + * + * @param bool $dynamicUpdate */ - public function toArray($columns = null) {} + protected function useDynamicUpdate(bool $dynamicUpdate) {} /** - * Serializes the object for json_encode + * Executes validators on every validation call * - * - * echo json_encode($robot); - * + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; * - * @return array + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->add( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * ``` + * + * @param \Phalcon\Validation\ValidationInterface $validator + * @return bool */ - public function jsonSerialize() {} + protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} /** - * Enables/disables options in the ORM + * Check whether validation process has generated any messages * - * @param array $options + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; + * + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->validate( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * ``` + * + * @return bool */ - public static function setup(array $options) {} + public function validationHasFailed(): bool {} /** - * Reset a model instance data + * Attempts to find key case-insensitively + * + * @param mixed $columnMap + * @param mixed $key + * @return string */ - public function reset() {} + private static function caseInsensitiveColumnMap($columnMap, $key): string {} } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index 5ded0692..b65f6f6d 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -11,313 +11,321 @@ interface ModelInterface { /** - * Sets a transaction related to the Model instance + * Appends a customized message on the validation process * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param \Phalcon\Messages\MessageInterface $message * @return \Phalcon\Mvc\ModelInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface; /** - * Returns table name mapped in the model + * Assigns values to a model from an array * - * @return string + * @param array $data + * @param mixed $dataColumnMap + * @param mixed $whiteList + * @param array $columnMap + * @return \Phalcon\Mvc\ModelInterface */ - public function getSource(); + public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface; /** - * Returns schema name where table mapped is located + * Allows to calculate the average value on a column matching the specified + * conditions * - * @return string + * @param array $parameters + * @return double */ - public function getSchema(); + public static function average($parameters = null): float; /** - * Sets both read/write connection services + * Assigns values to a model from an array returning a new model * - * @param string $connectionService + * @param \Phalcon\Mvc\ModelInterface $base + * @param array $data + * @param int $dirtyState + * @return \Phalcon\Mvc\ModelInterface */ - public function setConnectionService($connectionService); + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface; /** - * Sets the DependencyInjection connection service used to write data + * Assigns values to a model from an array returning a new model * - * @param string $connectionService + * @param \Phalcon\Mvc\Model $base + * @param array $data + * @param array $columnMap + * @param int $dirtyState + * @param bool $keepSnapshots + * @return \Phalcon\Mvc\ModelInterface */ - public function setWriteConnectionService($connectionService); + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; /** - * Sets the DependencyInjection connection service used to read data + * Returns an hydrated result based on the data and the column map * - * @param string $connectionService + * @param array $data + * @param array $columnMap + * @param int $hydrationMode */ - public function setReadConnectionService($connectionService); + public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode); /** - * Returns DependencyInjection connection service used to read data + * Allows to count how many records match the specified conditions * - * @return string + * @param array $parameters + * @return int */ - public function getReadConnectionService(); + public static function count($parameters = null): int; /** - * Returns DependencyInjection connection service used to write data + * Inserts a model instance. If the instance already exists in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. * - * @return string + * @return bool */ - public function getWriteConnectionService(); + public function create(): bool; /** - * Gets internal database connection + * Deletes a model instance. Returning true on success or false otherwise. * - * @return \Phalcon\Db\AdapterInterface + * @return bool */ - public function getReadConnection(); + public function delete(): bool; /** - * Gets internal database connection + * Allows to query a set of records that match the specified conditions * - * @return \Phalcon\Db\AdapterInterface + * @param mixed $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getWriteConnection(); + public static function find($parameters = null): ResultsetInterface; /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Allows to query the first record that match the specified conditions * - * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @param array $parameters + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState($dirtyState); + public static function findFirst($parameters = null); /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @return int + * @param string $eventName + * @return bool */ - public function getDirtyState(); + public function fireEvent(string $eventName): bool; /** - * Assigns values to a model from an array + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified. This method stops if one of the callbacks/listeners + * returns bool false * - * @param array $data - * @param mixed $dataColumnMap - * @param mixed $whiteList - * @param \Phalcon\Mvc\Model $object - * @param array $columnMap - * @return \Phalcon\Mvc\Model + * @param string $eventName + * @return bool */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null); + public function fireEventCancel(string $eventName): bool; /** - * Assigns values to a model from an array returning a new model + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param \Phalcon\Mvc\Model $base - * @param array $data - * @param array $columnMap - * @param int $dirtyState - * @param boolean $keepSnapshots - * @return \Phalcon\Mvc\Model + * @return int */ - public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null); + public function getDirtyState(): int; /** - * Assigns values to a model from an array returning a new model + * Returns array of validation messages * - * @param \Phalcon\Mvc\ModelInterface $base - * @param array $data - * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, $dirtyState = 0); + public function getMessages(): array; /** - * Returns an hydrated result based on the data and the column map + * Returns the models meta-data service related to the entity instance. * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode + * @return \Phalcon\Mvc\Model\MetaDataInterface */ - public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode); + public function getModelsMetaData(): MetaDataInterface; /** - * Allows to query a set of records that match the specified conditions + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * @param mixed $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return int */ - public static function find($parameters = null); + public function getOperationMade(): int; /** - * Allows to query the first record that match the specified conditions + * Gets internal database connection * - * @param array $parameters - * @return static + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public static function findFirst($parameters = null); + public function getReadConnection(): AdapterInterface; /** - * Create a criteria for a specific model + * Returns DependencyInjection connection service used to read data * - * @param \Phalcon\DiInterface $dependencyInjector - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return string */ - public static function query(\Phalcon\DiInterface $dependencyInjector = null); + public function getReadConnectionService(): string; /** - * Allows to count how many records match the specified conditions + * Returns related records based on defined relations * - * @param array $parameters - * @return int + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ - public static function count($parameters = null); + public function getRelated(string $alias, $arguments = null); /** - * Allows to calculate a sum on a column that match the specified conditions + * Returns schema name where table mapped is located * - * @param array $parameters - * @return double + * @return string */ - public static function sum($parameters = null); + public function getSchema(): string; /** - * Allows to get the maximum value of a column that match the specified conditions + * Returns table name mapped in the model * - * @param array $parameters - * @return mixed + * @return string */ - public static function maximum($parameters = null); + public function getSource(): string; /** - * Allows to get the minimum value of a column that match the specified conditions + * Gets internal database connection * - * @param array $parameters - * @return mixed + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public static function minimum($parameters = null); + public function getWriteConnection(): AdapterInterface; /** - * Allows to calculate the average value on a column matching the specified conditions + * Returns DependencyInjection connection service used to write data * - * @param array $parameters - * @return double + * @return string */ - public static function average($parameters = null); + public function getWriteConnectionService(): string; /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Allows to get the maximum value of a column that match the specified + * conditions * - * @param string $eventName - * @return boolean + * @param array $parameters + * @return mixed */ - public function fireEvent($eventName); + public static function maximum($parameters = null); /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Allows to get the minimum value of a column that match the specified + * conditions * - * @param string $eventName - * @return boolean + * @param array $parameters + * @return mixed */ - public function fireEventCancel($eventName); + public static function minimum($parameters = null); /** - * Appends a customized message on the validation process + * Create a criteria for a specific model * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); + public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface; /** - * Check whether validation process has generated any messages + * Refreshes the model attributes re-querying the record from the database * - * @return boolean + * @return \Phalcon\Mvc\ModelInterface */ - public function validationHasFailed(); + public function refresh(): ModelInterface; /** - * Returns array of validation messages + * Inserts or updates a model instance. Returning true on success or false + * otherwise. * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return bool */ - public function getMessages(); + public function save(): bool; /** - * Inserts or updates a model instance. Returning true on success or false otherwise. + * Sets both read/write connection services * - * @param array $data - * @param array $whiteList - * @return boolean + * @param string $connectionService */ - public function save($data = null, $whiteList = null); + public function setConnectionService(string $connectionService); /** - * Inserts a model instance. If the instance already exists in the persistence it will throw an exception - * Returning true on success or false otherwise. + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @param array $data - * @param array $whiteList - * @return boolean + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function create($data = null, $whiteList = null); + public function setDirtyState(int $dirtyState); /** - * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception - * Returning true on success or false otherwise. + * Sets the DependencyInjection connection service used to read data * - * @param array $data - * @param array $whiteList - * @return boolean + * @param string $connectionService */ - public function update($data = null, $whiteList = null); + public function setReadConnectionService(string $connectionService); /** - * Deletes a model instance. Returning true on success or false otherwise. + * Sets the record's snapshot data. This method is used internally to set + * snapshot data when the model was set up to keep snapshot data * - * @return boolean + * @param array $data + * @param array $columnMap */ - public function delete(); + public function setSnapshotData(array $data, $columnMap = null); /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Sets a transaction related to the Model instance * - * @return int + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return \Phalcon\Mvc\ModelInterface */ - public function getOperationMade(); + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface; /** - * Refreshes the model attributes re-querying the record from the database + * Sets the DependencyInjection connection service used to write data + * + * @param string $connectionService */ - public function refresh(); + public function setWriteConnectionService(string $connectionService); /** * Skips the current operation forcing a success state * * @param bool $skip */ - public function skipOperation($skip); + public function skipOperation(bool $skip); /** - * Returns related records based on defined relations + * Allows to calculate a sum on a column that match the specified conditions * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param array $parameters + * @return double */ - public function getRelated($alias, $arguments = null); + public static function sum($parameters = null): float; /** - * Sets the record's snapshot data. - * This method is used internally to set snapshot data when the model was set up to keep snapshot data + * Check whether validation process has generated any messages * - * @param array $data - * @param array $columnMap + * @return bool */ - public function setSnapshotData(array $data, $columnMap = null); + public function validationHasFailed(): bool; /** - * Reset a model instance data + * Updates a model instance. If the instance doesn't exist in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. + * + * @return bool */ - public function reset(); + public function update(): bool; } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index a1336e4e..fe59a300 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -13,15 +13,15 @@ interface ModuleDefinitionInterface /** * Registers an autoloader related to the module * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function registerAutoloaders(\Phalcon\DiInterface $dependencyInjector = null); + public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); /** * Registers services related to the module * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function registerServices(\Phalcon\DiInterface $dependencyInjector); + public function registerServices(\Phalcon\Di\DiInterface $container); } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index 69a4e1af..852feabd 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -6,11 +6,11 @@ * Phalcon\Mvc\Router * * Phalcon\Mvc\Router is the standard framework router. Routing is the - * process of taking a URI endpoint (that part of the URI which comes after the base URL) and - * decomposing it into parameters to determine which module, controller, and - * action of that controller should receive the request + * process of taking a URI endpoint (that part of the URI which comes after the + * base URL) and decomposing it into parameters to determine which module, + * controller, and action of that controller should receive the request * - * + * ```php * use Phalcon\Mvc\Router; * * $router = new Router(); @@ -23,87 +23,83 @@ * ] * ); * - * $router->handle(); + * $router->handle( + * "/documentation/1/examples.html" + * ); * * echo $router->getControllerName(); - * + * ``` */ class Router implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { - const URI_SOURCE_GET_URL = 0; - - - const URI_SOURCE_SERVER_REQUEST_URI = 1; - - const POSITION_FIRST = 0; const POSITION_LAST = 1; - protected $_dependencyInjector; + protected $action = null; - protected $_eventsManager; + protected $container; - protected $_uriSource; + protected $controller = null; - protected $_namespace = null; + protected $defaultAction; - protected $_module = null; + protected $defaultController; - protected $_controller = null; + protected $defaultModule; - protected $_action = null; + protected $defaultNamespace; - protected $_params = array(); + protected $defaultParams = array(); - protected $_routes; + protected $eventsManager; - protected $_matchedRoute; + protected $keyRouteNames = array(); - protected $_matches; + protected $keyRouteIds = array(); - protected $_wasMatched = false; + protected $matchedRoute; - protected $_defaultNamespace; + protected $matches; - protected $_defaultModule; + protected $module = null; - protected $_defaultController; + protected $namespaceName = null; - protected $_defaultAction; + protected $notFoundPaths; - protected $_defaultParams = array(); + protected $params = array(); - protected $_removeExtraSlashes; + protected $removeExtraSlashes; - protected $_notFoundPaths; + protected $routes; - protected $_keyRouteNames = array(); + protected $uriSource; - protected $_keyRouteIds = array(); + protected $wasMatched = false; @@ -127,141 +123,143 @@ public function setKeyRouteIds($keyRouteIds) {} * * @param bool $defaultRoutes */ - public function __construct($defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) {} /** - * Sets the dependency injector + * Adds a route to the router without any HTTP constraint * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector + * ```php + * use Phalcon\Mvc\Router; * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Sets the events manager + * $router->add("/about", "About::index"); * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Returns the internal event manager + * $router->add( + * "/about", + * "About::index", + * ["GET", "POST"] + * ); * - * @return \Phalcon\Events\ManagerInterface + * $router->add( + * "/about", + * "About::index", + * ["GET", "POST"], + * Router::POSITION_FIRST + * ); + * ``` + * + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getEventsManager() {} + public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Get rewrite info. This info is read from $_GET["_url"]. This returns '/' if the rewrite information cannot be read + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRewriteUri() {} + public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the URI source. One of the URI_SOURCE_ constants - * - * - * $router->setUriSource( - * Router::URI_SOURCE_SERVER_REQUEST_URI - * ); - * + * Adds a route to the router that only match if the HTTP method is DELETE * - * @param mixed $uriSource - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setUriSource($uriSource) {} + public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Set whether router must remove the extra slashes in the handled routes + * Adds a route to the router that only match if the HTTP method is GET * - * @param bool $remove - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function removeExtraSlashes($remove) {} + public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the name of the default namespace + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param string $namespaceName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultNamespace($namespaceName) {} + public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the name of the default module + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string $moduleName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultModule($moduleName) {} + public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the default controller name + * Adds a route to the router that only match if the HTTP method is PATCH * - * @param string $controllerName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultController($controllerName) {} + public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the default action name + * Adds a route to the router that only match if the HTTP method is POST * - * @param string $actionName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultAction($actionName) {} + public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets an array of default paths. If a route is missing a path the router will use the defined here - * This method must not be used to set a 404 route + * Adds a route to the router that only match if the HTTP method is PURGE + * (Squid and Varnish support) * - * - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * - * - * @param array $defaults - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaults(array $defaults) {} + public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Returns an array of default parameters + * Adds a route to the router that only match if the HTTP method is PUT * - * @return array + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getDefaults() {} + public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Handles routing information received from the rewrite engine - * - * - * // Read the info from the rewrite engine - * $router->handle(); - * - * // Manually passing an URL - * $router->handle("/posts/edit/1"); - * + * Adds a route to the router that only match if the HTTP method is TRACE * - * @param string $uri + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function handle($uri = null) {} + public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** * Attach Route object to the routes stack. * - * + * ```php * use Phalcon\Mvc\Router; * use Phalcon\Mvc\Router\Route; * @@ -275,239 +273,226 @@ public function handle($uri = null) {} * new CustomRoute("/about", "About::index", ["GET", "HEAD"]), * Router::POSITION_FIRST * ); - * + * ``` * - * @todo Add to the interface for 4.0.0 * @param \Phalcon\Mvc\Router\RouteInterface $route * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST) {} + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface {} /** - * Adds a route to the router without any HTTP constraint - * - * - * use Phalcon\Mvc\Router; - * - * $router->add("/about", "About::index"); - * $router->add("/about", "About::index", ["GET", "POST"]); - * $router->add("/about", "About::index", ["GET", "POST"], Router::POSITION_FIRST); - * + * Removes all the pre-defined routes + */ + public function clear() {} + + /** + * Returns the internal dependency injector * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Di\DiInterface */ - public function add($pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST) {} + public function getDI(): DiInterface {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Returns the internal event manager * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Events\ManagerInterface */ - public function addGet($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getEventsManager(): ManagerInterface {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Returns the processed action name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addPost($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getActionName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Returns the processed controller name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addPut($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getControllerName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Returns the route that matches the handled URI * - * @param string $pattern - * @param mixed $paths - * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getMatchedRoute(): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the sub expressions in the regular expression matched * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array */ - public function addDelete($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getMatches(): array {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the processed module name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addOptions($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getModuleName(): string {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the processed namespace name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addHead($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getNamespaceName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) + * Returns the processed parameters * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array */ - public function addPurge($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getParams(): array {} /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Returns a route object by its id * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function addTrace($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getRouteById($id) {} /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns a route object by its name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function addConnect($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getRouteByName(string $name) {} /** - * Mounts a group of routes in the router + * Returns all the routes defined in the router * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group) {} + public function getRoutes(): array {} /** - * Set a group of paths to be returned when none of the defined routes are matched + * Handles routing information received from the rewrite engine * - * @param mixed $paths - * @return RouterInterface + * ```php + * // Passing a URL + * $router->handle("/posts/edit/1"); + * ``` + * + * @param string $uri */ - public function notFound($paths) {} + public function handle(string $uri) {} /** - * Removes all the pre-defined routes + * Returns whether controller name should not be mangled + * + * @return bool */ - public function clear() {} + public function isExactControllerName(): bool {} /** - * Returns the processed namespace name + * Mounts a group of routes in the router * - * @return string + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function getNamespaceName() {} + public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface {} /** - * Returns the processed module name + * Set a group of paths to be returned when none of the defined routes are + * matched * - * @return string + * @param mixed $paths + * @return RouterInterface */ - public function getModuleName() {} + public function notFound($paths): RouterInterface {} /** - * Returns the processed controller name + * Set whether router must remove the extra slashes in the handled routes * - * @return string + * @param bool $remove + * @return RouterInterface */ - public function getControllerName() {} + public function removeExtraSlashes(bool $remove): RouterInterface {} /** - * Returns the processed action name + * Sets the default action name * - * @return string + * @param string $actionName + * @return RouterInterface */ - public function getActionName() {} + public function setDefaultAction(string $actionName): RouterInterface {} /** - * Returns the processed parameters + * Sets the default controller name * - * @return array + * @param string $controllerName + * @return RouterInterface */ - public function getParams() {} + public function setDefaultController(string $controllerName): RouterInterface {} /** - * Returns the route that matches the handled URI + * Sets the name of the default module * - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName + * @return RouterInterface */ - public function getMatchedRoute() {} + public function setDefaultModule(string $moduleName): RouterInterface {} /** - * Returns the sub expressions in the regular expression matched + * Sets the name of the default namespace * - * @return array + * @param string $namespaceName + * @return RouterInterface */ - public function getMatches() {} + public function setDefaultNamespace(string $namespaceName): RouterInterface {} /** - * Checks if the router matches any of the defined routes + * Sets an array of default paths. If a route is missing a path the router + * will use the defined here. This method must not be used to set a 404 + * route * - * @return bool + * ```php + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * ``` + * + * @param array $defaults + * @return RouterInterface */ - public function wasMatched() {} + public function setDefaults(array $defaults): RouterInterface {} /** - * Returns all the routes defined in the router + * Returns an array of default parameters * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @return array */ - public function getRoutes() {} + public function getDefaults(): array {} /** - * Returns a route object by its id + * Sets the dependency injector * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getRouteById($id) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns a route object by its name + * Sets the events manager * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getRouteByName($name) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns whether controller name should not be mangled + * Checks if the router matches any of the defined routes * * @return bool */ - public function isExactControllerName() {} + public function wasMatched(): bool {} } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index 6f7adef2..f78d3286 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -3,84 +3,74 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\RouterInterface - * * Interface for Phalcon\Mvc\Router */ interface RouterInterface { /** - * Sets the name of the default module - * - * @param string $moduleName - */ - public function setDefaultModule($moduleName); - - /** - * Sets the default controller name - * - * @param string $controllerName - */ - public function setDefaultController($controllerName); - - /** - * Sets the default action name + * Adds a route to the router on any HTTP method * - * @param string $actionName + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultAction($actionName); + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; /** - * Sets an array of default paths + * Attach Route object to the routes stack. * - * @param array $defaults + * @param \Phalcon\Mvc\Router\RouteInterface $route + * @param mixed $position + * @return RouterInterface */ - public function setDefaults(array $defaults); + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; /** - * Handles routing information received from the rewrite engine + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $uri + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function handle($uri = null); + public function addConnect(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router on any HTTP method + * Adds a route to the router that only match if the HTTP method is DELETE * * @param string $pattern * @param mixed $paths - * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null); + public function addDelete(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is HEAD * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet($pattern, $paths = null); + public function addHead(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is POST + * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost($pattern, $paths = null); + public function addGet(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PUT + * Add a route to the router that only match if the HTTP method is OPTIONS * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPut($pattern, $paths = null); + public function addOptions(string $pattern, $paths = null): RouteInterface; /** * Adds a route to the router that only match if the HTTP method is PATCH @@ -89,152 +79,170 @@ public function addPut($pattern, $paths = null); * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch($pattern, $paths = null); + public function addPatch(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Adds a route to the router that only match if the HTTP method is POST * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addDelete($pattern, $paths = null); + public function addPost(string $pattern, $paths = null): RouteInterface; /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Adds a route to the router that only match if the HTTP method is PURGE + * (Squid and Varnish support) * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addOptions($pattern, $paths = null); + public function addPurge(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addHead($pattern, $paths = null); + public function addPut(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPurge($pattern, $paths = null); + public function addTrace(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Removes all the defined routes + */ + public function clear(); + + /** + * Returns processed action name * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addTrace($pattern, $paths = null); + public function getActionName(): string; /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns processed controller name * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addConnect($pattern, $paths = null); + public function getControllerName(): string; /** - * Mounts a group of routes in the router + * Returns the route that matches the handled URI * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group); + public function getMatchedRoute(): RouteInterface; /** - * Removes all the defined routes + * Return the sub expressions in the regular expression matched + * + * @return array */ - public function clear(); + public function getMatches(): array; /** * Returns processed module name * * @return string */ - public function getModuleName(); + public function getModuleName(): string; /** * Returns processed namespace name * * @return string */ - public function getNamespaceName(); + public function getNamespaceName(): string; /** - * Returns processed controller name + * Returns processed extra params * - * @return string + * @return array */ - public function getControllerName(); + public function getParams(): array; /** - * Returns processed action name + * Return all the routes defined in the router * - * @return string + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function getActionName(); + public function getRoutes(): array; /** - * Returns processed extra params + * Returns a route object by its id * - * @return array + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getParams(); + public function getRouteById($id); /** - * Returns the route that matches the handled URI + * Returns a route object by its name * - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getMatchedRoute(); + public function getRouteByName(string $name); /** - * Return the sub expressions in the regular expression matched + * Handles routing information received from the rewrite engine * - * @return array + * @param string $uri */ - public function getMatches(); + public function handle(string $uri); /** - * Check if the router matches any of the defined routes + * Mounts a group of routes in the router * - * @return bool + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function wasMatched(); + public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface; /** - * Return all the routes defined in the router + * Sets the default action name * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @param string $actionName */ - public function getRoutes(); + public function setDefaultAction(string $actionName); /** - * Returns a route object by its id + * Sets the default controller name * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $controllerName */ - public function getRouteById($id); + public function setDefaultController(string $controllerName); /** - * Returns a route object by its name + * Sets the name of the default module * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName + */ + public function setDefaultModule(string $moduleName); + + /** + * Sets an array of default paths + * + * @param array $defaults + */ + public function setDefaults(array $defaults); + + /** + * Check if the router matches any of the defined routes + * + * @return bool */ - public function getRouteByName($name); + public function wasMatched(): bool; } diff --git a/src/Phalcon/mvc/Url.php b/src/Phalcon/mvc/Url.php deleted file mode 100644 index 92b6e69a..00000000 --- a/src/Phalcon/mvc/Url.php +++ /dev/null @@ -1,184 +0,0 @@ - - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2012", - * ] - * ); - * - */ -class Url implements \Phalcon\Mvc\UrlInterface, \Phalcon\Di\InjectionAwareInterface -{ - - protected $_dependencyInjector; - - - protected $_baseUri = null; - - - protected $_staticBaseUri = null; - - - protected $_basePath = null; - - - protected $_router; - - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Sets a prefix for all the URIs to be generated - * - * - * $url->setBaseUri("/invo/"); - * - * $url->setBaseUri("/invo/index.php/"); - * - * - * @param string $baseUri - * @return Url - */ - public function setBaseUri($baseUri) {} - - /** - * Sets a prefix for all static URLs generated - * - * - * $url->setStaticBaseUri("/invo/"); - * - * - * @param string $staticBaseUri - * @return Url - */ - public function setStaticBaseUri($staticBaseUri) {} - - /** - * Returns the prefix for all the generated urls. By default / - * - * @return string - */ - public function getBaseUri() {} - - /** - * Returns the prefix for all the generated static urls. By default / - * - * @return string - */ - public function getStaticBaseUri() {} - - /** - * Sets a base path for all the generated paths - * - * - * $url->setBasePath("/var/www/htdocs/"); - * - * - * @param string $basePath - * @return Url - */ - public function setBasePath($basePath) {} - - /** - * Returns the base path - * - * @return string - */ - public function getBasePath() {} - - /** - * Generates a URL - * - * - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2015", - * ] - * ); - * - * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) - * echo $url->get( - * "show/products", - * [ - * "id" => 1, - * "name" => "Carrots", - * ] - * ); - * - * // Generate an absolute URL by setting the third parameter as false. - * echo $url->get( - * "https://phalconphp.com/", - * null, - * false - * ); - * - * - * @param mixed $uri - * @param mixed $args - * @param mixed $local - * @param mixed $baseUri - * @return string - */ - public function get($uri = null, $args = null, $local = null, $baseUri = null) {} - - /** - * Generates a URL for a static resource - * - * - * // Generate a URL for a static resource - * echo $url->getStatic("img/logo.png"); - * - * // Generate a URL for a static predefined route - * echo $url->getStatic( - * [ - * "for" => "logo-cdn", - * ] - * ); - * - * - * @param mixed $uri - * @return string - */ - public function getStatic($uri = null) {} - - /** - * Generates a local path - * - * @param string $path - * @return string - */ - public function path($path = null) {} - -} diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index f55dcfd4..e8270a85 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\View * - * Phalcon\Mvc\View is a class for working with the "view" portion of the model-view-controller pattern. - * That is, it exists to help keep the view script separate from the model and controller scripts. - * It provides a system of helpers, output filters, and variable escaping. + * Phalcon\Mvc\View is a class for working with the "view" portion of the + * model-view-controller pattern. That is, it exists to help keep the view + * script separate from the model and controller scripts. It provides a system + * of helpers, output filters, and variable escaping. * - * + * ```php * use Phalcon\Mvc\View; * * $view = new View(); @@ -25,19 +26,19 @@ * * // Printing views output * echo $view->getContent(); - * + * ``` */ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface { /** - * Render Level: To the main layout + * Render Level: To the action view */ - const LEVEL_MAIN_LAYOUT = 5; + const LEVEL_ACTION_VIEW = 1; /** - * Render Level: Render to the templates "after" + * Render Level: To the templates "before" */ - const LEVEL_AFTER_TEMPLATE = 4; + const LEVEL_BEFORE_TEMPLATE = 2; /** * Render Level: To the controller layout @@ -45,14 +46,9 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_LAYOUT = 3; /** - * Render Level: To the templates "before" - */ - const LEVEL_BEFORE_TEMPLATE = 2; - - /** - * Render Level: To the action view + * Render Level: To the main layout */ - const LEVEL_ACTION_VIEW = 1; + const LEVEL_MAIN_LAYOUT = 5; /** * Render Level: No render any view @@ -60,99 +56,86 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_NO_RENDER = 0; /** - * Cache Mode + * Render Level: Render to the templates "after" */ - const CACHE_MODE_NONE = 0; - + const LEVEL_AFTER_TEMPLATE = 4; - const CACHE_MODE_INVERSE = 1; + protected $actionName; - protected $_options; + protected $activeRenderPaths; - protected $_basePath = ''; + protected $basePath = ''; - protected $_content = ''; + protected $content = ''; - protected $_renderLevel = 5; + protected $controllerName; - protected $_currentRenderLevel = 0; + protected $currentRenderLevel = 0; - protected $_disabledLevels; + protected $disabled = false; - protected $_viewParams = array(); + protected $disabledLevels; - protected $_layout; + protected $engines = false; - protected $_layoutsDir = ''; + protected $layout; - protected $_partialsDir = ''; + protected $layoutsDir = ''; - protected $_viewsDirs = array(); + protected $mainView = 'index'; - protected $_templatesBefore = array(); + protected $options = array(); - protected $_templatesAfter = array(); + protected $params; - protected $_engines = false; - /** - * @var array - */ - protected $_registeredEngines; + protected $pickView; - protected $_mainView = 'index'; + protected $partialsDir = ''; - protected $_controllerName; + protected $registeredEngines = array(); - protected $_actionName; + protected $renderLevel = 5; - protected $_params; + protected $templatesAfter = array(); - protected $_pickView; + protected $templatesBefore = array(); - protected $_cache; + protected $viewsDirs = array(); - protected $_cacheLevel = 0; + protected $viewParams = array(); - protected $_activeRenderPaths; + public function getCurrentRenderLevel() {} - protected $_disabled = false; + public function getRegisteredEngines() {} public function getRenderLevel() {} - - public function getCurrentRenderLevel() {} - - /** - * @return array - */ - public function getRegisteredEngines() {} - /** * Phalcon\Mvc\View constructor * @@ -161,563 +144,542 @@ public function getRegisteredEngines() {} public function __construct(array $options = array()) {} /** - * Checks if a path is absolute or not + * Magic method to retrieve a variable passed to the view * - * @param string $path + * ```php + * echo $this->view->products; + * ``` + * + * @param string $key + * @return mixed|null */ - protected final function _isAbsolutePath($path) {} + public function __get(string $key): ? {} /** - * Sets the views directory. Depending of your platform, - * always add a trailing slash or backslash + * Magic method to retrieve if a variable is set in the view * - * @param mixed $viewsDir - * @return View + * ```php + * echo isset($this->view->products); + * ``` + * + * @param string $key + * @return bool */ - public function setViewsDir($viewsDir) {} + public function __isset(string $key): bool {} /** - * Gets views directory + * Magic method to pass variables to the views * - * @return string|array + * ```php + * $this->view->products = $products; + * ``` + * + * @param string $key + * @param mixed $value */ - public function getViewsDir() {} + public function __set(string $key, $value) {} /** - * Sets the layouts sub-directory. Must be a directory under the views directory. - * Depending of your platform, always add a trailing slash or backslash - * - * - * $view->setLayoutsDir("../common/layouts/"); - * + * Resets any template before layouts * - * @param string $layoutsDir * @return View */ - public function setLayoutsDir($layoutsDir) {} + public function cleanTemplateAfter(): View {} /** - * Gets the current layouts sub-directory + * Resets any "template before" layouts * - * @return string + * @return View */ - public function getLayoutsDir() {} + public function cleanTemplateBefore(): View {} /** - * Sets a partials sub-directory. Must be a directory under the views directory. - * Depending of your platform, always add a trailing slash or backslash + * Disables a specific level of rendering * - * - * $view->setPartialsDir("../common/partials/"); - * + * ```php + * // Render all levels except ACTION level + * $this->view->disableLevel( + * View::LEVEL_ACTION_VIEW + * ); + * ``` * - * @param string $partialsDir - * @return View + * @param mixed $level + * @return \Phalcon\Mvc\ViewInterface */ - public function setPartialsDir($partialsDir) {} + public function disableLevel($level): ViewInterface {} /** - * Gets the current partials sub-directory + * Disables the auto-rendering process * - * @return string + * @return View */ - public function getPartialsDir() {} + public function disable(): View {} /** - * Sets base path. Depending of your platform, always add a trailing slash or backslash - * - * - * $view->setBasePath(__DIR__ . "/"); - * + * Enables the auto-rendering process * - * @param string $basePath * @return View */ - public function setBasePath($basePath) {} + public function enable(): View {} /** - * Gets base path + * Checks whether view exists * - * @return string + * @param string $view + * @return bool */ - public function getBasePath() {} + public function exists(string $view): bool {} /** - * Sets the render level for the view - * - * - * // Render the view related to the controller only - * $this->view->setRenderLevel( - * View::LEVEL_LAYOUT - * ); - * + * Finishes the render process by stopping the output buffering * - * @param int $level * @return View */ - public function setRenderLevel($level) {} + public function finish(): View {} /** - * Disables a specific level of rendering - * - * - * // Render all levels except ACTION level - * $this->view->disableLevel( - * View::LEVEL_ACTION_VIEW - * ); - * + * Gets the name of the action rendered * - * @param mixed $level - * @return View + * @return string */ - public function disableLevel($level) {} + public function getActionName(): string {} /** - * Sets default view name. Must be a file without extension in the views directory - * - * - * // Renders as main view views-dir/base.phtml - * $this->view->setMainView("base"); - * + * Returns the path (or paths) of the views that are currently rendered * - * @param string $viewPath - * @return View + * @return string|array */ - public function setMainView($viewPath) {} + public function getActiveRenderPath() {} /** - * Returns the name of the main view + * Gets base path * * @return string */ - public function getMainView() {} + public function getBasePath(): string {} /** - * Change the layout to be used instead of using the name of the latest controller name + * Returns output from another view stage * - * - * $this->view->setLayout("main"); - * + * @return string + */ + public function getContent(): string {} + + /** + * Gets the name of the controller rendered * - * @param string $layout - * @return View + * @return string */ - public function setLayout($layout) {} + public function getControllerName(): string {} /** * Returns the name of the main view * * @return string */ - public function getLayout() {} + public function getLayout(): string {} /** - * Sets a template before the controller layout + * Gets the current layouts sub-directory * - * @param mixed $templateBefore - * @return View + * @return string */ - public function setTemplateBefore($templateBefore) {} + public function getLayoutsDir(): string {} /** - * Resets any "template before" layouts + * Returns the name of the main view * - * @return View + * @return string */ - public function cleanTemplateBefore() {} + public function getMainView(): string {} /** - * Sets a "template after" controller layout + * Returns parameters to views * - * @param mixed $templateAfter - * @return View + * @return array */ - public function setTemplateAfter($templateAfter) {} + public function getParamsToView(): array {} /** - * Resets any template before layouts + * Renders a partial view * - * @return View + * ```php + * // Retrieve the contents of a partial + * echo $this->getPartial("shared/footer"); + * ``` + * + * ```php + * // Retrieve the contents of a partial with arguments + * echo $this->getPartial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * ``` + * + * @param string $partialPath + * @param mixed $params + * @return string */ - public function cleanTemplateAfter() {} + public function getPartial(string $partialPath, $params = null): string {} /** - * Adds parameters to views (alias of setVar) - * - * - * $this->view->setParamToView("products", $products); - * + * Gets the current partials sub-directory * - * @param string $key - * @param mixed $value - * @return View + * @return string */ - public function setParamToView($key, $value) {} + public function getPartialsDir(): string {} /** - * Set all the render params + * Perform the automatic rendering returning the output as a string * - * - * $this->view->setVars( + * ```php + * $template = $this->view->getRender( + * "products", + * "show", * [ * "products" => $products, * ] * ); - * + * ``` * + * @param string $controllerName + * @param string $actionName * @param array $params - * @param bool $merge - * @return View + * @param mixed $configCallback + * @return string */ - public function setVars(array $params, $merge = true) {} + public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string {} /** - * Set a single view parameter - * - * - * $this->view->setVar("products", $products); - * + * Returns a parameter previously set in the view * * @param string $key - * @param mixed $value - * @return View */ - public function setVar($key, $value) {} + public function getVar(string $key) {} /** - * Returns a parameter previously set in the view + * Gets views directory * - * @param string $key + * @return string|array */ - public function getVar($key) {} + public function getViewsDir() {} /** - * Returns parameters to views + * Gets views directories * * @return array */ - public function getParamsToView() {} + protected function getViewsDirs(): array {} /** - * Gets the name of the controller rendered + * Whether automatic rendering is enabled * - * @return string + * @return bool */ - public function getControllerName() {} + public function isDisabled(): bool {} /** - * Gets the name of the action rendered + * Renders a partial view * - * @return string - */ - public function getActionName() {} - - /** - * Gets extra parameters of the action rendered + * ```php + * // Show a partial inside another view + * $this->partial("shared/footer"); + * ``` * - * @deprecated Will be removed in 4.0.0 - * @deprecated - * @return array - */ - public function getParams() {} - - /** - * Starts rendering process enabling the output buffering + * ```php + * // Show a partial inside another view with parameters + * $this->partial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * ``` * - * @return View + * @param string $partialPath + * @param mixed $params */ - public function start() {} + public function partial(string $partialPath, $params = null) {} /** - * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php + * Choose a different view to render instead of last-controller/last-action * - * @return array - */ - protected function _loadTemplateEngines() {} - - /** - * Checks whether view exists on registered extensions and render it + * ```php + * use Phalcon\Mvc\Controller; * - * @param array $engines - * @param string $viewPath - * @param boolean $silence - * @param boolean $mustClean - * @param \Phalcon\Cache\BackendInterface $cache + * class ProductsController extends Controller + * { + * public function saveAction() + * { + * // Do some save stuff... + * + * // Then show the list view + * $this->view->pick("products/list"); + * } + * } + * ``` + * + * @param mixed $renderView + * @return View */ - protected function _engineRender($engines, $viewPath, $silence, $mustClean, \Phalcon\Cache\BackendInterface $cache = null) {} + public function pick($renderView): View {} /** * Register templating engines * - * + * ```php * $this->view->registerEngines( * [ - * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", - * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", - * ".mhtml" => "MyCustomEngine", + * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, + * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, + * ".mhtml" => \MyCustomEngine::class, * ] * ); - * + * ``` * * @param array $engines * @return View */ - public function registerEngines(array $engines) {} - - /** - * Checks whether view exists - * - * @param string $view - * @return bool - */ - public function exists($view) {} + public function registerEngines(array $engines): View {} /** * Executes render process from dispatching data * - * + * ```php * // Shows recent posts view (app/views/posts/recent.phtml) * $view->start()->render("posts", "recent")->finish(); - * + * ``` * * @param string $controllerName * @param string $actionName * @param array $params * @return bool|View */ - public function render($controllerName, $actionName, $params = null) {} + public function render(string $controllerName, string $actionName, array $params = array()) {} /** - * Choose a different view to render instead of last-controller/last-action - * - * - * use Phalcon\Mvc\Controller; - * - * class ProductsController extends Controller - * { - * public function saveAction() - * { - * // Do some save stuff... - * - * // Then show the list view - * $this->view->pick("products/list"); - * } - * } - * + * Resets the view component to its factory default values * - * @param mixed $renderView * @return View */ - public function pick($renderView) {} + public function reset(): View {} /** - * Renders a partial view + * Sets base path. Depending of your platform, always add a trailing slash + * or backslash * - * - * // Retrieve the contents of a partial - * echo $this->getPartial("shared/footer"); - * + * ```php + * $view->setBasePath(__DIR__ . "/"); + * ``` * - * - * // Retrieve the contents of a partial with arguments - * echo $this->getPartial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * - * - * @param string $partialPath - * @param mixed $params - * @return string + * @param string $basePath + * @return View */ - public function getPartial($partialPath, $params = null) {} + public function setBasePath(string $basePath): View {} /** - * Renders a partial view - * - * - * // Show a partial inside another view - * $this->partial("shared/footer"); - * + * Externally sets the view content * - * - * // Show a partial inside another view with parameters - * $this->partial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * + * ```php + * $this->view->setContent("

hello

"); + * ``` * - * @param string $partialPath - * @param mixed $params + * @param string $content + * @return View */ - public function partial($partialPath, $params = null) {} + public function setContent(string $content): View {} /** - * Perform the automatic rendering returning the output as a string + * Change the layout to be used instead of using the name of the latest + * controller name * - * - * $template = $this->view->getRender( - * "products", - * "show", - * [ - * "products" => $products, - * ] - * ); - * + * ```php + * $this->view->setLayout("main"); + * ``` * - * @param string $controllerName - * @param string $actionName - * @param array $params - * @param mixed $configCallback - * @return string + * @param string $layout + * @return View */ - public function getRender($controllerName, $actionName, $params = null, $configCallback = null) {} + public function setLayout(string $layout): View {} /** - * Finishes the render process by stopping the output buffering + * Sets the layouts sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * + * ```php + * $view->setLayoutsDir("../common/layouts/"); + * ``` + * + * @param string $layoutsDir * @return View */ - public function finish() {} + public function setLayoutsDir(string $layoutsDir): View {} /** - * Create a Phalcon\Cache based on the internal cache options + * Sets default view name. Must be a file without extension in the views + * directory * - * @return \Phalcon\Cache\BackendInterface + * ```php + * // Renders as main view views-dir/base.phtml + * $this->view->setMainView("base"); + * ``` + * + * @param string $viewPath + * @return View */ - protected function _createCache() {} + public function setMainView(string $viewPath): View {} /** - * Check if the component is currently caching the output content + * Sets a partials sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * - * @return bool + * ```php + * $view->setPartialsDir("../common/partials/"); + * ``` + * + * @param string $partialsDir + * @return View */ - public function isCaching() {} + public function setPartialsDir(string $partialsDir): View {} /** - * Returns the cache instance used to cache + * Adds parameters to views (alias of setVar) + * + * ```php + * $this->view->setParamToView("products", $products); + * ``` * - * @return \Phalcon\Cache\BackendInterface + * @param string $key + * @param mixed $value + * @return View */ - public function getCache() {} + public function setParamToView(string $key, $value): View {} /** - * Cache the actual view render to certain level + * Sets the render level for the view * - * - * $this->view->cache( - * [ - * "key" => "my-key", - * "lifetime" => 86400, - * ] + * ```php + * // Render the view related to the controller only + * $this->view->setRenderLevel( + * View::LEVEL_LAYOUT * ); - * + * ``` * - * @param mixed $options - * @return View + * @param int $level + * @return \Phalcon\Mvc\ViewInterface */ - public function cache($options = true) {} + public function setRenderLevel(int $level): ViewInterface {} /** - * Externally sets the view content - * - * - * $this->view->setContent("

hello

"); - *
+ * Sets a "template after" controller layout * - * @param string $content + * @param mixed $templateAfter * @return View */ - public function setContent($content) {} + public function setTemplateAfter($templateAfter): View {} /** - * Returns cached output from another view stage + * Sets a template before the controller layout * - * @return string + * @param mixed $templateBefore + * @return View */ - public function getContent() {} + public function setTemplateBefore($templateBefore): View {} /** - * Returns the path (or paths) of the views that are currently rendered + * Set a single view parameter * - * @return string|array + * ```php + * $this->view->setVar("products", $products); + * ``` + * + * @param string $key + * @param mixed $value + * @return View */ - public function getActiveRenderPath() {} + public function setVar(string $key, $value): View {} /** - * Disables the auto-rendering process + * Set all the render params * + * ```php + * $this->view->setVars( + * [ + * "products" => $products, + * ] + * ); + * ``` + * + * @param array $params + * @param bool $merge * @return View */ - public function disable() {} + public function setVars(array $params, bool $merge = true): View {} /** - * Enables the auto-rendering process + * Sets the views directory. Depending of your platform, + * always add a trailing slash or backslash * + * @param mixed $viewsDir * @return View */ - public function enable() {} + public function setViewsDir($viewsDir): View {} /** - * Resets the view component to its factory default values + * Starts rendering process enabling the output buffering * * @return View */ - public function reset() {} + public function start(): View {} /** - * Magic method to pass variables to the views - * - * - * $this->view->products = $products; - * + * Renders the view and returns it as a string * - * @param string $key - * @param mixed $value + * @param string $controllerName + * @param string $actionName + * @param array $params + * @return string */ - public function __set($key, $value) {} + public function toString(string $controllerName, string $actionName, array $params = array()): string {} /** - * Magic method to retrieve a variable passed to the view - * - * - * echo $this->view->products; - * + * Checks whether view exists on registered extensions and render it * - * @param string $key - * @return mixed|null + * @param array $engines + * @param string $viewPath + * @param bool $silence + * @param bool $mustClean */ - public function __get($key) {} + protected function engineRender(array $engines, string $viewPath, bool $silence, bool $mustClean = true) {} /** - * Whether automatic rendering is enabled + * Checks if a path is absolute or not * - * @return bool + * @param string $path */ - public function isDisabled() {} + final protected function isAbsolutePath(string $path) {} /** - * Magic method to retrieve if a variable is set in the view - * - * - * echo isset($this->view->products); - * + * Loads registered template engines, if none is registered it will use + * Phalcon\Mvc\View\Engine\Php * - * @param string $key - * @return bool + * @return array */ - public function __isset($key) {} + protected function loadTemplateEngines(): array {} /** - * Gets views directories + * Processes the view and templates; Fires events if needed * - * @return array + * @param string $controllerName + * @param string $actionName + * @param array $params + * @param bool $fireEvents + * @return bool */ - protected function getViewsDirs() {} + public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool {} } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index d0821d61..a88fca68 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -11,76 +11,63 @@ interface ViewBaseInterface { /** - * Sets views directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $viewsDir - */ - public function setViewsDir($viewsDir); - - /** - * Gets views directory - * - * @return string|array - */ - public function getViewsDir(); - - /** - * Adds parameters to views (alias of setVar) - * - * @param string $key - * @param mixed $value - */ - public function setParamToView($key, $value); - - /** - * Adds parameters to views + * Returns cached output from another view stage * - * @param string $key - * @param mixed $value + * @return string */ - public function setVar($key, $value); + public function getContent(): string; /** * Returns parameters to views * * @return array */ - public function getParamsToView(); + public function getParamsToView(): array; /** - * Returns the cache instance used to cache + * Gets views directory * - * @return \Phalcon\Cache\BackendInterface + * @return string|array */ - public function getCache(); + public function getViewsDir(); /** - * Cache the actual view render to certain level + * Renders a partial view * - * @param mixed $options + * @param string $partialPath + * @param mixed $params */ - public function cache($options = true); + public function partial(string $partialPath, $params = null); /** * Externally sets the view content * * @param string $content */ - public function setContent($content); + public function setContent(string $content); /** - * Returns cached output from another view stage + * Adds parameters to views (alias of setVar) * - * @return string + * @param string $key + * @param mixed $value */ - public function getContent(); + public function setParamToView(string $key, $value); /** - * Renders a partial view + * Adds parameters to views * - * @param string $partialPath - * @param mixed $params + * @param string $key + * @param mixed $value + */ + public function setVar(string $key, $value); + + /** + * Sets views directory. Depending of your platform, always add a trailing + * slash or backslash + * + * @param string $viewsDir */ - public function partial($partialPath, $params = null); + public function setViewsDir(string $viewsDir); } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index fb0b5082..c27c5ca3 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -11,135 +11,99 @@ interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface { /** - * Sets the layouts sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $layoutsDir + * Resets any template before layouts */ - public function setLayoutsDir($layoutsDir); + public function cleanTemplateAfter(); /** - * Gets the current layouts sub-directory - * - * @return string + * Resets any template before layouts */ - public function getLayoutsDir(); + public function cleanTemplateBefore(); /** - * Sets a partials sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $partialsDir + * Disables the auto-rendering process */ - public function setPartialsDir($partialsDir); + public function disable(); /** - * Gets the current partials sub-directory - * - * @return string + * Enables the auto-rendering process */ - public function getPartialsDir(); + public function enable(); /** - * Sets base path. Depending of your platform, always add a trailing slash or backslash - * - * @param string $basePath + * Finishes the render process by stopping the output buffering */ - public function setBasePath($basePath); + public function finish(); /** - * Gets base path + * Gets the name of the action rendered * * @return string */ - public function getBasePath(); + public function getActionName(): string; /** - * Sets the render level for the view - * - * @param int $level - */ - public function setRenderLevel($level); - - /** - * Sets default view name. Must be a file without extension in the views directory + * Returns the path of the view that is currently rendered * - * @param string $viewPath + * @return string|array */ - public function setMainView($viewPath); + public function getActiveRenderPath(); /** - * Returns the name of the main view + * Gets base path * * @return string */ - public function getMainView(); + public function getBasePath(): string; /** - * Change the layout to be used instead of using the name of the latest controller name + * Gets the name of the controller rendered * - * @param string $layout + * @return string */ - public function setLayout($layout); + public function getControllerName(): string; /** * Returns the name of the main view * * @return string */ - public function getLayout(); - - /** - * Appends template before controller layout - * - * @param string|array $templateBefore - */ - public function setTemplateBefore($templateBefore); - - /** - * Resets any template before layouts - */ - public function cleanTemplateBefore(); + public function getLayout(): string; /** - * Appends template after controller layout + * Gets the current layouts sub-directory * - * @param string|array $templateAfter - */ - public function setTemplateAfter($templateAfter); - - /** - * Resets any template before layouts + * @return string */ - public function cleanTemplateAfter(); + public function getLayoutsDir(): string; /** - * Gets the name of the controller rendered + * Returns the name of the main view * * @return string */ - public function getControllerName(); + public function getMainView(): string; /** - * Gets the name of the action rendered + * Gets the current partials sub-directory * * @return string */ - public function getActionName(); + public function getPartialsDir(): string; /** - * Gets extra parameters of the action rendered + * Whether the automatic rendering is disabled * - * @deprecated Will be removed in 4.0.0 - * @deprecated - * @return array + * @return bool */ - public function getParams(); + public function isDisabled(): bool; /** - * Starts rendering process enabling the output buffering + * Choose a view different to render than last-controller/last-action + * + * @param string $renderView */ - public function start(); + public function pick(string $renderView); /** * Register templating engines @@ -154,48 +118,82 @@ public function registerEngines(array $engines); * @param string $controllerName * @param string $actionName * @param array $params + * @return bool|ViewInterface */ - public function render($controllerName, $actionName, $params = null); + public function render(string $controllerName, string $actionName, array $params = array()); /** - * Choose a view different to render than last-controller/last-action + * Resets the view component to its factory default values + */ + public function reset(); + + /** + * Sets base path. Depending of your platform, always add a trailing slash + * or backslash * - * @param string $renderView + * @param string $basePath */ - public function pick($renderView); + public function setBasePath(string $basePath); /** - * Finishes the render process by stopping the output buffering + * Change the layout to be used instead of using the name of the latest + * controller name + * + * @param string $layout */ - public function finish(); + public function setLayout(string $layout); /** - * Returns the path of the view that is currently rendered + * Sets the layouts sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * - * @return string|array + * @param string $layoutsDir */ - public function getActiveRenderPath(); + public function setLayoutsDir(string $layoutsDir); /** - * Disables the auto-rendering process + * Sets default view name. Must be a file without extension in the views + * directory + * + * @param string $viewPath */ - public function disable(); + public function setMainView(string $viewPath); /** - * Enables the auto-rendering process + * Sets a partials sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash + * + * @param string $partialsDir */ - public function enable(); + public function setPartialsDir(string $partialsDir); /** - * Resets the view component to its factory default values + * Sets the render level for the view + * + * @param int $level + * @return ViewInterface */ - public function reset(); + public function setRenderLevel(int $level): ViewInterface; /** - * Whether the automatic rendering is disabled + * Appends template after controller layout * - * @return bool + * @param string|array $templateAfter */ - public function isDisabled(); + public function setTemplateAfter($templateAfter); + + /** + * Appends template before controller layout + * + * @param string|array $templateBefore + */ + public function setTemplateBefore($templateBefore); + + /** + * Starts rendering process enabling the output buffering + */ + public function start(); } diff --git a/src/Phalcon/mvc/collection/Behavior.php b/src/Phalcon/mvc/collection/Behavior.php index 7ad66958..b0683096 100644 --- a/src/Phalcon/mvc/collection/Behavior.php +++ b/src/Phalcon/mvc/collection/Behavior.php @@ -10,7 +10,7 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface { - protected $_options; + protected $options; /** @@ -18,39 +18,39 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Checks whether the behavior must take action on certain event + * Returns the behavior options related to an event * * @param string $eventName - * @return bool + * @return array */ - protected function mustTakeAction($eventName) {} + protected function getOptions(string $eventName = null) {} /** - * Returns the behavior options related to an event + * Acts as fallbacks when a missing method is called on the collection * - * @param string $eventName - * @return array + * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $method + * @param array $arguments */ - protected function getOptions($eventName = null) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $method, array $arguments = array()) {} /** - * This method receives the notifications from the EventsManager + * Checks whether the behavior must take action on certain event * - * @param string $type - * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $eventName + * @return bool */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + protected function mustTakeAction(string $eventName): bool {} /** - * Acts as fallbacks when a missing method is called on the collection + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $method - * @param mixed $arguments */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $method, $arguments = null) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/collection/BehaviorInterface.php b/src/Phalcon/mvc/collection/BehaviorInterface.php index a3d877ba..0a5b1437 100644 --- a/src/Phalcon/mvc/collection/BehaviorInterface.php +++ b/src/Phalcon/mvc/collection/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the collection * - * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection + * @param string $method + * @param array $arguments */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $collection); + public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, string $method, array $arguments = array()); /** - * Calls a method when it's missing in the collection + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection - * @param string $method - * @param mixed $arguments */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, $method, $arguments = null); + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $collection); } diff --git a/src/Phalcon/mvc/collection/Document.php b/src/Phalcon/mvc/collection/Document.php index bbc95b98..94efc018 100644 --- a/src/Phalcon/mvc/collection/Document.php +++ b/src/Phalcon/mvc/collection/Document.php @@ -12,19 +12,20 @@ class Document implements \Phalcon\Mvc\EntityInterface, \ArrayAccess { /** - * Checks whether an offset exists in the document + * Returns the value of a field using the ArrayAccess interfase * - * @param int $index - * @return bool + * @param mixed $index + * @return mixed */ - public function offsetExists($index) {} + public function offsetGet($index) {} /** - * Returns the value of a field using the ArrayAccess interfase + * Checks whether an offset exists in the document * * @param mixed $index + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index): bool {} /** * Change a value using the ArrayAccess interface @@ -37,39 +38,39 @@ public function offsetSet($index, $value) {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @param string $offset + * @param mixed $index */ - public function offsetUnset($offset) {} + public function offsetUnset($index) {} /** * Reads an attribute value by its name * - * + * ```php * echo $robot->readAttribute("name"); - * + * ``` * * @param string $attribute - * @return mixed + * @return mixed|null */ - public function readAttribute($attribute) {} + public function readAttribute(string $attribute): ? {} + + /** + * Returns the instance as an array representation + * + * @return array + */ + public function toArray(): array {} /** * Writes an attribute value by its name * - * + * ```php * $robot->writeAttribute("name", "Rosey"); - * + * ``` * * @param string $attribute * @param mixed $value */ - public function writeAttribute($attribute, $value) {} - - /** - * Returns the instance as an array representation - * - * @return array - */ - public function toArray() {} + public function writeAttribute(string $attribute, $value) {} } diff --git a/src/Phalcon/mvc/collection/Manager.php b/src/Phalcon/mvc/collection/Manager.php index dc635c26..8be4af53 100644 --- a/src/Phalcon/mvc/collection/Manager.php +++ b/src/Phalcon/mvc/collection/Manager.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * + * ```php * $di = new \Phalcon\Di(); * * $di->set( @@ -21,36 +21,36 @@ * ); * * $robot = new Robots($di); - * + * ``` */ class Manager implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_dependencyInjector; + protected $behaviors; - protected $_initialized; + protected $connectionServices; - protected $_lastInitialized; + protected $container; - protected $_eventsManager; + protected $customEventsManager; - protected $_customEventsManager; + protected $eventsManager; - protected $_connectionServices; + protected $implicitObjectsIds; - protected $_implicitObjectsIds; + protected $initialized; - protected $_behaviors; + protected $lastInitialized; - protected $_serviceName = 'mongo'; + protected $serviceName = 'mongo'; @@ -62,138 +62,138 @@ public function getServiceName() {} public function setServiceName($serviceName) {} /** - * Sets the DependencyInjector container + * Binds a behavior to a model * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} /** - * Returns the DependencyInjector container + * Returns a custom events manager related to a model * - * @return \Phalcon\DiInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @return mixed|null */ - public function getDI() {} + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): ? {} /** - * Sets the event manager + * Returns the connection related to a model * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Mongo */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Returns the internal event manager + * Gets a connection service for a specific model * - * @return \Phalcon\Events\ManagerInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @return string */ - public function getEventsManager() {} + public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model): string {} /** - * Sets a custom events manager for a specific model + * Returns the DependencyInjector container * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return \Phalcon\Di\DiInterface */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} + public function getDI(): DiInterface {} /** - * Returns a custom events manager related to a model + * Returns the internal event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return mixed|null + * @return \Phalcon\Events\ManagerInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model) {} + public function getEventsManager(): ManagerInterface {} /** - * Initializes a model in the models manager + * Get the latest initialized model * - * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Phalcon\Mvc\CollectionInterface */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} + public function getLastInitialized(): CollectionInterface {} /** - * Check whether a model is already initialized + * Checks if a model is using implicit object ids * - * @param string $modelName + * @param \Phalcon\Mvc\CollectionInterface $model * @return bool */ - public function isInitialized($modelName) {} + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool {} /** - * Get the latest initialized model + * Check whether a model is already initialized * - * @return \Phalcon\Mvc\CollectionInterface + * @param string $className + * @return bool */ - public function getLastInitialized() {} + public function isInitialized(string $className): bool {} /** - * Sets a connection service for a specific model + * Initializes a model in the models manager * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService) {} + public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Gets a connection service for a specific model + * Dispatch an event to the listeners and behaviors + * This method expects that the endpoint listeners/behaviors returns true + * meaning that at least one was implemented * * @param \Phalcon\Mvc\CollectionInterface $model - * @return string + * @param string $eventName + * @param mixed $data + * @return bool */ - public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $eventName, $data): bool {} /** - * Sets whether a model must use implicit objects ids + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds) {} + public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model) {} /** - * Checks if a model is using implicit object ids + * Sets a custom events manager for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model) {} + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns the connection related to a model + * Sets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Mongo + * @param string $connectionService */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService) {} /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets the DependencyInjector container * - * @param string $eventName - * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Di\DiInterface $container */ - public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented + * Sets the event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $eventName - * @param mixed $data - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $eventName, $data) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Binds a behavior to a model + * Sets whether a model must use implicit objects ids * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param bool $useImplicitObjectIds */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds) {} } diff --git a/src/Phalcon/mvc/collection/ManagerInterface.php b/src/Phalcon/mvc/collection/ManagerInterface.php index da8edc32..1d575f79 100644 --- a/src/Phalcon/mvc/collection/ManagerInterface.php +++ b/src/Phalcon/mvc/collection/ManagerInterface.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * + * ```php * $di = new \Phalcon\Di(); * * $di->set( @@ -21,64 +21,56 @@ * ); * * $robot = new Robots(di); - * + * ``` */ interface ManagerInterface { /** - * Sets a custom events manager for a specific model + * Binds a behavior to a collection * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); /** - * Returns a custom events manager related to a model + * Returns the connection related to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Events\ManagerInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model); + public function getConnection(\Phalcon\Mvc\CollectionInterface $model): AdapterInterface; /** - * Initializes a model in the models manager + * Returns a custom events manager related to a model * * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Phalcon\Events\ManagerInterface */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model); - - /** - * Check whether a model is already initialized - * - * @param string $modelName - * @return bool - */ - public function isInitialized($modelName); + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): EventsManagerInterface; /** * Get the latest initialized model * * @return \Phalcon\Mvc\CollectionInterface */ - public function getLastInitialized(); + public function getLastInitialized(): CollectionInterface; /** - * Sets a connection service for a specific model + * Initializes a model in the models manager * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService); + public function initialize(\Phalcon\Mvc\CollectionInterface $model); /** - * Sets if a model must use implicit objects ids + * Check whether a model is already initialized * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds + * @param string $className + * @return bool */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds); + public function isInitialized(string $className): bool; /** * Checks if a model is using implicit object ids @@ -86,31 +78,39 @@ public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $u * @param \Phalcon\Mvc\CollectionInterface $model * @return bool */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model); + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool; /** - * Returns the connection related to a model + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Db\AdapterInterface */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model); + public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model); /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets a custom events manager for a specific model * - * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model); + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); /** - * Binds a behavior to a collection + * Sets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param string $connectionService */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService); + + /** + * Sets if a model must use implicit objects ids + * + * @param \Phalcon\Mvc\CollectionInterface $model + * @param bool $useImplicitObjectIds + */ + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds); } diff --git a/src/Phalcon/mvc/collection/behavior/SoftDelete.php b/src/Phalcon/mvc/collection/behavior/SoftDelete.php index 59621249..18c2959f 100644 --- a/src/Phalcon/mvc/collection/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/collection/behavior/SoftDelete.php @@ -17,6 +17,6 @@ class SoftDelete extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/collection/behavior/Timestampable.php b/src/Phalcon/mvc/collection/behavior/Timestampable.php index d9803981..09ebb023 100644 --- a/src/Phalcon/mvc/collection/behavior/Timestampable.php +++ b/src/Phalcon/mvc/collection/behavior/Timestampable.php @@ -17,6 +17,6 @@ class Timestampable extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 1bffa5d2..84e98de1 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -15,6 +15,6 @@ interface BindModelInterface * * @return string */ - public static function getModelName(); + public static function getModelName(): string; } diff --git a/src/Phalcon/mvc/dispatcher/Exception.php b/src/Phalcon/mvc/dispatcher/Exception.php index 685af95f..b7f06862 100644 --- a/src/Phalcon/mvc/dispatcher/Exception.php +++ b/src/Phalcon/mvc/dispatcher/Exception.php @@ -7,7 +7,7 @@ * * Exceptions thrown in Phalcon\Mvc\Dispatcher will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Phalcon\Dispatcher\Exception { } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 8b312466..5c1ba381 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -7,7 +7,7 @@ * * Groups Micro-Mvc handlers as controllers * - * + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $collection = new Collection(); @@ -19,175 +19,185 @@ * $collection->get("/posts/edit/{id}", "edit"); * * $app->mount($collection); - * + * ``` */ class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { - protected $_prefix; + protected $handler; - protected $_lazy; + protected $handlers = array(); - protected $_handler; + protected $lazy; - protected $_handlers; + protected $prefix; /** - * Internal function to add a handler to the group + * Maps a route to a handler that only matches if the HTTP method is DELETE. * - * @param string|array $method * @param string $routePattern - * @param mixed $handler + * @param callable|string $handler * @param string $name + * @return CollectionInterface */ - protected function _addMap($method, $routePattern, $handler, $name) {} + public function delete(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is GET. * - * @param string $prefix + * @param string $routePattern + * @param callable|string $handler + * @param string $name * @return CollectionInterface */ - public function setPrefix($prefix) {} + public function get(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Returns the collection prefix if any + * Returns the main handler * - * @return string + * @return mixed */ - public function getPrefix() {} + public function getHandler() {} /** * Returns the registered handlers * * @return array */ - public function getHandlers() {} + public function getHandlers(): array {} /** - * Sets the main handler + * Returns the collection prefix if any * - * @param mixed $handler - * @param boolean $lazy - * @return Collection + * @return string */ - public function setHandler($handler, $lazy = false) {} + public function getPrefix(): string {} /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is HEAD. * - * @param bool $lazy + * @param string $routePattern + * @param callable|string $handler + * @param string $name * @return CollectionInterface */ - public function setLazy($lazy) {} + public function head(string $routePattern, $handler, string $name = null): CollectionInterface {} /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy() {} + public function isLazy(): bool {} /** - * Returns the main handler + * Maps a route to a handler. * - * @return mixed + * @param string $routePattern + * @param callable|string $handler + * @param string $name + * @return CollectionInterface */ - public function getHandler() {} + public function map(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler + * Maps a route to a handler via methods. + * + * ```php + * $collection->mapVia( + * "/test", + * "indexAction", + * ["POST", "GET"], + * "test" + * ); + * ``` * * @param string $routePattern * @param callable $handler + * @param string|array $method * @param string $name - * @return Collection + * @return CollectionInterface */ - public function map($routePattern, $handler, $name = null) {} + public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface {} /** - * Maps a route to a handler via methods + * Maps a route to a handler that only matches if the HTTP method is + * OPTIONS. * * @param string $routePattern - * @param callable $handler - * @param string|array $method + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function mapVia($routePattern, $handler, $method, $name = null) {} + public function options(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Maps a route to a handler that only matches if the HTTP method is PATCH. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function get($routePattern, $handler, $name = null) {} + public function patch(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Maps a route to a handler that only matches if the HTTP method is POST. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function post($routePattern, $handler, $name = null) {} + public function post(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Maps a route to a handler that only matches if the HTTP method is PUT. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function put($routePattern, $handler, $name = null) {} + public function put(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Sets the main handler. * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param callable|string $handler + * @param bool $lazy + * @return CollectionInterface */ - public function patch($routePattern, $handler, $name = null) {} + public function setHandler($handler, bool $lazy = false): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param bool $lazy + * @return CollectionInterface */ - public function head($routePattern, $handler, $name = null) {} + public function setLazy(bool $lazy): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param string $prefix + * @return CollectionInterface */ - public function delete($routePattern, $handler, $name = null) {} + public function setPrefix(string $prefix): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Internal function to add a handler to the group. * + * @param string|array $method * @param string $routePattern - * @param callable $handler - * @param mixed $name - * @return Collection + * @param callable|string $handler + * @param string $name */ - public function options($routePattern, $handler, $name = null) {} + protected function addMap($method, string $routePattern, $handler, string $name) {} } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index ad71ea2e..8254ccc9 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -11,57 +11,62 @@ interface CollectionInterface { /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @param string $prefix + * @param string $routePattern + * @param callable $handler + * @param string $name * @return CollectionInterface */ - public function setPrefix($prefix); + public function delete(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Returns the collection prefix if any + * Maps a route to a handler that only matches if the HTTP method is GET * - * @return string + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return CollectionInterface + */ + public function get(string $routePattern, $handler, string $name = null): CollectionInterface; + + /** + * Returns the main handler + * + * @return mixed */ - public function getPrefix(); + public function getHandler(); /** * Returns the registered handlers * * @return array */ - public function getHandlers(); + public function getHandlers(): array; /** - * Sets the main handler + * Returns the collection prefix if any * - * @param mixed $handler - * @param boolean $lazy - * @return \Phalcon\Mvc\Micro\Collection + * @return string */ - public function setHandler($handler, $lazy = false); + public function getPrefix(): string; /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param bool $lazy + * @param string $routePattern + * @param callable $handler + * @param string $name * @return CollectionInterface */ - public function setLazy($lazy); + public function head(string $routePattern, $handler, string $name = null): CollectionInterface; /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy(); - - /** - * Returns the main handler - * - * @return mixed - */ - public function getHandler(); + public function isLazy(): bool; /** * Maps a route to a handler @@ -69,78 +74,73 @@ public function getHandler(); * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function map($routePattern, $handler, $name = null); + public function map(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function get($routePattern, $handler, $name = null); + public function options(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Maps a route to a handler that only matches if the HTTP method is PATCH * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function post($routePattern, $handler, $name = null); + public function patch(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Maps a route to a handler that only matches if the HTTP method is POST * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function put($routePattern, $handler, $name = null); + public function post(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Maps a route to a handler that only matches if the HTTP method is PUT * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function patch($routePattern, $handler, $name = null); + public function put(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets the main handler * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param mixed $handler + * @param bool $lazy + * @return CollectionInterface */ - public function head($routePattern, $handler, $name = null); + public function setHandler($handler, bool $lazy = false): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param bool $lazy + * @return CollectionInterface */ - public function delete($routePattern, $handler, $name = null); + public function setLazy(bool $lazy): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $prefix + * @return CollectionInterface */ - public function options($routePattern, $handler, $name = null); + public function setPrefix(string $prefix): CollectionInterface; } diff --git a/src/Phalcon/mvc/micro/Exception.php b/src/Phalcon/mvc/micro/Exception.php index 1c22e5f4..cd352fc1 100644 --- a/src/Phalcon/mvc/micro/Exception.php +++ b/src/Phalcon/mvc/micro/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\Micro; /** - * Phalcon\Mvc\Micro\Exception - * * Exceptions thrown in Phalcon\Mvc\Micro will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index e083b411..d7cb0a66 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -10,13 +10,10 @@ class LazyLoader { - protected $_handler; + protected $handler; - protected $_modelBinder; - - - protected $_definition; + protected $definition; @@ -27,16 +24,7 @@ public function getDefinition() {} * * @param string $definition */ - public function __construct($definition) {} - - /** - * Initializes the internal handler, calling functions on it - * - * @param string $method - * @param array $arguments - * @return mixed - */ - public function __call($method, $arguments) {} + public function __construct(string $definition) {} /** * Calling __call method @@ -46,6 +34,6 @@ public function __call($method, $arguments) {} * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @return mixed */ - public function callMethod($method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} + public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index ee19ff86..daa73549 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\Micro; /** - * Phalcon\Mvc\Micro\MiddlewareInterface - * * Allows to implement Phalcon\Mvc\Micro middleware in classes */ interface MiddlewareInterface diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 4c5bc910..e3366fdd 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -9,8 +9,10 @@ */ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface { - - protected $_options; + /** + * @var array + */ + protected $options; /** @@ -18,39 +20,39 @@ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Checks whether the behavior must take action on certain event + * Returns the behavior options related to an event * * @param string $eventName - * @return bool + * @return array */ - protected function mustTakeAction($eventName) {} + protected function getOptions(string $eventName = null) {} /** - * Returns the behavior options related to an event + * Acts as fallbacks when a missing method is called on the model * - * @param string $eventName - * @return array + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - protected function getOptions($eventName = null) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) {} /** - * This method receives the notifications from the EventsManager + * Checks whether the behavior must take action on certain event * - * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param string $eventName + * @return bool */ - public function notify($type, \Phalcon\Mvc\ModelInterface $model) {} + protected function mustTakeAction(string $eventName): bool {} /** - * Acts as fallbacks when a missing method is called on the model + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null) {} + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 084b49fd..77ed3cc6 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the model * - * @param string $type * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - public function notify($type, \Phalcon\Mvc\ModelInterface $model); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()); /** - * Calls a method when it's missing in the model + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null); + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index dbe0bf78..086ca316 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -37,7 +37,7 @@ class Binder implements \Phalcon\Mvc\Model\BinderInterface * * @return array */ - public function getBoundModels() {} + public function getBoundModels(): array {} /** * Array for original values @@ -47,24 +47,9 @@ public function getOriginalValues() {} /** * Phalcon\Mvc\Model\Binder constructor * - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct(\Phalcon\Cache\BackendInterface $cache = null) {} - - /** - * Gets cache instance - * - * @param \Phalcon\Cache\BackendInterface $cache - * @return BinderInterface - */ - public function setCache(\Phalcon\Cache\BackendInterface $cache) {} - - /** - * Sets cache instance - * - * @return \Phalcon\Cache\BackendInterface - */ - public function getCache() {} + public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** * Bind models into params in proper handler @@ -72,10 +57,10 @@ public function getCache() {} * @param object $handler * @param array $params * @param string $cacheKey - * @param mixed $methodName + * @param string $methodName * @return array */ - public function bindToHandler($handler, array $params, $cacheKey, $methodName = null) {} + public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array {} /** * Find the model by param value. @@ -84,7 +69,14 @@ public function bindToHandler($handler, array $params, $cacheKey, $methodName = * @param string $className * @return object|bool */ - protected function findBoundModel($paramValue, $className) {} + protected function findBoundModel($paramValue, string $className): bool {} + + /** + * Sets cache instance + * + * @return \Phalcon\Cache\Adapter\AdapterInterface + */ + public function getCache(): AdapterInterface {} /** * Get params classes from cache by key @@ -92,7 +84,7 @@ protected function findBoundModel($paramValue, $className) {} * @param string $cacheKey * @return array|null */ - protected function getParamsFromCache($cacheKey) {} + protected function getParamsFromCache(string $cacheKey): ?array {} /** * Get modified params for handler using reflection @@ -100,9 +92,17 @@ protected function getParamsFromCache($cacheKey) {} * @param object $handler * @param array $params * @param string $cacheKey - * @param mixed $methodName + * @param string $methodName * @return array */ - protected function getParamsFromReflection($handler, array $params, $cacheKey, $methodName) {} + protected function getParamsFromReflection($handler, array $params, string $cacheKey, string $methodName): array {} + + /** + * Gets cache instance + * + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return BinderInterface + */ + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface {} } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index ddd77ec2..811f792e 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -11,36 +11,36 @@ interface BinderInterface { /** - * Gets active bound models + * Bind models into params in proper handler * + * @param object $handler + * @param array $params + * @param string $cacheKey + * @param string $methodName * @return array */ - public function getBoundModels(); + public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array; /** - * Gets cache instance + * Gets active bound models * - * @return \Phalcon\Cache\BackendInterface + * @return array */ - public function getCache(); + public function getBoundModels(): array; /** - * Sets cache instance + * Gets cache instance * - * @param \Phalcon\Cache\BackendInterface $cache - * @return BinderInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function setCache(\Phalcon\Cache\BackendInterface $cache); + public function getCache(): AdapterInterface; /** - * Bind models into params in proper handler + * Sets cache instance * - * @param object $handler - * @param array $params - * @param string $cacheKey - * @param mixed $methodName - * @return array + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return BinderInterface */ - public function bindToHandler($handler, array $params, $cacheKey, $methodName = null); + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index e39987a0..99b5a18f 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -6,10 +6,10 @@ * Phalcon\Mvc\Model\Criteria * * This class is used to build the array parameter required by - * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() - * using an object-oriented interface. + * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() using an + * object-oriented interface. * - * + * ```php * $robots = Robots::query() * ->where("type = :type:") * ->andWhere("year < 2000") @@ -17,39 +17,39 @@ * ->limit(5, 10) * ->orderBy("name") * ->execute(); - * + * ``` */ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_model; + protected $bindParams; - protected $_params; + protected $bindTypes; - protected $_bindParams; + protected $hiddenParamNumber = 0; - protected $_bindTypes; + protected $model; - protected $_hiddenParamNumber = 0; + protected $params = array(); /** * Sets the DependencyInjector container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the DependencyInjector container * - * @return null|\Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** * Set a model on which the query will be executed @@ -57,14 +57,14 @@ public function getDI() {} * @param string $modelName * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function setModelName($modelName) {} + public function setModelName(string $modelName): CriteriaInterface {} /** * Returns an internal model name on which the criteria will be applied * * @return string */ - public function getModelName() {} + public function getModelName(): string {} /** * Sets the bound parameters in the criteria @@ -74,7 +74,7 @@ public function getModelName() {} * @param bool $merge * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bind(array $bindParams, $merge = false) {} + public function bind(array $bindParams, bool $merge = false): CriteriaInterface {} /** * Sets the bind types in the criteria @@ -83,94 +83,130 @@ public function bind(array $bindParams, $merge = false) {} * @param array $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bindTypes(array $bindTypes) {} + public function bindTypes(array $bindTypes): CriteriaInterface {} /** * Sets SELECT DISTINCT / SELECT ALL flag * * @param mixed $distinct - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function distinct($distinct) {} + public function distinct($distinct): CriteriaInterface {} /** * Sets the columns to be queried * - * + * ```php * $criteria->columns( * [ * "id", * "name", * ] * ); - * + * ``` * * @param string|array $columns - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function columns($columns) {} + public function columns($columns): CriteriaInterface {} /** * Adds an INNER join to the query * - * - * $criteria->join("Robots"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); - * + * ```php + * $criteria->join( + * Robots::class + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r", + * "LEFT" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias * @param mixed $type - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function join($model, $conditions = null, $alias = null, $type = null) {} + public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface {} /** * Adds an INNER join to the query * - * - * $criteria->innerJoin("Robots"); - * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id"); - * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->innerJoin( + * Robots::class + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function innerJoin($model, $conditions = null, $alias = null) {} + public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Adds a LEFT join to the query * - * - * $criteria->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function leftJoin($model, $conditions = null, $alias = null) {} + public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Adds a RIGHT join to the query * - * - * $criteria->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function rightJoin($model, $conditions = null, $alias = null) {} + public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Sets the conditions parameter in the criteria @@ -180,20 +216,7 @@ public function rightJoin($model, $conditions = null, $alias = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null) {} - - /** - * Appends a condition to the current conditions using an AND operator (deprecated) - * - * @deprecated 1.0.0 - * @see \Phalcon\Mvc\Model\Criteria::andWhere() - * @param string $conditions - * @param mixed $bindParams - * @param mixed $bindTypes - * @deprecated - * @return Criteria - */ - public function addWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a condition to the current conditions using an AND operator @@ -203,7 +226,7 @@ public function addWhere($conditions, $bindParams = null, $bindTypes = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a condition to the current conditions using an OR operator @@ -213,61 +236,61 @@ public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a BETWEEN condition to the current conditions * - * + * ```php * $criteria->betweenWhere("price", 100.25, 200.50); - * + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function betweenWhere($expr, $minimum, $maximum) {} + public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} /** * Appends a NOT BETWEEN condition to the current conditions * - * + * ```php * $criteria->notBetweenWhere("price", 100.25, 200.50); - * + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notBetweenWhere($expr, $minimum, $maximum) {} + public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} /** * Appends an IN condition to the current conditions * - * + * ```php * $criteria->inWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function inWhere($expr, array $values) {} + public function inWhere(string $expr, array $values): CriteriaInterface {} /** * Appends a NOT IN condition to the current conditions * - * + * ```php * $criteria->notInWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notInWhere($expr, array $values) {} + public function notInWhere(string $expr, array $values): CriteriaInterface {} /** * Adds the conditions parameter to the criteria @@ -275,17 +298,7 @@ public function notInWhere($expr, array $values) {} * @param string $conditions * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function conditions($conditions) {} - - /** - * Adds the order-by parameter to the criteria (deprecated) - * - * @see \Phalcon\Mvc\Model\Criteria::orderBy() - * @param string $orderColumns - * @deprecated - * @return Criteria - */ - public function order($orderColumns) {} + public function conditions(string $conditions): CriteriaInterface {} /** * Adds the order-by clause to the criteria @@ -293,38 +306,38 @@ public function order($orderColumns) {} * @param string $orderColumns * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orderBy($orderColumns) {} + public function orderBy(string $orderColumns): CriteriaInterface {} /** * Adds the group-by clause to the criteria * * @param mixed $group - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function groupBy($group) {} + public function groupBy($group): CriteriaInterface {} /** * Adds the having clause to the criteria * * @param mixed $having - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function having($having) {} + public function having($having): CriteriaInterface {} /** * Adds the limit parameter to the criteria. * - * + * ```php * $criteria->limit(100); * $criteria->limit(100, 200); * $criteria->limit("100", "200"); - * + * ``` * * @param int $limit - * @param mixed $offset + * @param int $offset * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function limit($limit, $offset = null) {} + public function limit(int $limit, int $offset = 0): CriteriaInterface {} /** * Adds the "for_update" parameter to the criteria @@ -332,7 +345,7 @@ public function limit($limit, $offset = null) {} * @param bool $forUpdate * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function forUpdate($forUpdate = true) {} + public function forUpdate(bool $forUpdate = true): CriteriaInterface {} /** * Adds the "shared_lock" parameter to the criteria @@ -340,54 +353,53 @@ public function forUpdate($forUpdate = true) {} * @param bool $sharedLock * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function sharedLock($sharedLock = true) {} + public function sharedLock(bool $sharedLock = true): CriteriaInterface {} /** * Sets the cache options in the criteria * This method replaces all previously set cache options * * @param array $cache - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function cache(array $cache) {} + public function cache(array $cache): CriteriaInterface {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getWhere() {} + public function getWhere(): ?string {} /** * Returns the columns to be queried * * @return string|null */ - public function getColumns() {} + public function getColumns(): ?string {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getConditions() {} + public function getConditions(): ?string {} /** - * Returns the limit parameter in the criteria, which will be - * an integer if limit was set without an offset, - * an array with 'number' and 'offset' keys if an offset was set with the limit, - * or null if limit has not been set. + * Returns the limit parameter in the criteria, which will be an integer if + * limit was set without an offset, an array with 'number' and 'offset' keys + * if an offset was set with the limit, or null if limit has not been set. * * @return string|null */ - public function getLimit() {} + public function getLimit(): ?string {} /** * Returns the order clause in the criteria * * @return string|null */ - public function getOrderBy() {} + public function getOrderBy(): ?string {} /** * Returns the group clause in the criteria @@ -404,38 +416,38 @@ public function getHaving() {} * * @return array */ - public function getParams() {} + public function getParams(): array {} /** * Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param string $modelName * @param array $data * @param string $operator - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public static function fromInput(\Phalcon\DiInterface $dependencyInjector, $modelName, array $data, $operator = 'AND') {} + public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface {} /** * Creates a query builder from criteria. * - * + * ```php * $builder = Robots::query() * ->where("type = :type:") * ->bind(["type" => "mechanical"]) * ->createBuilder(); - * + * ``` * * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder() {} + public function createBuilder(): BuilderInterface {} /** * Executes a find using the parameters built with the criteria * * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function execute() {} + public function execute(): ResultsetInterface {} } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index cd77f6dc..923f16b8 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -11,29 +11,37 @@ interface CriteriaInterface { /** - * Set a model on which the query will be executed + * Appends a condition to the current conditions using an AND operator * - * @param string $modelName + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes * @return CriteriaInterface */ - public function setModelName($modelName); + public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; /** - * Returns an internal model name on which the criteria will be applied + * Appends a BETWEEN condition to the current conditions * - * @return string + * ```php + * $criteria->betweenWhere("price", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @return CriteriaInterface */ - public function getModelName(); + public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; /** * Sets the bound parameters in the criteria * This method replaces all previously set bound parameters * * @param array $bindParams - * @param bool $merge * @return CriteriaInterface */ - public function bind(array $bindParams, $merge = false); + public function bind(array $bindParams): CriteriaInterface; /** * Sets the bind types in the criteria @@ -42,17 +50,16 @@ public function bind(array $bindParams, $merge = false); * @param array $bindTypes * @return CriteriaInterface */ - public function bindTypes(array $bindTypes); + public function bindTypes(array $bindTypes): CriteriaInterface; /** - * Sets the conditions parameter in the criteria + * Sets the cache options in the criteria + * This method replaces all previously set cache options * - * @param string $conditions - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $cache * @return CriteriaInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null); + public function cache(array $cache): CriteriaInterface; /** * Adds the conditions parameter to the criteria @@ -60,24 +67,22 @@ public function where($conditions, $bindParams = null, $bindTypes = null); * @param string $conditions * @return CriteriaInterface */ - public function conditions($conditions); + public function conditions(string $conditions): CriteriaInterface; /** - * Adds the order-by parameter to the criteria + * Sets SELECT DISTINCT / SELECT ALL flag * - * @param string $orderColumns + * @param mixed $distinct * @return CriteriaInterface */ - public function orderBy($orderColumns); + public function distinct($distinct): CriteriaInterface; /** - * Sets the limit parameter to the criteria + * Executes a find using the parameters built with the criteria * - * @param int $limit - * @param int $offset - * @return CriteriaInterface + * @return ResultsetInterface */ - public function limit($limit, $offset = null); + public function execute(): ResultsetInterface; /** * Sets the "for_update" parameter to the criteria @@ -85,133 +90,237 @@ public function limit($limit, $offset = null); * @param bool $forUpdate * @return CriteriaInterface */ - public function forUpdate($forUpdate = true); + public function forUpdate(bool $forUpdate = true): CriteriaInterface; /** - * Sets the "shared_lock" parameter to the criteria + * Returns the columns to be queried * - * @param bool $sharedLock + * @return string|null + */ + public function getColumns(): ?string; + + /** + * Returns the conditions parameter in the criteria + * + * @return string|null + */ + public function getConditions(): ?string; + + /** + * Returns the group clause in the criteria + */ + public function getGroupBy(); + + /** + * Returns the having clause in the criteria + */ + public function getHaving(); + + /** + * Returns the limit parameter in the criteria, which will be an integer if + * limit was set without an offset, an array with 'number' and 'offset' keys + * if an offset was set with the limit, or null if limit has not been set. + * + * @return string|null + */ + public function getLimit(): ?string; + + /** + * Returns an internal model name on which the criteria will be applied + * + * @return string + */ + public function getModelName(): string; + + /** + * Returns the order parameter in the criteria + * + * @return string|null + */ + public function getOrderBy(): ?string; + + /** + * Returns all the parameters defined in the criteria + * + * @return array + */ + public function getParams(): array; + + /** + * Returns the conditions parameter in the criteria + * + * @return string|null + */ + public function getWhere(): ?string; + + /** + * Adds the group-by clause to the criteria + * + * @param mixed $group * @return CriteriaInterface */ - public function sharedLock($sharedLock = true); + public function groupBy($group): CriteriaInterface; /** - * Appends a condition to the current conditions using an AND operator + * Adds the having clause to the criteria * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes + * @param mixed $having * @return CriteriaInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null); + public function having($having): CriteriaInterface; /** - * Appends a condition to the current conditions using an OR operator + * Adds an INNER join to the query * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes + * ```php + * $criteria->innerJoin( + * Robots::class + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` + * + * @param string $model + * @param mixed $conditions + * @param mixed $alias * @return CriteriaInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null); + public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Appends a BETWEEN condition to the current conditions + * Appends an IN condition to the current conditions * - * - * $criteria->betweenWhere("price", 100.25, 200.50); - * + * ```php + * $criteria->inWhere("id", [1, 2, 3]); + * ``` * * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param array $values * @return CriteriaInterface */ - public function betweenWhere($expr, $minimum, $maximum); + public function inWhere(string $expr, array $values): CriteriaInterface; /** - * Appends a NOT BETWEEN condition to the current conditions + * Adds a LEFT join to the query * - * - * $criteria->notBetweenWhere("price", 100.25, 200.50); - * + * ```php + * $criteria->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param string $model + * @param mixed $conditions + * @param mixed $alias * @return CriteriaInterface */ - public function notBetweenWhere($expr, $minimum, $maximum); + public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Appends an IN condition to the current conditions + * Sets the limit parameter to the criteria * - * - * $criteria->inWhere("id", [1, 2, 3]); - * + * @param int $limit + * @param int $offset + * @return CriteriaInterface + */ + public function limit(int $limit, int $offset = 0): CriteriaInterface; + + /** + * Appends a NOT BETWEEN condition to the current conditions + * + * ```php + * $criteria->notBetweenWhere("price", 100.25, 200.50); + * ``` * * @param string $expr - * @param array $values + * @param mixed $minimum + * @param mixed $maximum * @return CriteriaInterface */ - public function inWhere($expr, array $values); + public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; /** * Appends a NOT IN condition to the current conditions * - * + * ```php * $criteria->notInWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return CriteriaInterface */ - public function notInWhere($expr, array $values); + public function notInWhere(string $expr, array $values): CriteriaInterface; /** - * Returns the conditions parameter in the criteria + * Adds the order-by parameter to the criteria * - * @return string|null + * @param string $orderColumns + * @return CriteriaInterface */ - public function getWhere(); + public function orderBy(string $orderColumns): CriteriaInterface; /** - * Returns the conditions parameter in the criteria + * Appends a condition to the current conditions using an OR operator * - * @return string|null + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return CriteriaInterface */ - public function getConditions(); + public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; /** - * Returns the limit parameter in the criteria, which will be - * an integer if limit was set without an offset, - * an array with 'number' and 'offset' keys if an offset was set with the limit, - * or null if limit has not been set. + * Adds a RIGHT join to the query * - * @return int|array|null + * ```php + * $criteria->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` + * + * @param string $model + * @param mixed $conditions + * @param mixed $alias + * @return CriteriaInterface */ - public function getLimit(); + public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Returns the order parameter in the criteria + * Set a model on which the query will be executed * - * @return string|null + * @param string $modelName + * @return CriteriaInterface */ - public function getOrderBy(); + public function setModelName(string $modelName): CriteriaInterface; /** - * Returns all the parameters defined in the criteria + * Sets the "shared_lock" parameter to the criteria * - * @return array + * @param bool $sharedLock + * @return CriteriaInterface */ - public function getParams(); + public function sharedLock(bool $sharedLock = true): CriteriaInterface; /** - * Executes a find using the parameters built with the criteria + * Sets the conditions parameter in the criteria * - * @return ResultsetInterface + * @param string $conditions + * @return CriteriaInterface */ - public function execute(); + public function where(string $conditions): CriteriaInterface; } diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index f83fe1c8..a398bec4 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -5,12 +5,13 @@ /** * Phalcon\Mvc\Model\Manager * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. + * This components controls the initialization of models, keeping record of + * relations between the different models of the application. * - * A ModelsManager is injected to a model via a Dependency Injector/Services Container such as Phalcon\Di. + * A ModelsManager is injected to a model via a Dependency Injector/Services + * Container such as Phalcon\Di. * - * + * ```php * use Phalcon\Di; * use Phalcon\Mvc\Model\Manager as ModelsManager; * @@ -24,145 +25,142 @@ * ); * * $robot = new Robots($di); - * + * ``` */ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_dependencyInjector; - - - protected $_eventsManager; + protected $aliases = array(); + /** + * Models' behaviors + */ + protected $behaviors = array(); - protected $_customEventsManager; + /** + * Belongs to relations + */ + protected $belongsTo = array(); + /** + * All the relationships by model + */ + protected $belongsToSingle = array(); - protected $_readConnectionServices; + protected $container; - protected $_writeConnectionServices; + protected $customEventsManager = array(); - protected $_aliases; + /** + * Does the model use dynamic update, instead of updating all rows? + */ + protected $dynamicUpdate = array(); - protected $_modelVisibility = array(); + protected $eventsManager; /** * Has many relations */ - protected $_hasMany; + protected $hasMany = array(); /** * Has many relations by model */ - protected $_hasManySingle; + protected $hasManySingle = array(); /** - * Has one relations + * Has many-Through relations */ - protected $_hasOne; + protected $hasManyToMany = array(); /** - * Has one relations by model + * Has many-Through relations by model */ - protected $_hasOneSingle; + protected $hasManyToManySingle = array(); /** - * Belongs to relations + * Has one relations */ - protected $_belongsTo; + protected $hasOne = array(); /** - * All the relationships by model + * Has one relations by model */ - protected $_belongsToSingle; + protected $hasOneSingle = array(); /** - * Has many-Through relations + * Mark initialized models */ - protected $_hasManyToMany; + protected $initialized = array(); + + + protected $keepSnapshots = array(); /** - * Has many-Through relations by model + * Last model initialized */ - protected $_hasManyToManySingle; + protected $lastInitialized; /** - * Mark initialized models + * Last query created/executed */ - protected $_initialized; + protected $lastQuery; - protected $_prefix = ''; + protected $modelVisibility = array(); - protected $_sources; + protected $prefix = ''; - protected $_schemas; + protected $readConnectionServices = array(); - /** - * Models' behaviors - */ - protected $_behaviors; - /** - * Last model initialized - */ - protected $_lastInitialized; + protected $sources = array(); - /** - * Last query created/executed - */ - protected $_lastQuery; - /** - * Stores a list of reusable instances - */ - protected $_reusable; + protected $schemas = array(); - protected $_keepSnapshots; + protected $writeConnectionServices = array(); /** - * Does the model use dynamic update, instead of updating all rows? + * Stores a list of reusable instances */ - protected $_dynamicUpdate; - - - protected $_namespaceAliases; + protected $reusable = array(); /** * Sets the DependencyInjector container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the DependencyInjector container * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return Manager + * @return \Phalcon\Mvc\Model\ManagerInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): ManagerInterface {} /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager() {} + public function getEventsManager(): EventsManagerInterface {} /** * Sets a custom events manager for a specific model @@ -186,73 +184,63 @@ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function initialize(\Phalcon\Mvc\ModelInterface $model) {} + public function initialize(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Check whether a model is already initialized * - * @param string $modelName + * @param string $className * @return bool */ - public function isInitialized($modelName) {} + public function isInitialized(string $className): bool {} /** * Get last initialized model * * @return \Phalcon\Mvc\ModelInterface */ - public function getLastInitialized() {} + public function getLastInitialized(): ModelInterface {} /** * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @param bool $newInstance * @return \Phalcon\Mvc\ModelInterface */ - public function load($modelName, $newInstance = false) {} + public function load(string $modelName): ModelInterface {} /** * Sets the prefix for all model sources. * - * + * ```php * use Phalcon\Mvc\Model\Manager; * - * $di->set("modelsManager", function () { - * $modelsManager = new Manager(); - * $modelsManager->setModelPrefix("wp_"); + * $di->set( + * "modelsManager", + * function () { + * $modelsManager = new Manager(); * - * return $modelsManager; - * }); + * $modelsManager->setModelPrefix("wp_"); + * + * return $modelsManager; + * } + * ); * * $robots = new Robots(); + * * echo $robots->getSource(); // wp_robots - * + * ``` * * @param string $prefix */ - public function setModelPrefix($prefix) {} + public function setModelPrefix(string $prefix) {} /** * Returns the prefix for all model sources. * - * - * use Phalcon\Mvc\Model\Manager; - * - * $di->set("modelsManager", function () { - * $modelsManager = new Manager(); - * $modelsManager->setModelPrefix("wp_"); - * - * return $modelsManager; - * }); - * - * $robots = new Robots(); - * echo $robots->getSource(); // wp_robots - * - * * @return string */ - public function getModelPrefix() {} + public function getModelPrefix(): string {} /** * Sets the mapped source for a model @@ -260,23 +248,23 @@ public function getModelPrefix() {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $source */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source) {} + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) {} /** * Check whether a model property is declared as public. * - * + * ```php * $isPublic = $manager->isVisibleModelProperty( * new Robots(), * "name" * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param string $property * @return bool */ - public final function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, $property) {} + final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool {} /** * Returns the mapped source for a model @@ -284,7 +272,7 @@ public final function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model) {} + public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} /** * Sets the mapped schema for a model @@ -292,7 +280,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema) {} + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) {} /** * Returns the mapped schema for a model @@ -300,7 +288,7 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema) {} * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model) {} + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} /** * Sets both write and read connection service for a model @@ -308,7 +296,7 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Sets write connection service for a model @@ -316,7 +304,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connec * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Sets read connection service for a model @@ -324,32 +312,32 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $c * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Returns the connection to read data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model) {} + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} /** * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model) {} + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} /** * Returns the connection to read or write data related to a model depending on the connection services. * * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $connectionServices - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} + protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface {} /** * Returns the connection service name used to read data related to a model @@ -357,7 +345,7 @@ protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectio * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model) {} + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns the connection service name used to write data related to a model @@ -365,7 +353,7 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model) {} + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns the connection service name used to read or write data related to @@ -375,16 +363,17 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model) {} * @param mixed $connectionServices * @return string */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} + public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string {} /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Receives events generated in the models and dispatches them to an + * events-manager if available. Notify the behaviors that are listening in + * the model * * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model */ - public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model) {} + public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) {} /** * Dispatch an event to the listeners and behaviors @@ -395,7 +384,7 @@ public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model) {} * @param string $eventName * @param mixed $data */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) {} /** * Binds a behavior to a model @@ -411,7 +400,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, $keepSnapshots) {} + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) {} /** * Checks if a model is keeping snapshots for the queried records @@ -419,7 +408,7 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, $keepSnapshots * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model) {} + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Sets if a model must use dynamic update instead of the all-field update @@ -427,7 +416,7 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, $dynamicUpdate) {} + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) {} /** * Checks if a model is using dynamic update instead of all-field update @@ -435,78 +424,58 @@ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, $dynamicUpd * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model) {} + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Setup a 1-1 relation between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options - * @param \Phalcon\Mvc\Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setup a relation reverse many to one between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options - * @param \Phalcon\Mvc\Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setup a relation 1-n between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @param $Phalcon\Mvc\ModelInterface model - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setups a relation n-m between two models * - * @param string fields - * @param string intermediateModel - * @param string intermediateFields - * @param string intermediateReferencedFields - * @param string referencedModel - * @param string referencedFields * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields + * @param string $fields * @param string $intermediateModel - * @param mixed $intermediateFields - * @param mixed $intermediateReferencedFields + * @param string $intermediateFields + * @param string $intermediateReferencedFields * @param string $referencedModel - * @param mixed $referencedFields + * @param string $referencedFields * @param array $options - * @param $Phalcon\Mvc\ModelInterface model - * @return \Phalcon\Mvc\Model\Relation + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referencedModel, $referencedFields, $options = null) {} + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Checks whether a model has a belongsTo relation with another model @@ -515,7 +484,7 @@ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, $i * @param string $modelRelation * @return bool */ - public function existsBelongsTo($modelName, $modelRelation) {} + public function existsBelongsTo(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasMany relation with another model @@ -524,7 +493,7 @@ public function existsBelongsTo($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasMany($modelName, $modelRelation) {} + public function existsHasMany(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasOne relation with another model @@ -533,7 +502,7 @@ public function existsHasMany($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasOne($modelName, $modelRelation) {} + public function existsHasOne(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasManyToMany relation with another model @@ -542,16 +511,16 @@ public function existsHasOne($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasManyToMany($modelName, $modelRelation) {} + public function existsHasManyToMany(string $modelName, string $modelRelation): bool {} /** * Returns a relation by its alias * * @param string $modelName * @param string $alias - * @return bool|\Phalcon\Mvc\Model\Relation + * @return bool|\Phalcon\Mvc\Model\RelationInterface */ - public function getRelationByAlias($modelName, $alias) {} + public function getRelationByAlias(string $modelName, string $alias) {} /** * Merge two arrays of find parameters @@ -560,18 +529,18 @@ public function getRelationByAlias($modelName, $alias) {} * @param mixed $findParamsTwo * @return array */ - protected final function _mergeFindParameters($findParamsOne, $findParamsTwo) {} + final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): array {} /** * Helper method to query records based on a relation definition * * @param \Phalcon\Mvc\Model\RelationInterface $relation - * @param string $method * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, $method, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Returns a reusable object from the internal list @@ -579,7 +548,7 @@ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relatio * @param string $modelName * @param string $key */ - public function getReusableRecords($modelName, $key) {} + public function getReusableRecords(string $modelName, string $key) {} /** * Stores a reusable record in the internal list @@ -588,7 +557,7 @@ public function getReusableRecords($modelName, $key) {} * @param string $key * @param mixed $records */ - public function setReusableRecords($modelName, $key, $records) {} + public function setReusableRecords(string $modelName, string $key, $records) {} /** * Clears the internal reusable list @@ -598,52 +567,52 @@ public function clearReusableObjects() {} /** * Gets belongsTo related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets hasMany related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets belongsTo related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets all the belongsTo relations defined in a model * - * + * ```php * $relations = $modelsManager->getBelongsTo( * new Robots() * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model) {} + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasMany relations defined on a model @@ -651,7 +620,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasOne relations defined on a model @@ -659,7 +628,7 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasManyToMany relations defined on a model @@ -667,32 +636,32 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Query all the relationships defined on a model * * @param string $modelName - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelations($modelName) {} + public function getRelations(string $modelName): array {} /** * Query the first relationship defined between two models * * @param string $first * @param string $second - * @return bool|\Phalcon\Mvc\Model\RelationInterface[] + * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelationsBetween($first, $second) {} + public function getRelationsBetween(string $first, string $second) {} /** * Creates a Phalcon\Mvc\Model\Query without execute it @@ -700,7 +669,7 @@ public function getRelationsBetween($first, $second) {} * @param string $phql * @return \Phalcon\Mvc\Model\QueryInterface */ - public function createQuery($phql) {} + public function createQuery(string $phql): QueryInterface {} /** * Creates a Phalcon\Mvc\Model\Query and execute it @@ -710,7 +679,7 @@ public function createQuery($phql) {} * @param mixed $types * @return \Phalcon\Mvc\Model\QueryInterface */ - public function executeQuery($phql, $placeholders = null, $types = null) {} + public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface {} /** * Creates a Phalcon\Mvc\Model\Query\Builder @@ -718,37 +687,14 @@ public function executeQuery($phql, $placeholders = null, $types = null) {} * @param mixed $params * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder($params = null) {} + public function createBuilder($params = null): BuilderInterface {} /** * Returns the last query created or executed in the models manager * * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getLastQuery() {} - - /** - * Registers shorter aliases for namespaces in PHQL statements - * - * @param string $alias - * @param string $namespaceName - */ - public function registerNamespaceAlias($alias, $namespaceName) {} - - /** - * Returns a real namespace from its alias - * - * @param string $alias - * @return string - */ - public function getNamespaceAlias($alias) {} - - /** - * Returns all the registered namespace aliases - * - * @return array - */ - public function getNamespaceAliases() {} + public function getLastQuery(): QueryInterface {} /** * Destroys the current PHQL cache diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 27bc4070..9cd12efc 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -11,331 +11,362 @@ interface ManagerInterface { /** - * Initializes a model in the model manager + * Binds a behavior to a model * * @param \Phalcon\Mvc\ModelInterface $model + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function initialize(\Phalcon\Mvc\ModelInterface $model); + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); /** - * Sets the mapped source for a model + * Setup a relation reverse 1-1 between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $source + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source); + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Returns the mapped source for a model + * Setup a relation 1-n between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model); + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Sets the mapped schema for a model + * Setup a 1-1 relation between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $schema + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema); + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Returns the mapped schema for a model + * Setups a relation n-m between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $fields + * @param string $intermediateModel + * @param string $intermediateFields + * @param string $intermediateReferencedFields + * @param string $referencedModel + * @param string $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model); + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Sets both write and read connection service for a model + * Creates a Phalcon\Mvc\Model\Query\Builder * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $params + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function createBuilder($params = null): BuilderInterface; /** - * Sets read connection service for a model + * Creates a Phalcon\Mvc\Model\Query without execute it * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $phql + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function createQuery(string $phql): QueryInterface; /** - * Returns the connection service name used to read data related to a model + * Creates a Phalcon\Mvc\Model\Query and execute it * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $phql + * @param array $placeholders + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model); + public function executeQuery(string $phql, $placeholders = null): QueryInterface; /** - * Sets write connection service for a model + * Checks whether a model has a belongsTo relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function existsBelongsTo(string $modelName, string $modelRelation): bool; /** - * Returns the connection service name used to write data related to a model + * Checks whether a model has a hasMany relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model); + public function existsHasMany(string $modelName, string $modelRelation): bool; /** - * Returns the connection to read data related to a model + * Checks whether a model has a hasOne relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model); + public function existsHasOne(string $modelName, string $modelRelation): bool; /** - * Returns the connection to write data related to a model + * Checks whether a model has a hasManyToMany relation with another model + * + * @param string $modelName + * @param string $modelRelation + * @return bool + */ + public function existsHasManyToMany(string $modelName, string $modelRelation): bool; + + /** + * Gets belongsTo relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model); + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; /** - * Check of a model is already initialized + * Gets belongsTo related records from a model * * @param string $modelName - * @return bool + * @param string $modelRelation + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|ResultsetInterface */ - public function isInitialized($modelName); + public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Get last initialized model + * Gets hasMany relations defined on a model * - * @return \Phalcon\Mvc\ModelInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getLastInitialized(); + public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Loads a model throwing an exception if it doesn't exist + * Gets hasMany related records from a model * * @param string $modelName - * @param bool $newInstance - * @return \Phalcon\Mvc\ModelInterface + * @param string $modelRelation + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|ResultsetInterface */ - public function load($modelName, $newInstance = false); + public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Setup a 1-1 relation between two models + * Gets hasManyToMany relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Setup a relation reverse 1-1 between two models + * Gets hasOne relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @param $\Phalcon\Mvc\ModelInterface $model - * @return + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; /** - * Setup a relation 1-n between two models + * Gets hasOne relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @param $\Phalcon\Mvc\ModelInterface $model - * @return + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Checks whether a model has a belongsTo relation with another model + * Gets belongsTo related records from a model * * @param string $modelName * @param string $modelRelation - * @param $string $modelRelation - * @return + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function existsBelongsTo($modelName, $modelRelation); + public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Checks whether a model has a hasMany relation with another model + * Get last initialized model * - * @param string $modelName - * @param string $modelRelation - * @param $string $modelRelation - * @return + * @return \Phalcon\Mvc\ModelInterface */ - public function existsHasMany($modelName, $modelRelation); + public function getLastInitialized(): ModelInterface; /** - * Checks whether a model has a hasOne relation with another model + * Returns the last query created or executed in the models manager * - * @param string $modelName - * @param string $modelRelation - * @param $string $modelRelation - * @return + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function existsHasOne($modelName, $modelRelation); + public function getLastQuery(): QueryInterface; /** - * Gets belongsTo related records from a model + * Returns the mapped schema for a model * - * @param string $method - * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return string */ - public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string; /** - * Gets hasMany related records from a model + * Returns the mapped source for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return string + */ + public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string; + + /** + * Returns the connection to read data related to a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return \Phalcon\Db\Adapter\AdapterInterface + */ + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + + /** + * Returns the connection service name used to read data related to a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return string + */ + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + + /** + * Returns a relation by its alias * - * @param string $method * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param string $alias + * @return bool|Relation */ - public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getRelationByAlias(string $modelName, string $alias); /** - * Gets belongsTo related records from a model + * Helper method to query records based on a relation definition * + * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @param \Phalcon\Mvc\ModelInterface $record + * @param mixed $parameters * @param string $method - * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Gets belongsTo relations defined on a model + * Query all the relationships defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $modelName + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model); + public function getRelations(string $modelName): array; /** - * Gets hasMany relations defined on a model + * Query the relations between two models * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $first + * @param string $second + * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model); + public function getRelationsBetween(string $first, string $second); /** - * Gets hasOne relations defined on a model + * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model); + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; /** - * Gets hasOne relations defined on a model + * Returns the connection service name used to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model); + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string; /** - * Query all the relationships defined on a model + * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getRelations($modelName); + public function load(string $modelName): ModelInterface; /** - * Query the relations between two models + * Initializes a model in the model manager * - * @param string $first - * @param string $second - * @return array + * @param \Phalcon\Mvc\ModelInterface $model */ - public function getRelationsBetween($first, $second); + public function initialize(\Phalcon\Mvc\ModelInterface $model); /** - * Creates a Phalcon\Mvc\Model\Query without execute it + * Check of a model is already initialized * - * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @param string $className + * @return bool */ - public function createQuery($phql); + public function isInitialized(string $className): bool; /** - * Creates a Phalcon\Mvc\Model\Query and execute it + * Checks if a model is keeping snapshots for the queried records * - * @param string $phql - * @param array $placeholders - * @param array $types - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return bool */ - public function executeQuery($phql, $placeholders = null, $types = null); + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool; /** - * Creates a Phalcon\Mvc\Model\Query\Builder + * Checks if a model is using dynamic update instead of all-field update * - * @param string $params - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return bool */ - public function createBuilder($params = null); + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; /** - * Binds a behavior to a model + * Check whether a model property is declared as public. + * + * ```php + * $isPublic = $manager->isVisibleModelProperty( + * new Robots(), + * "name" + * ); + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @param string $property + * @return bool */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); + final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets if a model must keep snapshots * - * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model + * @param bool $keepSnapshots */ - public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model); + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); /** * Dispatch an event to the listeners and behaviors @@ -345,24 +376,65 @@ public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model); * @param \Phalcon\Mvc\ModelInterface $model * @param string $eventName * @param array $data - * @return boolean + * @return bool */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); /** - * Returns the last query created or executed in the models manager + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param string $eventName + * @param \Phalcon\Mvc\ModelInterface $model */ - public function getLastQuery(); + public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model); /** - * Returns a relation by its alias + * Sets both write and read connection service for a model * - * @param string $modelName - * @param string $alias - * @return \Phalcon\Mvc\Model\Relation + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets read connection service for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets the mapped schema for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $schema + */ + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); + + /** + * Sets the mapped source for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $source + */ + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); + + /** + * Sets write connection service for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets if a model must use dynamic update instead of the all-field update + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param bool $dynamicUpdate */ - public function getRelationByAlias($modelName, $alias); + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); } diff --git a/src/Phalcon/mvc/model/Message.php b/src/Phalcon/mvc/model/Message.php deleted file mode 100644 index 971efcd9..00000000 --- a/src/Phalcon/mvc/model/Message.php +++ /dev/null @@ -1,147 +0,0 @@ - - * use Phalcon\Mvc\Model\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $text = "A robot cannot be named Peter"; - * $field = "name"; - * $type = "InvalidValue"; - * - * $message = new Message($text, $field, $type); - * - * $this->appendMessage($message); - * } - * } - * } - * - */ -class Message implements \Phalcon\Mvc\Model\MessageInterface -{ - /** - * @var string - */ - protected $_type; - - /** - * @var string - */ - protected $_message; - - - protected $_field; - - - protected $_model; - - - protected $_code; - - - /** - * @return string - */ - public function getType() {} - - /** - * @return string - */ - public function getMessage() {} - - /** - * Phalcon\Mvc\Model\Message constructor - * - * @param string $message - * @param string|array $field - * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model - * @param int|null $code - */ - public function __construct($message, $field = null, $type = null, $model = null, $code = null) {} - - /** - * Sets message type - * - * @param string $type - * @return Message - */ - public function setType($type) {} - - /** - * Sets verbose message - * - * @param string $message - * @return Message - */ - public function setMessage($message) {} - - /** - * Sets field name related to message - * - * @param mixed $field - * @return Message - */ - public function setField($field) {} - - /** - * Returns field name related to message - */ - public function getField() {} - - /** - * Set the model who generates the message - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return Message - */ - public function setModel(\Phalcon\Mvc\ModelInterface $model) {} - - /** - * Sets code for the message - * - * @param int $code - * @return Message - */ - public function setCode($code) {} - - /** - * Returns the model that produced the message - * - * @return \Phalcon\Mvc\ModelInterface - */ - public function getModel() {} - - /** - * Returns the message code - * - * @return int - */ - public function getCode() {} - - /** - * Magic __toString method returns verbose message - * - * @return string - */ - public function __toString() {} - - /** - * Magic __set_state helps to re-build messages variable exporting - * - * @param array $message - * @return \Phalcon\Mvc\Model\MessageInterface - */ - public static function __set_state(array $message) {} - -} diff --git a/src/Phalcon/mvc/model/MessageInterface.php b/src/Phalcon/mvc/model/MessageInterface.php deleted file mode 100644 index ffdb410e..00000000 --- a/src/Phalcon/mvc/model/MessageInterface.php +++ /dev/null @@ -1,70 +0,0 @@ -Because Phalcon\Mvc\Model requires meta-data like field names, data types, primary keys, etc. - * this component collect them and store for further querying by Phalcon\Mvc\Model. - * Phalcon\Mvc\Model\MetaData can also use adapters to store temporarily or permanently the meta-data.

+ * Because Phalcon\Mvc\Model requires meta-data like field names, data types, + * primary keys, etc. This component collect them and store for further + * querying by Phalcon\Mvc\Model. Phalcon\Mvc\Model\MetaData can also use + * adapters to store temporarily or permanently the meta-data. * - *

A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes:

+ * A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes: * - * + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Memory(); * * $attributes = $metaData->getAttributes( @@ -19,7 +20,7 @@ * ); * * print_r($attributes); - * + * ``` */ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface { @@ -27,357 +28,431 @@ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon const MODELS_ATTRIBUTES = 0; - const MODELS_PRIMARY_KEY = 1; + const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; - const MODELS_NON_PRIMARY_KEY = 2; + const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; - const MODELS_NOT_NULL = 3; + const MODELS_COLUMN_MAP = 0; - const MODELS_DATA_TYPES = 4; + const MODELS_DATE_AT = 6; - const MODELS_DATA_TYPES_NUMERIC = 5; + const MODELS_DATE_IN = 7; - const MODELS_DATE_AT = 6; + const MODELS_DATA_TYPES = 4; - const MODELS_DATE_IN = 7; + const MODELS_DATA_TYPES_BIND = 9; - const MODELS_IDENTITY_COLUMN = 8; + const MODELS_DATA_TYPES_NUMERIC = 5; - const MODELS_DATA_TYPES_BIND = 9; + const MODELS_DEFAULT_VALUES = 12; - const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; + const MODELS_EMPTY_STRING_VALUES = 13; - const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; + const MODELS_IDENTITY_COLUMN = 8; - const MODELS_DEFAULT_VALUES = 12; + const MODELS_NON_PRIMARY_KEY = 2; - const MODELS_EMPTY_STRING_VALUES = 13; + const MODELS_NOT_NULL = 3; - const MODELS_COLUMN_MAP = 0; + const MODELS_PRIMARY_KEY = 1; const MODELS_REVERSE_COLUMN_MAP = 1; + /** + * @var CacheAdapterInterface + */ + protected $adapter; + - protected $_dependencyInjector; + protected $columnMap; - protected $_strategy; + protected $container; - protected $_metaData; + protected $metaData = array(); - protected $_columnMap; + protected $strategy; /** - * Initialize the metadata for certain table + * Returns table attributes names (fields) + * + * ```php + * print_r( + * $metaData->getAttributes( + * new Robots() + * ) + * ); + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $key - * @param mixed $table - * @param mixed $schema + * @return array */ - protected final function _initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} + public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Sets the DependencyInjector container + * Returns attributes that must be ignored from the INSERT SQL generation * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container + * ```php + * print_r( + * $metaData->getAutomaticCreateAttributes( + * new Robots() + * ) + * ); + * ``` * - * @return \Phalcon\DiInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getDI() {} + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Set the meta-data extraction strategy + * Returns attributes that must be ignored from the UPDATE SQL generation * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy - */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} - - /** - * Return the strategy to obtain the meta-data + * ```php + * print_r( + * $metaData->getAutomaticUpdateAttributes( + * new Robots() + * ) + * ); + * ``` * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getStrategy() {} + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads the complete meta-data for certain model + * Returns attributes and their bind data types * - * + * ```php * print_r( - * $metaData->readMetaData( + * $metaData->getBindTypes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public final function readMetaData(\Phalcon\Mvc\ModelInterface $model) {} + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads meta-data for certain model + * Returns the column map if any * - * + * ```php * print_r( - * $metaData->readMetaDataIndex( - * new Robots(), - * 0 + * $metaData->getColumnMap( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public final function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Writes meta-data for certain model using a MODEL_ constant + * Returns attributes (which have default values) and their default values * - * + * ```php * print_r( - * $metaData->writeColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP, - * [ - * "leName" => "name", - * ] + * $metaData->getDefaultValues( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * @return array */ - public final function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data) {} + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads the ordered/reversed column map for certain model + * Returns attributes and their data types * - * + * ```php * print_r( - * $metaData->readColumnMap( + * $metaData->getDataTypes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public final function readColumnMap(\Phalcon\Mvc\ModelInterface $model) {} + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads column-map information for certain model using a MODEL_ constant + * Returns attributes which types are numerical * - * + * ```php * print_r( - * $metaData->readColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP + * $metaData->getDataTypesNumeric( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public final function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns table attributes names (fields) + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns attributes allow empty strings * - * + * ```php * print_r( - * $metaData->getAttributes( + * $metaData->getEmptyStringAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns an array of fields which are part of the primary key + * Returns the name of identity field (if one is present) * - * + * ```php * print_r( - * $metaData->getPrimaryKeyAttributes( + * $metaData->getIdentityField( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns an array of fields which are not part of the primary key * - * + * ```php * print_r( * $metaData->getNonPrimaryKeyAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** * Returns an array of not null attributes * - * + * ```php * print_r( * $metaData->getNotNullAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes and their data types + * Returns an array of fields which are part of the primary key * - * + * ```php * print_r( - * $metaData->getDataTypes( + * $metaData->getPrimaryKeyAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model) {} + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes which types are numerical + * Returns the reverse column map if any * - * + * ```php * print_r( - * $metaData->getDataTypesNumeric( + * $metaData->getReverseColumnMap( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model) {} + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns the name of identity field (if one is present) + * Return the strategy to obtain the meta-data * - * + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + */ + public function getStrategy(): StrategyInterface {} + + /** + * Check if a model has certain attribute + * + * ```php + * var_dump( + * $metaData->hasAttribute( + * new Robots(), + * "name" + * ) + * ); + * ``` + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $attribute + * @return bool + */ + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool {} + + /** + * Checks if the internal meta-data container is empty + * + * ```php + * var_dump( + * $metaData->isEmpty() + * ); + * ``` + * + * @return bool + */ + public function isEmpty(): bool {} + + /** + * Reads metadata from the adapter + * + * @param string $key + * @return array|null + */ + public function read(string $key): ?array {} + + /** + * Reads the ordered/reversed column map for certain model + * + * ```php * print_r( - * $metaData->getIdentityField( + * $metaData->readColumnMap( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model) {} + final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array {} /** - * Returns attributes and their bind data types + * Reads column-map information for certain model using a MODEL_ constant * - * + * ```php * print_r( - * $metaData->getBindTypes( - * new Robots() + * $metaData->readColumnMapIndex( + * new Robots(), + * MetaData::MODELS_REVERSE_COLUMN_MAP * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Reads the complete meta-data for certain model * - * + * ```php * print_r( - * $metaData->getAutomaticCreateAttributes( + * $metaData->readMetaData( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Reads meta-data for certain model * - * + * ```php * print_r( - * $metaData->getAutomaticUpdateAttributes( - * new Robots() + * $metaData->readMetaDataIndex( + * new Robots(), + * 0 * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} + + /** + * Resets internal meta-data in order to regenerate it + * + * ```php + * $metaData->reset(); + * ``` + */ + public function reset() {} /** * Set the attributes that must be ignored from the INSERT SQL generation * - * + * ```php * $metaData->setAutomaticCreateAttributes( * new Robots(), * [ * "created_at" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -387,14 +462,14 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that must be ignored from the UPDATE SQL generation * - * + * ```php * $metaData->setAutomaticUpdateAttributes( * new Robots(), * [ * "modified_at" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -404,14 +479,14 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that allow empty string values * - * + * ```php * $metaData->setEmptyStringAttributes( * new Robots(), * [ * "name" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -419,107 +494,63 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} /** - * Returns attributes allow empty strings - * - * - * print_r( - * $metaData->getEmptyStringAttributes( - * new Robots() - * ) - * ); - * + * Sets the DependencyInjector container * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param \Phalcon\Di\DiInterface $container */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns attributes (which have default values) and their default values - * - * - * print_r( - * $metaData->getDefaultValues( - * new Robots() - * ) - * ); - * + * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model) {} + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} /** - * Returns the column map if any - * - * - * print_r( - * $metaData->getColumnMap( - * new Robots() - * ) - * ); - * + * Writes the metadata to adapter * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $key + * @param array $data */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model) {} + public function write(string $key, array $data) {} /** - * Returns the reverse column map if any + * Writes meta-data for certain model using a MODEL_ constant * - * + * ```php * print_r( - * $metaData->getReverseColumnMap( - * new Robots() - * ) - * ); - * - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array - */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model) {} - - /** - * Check if a model has certain attribute - * - * - * var_dump( - * $metaData->hasAttribute( + * $metaData->writeColumnMapIndex( * new Robots(), - * "name" + * MetaData::MODELS_REVERSE_COLUMN_MAP, + * [ + * "leName" => "name", + * ] * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool + * @param int $index + * @param mixed $data */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute) {} + final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) {} /** - * Checks if the internal meta-data container is empty - * - * - * var_dump( - * $metaData->isEmpty() - * ); - * + * Initialize the metadata for certain table * - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @param mixed $key + * @param mixed $table + * @param mixed $schema */ - public function isEmpty() {} + final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} /** - * Resets internal meta-data in order to regenerate it + * Throws an exception when the metadata cannot be written * - * - * $metaData->reset(); - * + * @param mixed $option */ - public function reset() {} + private function throwWriteException($option) {} } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index 502ec310..bea647c2 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -11,225 +11,225 @@ interface MetaDataInterface { /** - * Set the meta-data extraction strategy + * Returns table attributes names (fields) * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); + public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Return the strategy to obtain the meta-data + * Returns attributes that must be ignored from the INSERT SQL generation * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getStrategy(); + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads meta-data for certain model + * Returns attributes that must be ignored from the UPDATE SQL generation * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function readMetaData(\Phalcon\Mvc\ModelInterface $model); + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads meta-data for certain model using a MODEL_ constant + * Returns attributes and their bind data types * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @return mixed + * @return array */ - public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index); + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Writes meta-data for certain model using a MODEL_ constant + * Returns the column map if any * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * @return array */ - public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data); + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads the ordered/reversed column map for certain model + * Returns attributes (which have default values) and their default values * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function readColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads column-map information for certain model using a MODEL_ constant + * Returns attributes and their data types * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index); + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns table attributes names (fields) + * Returns attributes which types are numerical * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns an array of fields which are part of the primary key + * Returns attributes allow empty strings * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns an array of fields which are not part of the primary key + * Returns the name of identity field (if one is present) * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string; /** - * Returns an array of not null attributes + * Returns an array of fields which are not part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes and their data types + * Returns an array of not null attributes * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model); + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes which types are numerical + * Returns an array of fields which are part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model); + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns the name of identity field (if one is present) + * Returns the reverse column map if any * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model); + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes and their bind data types + * Return the strategy to obtain the meta-data * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model); + public function getStrategy(): StrategyInterface; /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Check if a model has certain attribute * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $attribute + * @return bool */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model); + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool; /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Checks if the internal meta-data container is empty * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return bool */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model); + public function isEmpty(): bool; /** - * Set the attributes that must be ignored from the INSERT SQL generation + * Reads meta-data from the adapter * - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @param string $key + * @return array|null */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function read(string $key): ?array; /** - * Set the attributes that must be ignored from the UPDATE SQL generation + * Reads the ordered/reversed column map for certain model * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @return array|null */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array; /** - * Set the attributes that allow empty string values + * Reads column-map information for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @param int $index */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index); /** - * Returns attributes allow empty strings + * Reads meta-data for certain model * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model); + public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes (which have default values) and their default values + * Reads meta-data for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index + * @return mixed */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model); + public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index); /** - * Returns the column map if any - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * Resets internal meta-data in order to regenerate it */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function reset(); /** - * Returns the reverse column map if any + * Set the attributes that must be ignored from the INSERT SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param array $attributes */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Check if a model has certain attribute + * Set the attributes that must be ignored from the UPDATE SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool + * @param array $attributes */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute); + public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Checks if the internal meta-data container is empty + * Set the attributes that allow empty string values * - * @return boolean + * @param \Phalcon\Mvc\ModelInterface $model + * @param array $attributes */ - public function isEmpty(); + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Resets internal meta-data in order to regenerate it + * Writes meta-data for certain model using a MODEL_ constant + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param int $index + * @param mixed $data */ - public function reset(); + public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data); /** - * Reads meta-data from the adapter + * Set the meta-data extraction strategy * - * @param string $key - * @return array + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function read($key); + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); /** * Writes meta-data to the adapter @@ -237,6 +237,6 @@ public function read($key); * @param string $key * @param array $data */ - public function write($key, $data); + public function write(string $key, array $data); } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index dd7594e6..5d33d3c1 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -7,7 +7,7 @@ * * This class takes a PHQL intermediate representation and executes it. * - * + * ```php * $phql = "SELECT c.price0.16 AS taxes, c. FROM Cars AS c JOIN Brands AS b * WHERE b.name = :name: ORDER BY c.name"; * @@ -49,103 +49,107 @@ * $resultWithEntries = $queryWithTransaction->execute(); * * $queryWithOutTransaction = new Query($phql, $di); - * $resultWithOutEntries = $queryWithTransaction->execute() - * - * + * $resultWithOutEntries = $queryWithTransaction->execute(); + * ``` */ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { - const TYPE_SELECT = 309; + const TYPE_DELETE = 303; const TYPE_INSERT = 306; + const TYPE_SELECT = 309; + + const TYPE_UPDATE = 300; - const TYPE_DELETE = 303; + protected $ast; + + protected $bindParams; - protected $_dependencyInjector; + protected $bindTypes; - protected $_manager; + protected $cache; - protected $_metaData; + protected $cacheOptions; - protected $_type; + protected $container; - protected $_phql; + protected $enableImplicitJoins; - protected $_ast; + protected $intermediate; - protected $_intermediate; + protected $manager; - protected $_models; + protected $metaData; - protected $_sqlAliases; + protected $models; - protected $_sqlAliasesModels; + protected $modelsInstances; - protected $_sqlModelsAliases; + protected $nestingLevel = -1; - protected $_sqlAliasesModelsInstances; + protected $phql; - protected $_sqlColumnAliases; + protected $sharedLock; - protected $_modelsInstances; + protected $sqlAliases; - protected $_cache; + protected $sqlAliasesModels; - protected $_cacheOptions; + protected $sqlAliasesModelsInstances; - protected $_uniqueRow; + protected $sqlColumnAliases = array(); - protected $_bindParams; + protected $sqlModelsAliases; - protected $_bindTypes; + protected $type; - protected $_enableImplicitJoins; + protected $uniqueRow; - protected $_sharedLock; + + static protected $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local transaction instead of this one + * however if a model got a transaction set inside it will use the local + * transaction instead of this one */ protected $_transaction; - static protected $_irPhqlCache; - - /** * TransactionInterface so that the query can wrap a transaction * * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local transaction instead of this one + * however if a model got a transaction set inside it will use the local + * transaction instead of this one */ public function getTransaction() {} @@ -153,47 +157,50 @@ public function getTransaction() {} * Phalcon\Mvc\Model\Query constructor * * @param string $phql - * @param \Phalcon\DiInterface $dependencyInjector - * @param mixed $options + * @param \Phalcon\Di\DiInterface $container + * @param array $options */ - public function __construct($phql = null, \Phalcon\DiInterface $dependencyInjector = null, $options = null) {} + public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) {} /** * Sets the dependency injection container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the dependency injection container * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** - * Tells to the query if only the first row in the resultset must be returned + * Tells to the query if only the first row in the resultset must be + * returned * * @param bool $uniqueRow - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setUniqueRow($uniqueRow) {} + public function setUniqueRow(bool $uniqueRow): QueryInterface {} /** - * Check if the query is programmed to get only the first row in the resultset + * Check if the query is programmed to get only the first row in the + * resultset * * @return bool */ - public function getUniqueRow() {} + public function getUniqueRow(): bool {} /** - * Replaces the model's name to its source name in a qualified-name expression + * Replaces the model's name to its source name in a qualified-name + * expression * * @param array $expr * @return array */ - protected final function _getQualified(array $expr) {} + final protected function _getQualified(array $expr): array {} /** * Resolves an expression in a single call argument @@ -201,7 +208,7 @@ protected final function _getQualified(array $expr) {} * @param array $argument * @return array */ - protected final function _getCallArgument(array $argument) {} + final protected function _getCallArgument(array $argument): array {} /** * Resolves an expression in a single call argument @@ -209,7 +216,7 @@ protected final function _getCallArgument(array $argument) {} * @param array $expr * @return array */ - protected final function _getCaseExpression(array $expr) {} + final protected function _getCaseExpression(array $expr): array {} /** * Resolves an expression in a single call argument @@ -217,25 +224,25 @@ protected final function _getCaseExpression(array $expr) {} * @param array $expr * @return array */ - protected final function _getFunctionCall(array $expr) {} + final protected function _getFunctionCall(array $expr): array {} /** * Resolves an expression from its intermediate code into a string * * @param array $expr - * @param boolean $quoting + * @param bool $quoting * @return string */ - protected final function _getExpression($expr, $quoting = true) {} + final protected function _getExpression(array $expr, bool $quoting = true): string {} /** - * Resolves a column from its intermediate representation into an array used to determine - * if the resultset produced is simple or complex + * Resolves a column from its intermediate representation into an array + * used to determine if the resultset produced is simple or complex * * @param array $column * @return array */ - protected final function _getSelectColumn(array $column) {} + final protected function _getSelectColumn(array $column): array {} /** * Resolves a table in a SELECT statement checking if the model exists @@ -244,16 +251,16 @@ protected final function _getSelectColumn(array $column) {} * @param array $qualifiedName * @return string */ - protected final function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, $qualifiedName) {} + final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) {} /** * Resolves a JOIN clause checking if the associated models exist * * @param \Phalcon\Mvc\Model\ManagerInterface $manager - * @param mixed $join + * @param array $join * @return array */ - protected final function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, $join) {} + final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array {} /** * Resolves a JOIN type @@ -261,7 +268,7 @@ protected final function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, * @param array $join * @return string */ - protected final function _getJoinType($join) {} + final protected function _getJoinType(array $join): string {} /** * Resolves joins involving has-one/belongs-to/has-many relations @@ -273,7 +280,7 @@ protected final function _getJoinType($join) {} * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - protected final function _getSingleJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} + final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} /** * Resolves joins involving many-to-many relations @@ -285,15 +292,16 @@ protected final function _getSingleJoin($joinType, $joinSource, $modelAlias, $jo * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - protected final function _getMultiJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} + final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} /** - * Processes the JOINs in the query returning an internal representation for the database dialect + * Processes the JOINs in the query returning an internal representation for + * the database dialect * * @param array $select * @return array */ - protected final function _getJoins($select) {} + final protected function _getJoins(array $select): array {} /** * Returns a processed order clause for a SELECT statement @@ -301,7 +309,7 @@ protected final function _getJoins($select) {} * @param array|string $order * @return array */ - protected final function _getOrderClause($order) {} + final protected function _getOrderClause($order): array {} /** * Returns a processed group clause for a SELECT statement @@ -309,7 +317,7 @@ protected final function _getOrderClause($order) {} * @param array $group * @return array */ - protected final function _getGroupClause(array $group) {} + final protected function _getGroupClause(array $group): array {} /** * Returns a processed limit clause for a SELECT statement @@ -317,96 +325,104 @@ protected final function _getGroupClause(array $group) {} * @param array $limitClause * @return array */ - protected final function _getLimitClause(array $limitClause) {} + final protected function _getLimitClause(array $limitClause): array {} /** * Analyzes a SELECT intermediate code and produces an array to be executed later * * @param mixed $ast - * @param mixed $merge + * @param bool $merge * @return array */ - protected final function _prepareSelect($ast = null, $merge = null) {} + final protected function _prepareSelect($ast = null, bool $merge = false): array {} /** - * Analyzes an INSERT intermediate code and produces an array to be executed later + * Analyzes an INSERT intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareInsert() {} + final protected function _prepareInsert(): array {} /** - * Analyzes an UPDATE intermediate code and produces an array to be executed later + * Analyzes an UPDATE intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareUpdate() {} + final protected function _prepareUpdate(): array {} /** - * Analyzes a DELETE intermediate code and produces an array to be executed later + * Analyzes a DELETE intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareDelete() {} + final protected function _prepareDelete(): array {} /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another - * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang + * generating another intermediate representation that could be executed by + * Phalcon\Mvc\Model\Query * * @return array */ - public function parse() {} + public function parse(): array {} /** * Returns the current cache backend instance * - * @return \Phalcon\Cache\BackendInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function getCache() {} + public function getCache(): AdapterInterface {} /** - * Executes the SELECT intermediate representation producing a Phalcon\Mvc\Model\Resultset + * Executes the SELECT intermediate representation producing a + * Phalcon\Mvc\Model\Resultset * - * @param mixed $intermediate - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $intermediate + * @param array $bindParams + * @param array $bindTypes * @param bool $simulate * @return array|\Phalcon\Mvc\Model\ResultsetInterface */ - protected final function _executeSelect($intermediate, $bindParams, $bindTypes, $simulate = false) {} + final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) {} /** - * Executes the INSERT intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the INSERT intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeInsert($intermediate, $bindParams, $bindTypes) {} + final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Executes the UPDATE intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the UPDATE intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeUpdate($intermediate, $bindParams, $bindTypes) {} + final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Executes the DELETE intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the DELETE intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeDelete($intermediate, $bindParams, $bindTypes) {} + final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Query the records on which the UPDATE/DELETE operation well be done + * Query the records on which the UPDATE/DELETE operation will be done * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate @@ -414,7 +430,7 @@ protected final function _executeDelete($intermediate, $bindParams, $bindTypes) * @param array $bindTypes * @return \Phalcon\Mvc\Model\ResultsetInterface */ - protected final function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, $intermediate, $bindParams, $bindTypes) {} + final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface {} /** * Executes a parsed PHQL statement @@ -423,7 +439,7 @@ protected final function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, * @param array $bindTypes * @return mixed */ - public function execute($bindParams = null, $bindTypes = null) {} + public function execute(array $bindParams = array(), array $bindTypes = array()) {} /** * Executes the query returning the first result @@ -432,99 +448,100 @@ public function execute($bindParams = null, $bindTypes = null) {} * @param array $bindTypes * @return \Phalcon\Mvc\ModelInterface */ - public function getSingleResult($bindParams = null, $bindTypes = null) {} + public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface {} /** * Sets the type of PHQL statement to be executed * * @param int $type - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setType($type) {} + public function setType(int $type): QueryInterface {} /** * Gets the type of PHQL statement executed * * @return int */ - public function getType() {} + public function getType(): int {} /** * Set default bind parameters * * @param array $bindParams * @param bool $merge - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindParams(array $bindParams, $merge = false) {} + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface {} /** * Returns default bind params * * @return array */ - public function getBindParams() {} + public function getBindParams(): array {} /** * Set default bind parameters * * @param array $bindTypes * @param bool $merge - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindTypes(array $bindTypes, $merge = false) {} + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface {} /** * Set SHARED LOCK clause * * @param bool $sharedLock - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setSharedLock($sharedLock = false) {} + public function setSharedLock(bool $sharedLock = false): QueryInterface {} /** * Returns default bind types * * @return array */ - public function getBindTypes() {} + public function getBindTypes(): array {} /** * Allows to set the IR to be executed * * @param array $intermediate - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setIntermediate(array $intermediate) {} + public function setIntermediate(array $intermediate): QueryInterface {} /** * Returns the intermediate representation of the PHQL statement * * @return array */ - public function getIntermediate() {} + public function getIntermediate(): array {} /** * Sets the cache parameters of the query * - * @param mixed $cacheOptions - * @return Query + * @param array $cacheOptions + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function cache($cacheOptions) {} + public function cache(array $cacheOptions): QueryInterface {} /** * Returns the current cache options * - * @param array + * @return array */ - public function getCacheOptions() {} + public function getCacheOptions(): array {} /** - * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) + * Returns the SQL to be generated by the internal PHQL (only works in + * SELECT statements) * * @return array */ - public function getSql() {} + public function getSql(): array {} /** * Destroys the internal PHQL cache @@ -532,33 +549,35 @@ public function getSql() {} public static function clean() {} /** - * Gets the read connection from the model if there is no transaction set inside the query object + * Gets the read connection from the model if there is no transaction set + * inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} + protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} /** - * Gets the write connection from the model if there is no transaction inside the query object + * Gets the write connection from the model if there is no transaction + * inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} + protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} /** * allows to wrap a transaction around all queries * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface {} } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 197dbcd6..80c28f29 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -11,50 +11,106 @@ interface QueryInterface { /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another - * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * Sets the cache parameters of the query * - * @return array + * @param array $cacheOptions + * @return QueryInterface */ - public function parse(); + public function cache(array $cacheOptions): QueryInterface; /** - * Sets the cache parameters of the query + * Executes a parsed PHQL statement * - * @param array $cacheOptions - * @return \Phalcon\Mvc\Model\Query + * @param array $bindParams + * @param array $bindTypes + * @return mixed + */ + public function execute(array $bindParams = array(), array $bindTypes = array()); + + /** + * Returns default bind params + * + * @return array */ - public function cache($cacheOptions); + public function getBindParams(): array; /** * Returns the current cache options * - * @param array + * @return array */ - public function getCacheOptions(); + public function getCacheOptions(): array; /** - * Tells to the query if only the first row in the resultset must be returned + * Returns default bind types + * + * @return array + */ + public function getBindTypes(): array; + + /** + * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) + * + * @return array + */ + public function getSql(): array; + + /** + * Executes the query returning the first result * - * @param boolean $uniqueRow - * @return \Phalcon\Mvc\Model\Query + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\ModelInterface */ - public function setUniqueRow($uniqueRow); + public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface; /** * Check if the query is programmed to get only the first row in the resultset * - * @return boolean + * @return bool */ - public function getUniqueRow(); + public function getUniqueRow(): bool; /** - * Executes a parsed PHQL statement + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another + * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * + * @return array + */ + public function parse(): array; + + /** + * Set default bind parameters * * @param array $bindParams + * @param bool $merge + * @return QueryInterface + */ + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface; + + /** + * Set default bind parameters + * * @param array $bindTypes - * @return mixed + * @param bool $merge + * @return QueryInterface + */ + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface; + + /** + * Set SHARED LOCK clause + * + * @param bool $sharedLock + * @return QueryInterface + */ + public function setSharedLock(bool $sharedLock = false): QueryInterface; + + /** + * Tells to the query if only the first row in the resultset must be returned + * + * @param bool $uniqueRow + * @return QueryInterface */ - public function execute($bindParams = null, $bindTypes = null); + public function setUniqueRow(bool $uniqueRow): QueryInterface; } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index 362d73ff..4284bf95 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -10,52 +10,52 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface { - const BELONGS_TO = 0; + const ACTION_CASCADE = 2; - const HAS_ONE = 1; + const ACTION_RESTRICT = 1; - const HAS_MANY = 2; + const BELONGS_TO = 0; - const HAS_ONE_THROUGH = 3; + const HAS_MANY = 2; const HAS_MANY_THROUGH = 4; - const NO_ACTION = 0; + const HAS_ONE = 1; - const ACTION_RESTRICT = 1; + const HAS_ONE_THROUGH = 3; - const ACTION_CASCADE = 2; + const NO_ACTION = 0; - protected $_type; + protected $fields; - protected $_referencedModel; + protected $intermediateFields; - protected $_fields; + protected $intermediateModel; - protected $_referencedFields; + protected $intermediateReferencedFields; - protected $_intermediateModel; + protected $options; - protected $_intermediateFields; + protected $referencedFields; - protected $_intermediateReferencedFields; + protected $referencedModel; - protected $_options; + protected $type; /** @@ -67,51 +67,42 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface * @param string|array $referencedFields * @param array $options */ - public function __construct($type, $referencedModel, $fields, $referencedFields, $options = null) {} - - /** - * Sets the intermediate model data for has--through relations - * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string $intermediateReferencedFields - */ - public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields) {} + public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) {} /** - * Returns the relation type + * Returns the fields * - * @return int + * @return string|array */ - public function getType() {} + public function getFields() {} /** - * Returns the referenced model + * Returns the foreign key configuration * - * @return string + * @return string|array */ - public function getReferencedModel() {} + public function getForeignKey() {} /** - * Returns the fields + * Gets the intermediate fields for has--through relations * * @return string|array */ - public function getFields() {} + public function getIntermediateFields() {} /** - * Returns the referenced fields + * Gets the intermediate model for has--through relations * - * @return string|array + * @return string */ - public function getReferencedFields() {} + public function getIntermediateModel(): string {} /** - * Returns the options + * Gets the intermediate referenced fields for has--through relations * * @return string|array */ - public function getOptions() {} + public function getIntermediateReferencedFields() {} /** * Returns an option by the specified name @@ -119,62 +110,71 @@ public function getOptions() {} * * @param string $name */ - public function getOption($name) {} + public function getOption(string $name) {} /** - * Check whether the relation act as a foreign key + * Returns the options * - * @return bool + * @return array */ - public function isForeignKey() {} + public function getOptions(): array {} /** - * Returns the foreign key configuration + * Returns parameters that must be always used when the related records are obtained * - * @return string|array + * @return array */ - public function getForeignKey() {} + public function getParams() {} /** - * Returns parameters that must be always used when the related records are obtained + * Returns the relation type * - * @return array + * @return int */ - public function getParams() {} + public function getType(): int {} /** - * Check whether the relation is a 'many-to-many' relation or not + * Returns the referenced fields * - * @return bool + * @return string|array */ - public function isThrough() {} + public function getReferencedFields() {} /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Returns the referenced model + * + * @return string + */ + public function getReferencedModel(): string {} + + /** + * Check whether the relation act as a foreign key * * @return bool */ - public function isReusable() {} + public function isForeignKey(): bool {} /** - * Gets the intermediate fields for has--through relations + * Check whether the relation is a 'many-to-many' relation or not * - * @return string|array + * @return bool */ - public function getIntermediateFields() {} + public function isThrough(): bool {} /** - * Gets the intermediate model for has--through relations + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * - * @return string + * @return bool */ - public function getIntermediateModel() {} + public function isReusable(): bool {} /** - * Gets the intermediate referenced fields for has--through relations + * Sets the intermediate model data for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string $intermediateReferencedFields */ - public function getIntermediateReferencedFields() {} + public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) {} } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index 992893d1..4f018af5 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -11,104 +11,111 @@ interface RelationInterface { /** - * Sets the intermediate model dat for has--through relations + * Returns the fields * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string|array $intermediateReferencedFields + * @return string|array */ - public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields); + public function getFields(); /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Returns the foreign key configuration * - * @return bool + * @return string|array */ - public function isReusable(); + public function getForeignKey(); /** - * Returns the relations type + * Gets the intermediate fields for has--through relations * - * @return int + * @return string|array */ - public function getType(); + public function getIntermediateFields(); /** - * Returns the referenced model + * Gets the intermediate model for has--through relations * * @return string */ - public function getReferencedModel(); + public function getIntermediateModel(): string; /** - * Returns the fields + * Gets the intermediate referenced fields for has--through relations * * @return string|array */ - public function getFields(); + public function getIntermediateReferencedFields(); /** - * Returns the referenced fields + * Returns an option by the specified name + * If the option doesn't exist null is returned * - * @return string|array + * @param string $name */ - public function getReferencedFields(); + public function getOption(string $name); /** * Returns the options * - * @return string|array + * @return array */ - public function getOptions(); + public function getOptions(): array; /** - * Returns an option by the specified name - * If the option doesn't exist null is returned + * Returns parameters that must be always used when the related records are obtained * - * @param string $name + * @return array */ - public function getOption($name); + public function getParams(); /** - * Check whether the relation act as a foreign key + * Returns the referenced fields * - * @return bool + * @return string|array */ - public function isForeignKey(); + public function getReferencedFields(); /** - * Returns the foreign key configuration + * Returns the referenced model * - * @return string|array + * @return string */ - public function getForeignKey(); + public function getReferencedModel(): string; /** - * Check whether the relation is a 'many-to-many' relation or not + * Returns the relations type + * + * @return int + */ + public function getType(): int; + + /** + * Check whether the relation act as a foreign key * * @return bool */ - public function isThrough(); + public function isForeignKey(): bool; /** - * Gets the intermediate fields for has--through relations + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * - * @return string|array + * @return bool */ - public function getIntermediateFields(); + public function isReusable(): bool; /** - * Gets the intermediate model for has--through relations + * Check whether the relation is a 'many-to-many' relation or not * - * @return string + * @return bool */ - public function getIntermediateModel(); + public function isThrough(): bool; /** - * Gets the intermediate referenced fields for has--through relations + * Sets the intermediate model dat for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string|array $intermediateReferencedFields */ - public function getIntermediateReferencedFields(); + public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 12423705..9ba8f10b 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -13,8 +13,9 @@ interface ResultInterface /** * Sets the object's state * - * @param integer $dirtyState + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState($dirtyState); + public function setDirtyState(int $dirtyState); } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index 5e2e1bb8..4064c4a7 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -10,7 +10,7 @@ * it will dump all the rows into a big array. Then unserialize will retrieve the rows as they were before * serializing. * - * + * ```php * * // Using a standard foreach * $robots = Robots::find( @@ -41,247 +41,248 @@ * * $robots->next(); * } - * + * ``` */ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { - const TYPE_RESULT_FULL = 0; + const HYDRATE_ARRAYS = 1; - const TYPE_RESULT_PARTIAL = 1; + const HYDRATE_OBJECTS = 2; const HYDRATE_RECORDS = 0; - const HYDRATE_OBJECTS = 2; + const TYPE_RESULT_FULL = 0; - const HYDRATE_ARRAYS = 1; + const TYPE_RESULT_PARTIAL = 1; - /** - * Phalcon\Db\ResultInterface or false for empty resultset - */ - protected $_result = false; + protected $activeRow = null; - protected $_cache; + protected $cache; - protected $_isFresh = true; + protected $count; - protected $_pointer = 0; + protected $errorMessages; - protected $_count; + protected $hydrateMode = 0; - protected $_activeRow = null; + protected $isFresh = true; - protected $_rows = null; + protected $pointer = 0; - protected $_row = null; + protected $row = null; - protected $_errorMessages; + protected $rows = null; - protected $_hydrateMode = 0; + /** + * Phalcon\Db\ResultInterface or false for empty resultset + */ + protected $result; /** * Phalcon\Mvc\Model\Resultset constructor * * @param \Phalcon\Db\ResultInterface|false $result - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($result, \Phalcon\Cache\BackendInterface $cache = null) {} + public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** - * Moves cursor to next row in the resultset + * Counts how many rows are in the resultset + * + * @return int */ - public function next() {} + final public function count(): int {} /** - * Check whether internal resource has rows to fetch + * Deletes every record in the resultset * + * @param \Closure $conditionCallback * @return bool */ - public function valid() {} + public function delete(\Closure $conditionCallback = null): bool {} /** - * Gets pointer number of active row in the resultset + * Filters a resultset returning only those the developer requires * - * @return int|null + * ```php + * $filtered = $robots->filter( + * function ($robot) { + * if ($robot->id < 3) { + * return $robot; + * } + * } + * ); + * ``` + * + * @param callable $filter + * @return array|\Phalcon\Mvc\ModelInterface[] */ - public function key() {} + public function filter($filter): array {} /** - * Rewinds resultset to its beginning + * Returns the associated cache for the resultset + * + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public final function rewind() {} + public function getCache(): AdapterInterface {} /** - * Changes the internal pointer to a specific position in the resultset. - * Set the new position if required, and then set this->_row + * Get first row in the resultset * - * @param mixed $position + * @return null|\Phalcon\Mvc\ModelInterface */ - public final function seek($position) {} + public function getFirst(): ?ModelInterface {} /** - * Counts how many rows are in the resultset + * Returns the current hydration mode * * @return int */ - public final function count() {} + public function getHydrateMode(): int {} /** - * Checks whether offset exists in the resultset + * Get last row in the resultset * - * @param mixed $index - * @return bool + * @return null|\Phalcon\Mvc\ModelInterface */ - public function offsetExists($index) {} + public function getLast(): ?ModelInterface {} /** - * Gets row in a specific position of the resultset + * Returns the error messages produced by a batch operation * - * @param mixed $index - * @return bool|\Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function offsetGet($index) {} + public function getMessages(): array {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Returns the internal type of data retrieval that the resultset is using * - * @param int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @return int */ - public function offsetSet($index, $value) {} + public function getType(): int {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Tell if the resultset if fresh or an old one cached * - * @param mixed $offset + * @return bool */ - public function offsetUnset($offset) {} + public function isFresh(): bool {} /** - * Returns the internal type of data retrieval that the resultset is using + * Returns serialised model objects as array for json_encode. + * Calls jsonSerialize on each object if present * - * @return int + * ```php + * $robots = Robots::find(); + * + * echo json_encode($robots); + * ``` + * + * @return array */ - public function getType() {} + public function jsonSerialize(): array {} /** - * Get first row in the resultset + * Gets pointer number of active row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return int|null */ - public function getFirst() {} + public function key(): ?int {} /** - * Get last row in the resultset - * - * @return bool|\Phalcon\Mvc\ModelInterface + * Moves cursor to next row in the resultset */ - public function getLast() {} + public function next() {} /** - * Set if the resultset is fresh or an old one cached + * Gets row in a specific position of the resultset * - * @param bool $isFresh - * @return Resultset + * @param mixed $index + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setIsFresh($isFresh) {} + public function offsetGet($index) {} /** - * Tell if the resultset if fresh or an old one cached + * Checks whether offset exists in the resultset * + * @param mixed $index * @return bool */ - public function isFresh() {} + public function offsetExists($index): bool {} /** - * Sets the hydration mode in the resultset + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @param int $hydrateMode - * @return Resultset + * @param int $index + * @param \Phalcon\Mvc\ModelInterface $value */ - public function setHydrateMode($hydrateMode) {} + public function offsetSet($index, $value) {} /** - * Returns the current hydration mode + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @return int + * @param mixed $offset */ - public function getHydrateMode() {} + public function offsetUnset($offset) {} /** - * Returns the associated cache for the resultset - * - * @return \Phalcon\Cache\BackendInterface + * Rewinds resultset to its beginning */ - public function getCache() {} + final public function rewind() {} /** - * Returns the error messages produced by a batch operation + * Changes the internal pointer to a specific position in the resultset. + * Set the new position if required, and then set this->row * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @param mixed $position */ - public function getMessages() {} + final public function seek($position) {} /** - * Updates every record in the resultset + * Sets the hydration mode in the resultset * - * @param array $data - * @param \Closure $conditionCallback - * @return bool + * @param int $hydrateMode + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function update($data, \Closure $conditionCallback = null) {} + public function setHydrateMode(int $hydrateMode): ResultsetInterface {} /** - * Deletes every record in the resultset + * Set if the resultset is fresh or an old one cached * - * @param \Closure $conditionCallback - * @return bool + * @param bool $isFresh + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function delete(\Closure $conditionCallback = null) {} + public function setIsFresh(bool $isFresh): ResultsetInterface {} /** - * Filters a resultset returning only those the developer requires - * - * - * $filtered = $robots->filter( - * function ($robot) { - * if ($robot->id < 3) { - * return $robot; - * } - * } - * ); - * + * Updates every record in the resultset * - * @param callback $filter - * @return array + * @param array $data + * @param \Closure $conditionCallback + * @return bool */ - public function filter($filter) {} + public function update($data, \Closure $conditionCallback = null): bool {} /** - * Returns serialised model objects as array for json_encode. - * Calls jsonSerialize on each object if present - * - * - * $robots = Robots::find(); - * echo json_encode($robots); - * + * Check whether internal resource has rows to fetch * - * @return array + * @return bool */ - public function jsonSerialize() {} + public function valid(): bool {} } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index f1252a35..b36b34d7 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -11,46 +11,95 @@ interface ResultsetInterface { /** - * Returns the internal type of data retrieval that the resultset is using + * Deletes every record in the resultset * - * @return int + * @param \Closure $conditionCallback + * @return bool + */ + public function delete(\Closure $conditionCallback = null): bool; + + /** + * Filters a resultset returning only those the developer requires + * + * ```php + * $filtered = $robots->filter( + * function ($robot) { + * if ($robot->id < 3) { + * return $robot; + * } + * } + * ); + * ``` + * + * @param callable $filter + * @return array|\Phalcon\Mvc\ModelInterface[] */ - public function getType(); + public function filter($filter): array; + + /** + * Returns the associated cache for the resultset + * + * @return \Phalcon\Cache\Adapter\AdapterInterface + */ + public function getCache(): AdapterInterface; /** * Get first row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return null|\Phalcon\Mvc\ModelInterface */ - public function getFirst(); + public function getFirst(): ?ModelInterface; + + /** + * Returns the current hydration mode + * + * @return int + */ + public function getHydrateMode(): int; /** * Get last row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return null|\Phalcon\Mvc\ModelInterface */ - public function getLast(); + public function getLast(): ?ModelInterface; /** - * Set if the resultset is fresh or an old one cached + * Returns the error messages produced by a batch operation * - * @param bool $isFresh + * @return array|\Phalcon\Messages\MessageInterface[] + */ + public function getMessages(): array; + + /** + * Returns the internal type of data retrieval that the resultset is using + * + * @return int */ - public function setIsFresh($isFresh); + public function getType(): int; /** * Tell if the resultset if fresh or an old one cached * * @return bool */ - public function isFresh(); + public function isFresh(): bool; /** - * Returns the associated cache for the resultset + * Sets the hydration mode in the resultset * - * @return \Phalcon\Cache\BackendInterface + * @param int $hydrateMode + * @return ResultsetInterface */ - public function getCache(); + public function setHydrateMode(int $hydrateMode): ResultsetInterface; + + /** + * Set if the resultset is fresh or an old one cached + * + * @param bool $isFresh + * @return ResultsetInterface + */ + public function setIsFresh(bool $isFresh): ResultsetInterface; /** * Returns a complete resultset as an array, if the resultset has a big number of rows @@ -58,6 +107,15 @@ public function getCache(); * * @return array */ - public function toArray(); + public function toArray(): array; + + /** + * Updates every record in the resultset + * + * @param array $data + * @param \Closure $conditionCallback + * @return bool + */ + public function update($data, \Closure $conditionCallback = null): bool; } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 4d910b69..9d9200e2 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -12,28 +12,29 @@ class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInte { /** - * Set the current object's state + * Serializes the object for json_encode * - * @param int $dirtyState - * @return bool + * @return array */ - public function setDirtyState($dirtyState) {} + public function jsonSerialize(): array {} /** - * Checks whether offset exists in the row + * Gets a record in a specific position of the row * - * @param string|int $index - * @return bool + * @param string|int index + * + * @param mixed $index + * @return mixed */ - public function offsetExists($index) {} + public function offsetGet($index) {} /** - * Gets a record in a specific position of the row + * Checks whether offset exists in the row * * @param string|int $index - * @return string|Phalcon\Mvc\ModelInterface + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index): bool {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface @@ -53,39 +54,40 @@ public function offsetUnset($offset) {} /** * Reads an attribute value by its name * - * + * ```php * echo $robot->readAttribute("name"); - * + * ``` * * @param string $attribute * @return mixed */ - public function readAttribute($attribute) {} + public function readAttribute(string $attribute) {} /** - * Writes an attribute value by its name - * - * - * $robot->writeAttribute("name", "Rosey"); - * + * Set the current object's state * - * @param string $attribute - * @param mixed $value + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function writeAttribute($attribute, $value) {} + public function setDirtyState(int $dirtyState) {} /** * Returns the instance as an array representation * * @return array */ - public function toArray() {} + public function toArray(): array {} /** - * Serializes the object for json_encode + * Writes an attribute value by its name * - * @return array + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` + * + * @param string $attribute + * @param mixed $value */ - public function jsonSerialize() {} + public function writeAttribute(string $attribute, $value) {} } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index 072d0f35..6559b68e 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\Model\Transaction * - * Transactions are protective blocks where SQL statements are only permanent if they can - * all succeed as one atomic action. Phalcon\Transaction is intended to be used with Phalcon_Model_Base. - * Phalcon Transactions should be created using Phalcon\Transaction\Manager. + * Transactions are protective blocks where SQL statements are only permanent if + * they can all succeed as one atomic action. Phalcon\Transaction is intended to + * be used with Phalcon_Model_Base. Phalcon Transactions should be created using + * Phalcon\Transaction\Manager. * - * + * ```php * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -43,112 +44,108 @@ * } catch(Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` */ class Transaction implements \Phalcon\Mvc\Model\TransactionInterface { - protected $_connection; + protected $activeTransaction = false; - protected $_activeTransaction = false; + protected $connection; - protected $_isNewTransaction = true; + protected $isNewTransaction = true; - protected $_rollbackOnAbort = false; + protected $manager; - protected $_manager; + protected $messages; - protected $_messages; + protected $rollbackRecord; - protected $_rollbackRecord; + protected $rollbackOnAbort = false; + + + protected $rollbackThrowException = false; /** * Phalcon\Mvc\Model\Transaction constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param bool $autoBegin * @param string $service */ - public function __construct(\Phalcon\DiInterface $dependencyInjector, $autoBegin = false, $service = null) {} - - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} + public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') {} /** * Starts the transaction * * @return bool */ - public function begin() {} + public function begin(): bool {} /** * Commits the transaction * * @return bool */ - public function commit() {} + public function commit(): bool {} /** - * Rollbacks the transaction + * Returns the connection related to transaction * - * @param mixed $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord - * @return bool + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null) {} + public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface {} /** - * Returns the connection related to transaction + * Returns validations messages from last save try * - * @return \Phalcon\Db\AdapterInterface + * @return array */ - public function getConnection() {} + public function getMessages(): array {} /** - * Sets if is a reused transaction or new once + * Checks whether transaction is managed by a transaction manager * - * @param bool $isNew + * @return bool */ - public function setIsNewTransaction($isNew) {} + public function isManaged(): bool {} /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort($rollbackOnAbort) {} + public function isValid(): bool {} /** - * Checks whether transaction is managed by a transaction manager + * Rollbacks the transaction * + * @param string $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function isManaged() {} + public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool {} /** - * Returns validations messages from last save try + * Sets if is a reused transaction or new once * - * @return array + * @param bool $isNew */ - public function getMessages() {} + public function setIsNewTransaction(bool $isNew) {} /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid() {} + public function setRollbackOnAbort(bool $rollbackOnAbort) {} /** * Sets object which generates rollback action @@ -157,4 +154,19 @@ public function isValid() {} */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) {} + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} + + /** + * Enables throwing exception + * + * @param bool $status + * @return \Phalcon\Mvc\Model\TransactionInterface + */ + public function throwRollbackException(bool $status): TransactionInterface {} + } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index d1715dee..da437029 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -10,76 +10,70 @@ interface TransactionInterface { - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); - /** * Starts the transaction * * @return bool */ - public function begin(); + public function begin(): bool; /** * Commits the transaction * * @return bool */ - public function commit(); + public function commit(): bool; /** - * Rollbacks the transaction + * Returns connection related to transaction * - * @param mixed $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null); + public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface; /** - * Returns connection related to transaction + * Returns validations messages from last save try * - * @return \Phalcon\Db\AdapterInterface + * @return array */ - public function getConnection(); + public function getMessages(): array; /** - * Sets if is a reused transaction or new once + * Checks whether transaction is managed by a transaction manager * - * @param bool $isNew + * @return bool */ - public function setIsNewTransaction($isNew); + public function isManaged(): bool; /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort($rollbackOnAbort); + public function isValid(): bool; /** - * Checks whether transaction is managed by a transaction manager + * Rollbacks the transaction * + * @param string $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function isManaged(); + public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool; /** - * Returns validations messages from last save try + * Sets if is a reused transaction or new once * - * @return array + * @param bool $isNew */ - public function getMessages(); + public function setIsNewTransaction(bool $isNew); /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid(); + public function setRollbackOnAbort(bool $rollbackOnAbort); /** * Sets object which generates rollback action @@ -88,4 +82,19 @@ public function isValid(); */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); + + /** + * Enables throwing exception + * + * @param bool $status + * @return TransactionInterface + */ + public function throwRollbackException(bool $status): TransactionInterface; + } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index f491a341..e64943b7 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -11,32 +11,32 @@ class ValidationFailed extends \Phalcon\Mvc\Model\Exception { - protected $_model; + protected $messages; - protected $_messages; + protected $model; /** * Phalcon\Mvc\Model\ValidationFailed constructor * - * @param Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param Message[] $validationMessages */ - public function __construct(\Phalcon\Mvc\Model $model, array $validationMessages) {} + public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) {} /** - * Returns the model that generated the messages + * Returns the complete group of messages produced in the validation * - * @return \Phalcon\Mvc\Model + * @return array|Message[] */ - public function getModel() {} + public function getMessages(): array {} /** - * Returns the complete group of messages produced in the validation + * Returns the model that generated the messages * - * @return Message[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages() {} + public function getModel(): ModelInterface {} } diff --git a/src/Phalcon/mvc/model/Validator.php b/src/Phalcon/mvc/model/Validator.php deleted file mode 100644 index a5b17579..00000000 --- a/src/Phalcon/mvc/model/Validator.php +++ /dev/null @@ -1,73 +0,0 @@ - - * $metaData = new \Phalcon\Mvc\Model\Metadata\Apc( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * ] - * ); - * - * - * @deprecated Deprecated since 3.3.0, will be removed in 4.0.0 - * @see Phalcon\Mvc\Model\Metadata\Apcu - */ -class Apc extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Apc constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads meta-data from APC - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the meta-data to APC - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index d27a7af2..b676700d 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -11,48 +11,24 @@ * * You can query the meta-data by printing apcu_fetch('$PMM$') or apcu_fetch('$PMM$my-app-id') * - * - * $metaData = new \Phalcon\Mvc\Model\Metadata\Apcu( + * ```php + * $metaData = new \Phalcon\Mvc\Model\MetaData\Apcu( * [ * "prefix" => "my-app-id", * "lifetime" => 86400, * ] * ); - * + * ``` */ class Apcu extends \Phalcon\Mvc\Model\MetaData { - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Apcu constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads meta-data from APCu - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the meta-data to APCu - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) {} } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index ef4640b7..fad94fe0 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -8,61 +8,17 @@ * Stores model meta-data in the Memcache. * * By default meta-data is stored for 48 hours (172800 seconds) - * - * - * $metaData = new Phalcon\Mvc\Model\Metadata\Libmemcached( - * [ - * "servers" => [ - * [ - * "host" => "localhost", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * Memcached::OPT_HASH => Memcached::HASH_MD5, - * Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * */ class Libmemcached extends \Phalcon\Mvc\Model\MetaData { - protected $_ttl = 172800; - - - protected $_memcache = null; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Libmemcached constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads metadata from Memcache - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Memcache - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} /** * Flush Memcache data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Memcache.php b/src/Phalcon/mvc/model/metadata/Memcache.php deleted file mode 100644 index b846ab98..00000000 --- a/src/Phalcon/mvc/model/metadata/Memcache.php +++ /dev/null @@ -1,64 +0,0 @@ - - * $metaData = new Phalcon\Mvc\Model\Metadata\Memcache( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - */ -class Memcache extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_ttl = 172800; - - - protected $_memcache = null; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Memcache constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads metadata from Memcache - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Memcache - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} - - /** - * Flush Memcache data and resets internal meta-data in order to regenerate it - */ - public function reset() {} - -} diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index 57966816..c647040f 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -10,9 +10,6 @@ class Memory extends \Phalcon\Mvc\Model\MetaData { - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Memory constructor * @@ -24,9 +21,9 @@ public function __construct($options = null) {} * Reads the meta-data from temporal memory * * @param string $key - * @return array + * @return array|null */ - public function read($key) {} + public function read(string $key): ?array {} /** * Writes the meta-data to temporal memory @@ -34,6 +31,6 @@ public function read($key) {} * @param string $key * @param array $data */ - public function write($key, $data) {} + public function write(string $key, array $data) {} } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index 6b357aec..c32c0bca 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -9,55 +9,30 @@ * * By default meta-data is stored for 48 hours (172800 seconds) * - * - * use Phalcon\Mvc\Model\Metadata\Redis; + * ```php + * use Phalcon\Mvc\Model\MetaData\Redis; * * $metaData = new Redis( * [ * "host" => "127.0.0.1", * "port" => 6379, * "persistent" => 0, - * "statsKey" => "_PHCM_MM", * "lifetime" => 172800, * "index" => 2, * ] * ); - * + * ``` */ class Redis extends \Phalcon\Mvc\Model\MetaData { - protected $_ttl = 172800; - - - protected $_redis = null; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Redis constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads metadata from Redis - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Redis - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} /** * Flush Redis data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Session.php b/src/Phalcon/mvc/model/metadata/Session.php deleted file mode 100644 index 048388de..00000000 --- a/src/Phalcon/mvc/model/metadata/Session.php +++ /dev/null @@ -1,50 +0,0 @@ - - * $metaData = new \Phalcon\Mvc\Model\Metadata\Session( - * [ - * "prefix" => "my-app-id", - * ] - * ); - * - */ -class Session extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - /** - * Phalcon\Mvc\Model\MetaData\Session constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads meta-data from $_SESSION - * - * @param string $key - * @return array - */ - public function read($key) {} - - /** - * Writes the meta-data to $_SESSION - * - * @param string $key - * @param array $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/StrategyInterface.php index 82b2a4d6..9ba73ec4 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/StrategyInterface.php @@ -2,27 +2,34 @@ namespace Phalcon\Mvc\Model\MetaData; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ interface StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * + * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); + public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * - * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); + public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; } diff --git a/src/Phalcon/mvc/model/metadata/Files.php b/src/Phalcon/mvc/model/metadata/Stream.php similarity index 57% rename from src/Phalcon/mvc/model/metadata/Files.php rename to src/Phalcon/mvc/model/metadata/Stream.php index 419c3016..c14155d6 100644 --- a/src/Phalcon/mvc/model/metadata/Files.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -3,25 +3,22 @@ namespace Phalcon\Mvc\Model\MetaData; /** - * Phalcon\Mvc\Model\MetaData\Files + * Phalcon\Mvc\Model\MetaData\Stream * * Stores model meta-data in PHP files. * - * + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Files( * [ * "metaDataDir" => "app/cache/metadata/", * ] * ); - * + * ``` */ -class Files extends \Phalcon\Mvc\Model\MetaData +class Stream extends \Phalcon\Mvc\Model\MetaData { - protected $_metaDataDir = './'; - - - protected $_metaData = array(); + protected $metaDataDir = './'; /** @@ -35,9 +32,9 @@ public function __construct($options = null) {} * Reads meta-data from files * * @param string $key - * @return mixed + * @return array|null */ - public function read($key) {} + public function read(string $key): ?array {} /** * Writes the meta-data to files @@ -45,6 +42,13 @@ public function read($key) {} * @param string $key * @param array $data */ - public function write($key, $data) {} + public function write(string $key, array $data) {} + + /** + * Throws an exception when the metadata cannot be written + * + * @param mixed $option + */ + private function throwWriteException($option) {} } diff --git a/src/Phalcon/mvc/model/metadata/Xcache.php b/src/Phalcon/mvc/model/metadata/Xcache.php deleted file mode 100644 index bffa8d74..00000000 --- a/src/Phalcon/mvc/model/metadata/Xcache.php +++ /dev/null @@ -1,58 +0,0 @@ - - * $metaData = new Phalcon\Mvc\Model\Metadata\Xcache( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * ] - * ); - * - */ -class Xcache extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Xcache constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads metadata from XCache - * - * @param string $key - * @return array - */ - public function read($key) {} - - /** - * Writes the metadata to XCache - * - * @param string $key - * @param array $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index af7790fa..86f0806f 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -2,26 +2,33 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ class Annotations implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index 3f61fd1a..361aa28e 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -11,21 +11,21 @@ class Introspection implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index df6ecfc3..73447ad5 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -7,9 +7,11 @@ * * Helps to create PHQL queries using an OO interface * - * + * ```php * $params = [ - * "models" => ["Users"], + * "models" => [ + * Users::class, + * ], * "columns" => ["id", "name", "status"], * "conditions" => [ * [ @@ -34,111 +36,176 @@ * ]; * * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); - * + * ``` */ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $bindParams; - protected $_columns; + protected $bindTypes; - protected $_models; + protected $columns; - protected $_joins; - - /** - * @deprecated Will be removed in version 4.0.0 - */ - protected $_with; + protected $conditions; - protected $_conditions; + protected $container; - protected $_group; + protected $distinct; - protected $_having; + protected $forUpdate; - protected $_order; + /** + * @var array + */ + protected $group; - protected $_limit; + protected $having; - protected $_offset; + protected $hiddenParamNumber = 0; - protected $_forUpdate; + protected $joins; - protected $_sharedLock; + protected $limit; - protected $_bindParams; + protected $models; - protected $_bindTypes; + protected $offset; - protected $_distinct; + protected $order; - protected $_hiddenParamNumber = 0; + protected $sharedLock; /** * Phalcon\Mvc\Model\Query\Builder constructor * * @param mixed $params - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function __construct($params = null, \Phalcon\DiInterface $dependencyInjector = null) {} + public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) {} /** - * Sets the DependencyInjector container + * Add a model to take part of the query + * + * ```php + * // Load data from models Robots + * $builder->addFrom( + * Robots::class + * ); * - * @param \Phalcon\DiInterface $dependencyInjector - * @return Builder + * // Load data from model 'Robots' using 'r' as alias in PHQL + * $builder->addFrom( + * Robots::class, + * "r" + * ); + * ``` + * + * @param string $model + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function addFrom(string $model, string $alias = null): BuilderInterface {} /** - * Returns the DependencyInjector container + * Appends a condition to the current HAVING conditions clause using a AND operator * - * @return \Phalcon\DiInterface + * ```php + * $builder->andHaving("SUM(Robots.price) > 0"); + * + * $builder->andHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getDI() {} + public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets SELECT DISTINCT / SELECT ALL flag + * Appends a condition to the current WHERE conditions using a AND operator * - * - * $builder->distinct("status"); - * $builder->distinct(null); - * + * ```php + * $builder->andWhere("name = 'Peter'"); * - * @param mixed $distinct - * @return Builder + * $builder->andWhere( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function distinct($distinct) {} + public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Returns SELECT DISTINCT / SELECT ALL flag + * Automatically escapes identifiers but only if they need to be escaped. * - * @return bool + * @param string $identifier + * @return string + */ + final public function autoescape(string $identifier): string {} + + /** + * Appends a BETWEEN condition to the current HAVING conditions clause + * + * ```php + * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getDistinct() {} + public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + + /** + * Appends a BETWEEN condition to the current WHERE conditions + * + * ```php + * $builder->betweenWhere("price", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\BuilderInterface + */ + public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** * Sets the columns to be queried * - * + * ```php * $builder->columns("id, name"); * * $builder->columns( @@ -154,65 +221,100 @@ public function getDistinct() {} * "number" => "COUNT()", * ] * ); - * + * ``` * * @param mixed $columns - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function columns($columns) {} + public function columns($columns): BuilderInterface {} /** - * Return the columns to be queried + * Sets SELECT DISTINCT / SELECT ALL flag * - * @return string|array + * ```php + * $builder->distinct("status"); + * $builder->distinct(null); + * ``` + * + * @param mixed $distinct + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getColumns() {} + public function distinct($distinct): BuilderInterface {} + + /** + * Sets a FOR UPDATE clause + * + * ```php + * $builder->forUpdate(true); + * ``` + * + * @param bool $forUpdate + * @return \Phalcon\Mvc\Model\Query\BuilderInterface + */ + public function forUpdate(bool $forUpdate): BuilderInterface {} /** * Sets the models who makes part of the query * - * - * $builder->from("Robots"); + * ```php + * $builder->from( + * Robots::class + * ); * * $builder->from( * [ - * "Robots", - * "RobotsParts", + * Robots::class, + * RobotsParts::class, * ] * ); * * $builder->from( * [ - * "r" => "Robots", - * "rp" => "RobotsParts", + * "r" => Robots::class, + * "rp" => RobotsParts::class, * ] * ); - * + * ``` * * @param mixed $models - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function from($models) {} + public function from($models): BuilderInterface {} /** - * Add a model to take part of the query + * Returns default bind params * - * NOTE: The third parameter $with is deprecated and will be removed in future releases. + * @return array + */ + public function getBindParams(): array {} + + /** + * Returns default bind types * - * - * // Load data from models Robots - * $builder->addFrom("Robots"); + * @return array + */ + public function getBindTypes(): array {} + + /** + * Return the columns to be queried * - * // Load data from model 'Robots' using 'r' as alias in PHQL - * $builder->addFrom("Robots", "r"); - * + * @return string|array + */ + public function getColumns() {} + + /** + * Returns the DependencyInjector container * - * @param mixed $model - * @param mixed $alias - * @param mixed $with - * @return Builder + * @return \Phalcon\Di\DiInterface */ - public function addFrom($model, $alias = null, $with = null) {} + public function getDI(): DiInterface {} + + /** + * Returns SELECT DISTINCT / SELECT ALL flag + * + * @return bool + */ + public function getDistinct(): bool {} /** * Return the models who makes part of the query @@ -222,466 +324,439 @@ public function addFrom($model, $alias = null, $with = null) {} public function getFrom() {} /** - * Adds an :type: join (by default type - INNER) to the query - * - * - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->join("Robots"); - * - * // Inner Join model 'Robots' specifying conditions - * $builder->join("Robots", "Robots.id = RobotsParts.robots_id"); - * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r"); - * - * // Left Join model 'Robots' specifying conditions, alias and type of join - * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); - * + * Returns the GROUP BY clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return Builder + * @return array */ - public function join($model, $conditions = null, $alias = null, $type = null) {} + public function getGroupBy(): array {} /** - * Adds an INNER join to the query - * - * - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->innerJoin("Robots"); - * - * // Inner Join model 'Robots' specifying conditions - * $builder->innerJoin("Robots", "Robots.id = RobotsParts.robots_id"); - * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Return the current having clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return Builder + * @return string */ - public function innerJoin($model, $conditions = null, $alias = null) {} + public function getHaving(): string {} /** - * Adds a LEFT join to the query - * - * - * $builder->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Return join parts of the query * - * @param string $model - * @param string $conditions - * @param string $alias - * @return Builder + * @return array */ - public function leftJoin($model, $conditions = null, $alias = null) {} + public function getJoins(): array {} /** - * Adds a RIGHT join to the query - * - * - * $builder->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Returns the current LIMIT clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return Builder + * @return string|array */ - public function rightJoin($model, $conditions = null, $alias = null) {} + public function getLimit() {} /** - * Return join parts of the query + * Returns the models involved in the query * - * @return array + * @return string|array|null */ - public function getJoins() {} + public function getModels() {} /** - * Sets the query WHERE conditions + * Returns the current OFFSET clause * - * - * $builder->where(100); + * @return int + */ + public function getOffset(): int {} + + /** + * Returns the set ORDER BY clause * - * $builder->where("name = 'Peter'"); + * @return string|array + */ + public function getOrderBy() {} + + /** + * Returns a PHQL statement built based on the builder parameters * - * $builder->where( - * "name = :name: AND id > :id:", - * [ - * "name" => "Peter", - * "id" => 100, - * ] - * ); - * + * @return string + */ + final public function getPhql(): string {} + + /** + * Returns the query built * - * @param mixed $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null) {} + public function getQuery(): QueryInterface {} /** - * Appends a condition to the current WHERE conditions using a AND operator + * Return the conditions for the query * - * - * $builder->andWhere("name = 'Peter'"); + * @return string|array + */ + public function getWhere() {} + + /** + * Sets a GROUP BY clause * - * $builder->andWhere( - * "name = :name: AND id > :id:", + * ```php + * $builder->groupBy( * [ - * "name" => "Peter", - * "id" => 100, + * "Robots.name", * ] * ); - * + * ``` * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string|array $group + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function groupBy($group): BuilderInterface {} /** - * Appends a condition to the current conditions using an OR operator + * Sets the HAVING condition clause * - * - * $builder->orWhere("name = 'Peter'"); + * ```php + * $builder->having("SUM(Robots.price) > 0"); * - * $builder->orWhere( - * "name = :name: AND id > :id:", + * $builder->having( + * "SUM(Robots.price) > :sum:", * [ - * "name" => "Peter", - * "id" => 100, + * "sum" => 100, * ] * ); - * + * ``` * - * @param string $conditions + * @param mixed $conditions * @param array $bindParams * @param array $bindTypes - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Appends a BETWEEN condition to the current WHERE conditions + * Appends an IN condition to the current HAVING conditions clause * - * - * $builder->betweenWhere("price", 100.25, 200.50); - * + * ```php + * $builder->inHaving("SUM(Robots.price)", [100, 200]); + * ``` * * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT BETWEEN condition to the current WHERE conditions + * Adds an INNER join to the query * - * - * $builder->notBetweenWhere("price", 100.25, 200.50); - * + * ```php + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->innerJoin( + * Robots::class + * ); * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return Builder - */ - public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} - - /** - * Appends an IN condition to the current WHERE conditions + * // Inner Join model 'Robots' specifying conditions + * $builder->innerJoin( + * Robots::class, + * "Robots.id = RobotsParts.robots_id" + * ); * - * - * $builder->inWhere("id", [1, 2, 3]); - * + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * - * @param string $expr - * @param array $values - * @param string $operator + * @param string $model + * @param string $conditions + * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Appends a NOT IN condition to the current WHERE conditions + * Appends an IN condition to the current WHERE conditions * - * - * $builder->notInWhere("id", [1, 2, 3]); - * + * ```php + * $builder->inWhere( + * "id", + * [1, 2, 3] + * ); + * ``` * * @param string $expr * @param array $values * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Return the conditions for the query - * - * @return string|array - */ - public function getWhere() {} - - /** - * Sets an ORDER BY condition clause - * - * - * $builder->orderBy("Robots.name"); - * $builder->orderBy(["1", "Robots.name"]); - * $builder->orderBy(["Robots.name DESC"]); - * + * Adds an :type: join (by default type - INNER) to the query * - * @param string|array $orderBy - * @return Builder - */ - public function orderBy($orderBy) {} - - /** - * Returns the set ORDER BY clause + * ```php + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->join( + * Robots::class + * ); * - * @return string|array - */ - public function getOrderBy() {} - - /** - * Sets the HAVING condition clause + * // Inner Join model 'Robots' specifying conditions + * $builder->join( + * Robots::class, + * "Robots.id = RobotsParts.robots_id" + * ); * - * - * $builder->having("SUM(Robots.price) > 0"); + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); * - * $builder->having( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] + * // Left Join model 'Robots' specifying conditions, alias and type of join + * $builder->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r", + * "LEFT" * ); - * + * ``` * - * @param mixed $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function having($conditions, $bindParams = null, $bindTypes = null) {} + public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface {} /** - * Appends a condition to the current HAVING conditions clause using a AND operator - * - * - * $builder->andHaving("SUM(Robots.price) > 0"); + * Adds a LEFT join to the query * - * $builder->andHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] + * ```php + * $builder->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" * ); - * + * ``` * + * @param string $model * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andHaving($conditions, $bindParams = null, $bindTypes = null) {} + public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Appends a condition to the current HAVING conditions clause using an OR operator - * - * - * $builder->orHaving("SUM(Robots.price) > 0"); + * Sets a LIMIT clause, optionally an offset clause * - * $builder->orHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] - * ); - * + * ```php + * $builder->limit(100); + * $builder->limit(100, 20); + * $builder->limit("100", "20"); + * ``` * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param int $limit + * @param mixed $offset + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orHaving($conditions, $bindParams = null, $bindTypes = null) {} + public function limit(int $limit, $offset = null): BuilderInterface {} /** - * Appends a BETWEEN condition to the current HAVING conditions clause + * Appends a NOT BETWEEN condition to the current HAVING conditions clause * - * - * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); - * + * ```php + * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT BETWEEN condition to the current HAVING conditions clause + * Appends a NOT BETWEEN condition to the current WHERE conditions * - * - * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); - * + * ```php + * $builder->notBetweenWhere("price", 100.25, 200.50); + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notBetweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends an IN condition to the current HAVING conditions clause + * Appends a NOT IN condition to the current HAVING conditions clause * - * - * $builder->inHaving("SUM(Robots.price)", [100, 200]); - * + * ```php + * $builder->notInHaving("SUM(Robots.price)", [100, 200]); + * ``` * * @param string $expr * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT IN condition to the current HAVING conditions clause + * Appends a NOT IN condition to the current WHERE conditions * - * - * $builder->notInHaving("SUM(Robots.price)", [100, 200]); - * + * ```php + * $builder->notInWhere("id", [1, 2, 3]); + * ``` * * @param string $expr * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Return the current having clause + * Sets an OFFSET clause * - * @return string + * ```php + * $builder->offset(30); + * ``` + * + * @param int $offset + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getHaving() {} + public function offset(int $offset): BuilderInterface {} /** - * Sets a FOR UPDATE clause + * Sets an ORDER BY condition clause * - * - * $builder->forUpdate(true); - * + * ```php + * $builder->orderBy("Robots.name"); + * $builder->orderBy(["1", "Robots.name"]); + * $builder->orderBy(["Robots.name DESC"]); + * ``` * - * @param bool $forUpdate - * @return Builder + * @param string|array $orderBy + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function forUpdate($forUpdate) {} + public function orderBy($orderBy): BuilderInterface {} /** - * Sets a LIMIT clause, optionally an offset clause + * Appends a condition to the current HAVING conditions clause using an OR operator * - * - * $builder->limit(100); - * $builder->limit(100, 20); - * $builder->limit("100", "20"); - * + * ```php + * $builder->orHaving("SUM(Robots.price) > 0"); * - * @param int $limit - * @param mixed $offset - * @return Builder - */ - public function limit($limit, $offset = null) {} - - /** - * Returns the current LIMIT clause + * $builder->orHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] + * ); + * ``` * - * @return string|array + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getLimit() {} + public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets an OFFSET clause + * Appends a condition to the current conditions using an OR operator * - * - * $builder->offset(30); - * + * ```php + * $builder->orWhere("name = 'Peter'"); * - * @param int $offset - * @return Builder - */ - public function offset($offset) {} - - /** - * Returns the current OFFSET clause + * $builder->orWhere( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` * - * @return string|array + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getOffset() {} + public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets a GROUP BY clause + * Adds a RIGHT join to the query * - * - * $builder->groupBy( - * [ - * "Robots.name", - * ] + * ```php + * $builder->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" * ); - * + * ``` * - * @param string|array $group - * @return Builder + * @param string $model + * @param string $conditions + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function groupBy($group) {} + public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Returns the GROUP BY clause + * Set default bind parameters * - * @return string + * @param array $bindParams + * @param bool $merge + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getGroupBy() {} + public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface {} /** - * Returns a PHQL statement built based on the builder parameters + * Set default bind types * - * @return string + * @param array $bindTypes + * @param bool $merge + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public final function getPhql() {} + public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface {} /** - * Returns the query built + * Sets the DependencyInjector container * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getQuery() {} + public function setDI(\Phalcon\Di\DiInterface $container): BuilderInterface {} /** - * Automatically escapes identifiers but only if they need to be escaped. + * Sets the query WHERE conditions * - * @param string $identifier - * @return string + * ```php + * $builder->where(100); + * + * $builder->where("name = 'Peter'"); + * + * $builder->where( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - final public function autoescape($identifier) {} + public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** * Appends a BETWEEN condition @@ -691,32 +766,32 @@ final public function autoescape($identifier) {} * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionBetween($clause, $operator, $expr, $minimum, $maximum) {} + protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} /** - * Appends a NOT BETWEEN condition + * Appends an IN condition * * @param string $clause * @param string $operator * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @return Builder + * @param array $values + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionNotBetween($clause, $operator, $expr, $minimum, $maximum) {} + protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} /** - * Appends an IN condition + * Appends a NOT BETWEEN condition * * @param string $clause * @param string $operator * @param string $expr - * @param array $values - * @return Builder + * @param mixed $minimum + * @param mixed $maximum + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionIn($clause, $operator, $expr, array $values) {} + protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} /** * Appends a NOT IN condition @@ -725,8 +800,8 @@ protected function _conditionIn($clause, $operator, $expr, array $values) {} * @param string $operator * @param string $expr * @param array $values - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionNotIn($clause, $operator, $expr, array $values) {} + protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index ced90250..636c17c6 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -10,151 +10,206 @@ interface BuilderInterface { + const OPERATOR_AND = 'and'; + + const OPERATOR_OR = 'or'; - const OPERATOR_AND = 'and'; + /** + * Add a model to take part of the query + * + * @param string $model + * @param string $alias + * @return BuilderInterface + */ + public function addFrom(string $model, string $alias = null): BuilderInterface; + + /** + * Appends a condition to the current conditions using a AND operator + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface + */ + public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + /** + * Appends a BETWEEN condition to the current conditions + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return BuilderInterface + */ + public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** * Sets the columns to be queried * * @param string|array $columns - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function columns($columns); + public function columns($columns): BuilderInterface; /** - * Return the columns to be queried + * Sets SELECT DISTINCT / SELECT ALL flag * - * @return string|array + * ```php + * $builder->distinct("status"); + * $builder->distinct(null); + * ``` + * + * @param mixed $distinct + * @return BuilderInterface */ - public function getColumns(); + public function distinct($distinct): BuilderInterface; + + /** + * Sets a FOR UPDATE clause + * + * ```php + * $builder->forUpdate(true); + * ``` + * + * @param bool $forUpdate + * @return BuilderInterface + */ + public function forUpdate(bool $forUpdate): BuilderInterface; /** * Sets the models who makes part of the query * * @param string|array $models - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function from($models); + public function from($models): BuilderInterface; /** - * Add a model to take part of the query + * Returns default bind params * - * @param string $model - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return array */ - public function addFrom($model, $alias = null); + public function getBindParams(): array; /** - * Return the models who makes part of the query + * Returns default bind types + * + * @return array + */ + public function getBindTypes(): array; + + /** + * Return the columns to be queried * * @return string|array */ - public function getFrom(); + public function getColumns(); /** - * Adds an :type: join (by default type - INNER) to the query + * Returns SELECT DISTINCT / SELECT ALL flag * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return bool */ - public function join($model, $conditions = null, $alias = null, $type = null); + public function getDistinct(): bool; /** - * Adds an INNER join to the query + * Return the models who makes part of the query * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string|array */ - public function innerJoin($model, $conditions = null, $alias = null); + public function getFrom(); /** - * Adds a LEFT join to the query + * Returns the GROUP BY clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\Builder + * @return array */ - public function leftJoin($model, $conditions = null, $alias = null); + public function getGroupBy(): array; /** - * Adds a RIGHT join to the query + * Returns the HAVING condition clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string */ - public function rightJoin($model, $conditions = null, $alias = null); + public function getHaving(): string; /** * Return join parts of the query * * @return array */ - public function getJoins(); + public function getJoins(): array; /** - * Sets conditions for the query + * Returns the current LIMIT clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string|array */ - public function where($conditions, $bindParams = null, $bindTypes = null); + public function getLimit(); /** - * Appends a condition to the current conditions using a AND operator + * Returns the current OFFSET clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\Builder + * @return int */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null); + public function getOffset(): int; /** - * Appends a condition to the current conditions using an OR operator + * Return the set ORDER BY clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string|array */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null); + public function getOrderBy(); /** - * Appends a BETWEEN condition to the current conditions + * Returns a PHQL statement built based on the builder parameters * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string */ - public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); + public function getPhql(): string; /** - * Appends a NOT BETWEEN condition to the current conditions + * Returns the query built * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\Builder + * @return \Phalcon\Mvc\Model\QueryInterface + */ + public function getQuery(): QueryInterface; + + /** + * Return the conditions for the query + * + * @return string|array + */ + public function getWhere(); + + /** + * Sets a GROUP BY clause + * + * @param string|array $group + * @return BuilderInterface + */ + public function groupBy($group): BuilderInterface; + + /** + * Sets a HAVING condition clause + * + * @param string $having + * @return BuilderInterface + */ + public function having(string $having): BuilderInterface; + + /** + * Adds an INNER join to the query + * + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); + public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** * Appends an IN condition to the current conditions @@ -164,98 +219,128 @@ public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderIn * @param string $operator * @return BuilderInterface */ - public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); + public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Appends a NOT IN condition to the current conditions + * Adds an :type: join (by default type - INNER) to the query * - * @param string $expr - * @param array $values - * @param string $operator + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type * @return BuilderInterface */ - public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); + public function join(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Return the conditions for the query + * Adds a LEFT join to the query * - * @return string|array + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function getWhere(); + public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Sets an ORDER BY condition clause + * Sets a LIMIT clause * - * @param string $orderBy - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param int $limit + * @param int $offset + * @return BuilderInterface */ - public function orderBy($orderBy); + public function limit(int $limit, $offset = null): BuilderInterface; /** - * Return the set ORDER BY clause + * Returns the models involved in the query * - * @return string|array + * @return string|array|null */ - public function getOrderBy(); + public function getModels(); /** - * Sets a HAVING condition clause + * Appends a NOT BETWEEN condition to the current conditions * - * @param string $having - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return BuilderInterface */ - public function having($having); + public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Returns the HAVING condition clause + * Appends a NOT IN condition to the current conditions * - * @return string|array + * @param string $expr + * @param array $values + * @param string $operator + * @return BuilderInterface */ - public function getHaving(); + public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Sets a LIMIT clause + * Sets an OFFSET clause * - * @param int $limit * @param int $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function limit($limit, $offset = null); + public function offset(int $offset): BuilderInterface; /** - * Returns the current LIMIT clause + * Sets an ORDER BY condition clause * - * @return string|array + * @param string $orderBy + * @return BuilderInterface */ - public function getLimit(); + public function orderBy(string $orderBy): BuilderInterface; /** - * Sets a LIMIT clause + * Appends a condition to the current conditions using an OR operator * - * @param string|array $group - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface */ - public function groupBy($group); + public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; /** - * Returns the GROUP BY clause + * Adds a RIGHT join to the query * - * @return string + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function getGroupBy(); + public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Returns a PHQL statement built based on the builder parameters + * Set default bind parameters * - * @return string + * @param array $bindParams + * @param bool $merge + * @return BuilderInterface */ - public function getPhql(); + public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface; /** - * Returns the query built + * Set default bind types * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param array $bindTypes + * @param bool $merge + * @return BuilderInterface + */ + public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface; + + /** + * Sets conditions for the query + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface */ - public function getQuery(); + public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 5f453526..28727de1 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -15,9 +15,11 @@ * the same technology as SQLite. This technology provides a small in-memory * parser with a very low memory footprint that is also thread-safe. * - * - * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL("SELECT r. FROM Robots r LIMIT 10"); - * + * ```php + * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL( + * "SELECT r. FROM Robots r LIMIT 10" + * ); + * ``` */ abstract class Lang { @@ -28,6 +30,6 @@ abstract class Lang * @param string $phql * @return string */ - public static function parsePHQL($phql) {} + public static function parsePHQL(string $phql): string {} } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index ba75ee6d..f902467d 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -10,7 +10,7 @@ * information and the related messages produced by the * model which finally executes the operations when it fails * - * + * ```php * $phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:"; * * $status = $app->modelsManager->executeQuery( @@ -24,18 +24,18 @@ * ); * * // Check if the update was successful - * if ($status->success() === true) { + * if ($status->success()) { * echo "OK"; * } - * + * ``` */ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { - protected $_success; + protected $model; - protected $_model; + protected $success; /** @@ -44,27 +44,27 @@ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface * @param bool $success * @param \Phalcon\Mvc\ModelInterface $model */ - public function __construct($success, \Phalcon\Mvc\ModelInterface $model = null) {} + public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) {} /** - * Returns the model that executed the action + * Returns the messages produced because of a failed operation * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getModel() {} + public function getMessages(): array {} /** - * Returns the messages produced because of a failed operation + * Returns the model that executed the action * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages() {} + public function getModel(): ModelInterface {} /** * Allows to check if the executed operation was successful * * @return bool */ - public function success() {} + public function success(): bool {} } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index b2980bec..1f16632c 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -11,24 +11,24 @@ interface StatusInterface { /** - * Returns the model which executed the action + * Returns the messages produced by an operation failed * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getModel(); + public function getMessages(): array; /** - * Returns the messages produced by an operation failed + * Returns the model which executed the action * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages(); + public function getModel(): ModelInterface; /** * Allows to check if the executed operation was successful * * @return bool */ - public function success(); + public function success(): bool; } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 793e38d0..7f057733 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -11,12 +11,13 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model\ResultsetInterface { - protected $_columnTypes; + protected $columnTypes; /** - * Unserialised result-set hydrated all rows already. unserialise() sets _disableHydration to true + * Unserialised result-set hydrated all rows already. unserialise() sets + * disableHydration to true */ - protected $_disableHydration = false; + protected $disableHydration = false; /** @@ -24,31 +25,31 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model * * @param array $columnTypes * @param \Phalcon\Db\ResultInterface $result - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\BackendInterface $cache = null) {} + public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** * Returns current row in the resultset * * @return bool|ModelInterface */ - public final function current() {} + final public function current() {} /** - * Returns a complete resultset as an array, if the resultset has a big number of rows - * it could consume more memory than currently it does. + * Returns a complete resultset as an array, if the resultset has a big + * number of rows it could consume more memory than currently it does. * * @return array */ - public function toArray() {} + public function toArray(): array {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize() {} + public function serialize(): string {} /** * Unserializing a resultset will allow to only works on the rows present in the saved state diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 8d377287..1209af8a 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -11,13 +11,15 @@ class Simple extends \Phalcon\Mvc\Model\Resultset { - protected $_model; + protected $columnMap; - protected $_columnMap; + protected $model; - - protected $_keepSnapshots = false; + /** + * @var bool + */ + protected $keepSnapshots = false; /** @@ -25,38 +27,40 @@ class Simple extends \Phalcon\Mvc\Model\Resultset * * @param array $columnMap * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $model - * @param \Phalcon\Db\Result\Pdo|null $result - * @param \Phalcon\Cache\BackendInterface $cache - * @param boolean $keepSnapshots + * @param mixed $result + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param bool $keepSnapshots */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\BackendInterface $cache = null, $keepSnapshots = null) {} + public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) {} /** * Returns current row in the resultset * - * @return bool|ModelInterface + * @return null|ModelInterface */ - public final function current() {} + final public function current(): ?ModelInterface {} /** - * Returns a complete resultset as an array, if the resultset has a big number of rows - * it could consume more memory than currently it does. Export the resultset to an array - * couldn't be faster with a large number of records + * Returns a complete resultset as an array, if the resultset has a big + * number of rows it could consume more memory than currently it does. + * Export the resultset to an array couldn't be faster with a large number + * of records * * @param bool $renameColumns * @return array */ - public function toArray($renameColumns = true) {} + public function toArray(bool $renameColumns = true): array {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize() {} + public function serialize(): string {} /** - * Unserializing a resultset will allow to only works on the rows present in the saved state + * Unserializing a resultset will allow to only works on the rows present in + * the saved state * * @param mixed $data */ diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 725b413e..08fa28f4 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -10,7 +10,7 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception { - protected $_record = null; + protected $record = null; /** @@ -19,20 +19,20 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception * @param string $message * @param \Phalcon\Mvc\ModelInterface $record */ - public function __construct($message, \Phalcon\Mvc\ModelInterface $record = null) {} + public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) {} /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getRecordMessages() {} + public function getRecord(): ModelInterface {} /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getRecord() {} + public function getRecordMessages(): array {} } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index faf1aa4a..31af4afd 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -5,14 +5,15 @@ /** * Phalcon\Mvc\Model\Transaction\Manager * - * A transaction acts on a single database connection. If you have multiple class-specific - * databases, the transaction will not protect interaction among them. + * A transaction acts on a single database connection. If you have multiple + * class-specific databases, the transaction will not protect interaction among + * them. * * This class manages the objects that compose a transaction. - * A transaction produces a unique connection that is passed to every - * object part of the transaction. + * A transaction produces a unique connection that is passed to every object + * part of the transaction. * - * + * ```php * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -28,7 +29,7 @@ * $robot->name = "WALL·E"; * $robot->created_at = date("Y-m-d"); * - * if ($robot->save() === false){ + * if ($robot->save() === false) { * $transaction->rollback("Can't save robot"); * } * @@ -46,146 +47,150 @@ * } catch (Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` */ class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; + protected $container; - protected $_initialized = false; + protected $initialized = false; - protected $_rollbackPendent = true; + protected $number = 0; - protected $_number = 0; + protected $rollbackPendent = true; - protected $_service = 'db'; + protected $service = 'db'; - - protected $_transactions; + /** + * @var array + */ + protected $transactions = array(); /** * Phalcon\Mvc\Model\Transaction\Manager constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) {} /** - * Sets the dependency injection container - * - * @param \Phalcon\DiInterface $dependencyInjector + * Remove all the transactions from the manager */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function collectTransactions() {} /** - * Returns the dependency injection container - * - * @return \Phalcon\DiInterface + * Commits active transactions within the manager */ - public function getDI() {} + public function commit() {} /** - * Sets the database service used to run the isolated transactions + * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once + * This method registers a shutdown function to rollback active connections * - * @param string $service - * @return Manager + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function setDbService($service) {} + public function get(bool $autoBegin = true): TransactionInterface {} /** * Returns the database service used to isolate the transaction * * @return string */ - public function getDbService() {} + public function getDbService(): string {} /** - * Set if the transaction manager must register a shutdown function to clean up pendent transactions + * Returns the dependency injection container * - * @param bool $rollbackPendent - * @return Manager + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Create/Returns a new transaction or an existing one + * + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function setRollbackPendent($rollbackPendent) {} + public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface {} /** - * Check if the transaction manager is registering a shutdown function to clean up pendent transactions + * Check if the transaction manager is registering a shutdown function to + * clean up pendent transactions * * @return bool */ - public function getRollbackPendent() {} + public function getRollbackPendent(): bool {} /** * Checks whether the manager has an active transaction * * @return bool */ - public function has() {} + public function has(): bool {} /** - * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once - * This method registers a shutdown function to rollback active connections + * Notifies the manager about a committed transaction * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function get($autoBegin = true) {} + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** - * Create/Returns a new transaction or an existing one + * Notifies the manager about a rollbacked transaction * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function getOrCreateTransaction($autoBegin = true) {} + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** * Rollbacks active transactions within the manager + * Collect will remove the transaction from the manager + * + * @param bool $collect */ - public function rollbackPendent() {} + public function rollback(bool $collect = true) {} /** - * Commits active transactions within the manager + * Rollbacks active transactions within the manager */ - public function commit() {} + public function rollbackPendent() {} /** - * Rollbacks active transactions within the manager - * Collect will remove the transaction from the manager + * Sets the database service used to run the isolated transactions * - * @param boolean $collect + * @param string $service + * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function rollback($collect = true) {} + public function setDbService(string $service): ManagerInterface {} /** - * Notifies the manager about a rollbacked transaction + * Sets the dependency injection container * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param \Phalcon\Di\DiInterface $container */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Notifies the manager about a committed transaction + * Set if the transaction manager must register a shutdown function to clean + * up pendent transactions * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $rollbackPendent + * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setRollbackPendent(bool $rollbackPendent): ManagerInterface {} /** * Removes transactions from the TransactionManager * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - protected function _collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} - - /** - * Remove all the transactions from the manager - */ - public function collectTransactions() {} + protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index d2c1b841..21fa668d 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -11,11 +11,14 @@ interface ManagerInterface { /** - * Checks whether manager has an active transaction - * - * @return bool + * Remove all the transactions from the manager + */ + public function collectTransactions(); + + /** + * Commits active transactions within the manager */ - public function has(); + public function commit(); /** * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once @@ -23,25 +26,35 @@ public function has(); * @param bool $autoBegin * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function get($autoBegin = true); + public function get(bool $autoBegin = true): TransactionInterface; /** - * Rollbacks active transactions within the manager + * Returns the database service used to isolate the transaction + * + * @return string */ - public function rollbackPendent(); + public function getDbService(): string; /** - * Commits active transactions within the manager + * Check if the transaction manager is registering a shutdown function to clean up pendent transactions + * + * @return bool */ - public function commit(); + public function getRollbackPendent(): bool; /** - * Rollbacks active transactions within the manager - * Collect will remove transaction from the manager + * Checks whether manager has an active transaction * - * @param boolean $collect + * @return bool */ - public function rollback($collect = false); + public function has(): bool; + + /** + * Notifies the manager about a committed transaction + * + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + */ + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** * Notifies the manager about a rollbacked transaction @@ -51,15 +64,32 @@ public function rollback($collect = false); public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** - * Notifies the manager about a committed transaction + * Rollbacks active transactions within the manager + * Collect will remove transaction from the manager * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $collect */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function rollback(bool $collect = false); /** - * Remove all the transactions from the manager + * Rollbacks active transactions within the manager */ - public function collectTransactions(); + public function rollbackPendent(); + + /** + * Sets the database service used to run the isolated transactions + * + * @param string $service + * @return ManagerInterface + */ + public function setDbService(string $service): ManagerInterface; + + /** + * Set if the transaction manager must register a shutdown function to clean up pendent transactions + * + * @param bool $rollbackPendent + * @return ManagerInterface + */ + public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; } diff --git a/src/Phalcon/mvc/model/validator/Email.php b/src/Phalcon/mvc/model/validator/Email.php deleted file mode 100644 index 62825bce..00000000 --- a/src/Phalcon/mvc/model/validator/Email.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Email as EmailValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new EmailValidator( - * [ - * "field" => "electronic_mail", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Email - */ -class Email extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Exclusionin.php b/src/Phalcon/mvc/model/validator/Exclusionin.php deleted file mode 100644 index cd444ce3..00000000 --- a/src/Phalcon/mvc/model/validator/Exclusionin.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionInValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new ExclusionInValidator( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\EclusionIn - */ -class Exclusionin extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Inclusionin.php b/src/Phalcon/mvc/model/validator/Inclusionin.php deleted file mode 100644 index d506ab45..00000000 --- a/src/Phalcon/mvc/model/validator/Inclusionin.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\InclusionIn as InclusionInValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new InclusionInValidator( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\InclusionIn - */ -class Inclusionin extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Ip.php b/src/Phalcon/mvc/model/validator/Ip.php deleted file mode 100644 index f6ca5e5d..00000000 --- a/src/Phalcon/mvc/model/validator/Ip.php +++ /dev/null @@ -1,82 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Ip; - * - * class Data extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * // Any pubic IP - * $this->validate( - * new IP( - * [ - * "field" => "server_ip", - * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified - * "allowReserved" => false, // False if not specified. Ignored for v6 - * "allowPrivate" => false, // False if not specified - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * // Any public v4 address - * $this->validate( - * new IP( - * [ - * "field" => "ip_4", - * "version" => IP::VERSION_4, - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * // Any v6 address - * $this->validate( - * new IP( - * [ - * "field" => "ip6", - * "version" => IP::VERSION_6, - * "allowPrivate" => true, - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - */ -class Ip extends \Phalcon\Mvc\Model\Validator -{ - - const VERSION_4 = 1048576; - - - const VERSION_6 = 2097152; - - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Numericality.php b/src/Phalcon/mvc/model/validator/Numericality.php deleted file mode 100644 index 9878eac2..00000000 --- a/src/Phalcon/mvc/model/validator/Numericality.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Numericality as NumericalityValidator; - * - * class Products extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new NumericalityValidator( - * [ - * "field" => "price", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Numericality - */ -class Numericality extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/PresenceOf.php b/src/Phalcon/mvc/model/validator/PresenceOf.php deleted file mode 100644 index 229e417c..00000000 --- a/src/Phalcon/mvc/model/validator/PresenceOf.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\PresenceOf; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new PresenceOf( - * [ - * "field" => "name", - * "message" => "The name is required", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\PresenceOf - */ -class PresenceOf extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Regex.php b/src/Phalcon/mvc/model/validator/Regex.php deleted file mode 100644 index 64b6ee12..00000000 --- a/src/Phalcon/mvc/model/validator/Regex.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Regex as RegexValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new RegexValidator( - * [ - * "field" => "created_at", - * "pattern" => "/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])/", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Regex - */ -class Regex extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/StringLength.php b/src/Phalcon/mvc/model/validator/StringLength.php deleted file mode 100644 index 91a7701f..00000000 --- a/src/Phalcon/mvc/model/validator/StringLength.php +++ /dev/null @@ -1,53 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\StringLength as StringLengthValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new StringLengthValidator( - * [ - * "field" => "name_last", - * "max" => 50, - * "min" => 2, - * "messageMaximum" => "We don't like really long names", - * "messageMinimum" => "We want more than just their initials", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\StringLength - */ -class StringLength extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Uniqueness.php b/src/Phalcon/mvc/model/validator/Uniqueness.php deleted file mode 100644 index c9cb687b..00000000 --- a/src/Phalcon/mvc/model/validator/Uniqueness.php +++ /dev/null @@ -1,52 +0,0 @@ - - * use Phalcon\Mvc\Collection; - * use Phalcon\Mvc\Model\Validator\Uniqueness; - * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $this->validate( - * new Uniqueness( - * [ - * "field" => "email", - * "message" => "Value of field 'email' is already present in another record", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Uniqueness - */ -class Uniqueness extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Url.php b/src/Phalcon/mvc/model/validator/Url.php deleted file mode 100644 index 28ee074f..00000000 --- a/src/Phalcon/mvc/model/validator/Url.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Url as UrlValidator; - * - * class Posts extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new UrlValidator( - * [ - * "field" => "source_url", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Url - */ -class Url extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 18c4db8c..b8adad00 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -7,7 +7,7 @@ * * A router that reads routes annotations from classes/resources * - * + * ```php * use Phalcon\Mvc\Router\Annotations; * * $di->setShared( @@ -22,59 +22,58 @@ * return $router; * } * ); - * + * ``` */ class Annotations extends \Phalcon\Mvc\Router { - protected $_handlers = array(); + protected $actionSuffix = 'Action'; - protected $_controllerSuffix = 'Controller'; + protected $controllerSuffix = 'Controller'; - protected $_actionSuffix = 'Action'; + protected $handlers = array(); - protected $_routePrefix; + protected $routePrefix; /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations + * The class is located in a module * + * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addResource($handler, $prefix = null) {} + public function addModuleResource(string $module, string $handler, string $prefix = null): Annotations {} /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations - * The class is located in a module * - * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addModuleResource($module, $handler, $prefix = null) {} + public function addResource(string $handler, string $prefix = null): Annotations {} /** - * Produce the routing parameters from the rewrite information + * Return the registered resources * - * @param string $uri + * @return array */ - public function handle($uri = null) {} + public function getResources(): array {} /** - * Checks for annotations in the controller docblock + * Produce the routing parameters from the rewrite information * - * @param string $handler - * @param \Phalcon\Annotations\Annotation $annotation + * @param string $uri */ - public function processControllerAnnotation($handler, \Phalcon\Annotations\Annotation $annotation) {} + public function handle(string $uri) {} /** * Checks for annotations in the public methods of the controller @@ -85,27 +84,28 @@ public function processControllerAnnotation($handler, \Phalcon\Annotations\Annot * @param string $action * @param \Phalcon\Annotations\Annotation $annotation */ - public function processActionAnnotation($module, $namespaceName, $controller, $action, \Phalcon\Annotations\Annotation $annotation) {} + public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) {} /** - * Changes the controller class suffix + * Checks for annotations in the controller docblock * - * @param string $controllerSuffix + * @param string $handler + * @param \Phalcon\Annotations\Annotation $annotation */ - public function setControllerSuffix($controllerSuffix) {} + public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) {} /** * Changes the action method suffix * * @param string $actionSuffix */ - public function setActionSuffix($actionSuffix) {} + public function setActionSuffix(string $actionSuffix) {} /** - * Return the registered resources + * Changes the controller class suffix * - * @return array + * @param string $controllerSuffix */ - public function getResources() {} + public function setControllerSuffix(string $controllerSuffix) {} } diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index e89389c2..864e7821 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -7,7 +7,7 @@ * * Helper class to create a group of routes with common attributes * - * + * ```php * $router = new \Phalcon\Mvc\Router(); * * //Create a group with a common module and controller @@ -48,24 +48,24 @@ * * //Add the group to the router * $router->mount($blog); - * + * ``` */ class Group implements \Phalcon\Mvc\Router\GroupInterface { - protected $_prefix; + protected $beforeMatch; - protected $_hostname; + protected $hostname; - protected $_paths; + protected $paths; - protected $_routes; + protected $prefix; - protected $_beforeMatch; + protected $routes; /** @@ -76,155 +76,182 @@ class Group implements \Phalcon\Mvc\Router\GroupInterface public function __construct($paths = null) {} /** - * Set a hostname restriction for all the routes in the group + * Adds a route to the router on any HTTP method * - * @param string $hostname - * @return GroupInterface + * ```php + * $router->add("/about", "About::index"); + * ``` + * + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return RouteInterface */ - public function setHostname($hostname) {} + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} /** - * Returns the hostname restriction + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @return string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getHostname() {} + public function addConnect(string $pattern, $paths = null): RouteInterface {} /** - * Set a common uri prefix for all the routes in this group + * Adds a route to the router that only match if the HTTP method is DELETE * - * @param string $prefix - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setPrefix($prefix) {} + public function addDelete(string $pattern, $paths = null): RouteInterface {} /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is GET * - * @return string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getPrefix() {} + public function addGet(string $pattern, $paths = null): RouteInterface {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param callable $beforeMatch - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function beforeMatch($beforeMatch) {} + public function addHead(string $pattern, $paths = null): RouteInterface {} /** - * Returns the 'before match' callback if any + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @return callable + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getBeforeMatch() {} + public function addOptions(string $pattern, $paths = null): RouteInterface {} /** - * Set common paths for all the routes in the group + * Adds a route to the router that only match if the HTTP method is PATCH * - * @param mixed $paths - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setPaths($paths) {} + public function addPatch(string $pattern, $paths = null): RouteInterface {} /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is POST * - * @return array|string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getPaths() {} + public function addPost(string $pattern, $paths = null): RouteInterface {} /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is PURGE * - * @return RouteInterface[] + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getRoutes() {} + public function addPurge(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router on any HTTP method - * - * - * $router->add("/about", "About::index"); - * + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods + * @param string|array $paths * @return RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null) {} + public function addPut(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern - * @param string/array $paths + * @param string|array $paths * @return RouteInterface */ - public function addGet($pattern, $paths = null) {} + public function addTrace(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addPost($pattern, $paths = null) {} + public function beforeMatch($beforeMatch): GroupInterface {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Removes all the pre-defined routes + */ + public function clear() {} + + /** + * Returns the 'before match' callback if any * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return callable */ - public function addPut($pattern, $paths = null) {} + public function getBeforeMatch() {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Returns the hostname restriction * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return string */ - public function addPatch($pattern, $paths = null) {} + public function getHostname(): string {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the common paths defined for this group * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return array|string */ - public function addDelete($pattern, $paths = null) {} + public function getPaths() {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the common prefix for all the routes * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return string */ - public function addOptions($pattern, $paths = null) {} + public function getPrefix(): string {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the routes added to the group * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return array|RouteInterface[] */ - public function addHead($pattern, $paths = null) {} + public function getRoutes(): array {} /** - * Removes all the pre-defined routes + * Set a hostname restriction for all the routes in the group + * + * @param string $hostname + * @return GroupInterface */ - public function clear() {} + public function setHostname(string $hostname): GroupInterface {} + + /** + * Set common paths for all the routes in the group + * + * @param mixed $paths + * @return GroupInterface + */ + public function setPaths($paths): GroupInterface {} + + /** + * Set a common uri prefix for all the routes in this group + * + * @param string $prefix + * @return GroupInterface + */ + public function setPrefix(string $prefix): GroupInterface {} /** * Adds a route applying the common attributes @@ -234,6 +261,6 @@ public function clear() {} * @param mixed $httpMethods * @return RouteInterface */ - protected function _addRoute($pattern, $paths = null, $httpMethods = null) {} + protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index dd9a10b1..33d59115 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -5,7 +5,7 @@ /** * Phalcon\Mvc\Router\GroupInterface * - * + * ```php * $router = new \Phalcon\Mvc\Router(); * * // Create a group with a common module and controller @@ -46,160 +46,187 @@ * * // Add the group to the router * $router->mount($blog); - * + * ``` */ interface GroupInterface { /** - * Set a hostname restriction for all the routes in the group + * Adds a route to the router on any HTTP method * - * @param string $hostname - * @return GroupInterface - */ - public function setHostname($hostname); - - /** - * Returns the hostname restriction + * ```php + * router->add("/about", "About::index"); + * ``` * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getHostname(); + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; /** - * Set a common uri prefix for all the routes in this group + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $prefix - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPrefix($prefix); + public function addConnect(string $pattern, $paths = null): RouteInterface; /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is DELETE * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPrefix(); + public function addDelete(string $pattern, $paths = null): RouteInterface; /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Adds a route to the router that only match if the HTTP method is GET * - * @param callable $beforeMatch - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function beforeMatch($beforeMatch); + public function addGet(string $pattern, $paths = null): RouteInterface; /** - * Returns the 'before match' callback if any + * Adds a route to the router that only match if the HTTP method is HEAD * - * @return callable + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getBeforeMatch(); + public function addHead(string $pattern, $paths = null): RouteInterface; /** - * Set common paths for all the routes in the group + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param array $paths - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPaths($paths); + public function addOptions(string $pattern, $paths = null): RouteInterface; /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is PATCH * - * @return array|string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPaths(); + public function addPatch(string $pattern, $paths = null): RouteInterface; /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is POST * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRoutes(); + public function addPost(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router on any HTTP method - * - * - * router->add("/about", "About::index"); - * + * Adds a route to the router that only match if the HTTP method is PURGE * * @param string $pattern * @param mixed $paths - * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null); + public function addPurge(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet($pattern, $paths = null); + public function addPut(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is POST + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost($pattern, $paths = null); + public function addTrace(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PUT + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addPut($pattern, $paths = null); + public function beforeMatch($beforeMatch): GroupInterface; /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Removes all the pre-defined routes + */ + public function clear(); + + /** + * Returns the 'before match' callback if any * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return callable */ - public function addPatch($pattern, $paths = null); + public function getBeforeMatch(); /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the hostname restriction * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addDelete($pattern, $paths = null); + public function getHostname(): string; /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the common paths defined for this group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array|string */ - public function addOptions($pattern, $paths = null); + public function getPaths(); /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the common prefix for all the routes * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addHead($pattern, $paths = null); + public function getPrefix(): string; /** - * Removes all the pre-defined routes + * Returns the routes added to the group + * + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function clear(); + public function getRoutes(): array; + + /** + * Set a hostname restriction for all the routes in the group + * + * @param string $hostname + * @return GroupInterface + */ + public function setHostname(string $hostname): GroupInterface; + + /** + * Set common paths for all the routes in the group + * + * @param array $paths + * @return GroupInterface + */ + public function setPaths($paths): GroupInterface; + + /** + * Set a common uri prefix for all the routes in this group + * + * @param string $prefix + * @return GroupInterface + */ + public function setPrefix(string $prefix): GroupInterface; } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 8397b84f..5f86e634 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -10,40 +10,40 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface { - protected $_pattern; + protected $beforeMatch; - protected $_compiledPattern; + protected $compiledPattern; - protected $_paths; + protected $converters; - protected $_methods; + protected $group; - protected $_hostname; + protected $hostname; - protected $_converters; + protected $id; - protected $_id; + protected $methods; - protected $_name; + protected $match; - protected $_beforeMatch; + protected $name; - protected $_match; + protected $paths; - protected $_group; + protected $pattern; - static protected $_uniqueId; + static protected $uniqueId = 0; @@ -56,137 +56,103 @@ public function getId() {} * @param mixed $paths * @param mixed $httpMethods */ - public function __construct($pattern, $paths = null, $httpMethods = null) {} + public function __construct(string $pattern, $paths = null, $httpMethods = null) {} /** - * Replaces placeholders from pattern returning a valid PCRE regular expression - * - * @param string $pattern - * @return string - */ - public function compilePattern($pattern) {} - - /** - * Set one or more HTTP methods that constraint the matching of the route - * - * - * $route->via("GET"); + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * $route->via( + * ```php + * $router->add( + * "/login", * [ - * "GET", - * "POST", + * "module" => "admin", + * "controller" => "session", * ] + * )->beforeMatch( + * function ($uri, $route) { + * // Check if the request was made with Ajax + * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { + * return false; + * } + * + * return true; + * } * ); - * + * ``` * - * @param mixed $httpMethods - * @return Route + * @param mixed $callback + * @return RouteInterface */ - public function via($httpMethods) {} + public function beforeMatch($callback): RouteInterface {} /** - * Extracts parameters from a string + * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string $pattern - * @return array|bool + * @return string */ - public function extractNamedParams($pattern) {} + public function compilePattern(string $pattern): string {} /** - * Reconfigure the route adding a new pattern and a set of paths + * {@inheritdoc} + * + * @param string $name + * @param mixed $converter + * @return RouteInterface + */ + public function convert(string $name, $converter): RouteInterface {} + + /** + * Extracts parameters from a string * * @param string $pattern - * @param mixed $paths + * @return array|bool */ - public function reConfigure($pattern, $paths = null) {} + public function extractNamedParams(string $pattern) {} /** - * Returns routePaths + * Returns the 'before match' callback if any * - * @param mixed $paths - * @return array + * @return callable */ - public static function getRoutePaths($paths = null) {} + public function getBeforeMatch() {} /** - * Returns the route's name + * Returns the route's compiled pattern * * @return string */ - public function getName() {} + public function getCompiledPattern(): string {} /** - * Sets the route's name - * - * - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * + * Returns the router converter * - * @param string $name - * @return Route + * @return array */ - public function setName($name) {} + public function getConverters(): array {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched - * - * - * $router->add( - * "/login", - * [ - * "module" => "admin", - * "controller" => "session", - * ] - * )->beforeMatch( - * function ($uri, $route) { - * // Check if the request was made with Ajax - * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { - * return false; - * } - * - * return true; - * } - * ); - * + * Returns the group associated with the route * - * @param mixed $callback - * @return Route + * @return null|GroupInterface */ - public function beforeMatch($callback) {} + public function getGroup(): ?GroupInterface {} /** - * Returns the 'before match' callback if any + * Returns the HTTP methods that constraint matching the route * - * @return callable + * @return array|string */ - public function getBeforeMatch() {} + public function getHttpMethods() {} /** - * Allows to set a callback to handle the request directly in the route - * - * - * $router->add( - * "/help", - * [] - * )->match( - * function () { - * return $this->getResponse()->redirect("https://support.google.com/", true); - * } - * ); - * + * Returns the hostname restriction if any * - * @param mixed $callback - * @return Route + * @return string */ - public function match($callback) {} + public function getHostname(): string {} /** * Returns the 'match' callback if any @@ -196,137 +162,153 @@ public function match($callback) {} public function getMatch() {} /** - * Returns the route's id + * Returns the route's name * * @return string */ - public function getRouteId() {} + public function getName(): string {} /** - * Returns the route's pattern + * Returns the paths * - * @return string + * @return array */ - public function getPattern() {} + public function getPaths(): array {} /** - * Returns the route's compiled pattern + * Returns the route's pattern * * @return string */ - public function getCompiledPattern() {} - - /** - * Returns the paths - * - * @return array - */ - public function getPaths() {} + public function getPattern(): string {} /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths() {} + public function getReversedPaths(): array {} /** - * Sets a set of HTTP methods that constraint the matching of the route (alias of via) - * - * - * $route->setHttpMethods("GET"); - * $route->setHttpMethods(["GET", "POST"]); - * + * Returns the route's id * - * @param mixed $httpMethods - * @return RouteInterface + * @return string */ - public function setHttpMethods($httpMethods) {} + public function getRouteId(): string {} /** - * Returns the HTTP methods that constraint matching the route + * Returns routePaths * - * @return array|string + * @param mixed $paths + * @return array */ - public function getHttpMethods() {} + public static function getRoutePaths($paths = null): array {} /** - * Sets a hostname restriction to the route + * Allows to set a callback to handle the request directly in the route * - * - * $route->setHostname("localhost"); - * + * ```php + * $router->add( + * "/help", + * [] + * )->match( + * function () { + * return $this->getResponse()->redirect("https://support.google.com/", true); + * } + * ); + * ``` * - * @param string $hostname + * @param mixed $callback * @return RouteInterface */ - public function setHostname($hostname) {} + public function match($callback): RouteInterface {} /** - * Returns the hostname restriction if any + * Reconfigure the route adding a new pattern and a set of paths * - * @return string + * @param string $pattern + * @param mixed $paths */ - public function getHostname() {} + public function reConfigure(string $pattern, $paths = null) {} + + /** + * Resets the internal route id generator + */ + public static function reset() {} /** * Sets the group associated with the route * * @param GroupInterface $group - * @return Route + * @return RouteInterface */ - public function setGroup(GroupInterface $group) {} + public function setGroup(GroupInterface $group): RouteInterface {} /** - * Returns the group associated with the route + * Sets a set of HTTP methods that constraint the matching of the route (alias of via) * - * @return null|GroupInterface + * ```php + * $route->setHttpMethods("GET"); + * + * $route->setHttpMethods( + * [ + * "GET", + * "POST", + * ] + * ); + * ``` + * + * @param mixed $httpMethods + * @return RouteInterface */ - public function getGroup() {} + public function setHttpMethods($httpMethods): RouteInterface {} /** - * Adds a converter to perform an additional transformation for certain parameter - * - * - * $router = new Phalcon\Mvc\Router(false); //create Router without default routes - * $route = $router->add("/catalog/([a-zA-Z0-9\_\-]+)/([^\?]+)", [ - * "controller" => "catalog", - * "action" => "show", - * "name" => 1, - * "params_" => 2, - * ]); - * - * //additional parsing - * $route->convert( - * 'params_', - * function ($string) { - * $array = explode('/', $string); - * array_walk($array, function (&$string) { - * $string = explode('-', $string); - * }); - * - * return $array; - * }); - * $router->handle("https://site.com/controller_name/param1-val1-val2/param2-val3"); - * //result is: `["params_"] = [["param1","val1","val2"], ["param2","val3"]]` - * + * Sets a hostname restriction to the route * - * @param string $name - * @param mixed $converter - * @return Route + * ```php + * $route->setHostname("localhost"); + * ``` + * + * @param string $hostname + * @return RouteInterface */ - public function convert($name, $converter) {} + public function setHostname(string $hostname): RouteInterface {} /** - * Returns the router converter + * Sets the route's name * - * @return array + * ```php + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * ``` + * + * @param string $name + * @return RouteInterface */ - public function getConverters() {} + public function setName(string $name): RouteInterface {} /** - * Resets the internal route id generator + * Set one or more HTTP methods that constraint the matching of the route + * + * ```php + * $route->via("GET"); + * + * $route->via( + * [ + * "GET", + * "POST", + * ] + * ); + * ``` + * + * @param mixed $httpMethods + * @return RouteInterface */ - public static function reset() {} + public function via($httpMethods): RouteInterface {} } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index f6f1f632..77877799 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -11,110 +11,119 @@ interface RouteInterface { /** - * Sets a hostname restriction to the route + * Replaces placeholders from pattern returning a valid PCRE regular expression * - * @param string $hostname - * @return RouteInterface + * @param string $pattern + * @return string */ - public function setHostname($hostname); + public function compilePattern(string $pattern): string; /** - * Returns the hostname restriction if any + * Adds a converter to perform an additional transformation for certain parameter. * - * @return string + * @param string $name + * @param mixed $converter + * @return RouteInterface */ - public function getHostname(); + public function convert(string $name, $converter): RouteInterface; /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Returns the route's pattern * - * @param string $pattern * @return string */ - public function compilePattern($pattern); + public function getCompiledPattern(): string; /** - * Set one or more HTTP methods that constraint the matching of the route + * Returns the hostname restriction if any * - * @param mixed $httpMethods + * @return string */ - public function via($httpMethods); + public function getHostname(): string; /** - * Reconfigure the route adding a new pattern and a set of paths + * Returns the HTTP methods that constraint matching the route * - * @param string $pattern - * @param mixed $paths + * @return string|array */ - public function reConfigure($pattern, $paths = null); + public function getHttpMethods(); /** * Returns the route's name * * @return string */ - public function getName(); + public function getName(): string; /** - * Sets the route's name + * Returns the paths * - * @param string $name + * @return array */ - public function setName($name); + public function getPaths(): array; /** - * Sets a set of HTTP methods that constraint the matching of the route + * Returns the route's pattern * - * @param mixed $httpMethods - * @return RouteInterface + * @return string */ - public function setHttpMethods($httpMethods); + public function getPattern(): string; /** - * Returns the route's id + * Returns the paths using positions as keys and names as values * - * @return string + * @return array */ - public function getRouteId(); + public function getReversedPaths(): array; /** - * Returns the route's pattern + * Returns the route's id * * @return string */ - public function getPattern(); + public function getRouteId(): string; /** - * Returns the route's pattern + * Sets a hostname restriction to the route * - * @return string + * @param string $hostname + * @return RouteInterface */ - public function getCompiledPattern(); + public function setHostname(string $hostname): RouteInterface; /** - * Returns the paths + * Sets a set of HTTP methods that constraint the matching of the route * - * @return array + * @param mixed $httpMethods + * @return RouteInterface */ - public function getPaths(); + public function setHttpMethods($httpMethods): RouteInterface; /** - * Returns the paths using positions as keys and names as values + * Sets the route's name * - * @return array + * @param string $name */ - public function getReversedPaths(); + public function setName(string $name); /** - * Returns the HTTP methods that constraint matching the route + * Reconfigure the route adding a new pattern and a set of paths * - * @return string|array + * @param string $pattern + * @param mixed $paths */ - public function getHttpMethods(); + public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator */ public static function reset(); + /** + * Set one or more HTTP methods that constraint the matching of the route + * + * @param mixed $httpMethods + */ + public function via($httpMethods); + } diff --git a/src/Phalcon/mvc/url/Exception.php b/src/Phalcon/mvc/url/Exception.php deleted file mode 100644 index f10048ee..00000000 --- a/src/Phalcon/mvc/url/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - + * ```php * use Phalcon\Mvc\View\Simple as View; * * $view = new View(); @@ -27,49 +27,43 @@ * "parameter" => $here, * ] * ); - * + * ``` */ class Simple extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewBaseInterface { - protected $_options; + protected $activeRenderPath; - protected $_viewsDir; - - - protected $_partialsDir; - - - protected $_viewParams; + protected $content; /** * @var \Phalcon\Mvc\View\EngineInterface[]|false */ - protected $_engines = false; + protected $engines = false; - /** - * @var array|null - */ - protected $_registeredEngines; + protected $options; - protected $_activeRenderPath; + protected $partialsDir; - protected $_content; + /** + * @var array|null + */ + protected $registeredEngines; - protected $_cache = false; + protected $viewsDir; - protected $_cacheOptions; + protected $viewParams = array(); /** * @return array|null */ - public function getRegisteredEngines() {} + public function getRegisteredEngines(): ?array {} /** * Phalcon\Mvc\View\Simple constructor @@ -79,69 +73,74 @@ public function getRegisteredEngines() {} public function __construct(array $options = array()) {} /** - * Sets views directory. Depending of your platform, always add a trailing slash or backslash + * Magic method to retrieve a variable passed to the view * - * @param string $viewsDir + * ```php + * echo $this->view->products; + * ``` + * + * @param string $key + * @return mixed|null */ - public function setViewsDir($viewsDir) {} + public function __get(string $key): ? {} /** - * Gets views directory + * Magic method to pass variables to the views * - * @return string + * ```php + * $this->view->products = $products; + * ``` + * + * @param string $key + * @param mixed $value */ - public function getViewsDir() {} + public function __set(string $key, $value) {} /** - * Register templating engines + * Returns the path of the view that is currently rendered * - * - * $this->view->registerEngines( - * [ - * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", - * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", - * ".mhtml" => "MyCustomEngine", - * ] - * ); - * + * @return string + */ + public function getActiveRenderPath(): string {} + + /** + * Returns output from another view stage * - * @param array $engines + * @return string */ - public function registerEngines(array $engines) {} + public function getContent(): string {} /** - * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php + * Returns parameters to views * * @return array */ - protected function _loadTemplateEngines() {} + public function getParamsToView(): array {} /** - * Tries to render the view with every engine registered in the component + * Returns a parameter previously set in the view * - * @param string $path - * @param array $params + * @param string $key + * @return mixed|null */ - protected final function _internalRender($path, $params) {} + public function getVar(string $key): ? {} /** - * Renders a view + * Gets views directory * - * @param string $path - * @param array $params * @return string */ - public function render($path, $params = null) {} + public function getViewsDir(): string {} /** * Renders a partial view * - * + * ```php * // Show a partial inside another view * $this->partial("shared/footer"); - * + * ``` * - * + * ```php * // Show a partial inside another view with parameters * $this->partial( * "shared/footer", @@ -149,165 +148,115 @@ public function render($path, $params = null) {} * "content" => $html, * ] * ); - * + * ``` * * @param string $partialPath * @param mixed $params */ - public function partial($partialPath, $params = null) {} + public function partial(string $partialPath, $params = null) {} /** - * Sets the cache options + * Register templating engines * - * @param array $options - * @return Simple - */ - public function setCacheOptions(array $options) {} - - /** - * Returns the cache options + * ```php + * $this->view->registerEngines( + * [ + * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, + * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, + * ".mhtml" => \MyCustomEngine::class, + * ] + * ); + * ``` * - * @return array + * @param array $engines */ - public function getCacheOptions() {} + public function registerEngines(array $engines) {} /** - * Create a Phalcon\Cache based on the internal cache options + * Renders a view * - * @return \Phalcon\Cache\BackendInterface + * @param string $path + * @param array $params + * @return string */ - protected function _createCache() {} + public function render(string $path, array $params = array()): string {} /** - * Returns the cache instance used to cache + * Externally sets the view content + * + * ```php + * $this->view->setContent("

hello

"); + * ``` * - * @return \Phalcon\Cache\BackendInterface + * @param string $content + * @return Simple */ - public function getCache() {} + public function setContent(string $content): Simple {} /** - * Cache the actual view render to certain level + * Adds parameters to views (alias of setVar) * - * - * $this->view->cache( - * [ - * "key" => "my-key", - * "lifetime" => 86400, - * ] - * ); - * + * ```php + * $this->view->setParamToView("products", $products); + * ``` * - * @param mixed $options + * @param string $key + * @param mixed $value * @return Simple */ - public function cache($options = true) {} + public function setParamToView(string $key, $value): Simple {} /** - * Adds parameters to views (alias of setVar) + * Set a single view parameter * - * - * $this->view->setParamToView("products", $products); - * + * ```php + * $this->view->setVar("products", $products); + * ``` * * @param string $key * @param mixed $value * @return Simple */ - public function setParamToView($key, $value) {} + public function setVar(string $key, $value): Simple {} /** * Set all the render params * - * + * ```php * $this->view->setVars( * [ * "products" => $products, * ] * ); - * + * ``` * * @param array $params * @param bool $merge * @return Simple */ - public function setVars(array $params, $merge = true) {} + public function setVars(array $params, bool $merge = true): Simple {} /** - * Set a single view parameter - * - * - * $this->view->setVar("products", $products); - * + * Sets views directory * - * @param string $key - * @param mixed $value - * @return Simple - */ - public function setVar($key, $value) {} - - /** - * Returns a parameter previously set in the view - * - * @param string $key - * @return mixed|null + * @param string $viewsDir */ - public function getVar($key) {} + public function setViewsDir(string $viewsDir) {} /** - * Returns parameters to views + * Loads registered template engines, if none are registered it will use + * Phalcon\Mvc\View\Engine\Php * * @return array */ - public function getParamsToView() {} - - /** - * Externally sets the view content - * - * - * $this->view->setContent("

hello

"); - *
- * - * @param string $content - * @return Simple - */ - public function setContent($content) {} + protected function loadTemplateEngines(): array {} /** - * Returns cached output from another view stage - * - * @return string - */ - public function getContent() {} - - /** - * Returns the path of the view that is currently rendered - * - * @return string - */ - public function getActiveRenderPath() {} - - /** - * Magic method to pass variables to the views - * - * - * $this->view->products = $products; - * - * - * @param string $key - * @param mixed $value - */ - public function __set($key, $value) {} - - /** - * Magic method to retrieve a variable passed to the view - * - * - * echo $this->view->products; - * + * Tries to render the view with every engine registered in the component * - * @param string $key - * @return mixed|null + * @param string $path + * @param array $params */ - public function __get($key) {} + final protected function internalRender(string $path, $params) {} } diff --git a/src/Phalcon/mvc/view/Engine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php similarity index 62% rename from src/Phalcon/mvc/view/Engine.php rename to src/Phalcon/mvc/view/engine/AbstractEngine.php index 9ccfadcb..786bf49e 100644 --- a/src/Phalcon/mvc/view/Engine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -1,48 +1,46 @@ + * ```php * $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); * * $compiler->compile("views/partials/header.volt"); * * require $compiler->getCompiledTemplatePath(); - * + * ``` */ class Compiler implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - - - protected $_view; + protected $autoescape = false; - protected $_options; + protected $blockLevel = 0; - protected $_arrayHelpers; + protected $blocks; - protected $_level = 0; + protected $container; - protected $_foreachLevel = 0; + protected $compiledTemplatePath; - protected $_blockLevel = 0; + protected $currentBlock; - protected $_exprLevel = 0; + protected $currentPath; - protected $_extended = false; + protected $exprLevel = 0; - protected $_autoescape = false; + protected $extended = false; - protected $_extendedBlocks; + protected $extensions; - protected $_currentBlock; + protected $extendedBlocks; - protected $_blocks; + protected $filters; - protected $_forElsePointers; + protected $foreachLevel = 0; - protected $_loopPointers; + protected $forElsePointers; - protected $_extensions; + protected $functions; - protected $_functions; + protected $level = 0; - protected $_filters; + protected $loopPointers; - protected $_macros; + protected $macros; - protected $_prefix; + protected $options; - protected $_currentPath; + protected $prefix; - protected $_compiledTemplatePath; + protected $view; /** @@ -92,194 +87,200 @@ class Compiler implements \Phalcon\Di\InjectionAwareInterface public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) {} /** - * Sets the dependency injector - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector + * Registers a Volt's extension * - * @return \Phalcon\DiInterface + * @param mixed $extension + * @return Compiler */ - public function getDI() {} + public function addExtension($extension): Compiler {} /** - * Sets the compiler options + * Register a new filter in the compiler * - * @param array $options + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function setOptions(array $options) {} + public function addFilter(string $name, $definition): Compiler {} /** - * Sets a single compiler option + * Register a new function in the compiler * - * @param string $option - * @param mixed $value + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function setOption($option, $value) {} + public function addFunction(string $name, $definition): Compiler {} /** - * Returns a compiler's option + * Resolves attribute reading * - * @param string $option + * @param array $expr * @return string */ - public function getOption($option) {} + public function attributeReader(array $expr): string {} /** - * Returns the compiler options + * Compiles a template into a file applying the compiler options + * This method does not return the compiled path if the template was not compiled * - * @return array - */ - public function getOptions() {} - - /** - * Fires an event to registered extensions + * ```php + * $compiler->compile("views/layouts/main.volt"); * - * @param string $name - * @param array $arguments - * @return mixed - */ - public final function fireExtensionEvent($name, $arguments = null) {} - - /** - * Registers a Volt's extension + * require $compiler->getCompiledTemplatePath(); + * ``` * - * @param mixed $extension - * @return Compiler + * @param string $templatePath + * @param bool $extendsMode */ - public function addExtension($extension) {} + public function compile(string $templatePath, bool $extendsMode = false) {} /** - * Returns the list of extensions registered in Volt + * Compiles a "autoescape" statement returning PHP code * - * @return array + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function getExtensions() {} + public function compileAutoEscape(array $statement, bool $extendsMode): string {} /** - * Register a new function in the compiler + * Compiles a "cache" statement returning PHP code * - * @param string $name - * @param mixed $definition - * @return Compiler + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function addFunction($name, $definition) {} + public function compileCache(array $statement, bool $extendsMode = false): string {} /** - * Register the user registered functions + * Compiles calls to macros * - * @return array + * @param array $statement + * @param bool $extendsMode */ - public function getFunctions() {} + public function compileCall(array $statement, bool $extendsMode) {} /** - * Register a new filter in the compiler + * Compiles a "case"/"default" clause returning PHP code * - * @param string $name - * @param mixed $definition - * @return Compiler + * @param array $statement + * @param bool $caseClause + * @return string */ - public function addFilter($name, $definition) {} + public function compileCase(array $statement, bool $caseClause = true): string {} /** - * Register the user registered filters + * Compiles a "do" statement returning PHP code * - * @return array + * @param array $statement + * @return string */ - public function getFilters() {} + public function compileDo(array $statement): string {} /** - * Set a unique prefix to be used as prefix for compiled variables + * Compiles a {% raw %}`{{` `}}`{% endraw %} statement returning PHP code * - * @param string $prefix - * @return Compiler + * @param array $statement + * @return string */ - public function setUniquePrefix($prefix) {} + public function compileEcho(array $statement): string {} /** - * Return a unique prefix to be used as prefix for compiled variables and contexts + * Compiles a "elseif" statement returning PHP code * + * @param array $statement * @return string */ - public function getUniquePrefix() {} + public function compileElseIf(array $statement): string {} /** - * Resolves attribute reading + * Compiles a template into a file forcing the destination path * - * @param array $expr - * @return string + * ```php + * $compiler->compileFile( + * "views/layouts/main.volt", + * "views/layouts/main.volt.php" + * ); + * ``` + * + * @param string $path + * @param string $compiledPath + * @param bool $extendsMode + * @return string|array */ - public function attributeReader(array $expr) {} + public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) {} /** - * Resolves function intermediate code into PHP function calls + * Compiles a "foreach" intermediate code representation into plain PHP code * - * @param array $expr + * @param array $statement + * @param bool $extendsMode * @return string */ - public function functionCall(array $expr) {} + public function compileForeach(array $statement, bool $extendsMode = false): string {} /** - * Resolves filter intermediate code into a valid PHP expression + * Generates a 'forelse' PHP code * - * @param array $test - * @param string $left * @return string */ - public function resolveTest(array $test, $left) {} + public function compileForElse(): string {} /** - * Resolves filter intermediate code into PHP function calls + * Compiles a 'if' statement returning PHP code * - * @param array $filter - * @param string $left + * @param array $statement + * @param bool $extendsMode * @return string */ - final protected function resolveFilter(array $filter, $left) {} + public function compileIf(array $statement, bool $extendsMode = false): string {} /** - * Resolves an expression node in an AST volt tree + * Compiles a 'include' statement returning PHP code * - * @param array $expr + * @param array $statement * @return string */ - final public function expression(array $expr) {} + public function compileInclude(array $statement): string {} /** - * Compiles a block of statements + * Compiles macros * - * @param array $statements - * @return string|array + * @param array $statement + * @param bool $extendsMode + * @return string */ - final protected function _statementListOrExtends($statements) {} + public function compileMacro(array $statement, bool $extendsMode): string {} /** - * Compiles a "foreach" intermediate code representation into plain PHP code + * Compiles a "return" statement returning PHP code * * @param array $statement - * @param bool $extendsMode * @return string */ - public function compileForeach(array $statement, $extendsMode = false) {} + public function compileReturn(array $statement): string {} /** - * Generates a 'forelse' PHP code + * Compiles a "set" statement returning PHP code * + * @param array $statement * @return string */ - public function compileForElse() {} + public function compileSet(array $statement): string {} /** - * Compiles a 'if' statement returning PHP code + * Compiles a template into a string * - * @param array $statement + * ```php + * echo $compiler->compileString({% raw %}'{{ "hello world" }}'{% endraw %}); + * ``` + * + * @param string $viewCode * @param bool $extendsMode * @return string */ - public function compileIf(array $statement, $extendsMode = false) {} + public function compileString(string $viewCode, bool $extendsMode = false): string {} /** * Compiles a 'switch' statement returning PHP code @@ -288,195 +289,191 @@ public function compileIf(array $statement, $extendsMode = false) {} * @param bool $extendsMode * @return string */ - public function compileSwitch(array $statement, $extendsMode = false) {} + public function compileSwitch(array $statement, bool $extendsMode = false): string {} /** - * Compiles a "case"/"default" clause returning PHP code + * Resolves an expression node in an AST volt tree * - * @param array $statement - * @param bool $caseClause + * @param array $expr * @return string */ - public function compileCase(array $statement, $caseClause = true) {} + final public function expression(array $expr): string {} /** - * Compiles a "elseif" statement returning PHP code + * Fires an event to registered extensions * - * @param array $statement - * @return string + * @param string $name + * @param array $arguments + * @return mixed */ - public function compileElseIf(array $statement) {} + final public function fireExtensionEvent(string $name, $arguments = null) {} /** - * Compiles a "cache" statement returning PHP code + * Resolves function intermediate code into PHP function calls * - * @param array $statement - * @param bool $extendsMode + * @param array $expr * @return string */ - public function compileCache(array $statement, $extendsMode = false) {} + public function functionCall(array $expr): string {} /** - * Compiles a "set" statement returning PHP code + * Returns the path to the last compiled template * - * @param array $statement * @return string */ - public function compileSet(array $statement) {} + public function getCompiledTemplatePath(): string {} /** - * Compiles a "do" statement returning PHP code + * Returns the internal dependency injector * - * @param array $statement - * @return string + * @return \Phalcon\Di\DiInterface */ - public function compileDo(array $statement) {} + public function getDI(): DiInterface {} /** - * Compiles a "return" statement returning PHP code + * Returns the list of extensions registered in Volt * - * @param array $statement - * @return string + * @return array */ - public function compileReturn(array $statement) {} + public function getExtensions(): array {} /** - * Compiles a "autoescape" statement returning PHP code + * Register the user registered filters * - * @param array $statement - * @param bool $extendsMode - * @return string + * @return array */ - public function compileAutoEscape(array $statement, $extendsMode) {} + public function getFilters(): array {} /** - * Compiles a '{{' '}}' statement returning PHP code + * Register the user registered functions * - * @param array $statement - * @param boolean $extendsMode - * @return string + * @return array */ - public function compileEcho(array $statement) {} + public function getFunctions(): array {} /** - * Compiles a 'include' statement returning PHP code + * Returns a compiler's option * - * @param array $statement + * @param string $option * @return string */ - public function compileInclude(array $statement) {} + public function getOption(string $option) {} /** - * Compiles macros + * Returns the compiler options * - * @param array $statement - * @param bool $extendsMode - * @return string + * @return array */ - public function compileMacro(array $statement, $extendsMode) {} + public function getOptions(): array {} /** - * Compiles calls to macros + * Returns the path that is currently being compiled * - * @param array $statement - * @param boolean $extendsMode * @return string */ - public function compileCall(array $statement, $extendsMode) {} + public function getTemplatePath(): string {} /** - * Traverses a statement list compiling each of its nodes + * Return a unique prefix to be used as prefix for compiled variables and + * contexts * - * @param array $statements - * @param bool $extendsMode * @return string */ - final protected function _statementList(array $statements, $extendsMode = false) {} + public function getUniquePrefix(): string {} /** - * Compiles a Volt source code returning a PHP plain version + * Parses a Volt template returning its intermediate representation + * + * ```php + * print_r( + * $compiler->parse("{% raw %}{{ 3 + 2 }}{% endraw %}") + * ); + * ``` * * @param string $viewCode - * @param bool $extendsMode - * @return string + * @return array */ - protected function _compileSource($viewCode, $extendsMode = false) {} + public function parse(string $viewCode) {} /** - * Compiles a template into a string - * - * - * echo $compiler->compileString('{{ "hello world" }}'); - * + * Resolves filter intermediate code into a valid PHP expression * - * @param string $viewCode - * @param bool $extendsMode + * @param array $test + * @param string $left * @return string */ - public function compileString($viewCode, $extendsMode = false) {} + public function resolveTest(array $test, string $left): string {} /** - * Compiles a template into a file forcing the destination path + * Sets the dependency injector * - * - * $compiler->compileFile("views/layouts/main.volt", "views/layouts/main.volt.php"); - * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets a single compiler option * - * @param string $path - * @param string $compiledPath - * @param boolean $extendsMode - * @return string|array + * @param string $option + * @param mixed $value */ - public function compileFile($path, $compiledPath, $extendsMode = false) {} + public function setOption(string $option, $value) {} /** - * Compiles a template into a file applying the compiler options - * This method does not return the compiled path if the template was not compiled + * Sets the compiler options * - * - * $compiler->compile("views/layouts/main.volt"); + * @param array $options + */ + public function setOptions(array $options) {} + + /** + * Set a unique prefix to be used as prefix for compiled variables * - * require $compiler->getCompiledTemplatePath(); - * + * @param string $prefix + * @return Compiler + */ + public function setUniquePrefix(string $prefix): Compiler {} + + /** + * Compiles a Volt source code returning a PHP plain version * - * @param string $templatePath + * @param string $viewCode * @param bool $extendsMode + * @return string */ - public function compile($templatePath, $extendsMode = false) {} + protected function compileSource(string $viewCode, bool $extendsMode = false): string {} /** - * Returns the path that is currently being compiled + * Gets the final path with VIEW * - * @return string + * @param string $path */ - public function getTemplatePath() {} + protected function getFinalPath(string $path) {} /** - * Returns the path to the last compiled template + * Resolves filter intermediate code into PHP function calls * + * @param array $filter + * @param string $left * @return string */ - public function getCompiledTemplatePath() {} + final protected function resolveFilter(array $filter, string $left): string {} /** - * Parses a Volt template returning its intermediate representation - * - * - * print_r( - * $compiler->parse("{{ 3 + 2 }}") - * ); - * + * Traverses a statement list compiling each of its nodes * - * @param string $viewCode - * @return array + * @param array $statements + * @param bool $extendsMode + * @return string */ - public function parse($viewCode) {} + final protected function statementList(array $statements, bool $extendsMode = false): string {} /** - * Gets the final path with VIEW + * Compiles a block of statements * - * @param string $path + * @param array $statements + * @return string|array */ - protected function getFinalPath($path) {} + final protected function statementListOrExtends($statements) {} } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 0c9ec29b..8f230a7c 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\View\Engine\Volt; /** - * Phalcon\Mvc\View\Exception - * * Class for exceptions thrown by Phalcon\Mvc\View */ class Exception extends \Phalcon\Mvc\View\Exception @@ -19,13 +17,13 @@ class Exception extends \Phalcon\Mvc\View\Exception * @param int $code * @param \Exception $previous */ - public function __construct($message = '', array $statement = array(), $code = 0, \Exception $previous = null) {} + public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) {} /** * Gets currently parsed statement (if any). * * @return array */ - public function getStatement() {} + public function getStatement(): array {} } diff --git a/src/Phalcon/paginator/Adapter.php b/src/Phalcon/paginator/Adapter.php deleted file mode 100644 index 20238657..00000000 --- a/src/Phalcon/paginator/Adapter.php +++ /dev/null @@ -1,44 +0,0 @@ - - * use Phalcon\Paginator\Factory; - * $builder = $this->modelsManager->createBuilder() - * ->columns("id, name") - * ->from("Robots") - * ->orderBy("name"); - * - * $options = [ - * "builder" => $builder, - * "limit" => 20, - * "page" => 1, - * "adapter" => "queryBuilder", - * ]; - * $paginator = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php new file mode 100644 index 00000000..1b6a8f76 --- /dev/null +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class PaginatorFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * ```php + * use Phalcon\Paginator\PaginatorFactory; + * + * $builder = $this + * ->modelsManager + * ->createBuilder() + * ->columns("id, name") + * ->from(Robots::class) + * ->orderBy("name"); + * + * $options = [ + * "builder" => $builder, + * "limit" => 20, + * "page" => 1, + * "adapter" => "queryBuilder", + * ]; + * + * $paginator = (new PaginatorFactory())->load($options); + * ``` + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Paginator\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index 03fc7b1c..1d5fe849 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -5,106 +5,123 @@ /** * Phalcon\Paginator\Repository * - * Repository of current state Phalcon\Paginator\AdapterInterface::getPaginate() + * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements RepositoryInterface +class Repository implements \Phalcon\Paginator\RepositoryInterface { - protected $_properties = []; - protected $_aliases = []; - - /** - * {@inheritdoc} - */ - public function setProperties(array $properties) : RepositoryInterface - { - } - - /** - * {@inheritdoc} - */ - public function setAliases(array $aliases) : RepositoryInterface - { - } - - /** - * {@inheritdoc} - */ - public function getAliases() : array - { - } - - /** - * {@inheritdoc} - */ - public function getItems() { - } - - /** - * {@inheritdoc} - */ - public function getTotalItems() : int - { - } - - /** - * {@inheritdoc} - */ - public function getLimit() : int - { - } - - /** - * {@inheritdoc} - */ - public function getFirst() : int - { - } - - /** - * {@inheritdoc} - */ - public function getPrevious() : int - { - } - - /** - * {@inheritdoc} - */ - public function getCurrent() : int - { - } - - /** - * {@inheritdoc} - */ - public function getNext() : int - { - } - - /** - * {@inheritdoc} - */ - public function getLast() : int - { - } - - /** - * {@inheritdoc} - */ - public function __get(string $property) - { - } - - /** - * Gets value of property by name - */ - protected function getProperty(string $property, $defaultValue = null) { - } - - /** - * Resolve legacy alias for compatibility with version 2.0.x - */ - protected function getRealNameProperty(string $property) : string - { - } + /** + * @var array + */ + protected $aliases = array(); + + /** + * @var array + */ + protected $properties = array(); + + + /** + * {@inheritdoc} + * + * @param string $property + * @return mixed|null + */ + public function __get(string $property): ? {} + + /** + * {@inheritdoc} + * + * @return array + */ + public function getAliases(): array {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getCurrent(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getFirst(): int {} + + /** + * {@inheritdoc} + * + * @return mixed + */ + public function getItems() {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getLast(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getLimit(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getNext(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getPrevious(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getTotalItems(): int {} + + /** + * {@inheritdoc} + * + * @param array $aliases + * @return RepositoryInterface + */ + public function setAliases(array $aliases): RepositoryInterface {} + + /** + * {@inheritdoc} + * + * @param array $properties + * @return RepositoryInterface + */ + public function setProperties(array $properties): RepositoryInterface {} + + /** + * Gets value of property by name + * + * @param string $property + * @param mixed $defaultValue + * @return mixed + */ + protected function getProperty(string $property, $defaultValue = null) {} + + /** + * Resolve alias property name + * + * @param string $property + * @return string + */ + protected function getRealNameProperty(string $property): string {} + } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php new file mode 100644 index 00000000..94b41503 --- /dev/null +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -0,0 +1,117 @@ + + * ```php * use Phalcon\Paginator\Adapter\Model; * * $paginator = new Model( @@ -18,37 +19,17 @@ * ] * ); * - * $paginate = $paginator->getPaginate(); - * + * $paginate = $paginator->paginate(); + * ``` */ -class Model extends \Phalcon\Paginator\Adapter +class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of paginator by model - */ - protected $_config = null; - - - /** - * Phalcon\Paginator\Adapter\Model constructor - * - * @param array $config - */ - public function __construct(array $config) {} - - /** - * Returns a slice of the resultset to show in the pagination - * - * @deprecated will be removed after 4.0 - * @return \stdClass - */ - public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate() {} + public function paginate(): RepositoryInterface {} } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 39fee906..36547901 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -7,7 +7,7 @@ * * Pagination using a PHP array as source of data * - * + * ```php * use Phalcon\Paginator\Adapter\NativeArray; * * $paginator = new NativeArray( @@ -23,36 +23,16 @@ * "page" => $currentPage, * ] * ); - * + * ``` */ -class NativeArray extends \Phalcon\Paginator\Adapter +class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of the paginator - */ - protected $_config = null; - - - /** - * Phalcon\Paginator\Adapter\NativeArray constructor - * - * @param array $config - */ - public function __construct(array $config) {} - - /** - * Returns a slice of the resultset to show in the pagination - * - * @deprecated will be removed after 4.0 - * @return \stdClass - */ - public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate() {} + public function paginate(): RepositoryInterface {} } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index ed229f0a..7e810c18 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -7,12 +7,12 @@ * * Pagination using a PHQL query builder as source of data * - * + * ```php * use Phalcon\Paginator\Adapter\QueryBuilder; * * $builder = $this->modelsManager->createBuilder() * ->columns("id, name") - * ->from("Robots") + * ->from(Robots::class) * ->orderBy("name"); * * $paginator = new QueryBuilder( @@ -22,24 +22,19 @@ * "page" => 1, * ] * ); - * + * ``` */ -class QueryBuilder extends \Phalcon\Paginator\Adapter +class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of paginator by model - */ - protected $_config; - /** * Paginator's data */ - protected $_builder; + protected $builder; /** * Columns for count query if builder has having */ - protected $_columns; + protected $columns; /** @@ -54,36 +49,28 @@ public function __construct(array $config) {} * * @return int */ - public function getCurrentPage() {} - - /** - * Set query builder object - * - * @param \Phalcon\Mvc\Model\Query\Builder $builder - * @return QueryBuilder - */ - public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder) {} + public function getCurrentPage(): int {} /** * Get query builder object * * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getQueryBuilder() {} + public function getQueryBuilder(): Builder {} /** * Returns a slice of the resultset to show in the pagination * - * @deprecated `will be removed after 4.0 - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function getPaginate() {} + public function paginate(): RepositoryInterface {} /** - * Returns a slice of the resultset to show in the pagination + * Set query builder object * - * @return \stdClass + * @param \Phalcon\Mvc\Model\Query\Builder $builder + * @return QueryBuilder */ - public function paginate() {} + public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder {} } diff --git a/src/Phalcon/queue/Beanstalk.php b/src/Phalcon/queue/Beanstalk.php deleted file mode 100644 index fb1308ce..00000000 --- a/src/Phalcon/queue/Beanstalk.php +++ /dev/null @@ -1,269 +0,0 @@ - - * use Phalcon\Queue\Beanstalk; - * - * $queue = new Beanstalk( - * [ - * "host" => "127.0.0.1", - * "port" => 11300, - * "persistent" => true, - * ] - * ); - * - * - * @link http://www.igvita.com/2010/05/20/scalable-work-queues-with-beanstalk/ - */ -class Beanstalk -{ - /** - * Seconds to wait before putting the job in the ready queue. - * The job will be in the "delayed" state during this time. - * - * @const integer - */ - const DEFAULT_DELAY = 0; - - /** - * Jobs with smaller priority values will be scheduled before jobs with larger priorities. - * The most urgent priority is 0, the least urgent priority is 4294967295. - * - * @const integer - */ - const DEFAULT_PRIORITY = 100; - - /** - * Time to run - number of seconds to allow a worker to run this job. - * The minimum ttr is 1. - * - * @const integer - */ - const DEFAULT_TTR = 86400; - - /** - * Default tube name - * - * @const string - */ - const DEFAULT_TUBE = 'default'; - - /** - * Default connected host - * - * @const string - */ - const DEFAULT_HOST = '127.0.0.1'; - - /** - * Default connected port - * - * @const integer - */ - const DEFAULT_PORT = 11300; - - /** - * Connection resource - * - * @var resource - */ - protected $_connection; - - /** - * Connection options - * - * @var array - */ - protected $_parameters; - - - /** - * Phalcon\Queue\Beanstalk - * - * @param array $parameters - */ - public function __construct(array $parameters = array()) {} - - /** - * Makes a connection to the Beanstalkd server - * - * @return resource - */ - public function connect() {} - - /** - * Puts a job on the queue using specified tube. - * - * @param mixed $data - * @param array $options - * @return int|bool - */ - public function put($data, array $options = null) {} - - /** - * Reserves/locks a ready job from the specified tube. - * - * @param mixed $timeout - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function reserve($timeout = null) {} - - /** - * Change the active tube. By default the tube is "default". - * - * @param string $tube - * @return bool|string - */ - public function choose($tube) {} - - /** - * The watch command adds the named tube to the watch list for the current connection. - * - * @param string $tube - * @return bool|int - */ - public function watch($tube) {} - - /** - * It removes the named tube from the watch list for the current connection. - * - * @param string $tube - * @return bool|int - */ - public function ignore($tube) {} - - /** - * Can delay any new job being reserved for a given time. - * - * @param string $tube - * @param int $delay - * @return bool - */ - public function pauseTube($tube, $delay) {} - - /** - * The kick command applies only to the currently used tube. - * - * @param int $bound - * @return bool|int - */ - public function kick($bound) {} - - /** - * Gives statistical information about the system as a whole. - * - * @return bool|array - */ - public function stats() {} - - /** - * Gives statistical information about the specified tube if it exists. - * - * @param string $tube - * @return bool|array - */ - public function statsTube($tube) {} - - /** - * Returns a list of all existing tubes. - * - * @return bool|array - */ - public function listTubes() {} - - /** - * Returns the tube currently being used by the client. - * - * @return bool|string - */ - public function listTubeUsed() {} - - /** - * Returns a list tubes currently being watched by the client. - * - * @return bool|array - */ - public function listTubesWatched() {} - - /** - * Inspect the next ready job. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekReady() {} - - /** - * Return the next job in the list of buried jobs. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekBuried() {} - - /** - * Return the next job in the list of buried jobs. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekDelayed() {} - - /** - * The peek commands let the client inspect a job in the system. - * - * @param int $id - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function jobPeek($id) {} - - /** - * Reads the latest status from the Beanstalkd server - * - * @return array - */ - final public function readStatus() {} - - /** - * Fetch a YAML payload from the Beanstalkd server - * - * @return array - */ - final public function readYaml() {} - - /** - * Reads a packet from the socket. Prior to reading from the socket will - * check for availability of the connection. - * - * @param int $length - * @return bool|string - */ - public function read($length = 0) {} - - /** - * Writes data to the socket. Performs a connection if none is available - * - * @param string $data - * @return bool|int - */ - public function write($data) {} - - /** - * Closes the connection to the beanstalk server. - * - * @return bool - */ - public function disconnect() {} - - /** - * Simply closes the connection. - * - * @return bool - */ - public function quit() {} - -} diff --git a/src/Phalcon/queue/beanstalk/Exception.php b/src/Phalcon/queue/beanstalk/Exception.php deleted file mode 100644 index e2bb63bc..00000000 --- a/src/Phalcon/queue/beanstalk/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - + * ```php * $random = new \Phalcon\Security\Random(); * * // Random binary string @@ -68,7 +68,7 @@ * echo $random->base58(); // Umjxqf7ZPwh765yR * echo $random->base58(24); // qoXcgmw4A9dys26HaNEdCRj9 * echo $random->base58(7); // 774SJD3vgP - * + * ``` * * This class partially borrows SecureRandom library from Ruby * @@ -77,61 +77,21 @@ class Random { - /** - * Generates a random binary string - * - * The `Random::bytes` method returns a string and accepts as input an int - * representing the length in bytes to be returned. - * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The result may contain any byte: "x00" - "xFF". - * - * - * $random = new \Phalcon\Security\Random(); - * - * $bytes = $random->bytes(); - * var_dump(bin2hex($bytes)); - * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" - * - * - * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len - * @return string - */ - public function bytes($len = 16) {} - - /** - * Generates a random hex string - * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The length of the result string is usually greater of $len. - * - * - * $random = new \Phalcon\Security\Random(); - * - * echo $random->hex(10); // a29f470508d5ccb8e289 - * - * - * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len - * @return string - */ - public function hex($len = null) {} - /** * Generates a random base58 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The result may contain alphanumeric characters except 0, O, I and l. * - * It is similar to `Phalcon\Security\Random:base64` but has been modified to avoid both non-alphanumeric - * characters and letters which might look ambiguous when printed. + * It is similar to `Phalcon\Security\Random::base64()` but has been + * modified to avoid both non-alphanumeric characters and letters which + * might look ambiguous when printed. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base58(); // 4kUgL2pdQMSCQtjE - * + * ``` * * @see \Phalcon\Security\Random:base64 * @link https://en.wikipedia.org/wiki/Base58 @@ -139,47 +99,49 @@ public function hex($len = null) {} * @param int $len * @return string */ - public function base58($len = null) {} + public function base58(int $len = null): string {} /** * Generates a random base62 string * * If $len is not specified, 16 is assumed. It may be larger in future. * - * It is similar to `Phalcon\Security\Random:base58` but has been modified to provide the largest value that can - * safely be used in URLs without needing to take extra characters into consideration because it is [A-Za-z0-9]. + * It is similar to `Phalcon\Security\Random::base58()` but has been + * modified to provide the largest value that can safely be used in URLs + * without needing to take extra characters into consideration because it is + * [A-Za-z0-9]. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base62(); // z0RkwHfh8ErDM1xw - * + * ``` * * @see \Phalcon\Security\Random:base58 * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base62($len = null) {} + public function base62(int $len = null): string {} /** * Generates a random base64 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. - * Size formula: 4 ($len / 3) and this need to be rounded up to a multiple of 4. + * Size formula: 4 ($len / 3) rounded up to a multiple of 4. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base64(12); // 3rcq39QzGK9fUqh8 - * + * ``` * * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base64($len = null) {} + public function base64(int $len = null): string {} /** * Generates a random URL-safe base64 string @@ -187,15 +149,16 @@ public function base64($len = null) {} * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. * - * By default, padding is not generated because "=" may be used as a URL delimiter. - * The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if $padding is true. - * See RFC 3548 for the definition of URL-safe base64. + * By default, padding is not generated because "=" may be used as a URL + * delimiter. The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also + * used if $padding is true. See RFC 3548 for the definition of URL-safe + * base64. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base64Safe(); // GD8JojhzSTrqX7Q8J6uug - * + * ``` * * @link https://www.ietf.org/rfc/rfc3548.txt * @throws Exception If secure random number generator is not available or unexpected partial read @@ -203,50 +166,94 @@ public function base64($len = null) {} * @param bool $padding * @return string */ - public function base64Safe($len = null, $padding = false) {} + public function base64Safe(int $len = null, bool $padding = false): string {} /** - * Generates a v4 random UUID (Universally Unique IDentifier) + * Generates a random binary string + * + * The `Random::bytes` method returns a string and accepts as input an int + * representing the length in bytes to be returned. + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The result may contain any byte: "x00" - "xFF". * - * The version 4 UUID is purely random (except the version). It doesn't contain meaningful - * information such as MAC address, time, etc. See RFC 4122 for details of UUID. + * ```php + * $random = new \Phalcon\Security\Random(); + * + * $bytes = $random->bytes(); + * var_dump(bin2hex($bytes)); + * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" + * ``` * - * This algorithm sets the version number (4 bits) as well as two reserved bits. - * All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. - * Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal - * digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). + * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len + * @return string + */ + public function bytes(int $len = 16): string {} + + /** + * Generates a random hex string + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The length of the result string is usually greater of $len. * - * + * ```php * $random = new \Phalcon\Security\Random(); * - * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 - * + * echo $random->hex(10); // a29f470508d5ccb8e289 + * ``` * - * @link https://www.ietf.org/rfc/rfc4122.txt * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len * @return string */ - public function uuid() {} + public function hex(int $len = null): string {} /** * Generates a random number between 0 and $len * * Returns an integer: 0 <= result <= $len. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->number(16); // 8 - * + * ``` * * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 * @param int $len * @return int */ - public function number($len) {} + public function number(int $len): int {} + + /** + * Generates a v4 random UUID (Universally Unique IDentifier) + * + * The version 4 UUID is purely random (except the version). It doesn't + * contain meaningful information such as MAC address, time, etc. See RFC + * 4122 for details of UUID. + * + * This algorithm sets the version number (4 bits) as well as two reserved + * bits. All other bits (the remaining 122 bits) are set using a random or + * pseudorandom data source. Version 4 UUIDs have the form + * xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and + * y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). + * + * ```php + * $random = new \Phalcon\Security\Random(); + * + * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 + * ``` + * + * @link https://www.ietf.org/rfc/rfc4122.txt + * @throws Exception If secure random number generator is not available or unexpected partial read + * @return string + */ + public function uuid(): string {} /** - * Generates a random string based on the number ($base) of characters ($alphabet). + * Generates a random string based on the number ($base) of characters + * ($alphabet). * * If $n is not specified, 16 is assumed. It may be larger in future. * @@ -256,6 +263,6 @@ public function number($len) {} * @param mixed $n * @return string */ - protected function base($alphabet, $base, $n = null) {} + protected function base(string $alphabet, int $base, $n = null): string {} } diff --git a/src/Phalcon/service/Exception.php b/src/Phalcon/service/Exception.php deleted file mode 100644 index 22ac2332..00000000 --- a/src/Phalcon/service/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ - - * $session->setOptions( - * [ - * "uniqueId" => "my-private-app", - * ] - * ); - * - * - * @param array $options - */ - public function setOptions(array $options) {} - - /** - * Get internal options - * - * @return array - */ - public function getOptions() {} - - /** - * Set session name - * - * @param string $name - */ - public function setName($name) {} - - /** - * Get session name - * - * @return string - */ - public function getName() {} - - /** - * {@inheritdoc} - * - * @param bool $deleteOldSession - * @return AdapterInterface - */ - public function regenerateId($deleteOldSession = true) {} - - /** - * Gets a session variable from an application context - * - * - * $session->get("auth", "yes"); - * - * - * @param string $index - * @param mixed $defaultValue - * @param bool $remove - * @return mixed - */ - public function get($index, $defaultValue = null, $remove = false) {} - - /** - * Sets a session variable in an application context - * - * - * $session->set("auth", "yes"); - * - * - * @param string $index - * @param mixed $value - */ - public function set($index, $value) {} - - /** - * Check whether a session variable is set in an application context - * - * - * var_dump( - * $session->has("auth") - * ); - * - * - * @param string $index - * @return bool - */ - public function has($index) {} - - /** - * Removes a session variable from an application context - * - * - * $session->remove("auth"); - * - * - * @param string $index - */ - public function remove($index) {} - - /** - * Returns active session id - * - * - * echo $session->getId(); - * - * - * @return string - */ - public function getId() {} - - /** - * Set the current session id - * - * - * $session->setId($id); - * - * - * @param string $id - */ - public function setId($id) {} - - /** - * Check whether the session has been started - * - * - * var_dump( - * $session->isStarted() - * ); - * - * - * @return bool - */ - public function isStarted() {} - - /** - * Destroys the active session - * - * - * var_dump( - * $session->destroy() - * ); - * - * var_dump( - * $session->destroy(true) - * ); - * - * - * @param mixed $removeData - * @return bool - */ - public function destroy($removeData = null) {} - - /** - * Returns the status of the current session. - * - * - * var_dump( - * $session->status() - * ); - * - * if ($session->status() !== $session::SESSION_ACTIVE) { - * $session->start(); - * } - * - * - * @return int - */ - public function status() {} - - /** - * Alias: Gets a session variable from an application context - * - * @param string $index - * @return mixed - */ - public function __get($index) {} - - /** - * Alias: Sets a session variable in an application context - * - * @param string $index - * @param mixed $value - */ - public function __set($index, $value) {} - - /** - * Alias: Check whether a session variable is set in an application context - * - * @param string $index - * @return bool - */ - public function __isset($index) {} - - /** - * Alias: Removes a session variable from an application context - * - * - * unset($session->auth); - * - * - * @param string $index - */ - public function __unset($index) {} - - - public function __destruct() {} - - - protected function removeSessionData() {} - -} diff --git a/src/Phalcon/session/AdapterInterface.php b/src/Phalcon/session/AdapterInterface.php deleted file mode 100644 index aba0f232..00000000 --- a/src/Phalcon/session/AdapterInterface.php +++ /dev/null @@ -1,108 +0,0 @@ - + * ```php * $user = new \Phalcon\Session\Bag("user"); * * $user->name = "Kimbra Johnson"; * $user->age = 22; - * + * ``` */ -class Bag implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Session\BagInterface, \IteratorAggregate, \ArrayAccess, \Countable +class Bag extends \Phalcon\Collection implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; + private $container; - protected $_name = null; + private $name = null; - protected $_data; - - - protected $_initialized = false; - - - protected $_session; + private $session; /** @@ -38,176 +33,47 @@ class Bag implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Session\BagIn * * @param string $name */ - public function __construct($name) {} - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Initializes the session bag. This method must not be called directly, the - * class calls it when its internal data is accessed - */ - public function initialize() {} + public function __construct(string $name) {} /** * Destroys the session bag - * - * - * $user->destroy(); - * - */ - public function destroy() {} - - /** - * Sets a value in the session bag - * - * - * $user->set("name", "Kimbra"); - * - * - * @param string $property - * @param mixed $value - */ - public function set($property, $value) {} - - /** - * Magic setter to assign values to the session bag - * - * - * $user->name = "Kimbra"; - * - * - * @param string $property - * @param mixed $value - */ - public function __set($property, $value) {} - - /** - * Obtains a value from the session bag optionally setting a default value - * - * - * echo $user->get("name", "Kimbra"); - * - * - * @param string $property - * @param mixed $defaultValue */ - public function get($property, $defaultValue = null) {} + public function clear() {} /** - * Magic getter to obtain values from the session bag - * - * - * echo $user->name; - * - * - * @param string $property - * @return mixed - */ - public function __get($property) {} - - /** - * Check whether a property is defined in the internal bag - * - * - * var_dump( - * $user->has("name") - * ); - * - * - * @param string $property - * @return bool - */ - public function has($property) {} - - /** - * Magic isset to check whether a property is defined in the bag - * - * - * var_dump( - * isset($user["name"]) - * ); - * + * Returns the DependencyInjector container * - * @param string $property - * @return bool + * @return \Phalcon\Di\DiInterface */ - public function __isset($property) {} + public function getDI(): DiInterface {} /** * Removes a property from the internal bag * - * - * $user->remove("name"); - * - * - * @param string $property - * @return bool - */ - public function remove($property) {} - - /** - * Magic unset to remove items using the array syntax - * - * - * unset($user["name"]); - * - * - * @param string $property - * @return bool + * @param array $data */ - public function __unset($property) {} + public function init(array $data = array()) {} /** - * Return length of bag - * - * - * echo $user->count(); - * + * Removes a property from the internal bag * - * @return int + * @param string $element */ - public final function count() {} + public function remove(string $element) {} /** - *  Returns the bag iterator + * Sets a value in the session bag * - * @return \ArrayIterator - */ - public final function getIterator() {} - - /** - * @param mixed $property + * @param string $element * @param mixed $value */ - public final function offsetSet($property, $value) {} + public function set(string $element, $value) {} /** - * @param mixed $property - * @return bool - */ - public final function offsetExists($property) {} - - /** - * @param mixed $property - */ - public final function offsetUnset($property) {} - - /** - * @param mixed $property - * @return mixed + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container */ - public final function offsetGet($property) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} } diff --git a/src/Phalcon/session/BagInterface.php b/src/Phalcon/session/BagInterface.php deleted file mode 100644 index ed3afba4..00000000 --- a/src/Phalcon/session/BagInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - * use Phalcon\Session\Factory; - * - * $options = [ - * "uniqueId" => "my-private-app", - * "host" => "127.0.0.1", - * "port" => 11211, - * "persistent" => true, - * "lifetime" => 3600, - * "prefix" => "my_", - * "adapter" => "memcache", - * ]; - * $session = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 19b0c3b4..1ce22d22 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -2,238 +2,237 @@ namespace Phalcon\Session; -use InvalidArgumentException; -use RuntimeException; -use SessionHandlerInterface; -use Phalcon\DiInterface; -use Phalcon\DI\InjectionAwareInterface; -use Phalcon\Helper\Arr; -use Phalcon\Session\ManagerInterface; - /** * Phalcon\Session\Manager * * Session manager class */ -class Manager implements ManagerInterface, InjectionAwareInterface +class Manager implements \Phalcon\Session\ManagerInterface, \Phalcon\DI\InjectionAwareInterface { /** * @var */ private $container; - /** - * @var |null - */ - private $handler = null; - - /** - * @var string - */ - private $name = ""; - - /** - * @var array - */ - private $options = []; - - /** - * @var string - */ - private $uniqueId = ""; - - /** - * Manager constructor. - * - * @param array options - */ - public function __construct(array $options = []) - { - } - - - /** - * Alias: Gets a session variable from an application context - */ - public function __get(string $key) { - } - - /** - * Alias: Check whether a session variable is set in an application context - */ - public function __isset(string $key) : bool - { - } - - /** - * Alias: Sets a session variable in an application context - */ - public function __set(string $key, $value) : void - { - } - - /** - * Alias: Removes a session variable from an application context - */ - public function __unset(string $key) - { - } - - /** - * Destroy/end a session - */ - public function destroy() : void - { - } - - /** - * Check whether the session has been started - */ - public function exists() : bool - { - } - - /** - * Gets a session variable from an application context - */ - public function get(string $key, $defaultValue = null, bool $remove = false) { - } - - /** - * Returns the DependencyInjector container - */ - public function getDI() : DiInterface - { - } - - /** - * Returns the stored session handler - */ - public function getHandler() : SessionHandlerInterface - { - } - - /** - * Returns the session id - */ - public function getId() : string - { - } - - /** - * Returns the name of the session - */ - public function getName() : string - { - } - - /** - * Check whether a session variable is set in an application context - */ - public function has(string $key) : bool - { - } - - /** - * Get internal options - */ - public function getOptions() : array - { - } - - /** - * Regenerates the session id using the handler. - */ - public function regenerateId($deleteOldSession = true) : ManagerInterface - { - } - - /** - * Registers a handler with the session - */ - public function registerHandler(SessionHandlerInterface $handler) : bool - { - } - - /** - * Removes a session variable from an application context - */ - public function remove(string $key) - { - } - - /** - * Sets a session variable in an application context - */ - public function set(string $key, $value) : void - { - } - - /** - * Sets the DependencyInjector container - */ - public function setDI(DiInterface $container) - { - } - - /** - * Set the handler for the session - */ - public function setHandler(SessionHandlerInterface $handler) : ManagerInterface - { - } - - /** - * Set session Id - */ - public function setId(string $id) : ManagerInterface - { - } - - /** - * Set the session name. Throw exception if the session has started - * and do not allow poop names - * - * @param string name - * - * @throws InvalidArgumentException - * - * @return Manager - */ - public function setName(string $name) : ManagerInterface - { - } - - /** - * Sets session's options - * - * @param array options - */ - public function setOptions(array $options) : void - { - } - - /** - * Starts the session (if headers are already sent the session will not be - * started) - */ - public function start() : bool - { - } - - /** - * Returns the status of the current session. - * - * @return int - */ - public function status() : int - { - } - - /** - * Returns the key prefixed - */ - private function getUniqueKey(string $key) : string - { - } + /** + * @var |null + */ + private $handler = null; + + /** + * @var string + */ + private $name = ''; + + /** + * @var array + */ + private $options = array(); + + /** + * @var string + */ + private $uniqueId = ''; + + + /** + * Manager constructor. + * + * @param array $options + */ + public function __construct(array $options = array()) {} + + /** + * Alias: Gets a session variable from an application context + * + * @param string $key + * @return mixed + */ + public function __get(string $key) {} + + /** + * Alias: Check whether a session variable is set in an application context + * + * @param string $key + * @return bool + */ + public function __isset(string $key): bool {} + + /** + * Alias: Sets a session variable in an application context + * + * @param string $key + * @param mixed $value + */ + public function __set(string $key, $value) {} + + /** + * Alias: Removes a session variable from an application context + * + * @param string $key + */ + public function __unset(string $key) {} + + /** + * Destroy/end a session + */ + public function destroy() {} + + /** + * Check whether the session has been started + * + * @return bool + */ + public function exists(): bool {} + + /** + * Gets a session variable from an application context + * + * @param string $key + * @param mixed $defaultValue + * @param bool $remove + * @return mixed + */ + public function get(string $key, $defaultValue = null, bool $remove = false) {} + + /** + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the stored session handler + * + * @return \SessionHandlerInterface + */ + public function getHandler(): SessionHandlerInterface {} + + /** + * Returns the session id + * + * @return string + */ + public function getId(): string {} + + /** + * Returns the name of the session + * + * @return string + */ + public function getName(): string {} + + /** + * Check whether a session variable is set in an application context + * + * @param string $key + * @return bool + */ + public function has(string $key): bool {} + + /** + * Get internal options + * + * @return array + */ + public function getOptions(): array {} + + /** + * Regenerates the session id using the handler. + * + * @param mixed $deleteOldSession + * @return \Phalcon\Session\ManagerInterface + */ + public function regenerateId($deleteOldSession = true): ManagerInterface {} + + /** + * Registers a handler with the session + * + * @param \SessionHandlerInterface $handler + * @return bool + */ + public function registerHandler(\SessionHandlerInterface $handler): bool {} + + /** + * Removes a session variable from an application context + * + * @param string $key + */ + public function remove(string $key) {} + + /** + * Sets a session variable in an application context + * + * @param string $key + * @param mixed $value + */ + public function set(string $key, $value) {} + + /** + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the handler for the session + * + * @param \SessionHandlerInterface $handler + * @return \Phalcon\Session\ManagerInterface + */ + public function setHandler(\SessionHandlerInterface $handler): ManagerInterface {} + + /** + * Set session Id + * + * @param string $id + * @return \Phalcon\Session\ManagerInterface + */ + public function setId(string $id): ManagerInterface {} + + /** + * Set the session name. Throw exception if the session has started + * and do not allow poop names + * + * @param string name + * + * @throws InvalidArgumentException + * + * @param string $name + * @return \Phalcon\Session\ManagerInterface + */ + public function setName(string $name): ManagerInterface {} + + /** + * Sets session's options + * + * @param array $options + */ + public function setOptions(array $options) {} + + /** + * Starts the session (if headers are already sent the session will not be + * started) + * + * @return bool + */ + public function start(): bool {} + + /** + * Returns the status of the current session. + * + * @return int + */ + public function status(): int {} + + /** + * Returns the key prefixed + * + * @param string $key + * @return string + */ + private function getUniqueKey(string $key): string {} + } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php new file mode 100644 index 00000000..0bdb4024 --- /dev/null +++ b/src/Phalcon/session/ManagerInterface.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \SessionHandlerInterface +{ + /** + * @var + */ + protected $adapter; + + + /** + * Close + * + * @return bool + */ + public function close(): bool {} + + /** + * Destroy + * + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} + + /** + * Garbage Collector + * + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * Read + * + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * Open + * + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} + + /** + * Write + * + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} + +} diff --git a/src/Phalcon/session/adapter/Files.php b/src/Phalcon/session/adapter/Files.php deleted file mode 100644 index ffe3b7f0..00000000 --- a/src/Phalcon/session/adapter/Files.php +++ /dev/null @@ -1,29 +0,0 @@ - - * use Phalcon\Session\Adapter\Files; - * - * $session = new Files( - * [ - * "uniqueId" => "my-private-app", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * - */ -class Files extends \Phalcon\Session\Adapter -{ - -} diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index c1d60223..83668e14 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -4,100 +4,16 @@ /** * Phalcon\Session\Adapter\Libmemcached - * - * This adapter store sessions in libmemcached - * - * - * use Phalcon\Session\Adapter\Libmemcached; - * - * $session = new Libmemcached( - * [ - * "servers" => [ - * [ - * "host" => "localhost", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * \Memcached::OPT_HASH => \Memcached::HASH_MD5, - * \Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * */ -class Libmemcached extends \Phalcon\Session\Adapter +class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter { - protected $_libmemcached = null; - - - protected $_lifetime = 8600; - - - - public function getLibmemcached() {} - - - public function getLifetime() {} - /** - * Phalcon\Session\Adapter\Libmemcached constructor + * Constructor * - * @throws \Phalcon\Session\Exception + * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(array $options) {} - - /** - * @return bool - */ - public function open() {} - - /** - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} } diff --git a/src/Phalcon/session/adapter/Memcache.php b/src/Phalcon/session/adapter/Memcache.php deleted file mode 100644 index c5cac728..00000000 --- a/src/Phalcon/session/adapter/Memcache.php +++ /dev/null @@ -1,95 +0,0 @@ - - * use Phalcon\Session\Adapter\Memcache; - * - * $session = new Memcache( - * [ - * "uniqueId" => "my-private-app", - * "host" => "127.0.0.1", - * "port" => 11211, - * "persistent" => true, - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * - */ -class Memcache extends \Phalcon\Session\Adapter -{ - - protected $_memcache = null; - - - protected $_lifetime = 8600; - - - - public function getMemcache() {} - - - public function getLifetime() {} - - /** - * Phalcon\Session\Adapter\Memcache constructor - * - * @param array $options - */ - public function __construct(array $options = array()) {} - - /** - * @return bool - */ - public function open() {} - - /** - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} - -} diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index ed866229..02a62873 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -2,15 +2,13 @@ namespace Phalcon\Session\Adapter; -use SessionHandlerInterface; - /** * Phalcon\Session\Adapter\Noop * * This is an "empty" or null adapter. It can be used for testing or any * other purpose that no session needs to be invoked * - * + * ```php * setHandler(new Noop()); - * + * ``` */ -class Noop implements SessionHandlerInterface +class Noop implements \SessionHandlerInterface { /** * The connection of some adapters */ - protected $connection; + protected $connection; - /** - * Session options - * - * @var array - */ - protected $options = []; + /** + * Session options + * + * @var array + */ + protected $options = array(); - /** - * Session prefix - * - * @var string - */ - protected $prefix = ""; + /** + * Session prefix + * + * @var string + */ + protected $prefix = ''; - /** - * Time To Live - * - * @var int - */ - protected $ttl = 8600; + /** + * Time To Live + * + * @var int + */ + protected $ttl = 8600; - /** - * Constructor - */ - public function __construct(array $options = []) - { - } - /** - * Close - */ - public function close() : bool - { - } + /** + * Constructor + * + * @param array $options + */ + public function __construct(array $options = array()) {} - /** - * Destroy - */ - public function destroy($id) : bool - { - } + /** + * Close + * + * @return bool + */ + public function close(): bool {} - /** - * Garbage Collector - */ - public function gc($maxlifetime) : bool - { - } + /** + * Destroy + * + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} - /** - * Read - */ - public function read($id) : string - { - } + /** + * Garbage Collector + * + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * Read + * + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * Open + * + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} - /** - * Open - */ - public function open($savePath, $sessionName) : bool - { - } + /** + * Write + * + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} - /** - * Write - */ - public function write($id, $data) : bool - { - } + /** + * Helper method to get the name prefixed + * + * @param mixed $name + * @return string + */ + protected function getPrefixedName($name): string {} - /** - * Helper method to get the name prefixed - */ - protected function getPrefixedName($name) : string - { - } } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 179e2d47..9df67fd7 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -4,98 +4,16 @@ /** * Phalcon\Session\Adapter\Redis - * - * This adapter store sessions in Redis - * - * - * use Phalcon\Session\Adapter\Redis; - * - * $session = new Redis( - * [ - * "uniqueId" => "my-private-app", - * "host" => "localhost", - * "port" => 6379, - * "auth" => "foobared", - * "persistent" => false, - * "lifetime" => 3600, - * "prefix" => "my", - * "index" => 1, - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * */ -class Redis extends \Phalcon\Session\Adapter +class Redis extends \Phalcon\Session\Adapter\AbstractAdapter { - protected $_redis = null; - - - protected $_lifetime = 8600; - - - - public function getRedis() {} - - - public function getLifetime() {} - /** - * Phalcon\Session\Adapter\Redis constructor + * Constructor * + * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(array $options = array()) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function open() {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php new file mode 100644 index 00000000..50f4da55 --- /dev/null +++ b/src/Phalcon/session/adapter/Stream.php @@ -0,0 +1,70 @@ + '/tmp', + * ] + * ); + * $session->setHandler($files); + * ``` + */ +class Stream extends \Phalcon\Session\Adapter\Noop +{ + /** + * @var string + */ + private $path = ''; + + + /** + * @param array $options + */ + public function __construct(array $options = array()) {} + + /** + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} + + /** + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} + + /** + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} + +} diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php new file mode 100644 index 00000000..22477029 --- /dev/null +++ b/src/Phalcon/storage/AdapterFactory.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AdapterFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var + */ + private $serializerFactory; + + + /** + * AdapterFactory constructor. + * + * @param \Phalcon\Storage\SerializerFactory $factory + * @param array $services + */ + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Storage\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/storage/Exception.php b/src/Phalcon/storage/Exception.php new file mode 100644 index 00000000..e699f6fa --- /dev/null +++ b/src/Phalcon/storage/Exception.php @@ -0,0 +1,13 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class SerializerFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * SerializerFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * @param string name + * + * @throws Exception + * @param string $name + * @return \Phalcon\Storage\Serializer\SerializerInterface + */ + public function newInstance(string $name): SerializerInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php new file mode 100644 index 00000000..ec177404 --- /dev/null +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -0,0 +1,195 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface +{ + /** + * @var mixed + */ + protected $adapter; + + /** + * Name of the default serializer class + * + * @var string + */ + protected $defaultSerializer = 'Php'; + + /** + * Name of the default TTL (time to live) + * + * @var int + */ + protected $lifetime = 3600; + + /** + * @var string + */ + protected $prefix = ''; + + /** + * Serializer + * + * @var + */ + protected $serializer; + + /** + * Serializer Factory + * + * @var + */ + protected $serializerFactory; + + + /** + * Name of the default serializer class + * + * @return string + */ + public function getDefaultSerializer(): string {} + + /** + * Name of the default serializer class + * + * @param string $defaultSerializer + */ + public function setDefaultSerializer(string $defaultSerializer) {} + + /** + * @return string + */ + public function getPrefix(): string {} + + /** + * Sets parameters based on options + * + * @param \Phalcon\Storage\SerializerFactory $factory + * @param array $options + */ + protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) {} + + /** + * Flushes/clears the cache + * + * @return bool + */ + abstract public function clear(): bool; + + /** + * Decrements a stored number + * + * @param string $key + * @param int $value + * @return int|bool + */ + abstract public function decrement(string $key, int $value = 1); + + /** + * Deletes data from the adapter + * + * @param string $key + * @return bool + */ + abstract public function delete(string $key): bool; + + /** + * Reads data from the adapter + * + * @param string $key + * @return mixed + */ + abstract public function get(string $key); + + /** + * Returns the adapter - connects to the storage if not connected + * + * @return mixed + */ + abstract public function getAdapter(); + + /** + * Returns all the keys stored + * + * @return array + */ + abstract public function getKeys(): array; + + /** + * Checks if an element exists in the cache + * + * @param string $key + * @return bool + */ + abstract public function has(string $key): bool; + + /** + * Increments a stored number + * + * @param string $key + * @param int $value + * @return int|bool + */ + abstract public function increment(string $key, int $value = 1); + + /** + * Stores data in the adapter + * + * @param string $key + * @param mixed $value + * @param mixed $ttl + * @return bool + */ + abstract public function set(string $key, $value, $ttl = null): bool; + + /** + * Returns the key requested, prefixed + * + * @param mixed $key + * @return string + */ + protected function getPrefixedKey($key): string {} + + /** + * Returns serialized data + * + * @param mixed $content + * @return mixed + */ + protected function getSerializedData($content) {} + + /** + * Calculates the TTL for a cache item + * + * @param DateInterval|int|null $ttl + * + * @throws Exception + * @param mixed $ttl + * @return int + */ + protected function getTtl($ttl): int {} + + /** + * Returns unserialized data + * + * @param mixed $content + * @param mixed $defaultValue + * @return mixed + */ + protected function getUnserializedData($content, $defaultValue = null) {} + + /** + * Initializes the serializer + */ + protected function initSerializer() {} + +} diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php new file mode 100644 index 00000000..a7f35523 --- /dev/null +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface +{ + /** + * @var mixed + */ + protected $data = null; + + + /** + * @return mixed + */ + public function getData() {} + + /** + * @param mixed $data + */ + public function setData($data) {} + + /** + * Constructor + * + * @param mixed $data + */ + public function __construct($data = null) {} + + /** + * If this returns true, then the data returns back as is + * + * @param mixed $data + * @return bool + */ + protected function isSerializable($data): bool {} + +} diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php new file mode 100644 index 00000000..6dfbad46 --- /dev/null +++ b/src/Phalcon/storage/serializer/Base64.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php new file mode 100644 index 00000000..5047c4bc --- /dev/null +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php new file mode 100644 index 00000000..ef79de7a --- /dev/null +++ b/src/Phalcon/storage/serializer/Json.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Json extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php new file mode 100644 index 00000000..8b8a3e80 --- /dev/null +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string|null + */ + public function serialize(): ?string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php new file mode 100644 index 00000000..bba29154 --- /dev/null +++ b/src/Phalcon/storage/serializer/None.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class None extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php new file mode 100644 index 00000000..ea6e0ef6 --- /dev/null +++ b/src/Phalcon/storage/serializer/Php.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Php extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php new file mode 100644 index 00000000..b13acdd3 --- /dev/null +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +interface SerializerInterface extends \Serializable +{ + + /** + * @return mixed + */ + public function getData(); + + /** + * @param mixed $data + * @param $data + */ + public function setData($data); + +} diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 551efc84..5f1f29fe 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -5,7 +5,8 @@ /** * Phalcon\Tag\Select * - * Generates a SELECT html tag using a static array of values or a Phalcon\Mvc\Model resultset + * Generates a SELECT html tag using a static array of values or a + * Phalcon\Mvc\Model resultset */ abstract class Select { @@ -15,26 +16,29 @@ abstract class Select * * @param array $parameters * @param array $data + * @return string */ - public static function selectField($parameters, $data = null) {} + public static function selectField($parameters, $data = null): string {} /** - * Generate the OPTION tags based on a resultset + * Generate the OPTION tags based on an array * - * @param \Phalcon\Mvc\Model\Resultset $resultset - * @param array $using + * @param array $data * @param mixed $value * @param string $closeOption + * @return string */ - private static function _optionsFromResultset($resultset, $using, $value, $closeOption) {} + private static function optionsFromArray(array $data, $value, string $closeOption): string {} /** - * Generate the OPTION tags based on an array + * Generate the OPTION tags based on a resultset * - * @param array $data + * @param \Phalcon\Mvc\Model\ResulsetInterface $resultset + * @param array $using * @param mixed $value * @param string $closeOption + * @return string */ - private static function _optionsFromArray($data, $value, $closeOption) {} + private static function optionsFromResultset(\Phalcon\Mvc\Model\ResulsetInterface $resultset, $using, $value, string $closeOption): string {} } diff --git a/src/Phalcon/translate/Factory.php b/src/Phalcon/translate/Factory.php deleted file mode 100644 index a33f5973..00000000 --- a/src/Phalcon/translate/Factory.php +++ /dev/null @@ -1,30 +0,0 @@ - - * use Phalcon\Translate\Factory; - * - * $options = [ - * "locale" => "de_DE.UTF-8", - * "defaultDomain" => "translations", - * "directory" => "/path/to/application/locales", - * "category" => LC_MESSAGES, - * "adapter" => "gettext", - * ]; - * $translate = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php new file mode 100644 index 00000000..5907eda6 --- /dev/null +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class InterpolatorFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var array + */ + private $mapper = array(); + + /** + * @var array + */ + private $services = array(); + + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @return \Phalcon\Translate\Adapter\AdapterInterface + */ + public function newInstance(string $name): AdapterInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/translate/InterpolatorInterface.php b/src/Phalcon/translate/InterpolatorInterface.php deleted file mode 100644 index ebd37966..00000000 --- a/src/Phalcon/translate/InterpolatorInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class TranslateFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var InterpolatorFactory + */ + private $interpolator; + + + /** + * AdapterFactory constructor. + * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param array $services + */ + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/translate/Adapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php similarity index 58% rename from src/Phalcon/translate/Adapter.php rename to src/Phalcon/translate/adapter/AbstractAdapter.php index 42b3d83b..8d221db3 100644 --- a/src/Phalcon/translate/Adapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -1,79 +1,79 @@ + * ```php * use Phalcon\Translate\Adapter\Gettext; * * $adapter = new Gettext( @@ -16,72 +16,60 @@ * "category" => LC_MESSAGES, * ] * ); - * + * ``` * * Allows translate using gettext */ -class Gettext extends \Phalcon\Translate\Adapter implements \ArrayAccess +class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { /** - * @var string|array + * @var int */ - protected $_directory; + protected $category; /** * @var string */ - protected $_defaultDomain; + protected $defaultDomain; /** - * @var string + * @var string|array */ - protected $_locale; + protected $directory; /** - * @var int + * @var string */ - protected $_category; + protected $locale; /** - * @return string|array + * @return int */ - public function getDirectory() {} + public function getCategory(): int {} /** * @return string */ - public function getDefaultDomain() {} + public function getDefaultDomain(): string {} /** - * @return string + * @return string|array */ - public function getLocale() {} + public function getDirectory() {} /** - * @return int + * @return string */ - public function getCategory() {} + public function getLocale(): string {} /** * Phalcon\Translate\Adapter\Gettext constructor * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(array $options) {} - - /** - * Returns the translation related to the given key. - * - * - * $translator->query("你好 %name%!", ["name" => "Phalcon"]); - * - * - * @param string $index - * @param mixed $placeholders - * @return string - */ - public function query($index, $placeholders = null) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} /** * Check whether is defined a translation key in the internal array @@ -89,11 +77,12 @@ public function query($index, $placeholders = null) {} * @param string $index * @return bool */ - public function exists($index) {} + public function exists(string $index): bool {} /** * The plural version of gettext(). - * Some languages have more than one form for plural messages dependent on the count. + * Some languages have more than one form for plural messages dependent on + * the count. * * @param string $msgid1 * @param string $msgid2 @@ -102,34 +91,39 @@ public function exists($index) {} * @param string $domain * @return string */ - public function nquery($msgid1, $msgid2, $count, $placeholders = null, $domain = null) {} + public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string {} /** - * Changes the current domain (i.e. the translation file) + * Returns the translation related to the given key. * - * @param mixed $domain + * ```php + * $translator->query("你好 %name%!", ["name" => "Phalcon"]); + * ``` + * + * @param string $index + * @param array $placeholders * @return string */ - public function setDomain($domain) {} + public function query(string $index, $placeholders = null): string {} /** * Sets the default domain * * @return string */ - public function resetDomain() {} + public function resetDomain(): string {} /** * Sets the domain default to search within when calls are made to gettext() * * @param string $domain */ - public function setDefaultDomain($domain) {} + public function setDefaultDomain(string $domain) {} /** * Sets the path for a domain * - * + * ```php * // Set the directory path * $gettext->setDirectory("/path/to/the/messages"); * @@ -140,41 +134,49 @@ public function setDefaultDomain($domain) {} * "another" => "/path/to/the/another", * ] * ); - * + * ``` * * @param string|array $directory The directory path or an array of directories and domains */ public function setDirectory($directory) {} + /** + * Changes the current domain (i.e. the translation file) + * + * @param mixed $domain + * @return string + */ + public function setDomain($domain): string {} + /** * Sets locale information * - * + * ```php * // Set locale to Dutch * $gettext->setLocale(LC_ALL, "nl_NL"); * * // Try different possible locale names for german * $gettext->setLocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge"); - * + * ``` * * @param int $category * @param string $locale * @return string|bool */ - public function setLocale($category, $locale) {} + public function setLocale(int $category, string $locale) {} /** - * Validator for constructor + * Gets default options * - * @param array $options + * @return array */ - protected function prepareOptions(array $options) {} + protected function getOptionsDefault(): array {} /** - * Gets default options + * Validator for constructor * - * @return array + * @param array $options */ - protected function getOptionsDefault() {} + protected function prepareOptions(array $options) {} } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index bd5f98c6..710d5661 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -7,34 +7,50 @@ * * Allows to define translation lists using PHP arrays */ -class NativeArray extends \Phalcon\Translate\Adapter implements \ArrayAccess +class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { + /** + * @var array + */ + private $translate; - protected $_translate; + /** + * @var bool + */ + private $triggerError = false; /** * Phalcon\Translate\Adapter\NativeArray constructor * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} /** - * Returns the translation related to the given key + * Check whether is defined a translation key in the internal array + * + * @param string $index + * @return bool + */ + public function exists(string $index): bool {} + + /** + * Whenever a key is not found this medhod will be called * * @param string $index - * @param mixed $placeholders * @return string */ - public function query($index, $placeholders = null) {} + public function notFound(string $index): string {} /** - * Check whether is defined a translation key in the internal array + * Returns the translation related to the given key * * @param string $index - * @return bool + * @param mixed $placeholders + * @return string */ - public function exists($index) {} + public function query(string $index, $placeholders = null): string {} } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index cfb6f050..55bc4363 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -2,17 +2,24 @@ namespace Phalcon\Translate\Interpolator; - -class AssociativeArray implements \Phalcon\Translate\InterpolatorInterface +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function replacePlaceholders($translation, $placeholders = null) {} + public function replacePlaceholders(string $translation, array $placeholders = array()): string {} } diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index f668236e..af57aa6f 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -2,17 +2,24 @@ namespace Phalcon\Translate\Interpolator; - -class IndexedArray implements \Phalcon\Translate\InterpolatorInterface +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function replacePlaceholders($translation, $placeholders = null) {} + public function replacePlaceholders(string $translation, array $placeholders = array()): string {} } diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php new file mode 100644 index 00000000..4adb6a41 --- /dev/null +++ b/src/Phalcon/translate/interpolator/InterpolatorInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class ValidatorFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * TagFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Creates a new instance + * + * @param string $name + * @return mixed + */ + public function newInstance(string $name) {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 5cf7d765..307747be 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -3,38 +3,68 @@ namespace Phalcon\Validation; /** - * Phalcon\Validation\ValidatorInterface - * - * Interface for Phalcon\Validation\Validator + * Interface for Phalcon\Validation\AbstractValidator */ interface ValidatorInterface { /** - * Checks if an option is defined + * Returns an option in the validator's options + * Returns null if the option hasn't set * * @param string $key - * @return bool + * @param mixed $defaultValue + * @return mixed */ - public function hasOption($key); + public function getOption(string $key, $defaultValue = null); /** - * Returns an option in the validator's options - * Returns null if the option hasn't set + * Checks if an option is defined * * @param string $key - * @param mixed $defaultValue - * @return mixed + * @return bool */ - public function getOption($key, $defaultValue = null); + public function hasOption(string $key): bool; /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $attribute + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $attribute); + public function validate(\Phalcon\Validation $validation, $field): bool; + + /** + * Get the template message + * + * @throw InvalidArgumentException When the field does not exists + * @param string $field + * @return string + */ + public function getTemplate(string $field): string; + + /** + * Get message templates + * + * @return array + */ + public function getTemplates(): array; + + /** + * Clear current template and set new from an array, + * + * @param array $templates + * @return ValidatorInterface + */ + public function setTemplates(array $templates): ValidatorInterface; + + /** + * Set a new temlate message + * + * @param string $template + * @return ValidatorInterface + */ + public function setTemplate(string $template): ValidatorInterface; } diff --git a/src/Phalcon/validation/message/Group.php b/src/Phalcon/validation/message/Group.php deleted file mode 100644 index 34a8301c..00000000 --- a/src/Phalcon/validation/message/Group.php +++ /dev/null @@ -1,155 +0,0 @@ - - * print_r( - * $messages[0] - * ); - * - * - * @param int $index - * @return bool|\Phalcon\Validation\Message - */ - public function offsetGet($index) {} - - /** - * Sets an attribute using the array-syntax - * - * - * $messages[0] = new \Phalcon\Validation\Message("This is a message"); - * - * - * @param int $index - * @param \Phalcon\Validation\Message $message - */ - public function offsetSet($index, $message) {} - - /** - * Checks if an index exists - * - * - * var_dump( - * isset($message["database"]) - * ); - * - * - * @param int $index - * @return bool - */ - public function offsetExists($index) {} - - /** - * Removes a message from the list - * - * - * unset($message["database"]); - * - * - * @param mixed $index - */ - public function offsetUnset($index) {} - - /** - * Appends a message to the group - * - * - * $messages->appendMessage( - * new \Phalcon\Validation\Message("This is a message") - * ); - * - * - * @param \Phalcon\Validation\MessageInterface $message - */ - public function appendMessage(\Phalcon\Validation\MessageInterface $message) {} - - /** - * Appends an array of messages to the group - * - * - * $messages->appendMessages($messagesArray); - * - * - * @param \Phalcon\Validation\MessageInterface[] $messages - */ - public function appendMessages($messages) {} - - /** - * Filters the message group by field name - * - * @param string $fieldName - * @return array - */ - public function filter($fieldName) {} - - /** - * Returns the number of messages in the list - * - * @return int - */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} - - /** - * Returns the current message in the iterator - * - * @return \Phalcon\Validation\Message - */ - public function current() {} - - /** - * Returns the current position/key in the iterator - * - * @return int - */ - public function key() {} - - /** - * Moves the internal iteration pointer to the next position - */ - public function next() {} - - /** - * Check if the current message in the iterator is valid - * - * @return bool - */ - public function valid() {} - - /** - * Magic __set_state helps to re-build messages variable when exporting - * - * @param array $group - * @return \Phalcon\Validation\Message\Group - */ - public static function __set_state($group) {} - -} diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index c73c1ad4..e44a4154 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Alnum - * * Check for alphanumeric character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alnum as AlnumValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Alnum extends \Phalcon\Validation\Validator +class Alnum extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must contain only letters and numbers'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 87c1dd50..c4a0ef8c 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Alpha - * * Check for alphabetic character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alpha as AlphaValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Alpha extends \Phalcon\Validation\Validator +class Alpha extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must contain only letters'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index a6ec67a6..62ae2db7 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -3,12 +3,10 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Between - * * Validates that a value is between an inclusive range of two values. * For a value x, the test is passed if minimum<=x<=maximum. * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Between; * @@ -47,18 +45,21 @@ * ] * ) * ); - * + * ``` */ -class Between extends \Phalcon\Validation\Validator +class Between extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be within the range of :min to :max'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 6915f1e6..61c7a9fa 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Callback - * * Calls user function for validation * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Callback as CallbackValidator; * use Phalcon\Validation\Validator\Numericality as NumericalityValidator; @@ -46,18 +44,21 @@ * ] * ) * ); - * + * ``` */ -class Callback extends \Phalcon\Validation\Validator +class Callback extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must match the callback function'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 2c235c3d..9adbf563 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Confirmation - * * Checks that two values have the same value * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Confirmation; * @@ -41,19 +39,22 @@ * ] * ) * ); - * + * ``` */ -class Confirmation extends \Phalcon\Validation\Validator +class Confirmation extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be the same as :with'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * Compare strings @@ -62,6 +63,6 @@ public function validate(\Phalcon\Validation $validation, $field) {} * @param string $b * @return bool */ - protected final function compare($a, $b) {} + final protected function compare(string $a, string $b): bool {} } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index fcef5b6f..659e1445 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\CreditCard - * * Checks if a value has a valid credit card number * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\CreditCard as CreditCardValidator; * @@ -36,26 +34,30 @@ * ] * ) * ); - * + * ``` */ -class CreditCard extends \Phalcon\Validation\Validator +class CreditCard extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is not valid for a credit card number'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** - * is a simple checksum formula used to validate a variety of identification numbers + * is a simple checksum formula used to validate a variety of identification + * numbers * * @param string $number * @return bool */ - private function verifyByLuhnAlgorithm($number) {} + private function verifyByLuhnAlgorithm(string $number): bool {} } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index f5a354ed..47ce72e1 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Date - * * Checks if a value is a valid date * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Date as DateValidator; * @@ -41,25 +39,28 @@ * ] * ) * ); - * + * ``` */ -class Date extends \Phalcon\Validation\Validator +class Date extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is not a valid date'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * @param mixed $value * @param mixed $format * @return bool */ - private function checkDate($value, $format) {} + private function checkDate($value, $format): bool {} } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 4bcc361b..038cb5d8 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Digit - * * Check for numeric character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Digit as DigitValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Digit extends \Phalcon\Validation\Validator +class Digit extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be numeric'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 804d42f2..93b774b3 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Email - * * Checks if a value has a correct e-mail format * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Email as EmailValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Email extends \Phalcon\Validation\Validator +class Email extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be an email address'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Exception.php b/src/Phalcon/validation/validator/Exception.php index 6e0f3fbf..240b1809 100644 --- a/src/Phalcon/validation/validator/Exception.php +++ b/src/Phalcon/validation/validator/Exception.php @@ -3,9 +3,8 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Exception - * - * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this class + * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this + * class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index f4eac992..aa870b04 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\ExclusionIn - * * Check if a value is not included into a list of values * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\ExclusionIn; * @@ -47,18 +45,21 @@ * ] * ) * ); - * + * ``` */ -class ExclusionIn extends \Phalcon\Validation\Validator +class ExclusionIn extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must not be a part of list: :domain'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index aef472d0..3ab08575 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\File - * * Checks if a value has a correct file * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\File as FileValidator; * @@ -18,14 +16,14 @@ * new FileValidator( * [ * "maxSize" => "2M", - * "messageSize" => ":field exceeds the max filesize (:max)", + * "messageSize" => ":field exceeds the max filesize (:size)", * "allowedTypes" => [ * "image/jpeg", * "image/png", * ], * "messageType" => "Allowed file types are :types", * "maxResolution" => "800x600", - * "messageMaxResolution" => "Max resolution of :field is :max", + * "messageMaxResolution" => "Max resolution of :field is :resolution", * ] * ) * ); @@ -69,27 +67,16 @@ * ] * ) * ); - * + * ``` */ -class File extends \Phalcon\Validation\Validator +class File extends \Phalcon\Validation\AbstractValidatorComposite { /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field) {} - - /** - * Check on empty + * Constructor * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool + * @param array $options */ - public function isAllowEmpty(\Phalcon\Validation $validation, $field) {} + public function __construct(array $options = array()) {} } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 9a28f586..152a25ab 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Identical - * * Checks if a value is identical to other * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Identical; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class Identical extends \Phalcon\Validation\Validator +class Identical extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not have the expected value'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index b55343d3..2b69130e 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\InclusionIn - * * Check if a value is included into a list of values * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\InclusionIn; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class InclusionIn extends \Phalcon\Validation\Validator +class InclusionIn extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be a part of list: :domain'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 7193c835..485fdb5b 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -2,27 +2,21 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Validation; -use Phalcon\Validation\Validator; -use Phalcon\Messages\Message; - /** - * Phalcon\Validation\Validator\ip - * - * Check for ip addresses + * Check for IP addresses * - * + * ```php * use Phalcon\Validation\Validator\Ip as IpValidator; * * $validator->add( * "ip_address", * new IpValidator( * [ - * "message" => ":field must contain only ip addresses", - * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified + * "message" => ":field must contain only ip addresses", + * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified * "allowReserved" => false, // False if not specified. Ignored for v6 - * "allowPrivate" => false, // False if not specified - * "allowEmpty" => false, + * "allowPrivate" => false, // False if not specified + * "allowEmpty" => false, * ] * ) * ); @@ -35,39 +29,49 @@ * new IpValidator( * [ * "message" => [ - * "source_address" => "source_address must contain only ip addresses", - * "destination_address" => "destination_address must contain only ip addresses", + * "source_address" => "source_address must be a valid IP address", + * "destination_address" => "destination_address must be a valid IP address", * ], * "version" => [ - * "source_address" => Ip::VERSION_4 | IP::VERSION_6, + * "source_address" => Ip::VERSION_4 | IP::VERSION_6, * "destination_address" => Ip::VERSION_4, * ], * "allowReserved" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowPrivate" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowEmpty" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * ] * ) * ); - * + * ``` */ -class Ip extends Validator +class Ip extends \Phalcon\Validation\AbstractValidator { - const VERSION_4 = FILTER_FLAG_IPV4; - const VERSION_6 = FILTER_FLAG_IPV6; - /** - * Executes the validation - */ - public function validate(Validation $validation, $field) : bool - { - } + const VERSION_4 = 1048576; + + + const VERSION_6 = 2097152; + + + protected $template = 'Field :field must be a valid IP address'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index baf05fe8..4a55030b 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Numericality - * * Check for a valid numeric value * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Numericality; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Numericality extends \Phalcon\Validation\Validator +class Numericality extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not have a valid numeric format'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index 046f395b..f7e1a631 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\PresenceOf - * * Validates that a value is not null or empty string * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\PresenceOf; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class PresenceOf extends \Phalcon\Validation\Validator +class PresenceOf extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is required'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index f3f431b9..23aa7ec5 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Regex - * * Allows validate if the value of a field matches a regular expression * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Regex as RegexValidator; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class Regex extends \Phalcon\Validation\Validator +class Regex extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not match the required format'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index b95904f7..7cded7d9 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -3,13 +3,12 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\StringLength - * * Validates that a string has the specified maximum and minimum constraints * The test is passed if for a string's length L, min<=L<=max, i.e. L must * be at least min, and at most max. + * Since Phalcon v4.0 this valitor works like a container * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\StringLength as StringLength; * @@ -19,10 +18,12 @@ * "name_last", * new StringLength( * [ - * "max" => 50, - * "min" => 2, - * "messageMaximum" => "We don't like really long names", - * "messageMinimum" => "We want more than just their initials", + * "max" => 50, + * "min" => 2, + * "messageMaximum" => "We don't like really long names", + * "messageMinimum" => "We want more than just their initials", + * "includedMaximum" => true, + * "includedMinimum" => false, * ] * ) * ); @@ -49,22 +50,28 @@ * "messageMinimum" => [ * "name_last" => "We don't like too short last names", * "name_first" => "We don't like too short first names", + * ], + * "includedMaximum" => [ + * "name_last" => false, + * "name_first" => true, + * ], + * "includedMinimum" => [ + * "name_last" => false, + * "name_first" => true, * ] * ] * ) * ); - * + * ``` */ -class StringLength extends \Phalcon\Validation\Validator +class StringLength extends \Phalcon\Validation\AbstractValidatorComposite { /** - * Executes the validation + * Constructor * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool + * @param array $options */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function __construct(array $options = array()) {} } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index 26b77fb4..fa70ed86 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Uniqueness - * * Check that a field is unique in the related table * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; * @@ -22,10 +20,10 @@ * ] * ) * ); - * + * ``` * * Different attribute from the field: - * + * ```php * $validator->add( * "username", * new UniquenessValidator( @@ -35,18 +33,18 @@ * ] * ) * ); - * + * ``` * * In model: - * + * ```php * $validator->add( * "username", * new UniquenessValidator() * ); - * + * ``` * * Combination of fields in model: - * + * ```php * $validator->add( * [ * "firstName", @@ -54,12 +52,12 @@ * ], * new UniquenessValidator() * ); - * + * ``` * * It is possible to convert values before validation. This is useful in * situations where values need to be converted to do the database lookup: * - * + * ```php * $validator->add( * "username", * new UniquenessValidator( @@ -72,11 +70,14 @@ * ] * ) * ); - * + * ``` */ -class Uniqueness extends \Phalcon\Validation\CombinedFieldsValidator +class Uniqueness extends \Phalcon\Validation\AbstractCombinedFieldsValidator { + protected $template = 'Field :field must be unique'; + + private $columnMap = null; @@ -87,14 +88,7 @@ class Uniqueness extends \Phalcon\Validation\CombinedFieldsValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} - - /** - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - protected function isUniqueness(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * The column map is used in the case to get real column name @@ -103,24 +97,31 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field) {} * @param string $field * @return string */ - protected function getColumnNameReal($record, $field) {} + protected function getColumnNameReal($record, string $field): string {} /** - * Uniqueness method used for model + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + protected function isUniqueness(\Phalcon\Validation $validation, $field): bool {} + + /** + * Uniqueness method used for collection * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessModel($record, array $field, array $values) {} + protected function isUniquenessCollection($record, array $field, array $values) {} /** - * Uniqueness method used for collection + * Uniqueness method used for model * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessCollection($record, array $field, array $values) {} + protected function isUniquenessModel($record, array $field, array $values) {} } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index b3e86bd5..0c85f1f0 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Url - * * Checks if a value has a url format * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Url as UrlValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Url extends \Phalcon\Validation\Validator +class Url extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be a url'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php new file mode 100644 index 00000000..2a2c15cd --- /dev/null +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -0,0 +1,151 @@ +add( + * "file", + * new Size( + * [ + * "maxSize" => "2M", + * "messageSize" => ":field exceeds the max filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new FileValidator( + * [ + * "maxSize" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "messageSize" => [ + * "file" => "file exceeds the max filesize 2M", + * "anotherFile" => "anotherFile exceeds the max filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +abstract class AbstractFile extends \Phalcon\Validation\AbstractValidator +{ + /** + * Empty is empty + */ + protected $messageFileEmpty = 'Field :field must not be empty'; + + /** + * File exceeed the file size setted in PHP configuration + */ + protected $messageIniSize = 'File :field exceeds the maximum file size'; + + /** + * File is not valid + */ + protected $messageValid = 'Field :field is not valid'; + + + /** + * Empty is empty + */ + public function getMessageFileEmpty() {} + + /** + * Empty is empty + * + * @param mixed $messageFileEmpty + */ + public function setMessageFileEmpty($messageFileEmpty) {} + + /** + * File exceeed the file size setted in PHP configuration + */ + public function getMessageIniSize() {} + + /** + * File exceeed the file size setted in PHP configuration + * + * @param mixed $messageIniSize + */ + public function setMessageIniSize($messageIniSize) {} + + /** + * File is not valid + */ + public function getMessageValid() {} + + /** + * File is not valid + * + * @param mixed $messageValid + */ + public function setMessageValid($messageValid) {} + + /** + * Check on empty + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool {} + + /** + * Check upload + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUpload(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if uploaded file is larger than PHP allowed size + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if upload is empty + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if upload is valid + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool {} + + /** + * Convert a string like "2.5MB" in bytes + * + * @param string $size + * @return double + */ + public function getFileSizeInBytes(string $size): float {} + +} diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php new file mode 100644 index 00000000..b642b371 --- /dev/null +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -0,0 +1,68 @@ +add( + * "file", + * new MimeType( + * [ + * "types" => [ + * "image/jpeg", + * "image/png", + * ], + * "message" => "Allowed file types are :types" + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new MimeType( + * [ + * "types" => [ + * "file" => [ + * "image/jpeg", + * "image/png", + * ], + * "anotherFile" => [ + * "image/gif", + * "image/bmp", + * ], + * ], + * "message" => [ + * "file" => "Allowed file types are image/jpeg and image/png", + * "anotherFile" => "Allowed file types are image/gif and image/bmp", + * ] + * ] + * ) + * ); + * ``` + */ +class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field must be of type: :types'; + + + /** + * Executes the validation + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php new file mode 100644 index 00000000..cc59fdd6 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -0,0 +1,59 @@ +add( + * "file", + * new Equal( + * [ + * "resolution" => "800x600", + * "message" => "The resolution of the field :field has to be equal :resolution", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Equal( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "message" => [ + * "file" => "Equal resolution of file has to be 800x600", + * "anotherFile" => "Equal resolution of file has to be 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'The resolution of the field :field has to be equal :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php new file mode 100644 index 00000000..32ca0ec1 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Max( + * [ + * "resolution" => "800x600", + * "message" => "Max resolution of :field is :resolution", + * "included" => true, + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Max( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "Max resolution of file is 800x600", + * "anotherFile" => "Max resolution of file is 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field exceeds the maximum resolution of :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php new file mode 100644 index 00000000..db1e4db0 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Min( + * [ + * "resolution" => "800x600", + * "message" => "Min resolution of :field is :resolution", + * "included" => true, + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Min( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "Min resolution of file is 800x600", + * "anotherFile" => "Min resolution of file is 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field can not have the minimum resolution of :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php new file mode 100644 index 00000000..2e7de623 --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Equal( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the equal filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Equal( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file does not have the rigth filesize", + * "anotherFile" => "anotherFile wrong filesize (4MB)", + * ], + * ] + * ) + * ); + * ``` + */ +class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field does not have the exact :size filesize'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php new file mode 100644 index 00000000..1e634676 --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Max( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the max filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Max( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file exceeds the max filesize 2M", + * "anotherFile" => "anotherFile exceeds the max filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field exceeds the size of :size'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php new file mode 100644 index 00000000..92d65f3f --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Min( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the min filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Min( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file exceeds the min filesize 2M", + * "anotherFile" => "anotherFile exceeds the min filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field can not have the minimum size of :size'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php new file mode 100644 index 00000000..fe294b5f --- /dev/null +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -0,0 +1,66 @@ +add( + * "name_last", + * new Max( + * [ + * "max" => 50, + * "message" => "We don't like really long names", + * "included" => true + * ] + * ) + * ); + * + * $validation->add( + * [ + * "name_last", + * "name_first", + * ], + * new Max( + * [ + * "max" => [ + * "name_last" => 50, + * "name_first" => 40, + * ], + * "message" => [ + * "name_last" => "We don't like really long last names", + * "name_first" => "We don't like really long first names", + * ], + * "included" => [ + * "name_last" => false, + * "name_first" => true, + * ] + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\AbstractValidator +{ + + protected $template = 'Field :field must not exceed :max characters long'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php new file mode 100644 index 00000000..606924c0 --- /dev/null +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -0,0 +1,66 @@ +add( + * "name_last", + * new Min( + * [ + * "min" => 2, + * "message" => "We want more than just their initials", + * "included" => true + * ] + * ) + * ); + * + * $validation->add( + * [ + * "name_last", + * "name_first", + * ], + * new Min( + * [ + * "min" => [ + * "name_last" => 2, + * "name_first" => 4, + * ], + * "message" => [ + * "name_last" => "We don't like too short last names", + * "name_first" => "We don't like too short first names", + * ], + * "included" => [ + * "name_last" => false, + * "name_first" => true, + * ] + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\AbstractValidator +{ + + protected $template = 'Field :field must be at least :min characters long'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} From 860988946a554165bee498dcdfd374e5b9cc4142 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Wed, 24 Jul 2019 22:49:08 +0300 Subject: [PATCH 08/25] Revert "Generated stubs for Phalcon v4.0.0-beta.1" This reverts commit 7612b0b80fd95ef4d8b074a516faa9d57dc5cb4d. --- src/Phalcon/Acl.php | 60 + ...bstractApplication.php => Application.php} | 98 +- src/Phalcon/Cache.php | 164 -- src/Phalcon/Collection.php | 217 -- src/Phalcon/Config.php | 180 +- src/Phalcon/Container.php | 55 +- src/Phalcon/Crypt.php | 306 +-- src/Phalcon/CryptInterface.php | 86 + src/Phalcon/Db.php | 108 + src/Phalcon/Debug.php | 191 +- src/Phalcon/Di.php | 363 +-- src/Phalcon/{di => }/DiInterface.php | 114 +- .../AbstractDispatcher.php => Dispatcher.php} | 421 ++-- .../{dispatcher => }/DispatcherInterface.php | 127 +- src/Phalcon/Escaper.php | 130 +- .../{escaper => }/EscaperInterface.php | 56 +- src/Phalcon/Exception.php | 8 +- src/Phalcon/Factory.php | 15 + src/Phalcon/FactoryInterface.php | 15 + src/Phalcon/Filter.php | 103 + src/Phalcon/FilterInterface.php | 38 + src/Phalcon/Flash.php | 181 ++ src/Phalcon/FlashInterface.php | 49 + src/Phalcon/Image.php | 36 + src/Phalcon/Kernel.php | 4 +- src/Phalcon/Loader.php | 214 +- src/Phalcon/Logger.php | 55 + src/Phalcon/Plugin.php | 4 +- src/Phalcon/Registry.php | 184 +- src/Phalcon/Security.php | 202 +- src/Phalcon/Tag.php | 932 ++++--- src/Phalcon/Text.php | 250 +- src/Phalcon/Translate.php | 14 + src/Phalcon/Url.php | 334 ++- src/Phalcon/Urlinterface.php | 44 + src/Phalcon/Validation.php | 153 +- .../{validation => }/ValidationInterface.php | 121 +- src/Phalcon/Version.php | 50 +- .../AbstractAdapter.php => Adapter.php} | 72 +- .../acl/{adapter => }/AdapterInterface.php | 112 +- src/Phalcon/acl/Component.php | 53 +- src/Phalcon/acl/ComponentInterface.php | 32 - ...{ComponentAware.php => Componentaware.php} | 10 +- src/Phalcon/acl/Componentinterface.php | 27 + src/Phalcon/acl/Enum.php | 17 - src/Phalcon/acl/Exception.php | 2 + src/Phalcon/acl/Role.php | 16 +- src/Phalcon/acl/RoleAware.php | 5 +- src/Phalcon/acl/RoleInterface.php | 8 +- src/Phalcon/acl/adapter/Memory.php | 159 +- .../AbstractAdapter.php => Adapter.php} | 64 +- .../{adapter => }/AdapterInterface.php | 52 +- src/Phalcon/annotations/Annotation.php | 74 +- .../annotations/AnnotationsFactory.php | 42 - src/Phalcon/annotations/Collection.php | 87 +- src/Phalcon/annotations/Exception.php | 4 +- src/Phalcon/annotations/Factory.php | 28 + src/Phalcon/annotations/Reader.php | 8 +- src/Phalcon/annotations/ReaderInterface.php | 10 +- src/Phalcon/annotations/Reflection.php | 37 +- src/Phalcon/annotations/adapter/Apc.php | 51 + src/Phalcon/annotations/adapter/Apcu.php | 27 +- .../adapter/{Stream.php => Files.php} | 26 +- src/Phalcon/annotations/adapter/Memory.php | 15 +- src/Phalcon/annotations/adapter/Xcache.php | 33 + src/Phalcon/application/Exception.php | 2 + src/Phalcon/assets/Asset.php | 405 ++- src/Phalcon/assets/AssetInterface.php | 63 - src/Phalcon/assets/Assetinterface.php | 46 + src/Phalcon/assets/Collection.php | 376 ++- src/Phalcon/assets/Exception.php | 2 + src/Phalcon/assets/FilterInterface.php | 4 +- src/Phalcon/assets/Inline.php | 78 +- src/Phalcon/assets/Manager.php | 271 +- src/Phalcon/assets/Resource.php | 199 ++ src/Phalcon/assets/ResourceInterface.php | 65 + src/Phalcon/assets/asset/Css.php | 25 +- src/Phalcon/assets/asset/Js.php | 25 +- src/Phalcon/assets/filters/Cssmin.php | 8 +- src/Phalcon/assets/filters/Jsmin.php | 11 +- src/Phalcon/assets/filters/None.php | 6 +- src/Phalcon/assets/inline/Css.php | 10 +- src/Phalcon/assets/inline/Js.php | 12 +- src/Phalcon/assets/resource/Css.php | 23 + src/Phalcon/assets/resource/Js.php | 23 + src/Phalcon/cache/AdapterFactory.php | 40 - src/Phalcon/cache/Backend.php | 103 + src/Phalcon/cache/BackendInterface.php | 116 + src/Phalcon/cache/CacheFactory.php | 40 - src/Phalcon/cache/Exception.php | 13 + src/Phalcon/cache/FrontendInterface.php | 58 + src/Phalcon/cache/Multiple.php | 139 ++ .../cache/adapter/AdapterInterface.php | 11 - src/Phalcon/cache/adapter/Apcu.php | 11 - src/Phalcon/cache/adapter/Libmemcached.php | 11 - src/Phalcon/cache/adapter/Memory.php | 11 - src/Phalcon/cache/adapter/Redis.php | 11 - src/Phalcon/cache/adapter/Stream.php | 11 - src/Phalcon/cache/backend/Apc.php | 129 + src/Phalcon/cache/backend/Apcu.php | 126 + src/Phalcon/cache/backend/Factory.php | 35 + src/Phalcon/cache/backend/File.php | 152 ++ src/Phalcon/cache/backend/Libmemcached.php | 162 ++ src/Phalcon/cache/backend/Memcache.php | 148 ++ src/Phalcon/cache/backend/Memory.php | 123 + src/Phalcon/cache/backend/Mongo.php | 146 ++ src/Phalcon/cache/backend/Redis.php | 147 ++ src/Phalcon/cache/backend/Xcache.php | 123 + src/Phalcon/cache/exception/Exception.php | 11 - .../exception/InvalidArgumentException.php | 11 - src/Phalcon/cache/frontend/Base64.php | 110 + src/Phalcon/cache/frontend/Data.php | 114 + src/Phalcon/cache/frontend/Factory.php | 33 + src/Phalcon/cache/frontend/Igbinary.php | 109 + src/Phalcon/cache/frontend/Json.php | 102 + src/Phalcon/cache/frontend/Msgpack.php | 115 + src/Phalcon/cache/frontend/None.php | 98 + src/Phalcon/cache/frontend/Output.php | 120 + src/Phalcon/cli/Console.php | 35 +- src/Phalcon/cli/Dispatcher.php | 133 +- src/Phalcon/cli/DispatcherInterface.php | 57 +- src/Phalcon/cli/Router.php | 195 +- src/Phalcon/cli/RouterInterface.php | 106 +- src/Phalcon/cli/Task.php | 16 +- src/Phalcon/cli/TaskInterface.php | 2 + src/Phalcon/cli/console/Exception.php | 2 + src/Phalcon/cli/dispatcher/Exception.php | 4 +- src/Phalcon/cli/router/Exception.php | 2 + src/Phalcon/cli/router/Route.php | 162 +- src/Phalcon/cli/router/RouteInterface.php | 75 +- src/Phalcon/collection/Exception.php | 11 - src/Phalcon/collection/ReadOnly.php | 26 - src/Phalcon/config/ConfigFactory.php | 55 - src/Phalcon/config/Exception.php | 2 + src/Phalcon/config/Factory.php | 33 + src/Phalcon/config/adapter/Grouped.php | 19 +- src/Phalcon/config/adapter/Ini.php | 56 +- src/Phalcon/config/adapter/Json.php | 16 +- src/Phalcon/config/adapter/Php.php | 16 +- src/Phalcon/config/adapter/Yaml.php | 17 +- src/Phalcon/crypt/CryptInterface.php | 137 - src/Phalcon/crypt/Exception.php | 2 + src/Phalcon/crypt/Mismatch.php | 2 + src/Phalcon/db/AbstractDb.php | 58 - .../AbstractAdapter.php => Adapter.php} | 960 +++---- .../db/{adapter => }/AdapterInterface.php | 559 ++--- src/Phalcon/db/Column.php | 317 ++- src/Phalcon/db/ColumnInterface.php | 97 +- src/Phalcon/db/Dialect.php | 254 +- src/Phalcon/db/DialectInterface.php | 242 +- src/Phalcon/db/Enum.php | 62 - src/Phalcon/db/Exception.php | 2 + src/Phalcon/db/Index.php | 50 +- src/Phalcon/db/IndexInterface.php | 22 +- src/Phalcon/db/Profiler.php | 62 +- src/Phalcon/db/RawValue.php | 12 +- src/Phalcon/db/Reference.php | 106 +- src/Phalcon/db/ReferenceInterface.php | 44 +- src/Phalcon/db/ResultInterface.php | 63 +- .../adapter/{pdo/AbstractPdo.php => Pdo.php} | 341 ++- src/Phalcon/db/adapter/PdoFactory.php | 47 - src/Phalcon/db/adapter/pdo/Factory.php | 31 + src/Phalcon/db/adapter/pdo/Mysql.php | 61 +- src/Phalcon/db/adapter/pdo/Postgresql.php | 113 +- src/Phalcon/db/adapter/pdo/Sqlite.php | 85 +- src/Phalcon/db/dialect/Mysql.php | 220 +- src/Phalcon/db/dialect/Postgresql.php | 208 +- src/Phalcon/db/dialect/Sqlite.php | 219 +- src/Phalcon/db/profiler/Item.php | 80 +- src/Phalcon/db/result/Pdo.php | 165 +- src/Phalcon/debug/Dump.php | 120 +- src/Phalcon/debug/Exception.php | 2 + src/Phalcon/di/Exception.php | 2 + src/Phalcon/di/FactoryDefault.php | 7 +- src/Phalcon/di/Injectable.php | 53 +- src/Phalcon/di/InjectionAwareInterface.php | 14 +- src/Phalcon/di/Service.php | 99 +- src/Phalcon/di/ServiceInterface.php | 48 +- src/Phalcon/di/ServiceProviderInterface.php | 25 +- .../exception/ServiceResolutionException.php | 11 - .../exception/Serviceresolutionexception.php | 11 + src/Phalcon/di/service/Builder.php | 28 +- src/Phalcon/dispatcher/Exception.php | 29 - src/Phalcon/domain/payload/Payload.php | 121 - src/Phalcon/domain/payload/PayloadFactory.php | 18 - .../domain/payload/PayloadInterface.php | 11 - .../domain/payload/ReadableInterface.php | 47 - src/Phalcon/domain/payload/Status.php | 76 - .../domain/payload/WriteableInterface.php | 54 - src/Phalcon/escaper/Exception.php | 2 + src/Phalcon/events/Event.php | 95 +- src/Phalcon/events/EventInterface.php | 38 +- src/Phalcon/events/EventsAwareInterface.php | 15 +- src/Phalcon/events/Manager.php | 116 +- src/Phalcon/events/ManagerInterface.php | 28 +- src/Phalcon/factory/AbstractFactory.php | 55 - src/Phalcon/factory/Exception.php | 7 +- src/Phalcon/filter/Filter.php | 154 -- src/Phalcon/filter/FilterFactory.php | 29 - src/Phalcon/filter/FilterInterface.php | 21 - src/Phalcon/filter/Filterlocator.php | 51 + src/Phalcon/filter/Filterlocatorfactory.php | 42 + src/Phalcon/filter/UserFilterInterface.php | 20 + .../sanitize/{AbsInt.php => Absint.php} | 12 +- src/Phalcon/filter/sanitize/Alnum.php | 12 +- src/Phalcon/filter/sanitize/Alpha.php | 12 +- .../sanitize/{BoolVal.php => Boolval.php} | 12 +- src/Phalcon/filter/sanitize/Email.php | 12 +- .../sanitize/{FloatVal.php => Floatval.php} | 12 +- .../sanitize/{IntVal.php => Intval.php} | 12 +- src/Phalcon/filter/sanitize/Lower.php | 12 +- .../{LowerFirst.php => Lowerfirst.php} | 12 +- src/Phalcon/filter/sanitize/Regex.php | 14 +- src/Phalcon/filter/sanitize/Remove.php | 13 +- src/Phalcon/filter/sanitize/Replace.php | 14 +- src/Phalcon/filter/sanitize/Special.php | 12 +- .../{SpecialFull.php => Specialfull.php} | 12 +- .../sanitize/{StringVal.php => Stringval.php} | 12 +- src/Phalcon/filter/sanitize/Striptags.php | 12 +- src/Phalcon/filter/sanitize/Trim.php | 12 +- src/Phalcon/filter/sanitize/Upper.php | 12 +- .../{UpperFirst.php => Upperfirst.php} | 12 +- .../{UpperWords.php => Upperwords.php} | 12 +- src/Phalcon/filter/sanitize/Url.php | 12 +- src/Phalcon/firewall/Exception.php | 11 - .../firewall/adapter/AbstractAdapter.php | 190 -- src/Phalcon/firewall/adapter/Acl.php | 174 -- .../firewall/adapter/AdapterInterface.php | 61 - src/Phalcon/firewall/adapter/Annotations.php | 108 - src/Phalcon/firewall/adapter/micro/Acl.php | 197 -- src/Phalcon/flash/AbstractFlash.php | 234 -- src/Phalcon/flash/Direct.php | 11 +- src/Phalcon/flash/Exception.php | 2 + src/Phalcon/flash/FlashInterface.php | 53 - src/Phalcon/flash/Session.php | 53 +- .../AbstractElement.php => Element.php} | 253 +- .../forms/{element => }/ElementInterface.php | 224 +- src/Phalcon/forms/Exception.php | 2 + src/Phalcon/forms/Form.php | 258 +- src/Phalcon/forms/Manager.php | 12 +- src/Phalcon/forms/element/Check.php | 4 +- src/Phalcon/forms/element/Date.php | 6 +- src/Phalcon/forms/element/Email.php | 4 +- src/Phalcon/forms/element/File.php | 6 +- src/Phalcon/forms/element/Hidden.php | 4 +- src/Phalcon/forms/element/Numeric.php | 4 +- src/Phalcon/forms/element/Password.php | 4 +- src/Phalcon/forms/element/Radio.php | 4 +- src/Phalcon/forms/element/Select.php | 30 +- src/Phalcon/forms/element/Submit.php | 6 +- src/Phalcon/forms/element/Text.php | 4 +- src/Phalcon/forms/element/TextArea.php | 6 +- src/Phalcon/helper/Arr.php | 241 +- src/Phalcon/helper/Exception.php | 3 + src/Phalcon/helper/Number.php | 23 - src/Phalcon/helper/Str.php | 413 --- src/Phalcon/html/Attributes.php | 25 - src/Phalcon/html/Breadcrumbs.php | 79 +- src/Phalcon/html/Exception.php | 1 + src/Phalcon/html/Tag.php | 2222 ++++++++--------- src/Phalcon/html/TagFactory.php | 38 - src/Phalcon/html/Taglocator.php | 14 + src/Phalcon/html/Taglocatorfactory.php | 42 + .../html/attributes/AttributesInterface.php | 28 - .../html/attributes/RenderInterface.php | 20 - src/Phalcon/html/helper/AbstractHelper.php | 73 - src/Phalcon/html/helper/Abstracthelper.php | 54 + src/Phalcon/html/helper/Anchor.php | 21 +- src/Phalcon/html/helper/AnchorRaw.php | 21 - src/Phalcon/html/helper/Body.php | 19 - src/Phalcon/html/helper/Button.php | 19 +- src/Phalcon/html/helper/Close.php | 21 - src/Phalcon/html/helper/Element.php | 21 +- src/Phalcon/html/helper/ElementRaw.php | 24 - src/Phalcon/html/helper/Form.php | 17 +- src/Phalcon/html/helper/Formclose.php | 20 + src/Phalcon/html/helper/Img.php | 23 - src/Phalcon/html/helper/Label.php | 22 - src/Phalcon/html/helper/TextArea.php | 20 - src/Phalcon/html/helper/Textarea.php | 21 + src/Phalcon/http/Cookie.php | 201 +- src/Phalcon/http/CookieInterface.php | 118 +- src/Phalcon/http/Request.php | 715 +++--- src/Phalcon/http/RequestInterface.php | 418 +--- src/Phalcon/http/Response.php | 382 ++- src/Phalcon/http/ResponseInterface.php | 122 +- src/Phalcon/http/message/AbstractCommon.php | 41 - src/Phalcon/http/message/AbstractMessage.php | 369 --- src/Phalcon/http/message/AbstractRequest.php | 165 -- src/Phalcon/http/message/Request.php | 21 - src/Phalcon/http/message/RequestFactory.php | 22 - src/Phalcon/http/message/Response.php | 123 - src/Phalcon/http/message/ResponseFactory.php | 25 - src/Phalcon/http/message/ServerRequest.php | 331 --- .../http/message/ServerRequestFactory.php | 209 -- src/Phalcon/http/message/Stream.php | 195 -- src/Phalcon/http/message/StreamFactory.php | 52 - src/Phalcon/http/message/UploadedFile.php | 240 -- .../http/message/UploadedFileFactory.php | 34 - src/Phalcon/http/message/Uri.php | 432 ---- src/Phalcon/http/message/UriFactory.php | 20 - .../exception/InvalidArgumentException.php | 16 - src/Phalcon/http/message/stream/Input.php | 76 - src/Phalcon/http/message/stream/Memory.php | 22 - src/Phalcon/http/message/stream/Temp.php | 22 - src/Phalcon/http/request/File.php | 80 +- src/Phalcon/http/request/FileInterface.php | 28 +- src/Phalcon/http/response/Cookies.php | 129 +- .../http/response/CookiesInterface.php | 66 +- src/Phalcon/http/response/Headers.php | 46 +- .../http/response/HeadersInterface.php | 34 +- .../http/server/AbstractMiddleware.php | 28 - .../http/server/AbstractRequestHandler.php | 24 - .../AbstractAdapter.php => Adapter.php} | 193 +- src/Phalcon/image/AdapterInterface.php | 98 + src/Phalcon/image/Enum.php | 43 - src/Phalcon/image/Exception.php | 9 +- src/Phalcon/image/Factory.php | 35 + src/Phalcon/image/ImageFactory.php | 42 - .../image/adapter/AdapterInterface.php | 105 - src/Phalcon/image/adapter/Gd.php | 130 +- src/Phalcon/image/adapter/Imagick.php | 183 +- src/Phalcon/logger/Adapter.php | 174 ++ src/Phalcon/logger/AdapterFactory.php | 38 - src/Phalcon/logger/AdapterInterface.php | 144 ++ src/Phalcon/logger/Factory.php | 33 + src/Phalcon/logger/Formatter.php | 30 + src/Phalcon/logger/FormatterInterface.php | 24 + src/Phalcon/logger/Item.php | 47 +- src/Phalcon/logger/Logger.php | 268 -- src/Phalcon/logger/LoggerFactory.php | 42 - src/Phalcon/logger/Multiple.php | 125 + .../logger/adapter/AbstractAdapter.php | 105 - .../logger/adapter/Abstractadapter.php | 100 + .../logger/adapter/AdapterInterface.php | 70 - .../logger/adapter/Adapterinterface.php | 54 + src/Phalcon/logger/adapter/Blackhole.php | 37 + src/Phalcon/logger/adapter/File.php | 82 + src/Phalcon/logger/adapter/Firephp.php | 55 + src/Phalcon/logger/adapter/Noop.php | 34 +- src/Phalcon/logger/adapter/Stream.php | 71 +- src/Phalcon/logger/adapter/Syslog.php | 56 +- .../logger/formatter/AbstractFormatter.php | 25 - .../logger/formatter/Abstractformatter.php | 19 + src/Phalcon/logger/formatter/Firephp.php | 72 + ...erInterface.php => Formatterinterface.php} | 20 +- src/Phalcon/logger/formatter/Json.php | 37 +- src/Phalcon/logger/formatter/Line.php | 23 +- src/Phalcon/logger/formatter/Syslog.php | 9 +- src/Phalcon/messages/Exception.php | 3 +- src/Phalcon/messages/Message.php | 244 +- src/Phalcon/messages/MessageInterface.php | 95 - src/Phalcon/messages/Messageinterface.php | 72 + src/Phalcon/messages/Messages.php | 299 +-- src/Phalcon/mvc/Application.php | 43 +- src/Phalcon/mvc/Collection.php | 859 ++++--- src/Phalcon/mvc/CollectionInterface.php | 143 +- src/Phalcon/mvc/Controller.php | 16 +- src/Phalcon/mvc/Dispatcher.php | 175 +- src/Phalcon/mvc/DispatcherInterface.php | 38 +- src/Phalcon/mvc/EntityInterface.php | 6 +- src/Phalcon/mvc/Micro.php | 308 ++- src/Phalcon/mvc/Model.php | 2069 +++++++-------- src/Phalcon/mvc/ModelInterface.php | 314 ++- src/Phalcon/mvc/ModuleDefinitionInterface.php | 8 +- src/Phalcon/mvc/Router.php | 467 ++-- src/Phalcon/mvc/RouterInterface.php | 188 +- src/Phalcon/mvc/Url.php | 184 ++ src/Phalcon/{url => mvc}/UrlInterface.php | 45 +- src/Phalcon/mvc/View.php | 708 +++--- src/Phalcon/mvc/ViewBaseInterface.php | 69 +- src/Phalcon/mvc/ViewInterface.php | 176 +- src/Phalcon/mvc/collection/Behavior.php | 34 +- .../mvc/collection/BehaviorInterface.php | 14 +- src/Phalcon/mvc/collection/Document.php | 45 +- src/Phalcon/mvc/collection/Manager.php | 142 +- .../mvc/collection/ManagerInterface.php | 74 +- .../mvc/collection/behavior/SoftDelete.php | 2 +- .../mvc/collection/behavior/Timestampable.php | 2 +- .../mvc/controller/BindModelInterface.php | 2 +- src/Phalcon/mvc/dispatcher/Exception.php | 2 +- src/Phalcon/mvc/micro/Collection.php | 154 +- src/Phalcon/mvc/micro/CollectionInterface.php | 110 +- src/Phalcon/mvc/micro/Exception.php | 2 + src/Phalcon/mvc/micro/LazyLoader.php | 20 +- src/Phalcon/mvc/micro/MiddlewareInterface.php | 2 + src/Phalcon/mvc/model/Behavior.php | 38 +- src/Phalcon/mvc/model/BehaviorInterface.php | 14 +- src/Phalcon/mvc/model/Binder.php | 48 +- src/Phalcon/mvc/model/BinderInterface.php | 32 +- src/Phalcon/mvc/model/Criteria.php | 246 +- src/Phalcon/mvc/model/CriteriaInterface.php | 273 +- src/Phalcon/mvc/model/Manager.php | 374 +-- src/Phalcon/mvc/model/ManagerInterface.php | 426 ++-- src/Phalcon/mvc/model/Message.php | 147 ++ src/Phalcon/mvc/model/MessageInterface.php | 70 + src/Phalcon/mvc/model/MetaData.php | 465 ++-- src/Phalcon/mvc/model/MetaDataInterface.php | 170 +- src/Phalcon/mvc/model/Query.php | 263 +- src/Phalcon/mvc/model/QueryInterface.php | 94 +- src/Phalcon/mvc/model/Relation.php | 124 +- src/Phalcon/mvc/model/RelationInterface.php | 89 +- src/Phalcon/mvc/model/ResultInterface.php | 5 +- src/Phalcon/mvc/model/Resultset.php | 227 +- src/Phalcon/mvc/model/ResultsetInterface.php | 88 +- src/Phalcon/mvc/model/Row.php | 54 +- src/Phalcon/mvc/model/Transaction.php | 102 +- .../mvc/model/TransactionInterface.php | 69 +- src/Phalcon/mvc/model/ValidationFailed.php | 20 +- src/Phalcon/mvc/model/Validator.php | 73 + src/Phalcon/mvc/model/ValidatorInterface.php | 31 + src/Phalcon/mvc/model/behavior/SoftDelete.php | 6 +- .../mvc/model/behavior/Timestampable.php | 11 +- .../mvc/model/binder/BindableInterface.php | 3 +- src/Phalcon/mvc/model/metadata/Apc.php | 61 + src/Phalcon/mvc/model/metadata/Apcu.php | 34 +- .../model/metadata/{Stream.php => Files.php} | 26 +- .../mvc/model/metadata/Libmemcached.php | 48 +- src/Phalcon/mvc/model/metadata/Memcache.php | 64 + src/Phalcon/mvc/model/metadata/Memory.php | 9 +- src/Phalcon/mvc/model/metadata/Redis.php | 35 +- src/Phalcon/mvc/model/metadata/Session.php | 50 + .../mvc/model/metadata/StrategyInterface.php | 23 +- src/Phalcon/mvc/model/metadata/Xcache.php | 58 + .../model/metadata/strategy/Annotations.php | 21 +- .../model/metadata/strategy/Introspection.php | 12 +- src/Phalcon/mvc/model/query/Builder.php | 835 +++---- .../mvc/model/query/BuilderInterface.php | 319 +-- src/Phalcon/mvc/model/query/Lang.php | 10 +- src/Phalcon/mvc/model/query/Status.php | 26 +- .../mvc/model/query/StatusInterface.php | 14 +- src/Phalcon/mvc/model/resultset/Complex.php | 21 +- src/Phalcon/mvc/model/resultset/Simple.php | 36 +- src/Phalcon/mvc/model/transaction/Failed.php | 12 +- src/Phalcon/mvc/model/transaction/Manager.php | 133 +- .../model/transaction/ManagerInterface.php | 66 +- src/Phalcon/mvc/model/validator/Email.php | 49 + .../mvc/model/validator/Exclusionin.php | 50 + .../mvc/model/validator/Inclusionin.php | 50 + src/Phalcon/mvc/model/validator/Ip.php | 82 + .../mvc/model/validator/Numericality.php | 49 + .../mvc/model/validator/PresenceOf.php | 50 + src/Phalcon/mvc/model/validator/Regex.php | 50 + .../mvc/model/validator/StringLength.php | 53 + .../mvc/model/validator/Uniqueness.php | 52 + src/Phalcon/mvc/model/validator/Url.php | 49 + src/Phalcon/mvc/router/Annotations.php | 50 +- src/Phalcon/mvc/router/Group.php | 195 +- src/Phalcon/mvc/router/GroupInterface.php | 179 +- src/Phalcon/mvc/router/Route.php | 332 +-- src/Phalcon/mvc/router/RouteInterface.php | 93 +- src/Phalcon/mvc/url/Exception.php | 13 + src/Phalcon/mvc/user/Component.php | 14 + src/Phalcon/mvc/user/Module.php | 14 + src/Phalcon/mvc/user/Plugin.php | 14 + .../{engine/AbstractEngine.php => Engine.php} | 30 +- .../mvc/view/{engine => }/EngineInterface.php | 10 +- src/Phalcon/mvc/view/Simple.php | 255 +- src/Phalcon/mvc/view/engine/Php.php | 6 +- src/Phalcon/mvc/view/engine/Volt.php | 80 +- src/Phalcon/mvc/view/engine/volt/Compiler.php | 433 ++-- .../mvc/view/engine/volt/Exception.php | 6 +- src/Phalcon/paginator/Adapter.php | 44 + .../{adapter => }/AdapterInterface.php | 25 +- src/Phalcon/paginator/Factory.php | 33 + src/Phalcon/paginator/PaginatorFactory.php | 65 - src/Phalcon/paginator/Repository.php | 217 +- src/Phalcon/paginator/RepositoryInterface.php | 117 - src/Phalcon/paginator/Repositoryinterface.php | 75 + .../paginator/adapter/AbstractAdapter.php | 79 - src/Phalcon/paginator/adapter/Model.php | 35 +- src/Phalcon/paginator/adapter/NativeArray.php | 30 +- .../paginator/adapter/QueryBuilder.php | 41 +- src/Phalcon/queue/Beanstalk.php | 269 ++ src/Phalcon/queue/beanstalk/Exception.php | 13 + src/Phalcon/queue/beanstalk/Job.php | 104 + src/Phalcon/security/Random.php | 167 +- src/Phalcon/service/Exception.php | 12 + src/Phalcon/service/Locator.php | 59 + .../service/Locatorfactoryinterface.php | 18 + src/Phalcon/service/Locatorinterface.php | 27 + src/Phalcon/session/Adapter.php | 251 ++ src/Phalcon/session/AdapterInterface.php | 108 + src/Phalcon/session/Bag.php | 186 +- src/Phalcon/session/BagInterface.php | 73 + src/Phalcon/session/Factory.php | 32 + src/Phalcon/session/Manager.php | 445 ++-- src/Phalcon/session/ManagerInterface.php | 189 -- src/Phalcon/session/Managerinterface.php | 139 ++ .../session/adapter/AbstractAdapter.php | 70 - src/Phalcon/session/adapter/Files.php | 29 + src/Phalcon/session/adapter/Libmemcached.php | 92 +- src/Phalcon/session/adapter/Memcache.php | 95 + src/Phalcon/session/adapter/Noop.php | 152 +- src/Phalcon/session/adapter/Redis.php | 90 +- src/Phalcon/session/adapter/Stream.php | 70 - src/Phalcon/storage/AdapterFactory.php | 43 - src/Phalcon/storage/Exception.php | 13 - src/Phalcon/storage/SerializerFactory.php | 37 - .../storage/adapter/AbstractAdapter.php | 195 -- .../storage/adapter/AdapterInterface.php | 92 - src/Phalcon/storage/adapter/Apcu.php | 112 - src/Phalcon/storage/adapter/Libmemcached.php | 125 - src/Phalcon/storage/adapter/Memory.php | 116 - src/Phalcon/storage/adapter/Redis.php | 128 - src/Phalcon/storage/adapter/Stream.php | 156 -- .../storage/serializer/AbstractSerializer.php | 46 - src/Phalcon/storage/serializer/Base64.php | 30 - src/Phalcon/storage/serializer/Igbinary.php | 30 - src/Phalcon/storage/serializer/Json.php | 30 - src/Phalcon/storage/serializer/Msgpack.php | 30 - src/Phalcon/storage/serializer/None.php | 30 - src/Phalcon/storage/serializer/Php.php | 30 - .../serializer/SerializerInterface.php | 27 - src/Phalcon/tag/Select.php | 22 +- .../AbstractAdapter.php => Adapter.php} | 58 +- .../{adapter => }/AdapterInterface.php | 32 +- src/Phalcon/translate/Factory.php | 30 + src/Phalcon/translate/InterpolatorFactory.php | 46 - .../translate/InterpolatorInterface.php | 22 + src/Phalcon/translate/TranslateFactory.php | 51 - src/Phalcon/translate/adapter/Csv.php | 33 +- src/Phalcon/translate/adapter/Gettext.php | 102 +- src/Phalcon/translate/adapter/NativeArray.php | 34 +- .../interpolator/AssociativeArray.php | 15 +- .../translate/interpolator/IndexedArray.php | 15 +- .../interpolator/InterpolatorInterface.php | 22 - .../AbstractCombinedFieldsValidator.php | 11 - src/Phalcon/validation/AbstractValidator.php | 132 - .../validation/AbstractValidatorComposite.php | 30 - .../validation/CombinedFieldsValidator.php | 13 + src/Phalcon/validation/Exception.php | 2 + src/Phalcon/validation/Message.php | 110 + src/Phalcon/validation/MessageInterface.php | 73 + src/Phalcon/validation/Validator.php | 97 + .../ValidatorCompositeInterface.php | 27 - src/Phalcon/validation/ValidatorFactory.php | 36 - src/Phalcon/validation/ValidatorInterface.php | 56 +- src/Phalcon/validation/message/Group.php | 155 ++ src/Phalcon/validation/validator/Alnum.php | 15 +- src/Phalcon/validation/validator/Alpha.php | 15 +- src/Phalcon/validation/validator/Between.php | 15 +- src/Phalcon/validation/validator/Callback.php | 15 +- .../validation/validator/Confirmation.php | 17 +- .../validation/validator/CreditCard.php | 20 +- src/Phalcon/validation/validator/Date.php | 17 +- src/Phalcon/validation/validator/Digit.php | 15 +- src/Phalcon/validation/validator/Email.php | 15 +- .../validation/validator/Exception.php | 5 +- .../validation/validator/ExclusionIn.php | 15 +- src/Phalcon/validation/validator/File.php | 29 +- .../validation/validator/Identical.php | 15 +- .../validation/validator/InclusionIn.php | 15 +- src/Phalcon/validation/validator/Ip.php | 60 +- .../validation/validator/Numericality.php | 15 +- .../validation/validator/PresenceOf.php | 15 +- src/Phalcon/validation/validator/Regex.php | 15 +- .../validation/validator/StringLength.php | 35 +- .../validation/validator/Uniqueness.php | 53 +- src/Phalcon/validation/validator/Url.php | 15 +- .../validator/file/AbstractFile.php | 151 -- .../validation/validator/file/MimeType.php | 68 - .../validator/file/resolution/Equal.php | 59 - .../validator/file/resolution/Max.php | 64 - .../validator/file/resolution/Min.php | 64 - .../validation/validator/file/size/Equal.php | 64 - .../validation/validator/file/size/Max.php | 64 - .../validation/validator/file/size/Min.php | 64 - .../validation/validator/stringlength/Max.php | 66 - .../validation/validator/stringlength/Min.php | 66 - 570 files changed, 25277 insertions(+), 28067 deletions(-) create mode 100644 src/Phalcon/Acl.php rename src/Phalcon/{application/AbstractApplication.php => Application.php} (58%) delete mode 100644 src/Phalcon/Cache.php delete mode 100644 src/Phalcon/Collection.php create mode 100644 src/Phalcon/CryptInterface.php create mode 100644 src/Phalcon/Db.php rename src/Phalcon/{di => }/DiInterface.php (63%) rename src/Phalcon/{dispatcher/AbstractDispatcher.php => Dispatcher.php} (54%) rename src/Phalcon/{dispatcher => }/DispatcherInterface.php (63%) rename src/Phalcon/{escaper => }/EscaperInterface.php (65%) create mode 100644 src/Phalcon/Factory.php create mode 100644 src/Phalcon/FactoryInterface.php create mode 100644 src/Phalcon/Filter.php create mode 100644 src/Phalcon/FilterInterface.php create mode 100644 src/Phalcon/Flash.php create mode 100644 src/Phalcon/FlashInterface.php create mode 100644 src/Phalcon/Image.php create mode 100644 src/Phalcon/Logger.php create mode 100644 src/Phalcon/Translate.php create mode 100644 src/Phalcon/Urlinterface.php rename src/Phalcon/{validation => }/ValidationInterface.php (56%) rename src/Phalcon/acl/{adapter/AbstractAdapter.php => Adapter.php} (58%) rename src/Phalcon/acl/{adapter => }/AdapterInterface.php (57%) delete mode 100644 src/Phalcon/acl/ComponentInterface.php rename src/Phalcon/acl/{ComponentAware.php => Componentaware.php} (66%) create mode 100644 src/Phalcon/acl/Componentinterface.php delete mode 100644 src/Phalcon/acl/Enum.php rename src/Phalcon/annotations/{adapter/AbstractAdapter.php => Adapter.php} (63%) rename src/Phalcon/annotations/{adapter => }/AdapterInterface.php (72%) delete mode 100644 src/Phalcon/annotations/AnnotationsFactory.php create mode 100644 src/Phalcon/annotations/Factory.php create mode 100644 src/Phalcon/annotations/adapter/Apc.php rename src/Phalcon/annotations/adapter/{Stream.php => Files.php} (55%) create mode 100644 src/Phalcon/annotations/adapter/Xcache.php delete mode 100644 src/Phalcon/assets/AssetInterface.php create mode 100644 src/Phalcon/assets/Assetinterface.php create mode 100644 src/Phalcon/assets/Resource.php create mode 100644 src/Phalcon/assets/ResourceInterface.php create mode 100644 src/Phalcon/assets/resource/Css.php create mode 100644 src/Phalcon/assets/resource/Js.php delete mode 100644 src/Phalcon/cache/AdapterFactory.php create mode 100644 src/Phalcon/cache/Backend.php create mode 100644 src/Phalcon/cache/BackendInterface.php delete mode 100644 src/Phalcon/cache/CacheFactory.php create mode 100644 src/Phalcon/cache/Exception.php create mode 100644 src/Phalcon/cache/FrontendInterface.php create mode 100644 src/Phalcon/cache/Multiple.php delete mode 100644 src/Phalcon/cache/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/cache/adapter/Apcu.php delete mode 100644 src/Phalcon/cache/adapter/Libmemcached.php delete mode 100644 src/Phalcon/cache/adapter/Memory.php delete mode 100644 src/Phalcon/cache/adapter/Redis.php delete mode 100644 src/Phalcon/cache/adapter/Stream.php create mode 100644 src/Phalcon/cache/backend/Apc.php create mode 100644 src/Phalcon/cache/backend/Apcu.php create mode 100644 src/Phalcon/cache/backend/Factory.php create mode 100644 src/Phalcon/cache/backend/File.php create mode 100644 src/Phalcon/cache/backend/Libmemcached.php create mode 100644 src/Phalcon/cache/backend/Memcache.php create mode 100644 src/Phalcon/cache/backend/Memory.php create mode 100644 src/Phalcon/cache/backend/Mongo.php create mode 100644 src/Phalcon/cache/backend/Redis.php create mode 100644 src/Phalcon/cache/backend/Xcache.php delete mode 100644 src/Phalcon/cache/exception/Exception.php delete mode 100644 src/Phalcon/cache/exception/InvalidArgumentException.php create mode 100644 src/Phalcon/cache/frontend/Base64.php create mode 100644 src/Phalcon/cache/frontend/Data.php create mode 100644 src/Phalcon/cache/frontend/Factory.php create mode 100644 src/Phalcon/cache/frontend/Igbinary.php create mode 100644 src/Phalcon/cache/frontend/Json.php create mode 100644 src/Phalcon/cache/frontend/Msgpack.php create mode 100644 src/Phalcon/cache/frontend/None.php create mode 100644 src/Phalcon/cache/frontend/Output.php delete mode 100644 src/Phalcon/collection/Exception.php delete mode 100644 src/Phalcon/collection/ReadOnly.php delete mode 100644 src/Phalcon/config/ConfigFactory.php create mode 100644 src/Phalcon/config/Factory.php delete mode 100644 src/Phalcon/crypt/CryptInterface.php delete mode 100644 src/Phalcon/db/AbstractDb.php rename src/Phalcon/db/{adapter/AbstractAdapter.php => Adapter.php} (68%) rename src/Phalcon/db/{adapter => }/AdapterInterface.php (52%) delete mode 100644 src/Phalcon/db/Enum.php rename src/Phalcon/db/adapter/{pdo/AbstractPdo.php => Pdo.php} (75%) delete mode 100644 src/Phalcon/db/adapter/PdoFactory.php create mode 100644 src/Phalcon/db/adapter/pdo/Factory.php delete mode 100644 src/Phalcon/di/exception/ServiceResolutionException.php create mode 100644 src/Phalcon/di/exception/Serviceresolutionexception.php delete mode 100644 src/Phalcon/dispatcher/Exception.php delete mode 100644 src/Phalcon/domain/payload/Payload.php delete mode 100644 src/Phalcon/domain/payload/PayloadFactory.php delete mode 100644 src/Phalcon/domain/payload/PayloadInterface.php delete mode 100644 src/Phalcon/domain/payload/ReadableInterface.php delete mode 100644 src/Phalcon/domain/payload/Status.php delete mode 100644 src/Phalcon/domain/payload/WriteableInterface.php delete mode 100644 src/Phalcon/factory/AbstractFactory.php delete mode 100644 src/Phalcon/filter/Filter.php delete mode 100644 src/Phalcon/filter/FilterFactory.php delete mode 100644 src/Phalcon/filter/FilterInterface.php create mode 100644 src/Phalcon/filter/Filterlocator.php create mode 100644 src/Phalcon/filter/Filterlocatorfactory.php create mode 100644 src/Phalcon/filter/UserFilterInterface.php rename src/Phalcon/filter/sanitize/{AbsInt.php => Absint.php} (61%) rename src/Phalcon/filter/sanitize/{BoolVal.php => Boolval.php} (60%) rename src/Phalcon/filter/sanitize/{FloatVal.php => Floatval.php} (60%) rename src/Phalcon/filter/sanitize/{IntVal.php => Intval.php} (59%) rename src/Phalcon/filter/sanitize/{LowerFirst.php => Lowerfirst.php} (59%) rename src/Phalcon/filter/sanitize/{SpecialFull.php => Specialfull.php} (67%) rename src/Phalcon/filter/sanitize/{StringVal.php => Stringval.php} (60%) rename src/Phalcon/filter/sanitize/{UpperFirst.php => Upperfirst.php} (59%) rename src/Phalcon/filter/sanitize/{UpperWords.php => Upperwords.php} (64%) delete mode 100644 src/Phalcon/firewall/Exception.php delete mode 100644 src/Phalcon/firewall/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/firewall/adapter/Acl.php delete mode 100644 src/Phalcon/firewall/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/firewall/adapter/Annotations.php delete mode 100644 src/Phalcon/firewall/adapter/micro/Acl.php delete mode 100644 src/Phalcon/flash/AbstractFlash.php delete mode 100644 src/Phalcon/flash/FlashInterface.php rename src/Phalcon/forms/{element/AbstractElement.php => Element.php} (58%) rename src/Phalcon/forms/{element => }/ElementInterface.php (67%) delete mode 100644 src/Phalcon/helper/Number.php delete mode 100644 src/Phalcon/helper/Str.php delete mode 100644 src/Phalcon/html/Attributes.php delete mode 100644 src/Phalcon/html/TagFactory.php create mode 100644 src/Phalcon/html/Taglocator.php create mode 100644 src/Phalcon/html/Taglocatorfactory.php delete mode 100644 src/Phalcon/html/attributes/AttributesInterface.php delete mode 100644 src/Phalcon/html/attributes/RenderInterface.php delete mode 100644 src/Phalcon/html/helper/AbstractHelper.php create mode 100644 src/Phalcon/html/helper/Abstracthelper.php delete mode 100644 src/Phalcon/html/helper/AnchorRaw.php delete mode 100644 src/Phalcon/html/helper/Body.php delete mode 100644 src/Phalcon/html/helper/Close.php delete mode 100644 src/Phalcon/html/helper/ElementRaw.php create mode 100644 src/Phalcon/html/helper/Formclose.php delete mode 100644 src/Phalcon/html/helper/Img.php delete mode 100644 src/Phalcon/html/helper/Label.php delete mode 100644 src/Phalcon/html/helper/TextArea.php create mode 100644 src/Phalcon/html/helper/Textarea.php delete mode 100644 src/Phalcon/http/message/AbstractCommon.php delete mode 100644 src/Phalcon/http/message/AbstractMessage.php delete mode 100644 src/Phalcon/http/message/AbstractRequest.php delete mode 100644 src/Phalcon/http/message/Request.php delete mode 100644 src/Phalcon/http/message/RequestFactory.php delete mode 100644 src/Phalcon/http/message/Response.php delete mode 100644 src/Phalcon/http/message/ResponseFactory.php delete mode 100644 src/Phalcon/http/message/ServerRequest.php delete mode 100644 src/Phalcon/http/message/ServerRequestFactory.php delete mode 100644 src/Phalcon/http/message/Stream.php delete mode 100644 src/Phalcon/http/message/StreamFactory.php delete mode 100644 src/Phalcon/http/message/UploadedFile.php delete mode 100644 src/Phalcon/http/message/UploadedFileFactory.php delete mode 100644 src/Phalcon/http/message/Uri.php delete mode 100644 src/Phalcon/http/message/UriFactory.php delete mode 100644 src/Phalcon/http/message/exception/InvalidArgumentException.php delete mode 100644 src/Phalcon/http/message/stream/Input.php delete mode 100644 src/Phalcon/http/message/stream/Memory.php delete mode 100644 src/Phalcon/http/message/stream/Temp.php delete mode 100644 src/Phalcon/http/server/AbstractMiddleware.php delete mode 100644 src/Phalcon/http/server/AbstractRequestHandler.php rename src/Phalcon/image/{adapter/AbstractAdapter.php => Adapter.php} (63%) create mode 100644 src/Phalcon/image/AdapterInterface.php delete mode 100644 src/Phalcon/image/Enum.php create mode 100644 src/Phalcon/image/Factory.php delete mode 100644 src/Phalcon/image/ImageFactory.php delete mode 100644 src/Phalcon/image/adapter/AdapterInterface.php create mode 100644 src/Phalcon/logger/Adapter.php delete mode 100644 src/Phalcon/logger/AdapterFactory.php create mode 100644 src/Phalcon/logger/AdapterInterface.php create mode 100644 src/Phalcon/logger/Factory.php create mode 100644 src/Phalcon/logger/Formatter.php create mode 100644 src/Phalcon/logger/FormatterInterface.php delete mode 100644 src/Phalcon/logger/Logger.php delete mode 100644 src/Phalcon/logger/LoggerFactory.php create mode 100644 src/Phalcon/logger/Multiple.php delete mode 100644 src/Phalcon/logger/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/logger/adapter/Abstractadapter.php delete mode 100644 src/Phalcon/logger/adapter/AdapterInterface.php create mode 100644 src/Phalcon/logger/adapter/Adapterinterface.php create mode 100644 src/Phalcon/logger/adapter/Blackhole.php create mode 100644 src/Phalcon/logger/adapter/File.php create mode 100644 src/Phalcon/logger/adapter/Firephp.php delete mode 100644 src/Phalcon/logger/formatter/AbstractFormatter.php create mode 100644 src/Phalcon/logger/formatter/Abstractformatter.php create mode 100644 src/Phalcon/logger/formatter/Firephp.php rename src/Phalcon/logger/formatter/{FormatterInterface.php => Formatterinterface.php} (51%) delete mode 100644 src/Phalcon/messages/MessageInterface.php create mode 100644 src/Phalcon/messages/Messageinterface.php create mode 100644 src/Phalcon/mvc/Url.php rename src/Phalcon/{url => mvc}/UrlInterface.php (61%) create mode 100644 src/Phalcon/mvc/model/Message.php create mode 100644 src/Phalcon/mvc/model/MessageInterface.php create mode 100644 src/Phalcon/mvc/model/Validator.php create mode 100644 src/Phalcon/mvc/model/ValidatorInterface.php create mode 100644 src/Phalcon/mvc/model/metadata/Apc.php rename src/Phalcon/mvc/model/metadata/{Stream.php => Files.php} (57%) create mode 100644 src/Phalcon/mvc/model/metadata/Memcache.php create mode 100644 src/Phalcon/mvc/model/metadata/Session.php create mode 100644 src/Phalcon/mvc/model/metadata/Xcache.php create mode 100644 src/Phalcon/mvc/model/validator/Email.php create mode 100644 src/Phalcon/mvc/model/validator/Exclusionin.php create mode 100644 src/Phalcon/mvc/model/validator/Inclusionin.php create mode 100644 src/Phalcon/mvc/model/validator/Ip.php create mode 100644 src/Phalcon/mvc/model/validator/Numericality.php create mode 100644 src/Phalcon/mvc/model/validator/PresenceOf.php create mode 100644 src/Phalcon/mvc/model/validator/Regex.php create mode 100644 src/Phalcon/mvc/model/validator/StringLength.php create mode 100644 src/Phalcon/mvc/model/validator/Uniqueness.php create mode 100644 src/Phalcon/mvc/model/validator/Url.php create mode 100644 src/Phalcon/mvc/url/Exception.php create mode 100644 src/Phalcon/mvc/user/Component.php create mode 100644 src/Phalcon/mvc/user/Module.php create mode 100644 src/Phalcon/mvc/user/Plugin.php rename src/Phalcon/mvc/view/{engine/AbstractEngine.php => Engine.php} (62%) rename src/Phalcon/mvc/view/{engine => }/EngineInterface.php (68%) create mode 100644 src/Phalcon/paginator/Adapter.php rename src/Phalcon/paginator/{adapter => }/AdapterInterface.php (62%) create mode 100644 src/Phalcon/paginator/Factory.php delete mode 100644 src/Phalcon/paginator/PaginatorFactory.php delete mode 100644 src/Phalcon/paginator/RepositoryInterface.php create mode 100644 src/Phalcon/paginator/Repositoryinterface.php delete mode 100644 src/Phalcon/paginator/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/queue/Beanstalk.php create mode 100644 src/Phalcon/queue/beanstalk/Exception.php create mode 100644 src/Phalcon/queue/beanstalk/Job.php create mode 100644 src/Phalcon/service/Exception.php create mode 100644 src/Phalcon/service/Locator.php create mode 100644 src/Phalcon/service/Locatorfactoryinterface.php create mode 100644 src/Phalcon/service/Locatorinterface.php create mode 100644 src/Phalcon/session/Adapter.php create mode 100644 src/Phalcon/session/AdapterInterface.php create mode 100644 src/Phalcon/session/BagInterface.php create mode 100644 src/Phalcon/session/Factory.php delete mode 100644 src/Phalcon/session/ManagerInterface.php create mode 100644 src/Phalcon/session/Managerinterface.php delete mode 100644 src/Phalcon/session/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/session/adapter/Files.php create mode 100644 src/Phalcon/session/adapter/Memcache.php delete mode 100644 src/Phalcon/session/adapter/Stream.php delete mode 100644 src/Phalcon/storage/AdapterFactory.php delete mode 100644 src/Phalcon/storage/Exception.php delete mode 100644 src/Phalcon/storage/SerializerFactory.php delete mode 100644 src/Phalcon/storage/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/storage/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/storage/adapter/Apcu.php delete mode 100644 src/Phalcon/storage/adapter/Libmemcached.php delete mode 100644 src/Phalcon/storage/adapter/Memory.php delete mode 100644 src/Phalcon/storage/adapter/Redis.php delete mode 100644 src/Phalcon/storage/adapter/Stream.php delete mode 100644 src/Phalcon/storage/serializer/AbstractSerializer.php delete mode 100644 src/Phalcon/storage/serializer/Base64.php delete mode 100644 src/Phalcon/storage/serializer/Igbinary.php delete mode 100644 src/Phalcon/storage/serializer/Json.php delete mode 100644 src/Phalcon/storage/serializer/Msgpack.php delete mode 100644 src/Phalcon/storage/serializer/None.php delete mode 100644 src/Phalcon/storage/serializer/Php.php delete mode 100644 src/Phalcon/storage/serializer/SerializerInterface.php rename src/Phalcon/translate/{adapter/AbstractAdapter.php => Adapter.php} (58%) rename src/Phalcon/translate/{adapter => }/AdapterInterface.php (53%) create mode 100644 src/Phalcon/translate/Factory.php delete mode 100644 src/Phalcon/translate/InterpolatorFactory.php create mode 100644 src/Phalcon/translate/InterpolatorInterface.php delete mode 100644 src/Phalcon/translate/TranslateFactory.php delete mode 100644 src/Phalcon/translate/interpolator/InterpolatorInterface.php delete mode 100644 src/Phalcon/validation/AbstractCombinedFieldsValidator.php delete mode 100644 src/Phalcon/validation/AbstractValidator.php delete mode 100644 src/Phalcon/validation/AbstractValidatorComposite.php create mode 100644 src/Phalcon/validation/CombinedFieldsValidator.php create mode 100644 src/Phalcon/validation/Message.php create mode 100644 src/Phalcon/validation/MessageInterface.php create mode 100644 src/Phalcon/validation/Validator.php delete mode 100644 src/Phalcon/validation/ValidatorCompositeInterface.php delete mode 100644 src/Phalcon/validation/ValidatorFactory.php create mode 100644 src/Phalcon/validation/message/Group.php delete mode 100644 src/Phalcon/validation/validator/file/AbstractFile.php delete mode 100644 src/Phalcon/validation/validator/file/MimeType.php delete mode 100644 src/Phalcon/validation/validator/file/resolution/Equal.php delete mode 100644 src/Phalcon/validation/validator/file/resolution/Max.php delete mode 100644 src/Phalcon/validation/validator/file/resolution/Min.php delete mode 100644 src/Phalcon/validation/validator/file/size/Equal.php delete mode 100644 src/Phalcon/validation/validator/file/size/Max.php delete mode 100644 src/Phalcon/validation/validator/file/size/Min.php delete mode 100644 src/Phalcon/validation/validator/stringlength/Max.php delete mode 100644 src/Phalcon/validation/validator/stringlength/Min.php diff --git a/src/Phalcon/Acl.php b/src/Phalcon/Acl.php new file mode 100644 index 00000000..498be5ea --- /dev/null +++ b/src/Phalcon/Acl.php @@ -0,0 +1,60 @@ + + * use Phalcon\Acl; + * use Phalcon\Acl\Role; + * use Phalcon\Acl\Resource; + * use Phalcon\Acl\Adapter\Memory; + * + * $acl = new Memory(); + * + * // Default action is deny access + * $acl->setDefaultAction(Acl::DENY); + * + * // Create some roles + * $roleAdmins = new Role("Administrators", "Super-User role"); + * $roleGuests = new Role("Guests"); + * + * // Add "Guests" role to acl + * $acl->addRole($roleGuests); + * + * // Add "Designers" role to acl + * $acl->addRole("Designers"); + * + * // Define the "Customers" resource + * $customersResource = new Resource("Customers", "Customers management"); + * + * // Add "customers" resource with a couple of operations + * $acl->addResource($customersResource, "search"); + * $acl->addResource($customersResource, ["create", "update"]); + * + * // Set access level for roles into resources + * $acl->allow("Guests", "Customers", "search"); + * $acl->allow("Guests", "Customers", "create"); + * $acl->deny("Guests", "Customers", "update"); + * + * // Check whether role has access to the operations + * $acl->isAllowed("Guests", "Customers", "edit"); // Returns 0 + * $acl->isAllowed("Guests", "Customers", "search"); // Returns 1 + * $acl->isAllowed("Guests", "Customers", "create"); // Returns 1 + * + */ +abstract class Acl +{ + + const ALLOW = 1; + + + const DENY = 0; + + +} diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/Application.php similarity index 58% rename from src/Phalcon/application/AbstractApplication.php rename to src/Phalcon/Application.php index b0376906..6b5b964a 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/Application.php @@ -1,97 +1,91 @@ * $this->registerModules( * [ * "frontend" => [ - * "className" => \Multiple\Frontend\Module::class, + * "className" => "Multiple\\Frontend\\Module", * "path" => "../apps/frontend/Module.php", * ], * "backend" => [ - * "className" => \Multiple\Backend\Module::class, + * "className" => "Multiple\\Backend\\Module", * "path" => "../apps/backend/Module.php", * ], * ] * ); - * ``` + * * * @param array $modules * @param bool $merge * @return Application */ - public function registerModules(array $modules, bool $merge = false): Application {} + public function registerModules(array $modules, $merge = false) {} + + /** + * Return the modules registered in the application + * + * @return array + */ + public function getModules() {} + + /** + * Gets the module definition registered in the application via module name + * + * @param string $name + * @return array|object + */ + public function getModule($name) {} /** * Sets the module name to be used if the router doesn't return a valid module @@ -99,14 +93,18 @@ public function registerModules(array $modules, bool $merge = false): Applicatio * @param string $defaultModule * @return Application */ - public function setDefaultModule(string $defaultModule): Application {} + public function setDefaultModule($defaultModule) {} /** - * Sets the events manager + * Returns the default module name * - * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return Application + * @return string + */ + public function getDefaultModule() {} + + /** + * Handles a request */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): Application {} + abstract public function handle(); } diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php deleted file mode 100644 index 444fa3d7..00000000 --- a/src/Phalcon/Cache.php +++ /dev/null @@ -1,164 +0,0 @@ - value pairs. Cache keys that do not exist or are stale will have $default as value. - * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if $keys is neither an array nor a Traversable, - * or if any of the $keys are not a legal value. - * @param iterable $keys A list of keys that can obtained in a single operation. - * @param mixed $defaultValue - * @return mixed - */ - public function getMultiple($keys, $defaultValue = null) {} - - /** - * Determines whether an item is present in the cache. - * - * @param string $key The cache item key. - * - * @return bool - * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. - * @param mixed $key - * @return bool - */ - public function has($key): bool {} - - /** - * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. - * - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and - * the driver supports TTL then the library may set a default value - * for it or let the driver take care of that. - * - * @return bool True on success and false on failure. - * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. - * @param string $key The key of the item to store. - * @param mixed $value The value of the item to store. Must be serializable. - * @param mixed $ttl - * @return bool - */ - public function set($key, $value, $ttl = null): bool {} - - /** - * Persists a set of key => value pairs in the cache, with an optional TTL. - * - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and - * the driver supports TTL then the library may set a default value - * for it or let the driver take care of that. - * - * @return bool True on success and false on failure. - * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if $values is neither an array nor a Traversable, - * or if any of the $values are not a legal value. - * @param iterable $values A list of key => value pairs for a multiple-set operation. - * @param mixed $ttl - * @return bool - */ - public function setMultiple($values, $ttl = null): bool {} - - /** - * Checks the key. If it contains invalid characters an exception is thrown - * - * @param mixed $key - */ - protected function checkKey($key) {} - - /** - * Checks the key. If it contains invalid characters an exception is thrown - * - * @param mixed $keys - */ - protected function checkKeys($keys) {} - -} diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php deleted file mode 100644 index ecde5727..00000000 --- a/src/Phalcon/Collection.php +++ /dev/null @@ -1,217 +0,0 @@ - * $config = new \Phalcon\Config( * [ * "database" => [ @@ -25,30 +26,109 @@ * ], * ] * ); - * ``` + * */ -class Config extends \Phalcon\Collection +class Config implements \ArrayAccess, \Countable { const DEFAULT_PATH_DELIMITER = '.'; + + static protected $_pathDelimiter; + + /** - * @var string + * Phalcon\Config constructor + * + * @param array $arrayConfig */ - protected $pathDelimiter = null; + public function __construct(array $arrayConfig = null) {} + /** + * Allows to check whether an attribute is defined using the array-syntax + * + * + * var_dump( + * isset($config["database"]) + * ); + * + * + * @param mixed $index + * @return bool + */ + public function offsetExists($index) {} /** - * Gets the default path delimiter + * Returns a value from current config using a dot separated path. * + * + * echo $config->path("unknown.path", "default", "."); + * + * + * @param string $path + * @param mixed $defaultValue + * @param mixed $delimiter + * @return mixed + */ + public function path($path, $defaultValue = null, $delimiter = null) {} + + /** + * Gets an attribute from the configuration, if the attribute isn't defined returns null + * If the value is exactly null or is not defined the default value will be used instead + * + * + * echo $config->get("controllersDir", "../app/controllers/"); + * + * + * @param mixed $index + * @param mixed $defaultValue + * @return mixed + */ + public function get($index, $defaultValue = null) {} + + /** + * Gets an attribute using the array-syntax + * + * + * print_r( + * $config["database"] + * ); + * + * + * @param mixed $index * @return string */ - public function getPathDelimiter(): string {} + public function offsetGet($index) {} + + /** + * Sets an attribute using the array-syntax + * + * + * $config["database"] = [ + * "type" => "Sqlite", + * ]; + * + * + * @param mixed $index + * @param mixed $value + */ + public function offsetSet($index, $value) {} + + /** + * Unsets an attribute using the array-syntax + * + * + * unset($config["database"]); + * + * + * @param mixed $index + */ + public function offsetUnset($index) {} /** * Merges a configuration into the current one * - * ```php + * * $appConfig = new \Phalcon\Config( * [ * "database" => [ @@ -58,62 +138,74 @@ public function getPathDelimiter(): string {} * ); * * $globalConfig->merge($appConfig); - * ``` + * * - * @param mixed $toMerge + * @param Config $config * @return Config */ - public function merge($toMerge): Config {} + public function merge(Config $config) {} /** - * Returns a value from current config using a dot separated path. + * Converts recursively the object to an array * - * ```php - * echo $config->path("unknown.path", "default", "."); - * ``` + * + * print_r( + * $config->toArray() + * ); + * * - * @param string $path - * @param mixed $defaultValue - * @param mixed $delimiter + * @return array */ - public function path(string $path, $defaultValue = null, $delimiter = null) {} + public function toArray() {} /** - * Sets the default path delimiter + * Returns the count of properties set in the config * - * @param string $delimiter - * @return Config + * + * print count($config); + * + * + * or + * + * + * print $config->count(); + * + * + * @return int */ - public function setPathDelimiter(string $delimiter = null): Config {} + public function count() {} /** - * Converts recursively the object to an array + * Restores the state of a Phalcon\Config object * - * ```php - * print_r( - * $config->toArray() - * ); - * ``` + * @param array $data + * @return Config + */ + public static function __set_state(array $data) {} + + /** + * Sets the default path delimiter * - * @return array + * @param string $delimiter */ - public function toArray(): array {} + public static function setPathDelimiter($delimiter = null) {} /** - * Performs a merge recursively + * Gets the default path delimiter * - * @param array $source - * @param array $target - * @return array + * @return string */ - final protected function internalMerge(array $source, array $target): array {} + public static function getPathDelimiter() {} /** - * Sets the collection data + * Helper method for merge configs (forwarding nested config instance) * - * @param mixed $element - * @param mixed $value + * @param Config instance = null + * + * @param Config $config + * @param mixed $instance + * @return Config */ - protected function setData($element, $value) {} + protected final function _merge(Config $config, $instance = null) {} } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 22b70ee1..73a9f388 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -2,38 +2,33 @@ namespace Phalcon; -/** - * PSR-11 Wrapper for `Phalcon\Di` - */ -class Container implements \Psr\Container\ContainerInterface -{ - /** - * @var - */ - protected $container; - +use Psr\Container\ContainerInterface; +use Phalcon\DiInterface; - /** - * Phalcon\Container constructor - * - * @param \Phalcon\Di\DiInterface $container - */ - public function __construct(\Phalcon\Di\DiInterface $container) {} +class Container implements ContainerInterface +{ + /** + * @var + */ + protected $container; - /** - * Return the service - * - * @param mixed $name - * @return mixed - */ - public function get($name) {} + /** + * Phalcon\Di constructor + */ + public function __construct(DiInterface $container) + { + } - /** - * Whether a service exists or not in the container - * - * @param mixed $name - * @return bool - */ - public function has($name): bool {} + /** + * Return the service + */ + public function get($name) { + } + /** + * Whether a service exists or not in the container + */ + public function has($name) : bool + { + } } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 9a547569..722ef5af 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -3,9 +3,11 @@ namespace Phalcon; /** - * Provides encryption capabilities to Phalcon applications. + * Phalcon\Crypt * - * ```php + * Provides encryption facilities to Phalcon applications. + * + * * use Phalcon\Crypt; * * $crypt = new Crypt(); @@ -18,15 +20,18 @@ * $encrypted = $crypt->encrypt($text, $key); * * echo $crypt->decrypt($encrypted, $key); - * ``` + * */ -class Crypt implements \Phalcon\Crypt\CryptInterface +class Crypt implements \Phalcon\CryptInterface { + const PADDING_DEFAULT = 0; + + const PADDING_ANSI_X_923 = 1; - const PADDING_DEFAULT = 0; + const PADDING_PKCS7 = 2; const PADDING_ISO_10126 = 3; @@ -35,43 +40,19 @@ class Crypt implements \Phalcon\Crypt\CryptInterface const PADDING_ISO_IEC_7816_4 = 4; - const PADDING_PKCS7 = 2; + const PADDING_ZERO = 5; const PADDING_SPACE = 6; - const PADDING_ZERO = 5; + protected $_key; - /** - * @var string - */ - protected $authTag; - /** - * @var string - */ - protected $authData = ''; - - /** - * @var int - */ - protected $authTagLength = 16; + protected $_padding = 0; - /** - * @var string - */ - protected $key; - - /** - * @var int - */ - protected $padding = 0; - /** - * @var string - */ - protected $cipher = 'aes-256-cfb'; + protected $_cipher = 'aes-256-cfb'; /** * Available cipher methods. @@ -96,249 +77,224 @@ class Crypt implements \Phalcon\Crypt\CryptInterface /** * Whether calculating message digest enabled or not. + * NOTE: This feature will be enabled by default in Phalcon 4.0.0 * * @var bool */ - protected $useSigning = true; + protected $useSigning = false; - /** - * @return string - */ - public function getAuthTag(): string {} - - /** - * @return string - */ - public function getAuthData(): string {} - - /** - * @return int - */ - public function getAuthTagLength(): int {} - /** * Phalcon\Crypt constructor. * * @param string $cipher * @param bool $useSigning */ - public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = false) {} + public function __construct($cipher = 'aes-256-cfb', $useSigning = false) {} /** - * Decrypts an encrypted text. - * - * ```php - * $encrypted = $crypt->decrypt( - * $encrypted, - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * ``` + * Changes the padding scheme used. * - * @param string $text - * @param string $key - * @return string + * @param int $scheme + * @return \Phalcon\CryptInterface */ - public function decrypt(string $text, string $key = null): string {} + public function setPadding($scheme) {} /** - * Decrypt a text that is coded as a base64 string. + * Sets the cipher algorithm for data encryption and decryption. * - * @throws \Phalcon\Crypt\Mismatch - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string - */ - public function decryptBase64(string $text, $key = null, bool $safe = false): string {} - - /** - * Encrypts a text. + * The `aes-256-gcm' is the preferable cipher, but it is not usable + * until the openssl library is upgraded, which is available in PHP 7.1. * - * ```php - * $encrypted = $crypt->encrypt( - * "Top secret", - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * ``` + * The `aes-256-ctr' is arguably the best choice for cipher + * algorithm for current openssl library version. * - * @param string $text - * @param string $key - * @return string + * @param string $cipher + * @return \Phalcon\CryptInterface */ - public function encrypt(string $text, string $key = null): string {} + public function setCipher($cipher) {} /** - * Encrypts a text returning the result as a base64 string. + * Returns the current cipher * - * @param string $text - * @param mixed $key - * @param bool $safe * @return string */ - public function encryptBase64(string $text, $key = null, bool $safe = false): string {} + public function getCipher() {} /** - * Returns a list of available ciphers. + * Sets the encryption key. * - * @return array + * The `$key' should have been previously generated in a cryptographically safe way. + * + * Bad key: + * "le password" + * + * Better (but still unsafe): + * "#1dj8$=dp?.ak//j1V$~%0X" + * + * Good key: + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * + * @see \Phalcon\Security\Random + * @param string $key + * @return \Phalcon\CryptInterface */ - public function getAvailableCiphers(): array {} + public function setKey($key) {} /** - * Return a list of registered hashing algorithms suitable for hash_hmac. + * Returns the encryption key * - * @return array + * @return string */ - public function getAvailableHashAlgos(): array {} + public function getKey() {} /** - * Returns the current cipher + * Set the name of hashing algorithm. * - * @return string + * @throws \Phalcon\Crypt\Exception + * @param string $hashAlgo + * @return Crypt */ - public function getCipher(): string {} + public function setHashAlgo($hashAlgo) {} /** * Get the name of hashing algorithm. * * @return string */ - public function getHashAlgo(): string {} + public function getHashAlgo() {} /** - * Returns the encryption key + * Sets if the calculating message digest must used. * - * @return string + * NOTE: This feature will be enabled by default in Phalcon 4.0.0 + * + * @param bool $useSigning + * @return Crypt */ - public function getKey(): string {} + public function useSigning($useSigning) {} /** - * @param string $tag - * @return \Phalcon\Crypt\CryptInterface + * Pads texts before encryption. + * + * @link http://www.di-mgt.com.au/cryptopad.html + * @param string $text + * @param string $mode + * @param int $blockSize + * @param int $paddingType */ - public function setAuthTag(string $tag): CryptInterface {} + protected function _cryptPadText($text, $mode, $blockSize, $paddingType) {} /** - * @param string $data - * @return \Phalcon\Crypt\CryptInterface + * Removes a padding from a text. + * + * If the function detects that the text was not padded, it will return it unmodified. + * + * @param string $text Message to be unpadded + * @param string $mode Encryption mode; unpadding is applied only in CBC or ECB mode + * @param int $blockSize Cipher block size + * @param int $paddingType Padding scheme */ - public function setAuthData(string $data): CryptInterface {} + protected function _cryptUnpadText($text, $mode, $blockSize, $paddingType) {} /** - * @param int $length - * @return \Phalcon\Crypt\CryptInterface + * Encrypts a text. + * + * + * $encrypted = $crypt->encrypt( + * "Top secret", + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * + * + * @param string $text + * @param string $key + * @return string */ - public function setAuthTagLength(int $length): CryptInterface {} + public function encrypt($text, $key = null) {} /** - * Sets the cipher algorithm for data encryption and decryption. - * - * The `aes-256-gcm' is the preferable cipher, but it is not usable - * until the openssl library is upgraded, which is available in PHP 7.1. + * Decrypts an encrypted text. * - * The `aes-256-ctr' is arguably the best choice for cipher - * algorithm for current openssl library version. + * + * $encrypted = $crypt->decrypt( + * $encrypted, + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * * - * @param string $cipher - * @return \Phalcon\Crypt\CryptInterface + * @throws \Phalcon\Crypt\Mismatch + * @param string $text + * @param string $key + * @return string */ - public function setCipher(string $cipher): CryptInterface {} + public function decrypt($text, $key = null) {} /** - * Set the name of hashing algorithm. + * Encrypts a text returning the result as a base64 string. * - * @throws \Phalcon\Crypt\Exception - * @param string $hashAlgo - * @return \Phalcon\Crypt\CryptInterface + * @param string $text + * @param mixed $key + * @param bool $safe + * @return string */ - public function setHashAlgo(string $hashAlgo): CryptInterface {} + public function encryptBase64($text, $key = null, $safe = false) {} /** - * Sets the encryption key. - * - * The `$key' should have been previously generated in a cryptographically - * safe way. - * - * Bad key: - * "le password" - * - * Better (but still unsafe): - * "#1dj8$=dp?.ak//j1V$~%0X" - * - * Good key: - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * Decrypt a text that is coded as a base64 string. * - * @param string $key - * @return \Phalcon\Crypt\CryptInterface + * @throws \Phalcon\Crypt\Mismatch + * @param string $text + * @param mixed $key + * @param bool $safe + * @return string */ - public function setKey(string $key): CryptInterface {} + public function decryptBase64($text, $key = null, $safe = false) {} /** - * Changes the padding scheme used. + * Returns a list of available ciphers. * - * @param int $scheme - * @return \Phalcon\Crypt\CryptInterface + * @return array */ - public function setPadding(int $scheme): CryptInterface {} + public function getAvailableCiphers() {} /** - * Sets if the calculating message digest must used. + * Return a list of registered hashing algorithms suitable for hash_hmac. * - * @param bool $useSigning - * @return \Phalcon\Crypt\CryptInterface + * @return array */ - public function useSigning(bool $useSigning): CryptInterface {} + public function getAvailableHashAlgos() {} /** * Assert the cipher is available. * + * @throws \Phalcon\Crypt\Exception * @param string $cipher */ - protected function assertCipherIsAvailable(string $cipher) {} + protected function assertCipherIsAvailable($cipher) {} /** * Assert the hash algorithm is available. * + * @throws \Phalcon\Crypt\Exception * @param string $hashAlgo */ - protected function assertHashAlgorithmAvailable(string $hashAlgo) {} + protected function assertHashAlgorithmAvailable($hashAlgo) {} /** * Initialize available cipher algorithms. * + * @throws \Phalcon\Crypt\Exception * @param string $cipher * @return int */ - protected function getIvLength(string $cipher): int {} + protected function getIvLength($cipher) {} /** * Initialize available cipher algorithms. - */ - protected function initializeAvailableCiphers() {} - - /** - * Pads texts before encryption. See [cryptopad](http://www.di-mgt.com.au/cryptopad.html) * - * @param string $text - * @param string $mode - * @param int $blockSize - * @param int $paddingType - * @return string - */ - protected function cryptPadText(string $text, string $mode, int $blockSize, int $paddingType): string {} - - /** - * Removes a padding from a text. - * - * If the function detects that the text was not padded, it will return it - * unmodified. - * - * @param string $text - * @param string $mode - * @param int $blockSize - * @param int $paddingType + * @throws \Phalcon\Crypt\Exception */ - protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) {} + protected function initializeAvailableCiphers() {} } diff --git a/src/Phalcon/CryptInterface.php b/src/Phalcon/CryptInterface.php new file mode 100644 index 00000000..d79c16f8 --- /dev/null +++ b/src/Phalcon/CryptInterface.php @@ -0,0 +1,86 @@ + + * use Phalcon\Db; + * use Phalcon\Db\Exception; + * use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; + * + * try { + * $connection = new MysqlConnection( + * [ + * "host" => "192.168.0.11", + * "username" => "sigma", + * "password" => "secret", + * "dbname" => "blog", + * "port" => "3306", + * ] + * ); + * + * $result = $connection->query( + * "SELECT FROM robots LIMIT 5" + * ); + * + * $result->setFetchMode(Db::FETCH_NUM); + * + * while ($robot = $result->fetch()) { + * print_r($robot); + * } + * } catch (Exception $e) { + * echo $e->getMessage(), PHP_EOL; + * } + * + */ +abstract class Db +{ + + const FETCH_LAZY = 1; + + + const FETCH_ASSOC = 2; + + + const FETCH_NAMED = 11; + + + const FETCH_NUM = 3; + + + const FETCH_BOTH = 4; + + + const FETCH_OBJ = 5; + + + const FETCH_BOUND = 6; + + + const FETCH_COLUMN = 7; + + + const FETCH_CLASS = 8; + + + const FETCH_INTO = 9; + + + const FETCH_FUNC = 10; + + + const FETCH_GROUP = 65536; + + + const FETCH_UNIQUE = 196608; + + + const FETCH_KEY_PAIR = 12; + + + const FETCH_CLASSTYPE = 262144; + + + const FETCH_SERIALIZE = 524288; + + + const FETCH_PROPS_LATE = 1048576; + + + /** + * Enables/disables options in the Database component + * + * @param array $options + */ + public static function setup(array $options) {} + +} diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 291d4d30..cfe5cfe6 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -3,90 +3,69 @@ namespace Phalcon; /** + * Phalcon\Debug + * * Provides debug capabilities to Phalcon applications */ class Debug { - /** - * @var array - */ - protected $blacklist = array('request' => array(), 'server' => array()); + public $_uri = '//static.phalconphp.com/www/debug/3.0.x/'; - protected $data; - /** - * @var bool - */ - protected $hideDocumentRoot = false; + public $_theme = 'default'; - /** - * @var bool - */ - static protected $isActive; - /** - * @var bool - */ - protected $showBackTrace = true; + protected $_hideDocumentRoot = false; - /** - * @var bool - */ - protected $showFileFragment = false; - /** - * @var bool - */ - protected $showFiles = true; + protected $_showBackTrace = true; - /** - * @var string - */ - protected $uri = 'https://assets.phalconphp.com/debug/4.0.x/'; + protected $_showFiles = true; + + + protected $_showFileFragment = false; + + + protected $_data; + + + static protected $_isActive; - /** - * Clears are variables added previously - * - * @return Debug - */ - public function clearVars(): Debug {} /** - * Adds a variable to the debug output + * Change the base URI for static resources * - * @param mixed $varz - * @param string $key + * @param string $uri * @return Debug */ - public function debugVar($varz, string $key = null): Debug {} + public function setUri($uri) {} /** - * Returns the css sources + * Sets if files the exception's backtrace must be showed * - * @return string + * @param bool $showBackTrace + * @return Debug */ - public function getCssSources(): string {} + public function setShowBackTrace($showBackTrace) {} /** - * Returns the javascript sources + * Set if files part of the backtrace must be shown in the output * - * @return string + * @param bool $showFiles + * @return Debug */ - public function getJsSources(): string {} + public function setShowFiles($showFiles) {} /** - * Generates a link to the current version documentation + * Sets if files must be completely opened and showed in the output + * or just the fragment related to the exception * - * @return string - */ - public function getVersion(): string {} - - /** - * Halts the request showing a backtrace + * @param bool $showFileFragment + * @return Debug */ - public function halt() {} + public function setShowFileFragment($showFileFragment) {} /** * Listen for uncaught exceptions and unsilent notices or warnings @@ -95,114 +74,124 @@ public function halt() {} * @param bool $lowSeverity * @return Debug */ - public function listen(bool $exceptions = true, bool $lowSeverity = false): Debug {} + public function listen($exceptions = true, $lowSeverity = false) {} /** * Listen for uncaught exceptions * * @return Debug */ - public function listenExceptions(): Debug {} + public function listenExceptions() {} /** * Listen for unsilent notices or warnings * * @return Debug */ - public function listenLowSeverity(): Debug {} + public function listenLowSeverity() {} /** - * Handles uncaught exceptions - * - * @param \Exception $exception - * @return bool + * Halts the request showing a backtrace */ - public function onUncaughtException(\Exception $exception): bool {} + public function halt() {} /** - * Throws an exception when a notice or warning is raised + * Adds a variable to the debug output * - * @param mixed $severity - * @param mixed $message - * @param mixed $file - * @param mixed $line - * @param mixed $context + * @param mixed $varz + * @param string $key + * @return Debug */ - public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} + public function debugVar($varz, $key = null) {} /** - * Sets if files the exception's backtrace must be showed + * Clears are variables added previously * - * @param array $blacklist * @return Debug */ - public function setBlacklist(array $blacklist): Debug {} + public function clearVars() {} /** - * Sets if files the exception's backtrace must be showed + * Escapes a string with htmlentities * - * @param bool $showBackTrace - * @return Debug + * @param mixed $value + * @return string */ - public function setShowBackTrace(bool $showBackTrace): Debug {} + protected function _escapeString($value) {} /** - * Sets if files must be completely opened and showed in the output - * or just the fragment related to the exception + * Produces a recursive representation of an array * - * @param bool $showFileFragment - * @return Debug + * @param array $argument + * @param mixed $n + * @return string|null */ - public function setShowFileFragment(bool $showFileFragment): Debug {} + protected function _getArrayDump(array $argument, $n = 0) {} /** - * Set if files part of the backtrace must be shown in the output + * Produces an string representation of a variable * - * @param bool $showFiles - * @return Debug + * @param mixed $variable + * @return string */ - public function setShowFiles(bool $showFiles): Debug {} + protected function _getVarDump($variable) {} /** - * Change the base URI for static resources + * Returns the major framework's version * - * @param string $uri - * @return Debug + * @deprecated Will be removed in 4.0.0 + * @see Phalcon\Version::getPart() + * @deprecated + * @return string */ - public function setUri(string $uri): Debug {} + public function getMajorVersion() {} /** - * Escapes a string with htmlentities + * Generates a link to the current version documentation * - * @param mixed $value * @return string */ - protected function escapeString($value): string {} + public function getVersion() {} /** - * Produces a recursive representation of an array + * Returns the css sources * - * @param array $argument - * @param mixed $n - * @return string|null + * @return string */ - protected function getArrayDump(array $argument, $n = 0): ?string {} + public function getCssSources() {} /** - * Produces an string representation of a variable + * Returns the javascript sources * - * @param mixed $variable * @return string */ - protected function getVarDump($variable): string {} + public function getJsSources() {} /** * Shows a backtrace item * * @param int $n * @param array $trace - * @return string */ - final protected function showTraceItem(int $n, array $trace): string {} + protected final function showTraceItem($n, array $trace) {} + + /** + * Throws an exception when a notice or warning is raised + * + * @param mixed $severity + * @param mixed $message + * @param mixed $file + * @param mixed $line + * @param mixed $context + */ + public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} + + /** + * Handles uncaught exceptions + * + * @param \Exception $exception + * @return bool + */ + public function onUncaughtException(\Exception $exception) {} } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 4f4d7bb0..1ebe86df 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -3,24 +3,23 @@ namespace Phalcon; /** - * Phalcon\Di is a component that implements Dependency Injection/Service - * Location of services and it's itself a container for them. + * Phalcon\Di * - * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the - * different components of the framework. The developer can also use this - * component to inject dependencies and manage global instances of the different - * classes used in the application. + * Phalcon\Di is a component that implements Dependency Injection/Service Location + * of services and it's itself a container for them. * - * Basically, this component implements the `Inversion of Control` pattern. - * Applying this, the objects do not receive their dependencies using setters or - * constructors, but requesting a service dependency injector. This reduces the - * overall complexity, since there is only one way to get the required - * dependencies within a component. + * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the different + * components of the framework. The developer can also use this component to inject dependencies + * and manage global instances of the different classes used in the application. * - * Additionally, this pattern increases testability in the code, thus making it - * less prone to errors. + * Basically, this component implements the `Inversion of Control` pattern. Applying this, + * the objects do not receive their dependencies using setters or constructors, but requesting + * a service dependency injector. This reduces the overall complexity, since there is only one + * way to get the required dependencies within a component. * - * ```php + * Additionally, this pattern increases testability in the code, thus making it less prone to errors. + * + * * use Phalcon\Di; * use Phalcon\Http\Request; * @@ -38,26 +37,31 @@ * ); * * $request = $di->getRequest(); - * ``` + * */ -class Di implements \Phalcon\Di\DiInterface +class Di implements \Phalcon\DiInterface { /** * List of registered services */ - protected $services; + protected $_services; /** * List of shared instances */ - protected $sharedInstances; + protected $_sharedInstances; + + /** + * To know if the latest resolved instance was shared or not + */ + protected $_freshInstance = false; /** * Events Manager * - * @var ManagerInterface + * @var \Phalcon\Events\ManagerInterface */ - protected $eventsManager; + protected $_eventsManager; /** * Latest DI build @@ -71,48 +75,66 @@ class Di implements \Phalcon\Di\DiInterface public function __construct() {} /** - * Magic method to get or set services using setters/getters + * Sets the internal event manager * - * @param string $method - * @param array $arguments - * @return mixed|null + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function __call(string $method, array $arguments = array()): ? {} + public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Attempts to register a service in the services container - * Only is successful if a service hasn't been registered previously - * with the same name + * Returns the internal event manager + * + * @return \Phalcon\Events\ManagerInterface + */ + public function getInternalEventsManager() {} + + /** + * Registers a service in the services container * * @param string $name * @param mixed $definition * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return \Phalcon\Di\ServiceInterface */ - public function attempt(string $name, $definition, bool $shared = false) {} + public function set($name, $definition, $shared = false) {} /** - * Resolves the service based on its configuration + * Registers an "always shared" service in the services container * * @param string $name - * @param mixed $parameters - * @return mixed + * @param mixed $definition + * @return \Phalcon\Di\ServiceInterface */ - public function get(string $name, $parameters = null) {} + public function setShared($name, $definition) {} /** - * Return the latest DI created + * Removes a service in the services container + * It also removes any shared instance created for the service * - * @return null|\Phalcon\Di\DiInterface + * @param string $name */ - public static function getDefault(): ?DiInterface {} + public function remove($name) {} /** - * Returns the internal event manager + * Attempts to register a service in the services container + * Only is successful if a service hasn't been registered previously + * with the same name * - * @return \Phalcon\Events\ManagerInterface + * @param string $name + * @param mixed $definition + * @param bool $shared + * @return bool|\Phalcon\Di\ServiceInterface */ - public function getInternalEventsManager(): ManagerInterface {} + public function attempt($name, $definition, $shared = false) {} + + /** + * Sets a service using a raw Phalcon\Di\Service definition + * + * @param string $name + * @param \Phalcon\Di\ServiceInterface $rawDefinition + * @return \Phalcon\Di\ServiceInterface + */ + public function setRaw($name, \Phalcon\Di\ServiceInterface $rawDefinition) {} /** * Returns a service definition without resolving @@ -120,7 +142,7 @@ public function getInternalEventsManager(): ManagerInterface {} * @param string $name * @return mixed */ - public function getRaw(string $name) {} + public function getRaw($name) {} /** * Returns a Phalcon\Di\Service instance @@ -128,118 +150,76 @@ public function getRaw(string $name) {} * @param string $name * @return \Phalcon\Di\ServiceInterface */ - public function getService(string $name): ServiceInterface {} + public function getService($name) {} /** - * Return the services registered in the DI + * Resolves the service based on its configuration * - * @return array|\Phalcon\Di\ServiceInterface[] + * @param string $name + * @param mixed $parameters + * @return mixed */ - public function getServices(): array {} + public function get($name, $parameters = null) {} /** * Resolves a service, the resolved service is stored in the DI, subsequent * requests for this service will return the same instance * * @param string $name - * @param mixed $parameters + * @param array $parameters * @return mixed */ - public function getShared(string $name, $parameters = null) {} + public function getShared($name, $parameters = null) {} /** - * Loads services from a Config object. + * Check whether the DI contains a service by a name * - * @param \Phalcon\Config $config + * @param string $name + * @return bool */ - protected function loadFromConfig(\Phalcon\Config $config) {} + public function has($name) {} /** - * Loads services from a php config file. - * - * ```php - * $di->loadFromPhp("path/services.php"); - * ``` - * - * And the services can be specified in the file as: + * Check whether the last service obtained via getShared produced a fresh instance or an existing one * - * ```php - * return [ - * 'myComponent' => [ - * 'className' => '\Acme\Components\MyComponent', - * 'shared' => true, - * ], - * 'group' => [ - * 'className' => '\Acme\Group', - * 'arguments' => [ - * [ - * 'type' => 'service', - * 'service' => 'myComponent', - * ], - * ], - * ], - * 'user' => [ - * 'className' => '\Acme\User', - * ], - * ]; - * ``` - * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath + * @return bool */ - public function loadFromPhp(string $filePath) {} + public function wasFreshInstance() {} /** - * Loads services from a yaml file. - * - * ```php - * $di->loadFromYaml( - * "path/services.yaml", - * [ - * "!approot" => function ($value) { - * return dirname(__DIR__) . $value; - * } - * ] - * ); - * ``` - * - * And the services can be specified in the file as: - * - * ```php - * myComponent: - * className: \Acme\Components\MyComponent - * shared: true - * - * group: - * className: \Acme\Group - * arguments: - * - type: service - * name: myComponent + * Return the services registered in the DI * - * user: - * className: \Acme\User - * ``` + * @return \Phalcon\Di\Service[] + */ + public function getServices() {} + + /** + * Check if a service is registered using the array syntax * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath - * @param array $callbacks + * @param mixed $name + * @return bool */ - public function loadFromYaml(string $filePath, array $callbacks = null) {} + public function offsetExists($name) {} /** - * Check whether the DI contains a service by a name + * Allows to register a shared service using the array syntax * - * @param string $name + * + * $di["request"] = new \Phalcon\Http\Request(); + * + * + * @param mixed $name + * @param mixed $definition * @return bool */ - public function has(string $name): bool {} + public function offsetSet($name, $definition) {} /** * Allows to obtain a shared service using the array syntax * - * ```php + * * var_dump($di["request"]); - * ``` + * * * @param mixed $name * @return mixed @@ -247,111 +227,140 @@ public function has(string $name): bool {} public function offsetGet($name) {} /** - * Check if a service is registered using the array syntax + * Removes a service from the services container using the array syntax * * @param mixed $name * @return bool */ - public function offsetExists($name): bool {} - - /** - * Allows to register a shared service using the array syntax - * - * ```php - * $di["request"] = new \Phalcon\Http\Request(); - * ``` - * - * @param mixed $name - * @param mixed $definition - */ - public function offsetSet($name, $definition) {} + public function offsetUnset($name) {} /** - * Removes a service from the services container using the array syntax + * Magic method to get or set services using setters/getters * - * @param mixed $name + * @param string $method + * @param mixed $arguments + * @return mixed|null */ - public function offsetUnset($name) {} + public function __call($method, $arguments = null) {} /** * Registers a service provider. * - * ```php - * use Phalcon\Di\DiInterface; + * + * use Phalcon\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared( - * 'service', - * function () { - * // ... - * } - * ); + * $di->setShared('service', function () { + * // ... + * }); * } * } - * ``` + * * * @param \Phalcon\Di\ServiceProviderInterface $provider */ public function register(\Phalcon\Di\ServiceProviderInterface $provider) {} /** - * Removes a service in the services container - * It also removes any shared instance created for the service + * Set a default dependency injection container to be obtained into static methods * - * @param string $name + * @param \Phalcon\DiInterface $dependencyInjector */ - public function remove(string $name) {} + public static function setDefault(\Phalcon\DiInterface $dependencyInjector) {} /** - * Resets the internal default DI - */ - public static function reset() {} - - /** - * Registers a service in the services container + * Return the latest DI created * - * @param string $name - * @param mixed $definition - * @param bool $shared - * @return \Phalcon\Di\ServiceInterface + * @return null|\Phalcon\DiInterface */ - public function set(string $name, $definition, bool $shared = false): ServiceInterface {} + public static function getDefault() {} /** - * Set a default dependency injection container to be obtained into static - * methods - * - * @param \Phalcon\Di\DiInterface $container + * Resets the internal default DI */ - public static function setDefault(\Phalcon\Di\DiInterface $container) {} + public static function reset() {} /** - * Sets the internal event manager + * Loads services from a yaml file. * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * + * $di->loadFromYaml( + * "path/services.yaml", + * [ + * "!approot" => function ($value) { + * return dirname(__DIR__) . $value; + * } + * ] + * ); + * + * + * And the services can be specified in the file as: + * + * + * myComponent: + * className: \Acme\Components\MyComponent + * shared: true + * + * group: + * className: \Acme\Group + * arguments: + * - type: service + * name: myComponent + * + * user: + * className: \Acme\User + * + * + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath + * @param array $callbacks */ - public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function loadFromYaml($filePath, array $callbacks = null) {} /** - * Sets a service using a raw Phalcon\Di\Service definition + * Loads services from a php config file. * - * @param string $name - * @param \Phalcon\Di\ServiceInterface $rawDefinition - * @return \Phalcon\Di\ServiceInterface + * + * $di->loadFromPhp("path/services.php"); + * + * + * And the services can be specified in the file as: + * + * + * return [ + * 'myComponent' => [ + * 'className' => '\Acme\Components\MyComponent', + * 'shared' => true, + * ], + * 'group' => [ + * 'className' => '\Acme\Group', + * 'arguments' => [ + * [ + * 'type' => 'service', + * 'service' => 'myComponent', + * ], + * ], + * ], + * 'user' => [ + * 'className' => '\Acme\User', + * ], + * ]; + * + * + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath */ - public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface {} + public function loadFromPhp($filePath) {} /** - * Registers an "always shared" service in the services container + * Loads services from a Config object. * - * @param string $name - * @param mixed $definition - * @return \Phalcon\Di\ServiceInterface + * @param \Phalcon\Config $config */ - public function setShared(string $name, $definition): ServiceInterface {} + protected function loadFromConfig(\Phalcon\Config $config) {} } diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/DiInterface.php similarity index 63% rename from src/Phalcon/di/DiInterface.php rename to src/Phalcon/DiInterface.php index 0e63ebd8..a250d834 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/DiInterface.php @@ -1,127 +1,135 @@ false if an exception occurred and the operation was - * stopped by returning false in the exception handler. - * - * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. - * @return object|bool - */ - public function dispatch(): bool {} + protected $_handlerSuffix = ''; + + + protected $_actionSuffix = 'Action'; + + + protected $_previousNamespaceName = null; + + + protected $_previousHandlerName = null; + + + protected $_previousActionName = null; + + + protected $_modelBinding = false; + + + protected $_modelBinder = null; + + + protected $_isControllerInitialize = false; - /** - * Forwards the execution flow to another controller/action. - * - * ```php - * $this->dispatcher->forward( - * [ - * "controller" => "posts", - * "action" => "index", - * ] - * ); - * ``` - * - * @throws \Phalcon\Exception - * @param array $forward - */ - public function forward(array $forward) {} /** - * Gets the latest dispatched action name + * Sets the dependency injector * - * @return string + * @param \Phalcon\DiInterface $dependencyInjector */ - public function getActionName(): string {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Gets the default action suffix + * Returns the internal dependency injector * - * @return string + * @return \Phalcon\DiInterface */ - public function getActionSuffix(): string {} + public function getDI() {} /** - * Returns the current method to be/executed in the dispatcher + * Sets the events manager * - * @return string + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getActiveMethod(): string {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns bound models from binder instance - * - * ```php - * class UserController extends Controller - * { - * public function showAction(User $user) - * { - * // return array with $user - * $boundModels = $this->dispatcher->getBoundModels(); - * } - * } - * ``` + * Returns the internal event manager * - * @return array + * @return \Phalcon\Events\ManagerInterface */ - public function getBoundModels(): array {} + public function getEventsManager() {} /** - * Returns the default namespace + * Sets the default action suffix * - * @return string + * @param string $actionSuffix */ - public function getDefaultNamespace(): string {} + public function setActionSuffix($actionSuffix) {} /** - * Returns the internal dependency injector + * Gets the default action suffix * - * @return \Phalcon\Di\DiInterface + * @return string */ - public function getDI(): DiInterface {} + public function getActionSuffix() {} /** - * Returns the internal event manager + * Sets the module where the controller is (only informative) * - * @return \Phalcon\Events\ManagerInterface + * @param string $moduleName */ - public function getEventsManager(): ManagerInterface {} + public function setModuleName($moduleName) {} /** - * Gets the default handler suffix + * Gets the module where the controller class is * * @return string */ - public function getHandlerSuffix(): string {} + public function getModuleName() {} /** - * Gets model binder + * Sets the namespace where the controller class is * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param string $namespaceName */ - public function getModelBinder(): ?BinderInterface {} + public function setNamespaceName($namespaceName) {} /** - * Gets the module where the controller class is + * Gets a namespace to be prepended to the current handler name * * @return string */ - public function getModuleName(): string {} + public function getNamespaceName() {} /** - * Gets a namespace to be prepended to the current handler name + * Sets the default namespace * - * @return string + * @param string $namespaceName */ - public function getNamespaceName(): string {} + public function setDefaultNamespace($namespaceName) {} /** - * Gets a param by its name or numeric index + * Returns the default namespace * - * @param mixed $param - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @return string */ - public function getParam($param, $filters = null, $defaultValue = null) {} + public function getDefaultNamespace() {} /** - * Gets action params + * Sets the default action name * - * @return array + * @param string $actionName */ - public function getParams(): array {} + public function setDefaultAction($actionName) {} /** - * Check if a param exists + * Sets the action name to be dispatched * - * @param mixed $param - * @return bool + * @param string $actionName */ - public function hasParam($param): bool {} + public function setActionName($actionName) {} /** - * Checks if the dispatch loop is finished or has more pendent - * controllers/tasks to dispatch + * Gets the latest dispatched action name * - * @return bool + * @return string */ - public function isFinished(): bool {} + public function getActionName() {} /** - * Sets the action name to be dispatched + * Sets action params to be dispatched * - * @param string $actionName + * @param array $params */ - public function setActionName(string $actionName) {} + public function setParams($params) {} /** - * Sets the default action name + * Gets action params * - * @param string $actionName + * @return array */ - public function setDefaultAction(string $actionName) {} + public function getParams() {} /** - * Sets the default namespace + * Set a param by its name or numeric index * - * @param string $namespaceName + * @param mixed $param + * @param mixed $value */ - public function setDefaultNamespace(string $namespaceName) {} + public function setParam($param, $value) {} /** - * Sets the dependency injector + * Gets a param by its name or numeric index * - * @param \Phalcon\Di\DiInterface $container + * @param mixed $param + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getParam($param, $filters = null, $defaultValue = null) {} /** - * Possible class name that will be located to dispatch the request + * Check if a param exists * - * @return string + * @param mixed $param + * @return bool */ - public function getHandlerClass(): string {} + public function hasParam($param) {} /** - * Set a param by its name or numeric index + * Returns the current method to be/executed in the dispatcher * - * @param mixed $param - * @param mixed $value + * @return string */ - public function setParam($param, $value) {} + public function getActiveMethod() {} /** - * Sets action params to be dispatched + * Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch * - * @param array $params + * @return bool */ - public function setParams(array $params) {} + public function isFinished() {} /** * Sets the latest returned value by an action manually @@ -326,88 +265,130 @@ public function setParams(array $params) {} public function setReturnedValue($value) {} /** - * Sets the default action suffix + * Returns value returned by the latest dispatched action * - * @param string $actionSuffix + * @return mixed */ - public function setActionSuffix(string $actionSuffix) {} + public function getReturnedValue() {} /** - * Sets the events manager + * Enable/Disable model binding during dispatch * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Sets the default suffix for the handler + * + * $di->set('dispatcher', function() { + * $dispatcher = new Dispatcher(); + * + * $dispatcher->setModelBinding(true, 'cache'); + * return $dispatcher; + * }); + * * - * @param string $handlerSuffix + * @deprecated 3.1.0 Use setModelBinder method + * @see Phalcon\Dispatcher::setModelBinder() + * @param bool $value + * @param mixed $cache + * @deprecated + * @return Dispatcher */ - public function setHandlerSuffix(string $handlerSuffix) {} + public function setModelBinding($value, $cache = null) {} /** * Enable model binding during dispatch * - * ```php - * $di->set( - * 'dispatcher', - * function() { - * $dispatcher = new Dispatcher(); + * + * $di->set('dispatcher', function() { + * $dispatcher = new Dispatcher(); * - * $dispatcher->setModelBinder( - * new Binder(), - * 'cache' - * ); - * - * return $dispatcher; - * } - * ); - * ``` + * $dispatcher->setModelBinder(new Binder(), 'cache'); + * return $dispatcher; + * }); + * * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Dispatcher */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} /** - * Sets the module where the controller is (only informative) + * Gets model binder * - * @param string $moduleName + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function setModuleName(string $moduleName) {} + public function getModelBinder() {} /** - * Sets the namespace where the controller class is + * Process the results of the router by calling into the appropriate controller action(s) + * including any routing data or injected parameters. * - * @param string $namespaceName + * @return object|false Returns the dispatched handler class (the Controller for Mvc dispatching or a Task + * for CLI dispatching) or false if an exception occurred and the operation was + * stopped by returning false in the exception handler. + * + * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. */ - public function setNamespaceName(string $namespaceName) {} + public function dispatch() {} /** - * Returns value returned by the latest dispatched action + * Forwards the execution flow to another controller/action. * - * @return mixed + * + * $this->dispatcher->forward( + * [ + * "controller" => "posts", + * "action" => "index", + * ] + * ); + * + * + * @param array forward + * + * @throws \Phalcon\Exception + * @param mixed $forward */ - public function getReturnedValue() {} + public function forward($forward) {} /** * Check if the current executed action was forwarded by another one * * @return bool */ - public function wasForwarded(): bool {} + public function wasForwarded() {} /** - * Set empty properties to their defaults (where defaults are available) + * Possible class name that will be located to dispatch the request + * + * @return string */ - protected function resolveEmptyProperties() {} + public function getHandlerClass() {} /** - * @param string $input - * @return string + * @param mixed $handler + * @param string $actionMethod + * @param array $params + */ + public function callActionMethod($handler, $actionMethod, array $params = array()) {} + + /** + * Returns bound models from binder instance + * + * + * class UserController extends Controller + * { + * public function showAction(User $user) + * { + * $boundModels = $this->dispatcher->getBoundModels(); // return array with $user + * } + * } + * + * + * @return array + */ + public function getBoundModels() {} + + /** + * Set empty properties to their defaults (where defaults are available) */ - protected function toCamelCase(string $input): string {} + protected function _resolveEmptyProperties() {} } diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/DispatcherInterface.php similarity index 63% rename from src/Phalcon/dispatcher/DispatcherInterface.php rename to src/Phalcon/DispatcherInterface.php index e28b1de8..c7858384 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/DispatcherInterface.php @@ -1,149 +1,136 @@ * $escaper = new \Phalcon\Escaper(); * * $escaped = $escaper->escapeCss("font-family: "); * * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E - * ``` + * */ -class Escaper implements \Phalcon\Escaper\EscaperInterface +class Escaper implements \Phalcon\EscaperInterface { - /** - * @var bool - */ - protected $doubleEncode = true; - /** - * @var string - */ - protected $encoding = 'utf-8'; + protected $_encoding = 'utf-8'; - protected $htmlEscapeMap = null; + protected $_htmlEscapeMap = null; - protected $htmlQuoteType = 3; + protected $_htmlQuoteType = 3; + + + protected $_doubleEncode = true; /** - * Detect the character encoding of a string to be handled by an encoder. - * Special-handling for chr(172) and chr(128) to chr(159) which fail to be - * detected by mb_detect_encoding() + * Sets the encoding to be used by the escaper * - * @param string $str - * @return string|null + * + * $escaper->setEncoding("utf-8"); + * + * + * @param string $encoding */ - final public function detectEncoding(string $str): ?string {} + public function setEncoding($encoding) {} /** - * Escape CSS strings by replacing non-alphanumeric chars by their - * hexadecimal escaped representation + * Returns the internal encoding used by the escaper * - * @param string $css * @return string */ - public function escapeCss(string $css): string {} + public function getEncoding() {} /** - * Escape javascript strings by replacing non-alphanumeric chars by their - * hexadecimal escaped representation + * Sets the HTML quoting type for htmlspecialchars * - * @param string $js - * @return string + * + * $escaper->setHtmlQuoteType(ENT_XHTML); + * + * + * @param int $quoteType */ - public function escapeJs(string $js): string {} + public function setHtmlQuoteType($quoteType) {} /** - * Escapes a HTML string. Internally uses htmlspecialchars + * Sets the double_encode to be used by the escaper * - * @param string $text - * @return string + * + * $escaper->setDoubleEncode(false); + * + * + * @param bool $doubleEncode */ - public function escapeHtml(string $text): string {} + public function setDoubleEncode($doubleEncode) {} /** - * Escapes a HTML attribute string + * Detect the character encoding of a string to be handled by an encoder + * Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding() * - * @param string $attribute - * @return string + * @param string $str + * @return string|null */ - public function escapeHtmlAttr(string $attribute): string {} + public final function detectEncoding($str) {} /** - * Escapes a URL. Internally uses rawurlencode + * Utility to normalize a string's encoding to UTF-32. * - * @param string $url + * @param string $str * @return string */ - public function escapeUrl(string $url): string {} + public final function normalizeEncoding($str) {} /** - * Returns the internal encoding used by the escaper + * Escapes a HTML string. Internally uses htmlspecialchars * + * @param string $text * @return string */ - public function getEncoding(): string {} + public function escapeHtml($text) {} /** - * Utility to normalize a string's encoding to UTF-32. + * Escapes a HTML attribute string * - * @param string $str + * @param string $attribute * @return string */ - final public function normalizeEncoding(string $str): string {} + public function escapeHtmlAttr($attribute) {} /** - * Sets the double_encode to be used by the escaper - * - * ```php - * $escaper->setDoubleEncode(false); - * ``` + * Escape CSS strings by replacing non-alphanumeric chars by their hexadecimal escaped representation * - * @param bool $doubleEncode + * @param string $css + * @return string */ - public function setDoubleEncode(bool $doubleEncode) {} + public function escapeCss($css) {} /** - * Sets the encoding to be used by the escaper - * - * ```php - * $escaper->setEncoding("utf-8"); - * ``` + * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation * - * @param string $encoding + * @param string $js + * @return string */ - public function setEncoding(string $encoding) {} + public function escapeJs($js) {} /** - * Sets the HTML quoting type for htmlspecialchars - * - * ```php - * $escaper->setHtmlQuoteType(ENT_XHTML); - * ``` + * Escapes a URL. Internally uses rawurlencode * - * @param int $quoteType + * @param string $url + * @return string */ - public function setHtmlQuoteType(int $quoteType) {} + public function escapeUrl($url) {} } diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/EscaperInterface.php similarity index 65% rename from src/Phalcon/escaper/EscaperInterface.php rename to src/Phalcon/EscaperInterface.php index 784051f3..b6e40151 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/EscaperInterface.php @@ -1,74 +1,74 @@ + * $filter = new \Phalcon\Filter(); + * + * $filter->sanitize("some(one)@exa\\mple.com", "email"); // returns "someone@example.com" + * $filter->sanitize("hello<<", "string"); // returns "hello" + * $filter->sanitize("!100a019", "int"); // returns "100019" + * $filter->sanitize("!100a019.01a", "float"); // returns "100019.01" + * + */ +class Filter implements \Phalcon\FilterInterface +{ + + const FILTER_EMAIL = 'email'; + + + const FILTER_ABSINT = 'absint'; + + + const FILTER_INT = 'int'; + + + const FILTER_INT_CAST = 'int!'; + + + const FILTER_STRING = 'string'; + + + const FILTER_FLOAT = 'float'; + + + const FILTER_FLOAT_CAST = 'float!'; + + + const FILTER_ALPHANUM = 'alphanum'; + + + const FILTER_TRIM = 'trim'; + + + const FILTER_STRIPTAGS = 'striptags'; + + + const FILTER_LOWER = 'lower'; + + + const FILTER_UPPER = 'upper'; + + + const FILTER_URL = 'url'; + + + const FILTER_SPECIAL_CHARS = 'special_chars'; + + + protected $_filters; + + + /** + * Adds a user-defined filter + * + * @param string $name + * @param mixed $handler + * @return \Phalcon\FilterInterface + */ + public function add($name, $handler) {} + + /** + * Sanitizes a value with a specified single or set of filters + * + * @param mixed $value + * @param mixed $filters + * @param bool $noRecursive + * @return mixed + */ + public function sanitize($value, $filters, $noRecursive = false) {} + + /** + * Internal sanitize wrapper to filter_var + * + * @param mixed $value + * @param string $filter + */ + protected function _sanitize($value, $filter) {} + + /** + * Return the user-defined filters in the instance + * + * @return array + */ + public function getFilters() {} + +} diff --git a/src/Phalcon/FilterInterface.php b/src/Phalcon/FilterInterface.php new file mode 100644 index 00000000..6ffc77e2 --- /dev/null +++ b/src/Phalcon/FilterInterface.php @@ -0,0 +1,38 @@ + + * $flash->success("The record was successfully deleted"); + * $flash->error("Cannot open the file"); + * + */ +abstract class Flash implements \Phalcon\FlashInterface, \Phalcon\Di\InjectionAwareInterface +{ + + protected $_cssClasses; + + + protected $_implicitFlush = true; + + + protected $_automaticHtml = true; + + + protected $_escaperService = null; + + + protected $_autoescape = true; + + + protected $_dependencyInjector = null; + + + protected $_messages; + + + /** + * Phalcon\Flash constructor + * + * @param mixed $cssClasses + */ + public function __construct($cssClasses = null) {} + + /** + * Returns the autoescape mode in generated html + * + * @return bool + */ + public function getAutoescape() {} + + /** + * Set the autoescape mode in generated html + * + * @param bool $autoescape + * @return Flash + */ + public function setAutoescape($autoescape) {} + + /** + * Returns the Escaper Service + * + * @return EscaperInterface + */ + public function getEscaperService() {} + + /** + * Sets the Escaper Service + * + * @param EscaperInterface $escaperService + * @return Flash + */ + public function setEscaperService(EscaperInterface $escaperService) {} + + /** + * Sets the dependency injector + * + * @param DiInterface $dependencyInjector + * @return Flash + */ + public function setDI(DiInterface $dependencyInjector) {} + + /** + * Returns the internal dependency injector + * + * @return DiInterface + */ + public function getDI() {} + + /** + * Set whether the output must be implicitly flushed to the output or returned as string + * + * @param bool $implicitFlush + * @return FlashInterface + */ + public function setImplicitFlush($implicitFlush) {} + + /** + * Set if the output must be implicitly formatted with HTML + * + * @param bool $automaticHtml + * @return FlashInterface + */ + public function setAutomaticHtml($automaticHtml) {} + + /** + * Set an array with CSS classes to format the messages + * + * @param array $cssClasses + * @return FlashInterface + */ + public function setCssClasses(array $cssClasses) {} + + /** + * Shows a HTML error message + * + * + * $flash->error("This is an error"); + * + * + * @param mixed $message + * @return string + */ + public function error($message) {} + + /** + * Shows a HTML notice/information message + * + * + * $flash->notice("This is an information"); + * + * + * @param mixed $message + * @return string + */ + public function notice($message) {} + + /** + * Shows a HTML success message + * + * + * $flash->success("The process was finished successfully"); + * + * + * @param mixed $message + * @return string + */ + public function success($message) {} + + /** + * Shows a HTML warning message + * + * + * $flash->warning("Hey, this is important"); + * + * + * @param mixed $message + * @return string + */ + public function warning($message) {} + + /** + * Outputs a message formatting it with HTML + * + * + * $flash->outputMessage("error", $message); + * + * + * @param string $type + * @param string|array $message + * @return string|void + */ + public function outputMessage($type, $message) {} + + /** + * Clears accumulated messages when implicit flush is disabled + */ + public function clear() {} + +} diff --git a/src/Phalcon/FlashInterface.php b/src/Phalcon/FlashInterface.php new file mode 100644 index 00000000..9353fd25 --- /dev/null +++ b/src/Phalcon/FlashInterface.php @@ -0,0 +1,49 @@ + * use Phalcon\Loader; * * // Creates the autoloader @@ -26,131 +27,144 @@ * * // Requiring this class will automatically include file vendor/example/adapter/Some.php * $adapter = new \Example\Adapter\Some(); - * ``` + * */ class Loader implements \Phalcon\Events\EventsAwareInterface { - protected $checkedPath = null; + protected $_eventsManager = null; - /** - * @var array - */ - protected $classes = array(); - /** - * @var array - */ - protected $directories = array(); + protected $_foundPath = null; - protected $eventsManager = null; + protected $_checkedPath = null; - /** - * @var array - */ - protected $extensions = array('php'); + protected $_classes = array(); - protected $fileCheckingCallback = 'is_file'; - /** - * @var array - */ - protected $files = array(); + protected $_extensions = array('php'); - /** - * @var bool - */ - protected $foundPath = null; - /** - * @var array - */ - protected $namespaces = array(); + protected $_namespaces = array(); + + + protected $_directories = array(); + + + protected $_files = array(); + + + protected $_registered = false; + + + protected $fileCheckingCallback = 'is_file'; + /** - * @var bool + * Sets the file check callback. + * + * + * // Default behavior. + * $loader->setFileCheckingCallback("is_file"); + * + * // Faster than `is_file()`, but implies some issues if + * // the file is removed from the filesystem. + * $loader->setFileCheckingCallback("stream_resolve_include_path"); + * + * // Do not check file existence. + * $loader->setFileCheckingCallback(null); + * + * + * @param mixed $callback + * @return Loader */ - protected $registered = false; - + public function setFileCheckingCallback($callback = null) {} /** - * Autoloads the registered classes + * Sets the events manager * - * @param string $className - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function autoLoad(string $className): bool {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Get the path the loader is checking for a path + * Returns the internal event manager * - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getCheckedPath(): string {} + public function getEventsManager() {} /** - * Returns the class-map currently registered in the autoloader + * Sets an array of file extensions that the loader must try in each attempt to locate the file * - * @return array + * @param array $extensions + * @return Loader */ - public function getClasses(): array {} + public function setExtensions(array $extensions) {} /** - * Returns the directories currently registered in the autoloader + * Returns the file extensions registered in the loader * * @return array */ - public function getDirs(): array {} + public function getExtensions() {} /** - * Returns the internal event manager + * Register namespaces and their related directories * - * @return \Phalcon\Events\ManagerInterface + * @param array $namespaces + * @param bool $merge + * @return Loader */ - public function getEventsManager(): ManagerInterface {} + public function registerNamespaces(array $namespaces, $merge = false) {} /** - * Returns the file extensions registered in the loader - * + * @param array $namespace * @return array */ - public function getExtensions(): array {} + protected function prepareNamespace(array $namespace) {} /** - * Returns the files currently registered in the autoloader + * Returns the namespaces currently registered in the autoloader * * @return array */ - public function getFiles(): array {} + public function getNamespaces() {} /** - * Get the path when a class was found + * Register directories in which "not found" classes could be found * - * @return string + * @param array $directories + * @param bool $merge + * @return Loader */ - public function getFoundPath(): string {} + public function registerDirs(array $directories, $merge = false) {} /** - * Returns the namespaces currently registered in the autoloader + * Returns the directories currently registered in the autoloader * * @return array */ - public function getNamespaces(): array {} + public function getDirs() {} /** - * Checks if a file exists and then adds the file by doing virtual require + * Registers files that are "non-classes" hence need a "require". This is very useful for including files that only + * have functions + * + * @param array $files + * @param bool $merge + * @return Loader */ - public function loadFiles() {} + public function registerFiles(array $files, $merge = false) {} /** - * Register the autoload method + * Returns the files currently registered in the autoloader * - * @param bool $prepend - * @return Loader + * @return array */ - public function register(bool $prepend = false): Loader {} + public function getFiles() {} /** * Register classes and their locations @@ -159,83 +173,55 @@ public function register(bool $prepend = false): Loader {} * @param bool $merge * @return Loader */ - public function registerClasses(array $classes, bool $merge = false): Loader {} + public function registerClasses(array $classes, $merge = false) {} /** - * Register directories in which "not found" classes could be found + * Returns the class-map currently registered in the autoloader * - * @param array $directories - * @param bool $merge - * @return Loader + * @return array */ - public function registerDirs(array $directories, bool $merge = false): Loader {} + public function getClasses() {} /** - * Registers files that are "non-classes" hence need a "require". This is - * very useful for including files that only have functions + * Register the autoload method * - * @param array $files - * @param bool $merge + * @param bool $prepend * @return Loader */ - public function registerFiles(array $files, bool $merge = false): Loader {} + public function register($prepend = false) {} /** - * Register namespaces and their related directories + * Unregister the autoload method * - * @param array $namespaces - * @param bool $merge * @return Loader */ - public function registerNamespaces(array $namespaces, bool $merge = false): Loader {} + public function unregister() {} /** - * Sets the events manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * Checks if a file exists and then adds the file by doing virtual require */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function loadFiles() {} /** - * Sets an array of file extensions that the loader must try in each attempt - * to locate the file + * Autoloads the registered classes * - * @param array $extensions - * @return Loader + * @param string $className + * @return bool */ - public function setExtensions(array $extensions): Loader {} + public function autoLoad($className) {} /** - * Sets the file check callback. - * - * ```php - * // Default behavior. - * $loader->setFileCheckingCallback("is_file"); - * - * // Faster than `is_file()`, but implies some issues if - * // the file is removed from the filesystem. - * $loader->setFileCheckingCallback("stream_resolve_include_path"); - * - * // Do not check file existence. - * $loader->setFileCheckingCallback(null); - * ``` + * Get the path when a class was found * - * @param mixed $callback - * @return Loader + * @return string */ - public function setFileCheckingCallback($callback = null): Loader {} + public function getFoundPath() {} /** - * Unregister the autoload method + * Get the path the loader is checking for a path * - * @return Loader - */ - public function unregister(): Loader {} - - /** - * @param array $namespaceName - * @return array + * @return string */ - protected function prepareNamespace(array $namespaceName): array {} + public function getCheckedPath() {} } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php new file mode 100644 index 00000000..332e012a --- /dev/null +++ b/src/Phalcon/Logger.php @@ -0,0 +1,55 @@ + + * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); + * $logger->log("This is a message"); + * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); + * $logger->error("This is another error"); + * + */ +abstract class Logger +{ + + const SPECIAL = 9; + + + const CUSTOM = 8; + + + const DEBUG = 7; + + + const INFO = 6; + + + const NOTICE = 5; + + + const WARNING = 4; + + + const ERROR = 3; + + + const ALERT = 2; + + + const CRITICAL = 1; + + + const EMERGENCE = 0; + + + const EMERGENCY = 0; + + +} diff --git a/src/Phalcon/Plugin.php b/src/Phalcon/Plugin.php index ddc7559e..5689dbdb 100644 --- a/src/Phalcon/Plugin.php +++ b/src/Phalcon/Plugin.php @@ -3,10 +3,12 @@ namespace Phalcon; /** + * Phalcon\Plugin + * * This class can be used to provide user plugins an easy access to services * in the application */ -abstract class Plugin extends \Phalcon\Di\Injectable +class Plugin extends \Phalcon\Di\Injectable { } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index c86bd440..5f4d660d 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -5,11 +5,11 @@ /** * Phalcon\Registry * - * A registry is a container for storing objects and values in the application - * space. By storing the value in a registry, the same object is always - * available throughout your application. + * A registry is a container for storing objects and values in the application space. + * By storing the value in a registry, the same object is always available throughout + * your application. * - * ```php + * * $registry = new \Phalcon\Registry(); * * // Set value @@ -31,13 +31,13 @@ * unset($registry->something); * // or * unset($registry["something"]); - * ``` + * * * In addition to ArrayAccess, Phalcon\Registry also implements Countable * (count($registry) will return the number of elements in the registry), - * Serializable and Iterator (you can iterate over the registry using a foreach - * loop) interfaces. For PHP 5.4 and higher, JsonSerializable interface is - * implemented. + * Serializable and Iterator (you can iterate over the registry + * using a foreach loop) interfaces. For PHP 5.4 and higher, JsonSerializable + * interface is implemented. * * Phalcon\Registry is very fast (it is typically faster than any userspace * implementation of the registry); however, this comes at a price: @@ -49,186 +49,112 @@ * is several times slower than $registry->property. * * Internally all the magic methods (and interfaces except JsonSerializable) - * are implemented using object handlers or similar techniques: this allows to - * bypass relatively slow method calls. + * are implemented using object handlers or similar techniques: this allows + * to bypass relatively slow method calls. */ -final class Registry extends \Phalcon\Collection +final class Registry implements \ArrayAccess, \Countable, \Iterator { - /** - * Constructor - * - * @param array $data - */ - final public function __construct(array $data = null) {} - - /** - * Magic getter to get an element from the collection - * - * @param string $element - * @return mixed - */ - final public function __get(string $element) {} - - /** - * Magic isset to check whether an element exists or not - * - * @param string $element - * @return bool - */ - final public function __isset(string $element): bool {} - - /** - * Magic setter to assign values to an element - * - * @param string $element - * @param mixed $value - */ - final public function __set(string $element, $value) {} + protected $_data; - /** - * Magic unset to remove an element from the collection - * - * @param string $element - */ - final public function __unset(string $element) {} /** - * Clears the internal collection + * Registry constructor */ - final public function clear() {} + public final function __construct() {} /** - * Count elements of an object + * Checks if the element is present in the registry * - * @link https://php.net/manual/en/countable.count.php - * @return int + * @param mixed $offset + * @return bool */ - final public function count(): int {} + public final function offsetExists($offset) {} /** - * Get the element from the collection + * Returns an index in the registry * - * @param string $element - * @param mixed $defaultValue + * @param mixed $offset * @return mixed */ - final public function get(string $element, $defaultValue = null) {} - - /** - * Returns the iterator of the class - * - * @return \Traversable - */ - final public function getIterator(): Traversable {} - - /** - * Get the element from the collection - * - * @param string $element - * @return bool - */ - final public function has(string $element): bool {} + public final function offsetGet($offset) {} /** - * Initialize internal array + * Sets an element in the registry * - * @param array $data + * @param mixed $offset + * @param mixed $value */ - final public function init(array $data = array()) {} + public final function offsetSet($offset, $value) {} /** - * Specify data which should be serialized to JSON + * Unsets an element in the registry * - * @link https://php.net/manual/en/jsonserializable.jsonserialize.php - * @return array + * @param mixed $offset */ - final public function jsonSerialize(): array {} + public final function offsetUnset($offset) {} /** - * Whether a offset exists + * Checks how many elements are in the register * - * @link https://php.net/manual/en/arrayaccess.offsetexists.php - * @param mixed $element - * @return bool + * @return int */ - final public function offsetExists($element): bool {} + public final function count() {} /** - * Offset to retrieve - * - * @link https://php.net/manual/en/arrayaccess.offsetget.php - * @param mixed $element - * @return mixed + * Moves cursor to next row in the registry */ - final public function offsetGet($element) {} + public final function next() {} /** - * Offset to set + * Gets pointer number of active row in the registry * - * @link https://php.net/manual/en/arrayaccess.offsetset.php - * @param mixed $element - * @param mixed $value + * @return int */ - final public function offsetSet($element, $value) {} + public final function key() {} /** - * Offset to unset - * - * @link https://php.net/manual/en/arrayaccess.offsetunset.php - * @param mixed $element + * Rewinds the registry cursor to its beginning */ - final public function offsetUnset($element) {} + public final function rewind() {} /** - * Delete the element from the collection + * Checks if the iterator is valid * - * @param string $element + * @return bool */ - final public function remove(string $element) {} + public function valid() {} /** - * String representation of object - * - * @link https://php.net/manual/en/serializable.serialize.php - * @return string + * Obtains the current value in the internal iterator */ - final public function serialize(): string {} + public function current() {} /** - * Set an element in the collection + * Sets an element in the registry * - * @param string $element + * @param string $key * @param mixed $value */ - final public function set(string $element, $value) {} + public final function __set($key, $value) {} /** - * Returns the object in an array format + * Returns an index in the registry * - * @return array + * @param string $key + * @return mixed */ - final public function toArray(): array {} + public final function __get($key) {} /** - * Returns the object in a JSON format - * - * The default string uses the following options for json_encode - * - * JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES - * - * @see https://www.ietf.org/rfc/rfc4627.txt - * @param int $options - * @return string + * @param string $key + * @return bool */ - final public function toJson(int $options = 79): string {} + public final function __isset($key) {} /** - * Constructs the object - * - * @link https://php.net/manual/en/serializable.unserialize.php - * @param mixed $serialized + * @param string $key */ - final public function unserialize($serialized) {} + public final function __unset($key) {} } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 8a79b6be..03661177 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -3,10 +3,11 @@ namespace Phalcon; /** - * This component provides a set of functions to improve the security in Phalcon - * applications + * Phalcon\Security * - * ```php + * This component provides a set of functions to improve the security in Phalcon applications + * + * * $login = $this->request->getPost("login"); * $password = $this->request->getPost("password"); * @@ -17,7 +18,7 @@ * // The password is valid * } * } - * ``` + * */ class Security implements \Phalcon\Di\InjectionAwareInterface { @@ -25,61 +26,58 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_DEFAULT = 0; - const CRYPT_BLOWFISH = 4; - - - const CRYPT_BLOWFISH_A = 5; + const CRYPT_STD_DES = 1; - const CRYPT_BLOWFISH_X = 6; + const CRYPT_EXT_DES = 2; - const CRYPT_BLOWFISH_Y = 7; + const CRYPT_MD5 = 3; - const CRYPT_EXT_DES = 2; + const CRYPT_BLOWFISH = 4; - const CRYPT_MD5 = 3; + const CRYPT_BLOWFISH_A = 5; - const CRYPT_SHA256 = 8; + const CRYPT_BLOWFISH_X = 6; - const CRYPT_SHA512 = 9; + const CRYPT_BLOWFISH_Y = 7; - const CRYPT_STD_DES = 1; + const CRYPT_SHA256 = 8; - protected $container; + const CRYPT_SHA512 = 9; - protected $defaultHash; + protected $_dependencyInjector; - protected $numberBytes = 16; + protected $_workFactor = 8; - protected $random; + protected $_numberBytes = 16; - protected $requestToken; + protected $_tokenKeySessionID = '$PHALCON/CSRF/KEY$'; - protected $token; + protected $_tokenValueSessionID = '$PHALCON/CSRF$'; - protected $tokenKey; + protected $_token; - protected $tokenKeySessionId = '$PHALCON/CSRF/KEY$'; + protected $_tokenKey; - protected $tokenValueSessionId = '$PHALCON/CSRF$'; + protected $_random; - protected $workFactor = 8; + protected $_defaultHash; /** @@ -96,129 +94,124 @@ public function getWorkFactor() {} public function __construct() {} /** - * Checks a plain text password and its hash version to check if the - * password matches + * Sets the dependency injector * - * @param string $password - * @param string $passwordHash - * @param int $maxPassLength - * @return bool + * @param \Phalcon\DiInterface $dependencyInjector */ - public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Check if the CSRF token sent in the request is the same that the current - * in session + * Returns the internal dependency injector * - * @param mixed $tokenKey - * @param mixed $tokenValue - * @param bool $destroyIfValid - * @return bool + * @return \Phalcon\DiInterface */ - public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool {} + public function getDI() {} /** - * Computes a HMAC + * Sets a number of bytes to be generated by the openssl pseudo random generator * - * @param string $data - * @param string $key - * @param string $algo - * @param bool $raw - * @return string + * @param long $randomBytes + * @return Security */ - public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string {} + public function setRandomBytes($randomBytes) {} /** - * Removes the value of the CSRF token and key from session + * Returns a number of bytes to be generated by the openssl pseudo random generator * - * @return Security + * @return string */ - public function destroyToken(): Security {} + public function getRandomBytes() {} /** - * Returns the default hash + * Returns a secure random number generator instance * - * @return int|null + * @return \Phalcon\Security\Random */ - public function getDefaultHash(): ?int {} + public function getRandom() {} /** - * Returns the internal dependency injector + * Generate a >22-length pseudo random string to be used as salt for passwords * - * @return \Phalcon\Di\DiInterface + * @param int $numberBytes + * @return string */ - public function getDI(): DiInterface {} + public function getSaltBytes($numberBytes = 0) {} /** - * Returns a secure random number generator instance + * Creates a password hash using bcrypt with a pseudo random salt * - * @return \Phalcon\Security\Random + * @param string $password + * @param int $workFactor + * @return string */ - public function getRandom(): Random {} + public function hash($password, $workFactor = 0) {} /** - * Returns a number of bytes to be generated by the openssl pseudo random - * generator + * Checks a plain text password and its hash version to check if the password matches * - * @return string + * @param string $password + * @param string $passwordHash + * @param int $maxPassLength + * @return bool */ - public function getRandomBytes(): string {} + public function checkHash($password, $passwordHash, $maxPassLength = 0) {} /** - * Returns the value of the CSRF token for the current request. + * Checks if a password hash is a valid bcrypt's hash * - * @return string + * @param string $passwordHash + * @return bool */ - public function getRequestToken(): string {} + public function isLegacyHash($passwordHash) {} /** - * Returns the value of the CSRF token in session + * Generates a pseudo random token key to be used as input's name in a CSRF check * * @return string */ - public function getSessionToken(): string {} + public function getTokenKey() {} /** - * Generate a >22-length pseudo random string to be used as salt for - * passwords + * Generates a pseudo random token value to be used as input's value in a CSRF check * - * @param int $numberBytes * @return string */ - public function getSaltBytes(int $numberBytes = 0): string {} + public function getToken() {} /** - * Generates a pseudo random token value to be used as input's value in a - * CSRF check + * Check if the CSRF token sent in the request is the same that the current in session * - * @return string + * @param mixed $tokenKey + * @param mixed $tokenValue + * @param bool $destroyIfValid + * @return bool */ - public function getToken(): string {} + public function checkToken($tokenKey = null, $tokenValue = null, $destroyIfValid = true) {} /** - * Generates a pseudo random token key to be used as input's name in a CSRF - * check + * Returns the value of the CSRF token in session * * @return string */ - public function getTokenKey(): string {} + public function getSessionToken() {} /** - * Creates a password hash using bcrypt with a pseudo random salt + * Removes the value of the CSRF token and key from session * - * @param string $password - * @param int $workFactor - * @return string + * @return Security */ - public function hash(string $password, int $workFactor = 0): string {} + public function destroyToken() {} /** - * Checks if a password hash is a valid bcrypt's hash + * Computes a HMAC * - * @param string $passwordHash - * @return bool + * @param string $data + * @param string $key + * @param string $algo + * @param bool $raw + * @return string */ - public function isLegacyHash(string $passwordHash): bool {} + public function computeHmac($data, $key, $algo, $raw = false) {} /** * Sets the default hash @@ -226,22 +219,39 @@ public function isLegacyHash(string $passwordHash): bool {} * @param int $defaultHash * @return Security */ - public function setDefaultHash(int $defaultHash): Security {} + public function setDefaultHash($defaultHash) {} /** - * Sets the dependency injector + * Returns the default hash * - * @param \Phalcon\Di\DiInterface $container + * @return int|null */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getDefaultHash() {} /** - * Sets a number of bytes to be generated by the openssl pseudo random - * generator + * Testing for LibreSSL * - * @param long $randomBytes - * @return Security + * @deprecated Will be removed in 4.0.0 + * @return bool + */ + public function hasLibreSsl() {} + + /** + * Getting OpenSSL or LibreSSL version. + * + * Parse OPENSSL_VERSION_TEXT because OPENSSL_VERSION_NUMBER is no use for LibreSSL. + * This constant show not the current system openssl library version but version PHP was compiled with. + * + * @deprecated Will be removed in 4.0.0 + * @link https://bugs.php.net/bug.php?id=71143 + * + * + * if ($security->getSslVersionNumber() >= 20105) { + * // ... + * } + * + * @return int */ - public function setRandomBytes(int $randomBytes): Security {} + public function getSslVersionNumber() {} } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 75c84096..cc253c01 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -3,9 +3,11 @@ namespace Phalcon; /** + * Phalcon\Tag + * * Phalcon\Tag is designed to simplify building of HTML tags. * It provides a set of helpers to generate HTML in a dynamic way. - * This component is a class that you can extend to add more helpers. + * This component is an abstract class that you can extend to add more helpers. */ class Tag { @@ -42,570 +44,539 @@ class Tag const XHTML5 = 11; - - static protected $autoEscape = true; - /** - * Framework Dispatcher + * Pre-assigned values for components */ - static protected $container; + static protected $_displayValues; /** - * Pre-assigned values for components + * HTML document title */ - static protected $displayValues; + static protected $_documentTitle = null; - static protected $dispatcherService = null; + static protected $_documentAppendTitle = null; - static protected $documentAppendTitle = null; + static protected $_documentPrependTitle = null; - static protected $documentPrependTitle = null; + static protected $_documentTitleSeparator = null; + + + static protected $_documentType = 11; /** - * HTML document title + * Framework Dispatcher */ - static protected $documentTitle = null; + static protected $_dependencyInjector; - static protected $documentTitleSeparator = null; + static protected $_urlService = null; - static protected $documentType = 11; + static protected $_dispatcherService = null; - static protected $escaperService = null; + static protected $_escaperService = null; - static protected $urlService = null; + static protected $_autoEscape = true; /** - * Appends a text to current document title - * - * @param mixed $title - */ - public static function appendTitle($title) {} - - /** - * Builds a HTML input[type="check"] tag - * - * ```php - * echo Phalcon\Tag::checkField( - * [ - * "terms", - * "value" => "Y", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ check_field("terms") }} - * ``` + * Obtains the 'escaper' service if required * - * @param array $parameters - * @return string + * @param array $params + * @return EscaperInterface */ - public static function checkField($parameters): string {} + public static function getEscaper(array $params) {} /** - * Builds a HTML input[type="color"] tag + * Renders parameters keeping order in their HTML attributes * - * @param array $parameters + * @param string $code + * @param array $attributes * @return string */ - public static function colorField($parameters): string {} + public static function renderAttributes($code, array $attributes) {} /** - * Builds a HTML input[type="date"] tag - * - * ```php - * echo Phalcon\Tag::dateField( - * [ - * "born", - * "value" => "14-12-1980", - * ] - * ); - * ``` + * Sets the dependency injector container. * - * @param array $parameters - * @return string + * @param DiInterface $dependencyInjector */ - public static function dateField($parameters): string {} + public static function setDI(DiInterface $dependencyInjector) {} /** - * Builds a HTML input[type="datetime"] tag + * Internally gets the request dispatcher * - * @param array $parameters - * @return string + * @return DiInterface */ - public static function dateTimeField($parameters): string {} + public static function getDI() {} /** - * Builds a HTML input[type="datetime-local"] tag + * Returns a URL service from the default DI * - * @param array $parameters - * @return string + * @return \Phalcon\Mvc\UrlInterface */ - public static function dateTimeLocalField($parameters): string {} + public static function getUrlService() {} /** - * Alias of Phalcon\Tag::setDefault() + * Returns an Escaper service from the default DI * - * @param string $id - * @param string $value + * @return EscaperInterface */ - public static function displayTo(string $id, $value) {} + public static function getEscaperService() {} /** - * Builds a HTML input[type="email"] tag - * - * ```php - * echo Phalcon\Tag::emailField("email"); - * ``` + * Set autoescape mode in generated html * - * @param array $parameters - * @return string + * @param bool $autoescape */ - public static function emailField($parameters): string {} + public static function setAutoescape($autoescape) {} /** - * Builds a HTML close FORM tag + * Assigns default values to generated tags by helpers * - * @return string - */ - public static function endForm(): string {} - - /** - * Builds a HTML input[type="file"] tag + * + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefault("name", "peter"); * - * ```php - * echo Phalcon\Tag::fileField("file"); - * ``` + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * * - * @param array $parameters - * @return string + * @param string $id + * @param string $value */ - public static function fileField($parameters): string {} + public static function setDefault($id, $value) {} /** - * Builds a HTML FORM tag - * - * ```php - * echo Phalcon\Tag::form("posts/save"); + * Assigns default values to generated tags by helpers * - * echo Phalcon\Tag::form( + * + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefaults( * [ - * "posts/save", - * "method" => "post", + * "name" => "peter", * ] * ); - * ``` * - * Volt syntax: - * ```php - * {{ form("posts/save") }} - * {{ form("posts/save", "method": "post") }} - * ``` + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * * - * @param array $parameters - * @return string + * @param array $values + * @param bool $merge */ - public static function form($parameters): string {} + public static function setDefaults(array $values, $merge = false) {} /** - * Converts texts into URL-friendly titles - * - * ```php - * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") - * ``` + * Alias of Phalcon\Tag::setDefault * - * @param string $text - * @param string $separator - * @param bool $lowercase - * @param mixed $replace - * @return string + * @param string $id + * @param string $value */ - public static function friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string {} + public static function displayTo($id, $value) {} /** - * Get the document type declaration of content + * Check if a helper has a default value set using Phalcon\Tag::setDefault or value from $_POST * - * @return string + * @param string $name + * @return bool */ - public static function getDocType(): string {} + public static function hasValue($name) {} /** - * Obtains the 'escaper' service if required + * Every helper calls this function to check whether a component has a predefined + * value using Phalcon\Tag::setDefault or value from $_POST * + * @param string $name * @param array $params - * @return null|\Phalcon\Escaper\EscaperInterface + * @return mixed */ - public static function getEscaper(array $params): ?EscaperInterface {} + public static function getValue($name, $params = null) {} /** - * Internally gets the request dispatcher + * Resets the request and internal values to avoid those fields will have any default value. * - * @return \Phalcon\Di\DiInterface + * @deprecated Will be removed in 4.0.0 + * @deprecated */ - public static function getDI(): DiInterface {} + public static function resetInput() {} /** - * Returns an Escaper service from the default DI + * Builds a HTML A tag using framework conventions * - * @return \Phalcon\Escaper\EscaperInterface - */ - public static function getEscaperService(): EscaperInterface {} - - /** - * Gets the current document title. - * The title will be automatically escaped. + * + * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); * - * ```php - * Tag::prependTitle('Hello'); - * Tag::setTitle('World'); - * Tag::appendTitle('from Phalcon'); + * echo Phalcon\Tag::linkTo( + * [ + * "signup/register", + * "Register Here!" + * ] + * ); * - * echo Tag::getTitle(); // Hello World from Phalcon - * echo Tag::getTitle(false); // World from Phalcon - * echo Tag::getTitle(true, false); // Hello World - * echo Tag::getTitle(false, false); // World - * ``` + * echo Phalcon\Tag::linkTo( + * [ + * "signup/register", + * "Register Here!", + * "class" => "btn-primary", + * ] + * ); * - * ```php - * {{ get_title() }} - * ``` + * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); * - * @param bool $prepend - * @param bool $append - * @return string - */ - public static function getTitle(bool $prepend = true, bool $append = true): string {} - - /** - * Gets the current document title separator + * echo Phalcon\Tag::linkTo( + * [ + * "http://phalconphp.com/", + * "Phalcon Home", + * false, + * ] + * ); * - * ```php - * echo Phalcon\Tag::getTitleSeparator(); - * ``` + * echo Phalcon\Tag::linkTo( + * [ + * "http://phalconphp.com/", + * "Phalcon Home", + * "local" => false, + * ] + * ); * - * ```php - * {{ get_title_separator() }} - * ``` + * echo Phalcon\Tag::linkTo( + * [ + * "action" => "http://phalconphp.com/", + * "text" => "Phalcon Home", + * "local" => false, + * "target" => "_new" + * ] + * ); * + * + * + * @param array|string $parameters + * @param string $text + * @param boolean $local * @return string */ - public static function getTitleSeparator(): string {} + public static function linkTo($parameters, $text = null, $local = true) {} /** - * Returns a URL service from the default DI + * Builds generic INPUT tags * - * @return \Phalcon\Url\UrlInterface + * @param string $type + * @param array $parameters + * @param boolean $asValue + * @return string */ - public static function getUrlService(): UrlInterface {} + static protected final function _inputField($type, $parameters, $asValue = false) {} /** - * Every helper calls this function to check whether a component has a - * predefined value using Phalcon\Tag::setDefault() or value from $_POST + * Builds INPUT tags that implements the checked attribute * - * @param string $name - * @param array $params - * @return mixed + * @param string $type + * @param array $parameters + * @return string */ - public static function getValue($name, array $params = array()) {} + static protected final function _inputFieldChecked($type, $parameters) {} /** - * Check if a helper has a default value set using Phalcon\Tag::setDefault() - * or value from $_POST + * Builds a HTML input[type="color"] tag * - * @param string $name - * @return bool + * @param array $parameters + * @return string */ - public static function hasValue($name): bool {} + public static function colorField($parameters) {} /** - * Builds a HTML input[type="hidden"] tag + * Builds a HTML input[type="text"] tag * - * ```php - * echo Phalcon\Tag::hiddenField( + * + * echo Phalcon\Tag::textField( * [ * "name", - * "value" => "mike", + * "size" => 30, * ] * ); - * ``` + * * * @param array $parameters * @return string */ - public static function hiddenField($parameters): string {} + public static function textField($parameters) {} /** - * Builds HTML IMG tags - * - * ```php - * echo Phalcon\Tag::image("img/bg.png"); + * Builds a HTML input[type="number"] tag * - * echo Phalcon\Tag::image( + * + * echo Phalcon\Tag::numericField( * [ - * "img/photo.jpg", - * "alt" => "Some Photo", + * "price", + * "min" => "1", + * "max" => "5", * ] * ); - * ``` + * * - * Volt Syntax: - * ```php - * {{ image("img/bg.png") }} - * {{ image("img/photo.jpg", "alt": "Some Photo") }} - * {{ image("http://static.mywebsite.com/img/bg.png", false) }} - * ``` + * @param array $parameters + * @return string + */ + public static function numericField($parameters) {} + + /** + * Builds a HTML input[type="range"] tag * * @param array $parameters - * @param bool $local * @return string */ - public static function image($parameters = null, bool $local = true): string {} + public static function rangeField($parameters) {} /** - * Builds a HTML input[type="image"] tag + * Builds a HTML input[type="email"] tag * - * ```php - * echo Phalcon\Tag::imageInput( + * + * echo Phalcon\Tag::emailField("email"); + * + * + * @param array $parameters + * @return string + */ + public static function emailField($parameters) {} + + /** + * Builds a HTML input[type="date"] tag + * + * + * echo Phalcon\Tag::dateField( * [ - * "src" => "/img/button.png", + * "born", + * "value" => "14-12-1980", * ] * ); - * ``` - * - * Volt syntax: - * ```php - * {{ image_input("src": "/img/button.png") }} - * ``` + * * * @param array $parameters * @return string */ - public static function imageInput($parameters): string {} + public static function dateField($parameters) {} /** - * Builds a SCRIPT[type="javascript"] tag - * - * ```php - * echo Phalcon\Tag::javascriptInclude( - * "http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", - * false - * ); + * Builds a HTML input[type="datetime"] tag * - * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); - * ``` + * @param array $parameters + * @return string + */ + public static function dateTimeField($parameters) {} + + /** + * Builds a HTML input[type="datetime-local"] tag * - * Volt syntax: - * ```php - * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} - * {{ javascript_include("javascript/jquery.js") }} - * ``` + * @param array $parameters + * @return string + */ + public static function dateTimeLocalField($parameters) {} + + /** + * Builds a HTML input[type="month"] tag * * @param array $parameters - * @param bool $local * @return string */ - public static function javascriptInclude($parameters = null, bool $local = true): string {} + public static function monthField($parameters) {} /** - * Builds a HTML A tag using framework conventions + * Builds a HTML input[type="time"] tag * - * ```php - * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); + * @param array $parameters + * @return string + */ + public static function timeField($parameters) {} + + /** + * Builds a HTML input[type="week"] tag * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!" - * ] - * ); + * @param array $parameters + * @return string + */ + public static function weekField($parameters) {} + + /** + * Builds a HTML input[type="password"] tag * - * echo Phalcon\Tag::linkTo( + * + * echo Phalcon\Tag::passwordField( * [ - * "signup/register", - * "Register Here!", - * "class" => "btn-primary", + * "name", + * "size" => 30, * ] * ); + * * - * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); - * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * false, - * ] - * ); + * @param array $parameters + * @return string + */ + public static function passwordField($parameters) {} + + /** + * Builds a HTML input[type="hidden"] tag * - * echo Phalcon\Tag::linkTo( + * + * echo Phalcon\Tag::hiddenField( * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * "local" => false, + * "name", + * "value" => "mike", * ] * ); + * * - * echo Phalcon\Tag::linkTo( - * [ - * "action" => "http://phalconphp.com/", - * "text" => "Phalcon Home", - * "local" => false, - * "target" => "_new" - * ] - * ); + * @param array $parameters + * @return string + */ + public static function hiddenField($parameters) {} + + /** + * Builds a HTML input[type="file"] tag * - * ``` + * + * echo Phalcon\Tag::fileField("file"); + * * - * @param array|string $parameters - * @param string $text - * @param bool $local + * @param array $parameters * @return string */ - public static function linkTo($parameters, $text = null, $local = true): string {} + public static function fileField($parameters) {} /** - * Builds a HTML input[type="month"] tag + * Builds a HTML input[type="search"] tag * * @param array $parameters * @return string */ - public static function monthField($parameters): string {} + public static function searchField($parameters) {} /** - * Builds a HTML input[type="number"] tag + * Builds a HTML input[type="tel"] tag * - * ```php - * echo Phalcon\Tag::numericField( - * [ - * "price", - * "min" => "1", - * "max" => "5", - * ] - * ); - * ``` + * @param array $parameters + * @return string + */ + public static function telField($parameters) {} + + /** + * Builds a HTML input[type="url"] tag * * @param array $parameters * @return string */ - public static function numericField($parameters): string {} + public static function urlField($parameters) {} /** - * Builds a HTML input[type="password"] tag + * Builds a HTML input[type="check"] tag * - * ```php - * echo Phalcon\Tag::passwordField( + * + * echo Phalcon\Tag::checkField( * [ - * "name", - * "size" => 30, + * "terms", + * "value" => "Y", * ] * ); - * ``` + * + * + * Volt syntax: + * + * {{ check_field("terms") }} + * * * @param array $parameters * @return string */ - public static function passwordField($parameters): string {} - - /** - * Prepends a text to current document title - * - * @param mixed $title - */ - public static function prependTitle($title) {} + public static function checkField($parameters) {} /** * Builds a HTML input[type="radio"] tag * - * ```php + * * echo Phalcon\Tag::radioField( * [ * "weather", * "value" => "hot", * ] * ); - * ``` + * * * Volt syntax: - * ```php + * * {{ radio_field("Save") }} - * ``` + * * * @param array $parameters * @return string */ - public static function radioField($parameters): string {} + public static function radioField($parameters) {} /** - * Builds a HTML input[type="range"] tag + * Builds a HTML input[type="image"] tag * - * @param array $parameters - * @return string - */ - public static function rangeField($parameters): string {} - - /** - * Renders parameters keeping order in their HTML attributes + * + * echo Phalcon\Tag::imageInput( + * [ + * "src" => "/img/button.png", + * ] + * ); + * * - * @param string $code - * @param array $attributes + * Volt syntax: + * + * {{ image_input("src": "/img/button.png") }} + * + * + * @param array $parameters * @return string */ - public static function renderAttributes(string $code, array $attributes): string {} + public static function imageInput($parameters) {} /** - * Renders the title with title tags. The title is automaticall escaped - * - * ```php - * Tag::prependTitle('Hello'); - * Tag::setTitle('World'); - * Tag::appendTitle('from Phalcon'); + * Builds a HTML input[type="submit"] tag * - * echo Tag::renderTitle(); // Hello World from Phalcon - * echo Tag::renderTitle(false); // World from Phalcon - * echo Tag::renderTitle(true, false); // Hello World - * echo Tag::renderTitle(false, false); // World - * ``` + * + * echo Phalcon\Tag::submitButton("Save") + * * - * ```php - * {{ render_title() }} - * ``` + * Volt syntax: + * + * {{ submit_button("Save") }} + * * - * @param bool $prepend - * @param bool $append + * @param array $parameters * @return string */ - public static function renderTitle(bool $prepend = true, bool $append = true): string {} + public static function submitButton($parameters) {} /** - * Resets the request and internal values to avoid those fields will have - * any default value. + * Builds a HTML SELECT tag using a PHP array for options * - * @deprecated Will be removed in 4.0.0 - * @deprecated - */ - public static function resetInput() {} - - /** - * Builds a HTML input[type="search"] tag + * + * echo Phalcon\Tag::selectStatic( + * "status", + * [ + * "A" => "Active", + * "I" => "Inactive", + * ] + * ); + * * * @param array $parameters + * @param array $data * @return string */ - public static function searchField($parameters): string {} + public static function selectStatic($parameters, $data = null) {} /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * - * ```php + * * echo Phalcon\Tag::select( * [ * "robotId", @@ -613,272 +584,261 @@ public static function searchField($parameters): string {} * "using" => ["id", "name"], * ] * ); - * ``` + * * * Volt syntax: - * ```php + * * {{ select("robotId", robots, "using": ["id", "name"]) }} - * ``` + * * * @param array $parameters * @param array $data * @return string */ - public static function select($parameters, $data = null): string {} + public static function select($parameters, $data = null) {} /** - * Builds a HTML SELECT tag using a PHP array for options + * Builds a HTML TEXTAREA tag * - * ```php - * echo Phalcon\Tag::selectStatic( - * "status", + * + * echo Phalcon\Tag::textArea( * [ - * "A" => "Active", - * "I" => "Inactive", + * "comments", + * "cols" => 10, + * "rows" => 4, * ] * ); - * ``` + * + * + * Volt syntax: + * + * {{ text_area("comments", "cols": 10, "rows": 4) }} + * * * @param array $parameters - * @param array $data * @return string */ - public static function selectStatic($parameters, $data = null): string {} - - /** - * Set autoescape mode in generated html - * - * @param bool $autoescape - */ - public static function setAutoescape(bool $autoescape) {} + public static function textArea($parameters) {} /** - * Assigns default values to generated tags by helpers - * - * ```php - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefault("name", "peter"); - * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * ``` + * Builds a HTML FORM tag * - * @param string $id - * @param string $value - */ - public static function setDefault(string $id, $value) {} - - /** - * Assigns default values to generated tags by helpers + * + * echo Phalcon\Tag::form("posts/save"); * - * ```php - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefaults( + * echo Phalcon\Tag::form( * [ - * "name" => "peter", + * "posts/save", + * "method" => "post", * ] * ); + * * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * ``` - * - * @param array $values - * @param bool $merge - */ - public static function setDefaults(array $values, bool $merge = false) {} - - /** - * Sets the dependency injector container. + * Volt syntax: + * + * {{ form("posts/save") }} + * {{ form("posts/save", "method": "post") }} + * * - * @param \Phalcon\Di\DiInterface $container + * @param array $parameters + * @return string */ - public static function setDI(\Phalcon\Di\DiInterface $container) {} + public static function form($parameters) {} /** - * Set the document type of content + * Builds a HTML close FORM tag * - * @param int $doctype + * @return string */ - public static function setDocType(int $doctype) {} + public static function endForm() {} /** * Set the title of view content * - * ```php + * * Phalcon\Tag::setTitle("Welcome to my Page"); - * ``` + * * * @param string $title */ - public static function setTitle(string $title) {} + public static function setTitle($title) {} /** * Set the title separator of view content * - * ```php + * * Phalcon\Tag::setTitleSeparator("-"); - * ``` + * * * @param string $titleSeparator */ - public static function setTitleSeparator(string $titleSeparator) {} + public static function setTitleSeparator($titleSeparator) {} /** - * Builds a LINK[rel="stylesheet"] tag - * - * ```php - * echo Phalcon\Tag::stylesheetLink( - * "http://fonts.googleapis.com/css?family=Rosario", - * false - * ); - * - * echo Phalcon\Tag::stylesheetLink("css/style.css"); - * ``` - * - * Volt Syntax: - * ```php - * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} - * {{ stylesheet_link("css/style.css") }} - * ``` + * Appends a text to current document title * - * @param array $parameters - * @param bool $local - * @return string + * @param mixed $title */ - public static function stylesheetLink($parameters = null, bool $local = true): string {} + public static function appendTitle($title) {} /** - * Builds a HTML input[type="submit"] tag - * - * ```php - * echo Phalcon\Tag::submitButton("Save") - * ``` - * - * Volt syntax: - * ```php - * {{ submit_button("Save") }} - * ``` + * Prepends a text to current document title * - * @param array $parameters - * @return string + * @param mixed $title */ - public static function submitButton($parameters): string {} + public static function prependTitle($title) {} /** - * Builds a HTML tag + * Gets the current document title. + * The title will be automatically escaped. * - * @param string $tagName - * @param mixed $parameters - * @param bool $selfClose - * @param bool $onlyStart - * @param bool $useEol + * + * echo Phalcon\Tag::getTitle(); + * + * + * + * {{ get_title() }} + * + * + * @param bool $tags * @return string */ - public static function tagHtml(string $tagName, $parameters = null, bool $selfClose = false, bool $onlyStart = false, bool $useEol = false): string {} + public static function getTitle($tags = true) {} /** - * Builds a HTML tag closing tag + * Gets the current document title separator * - * ```php - * echo Phalcon\Tag::tagHtmlClose("script", true); - * ``` + * + * echo Phalcon\Tag::getTitleSeparator(); + * + * + * + * {{ get_title_separator() }} + * * - * @param string $tagName - * @param bool $useEol * @return string */ - public static function tagHtmlClose(string $tagName, bool $useEol = false): string {} + public static function getTitleSeparator() {} /** - * Builds a HTML input[type="tel"] tag + * Builds a LINK[rel="stylesheet"] tag + * + * + * echo Phalcon\Tag::stylesheetLink("http://fonts.googleapis.com/css?family=Rosario", false); + * echo Phalcon\Tag::stylesheetLink("css/style.css"); + * + * + * Volt Syntax: + * + * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} + * {{ stylesheet_link("css/style.css") }} + * * * @param array $parameters + * @param boolean $local * @return string */ - public static function telField($parameters): string {} + public static function stylesheetLink($parameters = null, $local = true) {} /** - * Builds a HTML TEXTAREA tag + * Builds a SCRIPT[type="javascript"] tag * - * ```php - * echo Phalcon\Tag::textArea( - * [ - * "comments", - * "cols" => 10, - * "rows" => 4, - * ] - * ); - * ``` + * + * echo Phalcon\Tag::javascriptInclude("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false); + * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); + * * * Volt syntax: - * ```php - * {{ text_area("comments", "cols": 10, "rows": 4) }} - * ``` + * + * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} + * {{ javascript_include("javascript/jquery.js") }} + * * * @param array $parameters + * @param boolean $local * @return string */ - public static function textArea($parameters): string {} + public static function javascriptInclude($parameters = null, $local = true) {} /** - * Builds a HTML input[type="text"] tag + * Builds HTML IMG tags * - * ```php - * echo Phalcon\Tag::textField( + * + * echo Phalcon\Tag::image("img/bg.png"); + * + * echo Phalcon\Tag::image( * [ - * "name", - * "size" => 30, + * "img/photo.jpg", + * "alt" => "Some Photo", * ] * ); - * ``` + * + * + * Volt Syntax: + * + * {{ image("img/bg.png") }} + * {{ image("img/photo.jpg", "alt": "Some Photo") }} + * {{ image("http://static.mywebsite.com/img/bg.png", false) }} + * * * @param array $parameters + * @param boolean $local * @return string */ - public static function textField($parameters): string {} + public static function image($parameters = null, $local = true) {} /** - * Builds a HTML input[type="time"] tag + * Converts texts into URL-friendly titles * - * @param array $parameters + * + * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") + * + * + * @param string $text + * @param string $separator + * @param bool $lowercase + * @param mixed $replace * @return string */ - public static function timeField($parameters): string {} + public static function friendlyTitle($text, $separator = '-', $lowercase = true, $replace = null) {} /** - * Builds a HTML input[type="url"] tag + * Set the document type of content * - * @param array $parameters - * @return string + * @param int $doctype */ - public static function urlField($parameters): string {} + public static function setDocType($doctype) {} /** - * Builds a HTML input[type="week"] tag + * Get the document type declaration of content * - * @param array $parameters * @return string */ - public static function weekField($parameters): string {} + public static function getDocType() {} /** - * Builds generic INPUT tags + * Builds a HTML tag * - * @param string $type - * @param array $parameters - * @param bool $asValue + * @param string $tagName + * @param mixed $parameters + * @param bool $selfClose + * @param bool $onlyStart + * @param bool $useEol * @return string */ - static final protected function inputField(string $type, $parameters, bool $asValue = false): string {} + public static function tagHtml($tagName, $parameters = null, $selfClose = false, $onlyStart = false, $useEol = false) {} /** - * Builds INPUT tags that implements the checked attribute + * Builds a HTML tag closing tag * - * @param string $type - * @param array $parameters + * + * echo Phalcon\Tag::tagHtmlClose("script", true); + * + * + * @param string $tagName + * @param bool $useEol * @return string */ - static final protected function inputFieldChecked(string $type, $parameters): string {} + public static function tagHtmlClose($tagName, $useEol = false) {} } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 14589c93..70eb7d2c 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -3,9 +3,11 @@ namespace Phalcon; /** + * Phalcon\Text + * * Provides utilities to work with texts */ -class Text +abstract class Text { const RANDOM_ALNUM = 0; @@ -14,233 +16,221 @@ class Text const RANDOM_ALPHA = 1; - const RANDOM_DISTINCT = 5; + const RANDOM_HEXDEC = 2; - const RANDOM_HEXDEC = 2; + const RANDOM_NUMERIC = 3; const RANDOM_NOZERO = 4; - const RANDOM_NUMERIC = 3; + const RANDOM_DISTINCT = 5; /** * Converts strings to camelize style * - * ```php + * * echo Phalcon\Text::camelize("coco_bongo"); // CocoBongo * echo Phalcon\Text::camelize("co_co-bon_go", "-"); // Co_coBon_go * echo Phalcon\Text::camelize("co_co-bon_go", "_-"); // CoCoBonGo - * ``` + * * - * @param string $text + * @param string $str * @param mixed $delimiter * @return string */ - public static function camelize(string $text, $delimiter = null): string {} + public static function camelize($str, $delimiter = null) {} /** - * Concatenates strings using the separator only once without duplication in - * places concatenation + * Uncamelize strings which are camelized * - * ```php - * $str = Phalcon\Text::concat( - * "/", - * "/tmp/", - * "/folder_1/", - * "/folder_2", - * "folder_3/" - * ); + * + * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo + * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo + * * - * // /tmp/folder_1/folder_2/folder_3/ - * echo $str; - * ``` + * @param string $str + * @param mixed $delimiter + * @return string + */ + public static function uncamelize($str, $delimiter = null) {} + + /** + * Adds a number to a string or increment that number if it already is defined * + * + * echo Phalcon\Text::increment("a"); // "a_1" + * echo Phalcon\Text::increment("a_1"); // "a_2" + * + * + * @param string $str * @param string $separator - * @param string $a - * @param string $b - * @param string $...N * @return string */ - public static function concat(): string {} + public static function increment($str, $separator = '_') {} /** - * Generates random text in accordance with the template + * Generates a random string based on the given type. Type is one of the RANDOM_ constants * - * ```php - * // Hi my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * + * use Phalcon\Text; * - * // Hi my name is a Jon - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * // "aloiwkqz" + * echo Text::random(Text::RANDOM_ALNUM); + * * - * // Hello my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * @param int $type + * @param long $length + * @return string + */ + public static function random($type = 0, $length = 8) {} + + /** + * Check if a string starts with a given string * - * // Hello my name is a Zyxep - * echo Phalcon\Text::dynamic( - * "[Hi/Hello], my name is a [Zyxep/Mark]!", - * "[", "]", - * "/" - * ); - * ``` + * + * echo Phalcon\Text::startsWith("Hello", "He"); // true + * echo Phalcon\Text::startsWith("Hello", "he", false); // false + * echo Phalcon\Text::startsWith("Hello", "he"); // true + * * - * @param string $text - * @param string $leftDelimiter - * @param string $rightDelimiter - * @param string $separator - * @return string + * @param string $str + * @param string $start + * @param bool $ignoreCase + * @return bool */ - public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string {} + public static function startsWith($str, $start, $ignoreCase = true) {} /** * Check if a string ends with a given string * - * ```php + * * echo Phalcon\Text::endsWith("Hello", "llo"); // true * echo Phalcon\Text::endsWith("Hello", "LLO", false); // false * echo Phalcon\Text::endsWith("Hello", "LLO"); // true - * ``` + * * - * @param string $text + * @param string $str * @param string $end * @param bool $ignoreCase * @return bool */ - public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool {} - - /** - * Makes an underscored or dashed phrase human-readable - * - * ```php - * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" - * echo Phalcon\Text::humanize("five_cats"); // "five cats" - * ``` - * - * @param string $text - * @return string - */ - public static function humanize(string $text): string {} + public static function endsWith($str, $end, $ignoreCase = true) {} /** - * Adds a number to a string or increment that number if it already is - * defined + * Lowercases a string, this function makes use of the mbstring extension if available * - * ```php - * echo Phalcon\Text::increment("a"); // "a_1" - * echo Phalcon\Text::increment("a_1"); // "a_2" - * ``` + * + * echo Phalcon\Text::lower("HELLO"); // hello + * * - * @param string $text - * @param string $separator + * @param string $str + * @param string $encoding * @return string */ - public static function increment(string $text, string $separator = '_'): string {} + public static function lower($str, $encoding = 'UTF-8') {} /** - * Lowercases a string, this function makes use of the mbstring extension if - * available + * Uppercases a string, this function makes use of the mbstring extension if available * - * ```php - * echo Phalcon\Text::lower("HELLO"); // hello - * ``` + * + * echo Phalcon\Text::upper("hello"); // HELLO + * * - * @param string $text + * @param string $str * @param string $encoding * @return string */ - public static function lower(string $text, string $encoding = 'UTF-8'): string {} + public static function upper($str, $encoding = 'UTF-8') {} /** - * Check if a string starts with a given string + * Reduces multiple slashes in a string to single slashes * - * ```php - * echo Phalcon\Text::startsWith("Hello", "He"); // true - * echo Phalcon\Text::startsWith("Hello", "he", false); // false - * echo Phalcon\Text::startsWith("Hello", "he"); // true - * ``` + * + * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); // foo/bar/baz + * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); // http://foo.bar/baz/buz + * * - * @param string $text - * @param string $start - * @param bool $ignoreCase - * @return bool + * @param string $str + * @return string */ - public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool {} + public static function reduceSlashes($str) {} /** - * Generates a random string based on the given type. Type is one of the - * RANDOM_ constants + * Concatenates strings using the separator only once without duplication in places concatenation * - * ```php - * use Phalcon\Text; + * + * $str = Phalcon\Text::concat( + * "/", + * "/tmp/", + * "/folder_1/", + * "/folder_2", + * "folder_3/" + * ); * - * // "aloiwkqz" - * echo Text::random(Text::RANDOM_ALNUM); - * ``` + * // /tmp/folder_1/folder_2/folder_3/ + * echo $str; + * * - * @param int $type - * @param long $length + * @param string $separator + * @param string $a + * @param string $b + * @param string $...N * @return string */ - public static function random(int $type = 0, int $length = 8): string {} + public static function concat() {} /** - * Reduces multiple slashes in a string to single slashes + * Generates random text in accordance with the template * - * ```php - * // foo/bar/baz - * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); + * + * // Hi my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * // http://foo.bar/baz/buz - * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); - * ``` + * // Hi my name is a Jon + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * @param string $text - * @return string - */ - public static function reduceSlashes(string $text): string {} - - /** - * Uncamelize strings which are camelized + * // Hello my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * ```php - * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo - * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo - * ``` + * // Hello my name is a Zyxep + * echo Phalcon\Text::dynamic("[Hi/Hello], my name is a [Zyxep/Mark]!", "[", "]", "/"); + * * * @param string $text - * @param mixed $delimiter + * @param string $leftDelimiter + * @param string $rightDelimiter + * @param string $separator * @return string */ - public static function uncamelize(string $text, $delimiter = null): string {} + public static function dynamic($text, $leftDelimiter = '{', $rightDelimiter = '}', $separator = '|') {} /** * Makes a phrase underscored instead of spaced * - * ```php + * * echo Phalcon\Text::underscore("look behind"); // "look_behind" * echo Phalcon\Text::underscore("Awesome Phalcon"); // "Awesome_Phalcon" - * ``` + * * * @param string $text * @return string */ - public static function underscore(string $text): string {} + public static function underscore($text) {} /** - * Uppercases a string, this function makes use of the mbstring extension if - * available + * Makes an underscored or dashed phrase human-readable * - * ```php - * echo Phalcon\Text::upper("hello"); // HELLO - * ``` + * + * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" + * echo Phalcon\Text::humanize("five_cats"); // "five cats" + * * * @param string $text - * @param string $encoding * @return string */ - public static function upper(string $text, string $encoding = 'UTF-8'): string {} + public static function humanize($text) {} } diff --git a/src/Phalcon/Translate.php b/src/Phalcon/Translate.php new file mode 100644 index 00000000..ad8cc91c --- /dev/null +++ b/src/Phalcon/Translate.php @@ -0,0 +1,14 @@ + * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * @@ -17,174 +26,163 @@ * "year" => "2012", * ] * ); - * ``` + * */ -class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterface +class Url implements UrlInterface, InjectionAwareInterface { - /** - * @var null | string - */ - protected $baseUri = null; - - /** - * @var null | string - */ - protected $basePath = null; - - /** - * @var - */ - protected $container; - - - protected $router; - - /** - * @var null | string - */ - protected $staticBaseUri = null; - - - /** - * Generates a URL - * - * ```php - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2015", - * ] - * ); - * - * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) - * echo $url->get( - * "show/products", - * [ - * "id" => 1, - * "name" => "Carrots", - * ] - * ); - * - * // Generate an absolute URL by setting the third parameter as false. - * echo $url->get( - * "https://phalconphp.com/", - * null, - * false - * ); - * ``` - * - * @param mixed $uri - * @param mixed $args - * @param bool $local - * @param mixed $baseUri - * @return string - */ - public function get($uri = null, $args = null, bool $local = null, $baseUri = null): string {} - - /** - * Returns the base path - * - * @return string - */ - public function getBasePath(): string {} - - /** - * Returns the prefix for all the generated urls. By default / - * - * @return string - */ - public function getBaseUri(): string {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Generates a URL for a static resource - * - * ```php - * // Generate a URL for a static resource - * echo $url->getStatic("img/logo.png"); - * - * // Generate a URL for a static predefined route - * echo $url->getStatic( - * [ - * "for" => "logo-cdn", - * ] - * ); - * ``` - * - * @param mixed $uri - * @return string - */ - public function getStatic($uri = null): string {} - - /** - * Returns the prefix for all the generated static urls. By default / - * - * @return string - */ - public function getStaticBaseUri(): string {} - - /** - * Sets a base path for all the generated paths - * - * ```php - * $url->setBasePath("/var/www/htdocs/"); - * ``` - * - * @param string $basePath - * @return \Phalcon\Url\UrlInterface - */ - public function setBasePath(string $basePath): UrlInterface {} - - /** - * Sets a prefix for all the URIs to be generated - * - * ```php - * $url->setBaseUri("/invo/"); - * - * $url->setBaseUri("/invo/index.php/"); - * ``` - * - * @param string $baseUri - * @return \Phalcon\Url\UrlInterface - */ - public function setBaseUri(string $baseUri): UrlInterface {} - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Sets a prefix for all static URLs generated - * - * ```php - * $url->setStaticBaseUri("/invo/"); - * ``` - * - * @param string $staticBaseUri - * @return \Phalcon\Url\UrlInterface - */ - public function setStaticBaseUri(string $staticBaseUri): UrlInterface {} - - /** - * Generates a local path - * - * @param string $path - * @return string - */ - public function path(string $path = null): string {} + /** + * @var null | string + */ + protected $baseUri = null; + + /** + * @var null | string + */ + protected $basePath = null; + + /** + * @var + */ + protected $container; + + protected $router; + + /** + * @var null | string + */ + protected $staticBaseUri = null; + + /** + * Generates a URL + * + * + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2015", + * ] + * ); + * + * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) + * echo $url->get( + * "show/products", + * [ + * "id" => 1, + * "name" => "Carrots", + * ] + * ); + * + * // Generate an absolute URL by setting the third parameter as false. + * echo $url->get( + * "https://phalconphp.com/", + * null, + * false + * ); + * + */ + public function get($uri = null, $args = null, bool $local = null, $baseUri = null) : string + { + } + + /** + * Returns the base path + */ + public function getBasePath() : string + { + } + + /** + * Returns the prefix for all the generated urls. By default / + */ + public function getBaseUri() : string + { + } + + /** + * Returns the DependencyInjector container + */ + public function getDI() : DiInterface + { + } + + /** + * Generates a URL for a static resource + * + * + * // Generate a URL for a static resource + * echo $url->getStatic("img/logo.png"); + * + * // Generate a URL for a static predefined route + * echo $url->getStatic( + * [ + * "for" => "logo-cdn", + * ] + * ); + * + */ + public function getStatic($uri = null) : string + { + } + + /** + * Returns the prefix for all the generated static urls. By default / + */ + public function getStaticBaseUri() : string + { + } + + /** + * Sets a base path for all the generated paths + * + * + * $url->setBasePath("/var/www/htdocs/"); + * + */ + public function setBasePath(string $basePath) : UrlInterface + { + } + + /** + * Sets a prefix for all the URIs to be generated + * + * + * $url->setBaseUri("/invo/"); + * + * $url->setBaseUri("/invo/index.php/"); + * + */ + public function setBaseUri(string $baseUri) : UrlInterface + { + } + + /** + * Sets the DependencyInjector container + */ + public function setDI(DiInterface $dependencyInjector) + { + } + + /** + * Sets a prefix for all static URLs generated + * + * + * $url->setStaticBaseUri("/invo/"); + * + */ + public function setStaticBaseUri(string $staticBaseUri) : UrlInterface + { + } + + /** + * Generates a local path + */ + public function path(string $path = null) : string + { + } } diff --git a/src/Phalcon/Urlinterface.php b/src/Phalcon/Urlinterface.php new file mode 100644 index 00000000..d107d252 --- /dev/null +++ b/src/Phalcon/Urlinterface.php @@ -0,0 +1,44 @@ + * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * ``` + * */ const VERSION_MAJOR = 0; /** * The constant referencing the major version. Returns 1 * - * ```php + * * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MEDIUM * ); - * ``` + * */ const VERSION_MEDIUM = 1; /** * The constant referencing the major version. Returns 2 * - * ```php + * * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MINOR * ); - * ``` + * */ const VERSION_MINOR = 2; /** * The constant referencing the major version. Returns 3 * - * ```php + * * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL * ); - * ``` + * */ const VERSION_SPECIAL = 3; /** * The constant referencing the major version. Returns 4 * - * ```php + * * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL_NUMBER * ); - * ``` + * */ const VERSION_SPECIAL_NUMBER = 4; @@ -70,56 +72,58 @@ class Version * A - Major version * B - Med version (two digits) * C - Min version (two digits) - * D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable + * D - Special release: 1 = Alpha, 2 = Beta, 3 = RC, 4 = Stable * E - Special release version i.e. RC1, Beta2 etc. * * @return array */ - protected static function _getVersion(): array {} + protected static function _getVersion() {} /** - * Translates a number to a special release. + * Translates a number to a special release + * + * If Special release = 1 this function will return ALPHA * * @param int $special * @return string */ - protected final static function _getSpecial(int $special): string {} + protected final static function _getSpecial($special) {} /** * Returns the active version (string) * - * ```php + * * echo Phalcon\Version::get(); - * ``` + * * * @return string */ - public static function get(): string {} + public static function get() {} /** * Returns the numeric active version * - * ```php + * * echo Phalcon\Version::getId(); - * ``` + * * * @return string */ - public static function getId(): string {} + public static function getId() {} /** * Returns a specific part of the version. If the wrong parameter is passed * it will return the full version * - * ```php + * * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * ``` + * * * @param int $part * @return string */ - public static function getPart(int $part): string {} + public static function getPart($part) {} } diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/Adapter.php similarity index 58% rename from src/Phalcon/acl/adapter/AbstractAdapter.php rename to src/Phalcon/acl/Adapter.php index 70df5795..a2997aab 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/Adapter.php @@ -1,18 +1,30 @@ setDefaultAction( - * \Phalcon\Acl\Enum::DENY + * \Phalcon\Acl::DENY * ); * * // Register roles @@ -51,9 +56,9 @@ * } * * // Grant access to public areas to both users and guests - * foreach ($roles as $role) { + * foreach ($roles as $role){ * foreach ($publicComponents as $component => $actions) { - * $acl->allow($role->getName(), $component, ""); + * $acl->allow($role->getName(), $component, "*"); * } * } * @@ -63,9 +68,9 @@ * $acl->allow("Users", $component, $action); * } * } - * ``` + *``` */ -class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter +class Memory extends Adapter { /** * Access @@ -81,11 +86,11 @@ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter */ protected $accessList; - /** - * Returns latest function used to acquire access - * - * @var mixed - */ + /** + * Returns latest function used to acquire access + * + * @var mixed + */ protected $activeFunction; /** @@ -93,7 +98,7 @@ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter * * @var int */ - protected $activeFunctionCustomArgumentsCount = 0; + protected $activeFunctionCustomArgumentsCount; /** * Returns latest key used to acquire access @@ -128,7 +133,7 @@ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter * * @var mixed */ - protected $noArgumentsDefaultAction = Enum::DENY; + protected $noArgumentsDefaultAction = Acl::DENY; /** * Roles @@ -152,27 +157,6 @@ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter protected $rolesNames; - /** - * Returns latest function used to acquire access - * - * @return mixed - */ - public function getActiveFunction() {} - - /** - * Returns number of additional arguments(excluding role and resource) for active function - * - * @return int - */ - public function getActiveFunctionCustomArgumentsCount(): int {} - - /** - * Returns latest key used to acquire access - * - * @return string|null - */ - public function getActiveKey(): ?string {} - /** * Phalcon\Acl\Adapter\Memory constructor */ @@ -211,21 +195,20 @@ public function __construct() {} * ] * ); * ``` - * - * @param mixed $componentValue - * @param mixed $accessList + * @param $componentValue + * @param $accessList * @return bool */ - public function addComponent($componentValue, $accessList): bool {} + public function addComponent($componentValue, $accessList) : bool {} /** * Adds access to components * - * @param string $componentName - * @param mixed $accessList + * @param $componentName + * @param $accessList * @return bool */ - public function addComponentAccess(string $componentName, $accessList): bool {} + public function addComponentAccess(string $componentName, $accessList) : bool {} /** * Do a role inherit from another existing role @@ -236,10 +219,10 @@ public function addComponentAccess(string $componentName, $accessList): bool {} * ``` * * @param string $roleName - * @param mixed $roleToInherits + * @param $roleToInherits * @return bool */ - public function addInherit(string $roleName, $roleToInherits): bool {} + public function addInherit(string $roleName, $roleToInherits) : bool {} /** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role @@ -254,14 +237,14 @@ public function addInherit(string $roleName, $roleToInherits): bool {} * $acl->addRole("administrator", ["consultant", "consultant2"]); * ``` * - * @param mixed $role - * @param mixed $accessInherits + * @param $role + * @param null $accessInherits * @return bool */ - public function addRole($role, $accessInherits = null): bool {} + public function addRole($role, $accessInherits = null) : bool {} /** - * Allow access to a role on a component. You can use `` as wildcard + * Allow access to a role on a component. You can use `*` as wildcard * * ```php * // Allow access to guests to search on customers @@ -271,20 +254,20 @@ public function addRole($role, $accessInherits = null): bool {} * $acl->allow("guests", "customers", ["search", "create"]); * * // Allow access to any role to browse on products - * $acl->allow("", "products", "browse"); + * $acl->allow("*", "products", "browse"); * * // Allow access to any role to browse on any component - * $acl->allow("", "", "browse"); + * $acl->allow("*", "*", "browse"); * * @param string $roleName * @param string $componentName - * @param mixed $access - * @param mixed $func + * @param $access + * @param null $func */ - public function allow(string $roleName, string $componentName, $access, $func = null) {} + public function allow(string $roleName, string $componentName, $access, $func = null) : void {} /** - * Deny access to a role on a component. You can use `` as wildcard + * Deny access to a role on a component. You can use `*` as wildcard * * ```php * // Deny access to guests to search on customers @@ -294,48 +277,45 @@ public function allow(string $roleName, string $componentName, $access, $func = * $acl->deny("guests", "customers", ["search", "create"]); * * // Deny access to any role to browse on products - * $acl->deny("", "products", "browse"); + * $acl->deny("*", "products", "browse"); * * // Deny access to any role to browse on any component - * $acl->deny("", "", "browse"); + * $acl->deny("*", "*", "browse"); * ``` * * @param string $roleName * @param string $componentName - * @param mixed $access - * @param mixed $func + * @param $access + * @param null $func */ - public function deny(string $roleName, string $componentName, $access, $func = null) {} + public function deny(string $roleName, string $componentName, $access, $func = null) : void {} /** * Removes an access from a component - * * @param string $componentName - * @param mixed $accessList + * @param $accessList */ - public function dropComponentAccess(string $componentName, $accessList) {} + public function dropComponentAccess(string $componentName, $accessList) : void {} /** * Returns the default ACL access level for no arguments provided in * `isAllowed` action if a `func` (callable) exists for `accessKey` - * - * @return int */ - public function getNoArgumentsDefaultAction(): int {} + public function getNoArgumentsDefaultAction() : int {} /** * Return an array with every role registered in the list * - * @return array|\Phalcon\Acl\RoleInterface[] + * @return RoleInterface[] */ - public function getRoles(): array {} + public function getRoles() : array {} /** * Return an array with every component registered in the list * - * @return array|\Phalcon\Acl\ComponentInterface[] + * @return ComponentInterface[] */ - public function getComponents(): array {} + public function getComponents() : array {} /** * Check whether a role is allowed to access an action from a component @@ -345,16 +325,15 @@ public function getComponents(): array {} * $acl->isAllowed("andres", "Products", "create"); * * // Do guests have access to any component to edit? - * $acl->isAllowed("guests", "", "edit"); + * $acl->isAllowed("guests", "*", "edit"); * ``` - * - * @param mixed $roleName - * @param mixed $componentName - * @param string $access - * @param array $parameters + * @param $roleName + * @param $componentName + * @param $access + * @param array|null $parameters * @return bool */ - public function isAllowed($roleName, $componentName, string $access, array $parameters = null): bool {} + public function isAllowed($roleName, $componentName, $access, ?array $parameters = null) : bool {} /** * Check whether role exist in the roles list @@ -362,7 +341,7 @@ public function isAllowed($roleName, $componentName, string $access, array $para * @param string $roleName * @return bool */ - public function isRole(string $roleName): bool {} + public function isRole(string $roleName) : bool {} /** * Check whether component exist in the components list @@ -370,36 +349,14 @@ public function isRole(string $roleName): bool {} * @param string $componentName * @return bool */ - public function isComponent(string $componentName): bool {} + public function isComponent(string $componentName) : bool {} /** - * Sets the default access level (`Phalcon\Enum::ALLOW` or `Phalcon\Enum::DENY`) + * Sets the default access level (`Phalcon\Acl::ALLOW` or `Phalcon\Acl::DENY`) * for no arguments provided in isAllowed action if there exists func for * accessKey * * @param int $defaultAccess */ - public function setNoArgumentsDefaultAction(int $defaultAccess) {} - - /** - * Checks if a role has access to a component - * - * @param string $roleName - * @param string $componentName - * @param mixed $access - * @param mixed $action - * @param mixed $func - */ - private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) {} - - /** - * Check whether a role is allowed to access an action from a component - * - * @param string $roleName - * @param string $componentName - * @param string $access - * @return string|bool - */ - private function canAccess(string $roleName, string $componentName, string $access) {} - + public function setNoArgumentsDefaultAction(int $defaultAccess) : void {} } diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/Adapter.php similarity index 63% rename from src/Phalcon/annotations/adapter/AbstractAdapter.php rename to src/Phalcon/annotations/Adapter.php index e20924a3..2b9a8b55 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/Adapter.php @@ -1,39 +1,42 @@ + * //Traverse annotations * foreach ($classAnnotations as $annotation) { * echo "Name=", $annotation->getName(), PHP_EOL; * } * - * // Check if the annotations has a specific + * //Check if the annotations has a specific * var_dump($classAnnotations->has("Cacheable")); * - * // Get an specific annotation in the collection + * //Get an specific annotation in the collection * $annotation = $classAnnotations->get("Cacheable"); - * ``` + * */ class Collection implements \Iterator, \Countable { - /** - * @var array - */ - protected $annotations; - /** - * @var int - */ - protected $position = 0; + protected $_position = 0; + + + protected $_annotations; /** @@ -37,75 +34,75 @@ class Collection implements \Iterator, \Countable * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) {} + public function __construct($reflectionData = null) {} /** * Returns the number of annotations in the collection * * @return int */ - public function count(): int {} + public function count() {} /** - * Returns the current annotation in the iterator - * - * @return bool|\Phalcon\Annotations\Annotation + * Rewinds the internal iterator */ - public function current() {} + public function rewind() {} /** - * Returns the first annotation that match a name + * Returns the current annotation in the iterator * - * @param string $name - * @return \Phalcon\Annotations\Annotation + * @return bool|\Phalcon\Annotations\Annotation */ - public function get(string $name): Annotation {} + public function current() {} /** - * Returns all the annotations that match a name + * Returns the current position/key in the iterator * - * @param string $name - * @return array|\Phalcon\Annotations\Annotation[] + * @return int */ - public function getAll(string $name): array {} + public function key() {} /** - * Returns the internal annotations as an array - * - * @return array|\Phalcon\Annotations\Annotation[] + * Moves the internal iteration pointer to the next position */ - public function getAnnotations(): array {} + public function next() {} /** - * Check if an annotation exists in a collection + * Check if the current annotation in the iterator is valid * - * @param string $name * @return bool */ - public function has(string $name): bool {} + public function valid() {} /** - * Returns the current position/key in the iterator + * Returns the internal annotations as an array * - * @return int + * @return \Phalcon\Annotations\Annotation[] */ - public function key(): int {} + public function getAnnotations() {} /** - * Moves the internal iteration pointer to the next position + * Returns the first annotation that match a name + * + * @param string $name + * @return \Phalcon\Annotations\Annotation */ - public function next() {} + public function get($name) {} /** - * Rewinds the internal iterator + * Returns all the annotations that match a name + * + * @param string $name + * @return \Phalcon\Annotations\Annotation[] */ - public function rewind() {} + public function getAll($name) {} /** - * Check if the current annotation in the iterator is valid + * Check if an annotation exists in a collection * + * @param string $name * @return bool */ - public function valid(): bool {} + public function has($name) {} } diff --git a/src/Phalcon/annotations/Exception.php b/src/Phalcon/annotations/Exception.php index 8864d544..22e5decf 100644 --- a/src/Phalcon/annotations/Exception.php +++ b/src/Phalcon/annotations/Exception.php @@ -3,9 +3,11 @@ namespace Phalcon\Annotations; /** + * Phalcon\Annotations\Exception + * * Class for exceptions thrown by Phalcon\Annotations */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { } diff --git a/src/Phalcon/annotations/Factory.php b/src/Phalcon/annotations/Factory.php new file mode 100644 index 00000000..63dd2a8a --- /dev/null +++ b/src/Phalcon/annotations/Factory.php @@ -0,0 +1,28 @@ + + * use Phalcon\Annotations\Factory; + * + * $options = [ + * "prefix" => "annotations", + * "lifetime" => "3600", + * "adapter" => "apc", + * ]; + * $annotations = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + +} diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index fdc95680..3208daf9 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -3,18 +3,20 @@ namespace Phalcon\Annotations; /** + * Phalcon\Annotations\Reader + * * Parses docblocks returning an array with the found annotations */ class Reader implements \Phalcon\Annotations\ReaderInterface { /** - * Reads annotations from the class docblocks, its methods and/or properties + * Reads annotations from the class dockblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse(string $className): array {} + public function parse($className) {} /** * Parses a raw doc block returning the annotations found @@ -24,6 +26,6 @@ public function parse(string $className): array {} * @param mixed $line * @return array */ - public static function parseDocBlock(string $docBlock, $file = null, $line = null): array {} + public static function parseDocBlock($docBlock, $file = null, $line = null) {} } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index 5ba4b965..1e6ce946 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -3,27 +3,29 @@ namespace Phalcon\Annotations; /** + * Phalcon\Annotations\Reader + * * Parses docblocks returning an array with the found annotations */ interface ReaderInterface { /** - * Reads annotations from the class docblocks, its methods and/or properties + * Reads annotations from the class dockblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse(string $className): array; + public function parse($className); /** - * Parses a raw docblock returning the annotations found + * Parses a raw doc block returning the annotations found * * @param string $docBlock * @param mixed $file * @param mixed $line * @return array */ - public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; + public static function parseDocBlock($docBlock, $file = null, $line = null); } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index 97072543..6bca75ff 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -3,9 +3,11 @@ namespace Phalcon\Annotations; /** + * Phalcon\Annotations\Reflection + * * Allows to manipulate the annotations reflection in an OO manner * - * ```php + * * use Phalcon\Annotations\Reader; * use Phalcon\Annotations\Reflection; * @@ -18,23 +20,21 @@ * * // Get the annotations in the class docblock * $classAnnotations = $reflection->getClassAnnotations(); - * ``` + * */ class Reflection { - protected $classAnnotations; + protected $_reflectionData; - protected $methodAnnotations; + protected $_classAnnotations; - protected $propertyAnnotations; + protected $_methodAnnotations; - /** - * @var array - */ - protected $reflectionData; + + protected $_propertyAnnotations; /** @@ -42,7 +42,7 @@ class Reflection * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) {} + public function __construct($reflectionData = null) {} /** * Returns the annotations found in the class docblock @@ -54,23 +54,30 @@ public function getClassAnnotations() {} /** * Returns the annotations found in the methods' docblocks * - * @return array|bool|\Phalcon\Annotations\Collection[] + * @return bool|\Phalcon\Annotations\Collection[] */ public function getMethodsAnnotations() {} /** * Returns the annotations found in the properties' docblocks * - * @return array|bool|\Phalcon\Annotations\Collection[] + * @return bool|\Phalcon\Annotations\Collection[] */ public function getPropertiesAnnotations() {} /** - * Returns the raw parsing intermediate definitions used to construct the - * reflection + * Returns the raw parsing intermediate definitions used to construct the reflection * * @return array */ - public function getReflectionData(): array {} + public function getReflectionData() {} + + /** + * Restores the state of a Phalcon\Annotations\Reflection variable export + * + * @param mixed $data + * @return Reflection + */ + public static function __set_state($data) {} } diff --git a/src/Phalcon/annotations/adapter/Apc.php b/src/Phalcon/annotations/adapter/Apc.php new file mode 100644 index 00000000..d508c94b --- /dev/null +++ b/src/Phalcon/annotations/adapter/Apc.php @@ -0,0 +1,51 @@ + + * use Phalcon\Annotations\Adapter\Apc; + * + * $annotations = new Apc(); + * + * + * @see \Phalcon\Annotations\Adapter\Apcu + * @deprecated + */ +class Apc extends \Phalcon\Annotations\Adapter +{ + + protected $_prefix = ''; + + + protected $_ttl = 172800; + + + /** + * Phalcon\Annotations\Adapter\Apc constructor + * + * @param array $options + */ + public function __construct($options = null) {} + + /** + * Reads parsed annotations from APC + * + * @param string $key + * @return bool|\Phalcon\Annotations\Reflection + */ + public function read($key) {} + + /** + * Writes parsed annotations to APC + * + * @param string $key + * @param \Phalcon\Annotations\Reflection $data + */ + public function write($key, \Phalcon\Annotations\Reflection $data) {} + +} diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index 3eedce01..0eabb8a8 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -3,25 +3,23 @@ namespace Phalcon\Annotations\Adapter; /** + * Phalcon\Annotations\Adapter\Apcu + * * Stores the parsed annotations in APCu. This adapter is suitable for production * - * ```php + * * use Phalcon\Annotations\Adapter\Apcu; * * $annotations = new Apcu(); - * ``` + * */ -class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Apcu extends \Phalcon\Annotations\Adapter { - /** - * @var string - */ - protected $prefix = ''; - /** - * @var int - */ - protected $ttl = 172800; + protected $_prefix = ''; + + + protected $_ttl = 172800; /** @@ -29,7 +27,7 @@ class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct($options = null) {} /** * Reads parsed annotations from APCu @@ -37,15 +35,14 @@ public function __construct(array $options = array()) {} * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read($key) {} /** * Writes parsed annotations to APCu * * @param string $key * @param \Phalcon\Annotations\Reflection $data - * @return bool */ - public function write(string $key, \Phalcon\Annotations\Reflection $data): bool {} + public function write($key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Files.php similarity index 55% rename from src/Phalcon/annotations/adapter/Stream.php rename to src/Phalcon/annotations/adapter/Files.php index 1ceda655..fc5be66d 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Files.php @@ -3,32 +3,32 @@ namespace Phalcon\Annotations\Adapter; /** + * Phalcon\Annotations\Adapter\Files + * * Stores the parsed annotations in files. This adapter is suitable for production * - * ```php - * use Phalcon\Annotations\Adapter\Stream; + * + * use Phalcon\Annotations\Adapter\Files; * - * $annotations = new Stream( + * $annotations = new Files( * [ * "annotationsDir" => "app/cache/annotations/", * ] * ); - * ``` + * */ -class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Files extends \Phalcon\Annotations\Adapter { - /** - * @var string - */ - protected $annotationsDir = './'; + + protected $_annotationsDir = './'; /** - * Phalcon\Annotations\Adapter\Stream constructor + * Phalcon\Annotations\Adapter\Files constructor * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct($options = null) {} /** * Reads parsed annotations from files @@ -36,7 +36,7 @@ public function __construct(array $options = array()) {} * @param string $key * @return bool|int|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read($key) {} /** * Writes parsed annotations to files @@ -44,6 +44,6 @@ public function read(string $key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) {} + public function write($key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index dff5586e..421aa079 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -3,15 +3,18 @@ namespace Phalcon\Annotations\Adapter; /** - * Stores the parsed annotations in memory. This adapter is the suitable - * development/testing + * Phalcon\Annotations\Adapter\Memory + * + * Stores the parsed annotations in memory. This adapter is the suitable development/testing */ -class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Memory extends \Phalcon\Annotations\Adapter { /** + * Data + * * @var mixed */ - protected $data; + protected $_data; /** @@ -20,7 +23,7 @@ class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read($key) {} /** * Writes parsed annotations to memory @@ -28,6 +31,6 @@ public function read(string $key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) {} + public function write($key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Xcache.php b/src/Phalcon/annotations/adapter/Xcache.php new file mode 100644 index 00000000..504b2674 --- /dev/null +++ b/src/Phalcon/annotations/adapter/Xcache.php @@ -0,0 +1,33 @@ + + * $annotations = new \Phalcon\Annotations\Adapter\Xcache(); + * + */ +class Xcache extends \Phalcon\Annotations\Adapter +{ + + /** + * Reads parsed annotations from XCache + * + * @param string $key + * @return bool|\Phalcon\Annotations\Reflection + */ + public function read($key) {} + + /** + * Writes parsed annotations to XCache + * + * @param string $key + * @param \Phalcon\Annotations\Reflection $data + */ + public function write($key, \Phalcon\Annotations\Reflection $data) {} + +} diff --git a/src/Phalcon/application/Exception.php b/src/Phalcon/application/Exception.php index 9e2d5a57..f400d62a 100644 --- a/src/Phalcon/application/Exception.php +++ b/src/Phalcon/application/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Application; /** + * Phalcon\Application\Exception + * * Exceptions thrown in Phalcon\Application class will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 431db7dc..16acb66d 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -3,247 +3,176 @@ namespace Phalcon\Assets; /** + * Phalcon\Assets\Asset + * * Represents an asset asset * - * ```php + * * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); - * ``` + * */ -class Asset implements \Phalcon\Assets\AssetInterface +class Asset implements AssetInterface { - /** - * @var array | null - */ - protected $attributes; - - /** - * @var bool - */ - protected $autoVersion = false; - - /** - * @var bool - */ - protected $filter; - - /** - * @var bool - */ - protected $local; - - /** - * @var string - */ - protected $path; - - /** - * @var string - */ - protected $sourcePath; - - /** - * @var string - */ - protected $targetPath; - - /** - * @var string - */ - protected $targetUri; - - /** - * @var string - */ - protected $type; - - /** - * Version of resource - * - * @var string - */ - protected $version; - - - /** - * @return array|null - */ - public function getAttributes(): ?array {} - - /** - * @param bool $autoVersion - */ - public function setAutoVersion(bool $autoVersion) {} - - /** - * @return bool - */ - public function getFilter(): bool {} - - /** - * @return bool - */ - public function getLocal(): bool {} - - /** - * @return string - */ - public function getPath(): string {} - - /** - * @return string - */ - public function getSourcePath(): string {} - - /** - * @return string - */ - public function getTargetPath(): string {} - - /** - * @return string - */ - public function getTargetUri(): string {} - - /** - * @return string - */ - public function getType(): string {} - - /** - * Version of resource - * - * @return string - */ - public function getVersion(): string {} - - /** - * Version of resource - * - * @param string $version - */ - public function setVersion(string $version) {} - - /** - * Phalcon\Assets\Asset constructor - * - * @param string $type - * @param string $path - * @param bool $local - * @param bool $filter - * @param array $attributes - * @param string $version - * @param bool $autoVersion - */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} - - /** - * Gets the asset's key. - * - * @return string - */ - public function getAssetKey(): string {} - - /** - * Returns the content of the asset as an string - * Optionally a base path where the asset is located can be set - * - * @param string $basePath - * @return string - */ - public function getContent(string $basePath = null): string {} - - /** - * Returns the complete location where the asset is located - * - * @param string $basePath - * @return string - */ - public function getRealSourcePath(string $basePath = null): string {} - - /** - * Returns the complete location where the asset must be written - * - * @param string $basePath - * @return string - */ - public function getRealTargetPath(string $basePath = null): string {} - - /** - * Returns the real target uri for the generated HTML - * - * @return string - */ - public function getRealTargetUri(): string {} - - /** - * Checks if resource is using auto version - * - * @return bool - */ - public function isAutoVersion(): bool {} - - /** - * Sets extra HTML attributes - * - * @param array $attributes - * @return AssetInterface - */ - public function setAttributes(array $attributes): AssetInterface {} - - /** - * Sets if the asset must be filtered or not - * - * @param bool $filter - * @return AssetInterface - */ - public function setFilter(bool $filter): AssetInterface {} - - /** - * Sets if the asset is local or external - * - * @param bool $local - * @return AssetInterface - */ - public function setLocal(bool $local): AssetInterface {} - - /** - * Sets the asset's source path - * - * @param string $sourcePath - * @return AssetInterface - */ - public function setSourcePath(string $sourcePath): AssetInterface {} - - /** - * Sets the asset's target path - * - * @param string $targetPath - * @return AssetInterface - */ - public function setTargetPath(string $targetPath): AssetInterface {} - - /** - * Sets a target uri for the generated HTML - * - * @param string $targetUri - * @return AssetInterface - */ - public function setTargetUri(string $targetUri): AssetInterface {} - - /** - * Sets the asset's type - * - * @param string $type - * @return AssetInterface - */ - public function setType(string $type): AssetInterface {} - - /** - * Sets the asset's path - * - * @param string $path - * @return AssetInterface - */ - public function setPath(string $path): AssetInterface {} - + /** + * @var array | null + */ + protected $attributes; + + /** + * @var bool + */ + protected $filter; + + /** + * @var bool + */ + protected $local; + + /** + * @var string + */ + protected $path; + + /** + * @var string + */ + protected $sourcePath; + + /** + * @var string + */ + protected $targetPath; + + /** + * @var string + */ + protected $targetUri; + + /** + * @var string + */ + protected $type; + + /** + * Phalcon\Assets\Asset constructor + */ + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = []) + { + } + + /** + * Sets the asset's type + */ + public function setType(string $type) : AssetInterface + { + } + + /** + * Sets the asset's path + */ + public function setPath(string $path) : AssetInterface + { + } + + /** + * Sets if the asset is local or external + */ + public function setLocal(bool $local) : AssetInterface + { + } + + /** + * Sets if the asset must be filtered or not + */ + public function setFilter(bool $filter) : AssetInterface + { + } + + /** + * Sets extra HTML attributes + */ + public function setAttributes(array $attributes) : AssetInterface + { + } + + /** + * Sets a target uri for the generated HTML + */ + public function setTargetUri(string $targetUri) : AssetInterface + { + } + + /** + * Sets the asset's source path + */ + public function setSourcePath(string $sourcePath) : AssetInterface + { + } + + /** + * Sets the asset's target path + */ + public function setTargetPath(string $targetPath) : AssetInterface + { + } + + /** + * Returns the content of the asset as an string + * Optionally a base path where the asset is located can be set + */ + public function getContent(string $basePath = null) : string + { + } + + /** + * Returns the real target uri for the generated HTML + */ + public function getRealTargetUri() : string + { + } + + /** + * Returns the complete location where the asset is located + */ + public function getRealSourcePath(string $basePath = null) : string + { + } + + /** + * Returns the complete location where the asset must be written + */ + public function getRealTargetPath(string $basePath = null) : string + { + } + + /** + * Gets the asset's key. + */ + public function getAssetKey() : string + { + } + + /** + * Gets the asset's type. + */ + public function getType(): string + { + // TODO: Implement getType() method. + } + + /** + * Gets if the asset must be filtered or not. + */ + public function getFilter(): bool + { + // TODO: Implement getFilter() method. + } + + /** + * Gets extra HTML attributes. + */ + public function getAttributes(): array + { + // TODO: Implement getAttributes() method. + } } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php deleted file mode 100644 index c7bdf739..00000000 --- a/src/Phalcon/assets/AssetInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - + * use Phalcon\Assets\Resource; + * use Phalcon\Assets\Collection; + * + * $collection = new Collection(); + * $resource = new Resource("js", "js/jquery.js"); + * $collection->add($resource); + * $collection->has($resource); // true + * + * + * @param ResourceInterface $resource + * @return bool */ - public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection {} + public function has(ResourceInterface $resource) {} /** - * Adds an inline code to the collection + * Adds a CSS resource to the collection * - * @param \Phalcon\Assets\Inline $code + * @param string $path + * @param mixed $local + * @param bool $filter + * @param mixed $attributes * @return Collection */ - public function addInline(\Phalcon\Assets\Inline $code): Collection {} + public function addCss($path, $local = null, $filter = true, $attributes = null) {} /** * Adds an inline CSS to the collection @@ -218,184 +143,161 @@ public function addInline(\Phalcon\Assets\Inline $code): Collection {} * @param mixed $attributes * @return Collection */ - public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection {} + public function addInlineCss($content, $filter = true, $attributes = null) {} /** - * Adds an inline javascript to the collection + * Adds a javascript resource to the collection * - * @param string $content - * @param bool $filter - * @param mixed $attributes + * @param string $path + * @param boolean $local + * @param boolean $filter + * @param array $attributes * @return Collection */ - public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection {} + public function addJs($path, $local = null, $filter = true, $attributes = null) {} /** - * Adds a javascript asset to the collection + * Adds an inline javascript to the collection * - * @param string $path - * @param mixed $local + * @param string $content * @param bool $filter - * @param array $attributes - * @param string $version - * @param bool $autoVersion + * @param mixed $attributes * @return Collection */ - public function addJs(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection {} + public function addInlineJs($content, $filter = true, $attributes = null) {} /** * Returns the number of elements in the form * * @return int */ - public function count(): int {} + public function count() {} /** - * Returns the current asset in the iterator - * - * @return \Phalcon\Assets\Asset + * Rewinds the internal iterator */ - public function current(): Asset {} + public function rewind() {} /** - * Returns the complete location where the joined/filtered collection must - * be written + * Returns the current resource in the iterator * - * @param string $basePath - * @return string + * @return \Phalcon\Assets\Resource */ - public function getRealTargetPath(string $basePath): string {} + public function current() {} /** - * Checks this the asset is added to the collection. - * - * ```php - * use Phalcon\Assets\Asset; - * use Phalcon\Assets\Collection; - * - * $collection = new Collection(); - * - * $asset = new Asset("js", "js/jquery.js"); - * - * $collection->add($asset); - * $collection->has($asset); // true - * ``` + * Returns the current position/key in the iterator * - * @param AssetInterface $asset - * @return bool + * @return int */ - public function has(AssetInterface $asset): bool {} + public function key() {} /** - * Checks if collection is using auto version - * - * @return bool + * Moves the internal iteration pointer to the next position */ - public function isAutoVersion(): bool {} + public function next() {} /** - * Sets if all filtered assets in the collection must be joined in a single - * result file + * Check if the current element in the iterator is valid * - * @param bool $join - * @return Collection + * @return bool */ - public function join(bool $join): Collection {} + public function valid() {} /** - * Returns the current position/key in the iterator + * Sets the target path of the file for the filtered/join output * - * @return int - */ - public function key(): int {} - - /** - * Moves the internal iteration pointer to the next position + * @param string $targetPath + * @return Collection */ - public function next() {} + public function setTargetPath($targetPath) {} /** - * Rewinds the internal iterator + * Sets a base source path for all the resources in this collection + * + * @param string $sourcePath + * @return Collection */ - public function rewind() {} + public function setSourcePath($sourcePath) {} /** - * Sets extra HTML attributes + * Sets a target uri for the generated HTML * - * @param array $attributes + * @param string $targetUri * @return Collection */ - public function setAttributes(array $attributes): Collection {} + public function setTargetUri($targetUri) {} /** - * Sets an array of filters in the collection + * Sets a common prefix for all the resources * - * @param array $filters + * @param string $prefix * @return Collection */ - public function setFilters(array $filters): Collection {} + public function setPrefix($prefix) {} /** - * Sets if the collection uses local assets by default + * Sets if the collection uses local resources by default * * @param bool $local * @return Collection */ - public function setLocal(bool $local): Collection {} + public function setLocal($local) {} /** - * Sets a common prefix for all the assets + * Sets extra HTML attributes * - * @param string $prefix + * @param array $attributes * @return Collection */ - public function setPrefix(string $prefix): Collection {} + public function setAttributes(array $attributes) {} /** - * Sets the target local + * Sets an array of filters in the collection * - * @param bool $targetLocal + * @param array $filters * @return Collection */ - public function setTargetLocal(bool $targetLocal): Collection {} + public function setFilters(array $filters) {} /** - * Sets the target path of the file for the filtered/join output + * Sets the target local * - * @param string $targetPath + * @param bool $targetLocal * @return Collection */ - public function setTargetPath(string $targetPath): Collection {} + public function setTargetLocal($targetLocal) {} /** - * Sets a target uri for the generated HTML + * Sets if all filtered resources in the collection must be joined in a single result file * - * @param string $targetUri + * @param bool $join * @return Collection */ - public function setTargetUri(string $targetUri): Collection {} + public function join($join) {} /** - * Sets a base source path for all the assets in this collection + * Returns the complete location where the joined/filtered collection must be written * - * @param string $sourcePath - * @return Collection + * @param string $basePath + * @return string */ - public function setSourcePath(string $sourcePath): Collection {} + public function getRealTargetPath($basePath) {} /** - * Check if the current element in the iterator is valid + * Adds a filter to the collection * - * @return bool + * @param \Phalcon\Assets\FilterInterface $filter + * @return Collection */ - public function valid(): bool {} + public function addFilter(\Phalcon\Assets\FilterInterface $filter) {} /** - * Adds a asset or inline-code to the collection + * Adds a resource or inline-code to the collection * - * @param AssetInterface $asset + * @param ResourceInterface $resource * @return bool */ - final protected function addAsset(AssetInterface $asset): bool {} + protected final function addResource(ResourceInterface $resource) {} } diff --git a/src/Phalcon/assets/Exception.php b/src/Phalcon/assets/Exception.php index 49148351..c3104d8d 100644 --- a/src/Phalcon/assets/Exception.php +++ b/src/Phalcon/assets/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Assets; /** + * Phalcon\Assets\Exception + * * Exceptions thrown in Phalcon\Assets will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index e0ba66c2..4d1d4911 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -3,6 +3,8 @@ namespace Phalcon\Assets; /** + * Phalcon\Assets\FilterInterface + * * Interface for custom Phalcon\Assets filters */ interface FilterInterface @@ -14,6 +16,6 @@ interface FilterInterface * @param string $content * @return string */ - public function filter(string $content): string; + public function filter($content); } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index de5d3bef..15b0be65 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -3,94 +3,92 @@ namespace Phalcon\Assets; /** + * Phalcon\Assets\Inline + * * Represents an inline asset * - * ```php + * * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); - * ``` + * */ -class Inline implements \Phalcon\Assets\AssetInterface +class Inline implements \Phalcon\Assets\ResourceInterface { - /** - * @var array | null - */ - protected $attributes; - /** * @var string */ - protected $content; + protected $_type; + + + protected $_content; /** * @var bool */ - protected $filter; + protected $_filter; - /** - * @var string - */ - protected $type; + protected $_attributes; - /** - * @return array|null - */ - public function getAttributes(): ?array {} /** * @return string */ - public function getContent(): string {} + public function getType() {} - /** - * @return bool - */ - public function getFilter(): bool {} + + public function getContent() {} /** - * @return string + * @return bool */ - public function getType(): string {} + public function getFilter() {} /** * Phalcon\Assets\Inline constructor * * @param string $type * @param string $content - * @param bool $filter + * @param boolean $filter * @param array $attributes */ - public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) {} + public function __construct($type, $content, $filter = true, $attributes = null) {} /** - * Gets the asset's key. + * Sets the inline's type * - * @return string + * @param string $type + * @return ResourceInterface + */ + public function setType($type) {} + + /** + * Sets if the resource must be filtered or not + * + * @param bool $filter + * @return ResourceInterface */ - public function getAssetKey(): string {} + public function setFilter($filter) {} /** * Sets extra HTML attributes * * @param array $attributes - * @return AssetInterface + * @return ResourceInterface */ - public function setAttributes(array $attributes): AssetInterface {} + public function setAttributes(array $attributes) {} /** - * Sets if the asset must be filtered or not + * returns extra HTML attributes * - * @param bool $filter - * @return AssetInterface + * @return array|null */ - public function setFilter(bool $filter): AssetInterface {} + public function getAttributes() {} /** - * Sets the inline's type + * Gets the resource's key. * - * @param string $type - * @return AssetInterface + * @return string */ - public function setType(string $type): AssetInterface {} + public function getResourceKey() {} } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index f34300b8..d93e5abb 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -7,110 +7,93 @@ * * Manages collections of CSS/Javascript assets */ -class Manager implements \Phalcon\Di\InjectionAwareInterface +class Manager { - - protected $collections; - - /** - * @var DiInterface - */ - protected $container; - /** * Options configure * * @var array */ - protected $options; + protected $_options; + + + protected $_collections; - /** - * @var bool - */ - protected $implicitOutput = true; + + protected $_implicitOutput = true; /** - * Phalcon\Assets\Manager constructor + * Phalcon\Assets\Manager * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct($options = null) {} /** - * Adds a raw asset to the manager - * - * ```php - * $assets->addAsset( - * new Phalcon\Assets\Asset("css", "css/style.css") - * ); - * ``` + * Sets the manager options * - * @param \Phalcon\Assets\Asset $asset + * @param array $options * @return Manager */ - public function addAsset(\Phalcon\Assets\Asset $asset): Manager {} + public function setOptions(array $options) {} /** - * Adds a asset by its type + * Returns the manager options * - * ```php - * $assets->addAssetByType( - * "css", - * new \Phalcon\Assets\Asset\Css("css/style.css") - * ); - * ``` + * @return array + */ + public function getOptions() {} + + /** + * Sets if the HTML generated must be directly printed or returned * - * @param string $type - * @param \Phalcon\Assets\Asset $asset + * @param bool $implicitOutput * @return Manager */ - public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager {} + public function useImplicitOutput($implicitOutput) {} /** - * Adds a Css asset to the 'css' collection + * Adds a Css resource to the 'css' collection * - * ```php + * * $assets->addCss("css/bootstrap.css"); * $assets->addCss("http://bootstrap.my-cdn.com/style.css", false); - * ``` + * * * @param string $path * @param mixed $local - * @param bool $filter + * @param mixed $filter * @param mixed $attributes - * @param string $version - * @param bool $autoVersion * @return Manager */ - public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} + public function addCss($path, $local = true, $filter = true, $attributes = null) {} /** - * Adds a raw inline code to the manager + * Adds an inline Css to the 'css' collection * - * @param Inline $code + * @param string $content + * @param mixed $filter + * @param mixed $attributes * @return Manager */ - public function addInlineCode(Inline $code): Manager {} + public function addInlineCss($content, $filter = true, $attributes = null) {} /** - * Adds an inline code by its type + * Adds a javascript resource to the 'js' collection * - * @param string $type - * @param Inline $code - * @return Manager - */ - public function addInlineCodeByType(string $type, Inline $code): Manager {} - - /** - * Adds an inline Css to the 'css' collection + * + * $assets->addJs("scripts/jquery.js"); + * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); + * * - * @param string $content + * @param string $path + * @param mixed $local * @param mixed $filter * @param mixed $attributes * @return Manager */ - public function addInlineCss(string $content, $filter = true, $attributes = null): Manager {} + public function addJs($path, $local = true, $filter = true, $attributes = null) {} /** * Adds an inline javascript to the 'js' collection @@ -120,104 +103,107 @@ public function addInlineCss(string $content, $filter = true, $attributes = null * @param mixed $attributes * @return Manager */ - public function addInlineJs(string $content, $filter = true, $attributes = null): Manager {} + public function addInlineJs($content, $filter = true, $attributes = null) {} /** - * Adds a javascript asset to the 'js' collection + * Adds a resource by its type * - * ```php - * $assets->addJs("scripts/jquery.js"); - * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); - * ``` + * + * $assets->addResourceByType("css", + * new \Phalcon\Assets\Resource\Css("css/style.css") + * ); + * * - * @param string $path - * @param mixed $local - * @param bool $filter - * @param mixed $attributes - * @param string $version - * @param bool $autoVersion + * @param string $type + * @param \Phalcon\Assets\Resource $resource * @return Manager */ - public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} + public function addResourceByType($type, \Phalcon\Assets\Resource $resource) {} /** - * Creates/Returns a collection of assets + * Adds an inline code by its type * - * @param string $name - * @return \Phalcon\Assets\Collection + * @param string $type + * @param Inline $code + * @return Manager */ - public function collection(string $name): Collection {} + public function addInlineCodeByType($type, Inline $code) {} /** - * Creates/Returns a collection of assets by type + * Adds a raw resource to the manager * - * @param array $assets - * @param string $type - * @return array + * + * $assets->addResource( + * new Phalcon\Assets\Resource("css", "css/style.css") + * ); + * + * + * @param \Phalcon\Assets\Resource $resource + * @return Manager */ - public function collectionAssetsByType(array $assets, string $type): array {} + public function addResource(\Phalcon\Assets\Resource $resource) {} /** - * Returns true or false if collection exists. + * Adds a raw inline code to the manager * - * ```php - * if ($assets->exists("jsHeader")) { - * // \Phalcon\Assets\Collection - * $collection = $assets->get("jsHeader"); - * } - * ``` + * @param Inline $code + * @return Manager + */ + public function addInlineCode(Inline $code) {} + + /** + * Sets a collection in the Assets Manager + * + * + * $assets->set("js", $collection); + * * * @param string $id - * @return bool + * @param \Phalcon\Assets\Collection $collection + * @return Manager */ - public function exists(string $id): bool {} + public function set($id, \Phalcon\Assets\Collection $collection) {} /** * Returns a collection by its id. * - * ```php + * * $scripts = $assets->get("js"); - * ``` + * * * @param string $id * @return \Phalcon\Assets\Collection */ - public function get(string $id): Collection {} - - /** - * Returns existing collections in the manager - * - * @return array|\Phalcon\Assets\Collection[] - */ - public function getCollections(): array {} + public function get($id) {} /** * Returns the CSS collection of assets * * @return \Phalcon\Assets\Collection */ - public function getCss(): Collection {} + public function getCss() {} /** - * Returns the internal dependency injector + * Returns the CSS collection of assets * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\Assets\Collection */ - public function getDI(): DiInterface {} + public function getJs() {} /** - * Returns the CSS collection of assets + * Creates/Returns a collection of resources * + * @param string $name * @return \Phalcon\Assets\Collection */ - public function getJs(): Collection {} + public function collection($name) {} /** - * Returns the manager options - * + * @param array $resources + * @param string $type * @return array */ - public function getOptions(): array {} + public function collectionResourcesByType(array $resources, $type) {} /** * Traverses a collection calling the callback to generate its HTML @@ -227,15 +213,7 @@ public function getOptions(): array {} * @param string $type * @return string|null */ - public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string {} - - /** - * Prints the HTML for CSS assets - * - * @param string $collectionName - * @return string - */ - public function outputCss(string $collectionName = null): string {} + public function output(\Phalcon\Assets\Collection $collection, $callback, $type) {} /** * Traverses a collection and generate its HTML @@ -244,75 +222,60 @@ public function outputCss(string $collectionName = null): string {} * @param string $type * @return string */ - public function outputInline(\Phalcon\Assets\Collection $collection, $type): string {} + public function outputInline(\Phalcon\Assets\Collection $collection, $type) {} /** - * Prints the HTML for inline CSS + * Prints the HTML for CSS resources * * @param string $collectionName * @return string */ - public function outputInlineCss(string $collectionName = null): string {} + public function outputCss($collectionName = null) {} /** - * Prints the HTML for inline JS + * Prints the HTML for inline CSS * * @param string $collectionName * @return string */ - public function outputInlineJs(string $collectionName = null): string {} + public function outputInlineCss($collectionName = null) {} /** - * Prints the HTML for JS assets + * Prints the HTML for JS resources * * @param string $collectionName * @return string */ - public function outputJs(string $collectionName = null): string {} + public function outputJs($collectionName = null) {} /** - * Sets a collection in the Assets Manager - * - * ```php - * $assets->set("js", $collection); - * ``` - * - * @param string $id - * @param \Phalcon\Assets\Collection $collection - * @return Manager - */ - public function set(string $id, \Phalcon\Assets\Collection $collection): Manager {} - - /** - * Sets the dependency injector + * Prints the HTML for inline JS * - * @param \Phalcon\Di\DiInterface $container + * @param string $collectionName + * @return string */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function outputInlineJs($collectionName = null) {} /** - * Sets the manager options + * Returns existing collections in the manager * - * @param array $options - * @return Manager + * @return \Phalcon\Assets\Collection[] */ - public function setOptions(array $options): Manager {} + public function getCollections() {} /** - * Sets if the HTML generated must be directly printed or returned + * Returns true or false if collection exists. * - * @param bool $implicitOutput - * @return Manager - */ - public function useImplicitOutput(bool $implicitOutput): Manager {} - - /** - * Returns the prefixed path + * + * if ($assets->exists("jsHeader")) { + * // \Phalcon\Assets\Collection + * $collection = $assets->get("jsHeader"); + * } + * * - * @param \Phalcon\Assets\Collection $collection - * @param string $path - * @return string + * @param string $id + * @return bool */ - private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string {} + public function exists($id) {} } diff --git a/src/Phalcon/assets/Resource.php b/src/Phalcon/assets/Resource.php new file mode 100644 index 00000000..82a0acf8 --- /dev/null +++ b/src/Phalcon/assets/Resource.php @@ -0,0 +1,199 @@ + + * $resource = new \Phalcon\Assets\Resource("js", "javascripts/jquery.js"); + * + */ +class Resource implements \Phalcon\Assets\ResourceInterface +{ + /** + * @var string + */ + protected $_type; + + /** + * @var string + */ + protected $_path; + + /** + * @var boolean + */ + protected $_local; + + /** + * @var bool + */ + protected $_filter; + + /** + * @var array | null + */ + protected $_attributes; + + + protected $_sourcePath; + + + protected $_targetPath; + + + protected $_targetUri; + + + /** + * @return string + */ + public function getType() {} + + /** + * @return string + */ + public function getPath() {} + + /** + * @return boolean + */ + public function getLocal() {} + + /** + * @return bool + */ + public function getFilter() {} + + /** + * @return array|null + */ + public function getAttributes() {} + + + public function getSourcePath() {} + + + public function getTargetPath() {} + + + public function getTargetUri() {} + + /** + * Phalcon\Assets\Resource constructor + * + * @param string $type + * @param string $path + * @param boolean $local + * @param boolean $filter + * @param array $attributes + */ + public function __construct($type, $path, $local = true, $filter = true, $attributes = null) {} + + /** + * Sets the resource's type + * + * @param string $type + * @return ResourceInterface + */ + public function setType($type) {} + + /** + * Sets the resource's path + * + * @param string $path + * @return Resource + */ + public function setPath($path) {} + + /** + * Sets if the resource is local or external + * + * @param bool $local + * @return Resource + */ + public function setLocal($local) {} + + /** + * Sets if the resource must be filtered or not + * + * @param bool $filter + * @return ResourceInterface + */ + public function setFilter($filter) {} + + /** + * Sets extra HTML attributes + * + * @param array $attributes + * @return ResourceInterface + */ + public function setAttributes(array $attributes) {} + + /** + * Sets a target uri for the generated HTML + * + * @param string $targetUri + * @return Resource + */ + public function setTargetUri($targetUri) {} + + /** + * Sets the resource's source path + * + * @param string $sourcePath + * @return Resource + */ + public function setSourcePath($sourcePath) {} + + /** + * Sets the resource's target path + * + * @param string $targetPath + * @return Resource + */ + public function setTargetPath($targetPath) {} + + /** + * Returns the content of the resource as an string + * Optionally a base path where the resource is located can be set + * + * @param string $basePath + * @return string + */ + public function getContent($basePath = null) {} + + /** + * Returns the real target uri for the generated HTML + * + * @return string + */ + public function getRealTargetUri() {} + + /** + * Returns the complete location where the resource is located + * + * @param string $basePath + * @return string + */ + public function getRealSourcePath($basePath = null) {} + + /** + * Returns the complete location where the resource must be written + * + * @param string $basePath + * @return string + */ + public function getRealTargetPath($basePath = null) {} + + /** + * Gets the resource's key. + * + * @return string + */ + public function getResourceKey() {} + +} diff --git a/src/Phalcon/assets/ResourceInterface.php b/src/Phalcon/assets/ResourceInterface.php new file mode 100644 index 00000000..c34ad4b7 --- /dev/null +++ b/src/Phalcon/assets/ResourceInterface.php @@ -0,0 +1,65 @@ + + * use Phalcon\Cache\Frontend\Data as DataFrontend; + * use Phalcon\Cache\Multiple; + * use Phalcon\Cache\Backend\Apc as ApcCache; + * use Phalcon\Cache\Backend\Memcache as MemcacheCache; + * use Phalcon\Cache\Backend\File as FileCache; + * + * $ultraFastFrontend = new DataFrontend( + * [ + * "lifetime" => 3600, + * ] + * ); + * + * $fastFrontend = new DataFrontend( + * [ + * "lifetime" => 86400, + * ] + * ); + * + * $slowFrontend = new DataFrontend( + * [ + * "lifetime" => 604800, + * ] + * ); + * + * //Backends are registered from the fastest to the slower + * $cache = new Multiple( + * [ + * new ApcCache( + * $ultraFastFrontend, + * [ + * "prefix" => "cache", + * ] + * ), + * new MemcacheCache( + * $fastFrontend, + * [ + * "prefix" => "cache", + * "host" => "localhost", + * "port" => "11211", + * ] + * ), + * new FileCache( + * $slowFrontend, + * [ + * "prefix" => "cache", + * "cacheDir" => "../app/cache/", + * ] + * ), + * ] + * ); + * + * //Save, saves in every backend + * $cache->save("my-key", $data); + * + */ +class Multiple +{ + + protected $_backends; + + + /** + * Phalcon\Cache\Multiple constructor + * + * @param Phalcon\Cache\BackendInterface[] backends + * @param mixed $backends + */ + public function __construct($backends = null) {} + + /** + * Adds a backend + * + * @param \Phalcon\Cache\BackendInterface $backend + * @return Multiple + */ + public function push(\Phalcon\Cache\BackendInterface $backend) {} + + /** + * Returns a cached content reading the internal backends + * + * @param string|int $keyName + * @param int $lifetime + * @return mixed + */ + public function get($keyName, $lifetime = null) {} + + /** + * Starts every backend + * + * @param string|int $keyName + * @param int $lifetime + */ + public function start($keyName, $lifetime = null) {} + + /** + * Stores cached content into all backends and stops the frontend + * + * @param string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = null) {} + + /** + * Deletes a value from each backend + * + * @param string|int $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Checks if cache exists in at least one backend + * + * @param string|int $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Flush all backend(s) + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php deleted file mode 100644 index 0acab0d8..00000000 --- a/src/Phalcon/cache/adapter/AdapterInterface.php +++ /dev/null @@ -1,11 +0,0 @@ - + * use Phalcon\Cache\Backend\Apc; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * $cache = new Apc( + * $frontCache, + * [ + * "prefix" => "app-data", + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + * + * @see \Phalcon\Cache\Backend\Apcu + * @deprecated + */ +class Apc extends \Phalcon\Cache\Backend +{ + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the APC backend and stops the frontend + * + * @param string|int $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Increment of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Deletes a value from the cache by its key + * + * @param string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it hasn't expired + * + * @param string|int $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Immediately invalidates all existing items. + * + * + * use Phalcon\Cache\Backend\Apc; + * + * $cache = new Apc($frontCache, ["prefix" => "app-data"]); + * + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // 'my-data' and all other used keys are deleted + * $cache->flush(); + * + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Apcu.php b/src/Phalcon/cache/backend/Apcu.php new file mode 100644 index 00000000..66151d00 --- /dev/null +++ b/src/Phalcon/cache/backend/Apcu.php @@ -0,0 +1,126 @@ + + * use Phalcon\Cache\Backend\Apcu; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * $cache = new Apcu( + * $frontCache, + * [ + * "prefix" => "app-data", + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Apcu extends \Phalcon\Cache\Backend +{ + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the APCu backend and stops the frontend + * + * @param string|int $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Increment of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Deletes a value from the cache by its key + * + * @param string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it hasn't expired + * + * @param string|int $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Immediately invalidates all existing items. + * + * + * use Phalcon\Cache\Backend\Apcu; + * + * $cache = new Apcu($frontCache, ["prefix" => "app-data"]); + * + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // 'my-data' and all other used keys are deleted + * $cache->flush(); + * + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Factory.php b/src/Phalcon/cache/backend/Factory.php new file mode 100644 index 00000000..ffb31f6b --- /dev/null +++ b/src/Phalcon/cache/backend/Factory.php @@ -0,0 +1,35 @@ + + * use Phalcon\Cache\Backend\Factory; + * use Phalcon\Cache\Frontend\Data; + * + * $options = [ + * "prefix" => "app-data", + * "frontend" => new Data(), + * "adapter" => "apc", + * ]; + * $backendCache = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return \Phalcon\Cache\BackendInterface + */ + public static function load($config) {} + + /** + * @param string $namespace + * @param mixed $config + */ + protected static function loadClass($namespace, $config) {} + +} diff --git a/src/Phalcon/cache/backend/File.php b/src/Phalcon/cache/backend/File.php new file mode 100644 index 00000000..06837215 --- /dev/null +++ b/src/Phalcon/cache/backend/File.php @@ -0,0 +1,152 @@ + + * use Phalcon\Cache\Backend\File; + * use Phalcon\Cache\Frontend\Output as FrontOutput; + * + * // Cache the file for 2 days + * $frontendOptions = [ + * "lifetime" => 172800, + * ]; + * + * // Create an output cache + * $frontCache = FrontOutput($frontOptions); + * + * // Set the cache directory + * $backendOptions = [ + * "cacheDir" => "../app/cache/", + * ]; + * + * // Create the File backend + * $cache = new File($frontCache, $backendOptions); + * + * $content = $cache->start("my-cache"); + * + * if ($content === null) { + * echo "

", time(), "

"; + * + * $cache->save(); + * } else { + * echo $content; + * } + * + */ +class File extends \Phalcon\Cache\Backend +{ + /** + * Default to false for backwards compatibility + * + * @var boolean + */ + private $_useSafeKey = false; + + + /** + * Phalcon\Cache\Backend\File constructor + * + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param array $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, array $options) {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string|int $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Increment of a given key, by number $value + * + * @param string|int $keyName + * @param int $value + * @return int|null + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of a given key, by number $value + * + * @param string|int $keyName + * @param int $value + * @return int|null + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + + /** + * Return a file-system safe identifier for a given key + * + * @param mixed $key + * @return string + */ + public function getKey($key) {} + + /** + * Set whether to use the safekey or not + * + * @param bool $useSafeKey + * @return File + */ + public function useSafeKey($useSafeKey) {} + +} diff --git a/src/Phalcon/cache/backend/Libmemcached.php b/src/Phalcon/cache/backend/Libmemcached.php new file mode 100644 index 00000000..89bb77a9 --- /dev/null +++ b/src/Phalcon/cache/backend/Libmemcached.php @@ -0,0 +1,162 @@ + + * use Phalcon\Cache\Backend\Libmemcached; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the Cache setting memcached connection options + * $cache = new Libmemcached( + * $frontCache, + * [ + * "servers" => [ + * [ + * "host" => "127.0.0.1", + * "port" => 11211, + * "weight" => 1, + * ], + * ], + * "client" => [ + * \Memcached::OPT_HASH => \Memcached::HASH_MD5, + * \Memcached::OPT_PREFIX_KEY => "prefix.", + * ], + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Libmemcached extends \Phalcon\Cache\Backend +{ + + protected $_memcache = null; + + + /** + * Phalcon\Cache\Backend\Memcache constructor + * + * @param Phalcon\Cache\FrontendInterface frontend + * @param array options + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param mixed $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} + + /** + * Create internal connection to memcached + */ + public function _connect() {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return boolean + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Increment of given $keyName by $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of $keyName by given $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * Memcached does not support flush() per default. If you require flush() support, set $config["statsKey"]. + * All modified keys are stored in "statsKey". Note: statsKey has a negative performance impact. + * + * + * $cache = new \Phalcon\Cache\Backend\Libmemcached( + * $frontCache, + * [ + * "statsKey" => "_PHCM", + * ] + * ); + * + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // 'my-data' and all other used keys are deleted + * $cache->flush(); + * + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Memcache.php b/src/Phalcon/cache/backend/Memcache.php new file mode 100644 index 00000000..446c7c63 --- /dev/null +++ b/src/Phalcon/cache/backend/Memcache.php @@ -0,0 +1,148 @@ + + * use Phalcon\Cache\Backend\Memcache; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the Cache setting memcached connection options + * $cache = new Memcache( + * $frontCache, + * [ + * "host" => "localhost", + * "port" => 11211, + * "persistent" => false, + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Memcache extends \Phalcon\Cache\Backend +{ + + protected $_memcache = null; + + + /** + * Phalcon\Cache\Backend\Memcache constructor + * + * @param Phalcon\Cache\FrontendInterface frontend + * @param array options + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param mixed $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} + + /** + * Create internal connection to memcached + */ + public function _connect() {} + + /** + * Add servers to memcache pool + * + * @param string $host + * @param int $port + * @param bool $persistent + * @return bool + */ + public function addServers($host, $port, $persistent = false) {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return boolean + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Increment of given $keyName by $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of $keyName by given $value + * + * @param string $keyName + * @param int $value + * @return int|bool + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Memory.php b/src/Phalcon/cache/backend/Memory.php new file mode 100644 index 00000000..f4ca7853 --- /dev/null +++ b/src/Phalcon/cache/backend/Memory.php @@ -0,0 +1,123 @@ + + * use Phalcon\Cache\Backend\Memory; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data + * $frontCache = new FrontData(); + * + * $cache = new Memory($frontCache); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Memory extends \Phalcon\Cache\Backend implements \Serializable +{ + + protected $_data; + + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the backend and stops the frontend + * + * @param string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it hasn't expired + * + * @param string|int $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Increment of given $keyName by $value + * + * @param string $keyName + * @param int $value + * @return int|null + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of $keyName by given $value + * + * @param string $keyName + * @param int $value + * @return int|null + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + + /** + * Required for interface \Serializable + * + * @return string + */ + public function serialize() {} + + /** + * Required for interface \Serializable + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/cache/backend/Mongo.php b/src/Phalcon/cache/backend/Mongo.php new file mode 100644 index 00000000..fe92cb29 --- /dev/null +++ b/src/Phalcon/cache/backend/Mongo.php @@ -0,0 +1,146 @@ + + * use Phalcon\Cache\Backend\Mongo; + * use Phalcon\Cache\Frontend\Base64; + * + * // Cache data for 2 days + * $frontCache = new Base64( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create a MongoDB cache + * $cache = new Mongo( + * $frontCache, + * [ + * "server" => "mongodb://localhost", + * "db" => "caches", + * "collection" => "images", + * ] + * ); + * + * // Cache arbitrary data + * $cache->save( + * "my-data", + * file_get_contents("some-image.jpg") + * ); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Mongo extends \Phalcon\Cache\Backend +{ + + protected $_collection = null; + + + /** + * Phalcon\Cache\Backend\Mongo constructor + * + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param array $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} + + /** + * Returns a MongoDb collection based on the backend parameters + * + * @return MongoCollection + */ + protected final function _getCollection() {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * gc + * + * @return collection->remove(...) + */ + public function gc() {} + + /** + * Increment of a given key by $value + * + * @param int|string $keyName + * @param int $value + * @return int|null + */ + public function increment($keyName, $value = 1) {} + + /** + * Decrement of a given key by $value + * + * @param int|string $keyName + * @param int $value + * @return int|null + */ + public function decrement($keyName, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Redis.php b/src/Phalcon/cache/backend/Redis.php new file mode 100644 index 00000000..731df280 --- /dev/null +++ b/src/Phalcon/cache/backend/Redis.php @@ -0,0 +1,147 @@ + + * use Phalcon\Cache\Backend\Redis; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the Cache setting redis connection options + * $cache = new Redis( + * $frontCache, + * [ + * "host" => "localhost", + * "port" => 6379, + * "auth" => "foobared", + * "persistent" => false, + * "index" => 0, + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Redis extends \Phalcon\Cache\Backend +{ + + protected $_redis = null; + + + /** + * Phalcon\Cache\Backend\Redis constructor + * + * @param Phalcon\Cache\FrontendInterface frontend + * @param array options + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param mixed $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} + + /** + * Create internal connection to redis + */ + public function _connect() {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * + * $cache->save("my-key", $data); + * + * // Save data termlessly + * $cache->save("my-key", $data, -1); + * + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return bool + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Increment of given $keyName by $value + * + * @param string $keyName + * @param int $value + * @return int + */ + public function increment($keyName = null, $value = 1) {} + + /** + * Decrement of $keyName by given $value + * + * @param string $keyName + * @param int $value + * @return int + */ + public function decrement($keyName = null, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/backend/Xcache.php b/src/Phalcon/cache/backend/Xcache.php new file mode 100644 index 00000000..f1ef2761 --- /dev/null +++ b/src/Phalcon/cache/backend/Xcache.php @@ -0,0 +1,123 @@ + + * use Phalcon\Cache\Backend\Xcache; + * use Phalcon\Cache\Frontend\Data as FrontData; + * + * // Cache data for 2 days + * $frontCache = new FrontData( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * $cache = new Xcache( + * $frontCache, + * [ + * "prefix" => "app-data", + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Xcache extends \Phalcon\Cache\Backend +{ + + /** + * Phalcon\Cache\Backend\Xcache constructor + * + * @param \Phalcon\Cache\FrontendInterface $frontend + * @param array $options + */ + public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} + + /** + * Returns a cached content + * + * @param string $keyName + * @param int $lifetime + * @return mixed|null + */ + public function get($keyName, $lifetime = null) {} + + /** + * Stores cached content into the file backend and stops the frontend + * + * @param int|string $keyName + * @param string $content + * @param int $lifetime + * @param boolean $stopBuffer + * @return bool + */ + public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} + + /** + * Deletes a value from the cache by its key + * + * @param int|string $keyName + * @return boolean + */ + public function delete($keyName) {} + + /** + * Query the existing cached keys. + * + * + * $cache->save("users-ids", [1, 2, 3]); + * $cache->save("projects-ids", [4, 5, 6]); + * + * var_dump($cache->queryKeys("users")); // ["users-ids"] + * + * + * @param string $prefix + * @return array + */ + public function queryKeys($prefix = null) {} + + /** + * Checks if cache exists and it isn't expired + * + * @param string $keyName + * @param int $lifetime + * @return bool + */ + public function exists($keyName = null, $lifetime = null) {} + + /** + * Atomic increment of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int + */ + public function increment($keyName, $value = 1) {} + + /** + * Atomic decrement of a given key, by number $value + * + * @param string $keyName + * @param int $value + * @return int + */ + public function decrement($keyName, $value = 1) {} + + /** + * Immediately invalidates all existing items. + * + * @return bool + */ + public function flush() {} + +} diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php deleted file mode 100644 index cd483e0a..00000000 --- a/src/Phalcon/cache/exception/Exception.php +++ /dev/null @@ -1,11 +0,0 @@ - + * 172800, + * ] + * ); + * + * //Create a MongoDB cache + * $cache = new \Phalcon\Cache\Backend\Mongo( + * $frontCache, + * [ + * "server" => "mongodb://localhost", + * "db" => "caches", + * "collection" => "images", + * ] + * ); + * + * $cacheKey = "some-image.jpg.cache"; + * + * // Try to get cached image + * $image = $cache->get($cacheKey); + * + * if ($image === null) { + * // Store the image in the cache + * $cache->save( + * $cacheKey, + * file_get_contents("tmp-dir/some-image.jpg") + * ); + * } + * + * header("Content-Type: image/jpeg"); + * + * echo $image; + * + */ +class Base64 implements \Phalcon\Cache\FrontendInterface +{ + + protected $_frontendOptions; + + + /** + * Phalcon\Cache\Frontend\Base64 constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Actually, does nothing in this adapter + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + * @return string + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/Data.php b/src/Phalcon/cache/frontend/Data.php new file mode 100644 index 00000000..4ea0ef05 --- /dev/null +++ b/src/Phalcon/cache/frontend/Data.php @@ -0,0 +1,114 @@ + + * use Phalcon\Cache\Backend\File; + * use Phalcon\Cache\Frontend\Data; + * + * // Cache the files for 2 days using a Data frontend + * $frontCache = new Data( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the component that will cache "Data" to a 'File' backend + * // Set the cache file directory - important to keep the '/' at the end of + * // of the value for the folder + * $cache = new File( + * $frontCache, + * [ + * "cacheDir" => "../app/cache/", + * ] + * ); + * + * $cacheKey = "robots_order_id.cache"; + * + * // Try to get cached records + * $robots = $cache->get($cacheKey); + * + * if ($robots === null) { + * // $robots is null due to cache expiration or data does not exist + * // Make the database call and populate the variable + * $robots = Robots::find( + * [ + * "order" => "id", + * ] + * ); + * + * // Store it in the cache + * $cache->save($cacheKey, $robots); + * } + * + * // Use $robots :) + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + */ +class Data implements \Phalcon\Cache\FrontendInterface +{ + + protected $_frontendOptions; + + + /** + * Phalcon\Cache\Frontend\Data constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Actually, does nothing + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/Factory.php b/src/Phalcon/cache/frontend/Factory.php new file mode 100644 index 00000000..61fd18e3 --- /dev/null +++ b/src/Phalcon/cache/frontend/Factory.php @@ -0,0 +1,33 @@ + + * use Phalcon\Cache\Frontend\Factory; + * + * $options = [ + * "lifetime" => 172800, + * "adapter" => "data", + * ]; + * $frontendCache = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return \Phalcon\Cache\FrontendInterface + */ + public static function load($config) {} + + /** + * @param string $namespace + * @param mixed $config + */ + protected static function loadClass($namespace, $config) {} + +} diff --git a/src/Phalcon/cache/frontend/Igbinary.php b/src/Phalcon/cache/frontend/Igbinary.php new file mode 100644 index 00000000..3b366e4f --- /dev/null +++ b/src/Phalcon/cache/frontend/Igbinary.php @@ -0,0 +1,109 @@ + + * // Cache the files for 2 days using Igbinary frontend + * $frontCache = new \Phalcon\Cache\Frontend\Igbinary( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the component that will cache "Igbinary" to a "File" backend + * // Set the cache file directory - important to keep the "/" at the end of + * // of the value for the folder + * $cache = new \Phalcon\Cache\Backend\File( + * $frontCache, + * [ + * "cacheDir" => "../app/cache/", + * ] + * ); + * + * $cacheKey = "robots_order_id.cache"; + * + * // Try to get cached records + * $robots = $cache->get($cacheKey); + * + * if ($robots === null) { + * // $robots is null due to cache expiration or data do not exist + * // Make the database call and populate the variable + * $robots = Robots::find( + * [ + * "order" => "id", + * ] + * ); + * + * // Store it in the cache + * $cache->save($cacheKey, $robots); + * } + * + * // Use $robots :) + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + */ +class Igbinary extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface +{ + + /** + * Phalcon\Cache\Frontend\Data constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Actually, does nothing + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + * @return string + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/Json.php b/src/Phalcon/cache/frontend/Json.php new file mode 100644 index 00000000..05bf6fc5 --- /dev/null +++ b/src/Phalcon/cache/frontend/Json.php @@ -0,0 +1,102 @@ + + * 172800, + * ] + * ); + * + * // Create the Cache setting memcached connection options + * $cache = new \Phalcon\Cache\Backend\Memcache( + * $frontCache, + * [ + * "host" => "localhost", + * "port" => 11211, + * "persistent" => false, + * ] + * ); + * + * // Cache arbitrary data + * $cache->save("my-data", [1, 2, 3, 4, 5]); + * + * // Get data + * $data = $cache->get("my-data"); + * + */ +class Json implements \Phalcon\Cache\FrontendInterface +{ + + protected $_frontendOptions; + + + /** + * Phalcon\Cache\Frontend\Base64 constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Actually, does nothing + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + * @return string + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/Msgpack.php b/src/Phalcon/cache/frontend/Msgpack.php new file mode 100644 index 00000000..66bb57fe --- /dev/null +++ b/src/Phalcon/cache/frontend/Msgpack.php @@ -0,0 +1,115 @@ + + * use Phalcon\Cache\Backend\File; + * use Phalcon\Cache\Frontend\Msgpack; + * + * // Cache the files for 2 days using Msgpack frontend + * $frontCache = new Msgpack( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the component that will cache "Msgpack" to a "File" backend + * // Set the cache file directory - important to keep the "/" at the end of + * // of the value for the folder + * $cache = new File( + * $frontCache, + * [ + * "cacheDir" => "../app/cache/", + * ] + * ); + * + * $cacheKey = "robots_order_id.cache"; + * + * // Try to get cached records + * $robots = $cache->get($cacheKey); + * + * if ($robots === null) { + * // $robots is null due to cache expiration or data do not exist + * // Make the database call and populate the variable + * $robots = Robots::find( + * [ + * "order" => "id", + * ] + * ); + * + * // Store it in the cache + * $cache->save($cacheKey, $robots); + * } + * + * // Use $robots + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + */ +class Msgpack extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface +{ + + /** + * Phalcon\Cache\Frontend\Msgpack constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Actually, does nothing + */ + public function start() {} + + /** + * Returns output cached content + * + * @return null + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + * @return string + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/None.php b/src/Phalcon/cache/frontend/None.php new file mode 100644 index 00000000..acce1cd2 --- /dev/null +++ b/src/Phalcon/cache/frontend/None.php @@ -0,0 +1,98 @@ + + * "localhost", + * "port" => "11211", + * ] + * ); + * + * $cacheKey = "robots_order_id.cache"; + * + * // This Frontend always return the data as it's returned by the backend + * $robots = $cache->get($cacheKey); + * + * if ($robots === null) { + * // This cache doesn't perform any expiration checking, so the data is always expired + * // Make the database call and populate the variable + * $robots = Robots::find( + * [ + * "order" => "id", + * ] + * ); + * + * $cache->save($cacheKey, $robots); + * } + * + * // Use $robots :) + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + */ +class None implements \Phalcon\Cache\FrontendInterface +{ + + /** + * Returns cache lifetime, always one second expiring content + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output, always false + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Prepare data to be stored + * + * @param mixed $data + */ + public function beforeStore($data) {} + + /** + * Prepares data to be retrieved to user + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cache/frontend/Output.php b/src/Phalcon/cache/frontend/Output.php new file mode 100644 index 00000000..eddcb223 --- /dev/null +++ b/src/Phalcon/cache/frontend/Output.php @@ -0,0 +1,120 @@ + + * use Phalcon\Tag; + * use Phalcon\Cache\Backend\File; + * use Phalcon\Cache\Frontend\Output; + * + * // Create an Output frontend. Cache the files for 2 days + * $frontCache = new Output( + * [ + * "lifetime" => 172800, + * ] + * ); + * + * // Create the component that will cache from the "Output" to a "File" backend + * // Set the cache file directory - it's important to keep the "/" at the end of + * // the value for the folder + * $cache = new File( + * $frontCache, + * [ + * "cacheDir" => "../app/cache/", + * ] + * ); + * + * // Get/Set the cache file to ../app/cache/my-cache.html + * $content = $cache->start("my-cache.html"); + * + * // If $content is null then the content will be generated for the cache + * if (null === $content) { + * // Print date and time + * echo date("r"); + * + * // Generate a link to the sign-up action + * echo Tag::linkTo( + * [ + * "user/signup", + * "Sign Up", + * "class" => "signup-button", + * ] + * ); + * + * // Store the output into the cache file + * $cache->save(); + * } else { + * // Echo the cached output + * echo $content; + * } + * + */ +class Output implements \Phalcon\Cache\FrontendInterface +{ + + protected $_buffering = false; + + + protected $_frontendOptions; + + + /** + * Phalcon\Cache\Frontend\Output constructor + * + * @param array $frontendOptions + */ + public function __construct($frontendOptions = null) {} + + /** + * Returns the cache lifetime + * + * @return int + */ + public function getLifetime() {} + + /** + * Check whether if frontend is buffering output + * + * @return bool + */ + public function isBuffering() {} + + /** + * Starts output frontend. Currently, does nothing + */ + public function start() {} + + /** + * Returns output cached content + * + * @return string + */ + public function getContent() {} + + /** + * Stops output frontend + */ + public function stop() {} + + /** + * Serializes data before storing them + * + * @param mixed $data + * @return string + */ + public function beforeStore($data) {} + + /** + * Unserializes data after retrieval + * + * @param mixed $data + * @return mixed + */ + public function afterRetrieve($data) {} + +} diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 2da7a60c..01123b6d 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -3,20 +3,37 @@ namespace Phalcon\Cli; /** + * Phalcon\Cli\Console + * * This component allows to create CLI applications using Phalcon */ -class Console extends \Phalcon\Application\AbstractApplication +class Console extends \Phalcon\Application { - /** - * @var array - */ - protected $arguments = array(); + + protected $_arguments = array(); + + + protected $_options = array(); + /** - * @var array + * Merge modules with the existing ones + * + * + * $application->addModules( + * [ + * "admin" => [ + * "className" => "Multiple\\Admin\\Module", + * "path" => "../apps/admin/Module.php", + * ], + * ] + * ); + * + * + * @param array $modules + * @deprecated */ - protected $options = array(); - + public function addModules(array $modules) {} /** * Handle the whole command-line tasks @@ -33,6 +50,6 @@ public function handle(array $arguments = null) {} * @param bool $shift * @return Console */ - public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console {} + public function setArgument(array $arguments = null, $str = true, $shift = true) {} } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index 3771ce22..28f105ea 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -3,18 +3,18 @@ namespace Phalcon\Cli; /** - * Dispatching is the process of taking the command-line arguments, extracting - * the module name, task name, action name, and optional parameters contained in - * it, and then instantiating a task and calling an action on it. + * Phalcon\Cli\Dispatcher * - * ```php + * Dispatching is the process of taking the command-line arguments, extracting the module name, + * task name, action name, and optional parameters contained in it, and then + * instantiating a task and calling an action on it. + * + * * use Phalcon\Di; * use Phalcon\Cli\Dispatcher; * * $di = new Di(); - * * $dispatcher = new Dispatcher(); - * * $dispatcher->setDi($di); * * $dispatcher->setTaskName("posts"); @@ -22,100 +22,79 @@ * $dispatcher->setParams([]); * * $handle = $dispatcher->dispatch(); - * ``` + * */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Cli\DispatcherInterface { - /** - * @var string - */ - protected $defaultHandler = 'main'; - /** - * @var string - */ - protected $defaultAction = 'main'; + protected $_handlerSuffix = 'Task'; - /** - * @var string - */ - protected $handlerSuffix = 'Task'; - /** - * @var array - */ - protected $options = array(); + protected $_defaultHandler = 'main'; - /** - * Calls the action method. - * - * @param mixed $handler - * @param string $actionMethod - * @param array $params - * @return mixed - */ - public function callActionMethod($handler, string $actionMethod, array $params = array()) {} + protected $_defaultAction = 'main'; + + + protected $_options = array(); + /** - * Returns the active task in the dispatcher + * Sets the default task suffix * - * @return TaskInterface + * @param string $taskSuffix */ - public function getActiveTask(): TaskInterface {} + public function setTaskSuffix($taskSuffix) {} /** - * Returns the latest dispatched controller + * Sets the default task name * - * @return TaskInterface + * @param string $taskName */ - public function getLastTask(): TaskInterface {} + public function setDefaultTask($taskName) {} /** - * Gets an option by its name or numeric index + * Sets the task name to be dispatched * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @param string $taskName */ - public function getOption($option, $filters = null, $defaultValue = null) {} + public function setTaskName($taskName) {} /** - * Get dispatched options + * Gets last dispatched task name * - * @return array + * @return string */ - public function getOptions(): array {} + public function getTaskName() {} /** - * Gets last dispatched task name + * Throws an internal exception * - * @return string + * @param string $message + * @param int $exceptionCode */ - public function getTaskName(): string {} + protected function _throwDispatchException($message, $exceptionCode = 0) {} /** - * Gets the default task suffix + * Handles a user exception * - * @return string + * @param \Exception $exception */ - public function getTaskSuffix(): string {} + protected function _handleException(\Exception $exception) {} /** - * Check if an option exists + * Returns the latest dispatched controller * - * @param mixed $option - * @return bool + * @return TaskInterface */ - public function hasOption($option): bool {} + public function getLastTask() {} /** - * Sets the default task name + * Returns the active task in the dispatcher * - * @param string $taskName + * @return TaskInterface */ - public function setDefaultTask(string $taskName) {} + public function getActiveTask() {} /** * Set the options to be dispatched @@ -125,32 +104,38 @@ public function setDefaultTask(string $taskName) {} public function setOptions(array $options) {} /** - * Sets the task name to be dispatched + * Get dispatched options * - * @param string $taskName + * @return array */ - public function setTaskName(string $taskName) {} + public function getOptions() {} /** - * Sets the default task suffix + * Gets an option by its name or numeric index * - * @param string $taskSuffix + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setTaskSuffix(string $taskSuffix) {} + public function getOption($option, $filters = null, $defaultValue = null) {} /** - * Handles a user exception + * Check if an option exists * - * @param \Exception $exception + * @param mixed $option + * @return bool */ - protected function handleException(\Exception $exception) {} + public function hasOption($option) {} /** - * Throws an internal exception + * Calls the action method. * - * @param string $message - * @param int $exceptionCode + * @param mixed $handler + * @param string $actionMethod + * @param array $params + * @return mixed */ - protected function throwDispatchException(string $message, int $exceptionCode = 0) {} + public function callActionMethod($handler, $actionMethod, array $params = array()) {} } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index eed77c38..99a31ecc 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -3,72 +3,53 @@ namespace Phalcon\Cli; /** + * Phalcon\Cli\DispatcherInterface + * * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends \Phalcon\DispatcherInterface { /** - * Returns the active task in the dispatcher + * Sets the default task suffix * - * @return TaskInterface + * @param string $taskSuffix */ - public function getActiveTask(): TaskInterface; + public function setTaskSuffix($taskSuffix); /** - * Returns the latest dispatched controller + * Sets the default task name * - * @return TaskInterface + * @param string $taskName */ - public function getLastTask(): TaskInterface; + public function setDefaultTask($taskName); /** - * Get dispatched options + * Sets the task name to be dispatched * - * @return array + * @param string $taskName */ - public function getOptions(): array; + public function setTaskName($taskName); /** * Gets last dispatched task name * * @return string */ - public function getTaskName(): string; - - /** - * Gets default task suffix - * - * @return string - */ - public function getTaskSuffix(): string; + public function getTaskName(); /** - * Sets the default task name - * - * @param string $taskName - */ - public function setDefaultTask(string $taskName); - - /** - * Set the options to be dispatched - * - * @param array $options - */ - public function setOptions(array $options); - - /** - * Sets the task name to be dispatched + * Returns the latest dispatched controller * - * @param string $taskName + * @return TaskInterface */ - public function setTaskName(string $taskName); + public function getLastTask(); /** - * Sets the default task suffix + * Returns the active task in the dispatcher * - * @param string $taskSuffix + * @return TaskInterface */ - public function setTaskSuffix(string $taskSuffix); + public function getActiveTask(); } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 541e64b1..09c0cf0c 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -3,12 +3,14 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Router is the standard framework router. Routing is the process - * of taking a command-line arguments and decomposing it into parameters to - * determine which module, task, and action of that task should receive the - * request. + * Phalcon\Cli\Router * - * ```php + *

Phalcon\Cli\Router is the standard framework router. Routing is the + * process of taking a command-line arguments and + * decomposing it into parameters to determine which module, task, and + * action of that task should receive the request

+ * + * * $router = new \Phalcon\Cli\Router(); * * $router->handle( @@ -20,52 +22,48 @@ * ); * * echo $router->getTaskName(); - * ``` + * */ class Router implements \Phalcon\Di\InjectionAwareInterface { - protected $action; + protected $_dependencyInjector; - protected $container; + protected $_module; - protected $defaultAction = null; + protected $_task; - protected $defaultModule = null; + protected $_action; - /** - * @var array - */ - protected $defaultParams = array(); + protected $_params = array(); - protected $defaultTask = null; + protected $_defaultModule = null; - protected $matchedRoute; + protected $_defaultTask = null; - protected $matches; + protected $_defaultAction = null; - protected $module; - /** - * @var array - */ - protected $params = array(); + protected $_defaultParams = array(); + + + protected $_routes; - protected $routes; + protected $_matchedRoute; - protected $task; + protected $_matches; - protected $wasMatched = false; + protected $_wasMatched = false; /** @@ -73,152 +71,151 @@ class Router implements \Phalcon\Di\InjectionAwareInterface * * @param bool $defaultRoutes */ - public function __construct(bool $defaultRoutes = true) {} + public function __construct($defaultRoutes = true) {} /** - * Adds a route to the router - * - * ```php - * $router->add("/about", "About::main"); - * ``` + * Sets the dependency injector * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @param \Phalcon\DiInterface $dependencyInjector */ - public function add(string $pattern, $paths = null): RouteInterface {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Returns processed action name + * Returns the internal dependency injector * - * @return string + * @return \Phalcon\DiInterface */ - public function getActionName(): string {} + public function getDI() {} /** - * Returns the internal dependency injector + * Sets the name of the default module * - * @return \Phalcon\Di\DiInterface + * @param string $moduleName */ - public function getDI(): DiInterface {} + public function setDefaultModule($moduleName) {} /** - * Returns the route that matches the handled URI + * Sets the default controller name * - * @return RouteInterface + * @param string $taskName */ - public function getMatchedRoute(): RouteInterface {} + public function setDefaultTask($taskName) {} /** - * Returns the sub expressions in the regular expression matched + * Sets the default action name * - * @return array + * @param string $actionName */ - public function getMatches(): array {} + public function setDefaultAction($actionName) {} /** - * Returns processed module name + * Sets an array of default paths. If a route is missing a path the router will use the defined here + * This method must not be used to set a 404 route * - * @return string + * + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * + * + * @param array $defaults + * @return Router */ - public function getModuleName(): string {} + public function setDefaults(array $defaults) {} /** - * Returns processed extra params + * Handles routing information received from command-line arguments * - * @return array + * @param array $arguments */ - public function getParams(): array {} + public function handle($arguments = null) {} /** - * Returns a route object by its id + * Adds a route to the router * - * @param int $id - * @return bool|RouteInterface + * + * $router->add("/about", "About::main"); + * + * + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function getRouteById($id) {} + public function add($pattern, $paths = null) {} /** - * Returns a route object by its name + * Returns processed module name * - * @param string $name - * @return bool|RouteInterface + * @return string */ - public function getRouteByName(string $name) {} + public function getModuleName() {} /** - * Returns all the routes defined in the router + * Returns processed task name * - * @return array|\Phalcon\Cli\Router\Route[] + * @return string */ - public function getRoutes(): array {} + public function getTaskName() {} /** - * Returns processed task name + * Returns processed action name * * @return string */ - public function getTaskName(): string {} + public function getActionName() {} /** - * Handles routing information received from command-line arguments + * Returns processed extra params * - * @param array $arguments + * @return array */ - public function handle($arguments = null) {} + public function getParams() {} /** - * Sets the default action name + * Returns the route that matches the handled URI * - * @param string $actionName + * @return RouteInterface */ - public function setDefaultAction(string $actionName) {} + public function getMatchedRoute() {} /** - * Sets the name of the default module + * Returns the sub expressions in the regular expression matched * - * @param string $moduleName + * @return array */ - public function setDefaultModule(string $moduleName) {} + public function getMatches() {} /** - * Sets an array of default paths. If a route is missing a path the router - * will use the defined here. This method must not be used to set a 404 - * route - * - * ```php - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * ``` + * Checks if the router matches any of the defined routes * - * @param array $defaults - * @return Router + * @return bool */ - public function setDefaults(array $defaults): Router {} + public function wasMatched() {} /** - * Sets the default controller name + * Returns all the routes defined in the router * - * @param string $taskName + * @return \Phalcon\Cli\Router\Route[] */ - public function setDefaultTask(string $taskName) {} + public function getRoutes() {} /** - * Sets the dependency injector + * Returns a route object by its id * - * @param \Phalcon\Di\DiInterface $container + * @param int $id + * @return bool|RouteInterface */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getRouteById($id) {} /** - * Checks if the router matches any of the defined routes + * Returns a route object by its name * - * @return bool + * @param string $name + * @return bool|RouteInterface */ - public function wasMatched(): bool {} + public function getRouteByName($name) {} } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 7f3d4abe..1d28c053 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -3,125 +3,127 @@ namespace Phalcon\Cli; /** + * Phalcon\Cli\RouterInterface + * * Interface for Phalcon\Cli\Router */ interface RouterInterface { /** - * Adds a route to the router on any HTTP method + * Sets the name of the default module * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Cli\Router\RouteInterface + * @param string $moduleName */ - public function add(string $pattern, $paths = null): RouteInterface; + public function setDefaultModule($moduleName); /** - * Returns processed action name + * Sets the default task name * - * @return string + * @param string $taskName */ - public function getActionName(): string; + public function setDefaultTask($taskName); /** - * Returns the route that matches the handled URI + * Sets the default action name * - * @return \Phalcon\Cli\Router\RouteInterface + * @param string $actionName */ - public function getMatchedRoute(): RouteInterface; + public function setDefaultAction($actionName); /** - * Return the sub expressions in the regular expression matched + * Sets an array of default paths * - * @return array + * @param array $defaults */ - public function getMatches(): array; + public function setDefaults(array $defaults); /** - * Returns processed module name + * Handles routing information received from the rewrite engine * - * @return string + * @param array $arguments */ - public function getModuleName(): string; + public function handle($arguments = null); /** - * Returns processed extra params + * Adds a route to the router on any HTTP method * - * @return array + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Cli\Router\RouteInterface */ - public function getParams(): array; + public function add($pattern, $paths = null); /** - * Returns a route object by its id + * Returns processed module name * - * @param mixed $id - * @return \Phalcon\Cli\Router\RouteInterface + * @return string */ - public function getRouteById($id): RouteInterface; + public function getModuleName(); /** - * Returns a route object by its name + * Returns processed task name * - * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return string */ - public function getRouteByName(string $name): RouteInterface; + public function getTaskName(); /** - * Return all the routes defined in the router + * Returns processed action name * - * @return array|\Phalcon\Cli\Router\RouteInterface[] + * @return string */ - public function getRoutes(): array; + public function getActionName(); /** - * Returns processed task name + * Returns processed extra params * - * @return string + * @return array */ - public function getTaskName(): string; + public function getParams(); /** - * Handles routing information received from the rewrite engine + * Returns the route that matches the handled URI * - * @param array $arguments + * @return \Phalcon\Cli\Router\RouteInterface */ - public function handle($arguments = null); + public function getMatchedRoute(); /** - * Sets the default action name + * Return the sub expressions in the regular expression matched * - * @param string $actionName + * @return array */ - public function setDefaultAction(string $actionName); + public function getMatches(); /** - * Sets the name of the default module + * Check if the router matches any of the defined routes * - * @param string $moduleName + * @return bool */ - public function setDefaultModule(string $moduleName); + public function wasMatched(); /** - * Sets an array of default paths + * Return all the routes defined in the router * - * @param array $defaults + * @return \Phalcon\Cli\Router\RouteInterface[] */ - public function setDefaults(array $defaults); + public function getRoutes(); /** - * Sets the default task name + * Returns a route object by its id * - * @param string $taskName + * @param mixed $id + * @return \Phalcon\Cli\Router\RouteInterface */ - public function setDefaultTask(string $taskName); + public function getRouteById($id); /** - * Check if the router matches any of the defined routes + * Returns a route object by its name * - * @return bool + * @param string $name + * @return \Phalcon\Cli\Router\RouteInterface */ - public function wasMatched(): bool; + public function getRouteByName($name); } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 41ba3342..038a6603 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -3,14 +3,14 @@ namespace Phalcon\Cli; /** - * Every command-line task should extend this class that encapsulates all the - * task functionality + * Phalcon\Cli\Task * - * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, - * or anything that you want. The Task class should at least have a "mainAction" - * method. + * Every command-line task should extend this class that encapsulates all the task functionality * - * ```php + * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that you want. + * The Task class should at least have a "mainAction" method + * + * * class HelloTask extends \Phalcon\Cli\Task * { * // This action will be executed by default @@ -24,7 +24,7 @@ * * } * } - * ``` + * */ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface { @@ -32,6 +32,6 @@ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface /** * Phalcon\Cli\Task constructor */ - final public function __construct() {} + public final function __construct() {} } diff --git a/src/Phalcon/cli/TaskInterface.php b/src/Phalcon/cli/TaskInterface.php index 9ceb7d69..2b561c82 100644 --- a/src/Phalcon/cli/TaskInterface.php +++ b/src/Phalcon/cli/TaskInterface.php @@ -3,6 +3,8 @@ namespace Phalcon\Cli; /** + * Phalcon\Cli\TaskInterface + * * Interface for task handlers */ interface TaskInterface diff --git a/src/Phalcon/cli/console/Exception.php b/src/Phalcon/cli/console/Exception.php index 09649fa2..602a4879 100644 --- a/src/Phalcon/cli/console/Exception.php +++ b/src/Phalcon/cli/console/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Cli\Console; /** + * Phalcon\Cli\Console\Exception + * * Exceptions thrown in Phalcon\Cli\Console will use this class */ class Exception extends \Phalcon\Application\Exception diff --git a/src/Phalcon/cli/dispatcher/Exception.php b/src/Phalcon/cli/dispatcher/Exception.php index d03f5450..416f26a6 100644 --- a/src/Phalcon/cli/dispatcher/Exception.php +++ b/src/Phalcon/cli/dispatcher/Exception.php @@ -3,9 +3,11 @@ namespace Phalcon\Cli\Dispatcher; /** + * Phalcon\Cli\Dispatcher\Exception + * * Exceptions thrown in Phalcon\Cli\Dispatcher will use this class */ -class Exception extends \Phalcon\Dispatcher\Exception +class Exception extends \Phalcon\Exception { } diff --git a/src/Phalcon/cli/router/Exception.php b/src/Phalcon/cli/router/Exception.php index 06f5a678..6b6d0485 100644 --- a/src/Phalcon/cli/router/Exception.php +++ b/src/Phalcon/cli/router/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Cli\Router; /** + * Phalcon\Cli\Router\Exception + * * Exceptions thrown in Phalcon\Cli\Router will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 5e0e0997..5b5e8ca6 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -3,6 +3,8 @@ namespace Phalcon\Cli\Router; /** + * Phalcon\Cli\Router\Route + * * This class represents every route added to the router */ class Route @@ -11,166 +13,159 @@ class Route const DEFAULT_DELIMITER = ' '; - protected $beforeMatch; + protected $_pattern; - protected $compiledPattern; + protected $_compiledPattern; - protected $converters; + protected $_paths; - protected $delimiter; + protected $_converters; - static protected $delimiterPath = self::DEFAULT_DELIMITER; + protected $_id; - protected $description; + protected $_name; - protected $id; + protected $_beforeMatch; - protected $name; + protected $_delimiter; - protected $paths; + static protected $_uniqueId; - protected $pattern; + static protected $_delimiterPath; - static protected $uniqueId = 0; - - - /** - * @param string $pattern - * @param array|string $paths - */ - public function __construct(string $pattern, $paths = null) {} - /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Phalcon\Cli\Router\Route constructor * - * @param callback $callback - * @return RouteInterface + * @param string $pattern + * @param array $paths */ - public function beforeMatch($callback): RouteInterface {} + public function __construct($pattern, $paths = null) {} /** - * Replaces placeholders from pattern returning a valid PCRE regular - * expression + * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string $pattern * @return string */ - public function compilePattern(string $pattern): string {} + public function compilePattern($pattern) {} /** - * Adds a converter to perform an additional transformation for certain - * parameter + * Extracts parameters from a string * - * @param string $name - * @param callable $converter - * @return RouteInterface + * @param string $pattern + * @return array|boolean */ - public function convert(string $name, $converter): RouteInterface {} + public function extractNamedParams($pattern) {} /** - * Set the routing delimiter + * Reconfigure the route adding a new pattern and a set of paths * - * @param string $delimiter + * @param string $pattern + * @param array $paths */ - public static function delimiter(string $delimiter = null) {} + public function reConfigure($pattern, $paths = null) {} /** - * Extracts parameters from a string + * Returns the route's name * - * @param string $pattern - * @return array|bool + * @return string */ - public function extractNamedParams(string $pattern) {} + public function getName() {} /** - * Returns the 'before match' callback if any + * Sets the route's name * - * @return mixed + * + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * + * + * @param string $name + * @return Route */ - public function getBeforeMatch() {} + public function setName($name) {} /** - * Returns the route's compiled pattern + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @return string + * @param callback $callback + * @return Route */ - public function getCompiledPattern(): string {} + public function beforeMatch($callback) {} /** - * Returns the router converter + * Returns the 'before match' callback if any * - * @return array + * @return mixed */ - public function getConverters(): array {} + public function getBeforeMatch() {} /** - * Get routing delimiter + * Returns the route's id * * @return string */ - public static function getDelimiter(): string {} + public function getRouteId() {} /** - * Returns the route's description + * Returns the route's pattern * * @return string */ - public function getDescription(): string {} + public function getPattern() {} /** - * Returns the route's name + * Returns the route's compiled pattern * * @return string */ - public function getName(): string {} + public function getCompiledPattern() {} /** * Returns the paths * * @return array */ - public function getPaths(): array {} - - /** - * Returns the route's pattern - * - * @return string - */ - public function getPattern(): string {} + public function getPaths() {} /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths(): array {} + public function getReversedPaths() {} /** - * Returns the route's id + * Adds a converter to perform an additional transformation for certain parameter * - * @return string + * @param string $name + * @param callable $converter + * @return Route */ - public function getRouteId(): string {} + public function convert($name, $converter) {} /** - * Reconfigure the route adding a new pattern and a set of paths + * Returns the router converter * - * @param string $pattern - * @param array|string $paths + * @return array */ - public function reConfigure(string $pattern, $paths = null) {} + public function getConverters() {} /** * Resets the internal route id generator @@ -178,28 +173,17 @@ public function reConfigure(string $pattern, $paths = null) {} public static function reset() {} /** - * Sets the route's description + * Set the routing delimiter * - * @param string $description - * @return RouteInterface + * @param string $delimiter */ - public function setDescription(string $description): RouteInterface {} + public static function delimiter($delimiter = null) {} /** - * Sets the route's name - * - * ```php - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * ``` + * Get routing delimiter * - * @param string $name - * @return RouteInterface + * @return string */ - public function setName(string $name): RouteInterface {} + public static function getDelimiter() {} } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index d5cff844..cec93a31 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -3,110 +3,81 @@ namespace Phalcon\Cli\Router; /** + * Phalcon\Cli\Router\RouteInterface + * * Interface for Phalcon\Cli\Router\Route */ interface RouteInterface { /** - * Replaces placeholders from pattern returning a valid PCRE regular - * expression + * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string $pattern * @return string */ - public function compilePattern(string $pattern): string; + public function compilePattern($pattern); /** - * Set the routing delimiter + * Reconfigure the route adding a new pattern and a set of paths * - * @param string $delimiter + * @param string $pattern + * @param mixed $paths */ - public static function delimiter(string $delimiter = null); + public function reConfigure($pattern, $paths = null); /** - * Returns the route's pattern + * Returns the route's name * * @return string */ - public function getCompiledPattern(): string; + public function getName(); /** - * Get routing delimiter + * Sets the route's name * - * @return string + * @param string $name */ - public static function getDelimiter(): string; + public function setName($name); /** - * Returns the route's description + * Returns the route's id * * @return string */ - public function getDescription(): string; + public function getRouteId(); /** - * Returns the route's name + * Returns the route's pattern * * @return string */ - public function getName(): string; - - /** - * Returns the paths - * - * @return array - */ - public function getPaths(): array; + public function getPattern(); /** * Returns the route's pattern * * @return string */ - public function getPattern(): string; + public function getCompiledPattern(); /** - * Returns the paths using positions as keys and names as values + * Returns the paths * * @return array */ - public function getReversedPaths(): array; - - /** - * Returns the route's id - * - * @return string - */ - public function getRouteId(): string; + public function getPaths(); /** - * Reconfigure the route adding a new pattern and a set of paths + * Returns the paths using positions as keys and names as values * - * @param string $pattern - * @param mixed $paths + * @return array */ - public function reConfigure(string $pattern, $paths = null); + public function getReversedPaths(); /** * Resets the internal route id generator */ public static function reset(); - /** - * Sets the route's description - * - * @param string $description - * @return RouteInterface - */ - public function setDescription(string $description): RouteInterface; - - /** - * Sets the route's name - * - * @param string $name - * @return RouteInterface - */ - public function setName(string $name): RouteInterface; - } diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php deleted file mode 100644 index 58194464..00000000 --- a/src/Phalcon/collection/Exception.php +++ /dev/null @@ -1,11 +0,0 @@ - "path/config", - * "adapter" => "php", - * ]; - * - * $config = (new ConfigFactory())->load($options); - * ``` - */ -class ConfigFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * ConfigFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Load a config to create a new instance - * - * @param mixed $config - * @return object - */ - public function load($config) {} - - /** - * Returns a new Config instance - * - * @param string $name - * @param string $fileName - * @param mixed $params - * @return object - */ - public function newInstance(string $name, string $fileName, $params = null) {} - - /** - * Returns the adapters for the factory - * - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/config/Exception.php b/src/Phalcon/config/Exception.php index 80954ccc..f365baad 100644 --- a/src/Phalcon/config/Exception.php +++ b/src/Phalcon/config/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Config; /** + * Phalcon\Config\Exception + * * Exceptions thrown in Phalcon\Config will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/config/Factory.php b/src/Phalcon/config/Factory.php new file mode 100644 index 00000000..1fe15287 --- /dev/null +++ b/src/Phalcon/config/Factory.php @@ -0,0 +1,33 @@ + + * use Phalcon\Config\Factory; + * + * $options = [ + * "filePath" => "path/config", + * "adapter" => "php", + * ]; + * $config = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return \Phalcon\Config + */ + public static function load($config) {} + + /** + * @param string $namespace + * @param mixed $config + */ + protected static function loadClass($namespace, $config) {} + +} diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 5de00ac0..348b9b5f 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -3,11 +3,13 @@ namespace Phalcon\Config\Adapter; /** + * Phalcon\Config\Adapter\Grouped + * * Reads multiple files (or arrays) and merges them all together. * - * See `Phalcon\Config\Factory::load` To load Config Adapter class using 'adapter' option. + * @see Phalcon\Config\Factory::load To load Config Adapter class using 'adapter' option. * - * ```php + * * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -16,9 +18,9 @@ * "path/to/config.dist.php", * ] * ); - * ``` + * * - * ```php + * * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -28,9 +30,9 @@ * ], * "json" * ); - * ``` + * * - * ```php + * * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -47,11 +49,10 @@ * "adapter" => "array", * "config" => [ * "property" => "value", - * ], * ], * ], * ); - * ``` + * */ class Grouped extends \Phalcon\Config { @@ -62,6 +63,6 @@ class Grouped extends \Phalcon\Config * @param array $arrayConfig * @param string $defaultAdapter */ - public function __construct(array $arrayConfig, string $defaultAdapter = 'php') {} + public function __construct(array $arrayConfig, $defaultAdapter = 'php') {} } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index d2679230..63694376 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -3,11 +3,13 @@ namespace Phalcon\Config\Adapter; /** + * Phalcon\Config\Adapter\Ini + * * Reads ini files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * ```ini + * * [database] * adapter = Mysql * host = localhost @@ -19,58 +21,68 @@ * controllersDir = "../app/controllers/" * modelsDir = "../app/models/" * viewsDir = "../app/views/" - * ``` + * * * You can read it as follows: * - * ```php - * use Phalcon\Config\Adapter\Ini; - * - * $config = new Ini("path/config.ini"); + * + * $config = new \Phalcon\Config\Adapter\Ini("path/config.ini"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * ``` + * * * PHP constants may also be parsed in the ini file, so if you define a constant * as an ini value before calling the constructor, the constant's value will be * integrated into the results. To use it this way you must specify the optional - * second parameter as `INI_SCANNER_NORMAL` when calling the constructor: + * second parameter as INI_SCANNER_NORMAL when calling the constructor: * - * ```php + * * $config = new \Phalcon\Config\Adapter\Ini( * "path/config-with-constants.ini", * INI_SCANNER_NORMAL * ); - * ``` + * */ class Ini extends \Phalcon\Config { /** - * Ini constructor. + * Phalcon\Config\Adapter\Ini constructor * * @param string $filePath * @param mixed $mode */ - public function __construct(string $filePath, $mode = null) {} - - /** - * We have to cast values manually because parse_ini_file() has a poor - * implementation. - * - * @param mixed $ini - * @return bool|null|double|int|string - */ - protected function cast($ini) {} + public function __construct($filePath, $mode = null) {} /** * Build multidimensional array from string * + * + * $this->_parseIniString("path.hello.world", "value for last key"); + * + * // result + * [ + * "path" => [ + * "hello" => [ + * "world" => "value for last key", + * ], + * ], + * ]; + * + * * @param string $path * @param mixed $value * @return array */ - protected function parseIniString(string $path, $value): array {} + protected function _parseIniString($path, $value) {} + + /** + * We have to cast values manually because parse_ini_file() has a poor implementation. + * + * @param mixed $ini The array casted by `parse_ini_file` + * @return bool|null|double|int|string + */ + protected function _cast($ini) {} } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 6f20d09f..5c9f5761 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -3,24 +3,24 @@ namespace Phalcon\Config\Adapter; /** + * Phalcon\Config\Adapter\Json + * * Reads JSON files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * ```json + * * {"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"}} - * ``` + * * * You can read it as follows: * - * ```php - * use Phalcon\Config\Adapter\Json; - * - * $config = new Json("path/config.json"); + * + * $config = new Phalcon\Config\Adapter\Json("path/config.json"); * * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * ``` + * */ class Json extends \Phalcon\Config { @@ -30,6 +30,6 @@ class Json extends \Phalcon\Config * * @param string $filePath */ - public function __construct(string $filePath) {} + public function __construct($filePath) {} } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index cea8c07c..844d44e6 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -3,11 +3,13 @@ namespace Phalcon\Config\Adapter; /** + * Phalcon\Config\Adapter\Php + * * Reads php files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * ```php + * * "../app/views/", * ], * ]; - * ``` + * * * You can read it as follows: * - * ```php - * use Phalcon\Config\Adapter\Php; - * - * $config = new Php("path/config.php"); + * + * $config = new \Phalcon\Config\Adapter\Php("path/config.php"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * ``` + * */ class Php extends \Phalcon\Config { @@ -45,6 +45,6 @@ class Php extends \Phalcon\Config * * @param string $filePath */ - public function __construct(string $filePath) {} + public function __construct($filePath) {} } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index b0d7dc11..a0beca14 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -3,29 +3,29 @@ namespace Phalcon\Config\Adapter; /** + * Phalcon\Config\Adapter\Yaml + * * Reads YAML files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * ```yaml + * * phalcon: * baseuri: /phalcon/ * controllersDir: !approot /app/controllers/ * models: * metadata: memory - * ``` + * * * You can read it as follows: * - * ```php + * * define( * "APPROOT", * dirname(__DIR__) * ); * - * use Phalcon\Config\Adapter\Yaml; - * - * $config = new Yaml( + * $config = new \Phalcon\Config\Adapter\Yaml( * "path/config.yaml", * [ * "!approot" => function($value) { @@ -37,7 +37,7 @@ * echo $config->phalcon->controllersDir; * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * ``` + * */ class Yaml extends \Phalcon\Config { @@ -45,9 +45,10 @@ class Yaml extends \Phalcon\Config /** * Phalcon\Config\Adapter\Yaml constructor * + * @throws \Phalcon\Config\Exception * @param string $filePath * @param array $callbacks */ - public function __construct(string $filePath, array $callbacks = null) {} + public function __construct($filePath, array $callbacks = null) {} } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php deleted file mode 100644 index 2758e631..00000000 --- a/src/Phalcon/crypt/CryptInterface.php +++ /dev/null @@ -1,137 +0,0 @@ - "192.168.0.11", - * "username" => "sigma", - * "password" => "secret", - * "dbname" => "blog", - * "port" => "3306", - * ] - * ); - * - * $result = $connection->query( - * "SELECT FROM robots LIMIT 5" - * ); - * - * $result->setFetchMode(Enum::FETCH_NUM); - * - * while ($robot = $result->fetch()) { - * print_r($robot); - * } - * } catch (Exception $e) { - * echo $e->getMessage(), PHP_EOL; - * } - * ``` - */ -abstract class AbstractDb -{ - - /** - * Enables/disables options in the Database component - * - * @param array $options - */ - public static function setup(array $options) {} - -} diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/Adapter.php similarity index 68% rename from src/Phalcon/db/adapter/AbstractAdapter.php rename to src/Phalcon/db/Adapter.php index e6cbc176..2de182e2 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/Adapter.php @@ -1,107 +1,101 @@ delete( - * "robots", - * "id = 101" - * ); - * - * // Next SQL sentence is generated - * DELETE FROM `robots` WHERE `id` = 101 - * ``` - * - * @param mixed $table - * @param mixed $whereCondition - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool - */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool {} - - /** - * Lists table indexes - * - * ```php - * print_r( - * $connection->describeIndexes("robots_parts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] - */ - public function describeIndexes(string $table, string $schema = null): array {} - - /** - * Lists table references - * - * ```php - * print_r( - * $connection->describeReferences("robots_parts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] - */ - public function describeReferences(string $table, string $schema = null): array {} - - /** - * Drops a column from a table - * - * @param string $tableName - * @param string $schemaName - * @param string $columnName - * @return bool - */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): bool {} - - /** - * Drops a foreign key from a table - * - * @param string $tableName - * @param string $schemaName - * @param string $referenceName - * @return bool - */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): bool {} - - /** - * Drop an index from a table + * Sets the event manager * - * @param string $tableName - * @param string $schemaName - * @param mixed $indexName - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function dropIndex(string $tableName, string $schemaName, $indexName): bool {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Drops a table's primary key + * Returns the internal event manager * - * @param string $tableName - * @param string $schemaName - * @return bool + * @return \Phalcon\Events\ManagerInterface */ - public function dropPrimaryKey(string $tableName, string $schemaName): bool {} + public function getEventsManager() {} /** - * Drops a table from a schema/database + * Sets the dialect used to produce the SQL * - * @param string $tableName - * @param string $schemaName - * @param bool $ifExists - * @return bool + * @param DialectInterface $dialect */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): bool {} + public function setDialect(DialectInterface $dialect) {} /** - * Drops a view + * Returns internal dialect instance * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists - * @return bool + * @return DialectInterface */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): bool {} + public function getDialect() {} /** - * Escapes a column/table/schema name + * Returns the first row in a SQL query result * - * ```php - * $escapedTable = $connection->escapeIdentifier( - * "robots" - * ); + * + * // Getting first robot + * $robot = $connection->fetchOne("SELECT FROM robots"); + * print_r($robot); * - * $escapedTable = $connection->escapeIdentifier( - * [ - * "store", - * "robots", - * ] - * ); - * ``` + * // Getting first robot with associative indexes only + * $robot = $connection->fetchOne("SELECT FROM robots", \Phalcon\Db::FETCH_ASSOC); + * print_r($robot); + * * - * @param mixed $identifier - * @return string + * @param string $sqlQuery + * @param mixed $fetchMode + * @param mixed $bindParams + * @param mixed $bindTypes + * @return array */ - public function escapeIdentifier($identifier): string {} + public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} /** * Dumps the complete result of a query into an array * - * ```php + * * // Getting all robots with associative indexes only * $robots = $connection->fetchAll( * "SELECT FROM robots", - * \Phalcon\Db\Enum::FETCH_ASSOC + * \Phalcon\Db::FETCH_ASSOC * ); * * foreach ($robots as $robot) { @@ -327,7 +170,7 @@ public function escapeIdentifier($identifier): string {} * // Getting all robots that contains word "robot" withing the name * $robots = $connection->fetchAll( * "SELECT FROM robots WHERE name LIKE :name", - * \Phalcon\Db\Enum::FETCH_ASSOC, + * \Phalcon\Db::FETCH_ASSOC, * [ * "name" => "%robot%", * ] @@ -335,20 +178,20 @@ public function escapeIdentifier($identifier): string {} * foreach($robots as $robot) { * print_r($robot); * } - * ``` + * * * @param string $sqlQuery * @param int $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $bindParams + * @param array $bindTypes * @return array */ - public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} + public function fetchAll($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} /** * Returns the n'th field of first row in a SQL query result * - * ```php + * * // Getting count of robots * $robotsCount = $connection->fetchColumn("SELECT count() FROM robots"); * print_r($robotsCount); @@ -359,260 +202,299 @@ public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $ * 1 * ); * print_r($robot); - * ``` + * * * @param string $sqlQuery * @param array $placeholders - * @param mixed $column + * @param int|string $column * @return string|bool */ - public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) {} + public function fetchColumn($sqlQuery, $placeholders = null, $column = 0) {} /** - * Returns the first row in a SQL query result - * - * ```php - * // Getting first robot - * $robot = $connection->fetchOne("SELECT FROM robots"); - * print_r($robot); + * Inserts data into a table using custom RDBMS SQL syntax * - * // Getting first robot with associative indexes only - * $robot = $connection->fetchOne( - * "SELECT FROM robots", - * \Phalcon\Db\Enum::FETCH_ASSOC + * + * // Inserting a new robot + * $success = $connection->insert( + * "robots", + * ["Astro Boy", 1952], + * ["name", "year"] * ); - * print_r($robot); - * ``` - * - * @param string $sqlQuery - * @param mixed $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes - * @return array - */ - public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} - - /** - * Returns a SQL modified with a FOR UPDATE clause * - * @param string $sqlQuery - * @return string - */ - public function forUpdate(string $sqlQuery): string {} - - /** - * Returns the SQL column definition from a column + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @param string|array $table + * @param array $values + * @param mixed $fields + * @param mixed $dataTypes + * @param $array dataTypes + * @return bool */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function insert($table, array $values, $fields = null, $dataTypes = null) {} /** - * Gets a list of columns + * Inserts data into a table using custom RBDM SQL syntax * - * @param mixed $columnList - * @return string - */ - public function getColumnList($columnList): string {} - - /** - * Gets the active connection unique identifier + * + * // Inserting a new robot + * $success = $connection->insertAsDict( + * "robots", + * [ + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); * - * @return string + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * + * + * @param mixed $table + * @param mixed $data + * @param mixed $dataTypes + * @param $string table + * @param $array dataTypes + * @return bool */ - public function getConnectionId(): string {} + public function insertAsDict($table, $data, $dataTypes = null) {} /** - * Returns the default identity value to be inserted in an identity column + * Updates data on a table using custom RBDM SQL syntax * - * ```php - * // Inserting a new robot with a valid default value for the column 'id' - * $success = $connection->insert( + * + * // Updating existing robot + * $success = $connection->update( * "robots", + * ["name"], + * ["New Astro Boy"], + * "id = 101" + * ); + * + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * + * // Updating existing robot with array condition and $dataTypes + * $success = $connection->update( + * "robots", + * ["name"], + * ["New Astro Boy"], * [ - * $connection->getDefaultIdValue(), - * "Astro Boy", - * 1952, + * "conditions" => "id = ?", + * "bind" => [$some_unsafe_id], + * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param * ], * [ - * "id", - * "name", - * "year", + * PDO::PARAM_STR * ] * ); - * ``` * - * @return \Phalcon\Db\RawValue + * + * + * Warning! If $whereCondition is string it not escaped. + * + * @param string|array $table + * @param mixed $fields + * @param mixed $values + * @param mixed $whereCondition + * @param mixed $dataTypes + * @param $array dataTypes + * @param $string|array whereCondition + * @return bool */ - public function getDefaultIdValue(): RawValue {} + public function update($table, $fields, $values, $whereCondition = null, $dataTypes = null) {} /** - * Returns the default value to make the RBDM use the default value declared - * in the table definition + * Updates data on a table using custom RBDM SQL syntax + * Another, more convenient syntax * - * ```php - * // Inserting a new robot with a valid default value for the column 'year' - * $success = $connection->insert( + * + * // Updating existing robot + * $success = $connection->updateAsDict( * "robots", * [ - * "Astro Boy", - * $connection->getDefaultValue() + * "name" => "New Astro Boy", * ], - * [ - * "name", - * "year", - * ] + * "id = 101" * ); - * ``` * - * @return \Phalcon\Db\RawValue - */ - public function getDefaultValue(): RawValue {} - - /** - * Return descriptor used to connect to the active database + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * * - * @return array + * @param mixed $table + * @param mixed $data + * @param mixed $whereCondition + * @param mixed $dataTypes + * @param $string whereCondition + * @param $array dataTypes + * @return bool */ - public function getDescriptor(): array {} + public function updateAsDict($table, $data, $whereCondition = null, $dataTypes = null) {} /** - * Returns internal dialect instance + * Deletes data from a table using custom RBDM SQL syntax * - * @return DialectInterface - */ - public function getDialect(): DialectInterface {} - - /** - * Returns the internal event manager + * + * // Deleting existing robot + * $success = $connection->delete( + * "robots", + * "id = 101" + * ); * - * @return \Phalcon\Events\ManagerInterface + * // Next SQL sentence is generated + * DELETE FROM `robots` WHERE `id` = 101 + * + * + * @param string|array $table + * @param string $whereCondition + * @param array $placeholders + * @param array $dataTypes + * @return bool */ - public function getEventsManager(): ManagerInterface {} + public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null) {} /** - * Returns the savepoint name to use for nested transactions + * Escapes a column/table/schema name * + * + * $escapedTable = $connection->escapeIdentifier( + * "robots" + * ); + * + * $escapedTable = $connection->escapeIdentifier( + * [ + * "store", + * "robots", + * ] + * ); + * + * + * @param array|string $identifier * @return string */ - public function getNestedTransactionSavepointName(): string {} + public function escapeIdentifier($identifier) {} /** - * Active SQL statement in the object without replace bound parameters + * Gets a list of columns * + * @param array columnList + * @return string + * @param mixed $columnList * @return string */ - public function getRealSQLStatement(): string {} + public function getColumnList($columnList) {} /** - * Active SQL statement in the object + * Appends a LIMIT clause to $sqlQuery argument * - * @return array - */ - public function getSQLBindTypes(): array {} - - /** - * Active SQL statement in the object + * + * echo $connection->limit("SELECT FROM robots", 5); + * * + * @param string $sqlQuery + * @param int $number * @return string */ - public function getSQLStatement(): string {} + public function limit($sqlQuery, $number) {} /** - * Inserts data into a table using custom RDBMS SQL syntax + * Generates SQL checking for the existence of a schema.table * - * ```php - * // Inserting a new robot - * $success = $connection->insert( - * "robots", - * ["Astro Boy", 1952], - * ["name", "year"] + * + * var_dump( + * $connection->tableExists("blog", "posts") * ); + * * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * ``` - * - * @param string $table - * @param array $values - * @param mixed $fields - * @param mixed $dataTypes + * @param string $tableName + * @param string $schemaName * @return bool */ - public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool {} + public function tableExists($tableName, $schemaName = null) {} /** - * Inserts data into a table using custom RBDM SQL syntax + * Generates SQL checking for the existence of a schema.view * - * ```php - * // Inserting a new robot - * $success = $connection->insertAsDict( - * "robots", - * [ - * "name" => "Astro Boy", - * "year" => 1952, - * ] + * + * var_dump( + * $connection->viewExists("active_users", "posts") * ); + * * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * ``` - * - * @param string $table - * @param mixed $data - * @param mixed $dataTypes + * @param string $viewName + * @param string $schemaName * @return bool */ - public function insertAsDict(string $table, $data, $dataTypes = null): bool {} + public function viewExists($viewName, $schemaName = null) {} /** - * Returns if nested transactions should use savepoints + * Returns a SQL modified with a FOR UPDATE clause * - * @return bool + * @param string $sqlQuery + * @return string */ - public function isNestedTransactionsWithSavepoints(): bool {} + public function forUpdate($sqlQuery) {} /** - * Appends a LIMIT clause to $sqlQuery argument - * - * ```php - * echo $connection->limit("SELECT FROM robots", 5); - * ``` + * Returns a SQL modified with a LOCK IN SHARE MODE clause * * @param string $sqlQuery - * @param int $number * @return string */ - public function limit(string $sqlQuery, int $number): string {} + public function sharedLock($sqlQuery) {} /** - * List all tables on a database + * Creates a table * - * ```php - * print_r( - * $connection->listTables("blog") - * ); - * ``` + * @param string $tableName + * @param string $schemaName + * @param array $definition + * @return bool + */ + public function createTable($tableName, $schemaName, array $definition) {} + + /** + * Drops a table from a schema/database * + * @param string $tableName * @param string $schemaName - * @return array + * @param bool $ifExists + * @return bool */ - public function listTables(string $schemaName = null): array {} + public function dropTable($tableName, $schemaName = null, $ifExists = true) {} /** - * List all views on a database + * Creates a view * - * ```php - * print_r( - * $connection->listViews("blog") - * ); - * ``` + * @param string $viewName + * @param array $definition + * @param string $schemaName + * @return bool + */ + public function createView($viewName, array $definition, $schemaName = null) {} + + /** + * Drops a view * + * @param string $viewName * @param string $schemaName - * @return array + * @param bool $ifExists + * @return bool */ - public function listViews(string $schemaName = null): array {} + public function dropView($viewName, $schemaName = null, $ifExists = true) {} + + /** + * Adds a column to a table + * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @return bool + */ + public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} /** * Modifies a table column based on a definition @@ -623,182 +505,300 @@ public function listViews(string $schemaName = null): array {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} /** - * Releases given savepoint + * Drops a column from a table * - * @param string $name + * @param string $tableName + * @param string $schemaName + * @param string $columnName * @return bool */ - public function releaseSavepoint(string $name): bool {} + public function dropColumn($tableName, $schemaName, $columnName) {} /** - * Rollbacks given savepoint + * Adds an index to a table * - * @param string $name + * @param string $tableName + * @param string $schemaName + * @param IndexInterface $index * @return bool */ - public function rollbackSavepoint(string $name): bool {} + public function addIndex($tableName, $schemaName, IndexInterface $index) {} /** - * Sets the event manager + * Drop an index from a table * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $tableName + * @param string $schemaName + * @param mixed $indexName + * @return bool */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function dropIndex($tableName, $schemaName, $indexName) {} /** - * Sets the dialect used to produce the SQL + * Adds a primary key to a table * - * @param DialectInterface $dialect + * @param string $tableName + * @param string $schemaName + * @param IndexInterface $index + * @return bool */ - public function setDialect(DialectInterface $dialect) {} + public function addPrimaryKey($tableName, $schemaName, IndexInterface $index) {} /** - * Set if nested transactions should use savepoints + * Drops a table's primary key * - * @param bool $nestedTransactionsWithSavepoints - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param string $tableName + * @param string $schemaName + * @return bool */ - public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface {} + public function dropPrimaryKey($tableName, $schemaName) {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Adds a foreign key to a table * - * @param string $sqlQuery - * @return string + * @param string $tableName + * @param string $schemaName + * @param ReferenceInterface $reference + * @return bool */ - public function sharedLock(string $sqlQuery): string {} + public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference) {} /** - * Check whether the database system requires a sequence to produce - * auto-numeric values + * Drops a foreign key from a table * + * @param string $tableName + * @param string $schemaName + * @param string $referenceName * @return bool */ - public function supportSequences(): bool {} + public function dropForeignKey($tableName, $schemaName, $referenceName) {} /** - * Generates SQL checking for the existence of a schema.table + * Returns the SQL column definition from a column * - * ```php - * var_dump( - * $connection->tableExists("blog", "posts") + * @param \Phalcon\Db\ColumnInterface $column + * @return string + */ + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + + /** + * List all tables on a database + * + * + * print_r( + * $connection->listTables("blog") * ); - * ``` + * * - * @param string $tableName * @param string $schemaName - * @return bool + * @return array + */ + public function listTables($schemaName = null) {} + + /** + * List all views on a database + * + * + * print_r( + * $connection->listViews("blog") + * ); + * + * + * @param string $schemaName + * @return array + */ + public function listViews($schemaName = null) {} + + /** + * Lists table indexes + * + * + * print_r( + * $connection->describeIndexes("robots_parts") + * ); + * + * + * @param string table + * @param string schema + * @return Phalcon\Db\Index[] + * @param string $table + * @param string $schema + * @return IndexInterface[] + */ + public function describeIndexes($table, $schema = null) {} + + /** + * Lists table references + * + * + * print_r( + * $connection->describeReferences("robots_parts") + * ); + * + * + * @param string $table + * @param string $schema + * @return ReferenceInterface[] */ - public function tableExists(string $tableName, string $schemaName = null): bool {} + public function describeReferences($table, $schema = null) {} /** * Gets creation options from a table * - * ```php + * * print_r( * $connection->tableOptions("robots") * ); - * ``` + * * * @param string $tableName * @param string $schemaName * @return array */ - public function tableOptions(string $tableName, string $schemaName = null): array {} + public function tableOptions($tableName, $schemaName = null) {} /** - * Updates data on a table using custom RBDM SQL syntax + * Creates a new savepoint * - * ```php - * // Updating existing robot - * $success = $connection->update( - * "robots", - * ["name"], - * ["New Astro Boy"], - * "id = 101" - * ); + * @param string $name + * @return bool + */ + public function createSavepoint($name) {} + + /** + * Releases given savepoint * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * @param string $name + * @return bool + */ + public function releaseSavepoint($name) {} + + /** + * Rollbacks given savepoint * - * // Updating existing robot with array condition and $dataTypes - * $success = $connection->update( + * @param string $name + * @return bool + */ + public function rollbackSavepoint($name) {} + + /** + * Set if nested transactions should use savepoints + * + * @param bool $nestedTransactionsWithSavepoints + * @return AdapterInterface + */ + public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints) {} + + /** + * Returns if nested transactions should use savepoints + * + * @return bool + */ + public function isNestedTransactionsWithSavepoints() {} + + /** + * Returns the savepoint name to use for nested transactions + * + * @return string + */ + public function getNestedTransactionSavepointName() {} + + /** + * Returns the default identity value to be inserted in an identity column + * + * + * // Inserting a new robot with a valid default value for the column 'id' + * $success = $connection->insert( * "robots", - * ["name"], - * ["New Astro Boy"], * [ - * "conditions" => "id = ?", - * "bind" => [$some_unsafe_id], - * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param + * $connection->getDefaultIdValue(), + * "Astro Boy", + * 1952, * ], * [ - * PDO::PARAM_STR + * "id", + * "name", + * "year", * ] * ); + * * - * ``` - * - * Warning! If $whereCondition is string it not escaped. - * - * @param string $table - * @param mixed $fields - * @param mixed $values - * @param mixed $whereCondition - * @param mixed $dataTypes - * @return bool + * @return RawValue */ - public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool {} + public function getDefaultIdValue() {} /** - * Updates data on a table using custom RBDM SQL syntax - * Another, more convenient syntax + * Returns the default value to make the RBDM use the default value declared in the table definition * - * ```php - * // Updating existing robot - * $success = $connection->updateAsDict( + * + * // Inserting a new robot with a valid default value for the column 'year' + * $success = $connection->insert( * "robots", * [ - * "name" => "New Astro Boy", + * "Astro Boy", + * $connection->getDefaultValue() * ], - * "id = 101" + * [ + * "name", + * "year", + * ] * ); + * * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 - * ``` + * @return RawValue + */ + public function getDefaultValue() {} + + /** + * Check whether the database system requires a sequence to produce auto-numeric values * - * @param string $table - * @param mixed $data - * @param mixed $whereCondition - * @param mixed $dataTypes * @return bool */ - public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool {} + public function supportSequences() {} /** - * Check whether the database system requires an explicit value for identity - * columns + * Check whether the database system requires an explicit value for identity columns * * @return bool */ - public function useExplicitIdValue(): bool {} + public function useExplicitIdValue() {} /** - * Generates SQL checking for the existence of a schema.view + * Return descriptor used to connect to the active database * - * ```php - * var_dump( - * $connection->viewExists("active_users", "posts") - * ); - * ``` + * @return array + */ + public function getDescriptor() {} + + /** + * Gets the active connection unique identifier * - * @param string $viewName - * @param string $schemaName - * @return bool + * @return string + */ + public function getConnectionId() {} + + /** + * Active SQL statement in the object + * + * @return string + */ + public function getSQLStatement() {} + + /** + * Active SQL statement in the object without replace bound parameters + * + * @return string + */ + public function getRealSQLStatement() {} + + /** + * Active SQL statement in the object + * + * @return array */ - public function viewExists(string $viewName, string $schemaName = null): bool {} + public function getSQLBindTypes() {} } diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/AdapterInterface.php similarity index 52% rename from src/Phalcon/db/adapter/AdapterInterface.php rename to src/Phalcon/db/AdapterInterface.php index e136e02f..d207a62d 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/AdapterInterface.php @@ -1,101 +1,126 @@ fetchColumn("SELECT count() FROM robots"); - * print_r($robotsCount); - * - * // Getting name of last edited robot - * $robot = $connection->fetchColumn( - * "SELECT id, name FROM robots order by modified desc", - * 1 - * ); - * print_r($robot); - * ``` + * List all views on a database * - * @param string $sqlQuery - * @param array $placeholders - * @param mixed $column - * @return string|bool + * @param string $schemaName + * @return array */ - public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0); + public function listViews($schemaName = null); /** - * Returns the first row in a SQL query result + * Return descriptor used to connect to the active database * - * @param string $sqlQuery - * @param int $fetchMode - * @param mixed $placeholders * @return array */ - public function fetchOne(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array; + public function getDescriptor(); /** - * Returns a SQL modified with a FOR UPDATE clause + * Gets the active connection unique identifier * - * @param string $sqlQuery * @return string */ - public function forUpdate(string $sqlQuery): string; + public function getConnectionId(); /** - * Returns the SQL column definition from a column + * Active SQL statement in the object * - * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; + public function getSQLStatement(); /** - * Gets a list of columns + * Active SQL statement in the object without replace bound parameters * - * @param mixed $columnList * @return string */ - public function getColumnList($columnList): string; + public function getRealSQLStatement(); /** - * Gets the active connection unique identifier + * Active SQL statement in the object * - * @return string + * @return array */ - public function getConnectionId(): string; + public function getSQLVariables(); /** - * Return descriptor used to connect to the active database + * Active SQL statement in the object * * @return array */ - public function getDescriptor(): array; + public function getSQLBindTypes(); /** - * Returns internal dialect instance + * Returns type of database system the adapter is used for * - * @return DialectInterface + * @return string */ - public function getDialect(): DialectInterface; + public function getType(); /** * Returns the name of the dialect used * * @return string */ - public function getDialectType(): string; + public function getDialectType(); /** - * Return the default identity value to insert in an identity column + * Returns internal dialect instance * - * @return \Phalcon\Db\RawValue + * @return DialectInterface */ - public function getDefaultIdValue(): RawValue; + public function getDialect(); /** - * Return internal PDO handler + * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. + * Call it when you need to restore a database connection * - * @return \Pdo + * @param array $descriptor + * @return bool */ - public function getInternalHandler(): \Pdo; + public function connect(array $descriptor = null); /** - * Returns the savepoint name to use for nested transactions + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server return rows * - * @return string + * @param string $sqlStatement + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool|ResultInterface */ - public function getNestedTransactionSavepointName(): string; + public function query($sqlStatement, $placeholders = null, $dataTypes = null); /** - * Active SQL statement in the object without replace bound parameters + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server doesn't return any rows * - * @return string + * @param string $sqlStatement + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool */ - public function getRealSQLStatement(): string; + public function execute($sqlStatement, $placeholders = null, $dataTypes = null); /** - * Active SQL statement in the object + * Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system * - * @return string + * @return int */ - public function getSQLStatement(): string; + public function affectedRows(); /** - * Active SQL statement in the object + * Closes active connection returning success. Phalcon automatically closes + * and destroys active connections within Phalcon\Db\Pool * - * @return array + * @return bool */ - public function getSQLBindTypes(): array; + public function close(); /** - * Active SQL statement in the object + * Escapes a column/table/schema name * - * @return array + * @param string $identifier + * @return string */ - public function getSQLVariables(): array; + public function escapeIdentifier($identifier); /** - * Returns type of database system the adapter is used for + * Escapes a value to avoid SQL injections * + * @param string $str * @return string */ - public function getType(): string; + public function escapeString($str); /** - * Inserts data into a table using custom RDBMS SQL syntax + * Returns insert id for the auto_increment column inserted in the last SQL statement * - * @param string $table - * @param array $values - * @param mixed $fields - * @param mixed $dataTypes - * @return bool + * @param string $sequenceName + * @return int */ - public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool; + public function lastInsertId($sequenceName = null); /** - * Inserts data into a table using custom RBDM SQL syntax - * - * ```php - * // Inserting a new robot - * $success = $connection->insertAsDict( - * "robots", - * [ - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); + * Starts a transaction in the connection * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * ``` + * @param bool $nesting + * @return bool + */ + public function begin($nesting = true); + + /** + * Rollbacks the active transaction in the connection * - * @param string $table - * @param mixed $data - * @param mixed $dataTypes + * @param bool $nesting * @return bool */ - public function insertAsDict(string $table, $data, $dataTypes = null): bool; + public function rollback($nesting = true); /** - * Returns if nested transactions should use savepoints + * Commits the active transaction in the connection * + * @param bool $nesting * @return bool */ - public function isNestedTransactionsWithSavepoints(): bool; + public function commit($nesting = true); /** * Checks whether connection is under database transaction * * @return bool */ - public function isUnderTransaction(): bool; + public function isUnderTransaction(); /** - * Returns insert id for the auto_increment column inserted in the last SQL - * statement + * Return internal PDO handler * - * @param mixed $sequenceName + * @return \Pdo */ - public function lastInsertId($sequenceName = null); + public function getInternalHandler(); /** - * Appends a LIMIT clause to sqlQuery argument + * Lists table indexes * - * @param string $sqlQuery - * @param int $number - * @return string + * @param string $table + * @param string $schema + * @return IndexInterface[] */ - public function limit(string $sqlQuery, int $number): string; + public function describeIndexes($table, $schema = null); /** - * List all tables on a database + * Lists table references * - * @param string $schemaName - * @return array + * @param string $table + * @param string $schema + * @return ReferenceInterface[] */ - public function listTables(string $schemaName = null): array; + public function describeReferences($table, $schema = null); /** - * List all views on a database + * Gets creation options from a table * + * @param string $tableName * @param string $schemaName * @return array */ - public function listViews(string $schemaName = null): array; + public function tableOptions($tableName, $schemaName = null); /** - * Modifies a table column based on a definition + * Check whether the database system requires an explicit value for identity columns * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool; + public function useExplicitIdValue(); /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server returns - * rows + * Return the default identity value to insert in an identity column * - * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool|ResultInterface + * @return RawValue */ - public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); + public function getDefaultIdValue(); /** - * Releases given savepoint + * Check whether the database system requires a sequence to produce auto-numeric values * - * @param string $name * @return bool */ - public function releaseSavepoint(string $name): bool; + public function supportSequences(); /** - * Rollbacks the active transaction in the connection + * Creates a new savepoint * - * @param bool $nesting + * @param string $name * @return bool */ - public function rollback(bool $nesting = true): bool; + public function createSavepoint($name); /** - * Rollbacks given savepoint + * Releases given savepoint * * @param string $name * @return bool */ - public function rollbackSavepoint(string $name): bool; + public function releaseSavepoint($name); /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Rollbacks given savepoint * - * @param string $sqlQuery - * @return string + * @param string $name + * @return bool */ - public function sharedLock(string $sqlQuery): string; + public function rollbackSavepoint($name); /** * Set if nested transactions should use savepoints @@ -536,87 +525,29 @@ public function sharedLock(string $sqlQuery): string; * @param bool $nestedTransactionsWithSavepoints * @return AdapterInterface */ - public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface; - - /** - * Check whether the database system requires a sequence to produce - * auto-numeric values - * - * @return bool - */ - public function supportSequences(): bool; + public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints); /** - * Generates SQL checking for the existence of a schema.table + * Returns if nested transactions should use savepoints * - * @param string $tableName - * @param string $schemaName * @return bool */ - public function tableExists(string $tableName, string $schemaName = null): bool; - - /** - * Gets creation options from a table - * - * @param string $tableName - * @param string $schemaName - * @return array - */ - public function tableOptions(string $tableName, string $schemaName = null): array; + public function isNestedTransactionsWithSavepoints(); /** - * Updates data on a table using custom RDBMS SQL syntax + * Returns the savepoint name to use for nested transactions * - * @param string $table - * @param mixed $fields - * @param mixed $values - * @param mixed $whereCondition - * @param mixed $dataTypes - * @return bool + * @return string */ - public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool; + public function getNestedTransactionSavepointName(); /** - * Updates data on a table using custom RBDM SQL syntax - * Another, more convenient syntax - * - * ```php - * // Updating existing robot - * $success = $connection->updateAsDict( - * "robots", - * [ - * "name" => "New Astro Boy", - * ], - * "id = 101" - * ); - * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 - * ``` + * Returns an array of Phalcon\Db\Column objects describing a table * * @param string $table - * @param mixed $data - * @param mixed $whereCondition - * @param mixed $dataTypes - * @return bool - */ - public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool; - - /** - * Check whether the database system requires an explicit value for identity - * columns - * - * @return bool - */ - public function useExplicitIdValue(): bool; - - /** - * Generates SQL checking for the existence of a schema.view - * - * @param string $viewName - * @param string $schemaName - * @return bool + * @param string $schema + * @return ColumnInterface[] */ - public function viewExists(string $viewName, string $schemaName = null): bool; + public function describeColumns($table, $schema = null); } diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 30f71f34..4c08e763 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -3,9 +3,11 @@ namespace Phalcon\Db; /** + * Phalcon\Db\Column + * * Allows to define columns to be used on create or alter table operations * - * ```php + * * use Phalcon\Db\Column as Column; * * // Column definition @@ -23,84 +25,54 @@ * * // Add column to existing table * $connection->addColumn("robots", null, $column); - * ``` + * */ class Column implements \Phalcon\Db\ColumnInterface { /** - * Bind Type Blob - */ - const BIND_PARAM_BLOB = 3; - - /** - * Bind Type Bool - */ - const BIND_PARAM_BOOL = 5; - - /** - * Bind Type Decimal - */ - const BIND_PARAM_DECIMAL = 32; - - /** - * Bind Type Integer - */ - const BIND_PARAM_INT = 1; - - /** - * Bind Type Null - */ - const BIND_PARAM_NULL = 0; - - /** - * Bind Type String + * Integer abstract type */ - const BIND_PARAM_STR = 2; + const TYPE_INTEGER = 0; /** - * Skip binding by type + * Date abstract type */ - const BIND_SKIP = 1024; + const TYPE_DATE = 1; /** - * Big integer abstract data type + * Varchar abstract type */ - const TYPE_BIGINTEGER = 14; + const TYPE_VARCHAR = 2; /** - * Bit abstract data type + * Decimal abstract type */ - const TYPE_BIT = 19; - - /** - * Blob abstract data type - */ - const TYPE_BLOB = 11; + const TYPE_DECIMAL = 3; /** - * Bool abstract data type + * Datetime abstract type */ - const TYPE_BOOLEAN = 8; + const TYPE_DATETIME = 4; /** - * Char abstract data type + * Char abstract type */ const TYPE_CHAR = 5; /** - * Date abstract data type + * Text abstract data type */ - const TYPE_DATE = 1; + const TYPE_TEXT = 6; /** - * Datetime abstract data type + * Float abstract data type */ - const TYPE_DATETIME = 4; + const TYPE_FLOAT = 7; /** - * Decimal abstract data type + * Boolean abstract data type */ - const TYPE_DECIMAL = 3; + const TYPE_BOOLEAN = 8; /** * Double abstract data type @@ -108,239 +80,238 @@ class Column implements \Phalcon\Db\ColumnInterface const TYPE_DOUBLE = 9; /** - * Enum abstract data type + * Tinyblob abstract data type */ - const TYPE_ENUM = 18; + const TYPE_TINYBLOB = 10; /** - * Float abstract data type + * Blob abstract data type */ - const TYPE_FLOAT = 7; + const TYPE_BLOB = 11; /** - * Int abstract data type + * Mediumblob abstract data type */ - const TYPE_INTEGER = 0; + const TYPE_MEDIUMBLOB = 12; /** - * Json abstract data type + * Longblob abstract data type */ - const TYPE_JSON = 15; + const TYPE_LONGBLOB = 13; /** - * Jsonb abstract data type + * Big integer abstract data type */ - const TYPE_JSONB = 16; + const TYPE_BIGINTEGER = 14; /** - * Longblob abstract data type + * Json abstract type */ - const TYPE_LONGBLOB = 13; + const TYPE_JSON = 15; /** - * Longtext abstract data type + * Jsonb abstract type */ - const TYPE_LONGTEXT = 24; + const TYPE_JSONB = 16; /** - * Mediumblob abstract data type + * Datetime abstract type */ - const TYPE_MEDIUMBLOB = 12; + const TYPE_TIMESTAMP = 17; /** - * Mediumintegerr abstract data type + * Bind Type Null */ - const TYPE_MEDIUMINTEGER = 21; + const BIND_PARAM_NULL = 0; /** - * Mediumtext abstract data type + * Bind Type Integer */ - const TYPE_MEDIUMTEXT = 23; + const BIND_PARAM_INT = 1; /** - * Smallint abstract data type + * Bind Type String */ - const TYPE_SMALLINTEGER = 22; + const BIND_PARAM_STR = 2; /** - * Text abstract data type + * Bind Type Blob */ - const TYPE_TEXT = 6; + const BIND_PARAM_BLOB = 3; /** - * Time abstract data type + * Bind Type Bool */ - const TYPE_TIME = 20; + const BIND_PARAM_BOOL = 5; /** - * Timestamp abstract data type + * Bind Type Decimal */ - const TYPE_TIMESTAMP = 17; + const BIND_PARAM_DECIMAL = 32; /** - * Tinyblob abstract data type + * Skip binding by type */ - const TYPE_TINYBLOB = 10; + const BIND_SKIP = 1024; /** - * Tinyint abstract data type + * Column's name + * + * @var string */ - const TYPE_TINYINTEGER = 26; + protected $_name; /** - * Tinytext abstract data type + * Schema which table related is + * + * @var string */ - const TYPE_TINYTEXT = 25; + protected $_schemaName; /** - * Varchar abstract data type + * Column data type + * + * @var int|string */ - const TYPE_VARCHAR = 2; + protected $_type; /** - * Column Position + * Column data type reference * - * @var string + * @var int */ - protected $after; + protected $_typeReference = -1; /** - * Column is autoIncrement? + * Column data type values * - * @var bool + * @var array|string */ - protected $autoIncrement = false; + protected $_typeValues; /** - * Bind Type + * The column have some numeric type? */ - protected $bindType = 2; + protected $_isNumeric = false; /** - * Default column value + * Integer column size + * + * @var int */ - protected $_default = null; + protected $_size = 0; /** - * Position is first + * Integer column number scale * - * @var bool + * @var int */ - protected $first = false; + protected $_scale = 0; /** - * The column have some numeric type? + * Default column value */ - protected $isNumeric = false; + protected $_default = null; /** - * Column's name + * Integer column unsigned? * - * @var string + * @var boolean */ - protected $name; + protected $_unsigned = false; /** * Column not nullable? * - * @var bool + * @var boolean */ - protected $notNull = false; + protected $_notNull = false; /** * Column is part of the primary key? */ - protected $primary = false; + protected $_primary = false; /** - * Integer column number scale + * Column is autoIncrement? * - * @var int + * @var boolean */ - protected $scale = 0; + protected $_autoIncrement = false; /** - * Integer column size + * Position is first * - * @var int + * @var boolean */ - protected $size = 0; + protected $_first = false; /** - * Column data type + * Column Position * - * @var int + * @var string */ - protected $type; + protected $_after; /** - * Column data type reference - * - * @var int + * Bind Type */ - protected $typeReference = -1; + protected $_bindType = 2; + /** - * Column data type values + * Column's name * - * @var array|string + * @return string */ - protected $typeValues; + public function getName() {} /** - * Integer column unsigned? + * Schema which table related is * - * @var bool + * @return string */ - protected $unsigned = false; - + public function getSchemaName() {} /** - * Default column value - */ - public function getDefault() {} - - /** - * Column's name + * Column data type * - * @return string + * @return int|string */ - public function getName(): string {} + public function getType() {} /** - * Integer column number scale + * Column data type reference * * @return int */ - public function getScale(): int {} + public function getTypeReference() {} /** - * Integer column size + * Column data type values * - * @return int + * @return array|string */ - public function getSize(): int {} + public function getTypeValues() {} /** - * Column data type + * Integer column size * * @return int */ - public function getType(): int {} + public function getSize() {} /** - * Column data type reference + * Integer column number scale * * @return int */ - public function getTypeReference(): int {} + public function getScale() {} /** - * Column data type values - * - * @return array|string + * Default column value */ - public function getTypeValues() {} + public function getDefault() {} /** * Phalcon\Db\Column constructor @@ -348,69 +319,77 @@ public function getTypeValues() {} * @param string $name * @param array $definition */ - public function __construct(string $name, array $definition) {} + public function __construct($name, array $definition) {} /** - * Check whether field absolute to position in table + * Returns true if number column is unsigned * - * @return string + * @return bool */ - public function getAfterPosition(): string {} + public function isUnsigned() {} /** - * Returns the type of bind handling + * Not null * - * @return int + * @return bool */ - public function getBindType(): int {} + public function isNotNull() {} /** - * Check whether column has default value + * Column is part of the primary key? * * @return bool */ - public function hasDefault(): bool {} + public function isPrimary() {} /** * Auto-Increment * * @return bool */ - public function isAutoIncrement(): bool {} + public function isAutoIncrement() {} /** - * Check whether column have first position in table + * Check whether column have an numeric type * * @return bool */ - public function isFirst(): bool {} + public function isNumeric() {} /** - * Not null + * Check whether column have first position in table * * @return bool */ - public function isNotNull(): bool {} + public function isFirst() {} /** - * Check whether column have an numeric type + * Check whether field absolute to position in table * - * @return bool + * @return string */ - public function isNumeric(): bool {} + public function getAfterPosition() {} /** - * Column is part of the primary key? + * Returns the type of bind handling * - * @return bool + * @return int */ - public function isPrimary(): bool {} + public function getBindType() {} /** - * Returns true if number column is unsigned + * Restores the internal state of a Phalcon\Db\Column object + * + * @param array $data + * @return \Phalcon\Db\ColumnInterface + */ + public static function __set_state(array $data) {} + + /** + * Check whether column has default value * * @return bool */ - public function isUnsigned(): bool {} + public function hasDefault() {} } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index 2fc8226d..dcf8d0c1 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -3,121 +3,138 @@ namespace Phalcon\Db; /** + * Phalcon\Db\ColumnInterface + * * Interface for Phalcon\Db\Column */ interface ColumnInterface { /** - * Check whether field absolute to position in table + * Returns schema's table related to column * * @return string */ - public function getAfterPosition(): string; + public function getSchemaName(); /** - * Returns the type of bind handling + * Returns column name * - * @return int + * @return string */ - public function getBindType(): int; + public function getName(); /** - * Returns default value of column + * Returns column type * - * @return mixed + * @return int */ - public function getDefault(); + public function getType(); /** - * Returns column name + * Returns column type reference * - * @return string + * @return int */ - public function getName(): string; + public function getTypeReference(); /** - * Returns column scale + * Returns column type values * * @return int */ - public function getScale(): int; + public function getTypeValues(); /** * Returns column size * * @return int */ - public function getSize(): int; + public function getSize(); /** - * Returns column type + * Returns column scale * * @return int */ - public function getType(): int; + public function getScale(); /** - * Returns column type reference + * Returns true if number column is unsigned * - * @return int + * @return boolean */ - public function getTypeReference(): int; + public function isUnsigned(); /** - * Returns column type values + * Not null * - * @return array|string + * @return boolean */ - public function getTypeValues(); + public function isNotNull(); /** - * Check whether column has default value + * Column is part of the primary key? * - * @return bool + * @return boolean */ - public function hasDefault(): bool; + public function isPrimary(); /** * Auto-Increment * - * @return bool + * @return boolean */ - public function isAutoIncrement(): bool; + public function isAutoIncrement(); + + /** + * Check whether column have an numeric type + * + * @return boolean + */ + public function isNumeric(); /** * Check whether column have first position in table * - * @return bool + * @return boolean */ - public function isFirst(): bool; + public function isFirst(); /** - * Not null + * Check whether field absolute to position in table * - * @return bool + * @return string */ - public function isNotNull(): bool; + public function getAfterPosition(); /** - * Check whether column have an numeric type + * Returns the type of bind handling * - * @return bool + * @return int */ - public function isNumeric(): bool; + public function getBindType(); /** - * Column is part of the primary key? + * Returns default value of column * - * @return bool + * @return int */ - public function isPrimary(): bool; + public function getDefault(); /** - * Returns true if number column is unsigned + * Check whether column has default value * * @return bool */ - public function isUnsigned(): bool; + public function hasDefault(); + + /** + * Restores the internal state of a Phalcon\Db\Column object + * + * @param array $data + * @return ColumnInterface + */ + public static function __set_state(array $data); } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index f72935c0..d6021102 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -3,83 +3,102 @@ namespace Phalcon\Db; /** + * Phalcon\Db\Dialect + * * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ abstract class Dialect implements \Phalcon\Db\DialectInterface { - protected $escapeChar; + protected $_escapeChar; - protected $customFunctions; + protected $_customFunctions; /** - * Generate SQL to create a new savepoint + * Registers custom SQL functions * * @param string $name - * @return string + * @param callable $customFunction + * @return Dialect */ - public function createSavepoint(string $name): string {} + public function registerCustomFunction($name, $customFunction) {} /** - * Escape identifiers + * Returns registered functions + * + * @return array + */ + public function getCustomFunctions() {} + + /** + * Escape Schema * * @param string $str * @param string $escapeChar * @return string */ - final public function escape(string $str, string $escapeChar = null): string {} + public final function escapeSchema($str, $escapeChar = null) {} /** - * Escape Schema + * Escape identifiers * * @param string $str * @param string $escapeChar * @return string */ - final public function escapeSchema(string $str, string $escapeChar = null): string {} + public final function escape($str, $escapeChar = null) {} + + /** + * Generates the SQL for LIMIT clause + * + * + * $sql = $dialect->limit("SELECT FROM robots", 10); + * echo $sql; // SELECT FROM robots LIMIT 10 + * + * $sql = $dialect->limit("SELECT FROM robots", [10, 50]); + * echo $sql; // SELECT FROM robots LIMIT 10 OFFSET 50 + * + * + * @param string $sqlQuery + * @param mixed $number + * @return string + */ + public function limit($sqlQuery, $number) {} /** * Returns a SQL modified with a FOR UPDATE clause * - * ```php + * * $sql = $dialect->forUpdate("SELECT FROM robots"); - * * echo $sql; // SELECT FROM robots FOR UPDATE - * ``` + * * * @param string $sqlQuery * @return string */ - public function forUpdate(string $sqlQuery): string {} + public function forUpdate($sqlQuery) {} /** * Gets a list of columns with escaped identifiers * - * ```php + * * echo $dialect->getColumnList( * [ * "column1", * "column", * ] * ); - * ``` + * * * @param array $columnList * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string {} - - /** - * Returns registered functions - * - * @return array - */ - public function getCustomFunctions(): array {} + public final function getColumnList(array $columnList, $escapeChar = null, $bindCounts = null) {} /** * Resolve Column expressions @@ -89,7 +108,7 @@ public function getCustomFunctions(): array {} * @param mixed $bindCounts * @return string */ - final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string {} + public final function getSqlColumn($column, $escapeChar = null, $bindCounts = null) {} /** * Transforms an intermediate representation for an expression into a database system valid expression @@ -99,65 +118,16 @@ final public function getSqlColumn($column, string $escapeChar = null, $bindCoun * @param mixed $bindCounts * @return string */ - public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string {} + public function getSqlExpression(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Transform an intermediate representation of a schema/table into a - * database system valid expression + * Transform an intermediate representation of a schema/table into a database system valid expression * * @param mixed $table * @param string $escapeChar * @return string */ - final public function getSqlTable($table, string $escapeChar = null): string {} - - /** - * Generates the SQL for LIMIT clause - * - * ```php - * // SELECT FROM robots LIMIT 10 - * echo $dialect->limit( - * "SELECT FROM robots", - * 10 - * ); - * - * // SELECT FROM robots LIMIT 10 OFFSET 50 - * echo $dialect->limit( - * "SELECT FROM robots", - * [10, 50] - * ); - * ``` - * - * @param string $sqlQuery - * @param mixed $number - * @return string - */ - public function limit(string $sqlQuery, $number): string {} - - /** - * Registers custom SQL functions - * - * @param string $name - * @param callable $customFunction - * @return Dialect - */ - public function registerCustomFunction(string $name, $customFunction): Dialect {} - - /** - * Generate SQL to release a savepoint - * - * @param string $name - * @return string - */ - public function releaseSavepoint(string $name): string {} - - /** - * Generate SQL to rollback a savepoint - * - * @param string $name - * @return string - */ - public function rollbackSavepoint(string $name): string {} + public final function getSqlTable($table, $escapeChar = null) {} /** * Builds a SELECT statement @@ -165,230 +135,222 @@ public function rollbackSavepoint(string $name): string {} * @param array $definition * @return string */ - public function select(array $definition): string {} + public function select(array $definition) {} /** * Checks whether the platform supports savepoints * * @return bool */ - public function supportsSavepoints(): bool {} + public function supportsSavepoints() {} /** * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsReleaseSavepoints(): bool {} + public function supportsReleaseSavepoints() {} /** - * Returns the size of the column enclosed in parentheses - * - * @param ColumnInterface $column - * @return string - */ - protected function getColumnSize(ColumnInterface $column): string {} - - /** - * Returns the column size and scale enclosed in parentheses + * Generate SQL to create a new savepoint * - * @param ColumnInterface $column + * @param string $name * @return string */ - protected function getColumnSizeAndScale(ColumnInterface $column): string {} + public function createSavepoint($name) {} /** - * Checks the column type and if not string it returns the type reference + * Generate SQL to release a savepoint * - * @param ColumnInterface $column + * @param string $name * @return string */ - protected function checkColumnType(ColumnInterface $column): string {} + public function releaseSavepoint($name) {} /** - * Checks the column type and returns the updated SQL statement + * Generate SQL to rollback a savepoint * - * @param ColumnInterface $column + * @param string $name * @return string */ - protected function checkColumnTypeSql(ColumnInterface $column): string {} + public function rollbackSavepoint($name) {} /** - * Resolve + * Resolve Column expressions * * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionAll(array $expression, string $escapeChar = null): string {} + protected final function getSqlExpressionScalar(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve binary operations expressions + * Resolve object expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionObject(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve CASE expressions + * Resolve qualified expressions * * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionQualified(array $expression, $escapeChar = null) {} /** - * Resolve CAST of values + * Resolve binary operations expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionBinaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve CONVERT of values encodings + * Resolve unary operations expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionUnaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve a FROM clause + * Resolve function calls * - * @param mixed $expression + * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionFrom($expression, string $escapeChar = null): string {} + protected final function getSqlExpressionFunctionCall(array $expression, $escapeChar = null, $bindCounts) {} /** - * Resolve function calls + * Resolve Lists * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string {} + protected final function getSqlExpressionList(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve a GROUP BY clause + * Resolve * - * @param mixed $expression + * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionAll(array $expression, $escapeChar = null) {} /** - * Resolve a HAVING clause + * Resolve CAST of values * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionCastValue(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve a JOINs clause + * Resolve CONVERT of values encodings * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionConvertValue(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve a LIMIT clause + * Resolve CASE expressions * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionCase(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve Lists + * Resolve a FROM clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionFrom($expression, $escapeChar = null) {} /** - * Resolve object expressions + * Resolve a JOINs clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionJoins($expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve an ORDER BY clause + * Resolve a WHERE clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionWhere($expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve qualified expressions + * Resolve a GROUP BY clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionQualified(array $expression, string $escapeChar = null): string {} + protected final function getSqlExpressionGroupBy($expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve Column expressions + * Resolve a HAVING clause * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionHaving(array $expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve unary operations expressions + * Resolve an ORDER BY clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionOrderBy($expression, $escapeChar = null, $bindCounts = null) {} /** - * Resolve a WHERE clause + * Resolve a LIMIT clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string {} + protected final function getSqlExpressionLimit($expression, $escapeChar = null, $bindCounts = null) {} /** * Prepares column for this RDBMS @@ -398,7 +360,7 @@ final protected function getSqlExpressionWhere($expression, string $escapeChar = * @param string $escapeChar * @return string */ - protected function prepareColumnAlias(string $qualified, string $alias = null, string $escapeChar = null): string {} + protected function prepareColumnAlias($qualified, $alias = null, $escapeChar = null) {} /** * Prepares table for this RDBMS @@ -409,7 +371,7 @@ protected function prepareColumnAlias(string $qualified, string $alias = null, s * @param string $escapeChar * @return string */ - protected function prepareTable(string $table, string $schema = null, string $alias = null, string $escapeChar = null): string {} + protected function prepareTable($table, $schema = null, $alias = null, $escapeChar = null) {} /** * Prepares qualified for this RDBMS @@ -419,6 +381,6 @@ protected function prepareTable(string $table, string $schema = null, string $al * @param string $escapeChar * @return string */ - protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string {} + protected function prepareQualified($column, $domain = null, $escapeChar = null) {} } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 0e8e587d..5345aabd 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -3,105 +3,82 @@ namespace Phalcon\Db; /** + * Phalcon\Db\DialectInterface + * * Interface for Phalcon\Db dialects */ interface DialectInterface { /** - * Generates SQL to add a column to a table - * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @return string - */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string; - - /** - * Generates SQL to add an index to a table - * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference - * @return string - */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string; - - /** - * Generates SQL to add an index to a table + * Generates the SQL for LIMIT clause * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $sqlQuery + * @param mixed $number * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; + public function limit($sqlQuery, $number); /** - * Generates SQL to add the primary key to a table + * Returns a SQL modified with a FOR UPDATE clause * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $sqlQuery * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; + public function forUpdate($sqlQuery); /** - * Generate SQL to create a new savepoint + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $name + * @param string $sqlQuery * @return string */ - public function createSavepoint(string $name): string; + public function sharedLock($sqlQuery); /** - * Generates SQL to create a table + * Builds a SELECT statement * - * @param string $tableName - * @param string $schemaName * @param array $definition * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string; + public function select(array $definition); /** - * Generates SQL to create a view + * Gets a list of columns * - * @param string $viewName - * @param array $definition - * @param string $schemaName + * @param array $columnList * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string; + public function getColumnList(array $columnList); /** - * Generates SQL to describe a table + * Gets the column name in RDBMS * - * @param string $table - * @param string $schema + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function describeColumns(string $table, string $schema = null): string; + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column); /** - * Generates SQL to query indexes on a table + * Generates SQL to add a column to a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function describeIndexes(string $table, string $schema = null): string; + public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column); /** - * Generates SQL to query foreign keys on a table + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function describeReferences(string $table, string $schema = null): string; + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null); /** * Generates SQL to delete a column from a table @@ -111,17 +88,17 @@ public function describeReferences(string $table, string $schema = null): string * @param string $columnName * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string; + public function dropColumn($tableName, $schemaName, $columnName); /** - * Generates SQL to delete a foreign key from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $referenceName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string; + public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); /** * Generates SQL to delete an index from a table @@ -131,186 +108,183 @@ public function dropForeignKey(string $tableName, string $schemaName, string $re * @param string $indexName * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string; + public function dropIndex($tableName, $schemaName, $indexName); /** - * Generates SQL to delete primary key from a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string; + public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); /** - * Generates SQL to drop a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropTable(string $tableName, string $schemaName): string; + public function dropPrimaryKey($tableName, $schemaName); /** - * Generates SQL to drop a view + * Generates SQL to add an index to a table * - * @param string $viewName + * @param string $tableName * @param string $schemaName - * @param bool $ifExists + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string; + public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference); /** - * Returns a SQL modified with a FOR UPDATE clause + * Generates SQL to delete a foreign key from a table * - * @param string $sqlQuery + * @param string $tableName + * @param string $schemaName + * @param string $referenceName * @return string */ - public function forUpdate(string $sqlQuery): string; + public function dropForeignKey($tableName, $schemaName, $referenceName); /** - * Gets the column name in RDBMS + * Generates SQL to create a table * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @param string $tableName + * @param string $schemaName + * @param array $definition */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; + public function createTable($tableName, $schemaName, array $definition); /** - * Gets a list of columns + * Generates SQL to create a view * - * @param array $columnList + * @param string $viewName + * @param array $definition + * @param string $schemaName * @return string */ - public function getColumnList(array $columnList): string; + public function createView($viewName, array $definition, $schemaName = null); /** - * Returns registered functions - * - * @return array - */ - public function getCustomFunctions(): array; - - /** - * Transforms an intermediate representation for an expression into a - * database system valid expression + * Generates SQL to drop a table * - * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param string $tableName + * @param string $schemaName * @return string */ - public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string; + public function dropTable($tableName, $schemaName); /** - * Generates the SQL for LIMIT clause + * Generates SQL to drop a view * - * @param string $sqlQuery - * @param mixed $number + * @param string $viewName + * @param string $schemaName + * @param bool $ifExists * @return string */ - public function limit(string $sqlQuery, $number): string; + public function dropView($viewName, $schemaName = null, $ifExists = true); /** - * List all tables in database + * Generates SQL checking for the existence of a schema.table * + * @param string $tableName * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string; + public function tableExists($tableName, $schemaName = null); /** - * Generates SQL to modify a column in a table + * Generates SQL checking for the existence of a schema.view * - * @param string $tableName + * @param string $viewName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string; + public function viewExists($viewName, $schemaName = null); /** - * Registers custom SQL functions + * Generates SQL to describe a table * - * @param string $name - * @param callable $customFunction - * @return Dialect + * @param string $table + * @param string $schema + * @return string */ - public function registerCustomFunction(string $name, $customFunction): Dialect; + public function describeColumns($table, $schema = null); /** - * Generate SQL to release a savepoint + * List all tables in database * - * @param string $name + * @param string $schemaName * @return string */ - public function releaseSavepoint(string $name): string; + public function listTables($schemaName = null); /** - * Generate SQL to rollback a savepoint + * Generates SQL to query indexes on a table * - * @param string $name + * @param string $table + * @param string $schema * @return string */ - public function rollbackSavepoint(string $name): string; + public function describeIndexes($table, $schema = null); /** - * Builds a SELECT statement + * Generates SQL to query foreign keys on a table * - * @param array $definition + * @param string $table + * @param string $schema * @return string */ - public function select(array $definition): string; + public function describeReferences($table, $schema = null); /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Generates the SQL to describe the table creation options * - * @param string $sqlQuery + * @param string $table + * @param string $schema * @return string */ - public function sharedLock(string $sqlQuery): string; + public function tableOptions($table, $schema = null); /** - * Checks whether the platform supports releasing savepoints. + * Checks whether the platform supports savepoints * * @return bool */ - public function supportsReleaseSavepoints(): bool; + public function supportsSavepoints(); /** - * Checks whether the platform supports savepoints + * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsSavepoints(): bool; + public function supportsReleaseSavepoints(); /** - * Generates SQL checking for the existence of a schema.table + * Generate SQL to create a new savepoint * - * @param string $tableName - * @param string $schemaName + * @param string $name * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string; + public function createSavepoint($name); /** - * Generates the SQL to describe the table creation options + * Generate SQL to release a savepoint * - * @param string $table - * @param string $schema + * @param string $name * @return string */ - public function tableOptions(string $table, string $schema = null): string; + public function releaseSavepoint($name); /** - * Generates SQL checking for the existence of a schema.view + * Generate SQL to rollback a savepoint * - * @param string $viewName - * @param string $schemaName + * @param string $name * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string; + public function rollbackSavepoint($name); } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php deleted file mode 100644 index 3049c8f7..00000000 --- a/src/Phalcon/db/Enum.php +++ /dev/null @@ -1,62 +0,0 @@ - * // Define new unique index * $index_unique = new \Phalcon\Db\Index( * 'column_UNIQUE', * [ * 'column', - * 'column', + * 'column' * ], * 'UNIQUE' * ); @@ -22,67 +24,75 @@ * $index_primary = new \Phalcon\Db\Index( * 'PRIMARY', * [ - * 'column', + * 'column' * ] * ); * * // Add index to existing table * $connection->addIndex("robots", null, $index_unique); * $connection->addIndex("robots", null, $index_primary); - * ``` + * */ class Index implements \Phalcon\Db\IndexInterface { /** - * Index columns + * Index name * - * @var array + * @var string */ - protected $columns; + protected $_name; /** - * Index name + * Index columns * - * @var string + * @var array */ - protected $name; + protected $_columns; /** * Index type * * @var string */ - protected $type; + protected $_type; /** - * Index columns + * Index name * - * @return array + * @return string */ - public function getColumns(): array {} + public function getName() {} /** - * Index name + * Index columns * - * @return string + * @return array */ - public function getName(): string {} + public function getColumns() {} /** * Index type * * @return string */ - public function getType(): string {} + public function getType() {} /** * Phalcon\Db\Index constructor * * @param string $name * @param array $columns - * @param string $type + * @param mixed $type + */ + public function __construct($name, array $columns, $type = null) {} + + /** + * Restore a Phalcon\Db\Index object from export + * + * @param array $data + * @return IndexInterface */ - public function __construct(string $name, array $columns, string $type = '') {} + public static function __set_state(array $data) {} } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index 036ed333..46e8eea8 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -3,30 +3,40 @@ namespace Phalcon\Db; /** + * Phalcon\Db\IndexInterface + * * Interface for Phalcon\Db\Index */ interface IndexInterface { + /** + * Gets the index name + * + * @return string + */ + public function getName(); + /** * Gets the columns that corresponds the index * * @return array */ - public function getColumns(): array; + public function getColumns(); /** - * Gets the index name + * Gets the index type * * @return string */ - public function getName(): string; + public function getType(); /** - * Gets the index type + * Restore a Phalcon\Db\Index object from export * - * @return string + * @param array $data + * @return IndexInterface */ - public function getType(): string; + public static function __set_state(array $data); } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index c0e49136..17e3ecad 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -3,12 +3,14 @@ namespace Phalcon\Db; /** + * Phalcon\Db\Profiler + * * Instances of Phalcon\Db can generate execution profiles * on SQL statements sent to the relational database. Profiled * information includes execution time in milliseconds. * This helps you to identify bottlenecks in your applications. * - * ```php + * * use Phalcon\Db\Profiler; * use Phalcon\Events\Event; * use Phalcon\Events\Manager; @@ -50,82 +52,82 @@ * echo "Start Time: ", $profile->getInitialTime(), "\n"; * echo "Final Time: ", $profile->getFinalTime(), "\n"; * echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n"; - * ``` + * */ class Profiler { /** - * Active Phalcon\Db\Profiler\Item + * All the Phalcon\Db\Profiler\Item in the active profile * - * @var Phalcon\Db\Profiler\Item + * @var \Phalcon\Db\Profiler\Item[] */ - protected $activeProfile; + protected $_allProfiles; /** - * All the Phalcon\Db\Profiler\Item in the active profile + * Active Phalcon\Db\Profiler\Item * - * @var \Phalcon\Db\Profiler\Item[] + * @var Phalcon\Db\Profiler\Item */ - protected $allProfiles; + protected $_activeProfile; /** * Total time spent by all profiles to complete * * @var float */ - protected $totalSeconds = 0; + protected $_totalSeconds = 0; /** - * Returns the last profile executed in the profiler + * Starts the profile of a SQL sentence * - * @return \Phalcon\Db\Profiler\Item + * @param string $sqlStatement + * @param mixed $sqlVariables + * @param mixed $sqlBindTypes + * @return Profiler */ - public function getLastProfile(): Item {} + public function startProfile($sqlStatement, $sqlVariables = null, $sqlBindTypes = null) {} + + /** + * Stops the active profile + * + * @return Profiler + */ + public function stopProfile() {} /** * Returns the total number of SQL statements processed * * @return int */ - public function getNumberTotalStatements(): int {} + public function getNumberTotalStatements() {} /** * Returns the total time in seconds spent by the profiles * * @return double */ - public function getTotalElapsedSeconds(): float {} + public function getTotalElapsedSeconds() {} /** * Returns all the processed profiles * - * @return array|\Phalcon\Db\Profiler\Item[] + * @return \Phalcon\Db\Profiler\Item[] */ - public function getProfiles(): array {} + public function getProfiles() {} /** * Resets the profiler, cleaning up all the profiles * * @return Profiler */ - public function reset(): Profiler {} + public function reset() {} /** - * Starts the profile of a SQL sentence - * - * @param string $sqlStatement - * @param mixed $sqlVariables - * @param mixed $sqlBindTypes - * @return Profiler - */ - public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBindTypes = null): Profiler {} - - /** - * Stops the active profile + * Returns the last profile executed in the profiler * - * @return Profiler + * @return \Phalcon\Db\Profiler\Item */ - public function stopProfile(): Profiler {} + public function getLastProfile() {} } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index e4f65201..84723bd0 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -3,18 +3,20 @@ namespace Phalcon\Db; /** + * Phalcon\Db\RawValue + * * This class allows to insert/update raw data without quoting or formatting. * * The next example shows how to use the MySQL now() function as a field value. * - * ```php + * * $subscriber = new Subscribers(); * * $subscriber->email = "andres@phalconphp.com"; * $subscriber->createdAt = new \Phalcon\Db\RawValue("now()"); * * $subscriber->save(); - * ``` + * */ class RawValue { @@ -23,7 +25,7 @@ class RawValue * * @var string */ - protected $value; + protected $_value; /** @@ -31,14 +33,14 @@ class RawValue * * @return string */ - public function getValue(): string {} + public function getValue() {} /** * Raw value without quoting or formatting * * @return string */ - public function __toString(): string {} + public function __toString() {} /** * Phalcon\Db\RawValue constructor diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index 43eb5a35..c9874b1a 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -3,16 +3,18 @@ namespace Phalcon\Db; /** + * Phalcon\Db\Reference + * * Allows to define reference constraints on tables * - * ```php + * * $reference = new \Phalcon\Db\Reference( * "field_fk", * [ * "referencedSchema" => "invoicing", * "referencedTable" => "products", * "columns" => [ - * "producttype", + * "product_type", * "product_code", * ], * "referencedColumns" => [ @@ -21,122 +23,106 @@ * ], * ] * ); - * ``` + * */ class Reference implements \Phalcon\Db\ReferenceInterface { - /** - * Local reference columns - * - * @var array - */ - protected $columns; - /** * Constraint name * * @var string */ - protected $name; + protected $_name; - /** - * Referenced Columns - * - * @var array - */ - protected $referencedColumns; + + protected $_schemaName; + + + protected $_referencedSchema; /** - * Referenced Schema + * Referenced Table * * @var string */ - protected $referencedSchema; + protected $_referencedTable; /** - * Referenced Table + * Local reference columns * - * @var string + * @var array */ - protected $referencedTable; + protected $_columns; /** - * Schema name + * Referenced Columns * - * @var string + * @var array */ - protected $schemaName; + protected $_referencedColumns; /** * ON DELETE * - * @var string + * @var array */ - protected $onDelete; + protected $_onDelete; /** * ON UPDATE * - * @var string + * @var array */ - protected $onUpdate; + protected $_onUpdate; - /** - * Local reference columns - * - * @return array - */ - public function getColumns(): array {} - /** * Constraint name * * @return string */ - public function getName(): string {} + public function getName() {} + + + public function getSchemaName() {} - /** - * Referenced Columns - * - * @return array - */ - public function getReferencedColumns(): array {} + + public function getReferencedSchema() {} /** - * Referenced Schema + * Referenced Table * * @return string */ - public function getReferencedSchema(): string {} + public function getReferencedTable() {} /** - * Referenced Table + * Local reference columns * - * @return string + * @return array */ - public function getReferencedTable(): string {} + public function getColumns() {} /** - * Schema name + * Referenced Columns * - * @return string + * @return array */ - public function getSchemaName(): string {} + public function getReferencedColumns() {} /** * ON DELETE * - * @return string + * @return array */ - public function getOnDelete(): string {} + public function getOnDelete() {} /** * ON UPDATE * - * @return string + * @return array */ - public function getOnUpdate(): string {} + public function getOnUpdate() {} /** * Phalcon\Db\Reference constructor @@ -144,6 +130,14 @@ public function getOnUpdate(): string {} * @param string $name * @param array $definition */ - public function __construct(string $name, array $definition) {} + public function __construct($name, array $definition) {} + + /** + * Restore a Phalcon\Db\Reference object from export + * + * @param array $data + * @return ReferenceInterface + */ + public static function __set_state(array $data) {} } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 738157ac..735af8e1 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -3,65 +3,75 @@ namespace Phalcon\Db; /** + * Phalcon\Db\Reference + * * Interface for Phalcon\Db\Reference */ interface ReferenceInterface { /** - * Gets local columns which reference is based + * Gets the index name * - * @return array + * @return string */ - public function getColumns(): array; + public function getName(); /** - * Gets the index name + * Gets the schema where referenced table is * * @return string */ - public function getName(): string; + public function getSchemaName(); /** - * Gets the referenced on delete + * Gets the schema where referenced table is * * @return string */ - public function getOnDelete(): string; + public function getReferencedSchema(); /** - * Gets the referenced on update + * Gets local columns which reference is based + * + * @return array + */ + public function getColumns(); + + /** + * Gets the referenced table * * @return string */ - public function getOnUpdate(): string; + public function getReferencedTable(); /** * Gets referenced columns * * @return array */ - public function getReferencedColumns(): array; + public function getReferencedColumns(); /** - * Gets the schema where referenced table is + * Gets the referenced on delete * * @return string */ - public function getReferencedSchema(): string; + public function getOnDelete(); /** - * Gets the referenced table + * Gets the referenced on update * * @return string */ - public function getReferencedTable(): string; + public function getOnUpdate(); /** - * Gets the schema where referenced table is + * Restore a Phalcon\Db\Reference object from export * - * @return string + * @param array $data + * @return ReferenceInterface */ - public function getSchemaName(): string; + public static function __set_state(array $data); } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index a6baa4b2..368397cc 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -3,75 +3,74 @@ namespace Phalcon\Db; /** + * Phalcon\Db\ResultInterface + * * Interface for Phalcon\Db\Result objects */ interface ResultInterface { /** - * Moves internal resultset cursor to another position letting us to fetch a - * certain row + * Allows to executes the statement again. Some database systems don't support scrollable cursors, + * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining * - * @param long $number + * @return boolean */ - public function dataSeek(int $number); + public function execute(); /** - * Allows to executes the statement again. Some database systems don't - * support scrollable cursors. So, as cursors are forward only, we need to - * execute the cursor again to fetch rows from the begining + * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * - * @return bool + * @return mixed */ - public function execute(): bool; + public function fetch(); /** - * Fetches an array/object of strings that corresponds to the fetched row, - * or FALSE if there are no more rows. This method is affected by the active - * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` + * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * * @return mixed */ - public function fetch(); + public function fetchArray(); /** - * Returns an array of arrays containing all the records in the result. This - * method is affected by the active fetch flag set using - * `Phalcon\Db\Result\Pdo::setFetchMode()` + * Returns an array of arrays containing all the records in the result + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * * @return array */ - public function fetchAll(): array; + public function fetchAll(); /** - * Returns an array of strings that corresponds to the fetched row, or FALSE - * if there are no more rows. This method is affected by the active fetch - * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` + * Gets number of rows returned by a resultset * - * @return mixed + * @return int */ - public function fetchArray(); + public function numRows(); /** - * Gets the internal PDO result object + * Moves internal resultset cursor to another position letting us to fetch a certain row * - * @return \PDOStatement + * @param int $number */ - public function getInternalResult(): \PDOStatement; + public function dataSeek($number); /** - * Gets number of rows returned by a resultset + * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * @return int + * @param int $fetchMode + * @param mixed $colNoOrClassNameOrObject + * @param mixed $ctorargs + * @return bool */ - public function numRows(): int; + public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null); /** - * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() + * Gets the internal PDO result object * - * @param int $fetchMode - * @return bool + * @return \PDOStatement */ - public function setFetchMode(int $fetchMode): bool; + public function getInternalResult(); } diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/db/adapter/Pdo.php similarity index 75% rename from src/Phalcon/db/adapter/pdo/AbstractPdo.php rename to src/Phalcon/db/adapter/Pdo.php index 80be64a0..81eb783d 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/db/adapter/Pdo.php @@ -1,12 +1,13 @@ * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -18,77 +19,36 @@ * ]; * * $connection = new Mysql($config); - * ``` + * */ -abstract class AbstractPdo extends \Phalcon\Db\Adapter\AbstractAdapter +abstract class Pdo extends \Phalcon\Db\Adapter { - /** - * Last affected rows - */ - protected $affectedRows; - /** * PDO Handler * * @var \Pdo */ - protected $pdo; - - - /** - * Constructor for Phalcon\Db\Adapter\Pdo - * - * @param array $descriptor - */ - public function __construct(array $descriptor) {} - - /** - * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE - * executed in the database system - * - * ```php - * $connection->execute( - * "DELETE FROM robots" - * ); - * - * echo $connection->affectedRows(), " were deleted"; - * ``` - * - * @return int - */ - public function affectedRows(): int {} + protected $_pdo; /** - * Starts a transaction in the connection - * - * @param bool $nesting - * @return bool + * Last affected rows */ - public function begin(bool $nesting = true): bool {} + protected $_affectedRows; - /** - * Commits the active transaction in the connection - * - * @param bool $nesting - * @return bool - */ - public function commit(bool $nesting = true): bool {} /** - * Closes the active connection returning success. Phalcon automatically - * closes and destroys active connections when the request ends + * Constructor for Phalcon\Db\Adapter\Pdo * - * @return bool + * @param array $descriptor */ - public function close(): bool {} + public function __construct(array $descriptor) {} /** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo - * constructor. + * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. * * Call it when you need to restore a database connection. * - * ```php + * * use Phalcon\Db\Adapter\Pdo\Mysql; * * // Make a connection @@ -104,78 +64,43 @@ public function close(): bool {} * * // Reconnect * $connection->connect(); - * ``` + * * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null): bool {} - - /** - * Converts bound parameters such as :name: or ?1 into PDO bind params ? - * - * ```php - * print_r( - * $connection->convertBoundParams( - * "SELECT FROM robots WHERE name = :name:", - * [ - * "Bender", - * ] - * ) - * ); - * ``` - * - * @param string $sql - * @param array $params - * @return array - */ - public function convertBoundParams(string $sql, array $params = array()): array {} + public function connect(array $descriptor = null) {} /** - * Escapes a value to avoid SQL injections according to the active charset - * in the connection - * - * ```php - * $escapedStr = $connection->escapeString("some dangerous value"); - * ``` + * Returns a PDO prepared statement to be executed with 'executePrepared' * - * @param string $str - * @return string - */ - public function escapeString(string $str): string {} - - /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't - * return any rows + * + * use Phalcon\Db\Column; * - * ```php - * // Inserting data - * $success = $connection->execute( - * "INSERT INTO robots VALUES (1, 'Astro Boy')" + * $statement = $db->prepare( + * "SELECT FROM robots WHERE name = :name" * ); * - * $success = $connection->execute( - * "INSERT INTO robots VALUES (?, ?)", + * $result = $connection->executePrepared( + * $statement, * [ - * 1, - * "Astro Boy", + * "name" => "Voltron", + * ], + * [ + * "name" => Column::BIND_PARAM_INT, * ] * ); - * ``` + * * * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes - * @return bool + * @return \PDOStatement */ - public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool {} + public function prepare($sqlStatement) {} /** - * Executes a prepared statement binding. This function uses integer indexes - * starting from zero + * Executes a prepared statement binding. This function uses integer indexes starting from zero * - * ```php + * * use Phalcon\Db\Column; * * $statement = $db->prepare( @@ -191,55 +116,125 @@ public function execute(string $sqlStatement, $bindParams = null, $bindTypes = n * "name" => Column::BIND_PARAM_INT, * ] * ); - * ``` + * * * @param \PDOStatement $statement * @param array $placeholders - * @param mixed $dataTypes + * @param array $dataTypes * @return \PDOStatement */ - public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement {} + public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes) {} /** - * Return the error info, if any + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server is returning rows + * + * + * // Querying data + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = 'mechanical'" + * ); + * + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = ?", + * [ + * "mechanical", + * ] + * ); + * + * + * @param string $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes + * @return bool|\Phalcon\Db\ResultInterface */ - public function getErrorInfo() {} + public function query($sqlStatement, $bindParams = null, $bindTypes = null) {} /** - * Return internal PDO handler + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server doesn't return any rows * - * @return \Pdo + * + * // Inserting data + * $success = $connection->execute( + * "INSERT INTO robots VALUES (1, 'Astro Boy')" + * ); + * + * $success = $connection->execute( + * "INSERT INTO robots VALUES (?, ?)", + * [ + * 1, + * "Astro Boy", + * ] + * ); + * + * + * @param string $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes + * @return bool */ - public function getInternalHandler(): \Pdo {} + public function execute($sqlStatement, $bindParams = null, $bindTypes = null) {} /** - * Returns the current transaction nesting level + * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system + * + * + * $connection->execute( + * "DELETE FROM robots" + * ); + * + * echo $connection->affectedRows(), " were deleted"; + * * * @return int */ - public function getTransactionLevel(): int {} + public function affectedRows() {} /** - * Checks whether the connection is under a transaction + * Closes the active connection returning success. Phalcon automatically closes and destroys + * active connections when the request ends * - * ```php - * $connection->begin(); + * @return bool + */ + public function close() {} + + /** + * Escapes a value to avoid SQL injections according to the active charset in the connection * - * // true - * var_dump( - * $connection->isUnderTransaction() + * + * $escapedStr = $connection->escapeString("some dangerous value"); + * + * + * @param string $str + * @return string + */ + public function escapeString($str) {} + + /** + * Converts bound parameters such as :name: or ?1 into PDO bind params ? + * + * + * print_r( + * $connection->convertBoundParams( + * "SELECT FROM robots WHERE name = :name:", + * [ + * "Bender", + * ] + * ) * ); - * ``` + * * - * @return bool + * @param string $sql + * @param array $params + * @return array */ - public function isUnderTransaction(): bool {} + public function convertBoundParams($sql, array $params = array()) {} /** - * Returns the insert id for the auto_increment/serial column inserted in - * the latest executed SQL statement + * Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement * - * ```php + * * // Inserting a new robot * $success = $connection->insert( * "robots", @@ -255,78 +250,72 @@ public function isUnderTransaction(): bool {} * * // Getting the generated id * $id = $connection->lastInsertId(); - * ``` + * * - * @param mixed $sequenceName + * @param string $sequenceName * @return int|bool */ public function lastInsertId($sequenceName = null) {} /** - * Returns a PDO prepared statement to be executed with 'executePrepared' + * Starts a transaction in the connection * - * ```php - * use Phalcon\Db\Column; + * @param bool $nesting + * @return bool + */ + public function begin($nesting = true) {} + + /** + * Rollbacks the active transaction in the connection * - * $statement = $db->prepare( - * "SELECT FROM robots WHERE name = :name" - * ); + * @param bool $nesting + * @return bool + */ + public function rollback($nesting = true) {} + + /** + * Commits the active transaction in the connection * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] - * ); - * ``` + * @param bool $nesting + * @return bool + */ + public function commit($nesting = true) {} + + /** + * Returns the current transaction nesting level * - * @param string $sqlStatement - * @return \PDOStatement + * @return int */ - public function prepare(string $sqlStatement): \PDOStatement {} + public function getTransactionLevel() {} /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server is - * returning rows + * Checks whether the connection is under a transaction * - * ```php - * // Querying data - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = 'mechanical'" - * ); + * + * $connection->begin(); * - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = ?", - * [ - * "mechanical", - * ] + * // true + * var_dump( + * $connection->isUnderTransaction() * ); - * ``` + * * - * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes - * @return bool|\Phalcon\Db\ResultInterface + * @return bool */ - public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) {} + public function isUnderTransaction() {} /** - * Rollbacks the active transaction in the connection + * Return internal PDO handler * - * @param bool $nesting - * @return bool + * @return \Pdo */ - public function rollback(bool $nesting = true): bool {} + public function getInternalHandler() {} /** - * Returns PDO adapter DSN defaults as a key-value map. + * Return the error info, if any * * @return array */ - abstract protected function getDsnDefaults(): array; + public function getErrorInfo() {} } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php deleted file mode 100644 index 1d71f837..00000000 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class PdoFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * Constructor - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Factory to create an instace from a Config object - * - * @param mixed $config - * @return mixed - */ - public function load($config) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @param array $options - * @return \Phalcon\Annotations\Adapter\AbstractAdapter - */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} - - /** - * Returns the available adapters - * - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/db/adapter/pdo/Factory.php b/src/Phalcon/db/adapter/pdo/Factory.php new file mode 100644 index 00000000..1a089408 --- /dev/null +++ b/src/Phalcon/db/adapter/pdo/Factory.php @@ -0,0 +1,31 @@ + + * use Phalcon\Db\Adapter\Pdo\Factory; + * + * $options = [ + * "host" => "localhost", + * "dbname" => "blog", + * "port" => 3306, + * "username" => "sigma", + * "password" => "secret", + * "adapter" => "mysql", + * ]; + * $db = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return \Phalcon\Db\AdapterInterface + */ + public static function load($config) {} + +} diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index 7e03f623..9f505dd2 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -3,9 +3,11 @@ namespace Phalcon\Db\Adapter\Pdo; /** + * Phalcon\Db\Adapter\Pdo\Mysql + * * Specific functions for the Mysql database system * - * ```php + * * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -17,81 +19,70 @@ * ]; * * $connection = new Mysql($config); - * ``` + * */ -class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Mysql extends \Phalcon\Db\Adapter\Pdo { - /** - * @var string - */ - protected $dialectType = 'mysql'; - /** - * @var string - */ - protected $type = 'mysql'; + protected $_type = 'mysql'; - /** - * Adds a foreign key to a table - * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference - * @return bool - */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool {} + protected $_dialectType = 'mysql'; + /** * Returns an array of Phalcon\Db\Column objects describing a table * - * ```php + * * print_r( * $connection->describeColumns("posts") * ); - * ``` + * * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return \Phalcon\Db\ColumnInterface[] */ - public function describeColumns(string $table, string $schema = null): array {} + public function describeColumns($table, $schema = null) {} /** * Lists table indexes * - * ```php + * * print_r( * $connection->describeIndexes("robots_parts") * ); - * ``` + * * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return \Phalcon\Db\IndexInterface[] */ - public function describeIndexes(string $table, string $schema = null): array {} + public function describeIndexes($table, $schema = null) {} /** * Lists table references * - * ```php + * * print_r( * $connection->describeReferences("robots_parts") * ); - * ``` + * * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return \Phalcon\Db\ReferenceInterface[] */ - public function describeReferences(string $table, string $schema = null): array {} + public function describeReferences($table, $schema = null) {} /** - * Returns PDO adapter DSN defaults as a key-value map. + * Adds a foreign key to a table * - * @return array + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ReferenceInterface $reference + * @return bool */ - protected function getDsnDefaults(): array {} + public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 16662427..25eacf0b 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -3,9 +3,11 @@ namespace Phalcon\Db\Adapter\Pdo; /** + * Phalcon\Db\Adapter\Pdo\Postgresql + * * Specific functions for the Postgresql database system * - * ```php + * * use Phalcon\Db\Adapter\Pdo\Postgresql; * * $config = [ @@ -17,36 +19,40 @@ * ]; * * $connection = new Postgresql($config); - * ``` + * */ -class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Postgresql extends \Phalcon\Db\Adapter\Pdo { - /** - * @var string - */ - protected $dialectType = 'postgresql'; - /** - * @var string - */ - protected $type = 'pgsql'; + protected $_type = 'pgsql'; + + + protected $_dialectType = 'postgresql'; /** - * Constructor for Phalcon\Db\Adapter\Pdo\Postgresql + * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. + * Call it when you need to restore a database connection. * * @param array $descriptor + * @return bool */ - public function __construct(array $descriptor) {} + public function connect(array $descriptor = null) {} /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo - * constructor. Call it when you need to restore a database connection. + * Returns an array of Phalcon\Db\Column objects describing a table * - * @param array $descriptor - * @return bool + * + * print_r( + * $connection->describeColumns("posts") + * ); + * + * + * @param string $table + * @param string $schema + * @return \Phalcon\Db\ColumnInterface[] */ - public function connect(array $descriptor = null): bool {} + public function describeColumns($table, $schema = null) {} /** * Creates a table @@ -56,42 +62,30 @@ public function connect(array $descriptor = null): bool {} * @param array $definition * @return bool */ - public function createTable(string $tableName, string $schemaName, array $definition): bool {} + public function createTable($tableName, $schemaName, array $definition) {} /** - * Returns an array of Phalcon\Db\Column objects describing a table - * - * ```php - * print_r( - * $connection->describeColumns("posts") - * ); - * ``` + * Modifies a table column based on a definition * - * @param string $table - * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn + * @return bool */ - public function describeColumns(string $table, string $schema = null): array {} + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} /** - * Lists table references + * Check whether the database system requires an explicit value for identity columns * - * ```php - * print_r( - * $connection->describeReferences("robots_parts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return bool */ - public function describeReferences(string $table, string $schema = null): array {} + public function useExplicitIdValue() {} /** * Returns the default identity value to be inserted in an identity column * - * ```php + * * // Inserting a new robot with a valid default value for the column 'id' * $success = $connection->insert( * "robots", @@ -106,44 +100,17 @@ public function describeReferences(string $table, string $schema = null): array * "year", * ] * ); - * ``` + * * * @return \Phalcon\Db\RawValue */ - public function getDefaultIdValue(): RawValue {} + public function getDefaultIdValue() {} /** - * Modifies a table column based on a definition + * Check whether the database system requires a sequence to produce auto-numeric values * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} - - /** - * Check whether the database system requires a sequence to produce - * auto-numeric values - * - * @return bool - */ - public function supportSequences(): bool {} - - /** - * Check whether the database system requires an explicit value for identity - * columns - * - * @return bool - */ - public function useExplicitIdValue(): bool {} - - /** - * Returns PDO adapter DSN defaults as a key-value map. - * - * @return array - */ - protected function getDsnDefaults(): array {} + public function supportSequences() {} } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index 8acf592d..bcf551fa 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -3,9 +3,11 @@ namespace Phalcon\Db\Adapter\Pdo; /** + * Phalcon\Db\Adapter\Pdo\Sqlite + * * Specific functions for the Sqlite database system * - * ```php + * * use Phalcon\Db\Adapter\Pdo\Sqlite; * * $connection = new Sqlite( @@ -13,81 +15,79 @@ * "dbname" => "/tmp/test.sqlite", * ] * ); - * ``` + * */ -class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Sqlite extends \Phalcon\Db\Adapter\Pdo { - /** - * @var string - */ - protected $dialectType = 'sqlite'; - /** - * @var string - */ - protected $type = 'sqlite'; + protected $_type = 'sqlite'; - /** - * Constructor for Phalcon\Db\Adapter\Pdo\Sqlite - * - * @param array $descriptor - */ - public function __construct(array $descriptor) {} + protected $_dialectType = 'sqlite'; + /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo - * constructor. Call it when you need to restore a database connection. + * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. + * Call it when you need to restore a database connection. * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null): bool {} + public function connect(array $descriptor = null) {} /** * Returns an array of Phalcon\Db\Column objects describing a table * - * ```php + * * print_r( * $connection->describeColumns("posts") * ); - * ``` + * * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return \Phalcon\Db\ColumnInterface[] */ - public function describeColumns(string $table, string $schema = null): array {} + public function describeColumns($table, $schema = null) {} /** * Lists table indexes * - * ```php + * * print_r( * $connection->describeIndexes("robots_parts") * ); - * ``` + * * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return \Phalcon\Db\IndexInterface[] */ - public function describeIndexes(string $table, string $schema = null): array {} + public function describeIndexes($table, $schema = null) {} /** * Lists table references * + * @param string table + * @param string schema + * @return Phalcon\Db\ReferenceInterface[] * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return \Phalcon\Db\ReferenceInterface[] + */ + public function describeReferences($table, $schema = null) {} + + /** + * Check whether the database system requires an explicit value for identity columns + * + * @return bool */ - public function describeReferences(string $table, string $schema = null): array {} + public function useExplicitIdValue() {} /** - * Returns the default value to make the RBDM use the default value declared - * in the table definition + * Returns the default value to make the RBDM use the default value declared in the table definition * - * ```php + * * // Inserting a new robot with a valid default value for the column 'year' * $success = $connection->insert( * "robots", @@ -100,25 +100,10 @@ public function describeReferences(string $table, string $schema = null): array * "year", * ] * ); - * ``` + * * * @return \Phalcon\Db\RawValue */ - public function getDefaultValue(): RawValue {} - - /** - * Check whether the database system requires an explicit value for identity - * columns - * - * @return bool - */ - public function useExplicitIdValue(): bool {} - - /** - * Returns PDO adapter DSN defaults as a key-value map. - * - * @return array - */ - protected function getDsnDefaults(): array {} + public function getDefaultValue() {} } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 85905487..7f2170b0 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -3,118 +3,103 @@ namespace Phalcon\Db\Dialect; /** + * Phalcon\Db\Dialect\Mysql + * * Generates database specific SQL for the MySQL RDBMS */ class Mysql extends \Phalcon\Db\Dialect { - /** - * @var string - */ - protected $escapeChar = '`'; + + protected $_escapeChar = '`'; /** - * Generates SQL to add a column to a table + * Gets the column name in MySQL * - * @param string $tableName - * @param string $schemaName * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to add a column to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to modify a column in a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $columnName * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function dropColumn($tableName, $schemaName, $columnName) {} /** - * Generates SQL to create a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to create a view + * Generates SQL to delete an index from a table * - * @param string $viewName - * @param array $definition + * @param string $tableName * @param string $schemaName + * @param string $indexName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} - - /** - * Generates SQL describing a table - * - * ```php - * print_r( - * $dialect->describeColumns("posts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return string - */ - public function describeColumns(string $table, string $schema = null): string {} + public function dropIndex($tableName, $schemaName, $indexName) {} /** - * Generates SQL to query indexes on a table + * Generates SQL to add the primary key to a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to delete primary key from a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function dropPrimaryKey($tableName, $schemaName) {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} /** * Generates SQL to delete a foreign key from a table @@ -124,26 +109,26 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey($tableName, $schemaName, $referenceName) {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function createTable($tableName, $schemaName, array $definition) {} /** - * Generates SQL to delete primary key from a table + * Generates SQL to truncate a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function truncateTable($tableName, $schemaName) {} /** * Generates SQL to drop a table @@ -153,121 +138,115 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable($tableName, $schemaName = null, $ifExists = true) {} /** - * Generates SQL to drop a view + * Generates SQL to create a view * * @param string $viewName + * @param array $definition * @param string $schemaName - * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function createView($viewName, array $definition, $schemaName = null) {} /** - * Gets the column name in MySQL + * Generates SQL to drop a view * - * @param \Phalcon\Db\ColumnInterface $column + * @param string $viewName + * @param string $schemaName + * @param bool $ifExists * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function dropView($viewName, $schemaName = null, $ifExists = true) {} /** - * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. + * Generates SQL checking for the existence of a schema.table * - * @return string - */ - public function getForeignKeyChecks(): string {} - - /** - * List all tables in database + * + * echo $dialect->tableExists("posts", "blog"); * - * ```php - * print_r( - * $dialect->listTables("blog") - * ); - * ``` + * echo $dialect->tableExists("posts"); + * * + * @param string $tableName * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function tableExists($tableName, $schemaName = null) {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.view * + * @param string $viewName * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function viewExists($viewName, $schemaName = null) {} /** - * Generates SQL to modify a column in a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * + * print_r( + * $dialect->describeColumns("posts") + * ); + * + * + * @param string $table + * @param string $schema * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function describeColumns($table, $schema = null) {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause - * - * ```php - * $sql = $dialect->sharedLock("SELECT FROM robots"); + * List all tables in database * - * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE - * ``` + * + * print_r( + * $dialect->listTables("blog") + * ); + * * - * @param string $sqlQuery + * @param string $schemaName * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function listTables($schemaName = null) {} /** - * Generates SQL checking for the existence of a schema.table - * - * ```php - * echo $dialect->tableExists("posts", "blog"); - * - * echo $dialect->tableExists("posts"); - * ``` + * Generates the SQL to list all views of a schema or user * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function listViews($schemaName = null) {} /** - * Generates the SQL to describe the table creation options + * Generates SQL to query indexes on a table * * @param string $table * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function describeIndexes($table, $schema = null) {} /** - * Generates SQL to truncate a table + * Generates SQL to query foreign keys on a table * - * @param string $tableName - * @param string $schemaName + * @param string $table + * @param string $schema * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function describeReferences($table, $schema = null) {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to describe the table creation options * - * @param string $viewName - * @param string $schemaName + * @param string $table + * @param string $schema * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} + public function tableOptions($table, $schema = null) {} /** * Generates SQL to add the table creation options @@ -275,23 +254,26 @@ public function viewExists(string $viewName, string $schemaName = null): string * @param array $definition * @return string */ - protected function getTableOptions(array $definition): string {} + protected function _getTableOptions(array $definition) {} /** - * Checks if the size and/or scale are present and encloses those values - * in parentheses if need be + * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. * - * @param \Phalcon\Db\ColumnInterface $column * @return string */ - private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string {} + public function getForeignKeyChecks() {} /** - * Checks if a column is unsigned or not and returns the relevant SQL syntax + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param \Phalcon\Db\ColumnInterface $column + * + * $sql = $dialect->sharedLock("SELECT FROM robots"); + * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE + * + * + * @param string $sqlQuery * @return string */ - private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string {} + public function sharedLock($sqlQuery) {} } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 2ef5c5ff..ff800073 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -3,118 +3,103 @@ namespace Phalcon\Db\Dialect; /** + * Phalcon\Db\Dialect\Postgresql + * * Generates database specific SQL for the PostgreSQL RDBMS */ class Postgresql extends \Phalcon\Db\Dialect { - /** - * @var string - */ - protected $escapeChar = '\\\"'; + + protected $_escapeChar = '\\\"'; /** - * Generates SQL to add a column to a table + * Gets the column name in PostgreSQL * - * @param string $tableName - * @param string $schemaName * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to add a column to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to modify a column in a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $columnName * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function dropColumn($tableName, $schemaName, $columnName) {} /** - * Generates SQL to create a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to create a view + * Generates SQL to delete an index from a table * - * @param string $viewName - * @param array $definition + * @param string $tableName * @param string $schemaName + * @param string $indexName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} - - /** - * Generates SQL describing a table - * - * ```php - * print_r( - * $dialect->describeColumns("posts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return string - */ - public function describeColumns(string $table, string $schema = null): string {} + public function dropIndex($tableName, $schemaName, $indexName) {} /** - * Generates SQL to query indexes on a table + * Generates SQL to add the primary key to a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to delete primary key from a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function dropPrimaryKey($tableName, $schemaName) {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} /** * Generates SQL to delete a foreign key from a table @@ -124,26 +109,26 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey($tableName, $schemaName, $referenceName) {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName - * @return string + * @param array $definition + * @return string|array */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function createTable($tableName, $schemaName, array $definition) {} /** - * Generates SQL to delete primary key from a table + * Generates SQL to truncate a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function truncateTable($tableName, $schemaName) {} /** * Generates SQL to drop a table @@ -153,120 +138,135 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable($tableName, $schemaName = null, $ifExists = true) {} /** - * Generates SQL to drop a view + * Generates SQL to create a view * * @param string $viewName + * @param array $definition * @param string $schemaName - * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function createView($viewName, array $definition, $schemaName = null) {} /** - * Gets the column name in PostgreSQL + * Generates SQL to drop a view * - * @param \Phalcon\Db\ColumnInterface $column + * @param string $viewName + * @param string $schemaName + * @param bool $ifExists * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function dropView($viewName, $schemaName = null, $ifExists = true) {} /** - * List all tables in database + * Generates SQL checking for the existence of a schema.table * - * ```php - * print_r( - * $dialect->listTables("blog") - * ); - * ``` + * + * echo $dialect->tableExists("posts", "blog"); * + * echo $dialect->tableExists("posts"); + * + * + * @param string $tableName * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function tableExists($tableName, $schemaName = null) {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.view * + * @param string $viewName * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function viewExists($viewName, $schemaName = null) {} /** - * Generates SQL to modify a column in a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * + * print_r( + * $dialect->describeColumns("posts") + * ); + * + * + * @param string $table + * @param string $schema * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function describeColumns($table, $schema = null) {} /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query + * List all tables in database * - * @param string $sqlQuery + * + * print_r( + * $dialect->listTables("blog") + * ); + * + * + * @param string $schemaName * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function listTables($schemaName = null) {} /** - * Generates SQL checking for the existence of a schema.table - * - * ```php - * echo $dialect->tableExists("posts", "blog"); - * - * echo $dialect->tableExists("posts"); - * ``` + * Generates the SQL to list all views of a schema or user * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function listViews($schemaName = null) {} /** - * Generates the SQL to describe the table creation options + * Generates SQL to query indexes on a table * * @param string $table * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function describeIndexes($table, $schema = null) {} /** - * Generates SQL to truncate a table + * Generates SQL to query foreign keys on a table * - * @param string $tableName - * @param string $schemaName + * @param string $table + * @param string $schema * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function describeReferences($table, $schema = null) {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to describe the table creation options * - * @param string $viewName - * @param string $schemaName + * @param string $table + * @param string $schema * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} + public function tableOptions($table, $schema = null) {} /** * @param \Phalcon\Db\ColumnInterface $column * @return string */ - protected function castDefault(\Phalcon\Db\ColumnInterface $column): string {} + protected function _castDefault(\Phalcon\Db\ColumnInterface $column) {} /** * @param array $definition * @return string */ - protected function getTableOptions(array $definition): string {} + protected function _getTableOptions(array $definition) {} + + /** + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query + * + * @param string $sqlQuery + * @return string + */ + public function sharedLock($sqlQuery) {} } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index f00fed05..f71e0ab8 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -3,126 +3,103 @@ namespace Phalcon\Db\Dialect; /** - * Generates database specific SQL for the SQLite RDBMS + * Phalcon\Db\Dialect\Sqlite + * + * Generates database specific SQL for the Sqlite RDBMS */ class Sqlite extends \Phalcon\Db\Dialect { - /** - * @var string - */ - protected $escapeChar = '\\\"'; + + protected $_escapeChar = '\\\"'; /** - * Generates SQL to add a column to a table + * Gets the column name in SQLite * - * @param string $tableName - * @param string $schemaName * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to add a column to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} /** - * Generates SQL to add an index to a table + * Generates SQL to modify a column in a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $columnName * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function dropColumn($tableName, $schemaName, $columnName) {} /** - * Generates SQL to create a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to create a view + * Generates SQL to delete an index from a table * - * @param string $viewName - * @param array $definition + * @param string $tableName * @param string $schemaName + * @param string $indexName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} - - /** - * Generates SQL describing a table - * - * ```php - * print_r( - * $dialect->describeColumns("posts") - * ); - * ``` - * - * @param string $table - * @param string $schema - * @return string - */ - public function describeColumns(string $table, string $schema = null): string {} - - /** - * Generates SQL to query indexes detail on a table - * - * @param string $index - * @return string - */ - public function describeIndex(string $index): string {} + public function dropIndex($tableName, $schemaName, $indexName) {} /** - * Generates SQL to query indexes on a table + * Generates SQL to add the primary key to a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to delete primary key from a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function dropPrimaryKey($tableName, $schemaName) {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} /** * Generates SQL to delete a foreign key from a table @@ -132,26 +109,26 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey($tableName, $schemaName, $referenceName) {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function createTable($tableName, $schemaName, array $definition) {} /** - * Generates SQL to delete primary key from a table + * Generates SQL to truncate a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function truncateTable($tableName, $schemaName) {} /** * Generates SQL to drop a table @@ -161,7 +138,17 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + + /** + * Generates SQL to create a view + * + * @param string $viewName + * @param array $definition + * @param string $schemaName + * @return string + */ + public function createView($viewName, array $definition, $schemaName = null) {} /** * Generates SQL to drop a view @@ -171,54 +158,60 @@ public function dropTable(string $tableName, string $schemaName = null, bool $if * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function dropView($viewName, $schemaName = null, $ifExists = true) {} /** - * Returns a SQL modified with a FOR UPDATE clause. For SQLite it returns - * the original query + * Generates SQL checking for the existence of a schema.table * - * @param string $sqlQuery + * + * echo $dialect->tableExists("posts", "blog"); + * + * echo $dialect->tableExists("posts"); + * + * + * @param string $tableName + * @param string $schemaName * @return string */ - public function forUpdate(string $sqlQuery): string {} + public function tableExists($tableName, $schemaName = null) {} /** - * Gets the column name in SQLite + * Generates SQL checking for the existence of a schema.view * - * @param \Phalcon\Db\ColumnInterface $column + * @param string $viewName + * @param string $schemaName * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function viewExists($viewName, $schemaName = null) {} /** - * Generates the SQL to get query list of indexes + * Generates SQL describing a table * - * ```php + * * print_r( - * $dialect->listIndexesSql("blog") + * $dialect->describeColumns("posts") * ); - * ``` + * * * @param string $table * @param string $schema - * @param string $keyName * @return string */ - public function listIndexesSql(string $table, string $schema = null, string $keyName = null): string {} + public function describeColumns($table, $schema = null) {} /** * List all tables in database * - * ```php + * * print_r( * $dialect->listTables("blog") * ); - * ``` + * * * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function listTables($schemaName = null) {} /** * Generates the SQL to list all views of a schema or user @@ -226,68 +219,66 @@ public function listTables(string $schemaName = null): string {} * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function listViews($schemaName = null) {} /** - * Generates SQL to modify a column in a table + * Generates the SQL to get query list of indexes * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * + * print_r( + * $dialect->listIndexesSql("blog") + * ); + * + * + * @param string $table + * @param string $schema + * @param string $keyName * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function listIndexesSql($table, $schema = null, $keyName = null) {} /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query + * Generates SQL to query indexes on a table * - * @param string $sqlQuery + * @param string $table + * @param string $schema * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function describeIndexes($table, $schema = null) {} /** - * Generates SQL checking for the existence of a schema.table - * - * ```php - * echo $dialect->tableExists("posts", "blog"); - * - * echo $dialect->tableExists("posts"); - * ``` + * Generates SQL to query indexes detail on a table * - * @param string $tableName - * @param string $schemaName + * @param string $index * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function describeIndex($index) {} /** - * Generates the SQL to describe the table creation options + * Generates SQL to query foreign keys on a table * * @param string $table * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function describeReferences($table, $schema = null) {} /** - * Generates SQL to truncate a table + * Generates the SQL to describe the table creation options * - * @param string $tableName - * @param string $schemaName + * @param string $table + * @param string $schema * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function tableOptions($table, $schema = null) {} /** - * Generates SQL checking for the existence of a schema.view + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query * - * @param string $viewName - * @param string $schemaName + * @param string $sqlQuery * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} + public function sharedLock($sqlQuery) {} } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 8e0bce9e..80149305 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -3,73 +3,75 @@ namespace Phalcon\Db\Profiler; /** + * Phalcon\Db\Profiler\Item + * * This class identifies each profile in a Phalcon\Db\Profiler */ class Item { /** - * Timestamp when the profile ended + * SQL statement related to the profile * - * @var double + * @var string */ - protected $finalTime; + protected $_sqlStatement; /** - * Timestamp when the profile started + * SQL variables related to the profile * - * @var double + * @var array */ - protected $initialTime; + protected $_sqlVariables; /** * SQL bind types related to the profile * * @var array */ - protected $sqlBindTypes; + protected $_sqlBindTypes; /** - * SQL statement related to the profile + * Timestamp when the profile started * - * @var string + * @var double */ - protected $sqlStatement; + protected $_initialTime; /** - * SQL variables related to the profile + * Timestamp when the profile ended * - * @var array + * @var double */ - protected $sqlVariables; + protected $_finalTime; /** - * Timestamp when the profile ended + * SQL statement related to the profile * - * @param double $finalTime + * @param string $sqlStatement */ - public function setFinalTime(float $finalTime) {} + public function setSqlStatement($sqlStatement) {} /** - * Timestamp when the profile ended + * SQL statement related to the profile * - * @return double + * @return string */ - public function getFinalTime(): float {} + public function getSqlStatement() {} /** - * Timestamp when the profile started + * SQL variables related to the profile * - * @param double $initialTime + * @param array $sqlVariables */ - public function setInitialTime(float $initialTime) {} + public function setSqlVariables(array $sqlVariables) {} /** - * Timestamp when the profile started + * SQL variables related to the profile * - * @return double + * @return array */ - public function getInitialTime(): float {} + public function getSqlVariables() {} /** * SQL bind types related to the profile @@ -83,41 +85,41 @@ public function setSqlBindTypes(array $sqlBindTypes) {} * * @return array */ - public function getSqlBindTypes(): array {} + public function getSqlBindTypes() {} /** - * SQL statement related to the profile + * Timestamp when the profile started * - * @param string $sqlStatement + * @param double $initialTime */ - public function setSqlStatement(string $sqlStatement) {} + public function setInitialTime($initialTime) {} /** - * SQL statement related to the profile + * Timestamp when the profile started * - * @return string + * @return double */ - public function getSqlStatement(): string {} + public function getInitialTime() {} /** - * SQL variables related to the profile + * Timestamp when the profile ended * - * @param array $sqlVariables + * @param double $finalTime */ - public function setSqlVariables(array $sqlVariables) {} + public function setFinalTime($finalTime) {} /** - * SQL variables related to the profile + * Timestamp when the profile ended * - * @return array + * @return double */ - public function getSqlVariables(): array {} + public function getFinalTime() {} /** * Returns the total time in seconds spent by the profile * * @return double */ - public function getTotalElapsedSeconds(): float {} + public function getTotalElapsedSeconds() {} } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 42675919..b7d9bdfa 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -3,109 +3,89 @@ namespace Phalcon\Db\Result; /** + * Phalcon\Db\Result\Pdo + * * Encapsulates the resultset internals * - * ```php + * * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Db\Enum::FETCH_NUM + * \Phalcon\Db::FETCH_NUM * ); * * while ($robot = $result->fetchArray()) { * print_r($robot); * } - * ``` + * */ class Pdo implements \Phalcon\Db\ResultInterface { - protected $bindParams; - - - protected $bindTypes; + protected $_connection; - protected $connection; + protected $_result; /** * Active fetch mode */ - protected $fetchMode = Enum::FETCH_OBJ; + protected $_fetchMode = Db::FETCH_OBJ; /** * Internal resultset * * @var \PDOStatement */ - protected $pdoStatement; + protected $_pdoStatement; + + + protected $_sqlStatement; - protected $result; + protected $_bindParams; - protected $rowCount = false; + protected $_bindTypes; - protected $sqlStatement; + protected $_rowCount = false; /** * Phalcon\Db\Result\Pdo constructor * - * @param Db\AdapterInterface $connection + * @param \Phalcon\Db\AdapterInterface $connection * @param \PDOStatement $result - * @param mixed $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes + * @param string $sqlStatement + * @param array $bindParams + * @param array $bindTypes */ public function __construct(Db\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} /** - * Moves internal resultset cursor to another position letting us to fetch a - * certain row - * - * ```php - * $result = $connection->query( - * "SELECT FROM robots ORDER BY name" - * ); - * - * // Move to third row on result - * $result->dataSeek(2); - * - * // Fetch third row - * $row = $result->fetch(); - * ``` - * - * @param long $number - */ - public function dataSeek(int $number) {} - - /** - * Allows to execute the statement again. Some database systems don't - * support scrollable cursors. So, as cursors are forward only, we need to - * execute the cursor again to fetch rows from the begining + * Allows to execute the statement again. Some database systems don't support scrollable cursors, + * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining * * @return bool */ - public function execute(): bool {} + public function execute() {} /** - * Fetches an array/object of strings that corresponds to the fetched row, - * or FALSE if there are no more rows. This method is affected by the active - * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` + * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * - * ```php + * * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Enum::FETCH_OBJ + * \Phalcon\Db::FETCH_OBJ * ); * * while ($robot = $result->fetch()) { * echo $robot->name; * } - * ``` + * * * @param mixed $fetchStyle * @param mixed $cursorOrientation @@ -113,97 +93,114 @@ public function execute(): bool {} */ public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) {} + /** + * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * + * + * $result = $connection->query("SELECT FROM robots ORDER BY name"); + * + * $result->setFetchMode( + * \Phalcon\Db::FETCH_NUM + * ); + * + * while ($robot = result->fetchArray()) { + * print_r($robot); + * } + * + */ + public function fetchArray() {} + /** * Returns an array of arrays containing all the records in the result - * This method is affected by the active fetch flag set using - * `Phalcon\Db\Result\Pdo::setFetchMode()` + * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * - * ```php + * * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * * $robots = $result->fetchAll(); - * ``` + * * * @param mixed $fetchStyle * @param mixed $fetchArgument * @param mixed $ctorArgs * @return array */ - public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null): array {} + public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null) {} /** - * Returns an array of strings that corresponds to the fetched row, or FALSE - * if there are no more rows. This method is affected by the active fetch - * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` - * - * ```php - * $result = $connection->query("SELECT FROM robots ORDER BY name"); + * Gets number of rows returned by a resultset * - * $result->setFetchMode( - * \Phalcon\Enum::FETCH_NUM + * + * $result = $connection->query( + * "SELECT FROM robots ORDER BY name" * ); * - * while ($robot = result->fetchArray()) { - * print_r($robot); - * } - * ``` - */ - public function fetchArray() {} - - /** - * Gets the internal PDO result object + * echo "There are ", $result->numRows(), " rows in the resultset"; + * * - * @return \PDOStatement + * @return int */ - public function getInternalResult(): \PDOStatement {} + public function numRows() {} /** - * Gets number of rows returned by a resultset + * Moves internal resultset cursor to another position letting us to fetch a certain row * - * ```php + * * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * - * echo "There are ", $result->numRows(), " rows in the resultset"; - * ``` + * // Move to third row on result + * $result->dataSeek(2); * - * @return int + * // Fetch third row + * $row = $result->fetch(); + * + * + * @param long $number */ - public function numRows(): int {} + public function dataSeek($number) {} /** * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * ```php + * * // Return array with integer indexes * $result->setFetchMode( - * \Phalcon\Enum::FETCH_NUM + * \Phalcon\Db::FETCH_NUM * ); * * // Return associative array without integer indexes * $result->setFetchMode( - * \Phalcon\Enum::FETCH_ASSOC + * \Phalcon\Db::FETCH_ASSOC * ); * * // Return associative array together with integer indexes * $result->setFetchMode( - * \Phalcon\Enum::FETCH_BOTH + * \Phalcon\Db::FETCH_BOTH * ); * * // Return an object * $result->setFetchMode( - * \Phalcon\Enum::FETCH_OBJ + * \Phalcon\Db::FETCH_OBJ * ); - * ``` + * * * @param int $fetchMode * @param mixed $colNoOrClassNameOrObject * @param mixed $ctorargs * @return bool */ - public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool {} + public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null) {} + + /** + * Gets the internal PDO result object + * + * @return \PDOStatement + */ + public function getInternalResult() {} } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index 96186819..a1bc563f 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -3,73 +3,68 @@ namespace Phalcon\Debug; /** + * Phalcon\Debug\Dump + * * Dumps information about a variable(s) * - * ```php + * * $foo = 123; * * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * ``` + * * - * ```php + * * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * ``` + * */ class Dump { - /** - * @var bool - */ - protected $detailed = false; - /** - * @var array - */ - protected $methods = array(); + protected $_detailed = false; - /** - * @var array - */ - protected $styles = array(); + + protected $_methods = array(); + + + protected $_styles; - /** - * @return bool - */ - public function getDetailed(): bool {} + + public function getDetailed() {} /** - * @param bool $detailed + * @param mixed $detailed */ - public function setDetailed(bool $detailed) {} + public function setDetailed($detailed) {} /** * Phalcon\Debug\Dump constructor * * @param array $styles - * @param bool $detailed + * @param boolean $detailed debug object's private and protected properties */ - public function __construct(array $styles = array(), bool $detailed = false) {} + public function __construct(array $styles = array(), $detailed = false) {} /** * Alias of variables() method * + * @param mixed $variable + * @param ... * @return string */ - public function all(): string {} + public function all() {} /** - * Alias of variable() method + * Get style for type * - * @param mixed $variable - * @param string $name + * @param string $type * @return string */ - public function one($variable, string $name = null): string {} + protected function getStyle($type) {} /** * Set styles for vars type @@ -77,74 +72,77 @@ public function one($variable, string $name = null): string {} * @param array $styles * @return array */ - public function setStyles(array $styles = array()): array {} + public function setStyles(array $styles = array()) {} /** - * Returns an JSON string of information about a single variable. - * - * ```php - * $foo = [ - * "key" => "value", - * ]; - * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * - * $foo = new stdClass(); - * $foo->bar = "buz"; + * Alias of variable() method * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * ``` + * @param mixed $variable + * @param string $name + * @return string + */ + public function one($variable, $name = null) {} + + /** + * Prepare an HTML string of information about a single variable. * * @param mixed $variable + * @param string $name + * @param int $tab * @return string */ - public function toJson($variable): string {} + protected function output($variable, $name = null, $tab = 1) {} /** * Returns an HTML string of information about a single variable. * - * ```php + * * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * ``` + * * * @param mixed $variable * @param string $name * @return string */ - public function variable($variable, string $name = null): string {} + public function variable($variable, $name = null) {} /** * Returns an HTML string of debugging information about any number of * variables, each wrapped in a "pre" tag. * - * ```php + * * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * ``` + * * + * @param mixed $variable + * @param ... * @return string */ - public function variables(): string {} + public function variables() {} /** - * Get style for type + * Returns an JSON string of information about a single variable. * - * @param string $type - * @return string - */ - protected function getStyle(string $type): string {} - - /** - * Prepare an HTML string of information about a single variable. + * + * $foo = [ + * "key" => "value", + * ]; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * + * $foo = new stdClass(); + * $foo->bar = "buz"; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * * * @param mixed $variable - * @param string $name - * @param int $tab * @return string */ - protected function output($variable, string $name = null, int $tab = 1): string {} + public function toJson($variable) {} } diff --git a/src/Phalcon/debug/Exception.php b/src/Phalcon/debug/Exception.php index 9616f511..ea6c9862 100644 --- a/src/Phalcon/debug/Exception.php +++ b/src/Phalcon/debug/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Debug; /** + * Phalcon\Debug\Exception + * * Exceptions thrown in Phalcon\Debug will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/di/Exception.php b/src/Phalcon/di/Exception.php index 076f3444..50cebbcd 100644 --- a/src/Phalcon/di/Exception.php +++ b/src/Phalcon/di/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Di; /** + * Phalcon\Di\Exception + * * Exceptions thrown in Phalcon\Di will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index a9ebce24..343d0b96 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -3,10 +3,11 @@ namespace Phalcon\Di; /** + * Phalcon\Di\FactoryDefault + * * This is a variant of the standard Phalcon\Di. By default it automatically - * registers all the services provided by the framework. Thanks to this, the - * developer does not need to register each service individually providing a - * full stack framework + * registers all the services provided by the framework. Thanks to this, the developer does not need + * to register each service individually providing a full stack framework */ class FactoryDefault extends \Phalcon\Di { diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index e2821622..a90c99f3 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -3,31 +3,33 @@ namespace Phalcon\Di; /** - * This class allows to access services in the services container by just only - * accessing a public property with the same name of a registered service + * Phalcon\Di\Injectable + * + * This class allows to access services in the services container by just only accessing a public property + * with the same name of a registered service * * @property \Phalcon\Mvc\Dispatcher|\Phalcon\Mvc\DispatcherInterface $dispatcher * @property \Phalcon\Mvc\Router|\Phalcon\Mvc\RouterInterface $router - * @property \Phalcon\Url|\Phalcon\Url\UrlInterface $url + * @property \Phalcon\Mvc\Url|\Phalcon\Mvc\UrlInterface $url * @property \Phalcon\Http\Request|\Phalcon\Http\RequestInterface $request * @property \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface $response * @property \Phalcon\Http\Response\Cookies|\Phalcon\Http\Response\CookiesInterface $cookies - * @property \Phalcon\Filter\FilterLocator $filter + * @property \Phalcon\Filter|\Phalcon\FilterInterface $filter * @property \Phalcon\Flash\Direct $flash * @property \Phalcon\Flash\Session $flashSession - * @property \Phalcon\Session\ManagerInterface $session + * @property \Phalcon\Session\Adapter\Files|\Phalcon\Session\Adapter|\Phalcon\Session\AdapterInterface $session * @property \Phalcon\Events\Manager|\Phalcon\Events\ManagerInterface $eventsManager - * @property \Phalcon\Db\Adapter\AdapterInterface $db + * @property \Phalcon\Db\AdapterInterface $db * @property \Phalcon\Security $security * @property \Phalcon\Crypt|\Phalcon\CryptInterface $crypt * @property \Phalcon\Tag $tag - * @property \Phalcon\Escaper|\Phalcon\Escaper\EscaperInterface $escaper + * @property \Phalcon\Escaper|\Phalcon\EscaperInterface $escaper * @property \Phalcon\Annotations\Adapter\Memory|\Phalcon\Annotations\Adapter $annotations * @property \Phalcon\Mvc\Model\Manager|\Phalcon\Mvc\Model\ManagerInterface $modelsManager * @property \Phalcon\Mvc\Model\MetaData\Memory|\Phalcon\Mvc\Model\MetadataInterface $modelsMetadata * @property \Phalcon\Mvc\Model\Transaction\Manager|\Phalcon\Mvc\Model\Transaction\ManagerInterface $transactionManager * @property \Phalcon\Assets\Manager $assets - * @property \Phalcon\Di|\Phalcon\Di\DiInterface $di + * @property \Phalcon\Di|\Phalcon\DiInterface $di * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ @@ -36,52 +38,51 @@ abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface, \Phalc /** * Dependency Injector * - * @var DiInterface + * @var \Phalcon\DiInterface */ - protected $container; + protected $_dependencyInjector; /** * Events Manager * * @var \Phalcon\Events\ManagerInterface */ - protected $eventsManager; + protected $_eventsManager; /** - * Magic method __get + * Sets the dependency injector * - * @param string $propertyName - * @return mixed|null + * @param \Phalcon\DiInterface $dependencyInjector */ - public function __get(string $propertyName): ? {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(): DiInterface {} + public function getDI() {} /** - * Returns the internal event manager + * Sets the event manager * - * @return \Phalcon\Events\ManagerInterface + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getEventsManager(): ManagerInterface {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Sets the dependency injector + * Returns the internal event manager * - * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Events\ManagerInterface */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getEventsManager() {} /** - * Sets the event manager + * Magic method __get * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $propertyName */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function __get($propertyName) {} } diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index d12064ac..84b720ef 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -3,8 +3,9 @@ namespace Phalcon\Di; /** - * This interface must be implemented in those classes that uses internally the - * Phalcon\Di that creates them + * Phalcon\Di\InjectionAwareInterface + * + * This interface must be implemented in those classes that uses internally the Phalcon\Di that creates them */ interface InjectionAwareInterface { @@ -12,15 +13,16 @@ interface InjectionAwareInterface /** * Sets the dependency injector * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector + * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container); + public function setDI(\Phalcon\DiInterface $dependencyInjector) : void; /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(): DiInterface; + public function getDI() : \Phalcon\DiInterface; } diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index fbc35b47..c3673ec1 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -3,88 +3,96 @@ namespace Phalcon\Di; /** + * Phalcon\Di\Service + * * Represents individually a service in the services container * - * ```php + * * $service = new \Phalcon\Di\Service( * "request", - * \Phalcon\Http\Request::class + * "Phalcon\\Http\\Request" * ); * * $request = service->resolve(); - * ``` + * */ class Service implements \Phalcon\Di\ServiceInterface { - protected $definition; + protected $_name; - /** - * @var bool - */ - protected $resolved = false; - /** - * @var bool - */ - protected $shared = false; + protected $_definition; + + + protected $_shared = false; + + protected $_resolved = false; - protected $sharedInstance; + + protected $_sharedInstance; /** * Phalcon\Di\Service * + * @param string $name * @param mixed $definition - * @param bool $shared + * @param boolean $shared */ - final public function __construct($definition, bool $shared = false) {} + public final function __construct($name, $definition, $shared = false) {} /** - * Returns the service definition + * Returns the service's name * - * @return mixed + * @return string */ - public function getDefinition() {} + public function getName() {} /** - * Returns a parameter in a specific position + * Sets if the service is shared or not * - * @param int $position - * @return array + * @param bool $shared */ - public function getParameter(int $position) {} + public function setShared($shared) {} /** - * Returns true if the service was resolved + * Check whether the service is shared or not * * @return bool */ - public function isResolved(): bool {} + public function isShared() {} /** - * Check whether the service is shared or not + * Sets/Resets the shared instance related to the service * - * @return bool + * @param mixed $sharedInstance */ - public function isShared(): bool {} + public function setSharedInstance($sharedInstance) {} /** - * Resolves the service + * Set the service definition + * + * @param mixed $definition + */ + public function setDefinition($definition) {} + + /** + * Returns the service definition * - * @param array $parameters - * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) {} + public function getDefinition() {} /** - * Set the service definition + * Resolves the service * - * @param mixed $definition + * @param array $parameters + * @param \Phalcon\DiInterface $dependencyInjector + * @return mixed */ - public function setDefinition($definition) {} + public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null) {} /** * Changes a parameter in the definition without resolve the service @@ -93,20 +101,29 @@ public function setDefinition($definition) {} * @param array $parameter * @return \Phalcon\Di\ServiceInterface */ - public function setParameter(int $position, array $parameter): ServiceInterface {} + public function setParameter($position, array $parameter) {} /** - * Sets if the service is shared or not + * Returns a parameter in a specific position * - * @param bool $shared + * @param int $position + * @return array */ - public function setShared(bool $shared) {} + public function getParameter($position) {} /** - * Sets/Resets the shared instance related to the service + * Returns true if the service was resolved * - * @param mixed $sharedInstance + * @return bool */ - public function setSharedInstance($sharedInstance) {} + public function isResolved() {} + + /** + * Restore the internal state of a service + * + * @param array $attributes + * @return \Phalcon\Di\ServiceInterface + */ + public static function __set_state(array $attributes) {} } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index a7447ae8..9277779a 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -3,55 +3,56 @@ namespace Phalcon\Di; /** + * Phalcon\Di\ServiceInterface + * * Represents a service in the services container */ interface ServiceInterface { /** - * Returns the service definition + * Returns the service's name * - * @return mixed + * @param string */ - public function getDefinition(); + public function getName(); /** - * Returns a parameter in a specific position + * Sets if the service is shared or not * - * @param int $position - * @return array + * @param bool $shared */ - public function getParameter(int $position); + public function setShared($shared); /** - * Returns true if the service was resolved + * Check whether the service is shared or not * * @return bool */ - public function isResolved(): bool; + public function isShared(); /** - * Check whether the service is shared or not + * Set the service definition * - * @return bool + * @param mixed $definition */ - public function isShared(): bool; + public function setDefinition($definition); /** - * Resolves the service + * Returns the service definition * - * @param array $parameters - * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null); + public function getDefinition(); /** - * Set the service definition + * Resolves the service * - * @param mixed $definition + * @param array $parameters + * @param \Phalcon\DiInterface $dependencyInjector + * @return mixed */ - public function setDefinition($definition); + public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null); /** * Changes a parameter in the definition without resolve the service @@ -60,13 +61,14 @@ public function setDefinition($definition); * @param array $parameter * @return ServiceInterface */ - public function setParameter(int $position, array $parameter): ServiceInterface; + public function setParameter($position, array $parameter); /** - * Sets if the service is shared or not + * Restore the internal state of a service * - * @param bool $shared + * @param array $attributes + * @return ServiceInterface */ - public function setShared(bool $shared); + public static function __set_state(array $attributes); } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index e61eaedb..61c53270 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -3,28 +3,27 @@ namespace Phalcon\Di; /** - * Should be implemented by service providers, or such components, which - * register a service in the service container. + * Phalcon\Di\ServiceProviderInterface * - * ```php + * Should be implemented by service providers, or such components, + * which register a service in the service container. + * + * * namespace Acme; * - * use Phalcon\Di\DiInterface; + * use Phalcon\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared( - * 'service', - * function () { - * // ... - * } - * ); + * $di->setShared('service', function () { + * // ... + * }); * } * } - * ``` + * */ interface ServiceProviderInterface { @@ -32,8 +31,8 @@ interface ServiceProviderInterface /** * Registers a service provider. * - * @param \Phalcon\Di\DiInterface $di + * @param \Phalcon\DiInterface $di */ - public function register(\Phalcon\Di\DiInterface $di); + public function register(\Phalcon\DiInterface $di); } diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php deleted file mode 100644 index 15c7d6b3..00000000 --- a/src/Phalcon/di/exception/ServiceResolutionException.php +++ /dev/null @@ -1,11 +0,0 @@ -isCancelable()) { - * $event->stop(); - * } - * ``` + * Sets event data. * - * @return bool + * @param mixed $data + * @return EventInterface */ - public function isCancelable(): bool {} + public function setData($data = null) {} /** - * Check whether the event is currently stopped. + * Sets event type. * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped(): bool {} + public function setType($type) {} /** - * Sets event data. + * Stops the event preventing propagation. + * + * + * if ($event->isCancelable()) { + * $event->stop(); + * } + * * - * @param mixed $data * @return EventInterface */ - public function setData($data = null): EventInterface {} + public function stop() {} /** - * Sets event type. + * Check whether the event is currently stopped. * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType(string $type): EventInterface {} + public function isStopped() {} /** - * Stops the event preventing propagation. + * Check whether the event is cancelable. * - * ```php + * * if ($event->isCancelable()) { * $event->stop(); * } - * ``` + * * - * @return EventInterface + * @return bool */ - public function stop(): EventInterface {} + public function isCancelable() {} } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index 92f60516..de3427cc 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -18,47 +18,47 @@ interface EventInterface public function getData(); /** - * Gets event type + * Sets event data * - * @return mixed + * @param mixed $data + * @return EventInterface */ - public function getType(); + public function setData($data = null); /** - * Check whether the event is cancelable + * Gets event type * - * @return bool + * @return mixed */ - public function isCancelable(): bool; + public function getType(); /** - * Check whether the event is currently stopped + * Sets event type * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped(): bool; + public function setType($type); /** - * Sets event data + * Stops the event preventing propagation * - * @param mixed $data * @return EventInterface */ - public function setData($data = null): EventInterface; + public function stop(); /** - * Sets event type + * Check whether the event is currently stopped * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType(string $type): EventInterface; + public function isStopped(); /** - * Stops the event preventing propagation + * Check whether the event is cancelable * - * @return EventInterface + * @return bool */ - public function stop(): EventInterface; + public function isCancelable(); } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index a7fcff43..903a9bb8 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -5,24 +5,23 @@ /** * Phalcon\Events\EventsAwareInterface * - * This interface must for those classes that accept an EventsManager and - * dispatch events + * This interface must for those classes that accept an EventsManager and dispatch events */ interface EventsAwareInterface { /** - * Returns the internal event manager + * Sets the events manager * - * @return ManagerInterface + * @param ManagerInterface $eventsManager */ - public function getEventsManager(): ManagerInterface; + public function setEventsManager(ManagerInterface $eventsManager); /** - * Sets the events manager + * Returns the internal event manager * - * @param ManagerInterface $eventsManager + * @return ManagerInterface */ - public function setEventsManager(ManagerInterface $eventsManager); + public function getEventsManager(); } diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index 39b3fb35..d1227745 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -5,31 +5,23 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if - * needed, the normal flow of operation. With the EventsManager the developer - * can create hooks or plugins that will offer monitoring of data, manipulation, - * conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, + * the normal flow of operation. With the EventsManager the developer can create hooks or + * plugins that will offer monitoring of data, manipulation, conditional execution and much more. */ class Manager implements \Phalcon\Events\ManagerInterface { - const DEFAULT_PRIORITY = 100; + protected $_events = null; - /** - * @var bool - */ - protected $collect = false; - /** - * @var bool - */ - protected $enablePriorities = false; + protected $_collect = false; - protected $events = null; + protected $_enablePriorities = false; - protected $responses; + protected $_responses; /** @@ -39,85 +31,83 @@ class Manager implements \Phalcon\Events\ManagerInterface * @param object|callable $handler * @param int $priority */ - public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) {} + public function attach($eventType, $handler, $priority = 100) {} /** - * Returns if priorities are enabled + * Detach the listener from the events manager * - * @return bool + * @param string $eventType + * @param object $handler */ - public function arePrioritiesEnabled(): bool {} + public function detach($eventType, $handler) {} /** - * Tells the event manager if it needs to collect all the responses returned - * by every registered listener in a single fire + * Set if priorities are enabled in the EventsManager * - * @param bool $collect + * @param bool $enablePriorities */ - public function collectResponses(bool $collect) {} + public function enablePriorities($enablePriorities) {} /** - * Detach the listener from the events manager + * Returns if priorities are enabled * - * @param string $eventType - * @param object $handler + * @return bool */ - public function detach(string $eventType, $handler) {} + public function arePrioritiesEnabled() {} /** - * Removes all events from the EventsManager + * Tells the event manager if it needs to collect all the responses returned by every + * registered listener in a single fire * - * @param string $type + * @param bool $collect */ - public function detachAll(string $type = null) {} + public function collectResponses($collect) {} /** - * Set if priorities are enabled in the EventsManager + * Check if the events manager is collecting all all the responses returned by every + * registered listener in a single fire * - * @param bool $enablePriorities + * @return bool */ - public function enablePriorities(bool $enablePriorities) {} + public function isCollecting() {} /** - * Fires an event in the events manager causing the active listeners to be - * notified about it - * - * ```php - * $eventsManager->fire("db", $connection); - * ``` + * Returns all the responses returned by every handler executed by the last 'fire' executed * - * @param string $eventType - * @param object $source - * @param mixed $data - * @param bool $cancelable - * @return mixed + * @return array */ - public function fire(string $eventType, $source, $data = null, bool $cancelable = true) {} + public function getResponses() {} /** - * Internal handler to call a queue of events + * Removes all events from the EventsManager * - * @param \SplPriorityQueue $queue - * @param EventInterface $event - * @return mixed + * @param string $type */ - final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) {} + public function detachAll($type = null) {} /** - * Returns all the attached listeners of a certain type + * Internal handler to call a queue of events * - * @param string $type - * @return array + * @param \SplPriorityQueue|array $queue + * @param \Phalcon\Events\Event $event + * @return mixed */ - public function getListeners(string $type): array {} + public final function fireQueue($queue, EventInterface $event) {} /** - * Returns all the responses returned by every handler executed by the last - * 'fire' executed + * Fires an event in the events manager causing the active listeners to be notified about it * - * @return array + * + * $eventsManager->fire("db", $connection); + * + * + * @param string $eventType + * @param object $source + * @param mixed $data + * @param boolean $cancelable + * @return mixed */ - public function getResponses(): array {} + public function fire($eventType, $source, $data = null, $cancelable = true) {} /** * Check whether certain type of event has listeners @@ -125,14 +115,14 @@ public function getResponses(): array {} * @param string $type * @return bool */ - public function hasListeners(string $type): bool {} + public function hasListeners($type) {} /** - * Check if the events manager is collecting all all the responses returned - * by every registered listener in a single fire + * Returns all the attached listeners of a certain type * - * @return bool + * @param string $type + * @return array */ - public function isCollecting(): bool {} + public function getListeners($type) {} } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 048672ab..0598a8c4 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -5,10 +5,9 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if - * needed, the normal flow of operation. With the EventsManager the developer - * can create hooks or plugins that will offer monitoring of data, manipulation, - * conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, + * the normal flow of operation. With the EventsManager the developer can create hooks or + * plugins that will offer monitoring of data, manipulation, conditional execution and much more. */ interface ManagerInterface { @@ -19,7 +18,7 @@ interface ManagerInterface * @param string $eventType * @param object|callable $handler */ - public function attach(string $eventType, $handler); + public function attach($eventType, $handler); /** * Detach the listener from the events manager @@ -27,25 +26,24 @@ public function attach(string $eventType, $handler); * @param string $eventType * @param object $handler */ - public function detach(string $eventType, $handler); + public function detach($eventType, $handler); /** * Removes all events from the EventsManager * * @param string $type */ - public function detachAll(string $type = null); + public function detachAll($type = null); /** - * Fires an event in the events manager causing the active listeners to be - * notified about it + * Fires an event in the events manager causing the active listeners to be notified about it * * @param string $eventType * @param object $source * @param mixed $data * @return mixed */ - public function fire(string $eventType, $source, $data = null); + public function fire($eventType, $source, $data = null); /** * Returns all the attached listeners of a certain type @@ -53,14 +51,6 @@ public function fire(string $eventType, $source, $data = null); * @param string $type * @return array */ - public function getListeners(string $type): array; - - /** - * Check whether certain type of event has listeners - * - * @param string $type - * @return bool - */ - public function hasListeners(string $type): bool; + public function getListeners($type); } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php deleted file mode 100644 index b54cb01b..00000000 --- a/src/Phalcon/factory/AbstractFactory.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class AbstractFactory -{ - /** - * @var array - */ - protected $mapper = array(); - - /** - * @var array - */ - protected $services = array(); - - - /** - * Checks if a service exists and throws an exception - * - * @param string $name - */ - protected function checkService(string $name) {} - - /** - * Checks the config if it is a valid object - * - * @param mixed $config - * @return array - */ - protected function checkConfig($config): array {} - - /** - * Returns the adapters for the factory - * - * @return array - */ - abstract protected function getAdapters(): array; - - /** - * AdapterFactory constructor. - * - * @param array $services - */ - protected function init(array $services = array()) {} - -} diff --git a/src/Phalcon/factory/Exception.php b/src/Phalcon/factory/Exception.php index 15f9cdc3..25a41d41 100644 --- a/src/Phalcon/factory/Exception.php +++ b/src/Phalcon/factory/Exception.php @@ -3,12 +3,9 @@ namespace Phalcon\Factory; /** - * This file is part of the Phalcon Framework. + * Phalcon\Factory\Exception * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. + * Exceptions thrown in Phalcon\Factory will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/filter/Filter.php b/src/Phalcon/filter/Filter.php deleted file mode 100644 index ad2a7516..00000000 --- a/src/Phalcon/filter/Filter.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class FilterFactory -{ - - /** - * Returns a Locator object with all the helpers defined in anonynous - * functions - * - * @return LocatorInterface - */ - public function newInstance(): LocatorInterface {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php deleted file mode 100644 index 067ba31c..00000000 --- a/src/Phalcon/filter/FilterInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ - protected $cache; - - /** - * Default access - * - * @var int - */ - protected $defaultAccess = Enum::DENY; - - /** - * Events manager - * - * @var mixed - */ - protected $eventsManager; - - /** - * Internal cache for caching access during request time - * - * @var mixed - */ - protected $internalCache; - - /** - * Anonymous function for getting user identity - this function must - * return string, array or object implementing Phalcon\Acl\RoleAware - * - * @var mixed - */ - protected $roleCallback; - - - /** - * Storing active identity object implementing Phalcon/Acl/RoleAware - */ - public function getActiveIdentity() {} - - /** - * Storing active user role - */ - public function getActiveRole() {} - - /** - * Should role always be resolved using role callback or just once? - * - * @param bool $alwaysResolvingRole - */ - public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} - - /** - * Default access - * - * @return int - */ - public function getDefaultAccess(): int {} - - /** - * Returns the internal event manager - * - * @return \Phalcon\Events\ManagerInterface - */ - public function getEventsManager(): ManagerInterface {} - - /** - * Gets role callback to fetch role name - * - * @return \Closure - */ - public function getRoleCallback(): Closure {} - - /** - * Gets always resolving role option - * - * @return bool - */ - public function isAlwaysResolvingRole(): bool {} - - /** - * Sets the cache adapter - * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @return AdapterInterface - */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface {} - - /** - * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) - * - * @param int $defaultAccess - * @return AdapterInterface - */ - public function setDefaultAccess(int $defaultAccess): AdapterInterface {} - - /** - * Sets the events manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return AdapterInterface - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AdapterInterface {} - - /** - * Sets role callback to fetch role name - * - * @param mixed $callback - * @return AdapterInterface - */ - public function setRoleCallback($callback): AdapterInterface {} - - /** - * @param \Phalcon\Di\DiInterface $container - */ - protected function callRoleCallback(\Phalcon\Di\DiInterface $container) {} - - /** - * Gets access from cache - * - * @param string $key - * @param array $originalValues - * @param string $roleCacheKey - * @return bool|null - */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} - - /** - * Handles a user exception - * - * @param \Exception $exception - */ - protected function handleException(\Exception $exception) {} - - /** - * Fires event or throwing exception - * - * @param mixed $role - * @param string $actionName - * @param string $controllerName - * @param bool $access - */ - protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) {} - - /** - * Saves access in cache and internal cache - * - * @param string $key - * @param bool $access - */ - protected function saveAccessInCache(string $key, bool $access) {} - - /** - * Throws an internal exception - * - * @param string $message - * @param int $exceptionCode - * @return bool - */ - protected function throwFirewallException(string $message, int $exceptionCode = 0): bool {} - -} diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php deleted file mode 100644 index 7ac99290..00000000 --- a/src/Phalcon/firewall/adapter/Acl.php +++ /dev/null @@ -1,174 +0,0 @@ -success("The record was successfully deleted"); - * $flash->error("Cannot open the file"); - * ``` - */ -abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\Di\InjectionAwareInterface -{ - /** - * @var bool - */ - protected $autoescape = true; - - /** - * @var bool - */ - protected $automaticHtml = true; - - /** - * @var array - */ - protected $cssClasses = array(); - - /** - * @var string - */ - protected $customTemplate = ''; - - - protected $container = null; - - - protected $escaperService = null; - - /** - * @var bool - */ - protected $implicitFlush = true; - - - protected $messages = array(); - - - /** - * Phalcon\Flash constructor - * - * @param mixed $cssClasses - */ - public function __construct($cssClasses = null) {} - - /** - * Clears accumulated messages when implicit flush is disabled - */ - public function clear() {} - - /** - * Shows a HTML error message - * - * ```php - * $flash->error("This is an error"); - * ``` - * - * @param string $message - * @return string - */ - public function error(string $message): string {} - - /** - * Returns the autoescape mode in generated html - * - * @return bool - */ - public function getAutoescape(): bool {} - - /** - * Returns the custom template set - * - * @return string - */ - public function getCustomTemplate(): string {} - - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns the Escaper Service - * - * @return \Phalcon\Escaper\EscaperInterface - */ - public function getEscaperService(): EscaperInterface {} - - /** - * Shows a HTML notice/information message - * - * ```php - * $flash->notice("This is an information"); - * ``` - * - * @param string $message - * @return string - */ - public function notice(string $message): string {} - - /** - * Set the autoescape mode in generated html - * - * @param bool $autoescape - * @return Flash - */ - public function setAutoescape(bool $autoescape): Flash {} - - /** - * Set if the output must be implicitly formatted with HTML - * - * @param bool $automaticHtml - * @return FlashInterface - */ - public function setAutomaticHtml(bool $automaticHtml): FlashInterface {} - - /** - * Set an array with CSS classes to format the messages - * - * @param array $cssClasses - * @return FlashInterface - */ - public function setCssClasses(array $cssClasses): FlashInterface {} - - /** - * Set an custom template for showing the messages - * - * @param string $customTemplate - * @return FlashInterface - */ - public function setCustomTemplate(string $customTemplate): FlashInterface {} - - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - * @return FlashInterface - */ - public function setDI(\Phalcon\Di\DiInterface $container): FlashInterface {} - - /** - * Sets the Escaper Service - * - * @param \Phalcon\Escaper\EscaperInterface $escaperService - * @return FlashInterface - */ - public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface {} - - /** - * Set whether the output must be implicitly flushed to the output or - * returned as string - * - * @param bool $implicitFlush - * @return FlashInterface - */ - public function setImplicitFlush(bool $implicitFlush): FlashInterface {} - - /** - * Shows a HTML success message - * - * ```php - * $flash->success("The process was finished successfully"); - * ``` - * - * @param string $message - * @return string - */ - public function success(string $message): string {} - - /** - * Outputs a message formatting it with HTML - * - * ```php - * $flash->outputMessage("error", $message); - * ``` - * - * @param string $type - * @param string|array $message - * @return string|void - */ - public function outputMessage(string $type, $message) {} - - /** - * Shows a HTML warning message - * - * ```php - * $flash->warning("Hey, this is important"); - * ``` - * - * @param string $message - * @return string - */ - public function warning(string $message): string {} - - /** - * @param string $cssClassses - * @return string - */ - private function getTemplate(string $cssClassses): string {} - - /** - * Returns the message escaped if the autoEscape is true, otherwise the - * original message is returned - * - * @param string $message - * @return string - */ - private function prepareEscapedMessage(string $message): string {} - - /** - * Prepares the HTML output for the message. If automaticHtml is not set - * then the original message is returned - * - * @param string $type - * @param string $message - * @return string - */ - private function prepareHtmlMessage(string $type, string $message): string {} - -} diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index fda928b6..bfe09e23 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -3,10 +3,11 @@ namespace Phalcon\Flash; /** - * This is a variant of the Phalcon\Flash that immediately outputs any message - * passed to it + * Phalcon\Flash\Direct + * + * This is a variant of the Phalcon\Flash that immediately outputs any message passed to it */ -class Direct extends \Phalcon\Flash\AbstractFlash +class Direct extends \Phalcon\Flash { /** @@ -16,13 +17,13 @@ class Direct extends \Phalcon\Flash\AbstractFlash * @param mixed $message * @return string */ - public function message(string $type, $message): string {} + public function message($type, $message) {} /** * Prints the messages accumulated in the flasher * * @param bool $remove */ - public function output(bool $remove = true) {} + public function output($remove = true) {} } diff --git a/src/Phalcon/flash/Exception.php b/src/Phalcon/flash/Exception.php index 6a123e85..fece45ed 100644 --- a/src/Phalcon/flash/Exception.php +++ b/src/Phalcon/flash/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Flash; /** + * Phalcon\Flash\Exception + * * Exceptions thrown in Phalcon\Flash will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php deleted file mode 100644 index 8faa3dea..00000000 --- a/src/Phalcon/flash/FlashInterface.php +++ /dev/null @@ -1,53 +0,0 @@ - * if ($form->isValid($_POST) == false) { + * // Get messages separated by the item name + * // $messages is an array of Group object + * $messages = $form->getMessages(true); + * + * foreach ($messages as $message) { + * echo $message, "
"; + * } + * + * // Default behavior. + * // $messages is a Group object * $messages = $form->getMessages(); * * foreach ($messages as $message) { * echo $message, "
"; * } * } - * ``` + * * - * @return array|\Phalcon\Messages\Messages + * @param bool $byItemName + * @return array|\Phalcon\Validation\Message\Group */ - public function getMessages() {} + public function getMessages($byItemName = false) {} /** * Returns the messages generated for a specific element * * @param string $name - * @return \Phalcon\Messages\Messages + * @return \Phalcon\Validation\Message\Group */ - public function getMessagesFor(string $name): Messages {} + public function getMessagesFor($name) {} /** - * Returns the value of an option if present + * Check if messages were generated for a specific element * - * @param string $option - * @param mixed $defaultValue - * @return mixed + * @param string $name + * @return bool */ - public function getUserOption(string $option, $defaultValue = null) {} + public function hasMessagesFor($name) {} /** - * Returns the options for the element + * Adds an element to the form * - * @return array + * @param \Phalcon\Forms\ElementInterface $element + * @param string $position + * @param bool $type + * @return Form */ - public function getUserOptions(): array {} + public function add(\Phalcon\Forms\ElementInterface $element, $position = null, $type = null) {} /** - * Gets a value from the internal related entity or from the default value + * Renders a specific item in the form * * @param string $name - * @return mixed|null + * @param array $attributes + * @return string */ - public function getValue(string $name): ? {} + public function render($name, $attributes = null) {} /** - * Check if the form contains an element + * Returns an element added to the form by its name * * @param string $name - * @return bool + * @return \Phalcon\Forms\ElementInterface */ - public function has(string $name): bool {} + public function get($name) {} /** - * Check if messages were generated for a specific element + * Generate the label of an element added to the form including HTML * * @param string $name - * @return bool - */ - public function hasMessagesFor(string $name): bool {} - - /** - * Validates the form - * - * @param array $data - * @param object $entity - * @return bool - */ - public function isValid($data = null, $entity = null): bool {} - - /** - * Returns the current position/key in the iterator - * - * @return int + * @param array $attributes + * @return string */ - public function key(): int {} + public function label($name, array $attributes = null) {} /** - * Generate the label of an element added to the form including HTML + * Returns a label for an element * * @param string $name - * @param array $attributes * @return string */ - public function label(string $name, array $attributes = null): string {} + public function getLabel($name) {} /** - * Moves the internal iteration pointer to the next position + * Gets a value from the internal related entity or from the default value + * + * @param string $name + * @return mixed|null */ - public function next() {} + public function getValue($name) {} /** - * Renders a specific item in the form + * Check if the form contains an element * * @param string $name - * @param array $attributes - * @return string + * @return bool */ - public function render(string $name, array $attributes = array()): string {} + public function has($name) {} /** * Removes an element from the form @@ -240,66 +252,52 @@ public function render(string $name, array $attributes = array()): string {} * @param string $name * @return bool */ - public function remove(string $name): bool {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} + public function remove($name) {} /** - * Sets the form's action + * Clears every element in the form to its default value * - * @param string $action + * @param array $fields * @return Form */ - public function setAction(string $action): Form {} + public function clear($fields = null) {} /** - * Sets the entity related to the model + * Returns the number of elements in the form * - * @param object $entity - * @return Form + * @return int */ - public function setEntity($entity): Form {} + public function count() {} /** - * Sets an option for the form - * - * @param string $option - * @param mixed $value - * @return Form + * Rewinds the internal iterator */ - public function setUserOption(string $option, $value): Form {} + public function rewind() {} /** - * Sets options for the element + * Returns the current element in the iterator * - * @param array $options - * @return Form + * @return bool|\Phalcon\Forms\ElementInterface */ - public function setUserOptions(array $options): Form {} + public function current() {} /** - * Check if the current element in the iterator is valid + * Returns the current position/key in the iterator * - * @return bool + * @return int */ - public function valid(): bool {} + public function key() {} /** - * Get Form attributes collection - * - * @return \Phalcon\Html\Attributes + * Moves the internal iteration pointer to the next position */ - public function getAttributes(): Attributes {} + public function next() {} /** - * Set form attributes collection + * Check if the current element in the iterator is valid * - * @param \Phalcon\Html\Attributes $attributes - * @return \Phalcon\Html\Attributes\AttributesInterface + * @return bool */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface {} + public function valid() {} } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index df4e51a2..7a74031c 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -3,12 +3,12 @@ namespace Phalcon\Forms; /** - * Forms Manager + * Phalcon\Forms\Manager */ class Manager { - protected $forms = array(); + protected $_forms; /** @@ -18,7 +18,7 @@ class Manager * @param object $entity * @return Form */ - public function create(string $name, $entity = null): Form {} + public function create($name, $entity = null) {} /** * Returns a form by its name @@ -26,7 +26,7 @@ public function create(string $name, $entity = null): Form {} * @param string $name * @return Form */ - public function get(string $name): Form {} + public function get($name) {} /** * Checks if a form is registered in the forms manager @@ -34,7 +34,7 @@ public function get(string $name): Form {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has($name) {} /** * Registers a form in the Forms Manager @@ -43,6 +43,6 @@ public function has(string $name): bool {} * @param Form $form * @return FormManager */ - public function set(string $name, Form $form): FormManager {} + public function set($name, Form $form) {} } diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index 2225b1ca..a5ac290a 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -7,7 +7,7 @@ * * Component INPUT[type=check] for forms */ -class Check extends \Phalcon\Forms\Element\AbstractElement +class Check extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Check extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index 2b905e67..5ef2f56d 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -3,9 +3,11 @@ namespace Phalcon\Forms\Element; /** + * Phalcon\Forms\Element\Date + * * Component INPUT[type=date] for forms */ -class Date extends \Phalcon\Forms\Element\AbstractElement +class Date extends \Phalcon\Forms\Element { /** @@ -14,6 +16,6 @@ class Date extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index cd53d0b8..b8b9edf5 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -7,7 +7,7 @@ * * Component INPUT[type=email] for forms */ -class Email extends \Phalcon\Forms\Element\AbstractElement +class Email extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Email extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index 78a18b84..fb51c794 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -3,9 +3,11 @@ namespace Phalcon\Forms\Element; /** + * Phalcon\Forms\Element\File + * * Component INPUT[type=file] for forms */ -class File extends \Phalcon\Forms\Element\AbstractElement +class File extends \Phalcon\Forms\Element { /** @@ -14,6 +16,6 @@ class File extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index 2a060ea9..211b20aa 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -7,7 +7,7 @@ * * Component INPUT[type=hidden] for forms */ -class Hidden extends \Phalcon\Forms\Element\AbstractElement +class Hidden extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 08b6ab96..1b9cca49 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -7,7 +7,7 @@ * * Component INPUT[type=number] for forms */ -class Numeric extends \Phalcon\Forms\Element\AbstractElement +class Numeric extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 8cc5ab6d..913180da 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -7,7 +7,7 @@ * * Component INPUT[type=password] for forms */ -class Password extends \Phalcon\Forms\Element\AbstractElement +class Password extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Password extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index a9a462fc..69f72dfb 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -7,7 +7,7 @@ * * Component INPUT[type=radio] for forms */ -class Radio extends \Phalcon\Forms\Element\AbstractElement +class Radio extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index 16c0fc24..81ea483f 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -7,10 +7,10 @@ * * Component SELECT (choice) for forms */ -class Select extends \Phalcon\Forms\Element\AbstractElement +class Select extends \Phalcon\Forms\Element { - protected $optionsValues; + protected $_optionsValues; /** @@ -20,15 +20,15 @@ class Select extends \Phalcon\Forms\Element\AbstractElement * @param object|array $options * @param array $attributes */ - public function __construct(string $name, $options = null, $attributes = null) {} + public function __construct($name, $options = null, $attributes = null) {} /** - * Adds an option to the current options + * Set the choice's options * - * @param array $option - * @return Element + * @param array|object $options + * @return \Phalcon\Forms\Element */ - public function addOption($option): Element {} + public function setOptions($options) {} /** * Returns the choices' options @@ -38,19 +38,19 @@ public function addOption($option): Element {} public function getOptions() {} /** - * Renders the element widget returning html + * Adds an option to the current options * - * @param array $attributes - * @return string + * @param array $option + * @return \Phalcon\Forms\Element */ - public function render(array $attributes = array()): string {} + public function addOption($option) {} /** - * Set the choice's options + * Renders the element widget returning html * - * @param array|object $options - * @return Element + * @param array $attributes + * @return string */ - public function setOptions($options): Element {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index dae2a93d..3a8ff801 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -3,9 +3,11 @@ namespace Phalcon\Forms\Element; /** + * Phalcon\Forms\Element\Submit + * * Component INPUT[type=submit] for forms */ -class Submit extends \Phalcon\Forms\Element\AbstractElement +class Submit extends \Phalcon\Forms\Element { /** @@ -14,6 +16,6 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index 6bccb1f9..5c7ce1e7 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -7,7 +7,7 @@ * * Component INPUT[type=text] for forms */ -class Text extends \Phalcon\Forms\Element\AbstractElement +class Text extends \Phalcon\Forms\Element { /** @@ -16,6 +16,6 @@ class Text extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index 480fdb62..28e3411f 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -3,9 +3,11 @@ namespace Phalcon\Forms\Element; /** + * Phalcon\Forms\Element\TextArea + * * Component TEXTAREA for forms */ -class TextArea extends \Phalcon\Forms\Element\AbstractElement +class TextArea extends \Phalcon\Forms\Element { /** @@ -14,6 +16,6 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render($attributes = null) {} } diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index 368e2140..279be1e2 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -2,247 +2,32 @@ namespace Phalcon\Helper; +use Phalcon\Helper\Exception; + /** - * This class offers quick array functions throughout the framework + * Phalcon\Helper\Arr + * + * This class offers quick array functions throught the framework */ class Arr { - - /** - * @param array $collection - */ - final public static function arrayToObject(array $collection) {} - - /** - * Chunks an array into smaller arrays of a specified size. - * - * @param bool $preserveKeys - * - * @param array $collection - * @param int $size - * @param bool $preserveKeys - * @return array - */ - final public static function chunk(array $collection, int $size, bool $preserveKeys = false): array {} - - /** - * Returns the first element of the collection. If a callable is passed, the - * element returned is the first that validates true - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return mixed - */ - final public static function first(array $collection, $method = null) {} - - /** - * Returns the key of the first element of the collection. If a callable - * is passed, the element returned is the first that validates true - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return mixed - */ - final public static function firstKey(array $collection, $method = null) {} - - /** - * Flattens an array up to the one level depth, unless `$deep` is set to `true` - * - * @param bool $deep - * - * @param array $collection - * @param bool $deep - * @return array - */ - final public static function flatten(array $collection, bool $deep = false): array {} - /** * Helper method to get an array element or a default - * - * @param array $collection - * @param mixed $index - * @param mixed $defaultValue - * @return mixed */ - final public static function get(array $collection, $index, $defaultValue = null) {} - - /** - * Groups the elements of an array based on the passed callable - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return array - */ - final public static function group(array $collection, $method): array {} + final public static function get(array $collection, $index, $defaultValue) { + } /** * Helper method to get an array element or a default - * - * @param mixed $index - * - * return bool - * @param array $collection - * @param mixed $index - * @return bool - */ - final public static function has(array $collection, $index): bool {} - - /** - * Checks a flat list for duplicate values. Returns true if duplicate - * values exist and false if values are all unique. - * - * @param array $collection - * - * @param array $collection - * @return bool - */ - final public static function isUnique(array $collection): bool {} - - /** - * Returns the last element of the collection. If a callable is passed, the - * element returned is the first that validates true - * - * @param callable $method - * - * return mixed - * @param array $collection - * @param mixed $method - * @return mixed - */ - final public static function last(array $collection, $method = null) {} - - /** - * Returns the key of the last element of the collection. If a callable is - * passed, the element returned is the first that validates true - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return mixed */ - final public static function lastKey(array $collection, $method = null) {} - - /** - * Sorts a collection of arrays or objects by key - * - * @param string $order - * - * @param array $collection - * @param mixed $attribute - * @param string $order - * @param mixed $attr - * @return array - */ - final public static function order(array $collection, $attribute, string $order = 'asc'): array {} - - /** - * Retrieves all of the values for a given key: - * - * @param string $element - * - * @param array $collection - * @param string $element - * @return array - */ - final public static function pluck(array $collection, string $element): array {} + final public static function has(array $collection, $index) : bool + { + } /** * Helper method to set an array element - * - * @param mixed $index - * - * @param array $collection - * @param mixed $value - * @param mixed $index - * @return array - */ - final public static function set(array $collection, $value, $index = null): array {} - - /** - * Returns a new array with n elements removed from the right. - * - * @param int $elements - * - * @param array $collection - * @param int $elements - * @return array - */ - final public static function sliceLeft(array $collection, int $elements = 1): array {} - - /** - * Returns a new array with the X elements from the right - * - * @param int $elements - * - * @param array $collection - * @param int $elements - * @return array - */ - final public static function sliceRight(array $collection, int $elements = 1): array {} - - /** - * Returns a new array with keys of the passed array as one element and - * values as another - * - * @param array $collection - * - * @param array $collection - * @return array - */ - final public static function split(array $collection): array {} - - /** - * Returns true if the provided function returns true for all elements of - * the collection, false otherwise. - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return bool - */ - final public static function validateAll(array $collection, $method): bool {} - - /** - * Returns true if the provided function returns true for at least one - * element fo the collection, false otherwise. - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return bool */ - final public static function validateAny(array $collection, $method): bool {} - - /** - * Helper method to filter the collection - * - * @param callable $method - * - * @param array $collection - * @param mixed $method - * @return array - */ - final private static function filterCollection(array $collection, $method = null): array {} - - /** - * White list filter by key: obtain elements of an array filtering - * by the keys obtained from the elements of a whitelist - * - * @param array $whiteList - * - * @param array $collection - * @param array $whiteList - * @return array - */ - final public static function whiteList(array $collection, array $whiteList): array {} - + final public static function set(array $collection, $value, $index = null) : array + { + } } diff --git a/src/Phalcon/helper/Exception.php b/src/Phalcon/helper/Exception.php index 308a77dc..b11cedeb 100644 --- a/src/Phalcon/helper/Exception.php +++ b/src/Phalcon/helper/Exception.php @@ -3,7 +3,10 @@ namespace Phalcon\Helper; /** + * Phalcon\Helper\Exception + * * Exceptions thrown in Phalcon\Helper will use this class + * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php deleted file mode 100644 index a14f4b6b..00000000 --- a/src/Phalcon/helper/Number.php +++ /dev/null @@ -1,23 +0,0 @@ -%label%'; - - - /** - * Crumb separator - * - * @return string - */ - public function getSeparator(): string {} - - /** - * Crumb separator - * - * @param string $separator - */ - public function setSeparator(string $separator) {} + private $template = "
%label%
"; /** * Adds a new crumb. * - * ```php + * * // Adding a crumb with a link * $breadcrumbs->add("Home", "/"); * * // Adding a crumb without a link (normally the last one) * $breadcrumbs->add("Users"); - * ``` - * - * @param string $label - * @param string $link - * @return Breadcrumbs + * */ - public function add(string $label, string $link = ''): Breadcrumbs {} + public function add(string $label, string $link = "") : Breadcrumbs + { + } /** - * Clears the crumbs + * Clears the crumbx * - * ```php + * * $breadcrumbs->clear() - * ``` + * */ - public function clear() {} + public function clear() : void + { + } /** * Removes crumb by url. * - * ```php + * * $breadcrumbs->remove("/admin/user/create"); * * // remove a crumb without an url (last link) * $breadcrumbs->remove(); - * ``` - * - * @param string $link + * */ - public function remove(string $link) {} + public function remove(string $link) : void + { + } /** * Renders and outputs breadcrumbs based on previously set template. * - * ```php + * + * // Php Engine * echo $breadcrumbs->render(); - * ``` - * - * @return string + * */ - public function render(): string {} + public function render() : string + { + } /** * Returns the internal breadcrumbs array - * - * @return array */ - public function toArray(): array {} - + public function toArray() : array + { + } } diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php index 2a33e680..1a22c6d9 100644 --- a/src/Phalcon/html/Exception.php +++ b/src/Phalcon/html/Exception.php @@ -6,6 +6,7 @@ * Phalcon\Html\Tag\Exception * * Exceptions thrown in Phalcon\Html\Tag will use this class + * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/html/Tag.php b/src/Phalcon/html/Tag.php index ee523d93..864cb02b 100644 --- a/src/Phalcon/html/Tag.php +++ b/src/Phalcon/html/Tag.php @@ -2,1181 +2,1063 @@ namespace Phalcon\Html; +use Phalcon\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Escaper; +use Phalcon\EscaperInterface; +use Phalcon\Helper\Arr; +use Phalcon\Html\Exception; +use Phalcon\UrlInterface; + /** * Phalcon\Html\Tag * - * Phalcon\Html\Tag is designed to simplify building of HTML tags. It provides a - * set of helpers to dynamically generate HTML. + * Phalcon\Tag is designed to simplify building of HTML tags. It provides a set + * of helpers to dynamically generate HTML. */ -class Tag implements \Phalcon\Di\InjectionAwareInterface +class Tag implements InjectionAwareInterface { - /** - * Constants - */ - const HTML32 = 1; - - - const HTML401_STRICT = 2; - - - const HTML401_TRANSITIONAL = 3; - - - const HTML401_FRAMESET = 4; - - - const HTML5 = 5; - - - const XHTML10_STRICT = 6; - - - const XHTML10_TRANSITIONAL = 7; - - - const XHTML10_FRAMESET = 8; - - - const XHTML11 = 9; - - - const XHTML20 = 10; - - - const XHTML5 = 11; - - /** - * @var DiInterface - */ - protected $container; - - /** - * @var array - */ - private $append = array(); - - /** - * @var int - */ - private $docType = 5; - - /** - * @var - */ - private $escaper; - - /** - * @var array - */ - private $prepend = array(); - - /** - * @var string - */ - private $separator = ''; - - /** - * @var string - */ - private $title = ''; - - /** - * @var array - */ - private $values = array(); - - /** - * @var - */ - private $url; - - - /** - * Constructor - * - * @param \Phalcon\Escaper\EscaperInterface $escaper - * @param \Phalcon\Url\UrlInterface $url - */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Url\UrlInterface $url = null) {} - - /** - * Appends a text to current document title - * - * @param mixed $title - * @return Tag - */ - public function appendTitle($title): Tag {} - - /** - * Builds a HTML input[type="button"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->button('Click Me'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ button('Click Me') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function button(string $name, array $parameters = array()): string {} - - /** - * Resets the request and internal values to avoid those fields will have - * any default value. - */ - public function clear() {} - - /** - * Builds a HTML tag - * - * Parameters - * `onlyStart` Only process the start of th element - * `selfClose` It is a self close element - * `useEol` Append PHP_EOL at the end - * - * @param string $tag - * @param array $parameters - * @return string - */ - public function element(string $tag, array $parameters = array()): string {} - - /** - * Builds the closing tag of an html element - * - * Parameters - * `useEol` Append PHP_EOL at the end - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', + /** + * @var + */ + protected $container; + + /** + * @var array + */ + private $append = []; + + /** + * @var int + */ + private $docType = 5; // HTML5 + + /** + * @var + */ + private $escaper; + + /** + * @var array + */ + private $prepend = []; + + /** + * @var string + */ + private $separator = ""; + + /** + * @var string + */ + private $title = ""; + + /** + * @var array + */ + private $values = []; + + /** + * @var + */ + private $url; + + /** + * Constants + */ + const HTML32 = 1; + const HTML401_STRICT = 2; + const HTML401_TRANSITIONAL = 3; + const HTML401_FRAMESET = 4; + const HTML5 = 5; + const XHTML10_STRICT = 6; + const XHTML10_TRANSITIONAL = 7; + const XHTML10_FRAMESET = 8; + const XHTML11 = 9; + const XHTML20 = 10; + const XHTML5 = 11; + + /** + * Appends a text to current document title + */ + public function appendTitle(array $title) : Tag + { + } + + /** + * Builds a HTML input[type="button"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->button('Click Me') + * + * + * Volt syntax: + * + * {{ button('Click Me) }} + * + */ + public function button(string $name, array $parameters = []) : string + { + } + + /** + * Resets the request and internal values to avoid those fields will have + * any default value. + */ + public function clear() : void + { + } + + /** + * Builds a HTML tag + * + * Parameters + * `onlyStart` Only process the start of th element + * `selfClose` It is a self close element + * `useEol` Append PHP_EOL at the end + * + */ + public function element(string $tag, array $parameters = []) : string + { + } + + /** + * Builds the closing tag of an html element + * + * Parameters + * `useEol` Append PHP_EOL at the end + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', * ] * ); // - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', - * 'useEol' => true, - * ] - * ); // '' . PHP_EOL - * ``` - * - * @param string $tag - * @param array $parameters - * @return string - */ - public function elementClose(string $tag, array $parameters = array()): string {} - - /** - * Returns the closing tag of a form element - * - * @param bool $eol - * @return string - */ - public function endForm(bool $eol = true): string {} - - /** - * Builds a HTML FORM tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->form('posts/save'); - * - * echo $tag->form( - * 'posts/save', - * [ - * "method" => "post", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ form('posts/save') }}{% endraw %} - * {% raw %}{{ form('posts/save', ['method': 'post') }}{% endraw %} - * ``` - * - * @param string $action - * @param array $parameters - * @return string - */ - public function form(string $action, array $parameters = array()): string {} - - /** - * Converts text to URL-friendly strings - * - * Parameters - * `text` The text to be processed - * `separator` Separator to use (default '-') - * `lowercase` Convert to lowercase - * `replace` - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->friendlyTitle( - * [ - * 'text' => 'These are big important news', - * 'separator' => '-', - * ] - * ); - * ``` - * - * Volt Syntax: - * ```php - * {% raw %}{{ friendly_title(['text': 'These are big important news', 'separator': '-']) }}{% endraw %} - * ``` - * - * @param string $text - * @param array $parameters - * @return string - */ - public function friendlyTitle(string $text, array $parameters = array()): string {} - - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Get the document type declaration of content. If the docType has not - * been set properly, XHTML5 is returned - * - * @return string - */ - public function getDocType(): string {} - - /** - * Gets the current document title. The title will be automatically escaped. - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->getTitle(); // Hello World from Phalcon - * echo $tag->getTitle(false); // World from Phalcon - * echo $tag->getTitle(true, false); // Hello World - * echo $tag->getTitle(false, false); // World - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ get_title() }}{% endraw %} - * ``` - * - * @param bool $prepend - * @param bool $append - * @return string - */ - public function getTitle(bool $prepend = true, bool $append = true): string {} - - /** - * Gets the current document title separator - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->getTitleSeparator(); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ get_title_separator() }}{% endraw %} - * ``` - * - * @return string - */ - public function getTitleSeparator(): string {} - - /** - * Every helper calls this function to check whether a component has a - * predefined value using `setAttribute` or value from $_POST - * - * @param string $name - * @param array $parameters - * @return mixed|null - */ - public function getValue(string $name, array $parameters = array()): ? {} - - /** - * Check if a helper has a default value set using `setAttribute()` or - * value from $_POST - * - * @param string $name - * @return bool - */ - public function hasValue(string $name): bool {} - - /** - * Builds HTML IMG tags - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->image('img/bg.png'); - * - * echo $tag->image( - * 'img/photo.jpg', - * [ - * 'alt' => 'Some Photo', - * ] - * ); - * - * echo $tag->image( - * 'http://static.mywebsite.com/img/bg.png', - * [ - * 'local' => false, - * ] - * ); - * ``` - * - * Volt Syntax: - * ```php - * {% raw %}{{ image('img/bg.png') }}{% endraw %} - * {% raw %}{{ image('img/photo.jpg', ['alt': 'Some Photo') }}{% endraw %} - * {% raw %}{{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function image(string $url = '', array $parameters = array()): string {} - - /** - * Builds a HTML input[type="check"] tag - * - * ```php - * echo $tag->inputCheckbox( - * [ - * 'name' => 'terms, - * 'value' => 'Y', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_checkbox(['name': 'terms, 'value': 'Y']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputCheckbox(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='color'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputColor(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='date'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDate( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDate(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='datetime'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTime( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date_time(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDateTime(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='datetime-local'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTimeLocal( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDateTimeLocal(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='email'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputEmail( - * [ - * 'name' => 'email', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_email(['name': 'email']);{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputEmail(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='file'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputFile( - * [ - * 'name' => 'file', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_file(['name': 'file']){% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputFile(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='hidden'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputHidden( - * [ - * 'name' => 'my-field', - * 'value' => 'mike', - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputHidden(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="image"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->inputImage( - * [ - * 'src' => '/img/button.png', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_image(['src': '/img/button.png']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputImage(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='month'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputMonth(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='number'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->numericField( - * [ - * 'name' => 'price', - * 'min' => '1', - * 'max' => '5', - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputNumeric(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='password'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->passwordField( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputPassword(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="radio"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputRadio( - * [ - * 'name' => 'weather', - * 'value" => 'hot', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_radio(['name': 'weather', 'value": 'hot']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputRadio(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='range'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputRange(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='search'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputSearch(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='tel'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputTel(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='text'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputText( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputText(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='time'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputTime(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='url'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputUrl(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='week'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputWeek(string $name, array $parameters = array()): string {} - - /** - * Builds a script[type="javascript"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->javascript( - * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->javascript('javascript/jquery.js'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }}{% endraw %} - * {% raw %}{{ javascript('javascript/jquery.js') }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function javascript(string $url, array $parameters = array()): string {} - - /** - * Builds a HTML A tag using framework conventions - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->link('signup/register', 'Register Here!'); - * - * echo $tag->link( - * 'signup/register', - * 'Register Here!', - * [ - * 'class' => 'btn-primary', - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * 'target' => '_new', - * ] - * ); - * ``` - * - * @param string $url - * @param string $text - * @param array $parameters - * @return string - */ - public function link(string $url, string $text = '', array $parameters = array()): string {} - - /** - * Prepends a text to current document title - * - * @param mixed $title - * @return Tag - */ - public function prependTitle($title): Tag {} - - /** - * Renders the title with title tags. The title is automaticall escaped - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->renderTitle(); // Hello World from Phalcon - * echo $tag->renderTitle(false); // World from Phalcon - * echo $tag->renderTitle(true, false); // Hello World - * echo $tag->renderTitle(false, false); // World - * ``` - * - * ```php - * {% raw %}{{ render_title() }}{% endraw %} - * ``` - * - * @param bool $prepend - * @param bool $append - * @return string - */ - public function renderTitle(bool $prepend = true, bool $append = true): string {} - - /** - * Builds a HTML input[type="reset"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->reset('Reset') - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ reset('Save') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function reset(string $name, array $parameters = array()): string {} - - /** - * Builds a select element. It accepts an array or a resultset from - * a Phalcon\Mvc\Model - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Status...', - * ], - * [ - * 'A' => 'Active', - * 'I' => 'Inactive', - * ] - * ); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Type...', - * 'using' => [ - * 'id, - * 'name', - * ], - * ], - * Robots::find( - * [ - * 'conditions' => 'type = :type:', - * 'bind' => [ - * 'type' => 'mechanical', - * ] - * ] - * ) - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @param mixed $data - * @return string - */ - public function select(string $name, array $parameters = array(), $data = null): string {} - - /** - * Assigns default values to generated tags by helpers - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute('name', 'peter'); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * ``` - * - * @param string $name - * @param mixed $value - * @return Tag - */ - public function setAttribute(string $name, $value): Tag {} - - /** - * Assigns default values to generated tags by helpers - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute( - * [ - * 'name' => 'peter', - * ] - * ); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * ``` - * - * @param array $values - * @param bool $merge - * @return Tag - */ - public function setAttributes(array $values, bool $merge = false): Tag {} - - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Set the document type of content - * - * @param int $doctype - * @return Tag - */ - public function setDocType(int $doctype): Tag {} - - /** - * Set the title separator of view content - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag->setTitle('Phalcon Framework'); - * ``` - * - * @param string $title - * @return Tag - */ - public function setTitle(string $title): Tag {} - - /** - * Set the title separator of view content - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->setTitleSeparator('-'); - * ``` - * - * @param string $separator - * @return Tag - */ - public function setTitleSeparator(string $separator): Tag {} - - /** - * Builds a LINK[rel="stylesheet"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->stylesheet( - * 'http://fonts.googleapis.com/css?family=Rosario', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->stylesheet('css/style.css'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }}{% endraw %} - * {% raw %}{{ stylesheet('css/style.css') }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function stylesheet(string $url, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="submit"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->submit('Save'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ submit('Save') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function submit(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML TEXTAREA tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->textArea( - * 'comments', - * [ - * 'cols' => 10, - * 'rows' => 4, - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ text_area('comments', ['cols': 10, 'rows': 4]) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function textArea(string $name, array $parameters = array()): string {} - - /** - * Returns the escaper service from the DI container - * - * @param string $name - */ - private function getService(string $name) {} - - /** - * Renders the attributes of an HTML element - * - * @param string $code - * @param array $attributes - * @return string - */ - private function renderAttributes(string $code, array $attributes): string {} - - /** - * Returns the closing tag depending on the doctype - * - * @param bool $addEol - * @return string - */ - private function renderCloseTag(bool $addEol = false): string {} - - /** - * Builds `input` elements - * - * @param string $type - * @param string $name - * @param array $parameters - * @return string - */ - private function renderInput(string $type, string $name, array $parameters = array()): string {} - - /** - * Builds INPUT tags that implements the checked attribute - * - * @param string $type - * @param string $name - * @param array $parameters - * @return string - */ - private function renderInputChecked(string $type, string $name, array $parameters = array()): string {} - - /** - * Generates the option values or optgroup from an array - * - * @param array $options - * @param mixed $value - * @param string $closeOption - * @return string - */ - private function renderSelectArray(array $options, $value, string $closeOption): string {} - - /** - * Generates the option values from a resultset - * - * @param ResulsetInterface $resultset - * @param mixed $using - * @param mixed $value - * @param string $closeOption - * @return string - */ - private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption): string {} - + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', + * 'useEol' => true, + * ] + * ); // '' . PHP_EOL + * + * + */ + public function elementClose(string $tag, array $parameters = []) : string + { + } + + /** + * Returns the closing tag of a form element + */ + public function endForm(bool $eol = true) : string + { + } + + /** + * Builds a HTML FORM tag + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->form('posts/save'); + * + * echo $tag->form( + * 'posts/save', + * [ + * "method" => "post", + * ] + * ); + * + * + * Volt syntax: + * + * {{ form('posts/save') }} + * {{ form('posts/save', ['method': 'post') }} + * + */ + public function form(string $action, array $parameters = []) : string + { + } + + /** + * Converts text to URL-friendly strings + * + * Parameters + * `text` The text to be processed + * `separator` Separator to use (default '-') + * `lowercase` Convert to lowercase + * `replace` + * + * + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->friendlyTitle( + * [ + * 'text' => 'These are big important news', + * 'separator' => '-', + * ] + * ); + * + * + * Volt Syntax: + * + * {{ friendly_title(['text': 'These are big important news', 'separator': '-']) }} + * + */ + public function friendlyTitle(string $text, array $parameters = []) : string + { + } + + /** + * Returns the internal dependency injector + */ + public function getDI() : DiInterface + { + } + + /** + * Get the document type declaration of content. If the docType has not + * been set properly, XHTML5 is returned + */ + public function getDocType() : string + { + } + + /** + * Gets the current document title. The title will be automatically escaped. + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->getTitle(); // Hello World from Phalcon + * echo $tag->getTitle(false); // World from Phalcon + * echo $tag->getTitle(true, false); // Hello World + * echo $tag->getTitle(false, false); // World + * + * + * Volt syntax: + * + * {{ get_title() }} + * + */ + public function getTitle(bool $prepend = true, bool $append = true) : string + { + } + + /** + * Gets the current document title separator + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->getTitleSeparator(); + * + * + * Volt syntax: + * + * {{ get_title_separator() }} + * + */ + public function getTitleSeparator() : string + { + } + + /** + * Every helper calls this function to check whether a component has a predefined + * value using `setAttribute` or value from $_POST + */ + public function getValue(string $name, array $parameters = []) { + } + + /** + * Check if a helper has a default value set using `setAttribute()` or + * value from $_POST + */ + public function hasValue(string $name) : bool + { + } + + /** + * Builds HTML IMG tags + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->image('img/bg.png'); + * + * echo $tag->image( + * 'img/photo.jpg', + * [ + * 'alt' => 'Some Photo', + * ] + * ); + * + * echo $tag->image( + * 'http://static.mywebsite.com/img/bg.png', + * [ + * 'local' => false, + * ] + * ); + * + * + * Volt Syntax: + * + * {{ image('img/bg.png') }} + * {{ image('img/photo.jpg', ['alt': 'Some Photo') }} + * {{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }} + * + */ + public function image(string $url = "", array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="check"] tag + * + * + * echo $tag->inputCheckbox( + * [ + * 'name' => 'terms, + * 'value' => 'Y', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_checkbox(['name': 'terms, 'value': 'Y']) }} + * + * + * @param array parameters + */ + public function inputCheckbox(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='color'] tag + */ + public function inputColor(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='date'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDate( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDate(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='datetime'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTime( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date_time(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDateTime(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='datetime-local'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTimeLocal( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }} + * + */ + public function inputDateTimeLocal(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='email'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputEmail( + * [ + * 'name' => 'email', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_email(['name': 'email']); + * + */ + public function inputEmail(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='file'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputFile( + * [ + * 'name' => 'file', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_file(['name': 'file']); + * + */ + public function inputFile(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='hidden'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputHidden( + * [ + * 'name' => 'my-field', + * 'value' => 'mike', + * ] + * ); + * + */ + public function inputHidden(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="image"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->inputImage( + * [ + * 'src' => '/img/button.png', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_image(['src': '/img/button.png']) }} + * + */ + public function inputImage(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='month'] tag + */ + public function inputMonth(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='number'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->numericField( + * [ + * 'name' => 'price', + * 'min' => '1', + * 'max' => '5', + * ] + * ); + * + */ + public function inputNumeric(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='password'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->passwordField( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * + */ + public function inputPassword(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="radio"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputRadio( + * [ + * 'name' => 'weather', + * 'value" => 'hot', + * ] + * ); + * + * + * Volt syntax: + * + * {{ input_radio(['name': 'weather', 'value": 'hot']) }} + * + */ + public function inputRadio(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='range'] tag + */ + public function inputRange(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='search'] tag + */ + public function inputSearch(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='tel'] tag + */ + public function inputTel(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='text'] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputText( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * + */ + public function inputText(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='time'] tag + */ + public function inputTime(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='url'] tag + */ + public function inputUrl(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type='week'] tag + */ + public function inputWeek(string $name, array $parameters = []) : string + { + } + + /** + * Builds a script[type="javascript"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->javascript( + * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', + * ['local' => false] + * ); + * echo $tag->javascript('javascript/jquery.js'); + * + * + * Volt syntax: + * + * {{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }} + * {{ javascript('javascript/jquery.js') }} + * + */ + public function javascript(string $url, array $parameters = []) : string + { + } + + /** + * Builds a HTML A tag using framework conventions + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->link('signup/register', 'Register Here!'); + * + * echo $tag->link( + * 'signup/register', + * 'Register Here!', + * [ + * 'class' => 'btn-primary', + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->linkTo( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * 'target' => '_new' + * ] + * ); + * + * + */ + public function link(string $url, string $text = "", array $parameters = []) : string + { + } + + /** + * Prepends a text to current document title + */ + public function prependTitle(array $title) : Tag + { + } + + /** + * Renders the title with title tags. The title is automaticall escaped + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->renderTitle(); // Hello World from Phalcon + * echo $tag->renderTitle(false); // World from Phalcon + * echo $tag->renderTitle(true, false); // Hello World + * echo $tag->renderTitle(false, false); // World + * + * + * + * {{ render_title() }} + * + */ + public function renderTitle(bool $prepend = true, bool $append = true) : string + { + } + + /** + * Builds a HTML input[type="reset"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->reset('Reset') + * + * + * Volt syntax: + * + * {{ reset('Save') }} + * + */ + public function reset(string $name, array $parameters = []) : string + { + } + + /** + * Builds a select element. It accepts an array or a resultset from + * a Phalcon\Mvc\Model + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Status...', + * ], + * [ + * 'A' => 'Active', + * 'I' => 'Inactive', + * ] + * ); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Type...', + * 'using' => [ + * 'id, + * 'name', + * ], + * ], + * Robots::find( + * [ + * 'conditions' => 'type = :type:', + * 'bind' => [ + * 'type' => 'mechanical', + * ] + * ] + * ) + * ); + * + * + * + * @param array parameters + * @param array data + */ + public function select(string $name, array $parameters = [], $data = null) : string + { + } + + /** + * Assigns default values to generated tags by helpers + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute('name', 'peter'); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * + */ + public function setAttribute(string $name, $value) : Tag + { + } + + /** + * Assigns default values to generated tags by helpers + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute( + * [ + * 'name' => 'peter', + * ] + * ); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * + */ + public function setAttributes(array $values, bool $merge = false) : Tag + { + } + + /** + * Sets the dependency injector + */ + public function setDI(DiInterface $container) : void + { + } + + /** + * Set the document type of content + * + * @param int doctype A valid doctype for the content + * + * @return + */ + public function setDocType(int $doctype) : Tag + { + } + + /** + * Set the title separator of view content + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag->setTitle('Phalcon Framework'); + * + */ + public function setTitle(string $title) : Tag + { + } + + /** + * Set the title separator of view content + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->setTitleSeparator('-'); + * + */ + public function setTitleSeparator(string $separator) : Tag + { + } + + /** + * Builds a LINK[rel="stylesheet"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->stylesheet( + * 'http://fonts.googleapis.com/css?family=Rosario', + * ['local' => false] + * ); + * echo $tag->stylesheet('css/style.css'); + * + * + * Volt syntax: + * + * {{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }} + * {{ stylesheet('css/style.css') }} + * + */ + public function stylesheet(string $url, array $parameters = []) : string + { + } + + /** + * Builds a HTML input[type="submit"] tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + *public + * echo $tag->submit('Save') + * + * + * Volt syntax: + * + * {{ submit('Save') }} + * + */ + public function submit(string $name, array $parameters = []) : string + { + } + + /** + * Builds a HTML TEXTAREA tag + * + * + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->textArea( + * 'comments', + * [ + * 'cols' => 10, + * 'rows' => 4, + * ] + * ); + * + * + * Volt syntax: + * + * {{ text_area('comments', ['cols': 10, 'rows': 4]) }} + * + */ + public function textArea(string $name, array $parameters = []) : string + { + } + + /** + * Returns the escaper service from the DI container + */ + private function getService(string $name) + { + } + + /** + * Renders the attributes of an HTML element + */ + private function renderAttributes(string $code, array $attributes) : string + { + } + + /** + * Returns the closing tag depending on the doctype + */ + private function renderCloseTag(bool $addEol = false) : string + { + } + + /** + * Builds `input` elements + */ + private function renderInput(string $type, string $name, array $parameters = []) : string + { + } + /** + * Builds INPUT tags that implements the checked attribute + */ + private function renderInputChecked(string $type, string $name, array $parameters = []) : string + { + } + + /** + * Generates the option values or optgroup from an array + */ + private function renderSelectArray(array $options, $value, string $closeOption) : string + { + } + + /** + * Generates the option values from a resultset + */ + private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption) : string + { + } } diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php deleted file mode 100644 index 3621c52c..00000000 --- a/src/Phalcon/html/TagFactory.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ - private $escaper; - - - /** - * TagFactory constructor. - * - * @param \Phalcon\Escaper\EscaperInterface $escaper - * @param array $services - */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) {} - - /** - * @param string name - * - * @throws Exception - * @param string $name - * @return mixed - */ - public function newInstance(string $name) {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/html/Taglocator.php b/src/Phalcon/html/Taglocator.php new file mode 100644 index 00000000..2cebb261 --- /dev/null +++ b/src/Phalcon/html/Taglocator.php @@ -0,0 +1,14 @@ + - */ - protected $escaper; - - - /** - * Constructor - * - * @param \Phalcon\Escaper\EscaperInterface $escaper - */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) {} - - /** - * Renders an element - * - * @param string $tag - * @param string $text - * @param array $attributes - * @param bool $raw - * @return string - */ - protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string {} - - /** - * Renders an element - * - * @param string $tag - * @param array $attributes - * @return string - */ - protected function renderElement(string $tag, array $attributes = array()): string {} - - /** - * Keeps all the attributes sorted - same order all the tome - * - * @param array attributes - * - * @param array $overrides - * @param array $attributes - * @return array - */ - protected function orderAttributes(array $overrides, array $attributes): array {} - - /** - * Renders all the attributes - * - * @param array $attributes - * @return string - */ - protected function renderAttributes(array $attributes): string {} - - /** - * Produces a self close tag i.e. - * - * @param string $tag - * @param array $attributes - * @return string - */ - protected function selfClose(string $tag, array $attributes = array()): string {} - -} diff --git a/src/Phalcon/html/helper/Abstracthelper.php b/src/Phalcon/html/helper/Abstracthelper.php new file mode 100644 index 00000000..cf39440c --- /dev/null +++ b/src/Phalcon/html/helper/Abstracthelper.php @@ -0,0 +1,54 @@ + + */ + protected $escaper; + + /** + * Constructor + */ + public function __construct(EscaperInterface $escaper) + { + } + + /** + * Keeps all the attributes sorted - same order all the tome + */ + protected function orderAttributes(array $overrides, array $attributes) : array + { + } + + /** + * Renders all the attributes + */ + protected function renderAttributes(array $attributes) : string + { + } + + /** + * Renders an element + */ + protected function renderElement(string $tag, string $text, array $attributes = []) + { + } + + /** + * Produces a self close tag i.e. + */ + protected function selfClose(string $tag, array $attributes = []) + { + } +} diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 5e8646d1..b4ecb01d 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -2,20 +2,21 @@ namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Anchor * * Creates an anchor */ -class Anchor extends \Phalcon\Html\Helper\AbstractHelper +class Anchor extends AbstractHelper { - - /** - * @param string $href - * @param string $text - * @param array $attributes - * @return string - */ - public function __invoke(string $href, string $text, array $attributes = array()): string {} - + /** + * @var string href The href tag + * @var string text The text for the anchor + * @var array attributes Any additional attributes + */ + public function __invoke(string $href, string $text, array $attributes = []) : string + { + } } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php deleted file mode 100644 index 1bdb84b7..00000000 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ /dev/null @@ -1,21 +0,0 @@ - * use Phalcon\Http\Request; * * $request = new Request(); @@ -18,67 +19,65 @@ * echo "Request was made using POST and AJAX"; * } * - * // Retrieve SERVER variables - * $request->getServer("HTTP_HOST"); - * - * // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT - * $request->getMethod(); - * - * // An array of languages the client accepts - * $request->getLanguages(); - * ``` + * $request->getServer("HTTP_HOST"); // Retrieve SERVER variables + * $request->getMethod(); // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT + * $request->getLanguages(); // An array of languages the client accepts + * */ class Request implements \Phalcon\Http\RequestInterface, \Phalcon\Di\InjectionAwareInterface { - private $container; + protected $_dependencyInjector; - private $filterService; + protected $_rawBody; - /** - * @var bool - */ - private $httpMethodParameterOverride = false; - /** - * @var array - */ - private $queryFilters = array(); + protected $_filter; - private $putCache; + protected $_putCache; - private $rawBody; + protected $_httpMethodParameterOverride = false; + + + protected $_strictHostCheck = false; + + + + public function getHttpMethodParameterOverride() {} /** - * @var bool + * @param mixed $httpMethodParameterOverride */ - private $strictHostCheck = false; - + public function setHttpMethodParameterOverride($httpMethodParameterOverride) {} /** - * @return bool + * Sets the dependency injector + * + * @param \Phalcon\DiInterface $dependencyInjector */ - public function getHttpMethodParameterOverride(): bool {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * @param bool $httpMethodParameterOverride + * Returns the internal dependency injector + * + * @return \Phalcon\DiInterface */ - public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride) {} + public function getDI() {} /** - * Gets a variable from the $_REQUEST superglobal applying filters if - * needed. If no parameters are given the $_REQUEST superglobal is returned + * Gets a variable from the $_REQUEST superglobal applying filters if needed. + * If no parameters are given the $_REQUEST superglobal is returned * - * ```php + * * // Returns value from $_REQUEST["user_email"] without sanitizing * $userEmail = $request->get("user_email"); * * // Returns value from $_REQUEST["user_email"] with sanitizing * $userEmail = $request->get("user_email", "email"); - * ``` + * * * @param string $name * @param mixed $filters @@ -87,637 +86,559 @@ public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride * @param bool $noRecursive * @return mixed */ - public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} - - /** - * Gets an array with mime/types and their quality accepted by the - * browser/client from _SERVER["HTTP_ACCEPT"] - * - * @return array - */ - public function getAcceptableContent(): array {} + public function get($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} /** - * Gets auth info accepted by the browser/client from - * $_SERVER["PHP_AUTH_USER"] + * Gets a variable from the $_POST superglobal applying filters if needed + * If no parameters are given the $_POST superglobal is returned * - * @return array|null - */ - public function getBasicAuth(): ?array {} - - /** - * Gets best mime/type accepted by the browser/client from - * _SERVER["HTTP_ACCEPT"] + * + * // Returns value from $_POST["user_email"] without sanitizing + * $userEmail = $request->getPost("user_email"); * - * @return string - */ - public function getBestAccept(): string {} - - /** - * Gets best charset accepted by the browser/client from - * _SERVER["HTTP_ACCEPT_CHARSET"] + * // Returns value from $_POST["user_email"] with sanitizing + * $userEmail = $request->getPost("user_email", "email"); + * * - * @return string + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getBestCharset(): string {} + public function getPost($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} /** - * Gets best language accepted by the browser/client from - * _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Gets a variable from put request * - * @return string - */ - public function getBestLanguage(): string {} - - /** - * Gets most possible client IPv4 Address. This method searches in - * `$_SERVER["REMOTE_ADDR"]` and optionally in - * `$_SERVER["HTTP_X_FORWARDED_FOR"]` + * + * // Returns value from $_PUT["user_email"] without sanitizing + * $userEmail = $request->getPut("user_email"); * - * @param bool $trustForwardedHeader - * @return string|bool - */ - public function getClientAddress(bool $trustForwardedHeader = false) {} - - /** - * Gets a charsets array and their quality accepted by the browser/client - * from _SERVER["HTTP_ACCEPT_CHARSET"] + * // Returns value from $_PUT["user_email"] with sanitizing + * $userEmail = $request->getPut("user_email", "email"); + * * - * @return array + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getClientCharsets(): array {} + public function getPut($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} /** - * Gets content type which request has been made + * Gets variable from $_GET superglobal applying filters if needed + * If no parameters are given the $_GET superglobal is returned * - * @return string|null - */ - public function getContentType(): ?string {} - - /** - * Returns the internal dependency injector + * + * // Returns value from $_GET["id"] without sanitizing + * $id = $request->getQuery("id"); * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Gets auth info accepted by the browser/client from - * $_SERVER["PHP_AUTH_DIGEST"] + * // Returns value from $_GET["id"] with sanitizing + * $id = $request->getQuery("id", "int"); * - * @return array - */ - public function getDigestAuth(): array {} - - /** - * Retrieves a query/get value always sanitized with the preset filters + * // Returns value from $_GET["id"] with a default value + * $id = $request->getQuery("id", null, 150); + * * * @param string $name + * @param mixed $filters * @param mixed $defaultValue * @param bool $notAllowEmpty * @param bool $noRecursive * @return mixed */ - public function getFilteredQuery(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getQuery($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} /** - * Retrieves a post value always sanitized with the preset filters + * Helper to get data from superglobals, applying filters if needed. + * If no parameters are given the superglobal is returned. * + * @param array $source * @param string $name + * @param mixed $filters * @param mixed $defaultValue * @param bool $notAllowEmpty * @param bool $noRecursive * @return mixed */ - public function getFilteredPost(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + protected final function getHelper(array $source, $name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} /** - * Retrieves a put value always sanitized with the preset filters + * Gets variable from $_SERVER superglobal * * @param string $name - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return string|null */ - public function getFilteredPut(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getServer($name) {} /** - * Gets HTTP header from request data + * Checks whether $_REQUEST superglobal has certain index * - * @param string $header - * @return string + * @param string $name + * @return bool */ - final public function getHeader(string $header): string {} + public function has($name) {} /** - * Returns the available headers in the request - * - * - * $_SERVER = [ - * "PHP_AUTH_USER" => "phalcon", - * "PHP_AUTH_PW" => "secret", - * ]; - * - * $headers = $request->getHeaders(); - * - * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= - * + * Checks whether $_POST superglobal has certain index * - * @return array + * @param string $name + * @return bool */ - public function getHeaders(): array {} + public function hasPost($name) {} /** - * Gets host name used by the request. - * - * `Request::getHttpHost` trying to find host name in following order: - * - * - `$_SERVER["HTTP_HOST"]` - * - `$_SERVER["SERVER_NAME"]` - * - `$_SERVER["SERVER_ADDR"]` - * - * Optionally `Request::getHttpHost` validates and clean host name. - * The `Request::$strictHostCheck` can be used to validate host name. - * - * Note: validation and cleaning have a negative performance impact because - * they use regular expressions. - * - * ```php - * use Phalcon\Http\Request; - * - * $request = new Request; - * - * $_SERVER["HTTP_HOST"] = "example.com"; - * $request->getHttpHost(); // example.com - * - * $_SERVER["HTTP_HOST"] = "example.com:8080"; - * $request->getHttpHost(); // example.com:8080 - * - * $request->setStrictHostCheck(true); - * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; - * $request->getHttpHost(); // UnexpectedValueException - * - * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; - * $request->getHttpHost(); // example.com - * ``` + * Checks whether the PUT data has certain index * - * @return string + * @param string $name + * @return bool */ - public function getHttpHost(): string {} + public function hasPut($name) {} /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks whether $_GET superglobal has certain index * - * @return string + * @param string $name + * @return bool */ - public function getHTTPReferer(): string {} + public function hasQuery($name) {} /** - * Gets decoded JSON HTTP raw request body + * Checks whether $_SERVER superglobal has certain index * - * @param bool $associative - * @return array|bool|\stdClass + * @param string $name + * @return bool */ - public function getJsonRawBody(bool $associative = false) {} + public final function hasServer($name) {} /** - * Gets languages array and their quality accepted by the browser/client - * from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether headers has certain index * - * @return array + * @param string $header + * @return bool */ - public function getLanguages(): array {} + public final function hasHeader($header) {} /** - * Gets HTTP method which request has been made - * - * If the X-HTTP-Method-Override header is set, and if the method is a POST, - * then it is used to determine the "real" intended HTTP method. - * - * The _method request parameter can also be used to determine the HTTP - * method, but only if setHttpMethodParameterOverride(true) has been called. - * - * The method is always an uppercased string. + * Gets HTTP header from request data * + * @param string $header * @return string */ - final public function getMethod(): string {} + public final function getHeader($header) {} /** - * Gets information about the port on which the request is made. + * Gets HTTP schema (http/https) * - * @return int + * @return string */ - public function getPort(): int {} + public function getScheme() {} /** - * Gets a variable from the $_POST superglobal applying filters if needed - * If no parameters are given the $_POST superglobal is returned - * - * ```php - * // Returns value from $_POST["user_email"] without sanitizing - * $userEmail = $request->getPost("user_email"); - * - * // Returns value from $_POST["user_email"] with sanitizing - * $userEmail = $request->getPost("user_email", "email"); - * ``` + * Checks whether request has been made using ajax * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return bool */ - public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function isAjax() {} /** - * Gets a variable from put request - * - * ```php - * // Returns value from $_PUT["user_email"] without sanitizing - * $userEmail = $request->getPut("user_email"); - * - * // Returns value from $_PUT["user_email"] with sanitizing - * $userEmail = $request->getPut("user_email", "email"); - * ``` + * Checks whether request has been made using SOAP * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return bool */ - public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function isSoap() {} /** - * Gets variable from $_GET superglobal applying filters if needed - * If no parameters are given the $_GET superglobal is returned - * - * ```php - * // Returns value from $_GET["id"] without sanitizing - * $id = $request->getQuery("id"); - * - * // Returns value from $_GET["id"] with sanitizing - * $id = $request->getQuery("id", "int"); + * Alias of isSoap(). It will be deprecated in future versions * - * // Returns value from $_GET["id"] with a default value - * $id = $request->getQuery("id", null, 150); - * ``` + * @deprecated + * @return bool + */ + public function isSoapRequested() {} + + /** + * Checks whether request has been made using any secure layer * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return bool */ - public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function isSecure() {} /** - * Gets HTTP raw request body + * Alias of isSecure(). It will be deprecated in future versions * - * @return string + * @deprecated + * @return bool */ - public function getRawBody(): string {} + public function isSecureRequest() {} /** - * Gets HTTP schema (http/https) + * Gets HTTP raw request body * * @return string */ - public function getScheme(): string {} + public function getRawBody() {} /** - * Gets variable from $_SERVER superglobal + * Gets decoded JSON HTTP raw request body * - * @param string $name - * @return string|null + * @param bool $associative + * @return array|bool|\stdClass */ - public function getServer(string $name): ?string {} + public function getJsonRawBody($associative = false) {} /** * Gets active server address IP * * @return string */ - public function getServerAddress(): string {} + public function getServerAddress() {} /** * Gets active server name * * @return string */ - public function getServerName(): string {} + public function getServerName() {} /** - * Gets attached files as Phalcon\Http\Request\File instances + * Gets host name used by the request. * - * @param bool $onlySuccessful - * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] - */ - public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array {} - - /** - * Gets HTTP URI which request has been made + * `Request::getHttpHost` trying to find host name in following order: + * + * - `$_SERVER["HTTP_HOST"]` + * - `$_SERVER["SERVER_NAME"]` + * - `$_SERVER["SERVER_ADDR"]` + * + * Optionally `Request::getHttpHost` validates and clean host name. + * The `Request::$_strictHostCheck` can be used to validate host name. + * + * Note: validation and cleaning have a negative performance impact because + * they use regular expressions. + * + * + * use Phalcon\Http\Request; + * + * $request = new Request; + * + * $_SERVER["HTTP_HOST"] = "example.com"; + * $request->getHttpHost(); // example.com + * + * $_SERVER["HTTP_HOST"] = "example.com:8080"; + * $request->getHttpHost(); // example.com:8080 + * + * $request->setStrictHostCheck(true); + * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; + * $request->getHttpHost(); // UnexpectedValueException + * + * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; + * $request->getHttpHost(); // example.com + * * * @return string */ - final public function getURI(): string {} + public function getHttpHost() {} /** - * Gets HTTP user agent used to made the request + * Sets if the `Request::getHttpHost` method must be use strict validation of host name or not * - * @return string + * @param bool $flag + * @return Request */ - public function getUserAgent(): string {} + public function setStrictHostCheck($flag = true) {} /** - * Checks whether $_REQUEST superglobal has certain index + * Checks if the `Request::getHttpHost` method will be use strict validation of host name or not * - * @param string $name * @return bool */ - public function has(string $name): bool {} + public function isStrictHostCheck() {} /** - * Returns the number of files available + * Gets information about the port on which the request is made. * - * TODO: Check this + * @return int + */ + public function getPort() {} + + /** + * Gets HTTP URI which request has been made * - * @param bool $onlySuccessful - * @return long + * @return string */ - public function hasFiles(bool $onlySuccessful = false): int {} + public final function getURI() {} /** - * Checks whether headers has certain index + * Gets most possible client IPv4 Address. This method searches in + * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] * - * @param string $header - * @return bool + * @param bool $trustForwardedHeader + * @return string|bool */ - final public function hasHeader(string $header): bool {} + public function getClientAddress($trustForwardedHeader = false) {} /** - * Checks whether $_POST superglobal has certain index + * Gets HTTP method which request has been made * - * @param string $name - * @return bool + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP method, + * but only if setHttpMethodParameterOverride(true) has been called. + * + * The method is always an uppercased string. + * + * @return string */ - public function hasPost(string $name): bool {} + public final function getMethod() {} /** - * Checks whether the PUT data has certain index + * Gets HTTP user agent used to made the request * - * @param string $name - * @return bool + * @return string */ - public function hasPut(string $name): bool {} + public function getUserAgent() {} /** - * Checks whether $_GET superglobal has certain index + * Checks if a method is a valid HTTP method * - * @param string $name + * @param string $method * @return bool */ - public function hasQuery(string $name): bool {} + public function isValidHttpMethod($method) {} /** - * Checks whether $_SERVER superglobal has certain index + * Check if HTTP method match any of the passed methods + * When strict is true it checks if validated methods are real HTTP methods * - * @param string $name + * @param mixed $methods + * @param bool $strict * @return bool */ - final public function hasServer(string $name): bool {} + public function isMethod($methods, $strict = false) {} /** - * Checks whether request has been made using ajax + * Checks whether HTTP method is POST. if _SERVER["REQUEST_METHOD"]==="POST" * * @return bool */ - public function isAjax(): bool {} + public function isPost() {} /** - * Checks whether HTTP method is CONNECT. - * if _SERVER["REQUEST_METHOD"]==="CONNECT" + * Checks whether HTTP method is GET. if _SERVER["REQUEST_METHOD"]==="GET" * * @return bool */ - public function isConnect(): bool {} + public function isGet() {} /** - * Checks whether HTTP method is DELETE. - * if _SERVER["REQUEST_METHOD"]==="DELETE" + * Checks whether HTTP method is PUT. if _SERVER["REQUEST_METHOD"]==="PUT" * * @return bool */ - public function isDelete(): bool {} + public function isPut() {} /** - * Checks whether HTTP method is GET. - * if _SERVER["REQUEST_METHOD"]==="GET" + * Checks whether HTTP method is PATCH. if _SERVER["REQUEST_METHOD"]==="PATCH" * * @return bool */ - public function isGet(): bool {} + public function isPatch() {} /** - * Checks whether HTTP method is HEAD. - * if _SERVER["REQUEST_METHOD"]==="HEAD" + * Checks whether HTTP method is HEAD. if _SERVER["REQUEST_METHOD"]==="HEAD" * * @return bool */ - public function isHead(): bool {} + public function isHead() {} /** - * Check if HTTP method match any of the passed methods - * When strict is true it checks if validated methods are real HTTP methods + * Checks whether HTTP method is DELETE. if _SERVER["REQUEST_METHOD"]==="DELETE" * - * @param mixed $methods - * @param bool $strict * @return bool */ - public function isMethod($methods, bool $strict = false): bool {} + public function isDelete() {} /** - * Checks whether HTTP method is OPTIONS. - * if _SERVER["REQUEST_METHOD"]==="OPTIONS" + * Checks whether HTTP method is OPTIONS. if _SERVER["REQUEST_METHOD"]==="OPTIONS" * * @return bool */ - public function isOptions(): bool {} + public function isOptions() {} /** - * Checks whether HTTP method is PATCH. - * if _SERVER["REQUEST_METHOD"]==="PATCH" + * Checks whether HTTP method is PURGE (Squid and Varnish support). if _SERVER["REQUEST_METHOD"]==="PURGE" * * @return bool */ - public function isPatch(): bool {} + public function isPurge() {} /** - * Checks whether HTTP method is POST. - * if _SERVER["REQUEST_METHOD"]==="POST" + * Checks whether HTTP method is TRACE. if _SERVER["REQUEST_METHOD"]==="TRACE" * * @return bool */ - public function isPost(): bool {} + public function isTrace() {} /** - * Checks whether HTTP method is PUT. - * if _SERVER["REQUEST_METHOD"]==="PUT" + * Checks whether HTTP method is CONNECT. if _SERVER["REQUEST_METHOD"]==="CONNECT" * * @return bool */ - public function isPut(): bool {} + public function isConnect() {} /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). - * if _SERVER["REQUEST_METHOD"]==="PURGE" + * Checks whether request include attached files * - * @return bool + * @param bool $onlySuccessful + * @return long */ - public function isPurge(): bool {} + public function hasFiles($onlySuccessful = false) {} /** - * Checks whether request has been made using any secure layer + * Recursively counts file in an array of files * - * @return bool + * @param mixed $data + * @param bool $onlySuccessful + * @return long */ - public function isSecure(): bool {} + protected final function hasFileHelper($data, $onlySuccessful) {} /** - * Checks if the `Request::getHttpHost` method will be use strict validation - * of host name or not + * Gets attached files as Phalcon\Http\Request\File instances * - * @return bool + * @param bool $onlySuccessful + * @return \Phalcon\Http\Request\FileInterface[] */ - public function isStrictHostCheck(): bool {} + public function getUploadedFiles($onlySuccessful = false) {} /** - * Checks whether request has been made using SOAP + * Smooth out $_FILES to have plain array with all files uploaded * - * @return bool + * @param array $names + * @param array $types + * @param array $tmp_names + * @param array $sizes + * @param array $errors + * @param string $prefix + * @return array */ - public function isSoap(): bool {} + protected final function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, $prefix) {} /** - * Checks whether HTTP method is TRACE. - * if _SERVER["REQUEST_METHOD"]==="TRACE" + * Returns the available headers in the request * - * @return bool + * + * $_SERVER = [ + * "PHP_AUTH_USER" => "phalcon", + * "PHP_AUTH_PW" => "secret", + * ]; + * + * $headers = $request->getHeaders(); + * + * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= + * + * + * @return array */ - public function isTrace(): bool {} + public function getHeaders() {} /** - * Checks if a method is a valid HTTP method + * Resolve authorization headers. * - * @param string $method - * @return bool + * @return array */ - public function isValidHttpMethod(string $method): bool {} + protected function resolveAuthorizationHeaders() {} /** - * Sets the dependency injector + * Gets web page that refers active request. ie: http://www.google.com * - * @param \Phalcon\Di\DiInterface $container + * @return string */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getHTTPReferer() {} /** - * Sets automatic sanitizers/filters for a particular field and for - * particular methods + * Process a request header and return the one with best quality * + * @param array $qualityParts * @param string $name - * @param array $filters - * @param array $scope - * @return RequestInterface + * @return string */ - public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface {} + protected final function _getBestQuality(array $qualityParts, $name) {} /** - * Sets if the `Request::getHttpHost` method must be use strict validation - * of host name or not + * Gets content type which request has been made * - * @param bool $flag - * @return RequestInterface + * @return string|null */ - public function setStrictHostCheck(bool $flag = true): RequestInterface {} + public function getContentType() {} /** - * Process a request header and return the one with best quality + * Gets an array with mime/types and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT"] + * + * @return array + */ + public function getAcceptableContent() {} + + /** + * Gets best mime/type accepted by the browser/client from _SERVER["HTTP_ACCEPT"] * - * @param array $qualityParts - * @param string $name * @return string */ - final protected function getBestQuality(array $qualityParts, string $name): string {} + public function getBestAccept() {} /** - * Helper to get data from superglobals, applying filters if needed. - * If no parameters are given the superglobal is returned. + * Gets a charsets array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param array $source - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return array */ - final protected function getHelper(array $source, string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getClientCharsets() {} /** - * Recursively counts file in an array of files + * Gets best charset accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param mixed $data - * @param bool $onlySuccessful - * @return long + * @return string */ - final protected function hasFileHelper($data, bool $onlySuccessful): int {} + public function getBestCharset() {} /** - * Process a request header and return an array of values with their qualities + * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @param string $serverIndex - * @param string $name * @return array */ - final protected function getQualityHeader(string $serverIndex, string $name): array {} + public function getLanguages() {} /** - * Resolve authorization headers. + * Gets best language accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return array + * @return string */ - protected function resolveAuthorizationHeaders(): array {} + public function getBestLanguage() {} /** - * Smooth out $_FILES to have plain array with all files uploaded + * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] * - * @param array $names - * @param array $types - * @param array $tmp_names - * @param array $sizes - * @param array $errors - * @param string $prefix - * @return array + * @return array|null */ - final protected function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, string $prefix): array {} + public function getBasicAuth() {} /** - * Checks the filter service and assigns it to the class parameter + * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] * - * @return \Phalcon\Filter\FilterInterface + * @return array */ - private function getFilterService(): FilterInterface {} + public function getDigestAuth() {} /** + * Process a request header and return an array of values with their qualities + * + * @param string $serverIndex + * @param string $name * @return array */ - private function getServerArray(): array {} + protected final function _getQualityHeader($serverIndex, $name) {} } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 853091b0..493883ff 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -3,104 +3,90 @@ namespace Phalcon\Http; /** + * Phalcon\Http\RequestInterface + * * Interface for Phalcon\Http\Request */ interface RequestInterface { /** - * Gets a variable from the $_REQUEST superglobal applying filters if - * needed. If no parameters are given the $_REQUEST superglobal is returned - * - * ```php - * // Returns value from $_REQUEST["user_email"] without sanitizing - * $userEmail = $request->get("user_email"); - * - * // Returns value from $_REQUEST["user_email"] with sanitizing - * $userEmail = $request->get("user_email", "email"); - * ``` + * Gets a variable from the $_REQUEST superglobal applying filters if needed * * @param string $name - * @param mixed $filters + * @param string|array $filters * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive * @return mixed */ - public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); - - /** - * Gets an array with mime/types and their quality accepted by the - * browser/client from _SERVER["HTTP_ACCEPT"] - * - * @return array - */ - public function getAcceptableContent(): array; + public function get($name = null, $filters = null, $defaultValue = null); /** - * Gets auth info accepted by the browser/client from - * $_SERVER["PHP_AUTH_USER"] + * Gets a variable from the $_POST superglobal applying filters if needed * - * @return array|null + * @param string $name + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function getBasicAuth(): ?array; + public function getPost($name = null, $filters = null, $defaultValue = null); /** - * Gets best mime/type accepted by the browser/client from - * _SERVER["HTTP_ACCEPT"] + * Gets variable from $_GET superglobal applying filters if needed * - * @return string + * @param string $name + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function getBestAccept(): string; + public function getQuery($name = null, $filters = null, $defaultValue = null); /** - * Gets best charset accepted by the browser/client from - * _SERVER["HTTP_ACCEPT_CHARSET"] + * Gets variable from $_SERVER superglobal * - * @return string + * @param string $name + * @return mixed */ - public function getBestCharset(): string; + public function getServer($name); /** - * Gets best language accepted by the browser/client from - * _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether $_REQUEST superglobal has certain index * - * @return string + * @param string $name + * @return bool */ - public function getBestLanguage(): string; + public function has($name); /** - * Gets most possible client IPv4 Address. This method searches in - * $_SERVER["REMOTE_ADDR"] and optionally in - * $_SERVER["HTTP_X_FORWARDED_FOR"] + * Checks whether $_POST superglobal has certain index * - * @param bool $trustForwardedHeader - * @return string|bool + * @param string $name + * @return bool */ - public function getClientAddress(bool $trustForwardedHeader = false); + public function hasPost($name); /** - * Gets a charsets array and their quality accepted by the browser/client - * from _SERVER["HTTP_ACCEPT_CHARSET"] + * Checks whether the PUT data has certain index * - * @return array + * @param string $name + * @return bool */ - public function getClientCharsets(): array; + public function hasPut($name); /** - * Gets content type which request has been made + * Checks whether $_GET superglobal has certain index * - * @return string|null + * @param string $name + * @return bool */ - public function getContentType(): ?string; + public function hasQuery($name); /** - * Gets auth info accepted by the browser/client from - * $_SERVER["PHP_AUTH_DIGEST"] + * Checks whether $_SERVER superglobal has certain index * - * @return array + * @param string $name + * @return bool */ - public function getDigestAuth(): array; + public function hasServer($name); /** * Gets HTTP header from request data @@ -108,383 +94,243 @@ public function getDigestAuth(): array; * @param string $header * @return string */ - public function getHeader(string $header): string; - - /** - * Returns the available headers in the request - * - * ```php - * $_SERVER = [ - * "PHP_AUTH_USER" => "phalcon", - * "PHP_AUTH_PW" => "secret", - * ]; - * - * $headers = $request->getHeaders(); - * - * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= - * ``` - * - * @return array - */ - public function getHeaders(): array; + public function getHeader($header); /** - * Gets host name used by the request. - * - * `Request::getHttpHost` trying to find host name in following order: - * - * - `$_SERVER["HTTP_HOST"]` - * - `$_SERVER["SERVER_NAME"]` - * - `$_SERVER["SERVER_ADDR"]` - * - * Optionally `Request::getHttpHost` validates and clean host name. - * The `Request::$_strictHostCheck` can be used to validate host name. - * - * Note: validation and cleaning have a negative performance impact because - * they use regular expressions. - * - * ```php - * use Phalcon\Http\Request; - * - * $request = new Request; - * - * $_SERVER["HTTP_HOST"] = "example.com"; - * $request->getHttpHost(); // example.com - * - * $_SERVER["HTTP_HOST"] = "example.com:8080"; - * $request->getHttpHost(); // example.com:8080 - * - * $request->setStrictHostCheck(true); - * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; - * $request->getHttpHost(); // UnexpectedValueException - * - * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; - * $request->getHttpHost(); // example.com - * ``` + * Gets HTTP schema (http/https) * * @return string */ - public function getHttpHost(): string; + public function getScheme(); /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" * - * @return string + * @return bool */ - public function getHTTPReferer(): string; + public function isAjax(); /** - * Gets decoded JSON HTTP raw request body + * Checks whether request has been made using SOAP * - * @param bool $associative - * @return array|bool|\stdClass + * @return bool */ - public function getJsonRawBody(bool $associative = false); + public function isSoapRequested(); /** - * Gets languages array and their quality accepted by the browser/client - * from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether request has been made using any secure layer * - * @return array + * @return bool */ - public function getLanguages(): array; + public function isSecureRequest(); /** - * Gets HTTP method which request has been made - * - * If the X-HTTP-Method-Override header is set, and if the method is a POST, - * then it is used to determine the "real" intended HTTP method. - * - * The _method request parameter can also be used to determine the HTTP - * method, but only if setHttpMethodParameterOverride(true) has been called. - * - * The method is always an uppercased string. + * Gets HTTP raw request body * * @return string */ - public function getMethod(): string; - - /** - * Gets information about the port on which the request is made - * - * @return int - */ - public function getPort(): int; + public function getRawBody(); /** - * Gets HTTP URI which request has been made + * Gets active server address IP * * @return string */ - final public function getURI(): string; - - /** - * Gets a variable from the $_POST superglobal applying filters if needed - * If no parameters are given the $_POST superglobal is returned - * - * ```php - * // Returns value from $_POST["user_email"] without sanitizing - * $userEmail = $request->getPost("user_email"); - * - * // Returns value from $_POST["user_email"] with sanitizing - * $userEmail = $request->getPost("user_email", "email"); - * ``` - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed - */ - public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); - - /** - * Gets a variable from put request - * - * ```php - * // Returns value from $_PUT["user_email"] without sanitizing - * $userEmail = $request->getPut("user_email"); - * - * // Returns value from $_PUT["user_email"] with sanitizing - * $userEmail = $request->getPut("user_email", "email"); - * ``` - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed - */ - public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); - - /** - * Gets variable from $_GET superglobal applying filters if needed - * If no parameters are given the $_GET superglobal is returned - * - * ```php - * // Returns value from $_GET["id"] without sanitizing - * $id = $request->getQuery("id"); - * - * // Returns value from $_GET["id"] with sanitizing - * $id = $request->getQuery("id", "int"); - * - * // Returns value from $_GET["id"] with a default value - * $id = $request->getQuery("id", null, 150); - * ``` - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed - */ - public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); + public function getServerAddress(); /** - * Gets HTTP raw request body + * Gets active server name * * @return string */ - public function getRawBody(): string; + public function getServerName(); /** - * Gets HTTP schema (http/https) + * Gets host name used by the request * * @return string */ - public function getScheme(): string; + public function getHttpHost(); /** - * Gets variable from $_SERVER superglobal + * Gets information about the port on which the request is made * - * @param string $name - * @return string|null + * @return int */ - public function getServer(string $name): ?string; + public function getPort(); /** - * Gets active server address IP + * Gets most possibly client IPv4 Address. This methods searches in + * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] * - * @return string + * @param bool $trustForwardedHeader + * @return string|bool */ - public function getServerAddress(): string; + public function getClientAddress($trustForwardedHeader = false); /** - * Gets active server name + * Gets HTTP method which request has been made * * @return string */ - public function getServerName(): string; + public function getMethod(); /** - * Gets attached files as Phalcon\Http\Request\FileInterface compatible - * instances + * Gets HTTP user agent used to made the request * - * @param bool $onlySuccessful - * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] + * @return string */ - public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; + public function getUserAgent(); /** - * Gets HTTP user agent used to made the request + * Check if HTTP method match any of the passed methods * - * @return string + * @param string|array $methods + * @param bool $strict + * @return bool */ - public function getUserAgent(): string; + public function isMethod($methods, $strict = false); /** - * Checks whether $_REQUEST superglobal has certain index + * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" * - * @param string $name * @return bool */ - public function has(string $name): bool; + public function isPost(); /** - * Checks whether request include attached files - * TODO: We need to check the name. Not very intuitive + * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" * - * @param bool $onlySuccessful - * @return long + * @return bool */ - public function hasFiles(bool $onlySuccessful = false): int; + public function isGet(); /** - * Checks whether headers has certain index + * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" * - * @param string $header * @return bool */ - public function hasHeader(string $header): bool; + public function isPut(); /** - * Checks whether $_GET superglobal has certain index + * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" * - * @param string $name * @return bool */ - public function hasQuery(string $name): bool; + public function isHead(); /** - * Checks whether $_POST superglobal has certain index + * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" * - * @param string $name * @return bool */ - public function hasPost(string $name): bool; + public function isDelete(); /** - * Checks whether the PUT data has certain index + * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" * - * @param string $name * @return bool */ - public function hasPut(string $name): bool; + public function isOptions(); /** - * Checks whether $_SERVER superglobal has certain index + * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" * - * @param string $name * @return bool */ - public function hasServer(string $name): bool; + public function isPurge(); /** - * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" + * Checks whether HTTP method is TRACE. if $_SERVER["REQUEST_METHOD"] === "TRACE" * * @return bool */ - public function isAjax(): bool; + public function isTrace(); /** * Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT" * * @return bool */ - public function isConnect(): bool; + public function isConnect(); /** - * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" + * Checks whether request include attached files * - * @return bool + * @param boolean $onlySuccessful + * @return int */ - public function isDelete(): bool; + public function hasFiles($onlySuccessful = false); /** - * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" + * Gets attached files as Phalcon\Http\Request\FileInterface compatible instances * - * @return bool + * @param bool $onlySuccessful + * @return \Phalcon\Http\Request\FileInterface[] */ - public function isGet(): bool; + public function getUploadedFiles($onlySuccessful = false); /** - * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" + * Gets web page that refers active request. ie: http://www.google.com * - * @return bool + * @return string */ - public function isHead(): bool; + public function getHTTPReferer(); /** - * Check if HTTP method match any of the passed methods + * Gets array with mime/types and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] * - * @param string|array $methods - * @param bool $strict - * @return bool + * @return array */ - public function isMethod($methods, bool $strict = false): bool; + public function getAcceptableContent(); /** - * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" + * Gets best mime/type accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] * - * @return bool + * @return string */ - public function isOptions(): bool; + public function getBestAccept(); /** - * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" + * Gets charsets array and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] * - * @return bool + * @return array */ - public function isPost(): bool; + public function getClientCharsets(); /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" + * Gets best charset accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] * - * @return bool + * @return string */ - public function isPurge(): bool; + public function getBestCharset(); /** - * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" + * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return bool + * @return array */ - public function isPut(): bool; + public function getLanguages(); /** - * Checks whether request has been made using any secure layer + * Gets best language accepted by the browser/client from $_SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return bool + * @return string */ - public function isSecure(): bool; + public function getBestLanguage(); /** - * Checks whether request has been made using SOAP + * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] * - * @return bool + * @return array */ - public function isSoap(): bool; + public function getBasicAuth(); /** - * Checks whether HTTP method is TRACE. - * if $_SERVER["REQUEST_METHOD"] === "TRACE" + * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] * - * @return bool + * @return array */ - public function isTrace(): bool; + public function getDigestAuth(); } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 31051ef3..31dd3efe 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -3,46 +3,40 @@ namespace Phalcon\Http; /** + * Phalcon\Http\Response + * * Part of the HTTP cycle is return responses to the clients. * Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. * HTTP responses are usually composed by headers and body. * - * ```php + * * $response = new \Phalcon\Http\Response(); * * $response->setStatusCode(200, "OK"); * $response->setContent("Hello"); * * $response->send(); - * ``` + * */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface { - protected $container; - + protected $_sent = false; - protected $content; + protected $_content; - protected $cookies; + protected $_headers; - protected $eventsManager; + protected $_cookies; - protected $file; + protected $_file; - protected $headers; - /** - * @var bool - */ - protected $sent = false; - - - protected $statusCodes; + protected $_dependencyInjector; /** @@ -55,351 +49,321 @@ class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\Injection public function __construct($content = null, $code = null, $status = null) {} /** - * Appends a string to the HTTP response body + * Sets the dependency injector * - * @param mixed $content - * @return ResponseInterface + * @param \Phalcon\DiInterface $dependencyInjector */ - public function appendContent($content): ResponseInterface {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Gets the HTTP response body + * Returns the internal dependency injector * - * @return string + * @return \Phalcon\DiInterface */ - public function getContent(): string {} + public function getDI() {} /** - * Returns cookies set by the user + * Sets the HTTP response code * - * @return \Phalcon\Http\Response\CookiesInterface - */ - public function getCookies(): CookiesInterface {} - - /** - * Returns the internal dependency injector + * + * $response->setStatusCode(404, "Not Found"); + * * - * @return \Phalcon\Di\DiInterface + * @param int $code + * @param string $message + * @return ResponseInterface */ - public function getDI(): DiInterface {} + public function setStatusCode($code, $message = null) {} /** - * Returns the internal event manager + * Returns the status code * - * @return \Phalcon\Events\ManagerInterface - */ - public function getEventsManager(): ManagerInterface {} - - /** - * Returns headers set by the user + * + * echo $response->getStatusCode(); + * * - * @return \Phalcon\Http\Response\HeadersInterface + * @return int|null */ - public function getHeaders(): HeadersInterface {} + public function getStatusCode() {} /** * Returns the reason phrase * - * ```php + * * echo $response->getReasonPhrase(); - * ``` + * * * @return string|null */ - public function getReasonPhrase(): ?string {} + public function getReasonPhrase() {} /** - * Returns the status code - * - * ```php - * echo $response->getStatusCode(); - * ``` + * Sets a headers bag for the response externally * - * @return int|null + * @param \Phalcon\Http\Response\HeadersInterface $headers + * @return ResponseInterface */ - public function getStatusCode(): ?int {} + public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers) {} /** - * Checks if a header exists - * - * ```php - * $response->hasHeader("Content-Type"); - * ``` + * Returns headers set by the user * - * @param string $name - * @return bool + * @return \Phalcon\Http\Response\HeadersInterface */ - public function hasHeader(string $name): bool {} + public function getHeaders() {} /** - * Check if the response is already sent + * Sets a cookies bag for the response externally * - * @return bool + * @param \Phalcon\Http\Response\CookiesInterface $cookies + * @return Response */ - public function isSent(): bool {} + public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies) {} /** - * Redirect by HTTP to another action or URL - * - * ```php - * // Using a string redirect (internal/external) - * $response->redirect("posts/index"); - * $response->redirect("http://en.wikipedia.org", true); - * $response->redirect("http://www.example.com/new-location", true, 301); - * - * // Making a redirection based on a named route - * $response->redirect( - * [ - * "for" => "index-lang", - * "lang" => "jp", - * "controller" => "index", - * ] - * ); - * ``` + * Returns cookies set by the user * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode - * @return ResponseInterface + * @return \Phalcon\Http\Response\CookiesInterface */ - public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface {} + public function getCookies() {} /** - * Remove a header in the response + * Overwrites a header in the response * - * ```php - * $response->removeHeader("Expires"); - * ``` + * + * $response->setHeader("Content-Type", "text/plain"); + * * * @param string $name + * @param mixed $value * @return ResponseInterface */ - public function removeHeader(string $name): ResponseInterface {} + public function setHeader($name, $value) {} /** - * Resets all the established headers + * Send a raw header to the response + * + * + * $response->setRawHeader("HTTP/1.1 404 Not Found"); + * * + * @param string $header * @return ResponseInterface */ - public function resetHeaders(): ResponseInterface {} + public function setRawHeader($header) {} /** - * Prints out HTTP response to the client + * Resets all the established headers * * @return ResponseInterface */ - public function send(): ResponseInterface {} + public function resetHeaders() {} /** - * Sends cookies to the client + * Sets an Expires header in the response that allows to use the HTTP cache * + * + * $this->response->setExpires( + * new DateTime() + * ); + * + * + * @param \DateTime $datetime * @return ResponseInterface */ - public function sendCookies(): ResponseInterface {} + public function setExpires(\DateTime $datetime) {} /** - * Sends headers to the client + * Sets Last-Modified header * - * @return bool|ResponseInterface + * + * $this->response->setLastModified( + * new DateTime() + * ); + * + * + * @param \DateTime $datetime + * @return Response */ - public function sendHeaders() {} + public function setLastModified(\DateTime $datetime) {} /** * Sets Cache headers to use HTTP cache * - * ```php + * * $this->response->setCache(60); - * ``` + * * * @param int $minutes - * @return ResponseInterface + * @return Response */ - public function setCache(int $minutes): ResponseInterface {} + public function setCache($minutes) {} /** - * Sets HTTP response body - * - * ```php - * $response->setContent("

Hello!

"); - * ``` - * - * @param string $content - * @return ResponseInterface - */ - public function setContent(string $content): ResponseInterface {} - - /** - * Sets the response content-length - * - * ```php - * $response->setContentLength(2048); - * ``` + * Sends a Not-Modified response * - * @param int $contentLength * @return ResponseInterface */ - public function setContentLength(int $contentLength): ResponseInterface {} + public function setNotModified() {} /** * Sets the response content-type mime, optionally the charset * - * ```php + * * $response->setContentType("application/pdf"); * $response->setContentType("text/plain", "UTF-8"); - * ``` + * * * @param string $contentType * @param mixed $charset * @return ResponseInterface */ - public function setContentType(string $contentType, $charset = null): ResponseInterface {} + public function setContentType($contentType, $charset = null) {} /** - * Sets a cookies bag for the response externally + * Sets the response content-length * - * @param \Phalcon\Http\Response\CookiesInterface $cookies + * + * $response->setContentLength(2048); + * + * + * @param int $contentLength * @return ResponseInterface */ - public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface {} + public function setContentLength($contentLength) {} /** - * Sets the dependency injector + * Set a custom ETag * - * @param \Phalcon\Di\DiInterface $container + * + * $response->setEtag(md5(time())); + * + * + * @param string $etag + * @return Response */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setEtag($etag) {} /** - * Set a custom ETag + * Redirect by HTTP to another action or URL * - * ```php - * $response->setEtag( - * md5( - * time() - * ) + * + * // Using a string redirect (internal/external) + * $response->redirect("posts/index"); + * $response->redirect("http://en.wikipedia.org", true); + * $response->redirect("http://www.example.com/new-location", true, 301); + * + * // Making a redirection based on a named route + * $response->redirect( + * [ + * "for" => "index-lang", + * "lang" => "jp", + * "controller" => "index", + * ] * ); - * ``` + * * - * @param string $etag + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode * @return ResponseInterface */ - public function setEtag(string $etag): ResponseInterface {} + public function redirect($location = null, $externalRedirect = false, $statusCode = 302) {} /** - * Sets an Expires header in the response that allows to use the HTTP cache + * Sets HTTP response body * - * ```php - * $this->response->setExpires( - * new DateTime() - * ); - * ``` + * + * $response->setContent("

Hello!

"); + *
* - * @param \DateTime $datetime + * @param string $content * @return ResponseInterface */ - public function setExpires(\DateTime $datetime): ResponseInterface {} + public function setContent($content) {} /** - * Sets the events manager + * Sets HTTP response body. The parameter is automatically converted to JSON + * and also sets default header: Content-Type: "application/json; charset=UTF-8" * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * + * $response->setJsonContent( + * [ + * "status" => "OK", + * ] + * ); + * + * + * @param mixed $content + * @param int $jsonOptions + * @param int $depth + * @return ResponseInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setJsonContent($content, $jsonOptions = 0, $depth = 512) {} /** - * Sets an attached file to be sent at the end of the request + * Appends a string to the HTTP response body * - * @param string $filePath - * @param mixed $attachmentName - * @param mixed $attachment + * @param mixed $content * @return ResponseInterface */ - public function setFileToSend(string $filePath, $attachmentName = null, $attachment = true): ResponseInterface {} + public function appendContent($content) {} /** - * Overwrites a header in the response - * - * ```php - * $response->setHeader("Content-Type", "text/plain"); - * ``` + * Gets the HTTP response body * - * @param string $name - * @param mixed $value - * @return ResponseInterface + * @return string */ - public function setHeader(string $name, $value): ResponseInterface {} + public function getContent() {} /** - * Sets a headers bag for the response externally + * Check if the response is already sent * - * @param \Phalcon\Http\Response\HeadersInterface $headers - * @return ResponseInterface + * @return bool */ - public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface {} + public function isSent() {} /** - * Sets HTTP response body. The parameter is automatically converted to JSON - * and also sets default header: Content-Type: "application/json; charset=UTF-8" - * - * ```php - * $response->setJsonContent( - * [ - * "status" => "OK", - * ] - * ); - * ``` + * Sends headers to the client * - * @param mixed $content - * @param int $jsonOptions - * @param int $depth * @return ResponseInterface */ - public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512): ResponseInterface {} + public function sendHeaders() {} /** - * Sets Last-Modified header - * - * ```php - * $this->response->setLastModified( - * new DateTime() - * ); - * ``` + * Sends cookies to the client * - * @param \DateTime $datetime * @return ResponseInterface */ - public function setLastModified(\DateTime $datetime): ResponseInterface {} + public function sendCookies() {} /** - * Sends a Not-Modified response + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function setNotModified(): ResponseInterface {} + public function send() {} /** - * Sets the HTTP response code - * - * ```php - * $response->setStatusCode(404, "Not Found"); - * ``` + * Sets an attached file to be sent at the end of the request * - * @param int $code - * @param string $message + * @param string $filePath + * @param mixed $attachmentName + * @param mixed $attachment * @return ResponseInterface */ - public function setStatusCode(int $code, string $message = null): ResponseInterface {} + public function setFileToSend($filePath, $attachmentName = null, $attachment = true) {} /** - * Send a raw header to the response + * Remove a header in the response * - * ```php - * $response->setRawHeader("HTTP/1.1 404 Not Found"); - * ``` + * + * $response->removeHeader("Expires"); + * * - * @param string $header - * @return ResponseInterface + * @param string $name + * @return Response */ - public function setRawHeader(string $header): ResponseInterface {} + public function removeHeader($name) {} } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index d3176976..17f684bc 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -11,81 +11,59 @@ interface ResponseInterface { /** - * Appends a string to the HTTP response body + * Sets the HTTP response code * - * @param mixed $content + * @param int $code + * @param string $message * @return ResponseInterface */ - public function appendContent($content): ResponseInterface; - - /** - * Gets the HTTP response body - * - * @return string - */ - public function getContent(): string; - - /** - * Returns the status code - * - * @return int|null - */ - public function getStatusCode(): ?int; + public function setStatusCode($code, $message = null); /** * Returns headers set by the user * * @return \Phalcon\Http\Response\HeadersInterface */ - public function getHeaders(): HeadersInterface; + public function getHeaders(); /** - * Checks if a header exists + * Overwrites a header in the response * * @param string $name - * @return bool - */ - public function hasHeader(string $name): bool; - - /** - * Checks if the response was already sent - * - * @return bool + * @param mixed $value + * @return ResponseInterface */ - public function isSent(): bool; + public function setHeader($name, $value); /** - * Redirect by HTTP to another action or URL + * Send a raw header to the response * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode + * @param string $header * @return ResponseInterface */ - public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface; + public function setRawHeader($header); /** * Resets all the established headers * * @return ResponseInterface */ - public function resetHeaders(): ResponseInterface; + public function resetHeaders(); /** - * Sets HTTP response body + * Sets output expire time header * - * @param string $content + * @param \DateTime $datetime * @return ResponseInterface */ - public function setContent(string $content): ResponseInterface; + public function setExpires(\DateTime $datetime); /** - * Sets the response content-length + * Sends a Not-Modified response * - * @param int $contentLength * @return ResponseInterface */ - public function setContentLength(int $contentLength): ResponseInterface; + public function setNotModified(); /** * Sets the response content-type mime, optionally the charset @@ -94,93 +72,93 @@ public function setContentLength(int $contentLength): ResponseInterface; * @param string $charset * @return ResponseInterface */ - public function setContentType(string $contentType, $charset = null): ResponseInterface; + public function setContentType($contentType, $charset = null); /** - * Sets output expire time header + * Sets the response content-length * - * @param \DateTime $datetime + * @param int $contentLength * @return ResponseInterface */ - public function setExpires(\DateTime $datetime): ResponseInterface; + public function setContentLength($contentLength); /** - * Sets an attached file to be sent at the end of the request + * Redirect by HTTP to another action or URL * - * @param string $filePath - * @param mixed $attachmentName + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode * @return ResponseInterface */ - public function setFileToSend(string $filePath, $attachmentName = null): ResponseInterface; + public function redirect($location = null, $externalRedirect = false, $statusCode = 302); /** - * Overwrites a header in the response + * Sets HTTP response body * - * @param string $name - * @param mixed $value + * @param string $content * @return ResponseInterface */ - public function setHeader(string $name, $value): ResponseInterface; + public function setContent($content); /** * Sets HTTP response body. The parameter is automatically converted to JSON * - * ```php + * * $response->setJsonContent( * [ * "status" => "OK", * ] * ); - * ``` + * * * @param mixed $content * @return ResponseInterface */ - public function setJsonContent($content): ResponseInterface; + public function setJsonContent($content); /** - * Sends a Not-Modified response + * Appends a string to the HTTP response body * + * @param mixed $content * @return ResponseInterface */ - public function setNotModified(): ResponseInterface; + public function appendContent($content); /** - * Send a raw header to the response + * Gets the HTTP response body * - * @param string $header - * @return ResponseInterface + * @return string */ - public function setRawHeader(string $header): ResponseInterface; + public function getContent(); /** - * Sets the HTTP response code + * Sends headers to the client * - * @param int $code - * @param string $message * @return ResponseInterface */ - public function setStatusCode(int $code, string $message = null): ResponseInterface; + public function sendHeaders(); /** - * Prints out HTTP response to the client + * Sends cookies to the client * * @return ResponseInterface */ - public function send(): ResponseInterface; + public function sendCookies(); /** - * Sends cookies to the client + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function sendCookies(): ResponseInterface; + public function send(); /** - * Sends headers to the client + * Sets an attached file to be sent at the end of the request * - * @return bool|ResponseInterface + * @param string $filePath + * @param mixed $attachmentName + * @return ResponseInterface */ - public function sendHeaders(); + public function setFileToSend($filePath, $attachmentName = null); } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php deleted file mode 100644 index 99f4f9c7..00000000 --- a/src/Phalcon/http/message/AbstractCommon.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ - protected $body; - - /** - * @var - */ - protected $headers; - - /** - * Retrieves the HTTP protocol version as a string. - * - * The string MUST contain only the HTTP version number (e.g., '1.1', - * '1.0'). - * - * @return string HTTP protocol version. - * - * @var string - */ - protected $protocolVersion = '1.1'; - - /** - * Retrieves the URI instance. - * - * This method MUST return a UriInterface instance. - * - * @see http://tools.ietf.org/html/rfc3986#section-4.3 - * - * @var UriInterface - */ - protected $uri; - - - /** - * Gets the body of the message. - * - * @return - */ - public function getBody() {} - - /** - * Retrieves the HTTP protocol version as a string. - * - * The string MUST contain only the HTTP version number (e.g., '1.1', - * '1.0'). - * - * @return string - */ - public function getProtocolVersion(): string {} - - /** - * Retrieves the URI instance. - * - * This method MUST return a UriInterface instance. - * - * @return UriInterface - */ - public function getUri() {} - - /** - * Retrieves a message header value by the given case-insensitive name. - * - * This method returns an array of all the header values of the given - * case-insensitive header name. - * - * If the header does not appear in the message, this method MUST return an - * empty array. - * - * @param string $name - * - * @param mixed $name - * @return array - */ - public function getHeader($name): array {} - - /** - * Retrieves a comma-separated string of the values for a single header. - * - * This method returns all of the header values of the given - * case-insensitive header name as a string concatenated together using - * a comma. - * - * NOTE: Not all header values may be appropriately represented using - * comma concatenation. For such headers, use getHeader() instead - * and supply your own delimiter when concatenating. - * - * If the header does not appear in the message, this method MUST return - * an empty string. - * - * @param string $name - * - * @param mixed $name - * @return string - */ - public function getHeaderLine($name): string {} - - /** - * Retrieves all message header values. - * - * The keys represent the header name as it will be sent over the wire, and - * each value is an array of strings associated with the header. - * - * // Represent the headers as a string - * foreach ($message->getHeaders() as $name => $values) { - * echo $name . ': ' . implode(', ', $values); - * } - * - * // Emit headers iteratively: - * foreach ($message->getHeaders() as $name => $values) { - * foreach ($values as $value) { - * header(sprintf('%s: %s', $name, $value), false); - * } - * } - * - * While header names are not case-sensitive, getHeaders() will preserve the - * exact case in which headers were originally specified. - * - * @return array - */ - public function getHeaders(): array {} - - /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $name - * - * @param mixed $name - * @return bool - */ - public function hasHeader($name): bool {} - - /** - * Return an instance with the specified header appended with the given - * value. - * - * Existing values for the specified header will be maintained. The new - * value(s) will be appended to the existing list. If the header did not - * exist previously, it will be added. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new header and/or value. - * - * @param string|string[] $value - * - * @param string $name - * @param mixed $value - * @return object - */ - public function withAddedHeader($name, $value) {} - - /** - * Return an instance with the specified message body. - * - * The body MUST be a StreamInterface object. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return a new instance that has the - * new body stream. - * - * @param StreamInterface $body - * - * @throws InvalidArgumentException When the body is not valid. - * - * @param \Psr\Http\Message\StreamInterface $body - * @return object - */ - public function withBody(\Psr\Http\Message\StreamInterface $body) {} - - /** - * Return an instance with the provided value replacing the specified - * header. - * - * While header names are case-insensitive, the casing of the header will - * be preserved by this function, and returned from getHeaders(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new and/or updated header and value. - * - * @param string|string[] $value - * - * @throws InvalidArgumentException for invalid header names or values. - * - * @param string $name - * @param mixed $value - * @return object - */ - public function withHeader($name, $value) {} - - /** - * Return an instance with the specified HTTP protocol version. - * - * The version string MUST contain only the HTTP version number (e.g., - * '1.1', '1.0'). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new protocol version. - * - * @param string $version - * - * @param mixed $version - * @return object - */ - public function withProtocolVersion($version) {} - - /** - * Return an instance without the specified header. - * - * Header resolution MUST be done without case-sensitivity. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the named header. - * - * @param string $name - * - * @param mixed $name - * @return object - */ - public function withoutHeader($name) {} - - /** - * Ensure Host is the first header. - * - * @see: http://tools.ietf.org/html/rfc7230#section-5.4 - * - * @param Collection $collection - * - * @param \Phalcon\Collection $collection - * @return \Phalcon\Collection - */ - final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection {} - - /** - * Check the name of the header. Throw exception if not valid - * - * @see http://tools.ietf.org/html/rfc7230#section-3.2 - * - * @param mixed $name - * @param $name - */ - final protected function checkHeaderName($name) {} - - /** - * Validates a header value - * - * Most HTTP header field values are defined using common syntax - * components (token, quoted-string, and comment) separated by - * whitespace or specific delimiting characters. Delimiters are chosen - * from the set of US-ASCII visual characters not allowed in a token - * (DQUOTE and '(),/:;<=>?@[\]{}'). - * - * token = 1tchar - * - * tchar = '!' / '#' / '$' / '%' / '&' / ''' / '' - * / '+' / '-' / '.' / '^' / '_' / '`' / '|' / '~' - * / DIGIT / ALPHA - * ; any VCHAR, except delimiters - * - * A string of text is parsed as a single value if it is quoted using - * double-quote marks. - * - * quoted-string = DQUOTE( qdtext / quoted-pair ) DQUOTE - * qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text - * obs-text = %x80-FF - * - * Comments can be included in some HTTP header fields by surrounding - * the comment text with parentheses. Comments are only allowed in - * fields containing 'comment' as part of their field value definition. - * - * comment = '('( ctext / quoted-pair / comment ) ')' - * ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text - * - * The backslash octet ('\') can be used as a single-octet quoting - * mechanism within quoted-string and comment constructs. Recipients - * that process the value of a quoted-string MUST handle a quoted-pair - * as if it were replaced by the octet following the backslash. - * - * quoted-pair = '\' ( HTAB / SP / VCHAR / obs-text ) - * - * A sender SHOULD NOT generate a quoted-pair in a quoted-string except - * where necessary to quote DQUOTE and backslash octets occurring within - * that string. A sender SHOULD NOT generate a quoted-pair in a comment - * except where necessary to quote parentheses ['(' and ')'] and - * backslash octets occurring within that comment. - * - * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 - * - * @param mixed $value - * @param $value - */ - final protected function checkHeaderValue($value) {} - - /** - * Returns the header values checked for validity - * - * @param $values - * - * @param mixed $values - * @return array - */ - final protected function getHeaderValue($values): array {} - - /** - * Return the host and if applicable the port - * - * @param UriInterface $uri - * - * @param \Psr\Http\Message\UriInterface $uri - * @return string - */ - final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string {} - - /** - * Populates the header collection - * - * @param array $headers - * - * @param array $headers - * @return \Phalcon\Collection - */ - final protected function populateHeaderCollection(array $headers): Collection {} - - /** - * Set a valid stream - * - * @param string $mode - * - * @param StreamInterface|resource|string $body - * @param string $mode - * @return \Psr\Http\Message\StreamInterface - */ - final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface {} - - /** - * Sets the headers - * - * @param $headers - * - * @param mixed $headers - * @return \Phalcon\Collection - */ - final protected function processHeaders($headers): Collection {} - - /** - * Checks the protocol - * - * @param string $protocol - * - * @param mixed $protocol - * @return string - */ - final protected function processProtocol($protocol = ''): string {} - -} diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php deleted file mode 100644 index 3fdf32fd..00000000 --- a/src/Phalcon/http/message/AbstractRequest.php +++ /dev/null @@ -1,165 +0,0 @@ -getQuery()` or from the `QUERY_STRING` server param. - * - * @var array - */ - private $queryParams = array(); - - /** - * Retrieve server parameters. - * - * Retrieves data related to the incoming request environment, - * typically derived from PHP's $_SERVER superglobal. The data IS NOT - * REQUIRED to originate from $_SERVER. - * - * @var array - */ - private $serverParams = array(); - - /** - * Retrieve normalized file upload data. - * - * This method returns upload metadata in a normalized tree, with each leaf - * an instance of Psr\Http\Message\UploadedFileInterface. - * - * These values MAY be prepared from $_FILES or the message body during - * instantiation, or MAY be injected via withUploadedFiles(). - * - * @var array - */ - private $uploadedFiles = array(); - - - /** - * Retrieve cookies. - * - * Retrieves cookies sent by the client to the server. - * - * The data MUST be compatible with the structure of the $_COOKIE - * superglobal. - * - * @return array - */ - public function getCookieParams(): array {} - - /** - * Retrieve any parameters provided in the request body. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, this method MUST - * return the contents of $_POST. - * - * Otherwise, this method may return any results of deserializing - * the request body content; as parsing returns structured content, the - * potential types MUST be arrays or objects only. A null value indicates - * the absence of body content. - * - * @return mixed - */ - public function getParsedBody() {} - - /** - * Retrieve query string arguments. - * - * Retrieves the deserialized query string arguments, if any. - * - * Note: the query params might not be in sync with the URI or server - * params. If you need to ensure you are only getting the original - * values, you may need to parse the query string from - * `getUri()->getQuery()` or from the `QUERY_STRING` server param. - * - * @return array - */ - public function getQueryParams(): array {} - - /** - * Retrieve server parameters. - * - * Retrieves data related to the incoming request environment, - * typically derived from PHP's $_SERVER superglobal. The data IS NOT - * REQUIRED to originate from $_SERVER. - * - * @return array - */ - public function getServerParams(): array {} - - /** - * Retrieve normalized file upload data. - * - * This method returns upload metadata in a normalized tree, with each leaf - * an instance of Psr\Http\Message\UploadedFileInterface. - * - * These values MAY be prepared from $_FILES or the message body during - * instantiation, or MAY be injected via withUploadedFiles(). - * - * @return array - */ - public function getUploadedFiles(): array {} - - /** - * ServerRequest constructor. - * - * @param string $method - * @param UriInterface|string|null $uri - * @param array $serverParams - * @param StreamInterface|string $body - * @param array $headers - * @param array $cookies - * @param array $queryParams - * @param array $uploadFiles - * @param null|array|object $parsedBody - * @param string $protocol - */ - public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') {} - - /** - * Retrieve a single derived request attribute. - * - * Retrieves a single derived request attribute as described in - * getAttributes(). If the attribute has not been previously set, returns - * the default value as provided. - * - * This method obviates the need for a hasAttribute() method, as it allows - * specifying a default value to return if the attribute is not found. - * - * @param mixed|null $defaultValue - * - * @param string $name - * @param mixed $defaultValue - * @return mixed - */ - public function getAttribute($name, $defaultValue = null) {} - - /** - * Retrieve attributes derived from the request. - * - * The request 'attributes' may be used to allow injection of any - * parameters derived from the request: e.g., the results of path - * match operations; the results of decrypting cookies; the results of - * deserializing non-form-encoded message bodies; etc. Attributes - * will be application and request specific, and CAN be mutable. - * - * @return array - */ - public function getAttributes(): array {} - - /** - * Return an instance with the specified derived request attribute. - * - * This method allows setting a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated attribute. - * - * @param mixed $value - * - * @param string $name - * @param mixed $value - * @return ServerRequest - */ - public function withAttribute($name, $value): ServerRequest {} - - /** - * Return an instance with the specified cookies. - * - * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST - * be compatible with the structure of $_COOKIE. Typically, this data will - * be injected at instantiation. - * - * This method MUST NOT update the related Cookie header of the request - * instance, nor related values in the server params. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated cookie values. - * - * @param array $cookies - * - * @param array $cookies - * @return ServerRequest - */ - public function withCookieParams(array $cookies): ServerRequest {} - - /** - * Return an instance with the specified body parameters. - * - * These MAY be injected during instantiation. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, use this method - * ONLY to inject the contents of $_POST. - * - * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of - * deserializing the request body content. Deserialization/parsing returns - * structured data, and, as such, this method ONLY accepts arrays or - * objects, or a null value if nothing was available to parse. - * - * As an example, if content negotiation determines that the request data - * is a JSON payload, this method could be used to create a request - * instance with the deserialized parameters. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param array|object|null $data - * - * @throws InvalidArgumentException if an unsupported argument type is - * provided. - * - * @param mixed $data - * @return ServerRequest - */ - public function withParsedBody($data): ServerRequest {} - - /** - * Return an instance with the specified query string arguments. - * - * These values SHOULD remain immutable over the course of the incoming - * request. They MAY be injected during instantiation, such as from PHP's - * $_GET superglobal, or MAY be derived from some other value such as the - * URI. In cases where the arguments are parsed from the URI, the data - * MUST be compatible with what PHP's parse_str() would return for - * purposes of how duplicate query parameters are handled, and how nested - * sets are handled. - * - * Setting query string arguments MUST NOT change the URI stored by the - * request, nor the values in the server params. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated query string arguments. - * - * @param array $query - * - * @param array $query - * @return ServerRequest - */ - public function withQueryParams(array $query): ServerRequest {} - - /** - * Create a new instance with the specified uploaded files. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param array $uploadedFiles - * - * @throws InvalidArgumentException if an invalid structure is provided. - * - * @param array $uploadedFiles - * @return ServerRequest - */ - public function withUploadedFiles(array $uploadedFiles): ServerRequest {} - - /** - * Return an instance that removes the specified derived request attribute. - * - * This method allows removing a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the attribute. - * - * @param string $name - * - * @param mixed $name - * @return ServerRequest - */ - public function withoutAttribute($name): ServerRequest {} - - /** - * Checks the uploaded files - * - * @param array $files - */ - private function checkUploadedFiles(array $files) {} - -} diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php deleted file mode 100644 index 2821ea96..00000000 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ /dev/null @@ -1,209 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class InvalidArgumentException extends InvalidArgumentException implements \Throwable -{ - -} diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php deleted file mode 100644 index 40b7b316..00000000 --- a/src/Phalcon/http/message/stream/Input.php +++ /dev/null @@ -1,76 +0,0 @@ - * use Phalcon\Mvc\Controller; * * class PostsController extends Controller @@ -20,58 +20,58 @@ * foreach ($this->request->getUploadedFiles() as $file) { * echo $file->getName(), " ", $file->getSize(), "\n"; * } - * } + * } * } * } - * ``` + * */ class File implements \Phalcon\Http\Request\FileInterface { - /** - * @var string|null - */ - protected $error; - /** - * @var string - */ - protected $extension; + protected $_name; - /** - * @var string|null - */ - protected $key; + protected $_tmp; - protected $name; + protected $_size; - protected $realType; + protected $_type; - protected $size; + protected $_realType; - protected $tmp; + /** + * @var string|null + */ + protected $_error; + /** + * @var string|null + */ + protected $_key; - protected $type; + /** + * @var string + */ + protected $_extension; /** * @return string|null */ - public function getError(): ?string {} + public function getError() {} /** - * @return string + * @return string|null */ - public function getExtension(): string {} + public function getKey() {} /** - * @return string|null + * @return string */ - public function getKey(): ?string {} + public function getExtension() {} /** * Phalcon\Http\Request\File constructor @@ -82,47 +82,47 @@ public function getKey(): ?string {} public function __construct(array $file, $key = null) {} /** - * Returns the real name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getName(): string {} + public function getSize() {} /** - * Gets the real mime type of the upload file using finfo + * Returns the real name of the uploaded file * * @return string */ - public function getRealType(): string {} + public function getName() {} /** - * Returns the file size of the uploaded file + * Returns the temporary name of the uploaded file * - * @return int + * @return string */ - public function getSize(): int {} + public function getTempName() {} /** - * Returns the temporary name of the uploaded file + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getTempName(): string {} + public function getType() {} /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getType(): string {} + public function getRealType() {} /** * Checks whether the file has been uploaded via Post. * * @return bool */ - public function isUploadedFile(): bool {} + public function isUploadedFile() {} /** * Moves the temporary file to a destination within the application @@ -130,6 +130,6 @@ public function isUploadedFile(): bool {} * @param string $destination * @return bool */ - public function moveTo(string $destination): bool {} + public function moveTo($destination) {} } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 69f37a10..913d759b 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -11,40 +11,40 @@ interface FileInterface { /** - * Returns the real name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getName(): string; + public function getSize(); /** - * Gets the real mime type of the upload file using finfo + * Returns the real name of the uploaded file * * @return string */ - public function getRealType(): string; + public function getName(); /** - * Returns the file size of the uploaded file + * Returns the temporal name of the uploaded file * - * @return int + * @return string */ - public function getSize(): int; + public function getTempName(); /** - * Returns the temporal name of the uploaded file + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getTempName(): string; + public function getType(); /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getType(): string; + public function getRealType(); /** * Move the temporary file to a destination @@ -52,6 +52,6 @@ public function getType(): string; * @param string $destination * @return bool */ - public function moveTo(string $destination): bool; + public function moveTo($destination); } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 8e63b483..8f7c5f7a 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -7,13 +7,12 @@ * * This class is a bag to manage the cookies. * - * A cookies bag is automatically registered as part of the 'response' service - * in the DI. By default, cookies are automatically encrypted before being sent - * to the client and are decrypted when retrieved from the user. To set sign key - * used to generate a message authentication code use - * `Phalcon\Http\Response\Cookies::setSignKey()`. + * A cookies bag is automatically registered as part of the 'response' service in the DI. + * By default, cookies are automatically encrypted before being sent to the client and are + * decrypted when retrieved from the user. To set sign key used to generate a message + * authentication code use `Phalcon\Http\Response\Cookies::setSignKey`. * - * ```php + * * use Phalcon\Di; * use Phalcon\Crypt; * use Phalcon\Http\Response\Cookies; @@ -27,7 +26,6 @@ * * // The `$key' should have been previously generated in a cryptographically safe way. * $key = "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3"; - * * $crypt->setKey($key); * * return $crypt; @@ -42,24 +40,26 @@ * // The `$key' MUST be at least 32 characters long and generated using a * // cryptographically secure pseudo random generator. * $key = "#1dj8$=dp?.ak//j1V$~%0XaK\xb1\x8d\xa9\x98\x054t7w!z%CF-Jk\x98\x05\\\x5c"; - * * $cookies->setSignKey($key); * * return $cookies; * } * ); - * ``` + * */ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\InjectionAwareInterface { - protected $container; + protected $_dependencyInjector; + + protected $_registered = false; - protected $cookies = array(); + protected $_useEncryption = true; - protected $registered = false; + + protected $_cookies; /** * The cookie's sign key. @@ -69,85 +69,63 @@ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\In protected $signKey = null; - protected $useEncryption = true; - - /** * Phalcon\Http\Response\Cookies constructor * * @param bool $useEncryption * @param string $signKey */ - public function __construct(bool $useEncryption = true, string $signKey = null) {} + public function __construct($useEncryption = true, $signKey = null) {} /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * Sets the cookie's sign key. * - * @param string $name - * @return bool - */ - public function delete(string $name): bool {} - - /** - * Gets a cookie from the bag + * The `$signKey' MUST be at least 32 characters long + * and generated using a cryptographically secure pseudo random generator. * - * @param string $name + * Use NULL to disable cookie signing. + * + * @see \Phalcon\Security\Random + * @param string $signKey * @return \Phalcon\Http\CookieInterface */ - public function get(string $name): CookieInterface {} + public function setSignKey($signKey = null) {} /** - * Gets all cookies from the bag + * Sets the dependency injector * - * @return array + * @param \Phalcon\DiInterface $dependencyInjector */ - public function getCookies(): array {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Check if a cookie is defined in the bag or exists in the _COOKIE - * superglobal - * - * @param string $name - * @return bool - */ - public function has(string $name): bool {} - - /** - * Returns if the bag is automatically encrypting/decrypting cookies - * - * @return bool + * @return \Phalcon\DiInterface */ - public function isUsingEncryption(): bool {} + public function getDI() {} /** - * Reset set cookies + * Set if cookies in the bag must be automatically encrypted/decrypted * + * @param bool $useEncryption * @return \Phalcon\Http\Response\CookiesInterface */ - public function reset(): CookiesInterface {} + public function useEncryption($useEncryption) {} /** - * Sends the cookies to the client - * Cookies aren't sent if headers are sent in the current request + * Returns if the bag is automatically encrypting/decrypting cookies * * @return bool */ - public function send(): bool {} + public function isUsingEncryption() {} /** * Sets a cookie to be sent at the end of the request. * * This method overrides any cookie set before with the same name. * - * ```php + * * use Phalcon\Http\Response\Cookies; * * $now = new DateTimeImmutable(); @@ -159,7 +137,7 @@ public function send(): bool {} * json_encode(['user_id' => 1]), * (int) $tomorrow->format('U'), * ); - * ``` + * * * @param string $name * @param mixed $value @@ -170,35 +148,46 @@ public function send(): bool {} * @param bool $httpOnly * @return \Phalcon\Http\Response\CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface {} + public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null) {} /** - * Sets the dependency injector + * Gets a cookie from the bag * - * @param \Phalcon\Di\DiInterface $container + * @param string $name + * @return \Phalcon\Http\Response\CookiesInterface */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function get($name) {} /** - * Sets the cookie's sign key. + * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal * - * The `$signKey' MUST be at least 32 characters long - * and generated using a cryptographically secure pseudo random generator. + * @param string $name + * @return bool + */ + public function has($name) {} + + /** + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * - * Use NULL to disable cookie signing. + * @param string $name + * @return bool + */ + public function delete($name) {} + + /** + * Sends the cookies to the client + * Cookies aren't sent if headers are sent in the current request * - * @see \Phalcon\Security\Random - * @param string $signKey - * @return \Phalcon\Http\CookieInterface + * @return bool */ - public function setSignKey(string $signKey = null): CookieInterface {} + public function send() {} /** - * Set if cookies in the bag must be automatically encrypted/decrypted + * Reset set cookies * - * @param bool $useEncryption * @return \Phalcon\Http\Response\CookiesInterface */ - public function useEncryption(bool $useEncryption): CookiesInterface {} + public function reset() {} } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index abe18b6f..cd1c100e 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -11,71 +11,71 @@ interface CookiesInterface { /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * Set if cookies in the bag must be automatically encrypted/decrypted * - * @param string $name - * @return bool + * @param bool $useEncryption + * @return CookiesInterface */ - public function delete(string $name): bool; + public function useEncryption($useEncryption); /** - * Gets a cookie from the bag + * Returns if the bag is automatically encrypting/decrypting cookies * - * @param string $name - * @return \Phalcon\Http\CookieInterface + * @return bool */ - public function get(string $name): CookieInterface; + public function isUsingEncryption(); /** - * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal + * Sets a cookie to be sent at the end of the request * * @param string $name - * @return bool + * @param mixed $value + * @param int $expire + * @param string $path + * @param bool $secure + * @param string $domain + * @param bool $httpOnly + * @return CookiesInterface */ - public function has(string $name): bool; + public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null); /** - * Returns if the bag is automatically encrypting/decrypting cookies + * Gets a cookie from the bag * - * @return bool + * @param string $name + * @return CookiesInterface */ - public function isUsingEncryption(): bool; + public function get($name); /** - * Reset set cookies + * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal * - * @return CookiesInterface + * @param string $name + * @return bool */ - public function reset(): CookiesInterface; + public function has($name); /** - * Sends the cookies to the client + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * + * @param string $name * @return bool */ - public function send(): bool; + public function delete($name); /** - * Sets a cookie to be sent at the end of the request + * Sends the cookies to the client * - * @param string $name - * @param mixed $value - * @param int $expire - * @param string $path - * @param bool $secure - * @param string $domain - * @param bool $httpOnly - * @return CookiesInterface + * @return bool */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface; + public function send(); /** - * Set if cookies in the bag must be automatically encrypted/decrypted + * Reset set cookies * - * @param bool $useEncryption * @return CookiesInterface */ - public function useEncryption(bool $useEncryption): CookiesInterface; + public function reset(); } diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 31f52cbd..7ccc1a96 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -10,64 +10,64 @@ class Headers implements \Phalcon\Http\Response\HeadersInterface { - protected $headers = array(); + protected $_headers = array(); /** - * Gets a header value from the internal bag + * Sets a header to be sent at the end of the request * * @param string $name - * @return string|bool + * @param string $value */ - public function get(string $name) {} + public function set($name, $value) {} /** - * Sets a header to be sent at the end of the request + * Gets a header value from the internal bag * * @param string $name - * @return bool + * @return string|bool */ - public function has(string $name): bool {} + public function get($name) {} /** - * Removes a header to be sent at the end of the request + * Sets a raw header to be sent at the end of the request * * @param string $header */ - public function remove(string $header) {} + public function setRaw($header) {} /** - * Reset set headers + * Removes a header to be sent at the end of the request + * + * @param string $header */ - public function reset() {} + public function remove($header) {} /** * Sends the headers to the client * * @return bool */ - public function send(): bool {} + public function send() {} /** - * Sets a header to be sent at the end of the request - * - * @param string $name - * @param string $value + * Reset set headers */ - public function set(string $name, string $value) {} + public function reset() {} /** - * Sets a raw header to be sent at the end of the request + * Returns the current headers as an array * - * @param string $header + * @return array */ - public function setRaw(string $header) {} + public function toArray() {} /** - * Returns the current headers as an array + * Restore a \Phalcon\Http\Response\Headers object * - * @return array + * @param array $data + * @return \Phalcon\Http\Response\HeadersInterface */ - public function toArray(): array {} + public static function __set_state(array $data) {} } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index a2b439a8..9d7349ea 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -11,46 +11,46 @@ interface HeadersInterface { /** - * Gets a header value from the internal bag + * Sets a header to be sent at the end of the request * * @param string $name - * @return string|bool + * @param string $value */ - public function get(string $name); + public function set($name, $value); /** - * Returns true if the header is set, false otherwise + * Gets a header value from the internal bag * * @param string $name - * @return bool + * @return string|bool */ - public function has(string $name): bool; + public function get($name); /** - * Reset set headers + * Sets a raw header to be sent at the end of the request + * + * @param string $header */ - public function reset(); + public function setRaw($header); /** * Sends the headers to the client * * @return bool */ - public function send(): bool; + public function send(); /** - * Sets a header to be sent at the end of the request - * - * @param string $name - * @param string $value + * Reset set headers */ - public function set(string $name, string $value); + public function reset(); /** - * Sets a raw header to be sent at the end of the request + * Restore a \Phalcon\Http\Response\Headers object * - * @param string $header + * @param array $data + * @return HeadersInterface */ - public function setRaw(string $header); + public static function __set_state(array $data); } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php deleted file mode 100644 index 8f3353b7..00000000 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Enum -{ - - const AUTO = 4; - - - const HEIGHT = 3; - - - const INVERSE = 5; - - - const NONE = 1; - - - const PRECISE = 6; - - - const TENSILE = 7; - - - const WIDTH = 2; - - - const HORIZONTAL = 11; - - - const VERTICAL = 12; - - -} diff --git a/src/Phalcon/image/Exception.php b/src/Phalcon/image/Exception.php index d590f857..7e881cbe 100644 --- a/src/Phalcon/image/Exception.php +++ b/src/Phalcon/image/Exception.php @@ -2,14 +2,7 @@ namespace Phalcon\Image; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ + class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/image/Factory.php b/src/Phalcon/image/Factory.php new file mode 100644 index 00000000..36ef8eb9 --- /dev/null +++ b/src/Phalcon/image/Factory.php @@ -0,0 +1,35 @@ + + * use Phalcon\Image\Factory; + * + * $options = [ + * "width" => 200, + * "height" => 200, + * "file" => "upload/test.jpg", + * "adapter" => "imagick", + * ]; + * $image = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + + /** + * @param string $namespace + * @param mixed $config + */ + protected static function loadClass($namespace, $config) {} + +} diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php deleted file mode 100644 index 234d2713..00000000 --- a/src/Phalcon/image/ImageFactory.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -interface AdapterInterface -{ - - /** - * @param string $color - * @param int $opacity - */ - public function background(string $color, int $opacity = 100); - - /** - * @param int $radius - */ - public function blur(int $radius); - - /** - * @param int $width - * @param int $height - * @param int $offsetX - * @param int $offsetY - */ - public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null); - - /** - * @param int $direction - */ - public function flip(int $direction); - - /** - * @param AdapterInterface $watermark - */ - public function mask(AdapterInterface $watermark); - - /** - * @param int $amount - */ - public function pixelate(int $amount); - - /** - * @param int $height - * @param int $opacity - * @param bool $fadeIn - */ - public function reflection(int $height, int $opacity = 100, bool $fadeIn = false); - - /** - * @param string $ext - * @param int $quality - */ - public function render(string $ext = null, int $quality = 100); - - /** - * @param int $width - * @param int $height - * @param int $master - */ - public function resize(int $width = null, int $height = null, int $master = Image::AUTO); - - /** - * @param int $degrees - */ - public function rotate(int $degrees); - - /** - * @param string $file - * @param int $quality - */ - public function save(string $file = null, int $quality = 100); - - /** - * @param int $amount - */ - public function sharpen(int $amount); - - /** - * @param string $text - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - * @param string $color - * @param int $size - * @param string $fontfile - */ - public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null); - - /** - * @param AdapterInterface $watermark - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - */ - public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100); - -} diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index e8769205..c162e8a3 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -2,58 +2,30 @@ namespace Phalcon\Image\Adapter; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Gd extends \Phalcon\Image\Adapter\AbstractAdapter -{ - - static protected $checked = false; - - /** - * @param string $file - * @param int $width - * @param int $height - */ - public function __construct(string $file, int $width = null, int $height = null) {} +class Gd extends \Phalcon\Image\Adapter +{ + static protected $_checked = false; - public function __destruct() {} /** * @return bool */ - public static function check(): bool {} - - /** - * @return string - */ - public static function getVersion(): string {} - - /** - * @param int $r - * @param int $g - * @param int $b - * @param int $opacity - */ - protected function processBackground(int $r, int $g, int $b, int $opacity) {} + public static function check() {} /** - * @param int $radius + * @param string $file + * @param int $width + * @param int $height */ - protected function processBlur(int $radius) {} + public function __construct($file, $width = null, $height = null) {} /** * @param int $width * @param int $height */ - protected function processCreate(int $width, int $height) {} + protected function _resize($width, $height) {} /** * @param int $width @@ -61,77 +33,93 @@ protected function processCreate(int $width, int $height) {} * @param int $offsetX * @param int $offsetY */ - protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} + protected function _crop($width, $height, $offsetX, $offsetY) {} /** - * @param int $direction + * @param int $degrees */ - protected function processFlip(int $direction) {} + protected function _rotate($degrees) {} /** - * @param AdapterInterface $mask + * @param int $direction */ - protected function processMask(AdapterInterface $mask) {} + protected function _flip($direction) {} /** * @param int $amount */ - protected function processPixelate(int $amount) {} + protected function _sharpen($amount) {} /** * @param int $height * @param int $opacity * @param bool $fadeIn */ - protected function processReflection(int $height, int $opacity, bool $fadeIn) {} + protected function _reflection($height, $opacity, $fadeIn) {} /** - * @param string $ext - * @param int $quality + * @param \Phalcon\Image\Adapter $watermark + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - protected function processRender(string $ext, int $quality) {} + protected function _watermark(\Phalcon\Image\Adapter $watermark, $offsetX, $offsetY, $opacity) {} /** - * @param int $width - * @param int $height + * @param string $text + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - protected function processResize(int $width, int $height) {} + protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} /** - * @param int $degrees + * @param \Phalcon\Image\Adapter $mask */ - protected function processRotate(int $degrees) {} + protected function _mask(\Phalcon\Image\Adapter $mask) {} /** - * @param string $file - * @param int $quality + * @param int $r + * @param int $g + * @param int $b + * @param int $opacity + */ + protected function _background($r, $g, $b, $opacity) {} + + /** + * @param int $radius */ - protected function processSave(string $file, int $quality) {} + protected function _blur($radius) {} /** * @param int $amount */ - protected function processSharpen(int $amount) {} + protected function _pixelate($amount) {} /** - * @param string $text - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @param string $file + * @param int $quality */ - protected function processText(string $text, int $offsetX, int $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} + protected function _save($file, $quality) {} /** - * @param AdapterInterface $watermark - * @param int $offsetX - * @param int $offsetY - * @param int $opacity + * @param string $ext + * @param int $quality */ - protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) {} + protected function _render($ext, $quality) {} + + /** + * @param int $width + * @param int $height + */ + protected function _create($width, $height) {} + + + public function __destruct() {} } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 6164a769..2164b7f7 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -7,7 +7,7 @@ * * Image manipulation support. Allows images to be resized, cropped, etc. * - * ```php + * * $image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg"); * * $image->resize(200, 200)->rotate(90)->crop(100, 100); @@ -15,17 +15,24 @@ * if ($image->save()) { * echo "success"; * } - * ``` + * */ -class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter +class Imagick extends \Phalcon\Image\Adapter { - static protected $checked = false; + static protected $_version = 0; - static protected $version = 0; + static protected $_checked = false; + /** + * Checks if Imagick is enabled + * + * @return bool + */ + public static function check() {} + /** * \Phalcon\Image\Adapter\Imagick constructor * @@ -33,166 +40,158 @@ class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter * @param int $width * @param int $height */ - public function __construct(string $file, int $width = null, int $height = null) {} + public function __construct($file, $width = null, $height = null) {} /** - * Destroys the loaded image to free up resources. + * Execute a resize. + * + * @param int $width + * @param int $height */ - public function __destruct() {} + protected function _resize($width, $height) {} /** - * Checks if Imagick is enabled + * This method scales the images using liquid rescaling method. Only support Imagick * - * @return bool + * @param int $width new width + * @param int $height new height + * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. + * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ - public static function check(): bool {} + protected function _liquidRescale($width, $height, $deltaX, $rigidity) {} /** - * Get instance + * Execute a crop. * - * @return \Imagick + * @param int $width + * @param int $height + * @param int $offsetX + * @param int $offsetY */ - public function getInternalImInstance(): \Imagick {} + protected function _crop($width, $height, $offsetX, $offsetY) {} /** - * Sets the limit for a particular resource in megabytes + * Execute a rotation. * - * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes - * @param int $type - * @param int $limit + * @param int $degrees */ - public function setResourceLimit(int $type, int $limit) {} + protected function _rotate($degrees) {} /** - * Execute a background. + * Execute a flip. * - * @param int $r - * @param int $g - * @param int $b - * @param int $opacity + * @param int $direction */ - protected function processBackground(int $r, int $g, int $b, int $opacity) {} + protected function _flip($direction) {} /** - * Blur image + * Execute a sharpen. * - * @param int $radius Blur radius + * @param int $amount */ - protected function processBlur(int $radius) {} + protected function _sharpen($amount) {} /** - * Execute a crop. + * Execute a reflection. * - * @param int $width * @param int $height - * @param int $offsetX - * @param int $offsetY + * @param int $opacity + * @param bool $fadeIn */ - protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} + protected function _reflection($height, $opacity, $fadeIn) {} /** - * Execute a flip. + * Execute a watermarking. * - * @param int $direction + * @param \Phalcon\Image\Adapter $image + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - protected function processFlip(int $direction) {} + protected function _watermark(\Phalcon\Image\Adapter $image, $offsetX, $offsetY, $opacity) {} /** - * This method scales the images using liquid rescaling method. Only support - * Imagick + * Execute a text * - * @param int $width new width - * @param int $height new height - * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. - * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. + * @param string $text + * @param mixed $offsetX + * @param mixed $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) {} + protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} /** * Composite one image onto another * - * @param AdapterInterface $image - */ - protected function processMask(AdapterInterface $image) {} - - /** - * Pixelate image - * - * @param int $amount amount to pixelate + * @param \Phalcon\Image\Adapter $image */ - protected function processPixelate(int $amount) {} + protected function _mask(\Phalcon\Image\Adapter $image) {} /** - * Execute a reflection. + * Execute a background. * - * @param int $height + * @param int $r + * @param int $g + * @param int $b * @param int $opacity - * @param bool $fadeIn */ - protected function processReflection(int $height, int $opacity, bool $fadeIn) {} + protected function _background($r, $g, $b, $opacity) {} /** - * Execute a render. + * Blur image * - * @param string $extension - * @param int $quality - * @return string + * @param int $radius Blur radius */ - protected function processRender(string $extension, int $quality): string {} + protected function _blur($radius) {} /** - * Execute a resize. + * Pixelate image * - * @param int $width - * @param int $height + * @param int $amount amount to pixelate */ - protected function processResize(int $width, int $height) {} + protected function _pixelate($amount) {} /** - * Execute a rotation. + * Execute a save. * - * @param int $degrees + * @param string $file + * @param int $quality */ - protected function processRotate(int $degrees) {} + protected function _save($file, $quality) {} /** - * Execute a save. + * Execute a render. * - * @param string $file + * @param string $extension * @param int $quality + * @return string */ - protected function processSave(string $file, int $quality) {} + protected function _render($extension, $quality) {} /** - * Execute a sharpen. - * - * @param int $amount + * Destroys the loaded image to free up resources. */ - protected function processSharpen(int $amount) {} + public function __destruct() {} /** - * Execute a text + * Get instance * - * @param string $text - * @param mixed $offsetX - * @param mixed $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @return \Imagick */ - protected function processText(string $text, $offsetX, $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} + public function getInternalImInstance() {} /** - * Execute a watermarking. + * Sets the limit for a particular resource in megabytes * - * @param AdapterInterface $image - * @param int $offsetX - * @param int $offsetY - * @param int $opacity + * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes + * @param int $type + * @param int $limit */ - protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) {} + public function setResourceLimit($type, $limit) {} } diff --git a/src/Phalcon/logger/Adapter.php b/src/Phalcon/logger/Adapter.php new file mode 100644 index 00000000..6332108c --- /dev/null +++ b/src/Phalcon/logger/Adapter.php @@ -0,0 +1,174 @@ + - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class AdapterFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * AdapterFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @param string $fileName - * @param array $options - * @return AdapterInterface - */ - public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/logger/AdapterInterface.php b/src/Phalcon/logger/AdapterInterface.php new file mode 100644 index 00000000..a6ed7ba9 --- /dev/null +++ b/src/Phalcon/logger/AdapterInterface.php @@ -0,0 +1,144 @@ + + * use Phalcon\Logger\Factory; + * + * $options = [ + * "name" => "log.txt", + * "adapter" => "file", + * ]; + * $logger = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + + /** + * @param string $namespace + * @param mixed $config + */ + protected static function loadClass($namespace, $config) {} + +} diff --git a/src/Phalcon/logger/Formatter.php b/src/Phalcon/logger/Formatter.php new file mode 100644 index 00000000..24868d1c --- /dev/null +++ b/src/Phalcon/logger/Formatter.php @@ -0,0 +1,30 @@ + $adapter1, - * 'remote' => $adapter2, - * 'manager' => $adapter3, - * ] - * ); - * - * // Log to all adapters - * $logger->error('Something went wrong'); - * - * // Log to specific adapters - * $logger - * ->excludeAdapters(['manager']) - * ->info('This does not go to the "manager" logger); - * ``` - */ -class Logger implements \Psr\Log\LoggerInterface -{ - - const ALERT = 2; - - - const CRITICAL = 1; - - - const CUSTOM = 8; - - - const DEBUG = 7; - - - const EMERGENCY = 0; - - - const ERROR = 3; - - - const INFO = 6; - - - const NOTICE = 5; - - - const WARNING = 4; - - /** - * The adapter stack - * - * @var AdapterInterface[] - */ - protected $adapters = array(); - - /** - * @var string - */ - protected $name = ''; - - /** - * The excluded adapters for this log process - * - * @var AdapterInterface[] - */ - protected $excluded = array(); - - - /** - * Constructor. - * - * @param string $name The name of the logger - * @param array $adapters The collection of adapters to be used for logging (default []) - */ - public function __construct(string $name, array $adapters = array()) {} - - /** - * Add an adapter to the stack. For processing we use FIFO - * - * @param string $name The name of the adapter - * @param $adapter The adapter to add to the stack - * @return Logger - */ - public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger {} - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - */ - public function alert($message, array $context = array()) {} - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - */ - public function critical($message, array $context = array()) {} - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - */ - public function debug($message, array $context = array()) {} - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - */ - public function error($message, array $context = array()) {} - - /** - * System is unusable. - * - * @param string $message - * @param array $context - */ - public function emergency($message, array $context = array()) {} - - /** - * Exclude certain adapters. - * - * @param array $adapters - * @return Logger - */ - public function excludeAdapters(array $adapters = array()): Logger {} - - /** - * Returns an adapter from the stack - * - * @param string name The name of the adapter - * - * @throws - * @param string $name - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function getAdapter(string $name): AdapterInterface {} - - /** - * Returns the adapter stack array - * - * @return array - */ - public function getAdapters(): array {} - - /** - * Returns the name of the logger - * - * @return string - */ - public function getName(): string {} - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - */ - public function info($message, array $context = array()) {} - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - */ - public function log($level, $message, array $context = array()) {} - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - */ - public function notice($message, array $context = array()) {} - - /** - * Removes an adapter from the stack - * - * @param string name The name of the adapter - * - * @throws - * @param string $name - * @return Logger - */ - public function removeAdapter(string $name): Logger {} - - /** - * Sets the adapters stack overriding what is already there - * - * @param array $adapters An array of adapters - * @return Logger - */ - public function setAdapters(array $adapters): Logger {} - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - */ - public function warning($message, array $context = array()) {} - - /** - * Adds a message to each handler for processing - * - * @param string message - * - * @throws - * @param int $level - * @param string $message - * @param array $context - * @return bool - */ - protected function addMessage(int $level, string $message, array $context = array()): bool {} - - /** - * Returns an array of log levels with integer to string conversion - * - * @return array - */ - protected function getLevels(): array {} - - /** - * Converts the level from string/word to an integer - * - * @param string|int $level - * @return int - */ - private function getLevelNumber($level): int {} - -} diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php deleted file mode 100644 index a53c608b..00000000 --- a/src/Phalcon/logger/LoggerFactory.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface -{ - /** - * Name of the default formatter class - * - * @var string - */ - protected $defaultFormatter = 'Line'; - - /** - * Formatter - * - * @var - */ - protected $formatter; - - /** - * Tells if there is an active transaction or not - * - * @var bool - */ - protected $inTransaction = false; - - /** - * Array with messages queued in the transaction - * - * @var array - */ - protected $queue = array(); - - - /** - * Destructor cleanup - */ - public function __destruct() {} - - /** - * Adds a message to the queue - * - * @param \Phalcon\Logger\Item $item - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function add(\Phalcon\Logger\Item $item): AdapterInterface {} - - /** - * Starts a transaction - * - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function begin(): AdapterInterface {} - - /** - * Commits the internal transaction - * - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function commit(): AdapterInterface {} - - /** - * @return \Phalcon\Logger\Formatter\FormatterInterface - */ - public function getFormatter(): FormatterInterface {} - - /** - * Returns the whether the logger is currently in an active transaction or not - * - * @return bool - */ - public function inTransaction(): bool {} - - /** - * Processes the message in the adapter - * - * @param \Phalcon\Logger\Item $item - */ - abstract public function process(\Phalcon\Logger\Item $item); - - /** - * Rollbacks the internal transaction - * - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function rollback(): AdapterInterface {} - - /** - * Sets the message formatter - * - * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter - * @return \Phalcon\Logger\Adapter\AdapterInterface - */ - public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface {} - -} diff --git a/src/Phalcon/logger/adapter/Abstractadapter.php b/src/Phalcon/logger/adapter/Abstractadapter.php new file mode 100644 index 00000000..6abb00ee --- /dev/null +++ b/src/Phalcon/logger/adapter/Abstractadapter.php @@ -0,0 +1,100 @@ + + */ + protected $formatter; + + /** + * Tells if there is an active transaction or not + * + * @var bool + */ + protected $inTransaction = false; + + /** + * Array with messages queued in the transaction + * + * @var array + */ + protected $queue = []; + + /** + * Destructor cleanup + */ + public function __destruct() + { + } + + /** + * Adds a message to the queue + */ + public function add(Item $item) : void + { + } + + /** + * Starts a transaction + */ + public function begin() : AdapterInterface + { + } + + /** + * Commits the internal transaction + */ + public function commit() : AdapterInterface + { + } + + public function getFormatter() : FormatterInterface + { + } + + /** + * Returns the whether the logger is currently in an active transaction or not + */ + public function inTransaction() : bool + { + } + + /** + * Processes the message in the adapter + */ + public function process(Item $item) : void + { + } + + /** + * Rollbacks the internal transaction + */ + public function rollback() : AdapterInterface + { + } + + /** + * Sets the message formatter + */ + public function setFormatter(FormatterInterface $formatter) : AdapterInterface + { + } +} diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php deleted file mode 100644 index b9317e56..00000000 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ /dev/null @@ -1,70 +0,0 @@ - + * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); + * + * $logger->log("This is a message"); + * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); + * $logger->error("This is another error"); + * + * $logger->close(); + * + */ +class File extends \Phalcon\Logger\Adapter +{ + /** + * File handler resource + * + * @var resource + */ + protected $_fileHandler; + + /** + * File Path + */ + protected $_path; + + /** + * Path options + */ + protected $_options; + + + /** + * File Path + */ + public function getPath() {} + + /** + * Phalcon\Logger\Adapter\File constructor + * + * @param string $name + * @param array $options + */ + public function __construct($name, $options = null) {} + + /** + * Returns the internal formatter + * + * @return \Phalcon\Logger\FormatterInterface + */ + public function getFormatter() {} + + /** + * Writes the log to the file itself + * + * @param string $message + * @param int $type + * @param int $time + * @param array $context + */ + public function logInternal($message, $type, $time, array $context) {} + + /** + * Closes the logger + * + * @return bool + */ + public function close() {} + + /** + * Opens the internal file handler after unserialization + */ + public function __wakeup() {} + +} diff --git a/src/Phalcon/logger/adapter/Firephp.php b/src/Phalcon/logger/adapter/Firephp.php new file mode 100644 index 00000000..c509e369 --- /dev/null +++ b/src/Phalcon/logger/adapter/Firephp.php @@ -0,0 +1,55 @@ + + * use Phalcon\Logger\Adapter\Firephp; + * use Phalcon\Logger; + * + * $logger = new Firephp(); + * + * $logger->log(Logger::ERROR, "This is an error"); + * $logger->error("This is another error"); + * + * + * @deprecated Will be removed in 4.0.0 + */ +class Firephp extends \Phalcon\Logger\Adapter +{ + + private $_initialized = false; + + + private $_index = 1; + + + /** + * Returns the internal formatter + * + * @return \Phalcon\Logger\FormatterInterface + */ + public function getFormatter() {} + + /** + * Writes the log to the stream itself + * + * @param string $message + * @param int $type + * @param int $time + * @param array $context + */ + public function logInternal($message, $type, $time, array $context) {} + + /** + * Closes the logger + * + * @return bool + */ + public function close() {} + +} diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 9f2e6578..76f9e1a9 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -2,35 +2,35 @@ namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Adapter\Noop * * Adapter to store logs in plain text files * - * ```php + * * $logger = new \Phalcon\Logger\Adapter\Noop(); * * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); * * $logger->close(); - * ``` + * */ -class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter +class Noop extends AbstractAdapter { + /** + * Closes the stream + */ + public function close() : bool + { + } - /** - * Closes the stream - * - * @return bool - */ - public function close(): bool {} - - /** - * Processes the message i.e. writes it to the file - * - * @param \Phalcon\Logger\Item $item - */ - public function process(\Phalcon\Logger\Item $item) {} - + /** + * Processes the message i.e. writes it to the file + */ + public function process(Item $item) : void + { + } } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 94b479a3..33279124 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -5,76 +5,59 @@ /** * Phalcon\Logger\Adapter\Stream * - * Adapter to store logs in plain text files + * Sends logs to a valid PHP stream * - * ```php - * $logger = new \Phalcon\Logger\Adapter\Stream("app/logs/test.log"); + * + * use Phalcon\Logger; + * use Phalcon\Logger\Adapter\Stream; + * + * $logger = new Stream("php://stderr"); * * $logger->log("This is a message"); - * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); + * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * - * $logger->close(); - * ``` + * */ -class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter +class Stream extends \Phalcon\Logger\Adapter { /** - * Stream handler resource + * File handler resource * - * @var resource|null + * @var resource */ - protected $handler = null; + protected $_stream; - /** - * The file open mode. Defaults to "ab" - * - * @var string - */ - protected $mode = 'ab'; - - /** - * Stream name - * - * @var string - */ - protected $name; /** - * Path options + * Phalcon\Logger\Adapter\Stream constructor * - * @var array + * @param string $name + * @param array $options */ - protected $options; - + public function __construct($name, $options = null) {} /** - * Stream name + * Returns the internal formatter * - * @return string + * @return \Phalcon\Logger\FormatterInterface */ - public function getName(): string {} + public function getFormatter() {} /** - * Constructor. Accepts the name and some options + * Writes the log to the stream itself * - * @param string $name - * @param array $options + * @param string $message + * @param int $type + * @param int $time + * @param array $context */ - public function __construct(string $name, array $options = array()) {} + public function logInternal($message, $type, $time, array $context) {} /** - * Closes the stream + * Closes the logger * * @return bool */ - public function close(): bool {} - - /** - * Processes the message i.e. writes it to the file - * - * @param \Phalcon\Logger\Item $item - */ - public function process(\Phalcon\Logger\Item $item) {} + public function close() {} } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index 14c95796..bf684c7c 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -7,7 +7,7 @@ * * Sends logs to the system logger * - * ```php + * * use Phalcon\Logger; * use Phalcon\Logger\Adapter\Syslog; * @@ -23,36 +23,12 @@ * $logger->log("This is a message"); * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * ``` + * */ -class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter +class Syslog extends \Phalcon\Logger\Adapter { - /** - * Name of the default formatter class - * - * @var string - */ - protected $defaultFormatter = 'Syslog'; - - /** - * @var int - */ - protected $facility = 0; - - /** - * @var string - */ - protected $name = ''; - /** - * @var bool - */ - protected $opened = false; - - /** - * @var int - */ - protected $option = 0; + protected $_opened = false; /** @@ -61,28 +37,30 @@ class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter * @param string $name * @param array $options */ - public function __construct(string $name, array $options = array()) {} + public function __construct($name, $options = null) {} /** - * Closes the logger + * Returns the internal formatter * - * @return bool + * @return \Phalcon\Logger\FormatterInterface */ - public function close(): bool {} + public function getFormatter() {} /** - * Processes the message i.e. writes it to the syslog + * Writes the log to the stream itself * - * @param \Phalcon\Logger\Item $item + * @param string $message + * @param int $type + * @param int $time + * @param array $context */ - public function process(\Phalcon\Logger\Item $item) {} + public function logInternal($message, $type, $time, array $context) {} /** - * Translates a Logger level to a Syslog level + * Closes the logger * - * @param string $level - * @return int + * @return bool */ - private function logLevelToSyslog(string $level): int {} + public function close() {} } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php deleted file mode 100644 index 9049eb11..00000000 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface -{ - - /** - * Interpolates context values into the message placeholders - * - * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message - * @param string $message - * @param array $context - */ - public function interpolate(string $message, $context = null) {} - -} diff --git a/src/Phalcon/logger/formatter/Abstractformatter.php b/src/Phalcon/logger/formatter/Abstractformatter.php new file mode 100644 index 00000000..1079548e --- /dev/null +++ b/src/Phalcon/logger/formatter/Abstractformatter.php @@ -0,0 +1,19 @@ + item + * + * @return string|array + */ + public function format(Item $item); } + diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index a1552d6a..127cb1bd 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -7,43 +7,18 @@ * * Formats messages using JSON encoding */ -class Json extends \Phalcon\Logger\Formatter\AbstractFormatter +class Json extends \Phalcon\Logger\Formatter { - /** - * Default date format - * - * @var string - */ - protected $dateFormat; - - - /** - * Default date format - * - * @return string - */ - public function getDateFormat(): string {} - - /** - * Default date format - * - * @param string $dateFormat - */ - public function setDateFormat(string $dateFormat) {} - - /** - * Phalcon\Logger\Formatter\Json construct - * - * @param string $dateFormat - */ - public function __construct(string $dateFormat = 'D, d M y H:i:s O') {} /** * Applies a format to a message before sent it to the internal log * - * @param \Phalcon\Logger\Item $item + * @param string $message + * @param int $type + * @param int $timestamp + * @param array $context * @return string */ - public function format(\Phalcon\Logger\Item $item): string {} + public function format($message, $type, $timestamp, $context = null) {} } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index b575d37d..0387d9ed 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -7,21 +7,21 @@ * * Formats messages using an one-line string */ -class Line extends \Phalcon\Logger\Formatter\AbstractFormatter +class Line extends \Phalcon\Logger\Formatter { /** * Default date format * * @var string */ - protected $dateFormat; + protected $_dateFormat = 'D, d M y H:i:s O'; /** * Format applied to each message * * @var string */ - protected $format; + protected $_format = '[%date%][%type%] %message%'; /** @@ -29,28 +29,28 @@ class Line extends \Phalcon\Logger\Formatter\AbstractFormatter * * @return string */ - public function getDateFormat(): string {} + public function getDateFormat() {} /** * Default date format * * @param string $dateFormat */ - public function setDateFormat(string $dateFormat) {} + public function setDateFormat($dateFormat) {} /** * Format applied to each message * * @return string */ - public function getFormat(): string {} + public function getFormat() {} /** * Format applied to each message * * @param string $format */ - public function setFormat(string $format) {} + public function setFormat($format) {} /** * Phalcon\Logger\Formatter\Line construct @@ -58,14 +58,17 @@ public function setFormat(string $format) {} * @param string $format * @param string $dateFormat */ - public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') {} + public function __construct($format = null, $dateFormat = null) {} /** * Applies a format to a message before sent it to the internal log * - * @param \Phalcon\Logger\Item $item + * @param string $message + * @param int $type + * @param int $timestamp + * @param array $context * @return string */ - public function format(\Phalcon\Logger\Item $item): string {} + public function format($message, $type, $timestamp, $context = null) {} } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 6f886239..c37da150 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -7,15 +7,18 @@ * * Prepares a message to be used in a Syslog backend */ -class Syslog extends \Phalcon\Logger\Formatter\AbstractFormatter +class Syslog extends \Phalcon\Logger\Formatter { /** * Applies a format to a message before sent it to the internal log * - * @param \Phalcon\Logger\Item $item + * @param string $message + * @param int $type + * @param int $timestamp + * @param array $context * @return array */ - public function format(\Phalcon\Logger\Item $item): array {} + public function format($message, $type, $timestamp, $context = null) {} } diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php index bca86886..b1978f3b 100644 --- a/src/Phalcon/messages/Exception.php +++ b/src/Phalcon/messages/Exception.php @@ -5,7 +5,8 @@ /** * Phalcon\Validation\Exception * - * Exceptions thrown in Phalcon\Messages\ classes will use this class + * Exceptions thrown in Phalcon\Messages\* classes will use this class + * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index e1d94052..3cfe5cfe 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -2,127 +2,137 @@ namespace Phalcon\Messages; +use Phalcon\Messages\MessageInterface; + /** * Phalcon\Messages\Message * * Stores a message from various components */ -class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable +class Message implements MessageInterface, \JsonSerializable { - /** - * @var int - */ - protected $code; - - /** - * @var string - */ - protected $field; - - /** - * @var string - */ - protected $message; - - /** - * @var string - */ - protected $type; - - /** - * @var array - */ - protected $metaData = array(); - - - /** - * @return int - */ - public function getCode(): int {} - - /** - * @return string - */ - public function getField(): string {} - - /** - * @return string - */ - public function getMessage(): string {} - - /** - * @return string - */ - public function getType(): string {} - - /** - * @return array - */ - public function getMetaData(): array {} - - /** - * Phalcon\Messages\Message constructor - * - * @param string $message - * @param mixed $field - * @param string $type - * @param int $code - * @param array $metaData - */ - public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) {} - - /** - * Magic __toString method returns verbose message - * - * @return string - */ - public function __toString(): string {} - - /** - * Serializes the object for json_encode - * - * @return array - */ - public function jsonSerialize(): array {} - - /** - * Sets code for the message - * - * @param int $code - * @return \Phalcon\Messages\MessageInterface - */ - public function setCode(int $code): MessageInterface {} - - /** - * Sets field name related to message - * - * @param mixed $field - * @return \Phalcon\Messages\MessageInterface - */ - public function setField($field): MessageInterface {} - - /** - * Sets verbose message - * - * @param string $message - * @return \Phalcon\Messages\MessageInterface - */ - public function setMessage(string $message): MessageInterface {} - - /** - * Sets message metadata - * - * @param array $metaData - * @return \Phalcon\Messages\MessageInterface - */ - public function setMetaData(array $metaData): MessageInterface {} - - /** - * Sets message type - * - * @param string $type - * @return \Phalcon\Messages\MessageInterface - */ - public function setType(string $type): MessageInterface {} - + /** + * @var int + */ + protected $code; + + /** + * @var string + */ + protected $field; + + /** + * @var string + */ + protected $message; + + /** + * @var string + */ + protected $type; + + /** + * @var array + */ + protected $metaData = []; + + /** + * Phalcon\Messages\Message constructor + */ + public function __construct(string $message, $field = "", string $type = "", int $code = 0, array $metaData = []) + { + } + + /** + * Returns the message code + */ + public function getCode() : int + { + } + + /** + * Returns field name related to message + * + * @return mixed + */ + public function getField() + { + } + + /** + * Returns verbose message + */ + public function getMessage() : string + { + } + + /** + * Returns message type + */ + public function getType() : string + { + } + + /** + * Returns message metadata + */ + public function getMetaData() : array + { + } + + /** + * Serializes the object for json_encode + */ + public function jsonSerialize() : array + { + } + + /** + * Sets code for the message + */ + public function setCode(int $code) : MessageInterface + { + } + + /** + * Sets field name related to message + */ + public function setField($field) : MessageInterface + { + } + + /** + * Sets verbose message + */ + public function setMessage(string $message) : MessageInterface + { + } + + /** + * Sets message type + */ + public function setType(string $type) : MessageInterface + { + } + + /** + * Sets message metadata + */ + public function setMetaData(array $metaData) : MessageInterface + { + } + + /** + * Magic __toString method returns verbose message + */ + public function __toString() : string + { + } + + /** + * Magic __set_state helps to re-build messages variable exporting + */ + public static function __set_state(array $message) : MessageInterface + { + } } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php deleted file mode 100644 index 550abcfa..00000000 --- a/src/Phalcon/messages/MessageInterface.php +++ /dev/null @@ -1,95 +0,0 @@ -appendMessage( - * new \Phalcon\Messages\Message("This is a message") - * ); - * ``` - * - * @param \Phalcon\Messages\MessageInterface $message - */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} - - /** - * Appends an array of messages to the collection - * - * ```php - * $messages->appendMessages($messagesArray); - * ``` - * - * @param \Phalcon\Messages\MessageInterface[] $messages - */ - public function appendMessages($messages) {} - - /** - * Returns the number of messages in the list - * - * @return int - */ - public function count(): int {} - - /** - * Returns the current message in the iterator - * - * @return \Phalcon\Messages\MessageInterface - */ - public function current(): MessageInterface {} - - /** - * Filters the message collection by field name - * - * @param string $fieldName - * @return array - */ - public function filter(string $fieldName): array {} + /** + * @var int + */ + protected $position = 0; + + /** + * @var array + */ + protected $messages; + + /** + * Phalcon\Messages\Messages constructor + */ + public function __construct(array $messages = []) + { + } + + /** + * Appends a message to the collection + * + * + * $messages->appendMessage( + * new \Phalcon\Messages\Message("This is a message") + * ); + * + */ + public function appendMessage(MessageInterface $message) + { + } + + /** + * Appends an array of messages to the collection + * + * + * $messages->appendMessages($messagesArray); + * + * + * @param \Phalcon\Messages\MessageInterface[] messages + */ + public function appendMessages($messages) + { + } + + /** + * Returns the number of messages in the list + */ + public function count() : int + { + } + + /** + * Returns the current message in the iterator + */ + public function current() : MessageInterface + { + } + + /** + * Filters the message collection by field name + */ + public function filter(string $fieldName) : array + { + } /** * Returns serialised message objects as array for json_encode. Calls * jsonSerialize on each object if present * - * ```php + * * $data = $messages->jsonSerialize(); * echo json_encode($data); - * ``` - * - * @return array - */ - public function jsonSerialize(): array {} - - /** - * Returns the current position/key in the iterator - * - * @return int - */ - public function key(): int {} - - /** - * Moves the internal iteration pointer to the next position - */ - public function next() {} - - /** - * Checks if an index exists - * - * ```php - * var_dump( - * isset($message["database"]) - * ); - * ``` - * - * @param int $index - * @return bool - */ - public function offsetExists($index): bool {} - - /** - * Gets an attribute a message using the array syntax - * - * ```php - * print_r( - * $messages[0] - * ); - * ``` - * - * @param mixed $index - * @return mixed - */ - public function offsetGet($index) {} - - /** - * Sets an attribute using the array-syntax - * - * ```php - * $messages[0] = new \Phalcon\Messages\Message("This is a message"); - * ``` - * - * @param mixed $index - * @param \Phalcon\Messages\Message $message - */ - public function offsetSet($index, $message) {} - - /** - * Removes a message from the list - * - * ```php - * unset($message["database"]); - * ``` - * - * @param mixed $index - */ - public function offsetUnset($index) {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} - - /** - * Check if the current message in the iterator is valid - * - * @return bool - */ - public function valid(): bool {} - + * + */ + public function jsonSerialize() : array + { + } + + /** + * Returns the current position/key in the iterator + */ + public function key() : int + { + } + + /** + * Moves the internal iteration pointer to the next position + */ + public function next() : void + { + } + + /** + * Checks if an index exists + * + * + * var_dump( + * isset($message["database"]) + * ); + * + * + * @param int index + */ + public function offsetExists($index) : boolean + { + } + + /** + * Gets an attribute a message using the array syntax + * + * + * print_r( + * $messages[0] + * ); + * + */ + public function offsetGet($index) { + } + + /** + * Sets an attribute using the array-syntax + * + * + * $messages[0] = new \Phalcon\Messages\Message("This is a message"); + * + * + * @param \Phalcon\Messages\Message message + */ + public function offsetSet($index, $message) : void + { + } + + /** + * Removes a message from the list + * + * + * unset($message["database"]); + * + */ + public function offsetUnset($index) : void + { + } + + /** + * Rewinds the internal iterator + */ + public function rewind() : void + { + } + + /** + * Check if the current message in the iterator is valid + */ + public function valid() : boolean + { + } } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 9faf4966..293a9d9d 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -5,11 +5,10 @@ /** * Phalcon\Mvc\Application * - * This component encapsulates all the complex operations behind instantiating - * every component needed and integrating it with the rest to allow the MVC - * pattern to operate as desired. + * This component encapsulates all the complex operations behind instantiating every component + * needed and integrating it with the rest to allow the MVC pattern to operate as desired. * - * ```php + * * use Phalcon\Mvc\Application; * * class MyApp extends Application @@ -46,27 +45,27 @@ * $application = new MyApp(); * * $application->main(); - * ``` + * */ -class Application extends \Phalcon\Application\AbstractApplication +class Application extends \Phalcon\Application { - protected $implicitView = true; + protected $_implicitView = true; - protected $sendCookies = true; + protected $_sendHeaders = true; - protected $sendHeaders = true; + protected $_sendCookies = true; /** - * Handles a MVC request + * Enables or disables sending headers by each request handling * - * @param string $uri - * @return bool|\Phalcon\Http\ResponseInterface + * @param bool $sendHeaders + * @return Application */ - public function handle(string $uri) {} + public function sendHeadersOnHandleRequest($sendHeaders) {} /** * Enables or disables sending cookies by each request handling @@ -74,23 +73,23 @@ public function handle(string $uri) {} * @param bool $sendCookies * @return Application */ - public function sendCookiesOnHandleRequest(bool $sendCookies): Application {} + public function sendCookiesOnHandleRequest($sendCookies) {} /** - * Enables or disables sending headers by each request handling + * By default. The view is implicitly buffering all the output + * You can full disable the view component using this method * - * @param bool $sendHeaders + * @param bool $implicitView * @return Application */ - public function sendHeadersOnHandleRequest(bool $sendHeaders): Application {} + public function useImplicitView($implicitView) {} /** - * By default. The view is implicitly buffering all the output - * You can full disable the view component using this method + * Handles a MVC request * - * @param bool $implicitView - * @return Application + * @param string $uri + * @return bool|\Phalcon\Http\ResponseInterface */ - public function useImplicitView(bool $implicitView): Application {} + public function handle($uri = null) {} } diff --git a/src/Phalcon/mvc/Collection.php b/src/Phalcon/mvc/Collection.php index a5dbf4ae..14296c3d 100644 --- a/src/Phalcon/mvc/Collection.php +++ b/src/Phalcon/mvc/Collection.php @@ -11,336 +11,160 @@ abstract class Collection implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\CollectionInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable { - const DIRTY_STATE_DETACHED = 2; + const OP_NONE = 0; - const DIRTY_STATE_PERSISTENT = 0; + const OP_CREATE = 1; - const DIRTY_STATE_TRANSIENT = 1; + const OP_UPDATE = 2; - const OP_CREATE = 1; + const OP_DELETE = 3; - const OP_DELETE = 3; + const DIRTY_STATE_PERSISTENT = 0; - const OP_NONE = 0; + const DIRTY_STATE_TRANSIENT = 1; - const OP_UPDATE = 2; + const DIRTY_STATE_DETACHED = 2; public $_id; - protected $connection; + protected $_dependencyInjector; - protected $container; + protected $_modelsManager; - protected $dirtyState = 1; + protected $_source; - static protected $disableEvents; + protected $_operationMade = 0; - protected $errorMessages = array(); + protected $_dirtyState = 1; - protected $modelsManager; + protected $_connection; - protected $operationMade = 0; + protected $_errorMessages = array(); - static protected $reserved; + static protected $_reserved; - protected $skipped = false; + static protected $_disableEvents; - protected $source; + protected $_skipped = false; /** * Phalcon\Mvc\Collection constructor * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @param \Phalcon\Mvc\Collection\ManagerInterface $modelsManager */ - final public function __construct(\Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} - - /** - * Sets up a behavior in a collection - * - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior - */ - protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + public final function __construct(\Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} /** - * Perform an aggregation using the Mongo aggregation framework + * Sets a value for the _id property, creates a MongoId object if needed * - * @param array $parameters - * @param array $options - * @return array + * @param mixed $id */ - public static function aggregate(array $parameters = null, array $options = null): array {} + public function setId($id) {} /** - * Appends a customized message on the validation process - * - * ```php - * use \Phalcon\Messages\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - * ``` + * Returns the value of the _id property * - * @param \Phalcon\Messages\MessageInterface $message + * @return \MongoId */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} + public function getId() {} /** - * Returns a cloned collection + * Sets the dependency injection container * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @param \Phalcon\DiInterface $dependencyInjector */ - public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Creates a collection based on the values in the attributes + * Returns the dependency injection container * - * @return bool + * @return \Phalcon\DiInterface */ - public function create(): bool {} + public function getDI() {} /** - * Creates a document based on the values in the attributes, if not found by - * criteria. Preferred way to avoid duplication is to create index o - * attribute - * - * ```php - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * ``` + * Sets a custom events manager * - * @param array $criteria - * @return bool + * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager */ - public function createIfNotExist(array $criteria): bool {} + protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} /** - * Perform a count over a collection - * - * ```php - * echo "There are ", Robots::count(), " robots"; - * ``` + * Returns the custom events manager * - * @param array $parameters - * @return int + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - public static function count(array $parameters = null): int {} + protected function getEventsManager() {} /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * ```php - * $robot = Robots::findFirst(); - * - * $robot->delete(); - * - * $robots = Robots::find(); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * ``` + * Returns the models manager related to the entity instance * - * @return bool + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - public function delete(): bool {} + public function getCollectionManager() {} /** - * Allows to query a set of records that match the specified conditions - * - * ```php - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * ``` + * Returns an array with reserved properties that cannot be part of the insert/update * - * @param array $parameters * @return array */ - public static function find(array $parameters = null): array {} + public function getReservedAttributes() {} /** - * Find a document by its id (_id) - * - * ```php - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * ``` + * Sets if a model must use implicit objects ids * - * @param mixed $id - * @return null|CollectionInterface + * @param bool $useImplicitObjectIds */ - public static function findById($id): ?CollectionInterface {} + protected function useImplicitObjectIds($useImplicitObjectIds) {} /** - * Allows to query the first record that match the specified conditions - * - * ```php - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * ``` + * Sets collection name which model should be mapped * - * @param array $parameters - * @return array + * @param string $source + * @return Collection */ - public static function findFirst(array $parameters = null): array {} + protected function setSource($source) {} /** - * Fires an internal event + * Returns collection name mapped in the model * - * @param string $eventName - * @return bool + * @return string */ - public function fireEvent(string $eventName): bool {} + public function getSource() {} /** - * Fires an internal event that cancels the operation + * Sets the DependencyInjection connection service name * - * @param string $eventName - * @return bool + * @param string $connectionService + * @return Collection */ - public function fireEventCancel(string $eventName): bool {} + public function setConnectionService($connectionService) {} /** - * Returns the models manager related to the entity instance + * Returns DependencyInjection connection service * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * @return string */ - public function getCollectionManager(): ManagerInterface {} + public function getConnectionService() {} /** * Retrieves a database connection @@ -350,315 +174,534 @@ public function getCollectionManager(): ManagerInterface {} public function getConnection() {} /** - * Returns DependencyInjection connection service + * Reads an attribute value by its name * - * @return string + * + * echo $robot->readAttribute("name"); + * + * + * @param string $attribute + * @return mixed */ - public function getConnectionService(): string {} + public function readAttribute($attribute) {} /** - * Returns the dependency injection container + * Writes an attribute value by its name * - * @return \Phalcon\Di\DiInterface + * + * $robot->writeAttribute("name", "Rosey"); + * + * + * @param string $attribute + * @param mixed $value */ - public function getDI(): DiInterface {} + public function writeAttribute($attribute, $value) {} /** - * Returns one of the DIRTY_STATE_ constants telling if the document exists - * in the collection or not + * Returns a cloned collection * - * @return int + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function getDirtyState(): int {} + public static function cloneResult(CollectionInterface $collection, array $document) {} /** - * Returns the custom events manager + * Returns a collection resultset * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * @param array $params + * @param \Phalcon\Mvc\Collection $collection + * @param \MongoDb $connection + * @param boolean $unique + * @return array */ - protected function getEventsManager(): ManagerInterface {} + protected static function _getResultset($params, CollectionInterface $collection, $connection, $unique) {} /** - * Returns the value of the _id property + * Perform a count over a resultset * - * @return \MongoId + * @param array $params + * @param \Phalcon\Mvc\Collection $collection + * @param \MongoDb $connection + * @return int */ - public function getId() {} + protected static function _getGroupResultset($params, Collection $collection, $connection) {} /** - * Returns all the validation messages - * - * ```php - * $robot = new Robots(); + * Executes internal hooks before save a document * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; + * @param \Phalcon\DiInterface $dependencyInjector + * @param boolean $disableEvents + * @param boolean $exists + * @return bool + */ + protected final function _preSave($dependencyInjector, $disableEvents, $exists) {} + + /** + * Executes internal events after save a document * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; + * @param bool $disableEvents + * @param bool $success + * @param bool $exists + * @return bool + */ + protected final function _postSave($disableEvents, $success, $exists) {} + + /** + * Executes validators on every validation call * - * $messages = $robot->getMessages(); + * + * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; * - * foreach ($messages as $message) { - * echo $message; + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * // Old, deprecated syntax, use new one below + * $this->validate( + * new ExclusionIn( + * [ + * "field" => "status", + * "domain" => ["A", "I"], + * ] + * ) + * ); + * + * if ($this->validationHasFailed() == true) { + * return false; + * } * } - * } else { - * echo "Great, a new robot was saved successfully!"; * } - * ``` + * + * + * + * use Phalcon\Validation\Validator\ExclusionIn as ExclusionIn; + * use Phalcon\Validation; * - * @return array|\Phalcon\Messages\MessageInterface[] + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $validator = new Validation(); + * $validator->add("status", + * new ExclusionIn( + * [ + * "domain" => ["A", "I"] + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * + * + * @param mixed $validator */ - public function getMessages(): array {} + protected function validate($validator) {} /** - * Returns an array with reserved properties that cannot be part of the - * insert/update + * Check whether validation process has generated any messages * - * @return array + * + * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new ExclusionIn( + * [ + * "field" => "status", + * "domain" => ["A", "I"], + * ] + * ) + * ); + * + * if ($this->validationHasFailed() == true) { + * return false; + * } + * } + * } + * + * + * @return bool */ - public function getReservedAttributes(): array {} + public function validationHasFailed() {} /** - * Returns collection name mapped in the model + * Fires an internal event * - * @return string + * @param string $eventName + * @return bool */ - public function getSource(): string {} + public function fireEvent($eventName) {} /** - * Reads an attribute value by its name - * - * ```php - * echo $robot->readAttribute("name"); - * ``` + * Fires an internal event that cancels the operation * - * @param string $attribute - * @return mixed|null + * @param string $eventName + * @return bool */ - public function readAttribute(string $attribute): ? {} + public function fireEventCancel($eventName) {} /** - * Creates/Updates a collection based on the values in the attributes + * Cancel the current operation * + * @param bool $disableEvents * @return bool */ - public function save(): bool {} + protected function _cancelOperation($disableEvents) {} /** - * Serializes the object ignoring connections or protected properties + * Checks if the document exists in the collection * - * @return string + * @param \MongoCollection $collection + * @return bool */ - public function serialize(): string {} + protected function _exists($collection) {} /** - * Sets the DependencyInjection connection service name + * Returns all the validation messages * - * @param string $connectionService - * @return Collection + * + * $robot = new Robots(); + * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; + * + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; + * + * $messages = $robot->getMessages(); + * + * foreach ($messages as $message) { + * echo $message; + * } + * } else { + * echo "Great, a new robot was saved successfully!"; + * } + * + * + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function setConnectionService(string $connectionService): Collection {} + public function getMessages() {} /** - * Sets the dependency injection container + * Appends a customized message on the validation process + * + * + * use \Phalcon\Mvc\Model\Message as Message; + * + * class Robots extends \Phalcon\Mvc\Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); * - * @param \Phalcon\Di\DiInterface $container + * $this->appendMessage(message); + * } + * } + * } + * + * + * @param \Phalcon\Mvc\Model\MessageInterface $message + */ + public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} + + /** + * Shared Code for CU Operations + * Prepares Collection */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + protected function prepareCU() {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ - * constants + * Creates/Updates a collection based on the values in the attributes * - * @param int $dirtyState - * @return CollectionInterface + * @return bool */ - public function setDirtyState(int $dirtyState): CollectionInterface {} + public function save() {} /** - * Sets a custom events manager + * Creates a collection based on the values in the attributes * - * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager + * @return bool */ - protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} + public function create() {} /** - * Sets a value for the _id property, creates a MongoId object if needed + * Creates a document based on the values in the attributes, if not found by criteria + * Preferred way to avoid duplication is to create index on attribute * - * @param mixed $id + * + * $robot = new Robot(); + * + * $robot->name = "MyRobot"; + * $robot->type = "Droid"; + * + * // Create only if robot with same name and type does not exist + * $robot->createIfNotExist( + * [ + * "name", + * "type", + * ] + * ); + * + * + * @param array $criteria + * @return bool */ - public function setId($id) {} + public function createIfNotExist(array $criteria) {} /** - * Sets collection name which model should be mapped + * Creates/Updates a collection based on the values in the attributes * - * @param string $source - * @return Collection + * @return bool */ - protected function setSource(string $source): Collection {} + public function update() {} /** - * Skips the current operation forcing a success state + * Find a document by its id (_id) * - * @param bool $skip + * + * // Find user by using \MongoId object + * $user = Users::findById( + * new \MongoId("545eb081631d16153a293a66") + * ); + * + * // Find user by using id as sting + * $user = Users::findById("45cbc4a0e4123f6920000002"); + * + * // Validate input + * if ($user = Users::findById($_POST["id"])) { + * // ... + * } + * + * + * @param mixed $id + * @return null|CollectionInterface */ - public function skipOperation(bool $skip) {} + public static function findById($id) {} /** - * Allows to perform a summatory group for a column in the collection + * Allows to query the first record that match the specified conditions * - * @param string $field - * @param mixed $conditions - * @param mixed $finalize + * + * // What's the first robot in the robots table? + * $robot = Robots::findFirst(); + * + * echo "The robot name is ", $robot->name, "\n"; + * + * // What's the first mechanical robot in robots table? + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "The first mechanical robot name is ", $robot->name, "\n"; + * + * // Get first virtual robot ordered by name + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ], + * "order" => [ + * "name" => 1, + * ], + * ] + * ); + * + * echo "The first virtual robot name is ", $robot->name, "\n"; + * + * // Get first robot by id (_id) + * $robot = Robots::findFirst( + * [ + * [ + * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), + * ] + * ] + * ); + * + * echo "The robot id is ", $robot->_id, "\n"; + * + * + * @param array $parameters * @return array */ - public static function summatory(string $field, $conditions = null, $finalize = null): array {} + public static function findFirst(array $parameters = null) {} /** - * Returns the instance as an array representation + * Allows to query a set of records that match the specified conditions * - * ```php - * print_r( - * $robot->toArray() + * + * // How many robots are there? + * $robots = Robots::find(); + * + * echo "There are ", count($robots), "\n"; + * + * // How many mechanical robots are there? + * $robots = Robots::find( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "There are ", count(robots), "\n"; + * + * // Get and print virtual robots ordered by name + * $robots = Robots::findFirst( + * [ + * [ + * "type" => "virtual" + * ], + * "order" => [ + * "name" => 1, + * ] + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + * // Get first 100 virtual robots ordered by name + * $robots = Robots::find( + * [ + * [ + * "type" => "virtual", + * ], + * "order" => [ + * "name" => 1, + * ], + * "limit" => 100, + * ] * ); - * ``` * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + * + * @param array $parameters * @return array */ - public function toArray(): array {} + public static function find(array $parameters = null) {} /** - * Unserializes the object from a serialized string + * Perform a count over a collection * - * @param mixed $data + * + * echo "There are ", Robots::count(), " robots"; + * + * + * @param array $parameters + * @return int */ - public function unserialize($data) {} + public static function count(array $parameters = null) {} /** - * Creates/Updates a collection based on the values in the attributes + * Perform an aggregation using the Mongo aggregation framework * - * @return bool + * @param array $parameters + * @param array $options + * @return array */ - public function update(): bool {} + public static function aggregate(array $parameters = null, array $options = null) {} /** - * Executes validators on every validation call + * Allows to perform a summatory group for a column in the collection * - * ```php - * use Phalcon\Mvc\Collection; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; + * @param string $field + * @param mixed $conditions + * @param mixed $finalize + * @return array + */ + public static function summatory($field, $conditions = null, $finalize = null) {} + + /** + * Deletes a model instance. Returning true on success or false otherwise. * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $validator = new Validation(); + * + * $robot = Robots::findFirst(); * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); + * $robot->delete(); * - * return $this->validate($validator); - * } + * $robots = Robots::find(); + * + * foreach ($robots as $robot) { + * $robot->delete(); * } - * ``` + * * - * @param \Phalcon\Validation\ValidationInterface $validator * @return bool */ - protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} + public function delete() {} /** - * Sets if a model must use implicit objects ids + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * - * @param bool $useImplicitObjectIds + * @param int $dirtyState + * @return CollectionInterface */ - protected function useImplicitObjectIds(bool $useImplicitObjectIds) {} + public function setDirtyState($dirtyState) {} /** - * Writes an attribute value by its name - * - * ```php - * $robot->writeAttribute("name", "Rosey"); - * ``` + * Returns one of the DIRTY_STATE_ constants telling if the document exists in the collection or not * - * @param string $attribute - * @param mixed $value + * @return int */ - public function writeAttribute(string $attribute, $value) {} + public function getDirtyState() {} /** - * Cancel the current operation + * Sets up a behavior in a collection * - * @param bool $disableEvents - * @return bool + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - protected function cancelOperation(bool $disableEvents): bool {} + protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} /** - * Checks if the document exists in the collection + * Skips the current operation forcing a success state * - * @param MongoCollection $collection - * @return bool + * @param bool $skip */ - protected function exists($collection): bool {} + public function skipOperation($skip) {} /** - * Perform a count over a resultset + * Returns the instance as an array representation * - * @param array $params - * @param Collection $collection - * @param \MongoDb $connection - * @return int - */ - protected static function getGroupResultset($params, Collection $collection, $connection): int {} - - /** - * Returns a collection resultset + * + * print_r( + * $robot->toArray() + * ); + * * - * @param array $params - * @param CollectionInterface $collection - * @param \MongoDb $connection - * @param bool $unique * @return array */ - protected static function getResultset($params, CollectionInterface $collection, $connection, bool $unique) {} + public function toArray() {} /** - * Executes internal hooks before save a document + * Serializes the object ignoring connections or protected properties * - * @param \Phalcon\Di\DiInterface $container - * @param bool $disableEvents - * @param bool $exists - * @return bool + * @return string */ - final protected function preSave(\Phalcon\Di\DiInterface $container, bool $disableEvents, bool $exists): bool {} + public function serialize() {} /** - * Executes internal events after save a document + * Unserializes the object from a serialized string * - * @param bool $disableEvents - * @param bool $success - * @param bool $exists - * @return bool - */ - final protected function postSave(bool $disableEvents, bool $success, bool $exists): bool {} - - /** - * Shared Code for CU Operations - * Prepares Collection + * @param mixed $data */ - protected function prepareCU() {} + public function unserialize($data) {} } diff --git a/src/Phalcon/mvc/CollectionInterface.php b/src/Phalcon/mvc/CollectionInterface.php index ead5cdd5..ab22a531 100644 --- a/src/Phalcon/mvc/CollectionInterface.php +++ b/src/Phalcon/mvc/CollectionInterface.php @@ -3,163 +3,162 @@ namespace Phalcon\Mvc; /** + * Phalcon\Mvc\CollectionInterface + * * Interface for Phalcon\Mvc\Collection */ interface CollectionInterface { /** - * Appends a customized message on the validation process + * Sets a value for the _id property, creates a MongoId object if needed * - * @param \Phalcon\Messages\MessageInterface $message + * @param mixed $id */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message); + public function setId($id); /** - * Returns a cloned collection + * Returns the value of the _id property * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @return MongoId */ - public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface; + public function getId(); /** - * Perform a count over a collection + * Returns an array with reserved properties that cannot be part of the insert/update * - * @param array $parameters - * @return int + * @return array */ - public static function count(array $parameters = null): int; + public function getReservedAttributes(); /** - * Deletes a model instance. Returning true on success or false otherwise + * Returns collection name mapped in the model * - * @return bool + * @return string */ - public function delete(): bool; + public function getSource(); /** - * Allows to query a set of records that match the specified conditions + * Sets a service in the services container that returns the Mongo database * - * @param array $parameters - * @return array + * @param string $connectionService */ - public static function find(array $parameters = null): array; + public function setConnectionService($connectionService); /** - * Find a document by its id + * Retrieves a database connection * - * @param string $id - * @return null|CollectionInterface + * @return MongoDb */ - public static function findById($id): ?CollectionInterface; + public function getConnection(); /** - * Allows to query the first record that match the specified conditions + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * - * @param array $parameters - * @return array + * @param int $dirtyState + * @return \Phalcon\Mvc\CollectionInterface */ - public static function findFirst(array $parameters = null): array; + public function setDirtyState($dirtyState); /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified + * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not * - * @param string $eventName - * @return bool + * @return int */ - public function fireEvent(string $eventName): bool; + public function getDirtyState(); /** - * Fires an event, implicitly listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns bool false + * Returns a cloned collection * - * @param string $eventName - * @return bool + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function fireEventCancel(string $eventName): bool; + public static function cloneResult(CollectionInterface $collection, array $document); /** - * Retrieves a database connection + * Fires an event, implicitly calls behaviors and listeners in the events manager are notified * - * @return MongoDb + * @param string $eventName + * @return bool */ - public function getConnection(); + public function fireEvent($eventName); /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists - * in the database or not + * Fires an event, implicitly listeners in the events manager are notified + * This method stops if one of the callbacks/listeners returns boolean false * - * @return int + * @param string $eventName + * @return bool */ - public function getDirtyState(): int; + public function fireEventCancel($eventName); /** - * Returns the value of the _id property + * Check whether validation process has generated any messages * - * @return MongoId + * @return bool */ - public function getId(); + public function validationHasFailed(); /** * Returns all the validation messages * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function getMessages(): array; + public function getMessages(); /** - * Returns an array with reserved properties that cannot be part of the - * insert/update + * Appends a customized message on the validation process * - * @return array + * @param \Phalcon\Mvc\Model\MessageInterface $message */ - public function getReservedAttributes(): array; + public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); /** - * Returns collection name mapped in the model + * Creates/Updates a collection based on the values in the attributes * - * @return string + * @return bool */ - public function getSource(): string; + public function save(); /** - * Creates/Updates a collection based on the values in the attributes + * Find a document by its id * - * @return bool + * @param string $id + * @return null|CollectionInterface */ - public function save(): bool; + public static function findById($id); /** - * Sets a service in the services container that returns the Mongo database + * Allows to query the first record that match the specified conditions * - * @param string $connectionService + * @param array $parameters + * @return array */ - public function setConnectionService(string $connectionService); + public static function findFirst(array $parameters = null); /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ - * constants + * Allows to query a set of records that match the specified conditions * - * @param int $dirtyState - * @return CollectionInterface + * @param array $parameters + * @param $array parameters + * @return array */ - public function setDirtyState(int $dirtyState): CollectionInterface; + public static function find(array $parameters = null); /** - * Sets a value for the _id property, creates a MongoId object if needed + * Perform a count over a collection * - * @param mixed $id + * @param array $parameters + * @return array */ - public function setId($id); + public static function count(array $parameters = null); /** - * Check whether validation process has generated any messages + * Deletes a model instance. Returning true on success or false otherwise * * @return bool */ - public function validationHasFailed(): bool; + public function delete(); } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index e7f03779..f4089c53 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -5,15 +5,13 @@ /** * Phalcon\Mvc\Controller * - * Every application controller should extend this class that encapsulates all - * the controller functionality + * Every application controller should extend this class that encapsulates all the controller functionality * - * The controllers provide the “flow” between models and views. Controllers are - * responsible for processing the incoming requests from the web browser, - * interrogating the models for data, and passing that data on to the views for - * presentation. + * The controllers provide the “flow” between models and views. Controllers are responsible + * for processing the incoming requests from the web browser, interrogating the models for data, + * and passing that data on to the views for presentation. * - * ```php + * * */ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ControllerInterface { @@ -48,6 +46,6 @@ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc /** * Phalcon\Mvc\Controller constructor */ - final public function __construct() {} + public final function __construct() {} } diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index 50644e36..f48fc6ad 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -3,12 +3,13 @@ namespace Phalcon\Mvc; /** - * Dispatching is the process of taking the request object, extracting the - * module name, controller name, action name, and optional parameters contained - * in it, and then instantiating a controller and calling an action of that - * controller. + * Phalcon\Mvc\Dispatcher * - * ```php + * Dispatching is the process of taking the request object, extracting the module name, + * controller name, action name, and optional parameters contained in it, and then + * instantiating a controller and calling an action of that controller. + * + * * $di = new \Phalcon\Di(); * * $dispatcher = new \Phalcon\Mvc\Dispatcher(); @@ -20,24 +21,88 @@ * $dispatcher->setParams([]); * * $controller = $dispatcher->dispatch(); - * ``` + * */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Mvc\DispatcherInterface { - protected $defaultAction = 'index'; + protected $_handlerSuffix = 'Controller'; + + + protected $_defaultHandler = 'index'; + + + protected $_defaultAction = 'index'; + + + /** + * Sets the default controller suffix + * + * @param string $controllerSuffix + */ + public function setControllerSuffix($controllerSuffix) {} + + /** + * Sets the default controller name + * + * @param string $controllerName + */ + public function setDefaultController($controllerName) {} + + /** + * Sets the controller name to be dispatched + * + * @param string $controllerName + */ + public function setControllerName($controllerName) {} + + /** + * Gets last dispatched controller name + * + * @return string + */ + public function getControllerName() {} + /** + * Gets previous dispatched namespace name + * + * @return string + */ + public function getPreviousNamespaceName() {} - protected $defaultHandler = 'index'; + /** + * Gets previous dispatched controller name + * + * @return string + */ + public function getPreviousControllerName() {} + /** + * Gets previous dispatched action name + * + * @return string + */ + public function getPreviousActionName() {} - protected $handlerSuffix = 'Controller'; + /** + * Throws an internal exception + * + * @param string $message + * @param int $exceptionCode + */ + protected function _throwDispatchException($message, $exceptionCode = 0) {} + /** + * Handles a user exception + * + * @param \Exception $exception + */ + protected function _handleException(\Exception $exception) {} /** * Forwards the execution flow to another controller/action. * - * ```php + * * use Phalcon\Events\Event; * use Phalcon\Mvc\Dispatcher; * use App\Backend\Bootstrap as Backend; @@ -71,13 +136,8 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal * function(Event $event, Dispatcher $dispatcher, array $forward) use ($modules) { * $metadata = $modules[$forward["module"]]["metadata"]; * - * $dispatcher->setModuleName( - * $forward["module"] - * ); - * - * $dispatcher->setNamespaceName( - * $metadata["controllersNamespace"] - * ); + * $dispatcher->setModuleName($forward["module"]); + * $dispatcher->setNamespaceName($metadata["controllersNamespace"]); * } * ); * @@ -89,96 +149,31 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal * "action" => "index", * ] * ); - * ``` + * * * @param array $forward */ public function forward($forward) {} /** - * Returns the active controller in the dispatcher - * - * @return \Phalcon\Mvc\ControllerInterface - */ - public function getActiveController(): ControllerInterface {} - - /** - * Possible controller class name that will be located to dispatch the - * request + * Possible controller class name that will be located to dispatch the request * * @return string */ - public function getControllerClass(): string {} - - /** - * Gets last dispatched controller name - * - * @return string - */ - public function getControllerName(): string {} + public function getControllerClass() {} /** * Returns the latest dispatched controller * * @return \Phalcon\Mvc\ControllerInterface */ - public function getLastController(): ControllerInterface {} - - /** - * Gets previous dispatched action name - * - * @return string - */ - public function getPreviousActionName(): string {} - - /** - * Gets previous dispatched controller name - * - * @return string - */ - public function getPreviousControllerName(): string {} - - /** - * Gets previous dispatched namespace name - * - * @return string - */ - public function getPreviousNamespaceName(): string {} + public function getLastController() {} /** - * Sets the controller name to be dispatched - * - * @param string $controllerName - */ - public function setControllerName(string $controllerName) {} - - /** - * Sets the default controller suffix - * - * @param string $controllerSuffix - */ - public function setControllerSuffix(string $controllerSuffix) {} - - /** - * Sets the default controller name - * - * @param string $controllerName - */ - public function setDefaultController(string $controllerName) {} - - /** - * Handles a user exception - * - * @param \Exception $exception - */ - protected function handleException(\Exception $exception) {} - - /** - * Throws an internal exception + * Returns the active controller in the dispatcher * - * @param string $message - * @param int $exceptionCode + * @return \Phalcon\Mvc\ControllerInterface */ - protected function throwDispatchException(string $message, int $exceptionCode = 0) {} + public function getActiveController() {} } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index 3019e142..d0625078 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -7,49 +7,49 @@ * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends \Phalcon\DispatcherInterface { /** - * Returns the active controller in the dispatcher + * Sets the default controller suffix * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerSuffix */ - public function getActiveController(): ControllerInterface; + public function setControllerSuffix($controllerSuffix); /** - * Gets last dispatched controller name + * Sets the default controller name * - * @return string + * @param string $controllerName */ - public function getControllerName(): string; + public function setDefaultController($controllerName); /** - * Returns the latest dispatched controller + * Sets the controller name to be dispatched * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerName */ - public function getLastController(): ControllerInterface; + public function setControllerName($controllerName); /** - * Sets the default controller suffix + * Gets last dispatched controller name * - * @param string $controllerSuffix + * @return string */ - public function setControllerSuffix(string $controllerSuffix); + public function getControllerName(); /** - * Sets the controller name to be dispatched + * Returns the latest dispatched controller * - * @param string $controllerName + * @return \Phalcon\Mvc\ControllerInterface */ - public function setControllerName(string $controllerName); + public function getLastController(); /** - * Sets the default controller name + * Returns the active controller in the dispatcher * - * @param string $controllerName + * @return \Phalcon\Mvc\ControllerInterface */ - public function setDefaultController(string $controllerName); + public function getActiveController(); } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index ccff1790..196e0b86 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -14,9 +14,9 @@ interface EntityInterface * Reads an attribute value by its name * * @param string $attribute - * @return mixed|null + * @return mixed */ - public function readAttribute(string $attribute): ?; + public function readAttribute($attribute); /** * Writes an attribute value by its name @@ -24,6 +24,6 @@ public function readAttribute(string $attribute): ?; * @param string $attribute * @param mixed $value */ - public function writeAttribute(string $attribute, $value); + public function writeAttribute($attribute, $value); } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index b1fba1ac..7f8ca591 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -5,12 +5,11 @@ /** * Phalcon\Mvc\Micro * - * With Phalcon you can create "Micro-Framework like" applications. By doing - * this, you only need to write a minimal amount of code to create a PHP - * application. Micro applications are suitable to small applications, APIs and - * prototypes in a practical way. + * With Phalcon you can create "Micro-Framework like" applications. By doing this, you only need to + * write a minimal amount of code to create a PHP application. Micro applications are suitable + * to small applications, APIs and prototypes in a practical way. * - * ```php + * * $app = new \Phalcon\Mvc\Micro(); * * $app->get( @@ -20,161 +19,185 @@ * } * ); * - * $app->handle("/say/welcome/Phalcon"); - * ``` + * $app->handle(); + * */ class Micro extends \Phalcon\Di\Injectable implements \ArrayAccess { - protected $activeHandler; + protected $_dependencyInjector; - protected $afterBindingHandlers = array(); + protected $_handlers = array(); - protected $afterHandlers = array(); + protected $_router; - protected $beforeHandlers = array(); + protected $_stopped; - protected $container; + protected $_notFoundHandler; - protected $errorHandler; + protected $_errorHandler; - protected $finishHandlers = array(); + protected $_activeHandler; - protected $handlers = array(); + protected $_beforeHandlers; - protected $modelBinder; + protected $_afterHandlers; - protected $notFoundHandler; + protected $_finishHandlers; - protected $responseHandler; + protected $_returnedValue; - protected $returnedValue; + protected $_modelBinder; - protected $router; - - - protected $stopped; + protected $_afterBindingHandlers; /** * Phalcon\Mvc\Micro constructor * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function __construct(\Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} /** - * Appends an 'after' middleware to be called after execute the route + * Sets the DependencyInjector container * - * @param callable $handler - * @return Micro + * @param \Phalcon\DiInterface $dependencyInjector */ - public function after($handler): Micro {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Appends a afterBinding middleware to be called after model binding + * Maps a route to a handler without any HTTP method constraint * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function afterBinding($handler): Micro {} + public function map($routePattern, $handler) {} /** - * Appends a before middleware to be called before execute the route + * Maps a route to a handler that only matches if the HTTP method is GET * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function before($handler): Micro {} + public function get($routePattern, $handler) {} /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Maps a route to a handler that only matches if the HTTP method is POST * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function delete(string $routePattern, $handler): RouteInterface {} + public function post($routePattern, $handler) {} /** - * Sets a handler that will be called when an exception is thrown handling - * the route + * Maps a route to a handler that only matches if the HTTP method is PUT * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function error($handler): Micro {} + public function put($routePattern, $handler) {} /** - * Appends a 'finish' middleware to be called when the request is finished + * Maps a route to a handler that only matches if the HTTP method is PATCH * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function finish($handler): Micro {} + public function patch($routePattern, $handler) {} /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Maps a route to a handler that only matches if the HTTP method is HEAD * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function get(string $routePattern, $handler): RouteInterface {} + public function head($routePattern, $handler) {} /** - * Return the handler that will be called for the matched route + * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @return callable + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getActiveHandler() {} + public function delete($routePattern, $handler) {} /** - * Returns bound models from binder instance + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * - * @return array + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getBoundModels(): array {} + public function options($routePattern, $handler) {} /** - * Returns the internal handlers attached to the application + * Mounts a collection of handlers * - * @return array + * @param \Phalcon\Mvc\Micro\CollectionInterface $collection + * @return Micro */ - public function getHandlers(): array {} + public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection) {} /** - * Gets model binder + * Sets a handler that will be called when the router doesn't match any of the defined routes * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param callable $handler + * @return Micro */ - public function getModelBinder(): ?BinderInterface {} + public function notFound($handler) {} /** - * Returns the value returned by the executed handler + * Sets a handler that will be called when an exception is thrown handling the route * - * @return mixed + * @param callable $handler + * @return Micro */ - public function getReturnedValue() {} + public function error($handler) {} /** * Returns the internal router used by the application * * @return RouterInterface */ - public function getRouter(): RouterInterface {} + public function getRouter() {} + + /** + * Sets a service from the DI + * + * @param string $serviceName + * @param mixed $definition + * @param boolean $shared + * @return \Phalcon\Di\ServiceInterface + */ + public function setService($serviceName, $definition, $shared = false) {} + + /** + * Checks if a service is registered in the DI + * + * @param string $serviceName + * @return bool + */ + public function hasService($serviceName) {} /** * Obtains a service from the DI @@ -182,7 +205,7 @@ public function getRouter(): RouterInterface {} * @param string $serviceName * @return object */ - public function getService(string $serviceName) {} + public function getService($serviceName) {} /** * Obtains a shared service from the DI @@ -190,7 +213,7 @@ public function getService(string $serviceName) {} * @param string $serviceName * @return mixed */ - public function getSharedService(string $serviceName) {} + public function getSharedService($serviceName) {} /** * Handle the whole request @@ -198,187 +221,140 @@ public function getSharedService(string $serviceName) {} * @param string $uri * @return mixed */ - public function handle(string $uri) {} + public function handle($uri = null) {} /** - * Checks if a service is registered in the DI - * - * @param string $serviceName - * @return bool + * Stops the middleware execution avoiding than other middlewares be executed */ - public function hasService(string $serviceName): bool {} + public function stop() {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets externally the handler that must be called by the matched route * - * @param string $routePattern - * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @param callable $activeHandler */ - public function head(string $routePattern, $handler): RouteInterface {} + public function setActiveHandler($activeHandler) {} /** - * Maps a route to a handler without any HTTP method constraint + * Return the handler that will be called for the matched route * - * @param string $routePattern - * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return callable */ - public function map(string $routePattern, $handler): RouteInterface {} + public function getActiveHandler() {} /** - * Mounts a collection of handlers + * Returns the value returned by the executed handler * - * @param \Phalcon\Mvc\Micro\CollectionInterface $collection - * @return Micro + * @return mixed */ - public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro {} + public function getReturnedValue() {} /** - * Sets a handler that will be called when the router doesn't match any of - * the defined routes + * Check if a service is registered in the internal services container using the array syntax * - * @param callable $handler - * @return Micro + * @param string $alias + * @return bool */ - public function notFound($handler): Micro {} + public function offsetExists($alias) {} /** - * Check if a service is registered in the internal services container using - * the array syntax + * Allows to register a shared service in the internal services container using the array syntax * - * @param mixed $alias - * @return bool + * + * $app["request"] = new \Phalcon\Http\Request(); + * + * + * @param string $alias + * @param mixed $definition */ - public function offsetExists($alias): bool {} + public function offsetSet($alias, $definition) {} /** - * Allows to obtain a shared service in the internal services container - * using the array syntax + * Allows to obtain a shared service in the internal services container using the array syntax * - * ```php + * * var_dump( * $app["request"] * ); - * ``` + * * - * @param mixed $alias + * @param string $alias * @return mixed */ public function offsetGet($alias) {} /** - * Allows to register a shared service in the internal services container - * using the array syntax + * Removes a service from the internal services container using the array syntax * - * ```php - * $app["request"] = new \Phalcon\Http\Request(); - * ``` - * - * @param mixed $alias - * @param mixed $definition - */ - public function offsetSet($alias, $definition) {} - - /** - * Removes a service from the internal services container using the array - * syntax - * - * @param mixed $alias + * @param string $alias */ public function offsetUnset($alias) {} /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Appends a before middleware to be called before execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function options(string $routePattern, $handler): RouteInterface {} + public function before($handler) {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Appends a afterBinding middleware to be called after model binding * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function patch(string $routePattern, $handler): RouteInterface {} + public function afterBinding($handler) {} /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Appends an 'after' middleware to be called after execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function post(string $routePattern, $handler): RouteInterface {} + public function after($handler) {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Appends a 'finish' middleware to be called when the request is finished * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function put(string $routePattern, $handler): RouteInterface {} + public function finish($handler) {} /** - * Sets externally the handler that must be called by the matched route + * Returns the internal handlers attached to the application * - * @param callable $activeHandler + * @return array */ - public function setActiveHandler($activeHandler) {} + public function getHandlers() {} /** - * Sets the DependencyInjector container + * Gets model binder * - * @param \Phalcon\Di\DiInterface $container + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getModelBinder() {} /** * Sets model binder * - * ```php + * * $micro = new Micro($di); - * - * $micro->setModelBinder( - * new Binder(), - * 'cache' - * ); - * ``` + * $micro->setModelBinder(new Binder(), 'cache'); + * * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Micro */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro {} - - /** - * Appends a custom 'reponse' handler to be called insted of the default - * response handler - * - * @param callable $handler - * @return Micro - */ - public function setResponseHandler($handler): Micro {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} /** - * Sets a service from the DI + * Returns bound models from binder instance * - * @param string $serviceName - * @param mixed $definition - * @param bool $shared - * @return \Phalcon\Di\ServiceInterface - */ - public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface {} - - /** - * Stops the middleware execution avoiding than other middlewares be - * executed + * @return array */ - public function stop() {} + public function getBoundModels() {} } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 4778080b..85fada49 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -5,21 +5,19 @@ /** * Phalcon\Mvc\Model * - * Phalcon\Mvc\Model connects business objects and database tables to create a - * persistable domain model where logic and data are presented in one wrapping. + * Phalcon\Mvc\Model connects business objects and database tables to create + * a persistable domain model where logic and data are presented in one wrapping. * It‘s an implementation of the object-relational mapping (ORM). * - * A model represents the information (data) of the application and the rules to - * manipulate that data. Models are primarily used for managing the rules of - * interaction with a corresponding database table. In most cases, each table in - * your database will correspond to one model in your application. The bulk of - * your application's business logic will be concentrated in the models. + * A model represents the information (data) of the application and the rules to manipulate that data. + * Models are primarily used for managing the rules of interaction with a corresponding database table. + * In most cases, each table in your database will correspond to one model in your application. + * The bulk of your application's business logic will be concentrated in the models. * - * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, - * giving to developers high performance when interacting with databases while - * is also easy to use. + * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, giving to developers high performance + * when interacting with databases while is also easy to use. * - * ```php + * * $robot = new Robots(); * * $robot->type = "mechanical"; @@ -37,78 +35,75 @@ * } else { * echo "Great, a new robot was saved successfully!"; * } - * ``` + * */ abstract class Model implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable, \JsonSerializable { - const DIRTY_STATE_DETACHED = 2; - - - const DIRTY_STATE_PERSISTENT = 0; + const TRANSACTION_INDEX = 'transaction'; - const DIRTY_STATE_TRANSIENT = 1; + const OP_NONE = 0; const OP_CREATE = 1; - const OP_DELETE = 3; + const OP_UPDATE = 2; - const OP_NONE = 0; + const OP_DELETE = 3; - const OP_UPDATE = 2; + const DIRTY_STATE_PERSISTENT = 0; - const TRANSACTION_INDEX = 'transaction'; + const DIRTY_STATE_TRANSIENT = 1; - protected $container; + const DIRTY_STATE_DETACHED = 2; - protected $dirtyState = 1; + protected $_dependencyInjector; - protected $dirtyRelated = array(); + protected $_modelsManager; - protected $errorMessages = array(); + protected $_modelsMetaData; - protected $modelsManager; + protected $_errorMessages; - protected $modelsMetaData; + protected $_operationMade = 0; - protected $related = array(); + protected $_dirtyState = 1; - protected $operationMade = 0; + protected $_transaction; - protected $oldSnapshot = array(); + protected $_uniqueKey; - protected $skipped; + protected $_uniqueParams; - protected $snapshot; + protected $_uniqueTypes; - protected $transaction; + protected $_skipped; - protected $uniqueKey; + protected $_related; - protected $uniqueParams; + protected $_snapshot; - protected $uniqueTypes; + protected $_oldSnapshot; @@ -118,114 +113,198 @@ public function getTransaction() {} * Phalcon\Mvc\Model constructor * * @param mixed $data - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager */ - final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} + public final function __construct($data = null, \Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} /** - * Handles method calls when a method is not implemented + * Sets the dependency injection container * - * @param string $method - * @param array $arguments - * @return mixed + * @param \Phalcon\DiInterface $dependencyInjector */ - public function __call(string $method, array $arguments) {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Handles method calls when a static method is not implemented + * Returns the dependency injection container * - * @param string $method - * @param array $arguments - * @return mixed + * @return \Phalcon\DiInterface */ - public static function __callStatic(string $method, array $arguments) {} + public function getDI() {} /** - * Magic method to get related records using the relation alias as a - * property + * Sets a custom events manager * - * @param string $property - * @return mixed + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function __get(string $property) {} + protected function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Magic method to check if a property is a valid relation + * Returns the custom events manager * - * @param string $property - * @return bool + * @return \Phalcon\Events\ManagerInterface */ - public function __isset(string $property): bool {} + protected function getEventsManager() {} /** - * Magic method to assign values to the the model + * Returns the models meta-data service related to the entity instance * - * @param string $property - * @param mixed $value + * @return \Phalcon\Mvc\Model\MetaDataInterface */ - public function __set(string $property, $value) {} + public function getModelsMetaData() {} /** - * Setups a behavior in a model + * Returns the models manager related to the entity instance * - * ```php - * use Phalcon\Mvc\Model; - * use Phalcon\Mvc\Model\Behavior\Timestampable; + * @return \Phalcon\Mvc\Model\ManagerInterface + */ + public function getModelsManager() {} + + /** + * Sets a transaction related to the Model instance * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->addBehavior( - * new Timestampable( - * [ - * "onCreate" => [ - * "field" => "created_at", - * "format" => "Y-m-d", - * ], - * ] - * ) - * ); + * + * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; + * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; + * + * try { + * $txManager = new TxManager(); + * + * $transaction = $txManager->get(); + * + * $robot = new Robots(); + * + * $robot->setTransaction($transaction); + * + * $robot->name = "WALL·E"; + * $robot->created_at = date("Y-m-d"); + * + * if ($robot->save() === false) { + * $transaction->rollback("Can't save robot"); + * } + * + * $robotPart = new RobotParts(); + * + * $robotPart->setTransaction($transaction); + * + * $robotPart->type = "head"; + * + * if ($robotPart->save() === false) { + * $transaction->rollback("Robot part cannot be saved"); * } + * + * $transaction->commit(); + * } catch (TxFailed $e) { + * echo "Failed, reason: ", $e->getMessage(); * } - * ``` + * * - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return ModelInterface */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** - * Appends a customized message on the validation process + * Sets the table name to which model should be mapped * - * ```php - * use Phalcon\Mvc\Model; - * use Phalcon\Messages\Message as Message; + * @param string $source + * @return Model + */ + protected function setSource($source) {} + + /** + * Returns the table name mapped in the model * - * class Robots extends Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); + * @return string + */ + public function getSource() {} + + /** + * Sets schema name where the mapped table is located * - * $this->appendMessage($message); - * } - * } - * } - * ``` + * @param string $schema + * @return Model + */ + protected function setSchema($schema) {} + + /** + * Returns schema name where the mapped table is located * - * @param \Phalcon\Messages\MessageInterface $message - * @return \Phalcon\Mvc\ModelInterface + * @return string + */ + public function getSchema() {} + + /** + * Sets the DependencyInjection connection service name + * + * @param string $connectionService + * @return Model + */ + public function setConnectionService($connectionService) {} + + /** + * Sets the DependencyInjection connection service name used to read data + * + * @param string $connectionService + * @return Model + */ + public function setReadConnectionService($connectionService) {} + + /** + * Sets the DependencyInjection connection service name used to write data + * + * @param string $connectionService + * @return Model + */ + public function setWriteConnectionService($connectionService) {} + + /** + * Returns the DependencyInjection connection service name used to read data related the model + * + * @return string + */ + public function getReadConnectionService() {} + + /** + * Returns the DependencyInjection connection service name used to write data related to the model + * + * @return string + */ + public function getWriteConnectionService() {} + + /** + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * + * @param int $dirtyState + * @return ModelInterface + */ + public function setDirtyState($dirtyState) {} + + /** + * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * + * @return int + */ + public function getDirtyState() {} + + /** + * Gets the connection used to read data for the model + * + * @return \Phalcon\Db\AdapterInterface + */ + public function getReadConnection() {} + + /** + * Gets the connection used to write data to the model + * + * @return \Phalcon\Db\AdapterInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface {} + public function getWriteConnection() {} /** * Assigns values to a model from an array * - * ```php + * * $robot->assign( * [ * "type" => "mechanical", @@ -266,50 +345,20 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * "year", * ] * ); - * ``` + * * * @param array $data * @param array $dataColumnMap array to transform keys of data to another * @param array $whiteList - * @return \Phalcon\Mvc\ModelInterface - */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface {} - - /** - * Returns the average value on a column for a result-set of rows matching - * the specified conditions - * - * ```php - * // What's the average price of robots? - * $average = Robots::average( - * [ - * "column" => "price", - * ] - * ); - * - * echo "The average price is ", $average, "\n"; - * - * // What's the average price of mechanical robots? - * $average = Robots::average( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); - * - * echo "The average price of mechanical robots is ", $average, "\n"; - * ``` - * - * @param array $parameters - * @return double + * @return Model */ - public static function average($parameters = null): float {} + public function assign(array $data, $dataColumnMap = null, $whiteList = null) {} /** - * Assigns values to a model from an array returning a new model + * Assigns values to a model from an array, returning a new model. * - * ```php - * $robot = Phalcon\Mvc\Model::cloneResult( + * + * $robot = \Phalcon\Mvc\Model::cloneResultMap( * new Robots(), * [ * "type" => "mechanical", @@ -317,20 +366,32 @@ public static function average($parameters = null): float {} * "year" => 1952, * ] * ); - * ``` + * * - * @param \Phalcon\Mvc\ModelInterface $base + * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base * @param array $data + * @param array $columnMap * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @param boolean $keepSnapshots + * @return Model */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface {} + public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null) {} /** - * Assigns values to a model from an array, returning a new model. + * Returns an hydrated result based on the data and the column map * - * ```php - * $robot = \Phalcon\Mvc\Model::cloneResultMap( + * @param array $data + * @param array $columnMap + * @param int $hydrationMode + * @return mixed + */ + public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode) {} + + /** + * Assigns values to a model from an array returning a new model + * + * + * $robot = Phalcon\Mvc\Model::cloneResult( * new Robots(), * [ * "type" => "mechanical", @@ -338,128 +399,30 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * "year" => 1952, * ] * ); - * ``` + * * - * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface $base * @param array $data - * @param array $columnMap * @param int $dirtyState - * @param bool $keepSnapshots * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface {} - - /** - * Returns an hydrated result based on the data and the column map - * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode - * @return mixed - */ - public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) {} + public static function cloneResult(ModelInterface $base, array $data, $dirtyState = 0) {} /** - * Counts how many records match the specified conditions + * Query for a set of records that match the specified conditions * - * ```php + * * // How many robots are there? - * $number = Robots::count(); + * $robots = Robots::find(); * - * echo "There are ", $number, "\n"; + * echo "There are ", count($robots), "\n"; * * // How many mechanical robots are there? - * $number = Robots::count("type = 'mechanical'"); - * - * echo "There are ", $number, " mechanical robots\n"; - * ``` + * $robots = Robots::find( + * "type = 'mechanical'" + * ); * - * @param array $parameters - * @return int - */ - public static function count($parameters = null): int {} - - /** - * Inserts a model instance. If the instance already exists in the - * persistence it will throw an exception - * Returning true on success or false otherwise. - * - * ```php - * // Creating a new robot - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * $robot->create(); - * - * // Passing an array to create - * $robot = new Robots(); - * - * $robot->assign( - * [ - * "type" => "mechanical", - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); - * - * $robot->create(); - * ``` - * - * @return bool - */ - public function create(): bool {} - - /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * ```php - * $robot = Robots::findFirst("id=100"); - * - * $robot->delete(); - * - * $robots = Robots::find("type = 'mechanical'"); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * ``` - * - * @return bool - */ - public function delete(): bool {} - - /** - * Returns a simple representation of the object that can be used with - * `var_dump()` - * - * ```php - * var_dump( - * $robot->dump() - * ); - * ``` - * - * @return array - */ - public function dump(): array {} - - /** - * Query for a set of records that match the specified conditions - * - * ```php - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * "type = 'mechanical'" - * ); - * - * echo "There are ", count($robots), "\n"; + * echo "There are ", count($robots), "\n"; * * // Get and print virtual robots ordered by name * $robots = Robots::find( @@ -470,7 +433,7 @@ public function dump(): array {} * ); * * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * echo $robot->name, "\n"; * } * * // Get first 100 virtual robots ordered by name @@ -483,7 +446,7 @@ public function dump(): array {} * ); * * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * echo $robot->name, "\n"; * } * * // encapsulate find it into an running transaction esp. useful for application unit-tests @@ -491,27 +454,11 @@ public function dump(): array {} * * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); - * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); + * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); * - * $newRobot->assign( - * [ - * 'name' => 'test', - * 'type' => 'mechanical', - * 'year' => 1944, - * ] - * ); - * - * $newRobot->save(); - * - * $resultInsideTransaction = Robot::find( - * [ - * 'name' => 'test', - * Model::TRANSACTION_INDEX => $myTransaction, - * ] - * ); - * + * $resultInsideTransaction = Robot::find(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); * $resultOutsideTransaction = Robot::find(['name' => 'test']); * * foreach ($setInsideTransaction as $robot) { @@ -534,85 +481,39 @@ public function dump(): array {} * // add a new robots * $firstNewRobot = new Robot(); * $firstNewRobot->setTransaction($myTransaction1); - * $firstNewRobot->assign( - * [ - * 'name' => 'first-transaction-robot', - * 'type' => 'mechanical', - * 'year' => 1944, - * ] - * ); - * $firstNewRobot->save(); + * $firstNewRobot->save(['name' => 'first-transaction-robot', 'type' => 'mechanical', 'year' => 1944]); * * $secondNewRobot = new Robot(); * $secondNewRobot->setTransaction($myTransaction2); - * $secondNewRobot->assign( - * [ - * 'name' => 'second-transaction-robot', - * 'type' => 'fictional', - * 'year' => 1984, - * ] - * ); - * $secondNewRobot->save(); + * $secondNewRobot->save(['name' => 'second-transaction-robot', 'type' => 'fictional', 'year' => 1984]); * * // this transaction will find the robot. - * $resultInFirstTransaction = Robot::find( - * [ - * 'name' => 'first-transaction-robot', - * Model::TRANSACTION_INDEX => $myTransaction1, - * ] - * ); - * + * $resultInFirstTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); * // this transaction won't find the robot. - * $resultInSecondTransaction = Robot::find( - * [ - * 'name' => 'first-transaction-robot', - * Model::TRANSACTION_INDEX => $myTransaction2, - * ] - * ); - * + * $resultInSecondTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find( - * [ - * 'name' => 'first-transaction-robot', - * ] - * ); + * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'first-transaction-robot']); * * // this transaction won't find the robot. - * $resultInFirstTransaction = Robot::find( - * [ - * 'name' => 'second-transaction-robot', - * Model::TRANSACTION_INDEX => $myTransaction2, - * ] - * ); - * + * $resultInFirstTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); * // this transaction will find the robot. - * $resultInSecondTransaction = Robot::find( - * [ - * 'name' => 'second-transaction-robot', - * Model::TRANSACTION_INDEX => $myTransaction1, - * ] - * ); - * + * $resultInSecondTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find( - * [ - * 'name' => 'second-transaction-robot', - * ] - * ); + * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'second-transaction-robot']); * * $transaction1->rollback(); * $transaction2->rollback(); - * ``` + * * * @param mixed $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public static function find($parameters = null): ResultsetInterface {} + public static function find($parameters = null) {} /** * Query the first record that matches the specified conditions * - * ```php + * * // What's the first robot in robots table? * $robot = Robots::findFirst(); * @@ -620,7 +521,7 @@ public static function find($parameters = null): ResultsetInterface {} * * // What's the first mechanical robot in robots table? * $robot = Robots::findFirst( - * "type = 'mechanical'" + * "type = 'mechanical'" * ); * * echo "The first mechanical robot name is ", $robot->name; @@ -638,414 +539,431 @@ public static function find($parameters = null): ResultsetInterface {} * // behaviour with transaction * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); - * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); - * $newRobot->assign( - * [ - * 'name' => 'test', - * 'type' => 'mechanical', - * 'year' => 1944, - * ] - * ); - * $newRobot->save(); - * - * $findsARobot = Robot::findFirst( - * [ - * 'name' => 'test', - * Model::TRANSACTION_INDEX => $myTransaction, - * ] - * ); + * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); * - * $doesNotFindARobot = Robot::findFirst( - * [ - * 'name' => 'test', - * ] - * ); + * $findsARobot = Robot::findFirst(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); + * $doesNotFindARobot = Robot::findFirst(['name' => 'test']); * * var_dump($findARobot); * var_dump($doesNotFindARobot); * * $transaction->commit(); + * $doesFindTheRobotNow = Robot::findFirst(['name' => 'test']); + * * - * $doesFindTheRobotNow = Robot::findFirst( - * [ - * 'name' => 'test', - * ] - * ); - * ``` - * - * @param string|array $parameters - * @return bool|\Phalcon\Mvc\ModelInterface + * @param mixed $parameters + * @return Model */ public static function findFirst($parameters = null) {} /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified - * - * @param string $eventName - * @return bool - */ - public function fireEvent(string $eventName): bool {} - - /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified - * This method stops if one of the callbacks/listeners returns bool false - * - * @param string $eventName - * @return bool - */ - public function fireEventCancel(string $eventName): bool {} - - /** - * Returns a list of changed values. - * - * ```php - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] - * - * $robots->deleted = 'Y'; - * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * ``` + * shared prepare query logic for find and findFirst method * - * @return array + * @param mixed $params + * @param mixed $limit + * @return \Phalcon\Mvc\Model\Query */ - public function getChangedFields(): array {} + private static function getPreparedQuery($params, $limit = null) {} /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists - * in the database or not + * Create a criteria for a specific model * - * @return int + * @param \Phalcon\DiInterface $dependencyInjector + * @return \Phalcon\Mvc\Model\Criteria */ - public function getDirtyState(): int {} + public static function query(\Phalcon\DiInterface $dependencyInjector = null) {} /** - * Returns the dependency injection container + * Checks whether the current record already exists * - * @return \Phalcon\Di\DiInterface + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\AdapterInterface $connection + * @param string|array $table + * @return bool */ - public function getDI(): DiInterface {} + protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table = null) {} /** - * Returns the custom events manager + * Generate a PHQL SELECT statement for an aggregate * - * @return \Phalcon\Events\ManagerInterface + * @param string $functionName + * @param string $alias + * @param array $parameters + * @param string $function + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getEventsManager(): EventsManagerInterface {} + protected static function _groupResult($functionName, $alias, $parameters) {} /** - * Returns array of validation messages - * - * ```php - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; + * Counts how many records match the specified conditions * - * $messages = $robot->getMessages(); + * + * // How many robots are there? + * $number = Robots::count(); * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * ``` + * echo "There are ", $number, "\n"; * - * @param mixed $filter - * @return array|\Phalcon\Messages\MessageInterface[] - */ - public function getMessages($filter = null): array {} - - /** - * Returns the models manager related to the entity instance + * // How many mechanical robots are there? + * $number = Robots::count("type = 'mechanical'"); * - * @return \Phalcon\Mvc\Model\ManagerInterface - */ - public function getModelsManager(): ManagerInterface {} - - /** - * {@inheritdoc} + * echo "There are ", $number, " mechanical robots\n"; + * * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @param array $parameters + * @return mixed */ - public function getModelsMetaData(): MetaDataInterface {} + public static function count($parameters = null) {} /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Calculates the sum on a column for a result-set of rows that match the specified conditions * - * @return int - */ - public function getOperationMade(): int {} - - /** - * Returns the internal old snapshot data + * + * // How much are all robots? + * $sum = Robots::sum( + * [ + * "column" => "price", + * ] + * ); * - * @return array - */ - public function getOldSnapshotData(): array {} - - /** - * Gets the connection used to read data for the model + * echo "The total price of robots is ", $sum, "\n"; * - * @return \Phalcon\Db\Adapter\AdapterInterface - */ - final public function getReadConnection(): AdapterInterface {} - - /** - * Returns the DependencyInjection connection service name used to read data - * related the model + * // How much are mechanical robots? + * $sum = Robots::sum( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); * - * @return string - */ - final public function getReadConnectionService(): string {} - - /** - * Returns related records based on defined relations + * echo "The total price of mechanical robots is ", $sum, "\n"; + * * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param array $parameters + * @return mixed */ - public function getRelated(string $alias, $arguments = null) {} + public static function sum($parameters = null) {} /** - * Checks if saved related records have already been loaded. - * - * Only returns true if the records were previously fetched - * through the model without any additional parameters. + * Returns the maximum value of a column for a result-set of rows that match the specified conditions * - * ```php - * $robot = Robots::findFirst(); - * var_dump($robot->isRelationshipLoaded('robotsParts')); // false + * + * // What is the maximum robot id? + * $id = Robots::maximum( + * [ + * "column" => "id", + * ] + * ); * - * $robotsParts = $robot->getRobotsParts(['id > 0']); - * var_dump($robot->isRelationshipLoaded('robotsParts')); // false + * echo "The maximum robot id is: ", $id, "\n"; * - * $robotsParts = $robot->getRobotsParts(); // or $robot->robotsParts - * var_dump($robot->isRelationshipLoaded('robotsParts')); // true + * // What is the maximum id of mechanical robots? + * $sum = Robots::maximum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); * - * $robot->robotsParts = [new RobotsParts()]; - * var_dump($robot->isRelationshipLoaded('robotsParts')); // false - * ``` + * echo "The maximum robot id of mechanical robots is ", $id, "\n"; + * * - * @param string $relationshipAlias - * @return bool + * @param array $parameters + * @return mixed */ - public function isRelationshipLoaded(string $relationshipAlias): bool {} + public static function maximum($parameters = null) {} /** - * Returns schema name where the mapped table is located + * Returns the minimum value of a column for a result-set of rows that match the specified conditions * - * @return string + * + * // What is the minimum robot id? + * $id = Robots::minimum( + * [ + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id is: ", $id; + * + * // What is the minimum id of mechanical robots? + * $sum = Robots::minimum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id of mechanical robots is ", $id; + * + * + * @param array $parameters + * @return mixed */ - final public function getSchema(): string {} + public static function minimum($parameters = null) {} /** - * Returns the internal snapshot data + * Returns the average value on a column for a result-set of rows matching the specified conditions * - * @return array + * + * // What's the average price of robots? + * $average = Robots::average( + * [ + * "column" => "price", + * ] + * ); + * + * echo "The average price is ", $average, "\n"; + * + * // What's the average price of mechanical robots? + * $average = Robots::average( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); + * + * echo "The average price of mechanical robots is ", $average, "\n"; + * + * + * @param array $parameters + * @return double */ - public function getSnapshotData(): array {} + public static function average($parameters = null) {} /** - * Returns the table name mapped in the model + * Fires an event, implicitly calls behaviors and listeners in the events manager are notified * - * @return string + * @param string $eventName + * @return bool */ - final public function getSource(): string {} + public function fireEvent($eventName) {} /** - * Returns a list of updated values. + * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * This method stops if one of the callbacks/listeners returns boolean false * - * ```php - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] + * @param string $eventName + * @return bool + */ + public function fireEventCancel($eventName) {} + + /** + * Cancel the current operation + */ + protected function _cancelOperation() {} + + /** + * Appends a customized message on the validation process * - * $robots->deleted = 'Y'; + * + * use Phalcon\Mvc\Model; + * use Phalcon\Mvc\Model\Message as Message; * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * $robots->save(); - * print_r($robots->getChangedFields()); // [] - * print_r($robots->getUpdatedFields()); // ["deleted"] - * ``` + * class Robots extends Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); * - * @return array + * $this->appendMessage($message); + * } + * } + * } + * + * + * @param \Phalcon\Mvc\Model\MessageInterface $message + * @return Model */ - public function getUpdatedFields(): array {} + public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} /** - * Gets the connection used to write data to the model + * Executes validators on every validation call + * + * + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; + * + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->add( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param \Phalcon\ValidationInterface $validator + * @return bool */ - final public function getWriteConnection(): AdapterInterface {} + protected function validate(\Phalcon\ValidationInterface $validator) {} /** - * Returns the DependencyInjection connection service name used to write - * data related to the model + * Check whether validation process has generated any messages * - * @return string + * + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; + * + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->validate( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * + * + * @return bool */ - final public function getWriteConnectionService(): string {} + public function validationHasFailed() {} /** - * Check if a specific attribute has changed - * This only works if the model is keeping data snapshots + * Returns array of validation messages * - * ```php + * * $robot = new Robots(); * * $robot->type = "mechanical"; * $robot->name = "Astro Boy"; * $robot->year = 1952; * - * $robot->create(); + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; * - * $robot->type = "hydraulic"; + * $messages = $robot->getMessages(); * - * $hasChanged = $robot->hasChanged("type"); // returns true - * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true - * $hasChanged = $robot->hasChanged(["type", "name"], true); // returns false - * ``` + * foreach ($messages as $message) { + * echo $message; + * } + * } else { + * echo "Great, a new robot was saved successfully!"; + * } + * * - * @param string|array $fieldName - * @param boolean $allFields - * @return bool + * @param mixed $filter + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function hasChanged($fieldName = null, bool $allFields = false): bool {} + public function getMessages($filter = null) {} /** - * Checks if the object has internal snapshot data + * Reads "belongs to" relations and check the virtual foreign keys when inserting or updating records + * to verify that inserted/updated values are present in the related entity * * @return bool */ - public function hasSnapshotData(): bool {} + protected final function _checkForeignKeysRestrict() {} /** - * Check if a specific attribute was updated - * This only works if the model is keeping data snapshots + * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (cascade) when deleting records * - * @param string|array $fieldName - * @param bool $allFields * @return bool */ - public function hasUpdated($fieldName = null, bool $allFields = false): bool {} + protected final function _checkForeignKeysReverseCascade() {} /** - * Serializes the object for json_encode - * - * ```php - * echo json_encode($robot); - * ``` + * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (restrict) when deleting records * - * @return array + * @return bool */ - public function jsonSerialize(): array {} + protected final function _checkForeignKeysReverseRestrict() {} /** - * Returns the maximum value of a column for a result-set of rows that match - * the specified conditions - * - * ```php - * // What is the maximum robot id? - * $id = Robots::maximum( - * [ - * "column" => "id", - * ] - * ); - * - * echo "The maximum robot id is: ", $id, "\n"; - * - * // What is the maximum id of mechanical robots? - * $sum = Robots::maximum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); - * - * echo "The maximum robot id of mechanical robots is ", $id, "\n"; - * ``` + * Executes internal hooks before save a record * - * @param array $parameters - * @return mixed + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param bool $exists + * @param mixed $identityField + * @return bool */ - public static function maximum($parameters = null) {} + protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, $exists, $identityField) {} /** - * Returns the minimum value of a column for a result-set of rows that match - * the specified conditions - * - * ```php - * // What is the minimum robot id? - * $id = Robots::minimum( - * [ - * "column" => "id", - * ] - * ); - * - * echo "The minimum robot id is: ", $id; - * - * // What is the minimum id of mechanical robots? - * $sum = Robots::minimum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); - * - * echo "The minimum robot id of mechanical robots is ", $id; - * ``` + * Executes internal events after save a record * - * @param array $parameters - * @return mixed + * @param bool $success + * @param bool $exists + * @return bool */ - public static function minimum($parameters = null) {} + protected function _postSave($success, $exists) {} /** - * Create a criteria for a specific model + * Sends a pre-build INSERT SQL statement to the relational database system * - * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\AdapterInterface $connection + * @param string|array $table + * @param boolean|string $identityField + * @return bool */ - public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface {} + protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table, $identityField) {} /** - * Reads an attribute value by its name + * Sends a pre-build UPDATE SQL statement to the relational database system * - * ```php - * echo $robot->readAttribute("name"); - * ``` + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\AdapterInterface $connection + * @param string|array $table + * @return bool + */ + protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table) {} + + /** + * Saves related records that must be stored prior to save the master record * - * @param string $attribute - * @return mixed|null + * @param \Phalcon\Db\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool */ - public function readAttribute(string $attribute): ? {} + protected function _preSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} /** - * Refreshes the model attributes re-querying the record from the database + * Save the related records assigned in the has-one/has-many relations * - * @return \Phalcon\Mvc\ModelInterface + * @param \Phalcon\Db\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool */ - public function refresh(): ModelInterface {} + protected function _postSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} /** - * Inserts or updates a model instance. Returning true on success or false - * otherwise. + * Inserts or updates a model instance. Returning true on success or false otherwise. * - * ```php + * * // Creating a new robot * $robot = new Robots(); * @@ -1061,697 +979,648 @@ public function refresh(): ModelInterface {} * $robot->name = "Biomass"; * * $robot->save(); - * ``` + * * + * @param array $data + * @param array $whiteList * @return bool */ - public function save(): bool {} + public function save($data = null, $whiteList = null) {} /** - * Serializes the object ignoring connections, services, related objects or - * static properties + * Inserts a model instance. If the instance already exists in the persistence it will throw an exception + * Returning true on success or false otherwise. * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes the object from a serialized string + * + * // Creating a new robot + * $robot = new Robots(); + * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; + * + * $robot->create(); + * + * // Passing an array to create + * $robot = new Robots(); + * + * $robot->create( + * [ + * "type" => "mechanical", + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); + * * * @param mixed $data + * @param mixed $whiteList + * @return bool */ - public function unserialize($data) {} + public function create($data = null, $whiteList = null) {} /** - * Sets the DependencyInjection connection service name + * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception + * Returning true on success or false otherwise. * - * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface + * + * // Updating a robot name + * $robot = Robots::findFirst("id = 100"); + * + * $robot->name = "Biomass"; + * + * $robot->update(); + * + * + * @param mixed $data + * @param mixed $whiteList + * @return bool */ - final public function setConnectionService(string $connectionService): ModelInterface {} + public function update($data = null, $whiteList = null) {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Deletes a model instance. Returning true on success or false otherwise. * - * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * + * $robot = Robots::findFirst("id=100"); + * + * $robot->delete(); + * + * $robots = Robots::find("type = 'mechanical'"); + * + * foreach ($robots as $robot) { + * $robot->delete(); + * } + * + * + * @return bool */ - public function setDirtyState(int $dirtyState) {} + public function delete() {} /** - * Sets the dependency injection container + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * @param \Phalcon\Di\DiInterface $container + * @return int */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getOperationMade() {} /** - * Sets a custom events manager + * Refreshes the model attributes re-querying the record from the database * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return Model */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function refresh() {} /** - * Sets the DependencyInjection connection service name used to read data + * Skips the current operation forcing a success state * - * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface + * @param bool $skip */ - final public function setReadConnectionService(string $connectionService): ModelInterface {} + public function skipOperation($skip) {} /** - * Sets the record's old snapshot data. - * This method is used internally to set old snapshot data when the model - * was set up to keep snapshot data + * Reads an attribute value by its name * - * @param array $data - * @param array $columnMap + * + * echo $robot->readAttribute("name"); + * + * + * @param string $attribute */ - public function setOldSnapshotData(array $data, $columnMap = null) {} + public function readAttribute($attribute) {} /** - * Sets the record's snapshot data. - * This method is used internally to set snapshot data when the model was - * set up to keep snapshot data + * Writes an attribute value by its name * - * @param array $data - * @param array $columnMap + * + * $robot->writeAttribute("name", "Rosey"); + * + * + * @param string $attribute + * @param mixed $value */ - public function setSnapshotData(array $data, $columnMap = null) {} + public function writeAttribute($attribute, $value) {} /** - * Sets a transaction related to the Model instance - * - * ```php - * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; - * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; - * - * try { - * $txManager = new TxManager(); - * - * $transaction = $txManager->get(); - * - * $robot = new Robots(); - * - * $robot->setTransaction($transaction); + * Sets a list of attributes that must be skipped from the + * generated INSERT/UPDATE statement * - * $robot->name = "WALL·E"; - * $robot->created_at = date("Y-m-d"); + * * - * if ($robot->save() === false) { - * $transaction->rollback("Can't save robot"); + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributes( + * [ + * "price", + * ] + * ); * } + * } + * * - * $robotPart = new RobotParts(); - * - * $robotPart->setTransaction($transaction); + * @param array $attributes + */ + protected function skipAttributes(array $attributes) {} + + /** + * Sets a list of attributes that must be skipped from the + * generated INSERT statement * - * $robotPart->type = "head"; + * * - * if ($robotPart->save() === false) { - * $transaction->rollback("Robot part cannot be saved"); + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnCreate( + * [ + * "created_at", + * ] + * ); * } - * - * $transaction->commit(); - * } catch (TxFailed $e) { - * echo "Failed, reason: ", $e->getMessage(); * } - * ``` + * * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\ModelInterface + * @param array $attributes */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface {} + protected function skipAttributesOnCreate(array $attributes) {} /** - * Enables/disables options in the ORM + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * @param array $options - */ - public static function setup(array $options) {} - - /** - * Sets the DependencyInjection connection service name used to write data + * * - * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface - */ - final public function setWriteConnectionService(string $connectionService): ModelInterface {} - - /** - * Skips the current operation forcing a success state + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnUpdate( + * [ + * "modified_in", + * ] + * ); + * } + * } + * * - * @param bool $skip + * @param array $attributes */ - public function skipOperation(bool $skip) {} + protected function skipAttributesOnUpdate(array $attributes) {} /** - * Calculates the sum on a column for a result-set of rows that match the - * specified conditions - * - * ```php - * // How much are all robots? - * $sum = Robots::sum( - * [ - * "column" => "price", - * ] - * ); - * - * echo "The total price of robots is ", $sum, "\n"; + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * // How much are mechanical robots? - * $sum = Robots::sum( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); + * * - * echo "The total price of mechanical robots is ", $sum, "\n"; - * ``` + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->allowEmptyStringValues( + * [ + * "name", + * ] + * ); + * } + * } + * * - * @param array $parameters - * @return double + * @param array $attributes */ - public static function sum($parameters = null): float {} + protected function allowEmptyStringValues(array $attributes) {} /** - * Returns the instance as an array representation + * Setup a 1-1 relation between two models * - * ```php - * print_r( - * $robot->toArray() - * ); - * ``` + * * - * @param array $columns - * @return array + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasOne("id", "RobotsDescription", "robots_id"); + * } + * } + * + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function toArray($columns = null): array {} + protected function hasOne($fields, $referenceModel, $referencedFields, $options = null) {} /** - * Updates a model instance. If the instance doesn't exist in the - * persistence it will throw an exception. Returning true on success or - * false otherwise. - * - * ```php - * // Updating a robot name - * $robot = Robots::findFirst("id = 100"); + * Setup a reverse 1-1 or n-1 relation between two models * - * $robot->name = "Biomass"; + * * - * $robot->update(); - * ``` + * class RobotsParts extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->belongsTo("robots_id", "Robots", "id"); + * } + * } + * * - * @return bool + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function update(): bool {} + protected function belongsTo($fields, $referenceModel, $referencedFields, $options = null) {} /** - * Writes an attribute value by its name + * Setup a 1-n relation between two models * - * ```php - * $robot->writeAttribute("name", "Rosey"); - * ``` + * * - * @param string $attribute - * @param mixed $value + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasMany("id", "RobotsParts", "robots_id"); + * } + * } + * + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function writeAttribute(string $attribute, $value) {} + protected function hasMany($fields, $referenceModel, $referencedFields, $options = null) {} /** - * Reads "belongs to" relations and check the virtual foreign keys when - * inserting or updating records to verify that inserted/updated values are - * present in the related entity + * Setup an n-n relation between two models, through an intermediate relation * - * @return bool - */ - final protected function _checkForeignKeysRestrict(): bool {} - - /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual - * foreign keys (cascade) when deleting records + * * - * @return bool - */ - final protected function _checkForeignKeysReverseCascade(): bool {} - - /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual - * foreign keys (restrict) when deleting records + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * // Setup a many-to-many relation to Parts through RobotsParts + * $this->hasManyToMany( + * "id", + * "RobotsParts", + * "robots_id", + * "parts_id", + * "Parts", + * "id", + * ); + * } + * } + * * - * @return bool + * @param string|array fields + * @param string intermediateModel + * @param string|array intermediateFields + * @param string|array intermediateReferencedFields + * @param string referencedModel + * @param mixed $fields + * @param string $intermediateModel + * @param mixed $intermediateFields + * @param mixed $intermediateReferencedFields + * @param string $referenceModel + * @param string|array $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\Relation */ - final protected function _checkForeignKeysReverseRestrict(): bool {} + protected function hasManyToMany($fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referenceModel, $referencedFields, $options = null) {} /** - * Sends a pre-build INSERT SQL statement to the relational database system + * Setups a behavior in a model * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param string|array $table - * @param bool|string $identityField - * @return bool + * + * + * use Phalcon\Mvc\Model; + * use Phalcon\Mvc\Model\Behavior\Timestampable; + * + * class Robots extends Model + * { + * public function initialize() + * { + * $this->addBehavior( + * new Timestampable( + * [ + * "onCreate" => [ + * "field" => "created_at", + * "format" => "Y-m-d", + * ], + * ] + * ) + * ); + * } + * } + * + * + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool {} + public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} /** - * Sends a pre-build UPDATE SQL statement to the relational database system + * Sets if the model must keep the original record snapshot in memory * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param string|array $table - * @return bool + * + * + * use Phalcon\Mvc\Model; + * + * class Robots extends Model + * { + * public function initialize() + * { + * $this->keepSnapshots(true); + * } + * } + * + * + * @param bool $keepSnapshot */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool {} + protected function keepSnapshots($keepSnapshot) {} /** - * Checks whether the current record already exists + * Sets the record's snapshot data. + * This method is used internally to set snapshot data when the model was set up to keep snapshot data * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @return bool + * @param array $data + * @param array $columnMap */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool {} + public function setSnapshotData(array $data, $columnMap = null) {} /** - * Returns related records defined relations depending on the method name + * Sets the record's old snapshot data. + * This method is used internally to set old snapshot data when the model was set up to keep snapshot data * - * @param string $modelName - * @param string $method - * @param array $arguments - * @return mixed + * @param array $data + * @param array $columnMap */ - protected function _getRelatedRecords(string $modelName, string $method, $arguments) {} + public function setOldSnapshotData(array $data, $columnMap = null) {} /** - * Generate a PHQL SELECT statement for an aggregate + * Checks if the object has internal snapshot data * - * @param string $functionName - * @param string $alias - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return bool */ - protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface {} + public function hasSnapshotData() {} /** - * Try to check if the query must invoke a finder + * Returns the internal snapshot data * - * @param string $method - * @param array $arguments - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool + * @return array */ - protected final static function _invokeFinder(string $method, array $arguments) {} + public function getSnapshotData() {} /** - * Check for, and attempt to use, possible setter. + * Returns the internal old snapshot data * - * @param string $property - * @param mixed $value - * @return bool + * @return array */ - final protected function _possibleSetter(string $property, $value): bool {} + public function getOldSnapshotData() {} /** - * Executes internal hooks before save a record + * Check if a specific attribute has changed + * This only works if the model is keeping data snapshots * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param bool $exists - * @param mixed $identityField + * + * $robot = new Robots(); + * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; + * + * $robot->create(); + * $robot->type = "hydraulic"; + * $hasChanged = $robot->hasChanged("type"); // returns true + * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true + * $hasChanged = $robot->hasChanged(["type", "name", true]); // returns false + * + * + * @param string|array $fieldName + * @param boolean $allFields * @return bool */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool {} + public function hasChanged($fieldName = null, $allFields = false) {} /** - * Saves related records that must be stored prior to save the master record + * Check if a specific attribute was updated + * This only works if the model is keeping data snapshots * - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related + * @param string|array $fieldName + * @param bool $allFields * @return bool */ - protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + public function hasUpdated($fieldName = null, $allFields = false) {} /** - * Executes internal events after save a record + * Returns a list of changed values. * - * @param bool $success - * @param bool $exists - * @return bool + * + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] + * + * $robots->deleted = 'Y'; + * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * + * + * @return array */ - protected function _postSave(bool $success, bool $exists): bool {} + public function getChangedFields() {} /** - * Save the related records assigned in the has-one/has-many relations + * Returns a list of updated values. * - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related - * @return bool + * + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] + * + * $robots->deleted = 'Y'; + * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * $robots->save(); + * print_r($robots->getChangedFields()); // [] + * print_r($robots->getUpdatedFields()); // ["deleted"] + * */ - protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + public function getUpdatedFields() {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Sets if a model must use dynamic update instead of the all-field update * - * ```php - * class Robots extends \Phalcon\Mvc\Model + * + * + * use Phalcon\Mvc\Model; + * + * class Robots extends Model * { * public function initialize() * { - * $this->allowEmptyStringValues( - * [ - * "name", - * ] - * ); + * $this->useDynamicUpdate(true); * } * } - * ``` + * * - * @param array $attributes + * @param bool $dynamicUpdate */ - protected function allowEmptyStringValues(array $attributes) {} + protected function useDynamicUpdate($dynamicUpdate) {} /** - * Cancel the current operation + * Returns related records based on defined relations + * + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - protected function _cancelOperation() {} + public function getRelated($alias, $arguments = null) {} /** - * Setup a reverse 1-1 or n-1 relation between two models - * - * ```php - * class RobotsParts extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->belongsTo( - * "robots_id", - * Robots::class, - * "id" - * ); - * } - * } - * ``` + * Returns related records defined relations depending on the method name * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param string $modelName + * @param string $method + * @param array $arguments + * @return mixed */ - protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + protected function _getRelatedRecords($modelName, $method, $arguments) {} /** - * shared prepare query logic for find and findFirst method + * Try to check if the query must invoke a finder * - * @param mixed $params - * @param mixed $limit - * @return \Phalcon\Mvc\Model\Query + * @param string $method + * @param array $arguments + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|boolean */ - private static function getPreparedQuery($params, $limit = null): Query {} + protected final static function _invokeFinder($method, $arguments) {} /** - * Setup a 1-n relation between two models - * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasMany( - * "id", - * RobotsParts::class, - * "robots_id" - * ); - * } - * } - * ``` + * Handles method calls when a method is not implemented * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param string method + * @param array arguments + * @return mixed + * @param string $method + * @param mixed $arguments */ - protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + public function __call($method, $arguments) {} /** - * Setup an n-n relation between two models, through an intermediate - * relation - * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * // Setup a many-to-many relation to Parts through RobotsParts - * $this->hasManyToMany( - * "id", - * RobotsParts::class, - * "robots_id", - * "parts_id", - * Parts::class, - * "id", - * ); - * } - * } - * ``` + * Handles method calls when a static method is not implemented * - * @param string|array $fields - * @param string $intermediateModel - * @param string|array $intermediateFields - * @param string|array $intermediateReferencedFields - * @param string $referenceModel - * @param string|array $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\Relation + * @param string method + * @param array arguments + * @return mixed + * @param string $method + * @param mixed $arguments */ - protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation {} + public static function __callStatic($method, $arguments) {} /** - * Setup a 1-1 relation between two models - * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasOne( - * "id", - * RobotsDescription::class, - * "robots_id" - * ); - * } - * } - * ``` + * Magic method to assign values to the the model * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param string $property + * @param mixed $value */ - protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + public function __set($property, $value) {} /** - * Sets if the model must keep the original record snapshot in memory - * - * ```php - * use Phalcon\Mvc\Model; - * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->keepSnapshots(true); - * } - * } - * ``` + * Check for, and attempt to use, possible setter. * - * @param bool $keepSnapshot + * @param string $property + * @param mixed $value + * @return string */ - protected function keepSnapshots(bool $keepSnapshot) {} + protected final function _possibleSetter($property, $value) {} /** - * Sets schema name where the mapped table is located + * Magic method to get related records using the relation alias as a property * - * @param string $schema - * @return \Phalcon\Mvc\ModelInterface + * @param string $property + * @return \Phalcon\Mvc\Model\Resultset|Phalcon\Mvc\Model */ - final protected function setSchema(string $schema): ModelInterface {} + public function __get($property) {} /** - * Sets the table name to which model should be mapped + * Magic method to check if a property is a valid relation * - * @param string $source - * @return \Phalcon\Mvc\ModelInterface + * @param string $property + * @return bool */ - final protected function setSource(string $source): ModelInterface {} + public function __isset($property) {} /** - * Sets a list of attributes that must be skipped from the - * generated INSERT/UPDATE statement + * Serializes the object ignoring connections, services, related objects or static properties * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributes( - * [ - * "price", - * ] - * ); - * } - * } - * ``` - * - * @param array $attributes + * @return string */ - protected function skipAttributes(array $attributes) {} + public function serialize() {} /** - * Sets a list of attributes that must be skipped from the - * generated INSERT statement - * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnCreate( - * [ - * "created_at", - * ] - * ); - * } - * } - * ``` + * Unserializes the object from a serialized string * - * @param array $attributes + * @param mixed $data */ - protected function skipAttributesOnCreate(array $attributes) {} + public function unserialize($data) {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Returns a simple representation of the object that can be used with var_dump * - * ```php - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnUpdate( - * [ - * "modified_in", - * ] - * ); - * } - * } - * ``` + * + * var_dump( + * $robot->dump() + * ); + * * - * @param array $attributes + * @return array */ - protected function skipAttributesOnUpdate(array $attributes) {} + public function dump() {} /** - * Sets if a model must use dynamic update instead of the all-field update - * - * ```php - * use Phalcon\Mvc\Model; + * Returns the instance as an array representation * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->useDynamicUpdate(true); - * } - * } - * ``` + * + * print_r( + * $robot->toArray() + * ); + * * - * @param bool $dynamicUpdate + * @param array $columns + * @return array */ - protected function useDynamicUpdate(bool $dynamicUpdate) {} + public function toArray($columns = null) {} /** - * Executes validators on every validation call - * - * ```php - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); + * Serializes the object for json_encode * - * return $this->validate($validator); - * } - * } - * ``` + * + * echo json_encode($robot); + * * - * @param \Phalcon\Validation\ValidationInterface $validator - * @return bool + * @return array */ - protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} + public function jsonSerialize() {} /** - * Check whether validation process has generated any messages - * - * ```php - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->validate( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * ``` + * Enables/disables options in the ORM * - * @return bool + * @param array $options */ - public function validationHasFailed(): bool {} + public static function setup(array $options) {} /** - * Attempts to find key case-insensitively - * - * @param mixed $columnMap - * @param mixed $key - * @return string + * Reset a model instance data */ - private static function caseInsensitiveColumnMap($columnMap, $key): string {} + public function reset() {} } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index b65f6f6d..5ded0692 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -11,321 +11,313 @@ interface ModelInterface { /** - * Appends a customized message on the validation process + * Sets a transaction related to the Model instance * - * @param \Phalcon\Messages\MessageInterface $message + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction * @return \Phalcon\Mvc\ModelInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface; + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** - * Assigns values to a model from an array + * Returns table name mapped in the model * - * @param array $data - * @param mixed $dataColumnMap - * @param mixed $whiteList - * @param array $columnMap - * @return \Phalcon\Mvc\ModelInterface + * @return string */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface; + public function getSource(); /** - * Allows to calculate the average value on a column matching the specified - * conditions + * Returns schema name where table mapped is located * - * @param array $parameters - * @return double + * @return string */ - public static function average($parameters = null): float; + public function getSchema(); /** - * Assigns values to a model from an array returning a new model + * Sets both read/write connection services * - * @param \Phalcon\Mvc\ModelInterface $base - * @param array $data - * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @param string $connectionService */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface; + public function setConnectionService($connectionService); /** - * Assigns values to a model from an array returning a new model + * Sets the DependencyInjection connection service used to write data * - * @param \Phalcon\Mvc\Model $base - * @param array $data - * @param array $columnMap - * @param int $dirtyState - * @param bool $keepSnapshots - * @return \Phalcon\Mvc\ModelInterface + * @param string $connectionService */ - public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; + public function setWriteConnectionService($connectionService); /** - * Returns an hydrated result based on the data and the column map + * Sets the DependencyInjection connection service used to read data * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode + * @param string $connectionService */ - public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode); + public function setReadConnectionService($connectionService); /** - * Allows to count how many records match the specified conditions + * Returns DependencyInjection connection service used to read data * - * @param array $parameters - * @return int + * @return string */ - public static function count($parameters = null): int; + public function getReadConnectionService(); /** - * Inserts a model instance. If the instance already exists in the - * persistence it will throw an exception. Returning true on success or - * false otherwise. + * Returns DependencyInjection connection service used to write data * - * @return bool + * @return string */ - public function create(): bool; + public function getWriteConnectionService(); /** - * Deletes a model instance. Returning true on success or false otherwise. + * Gets internal database connection * - * @return bool + * @return \Phalcon\Db\AdapterInterface */ - public function delete(): bool; + public function getReadConnection(); /** - * Allows to query a set of records that match the specified conditions + * Gets internal database connection * - * @param mixed $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return \Phalcon\Db\AdapterInterface */ - public static function find($parameters = null): ResultsetInterface; + public function getWriteConnection(); /** - * Allows to query the first record that match the specified conditions + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * - * @param array $parameters - * @return bool|\Phalcon\Mvc\ModelInterface + * @param int $dirtyState + * @return \Phalcon\Mvc\ModelInterface */ - public static function findFirst($parameters = null); + public function setDirtyState($dirtyState); /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified + * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not * - * @param string $eventName - * @return bool + * @return int */ - public function fireEvent(string $eventName): bool; + public function getDirtyState(); /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified. This method stops if one of the callbacks/listeners - * returns bool false + * Assigns values to a model from an array * - * @param string $eventName - * @return bool + * @param array $data + * @param mixed $dataColumnMap + * @param mixed $whiteList + * @param \Phalcon\Mvc\Model $object + * @param array $columnMap + * @return \Phalcon\Mvc\Model */ - public function fireEventCancel(string $eventName): bool; + public function assign(array $data, $dataColumnMap = null, $whiteList = null); /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists - * in the database or not + * Assigns values to a model from an array returning a new model * - * @return int + * @param \Phalcon\Mvc\Model $base + * @param array $data + * @param array $columnMap + * @param int $dirtyState + * @param boolean $keepSnapshots + * @return \Phalcon\Mvc\Model */ - public function getDirtyState(): int; + public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null); /** - * Returns array of validation messages + * Assigns values to a model from an array returning a new model * - * @return array|\Phalcon\Messages\MessageInterface[] + * @param \Phalcon\Mvc\ModelInterface $base + * @param array $data + * @param int $dirtyState + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages(): array; + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, $dirtyState = 0); /** - * Returns the models meta-data service related to the entity instance. + * Returns an hydrated result based on the data and the column map * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @param array $data + * @param array $columnMap + * @param int $hydrationMode */ - public function getModelsMetaData(): MetaDataInterface; + public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode); /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Allows to query a set of records that match the specified conditions * - * @return int + * @param mixed $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getOperationMade(): int; + public static function find($parameters = null); /** - * Gets internal database connection + * Allows to query the first record that match the specified conditions * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param array $parameters + * @return static */ - public function getReadConnection(): AdapterInterface; + public static function findFirst($parameters = null); /** - * Returns DependencyInjection connection service used to read data + * Create a criteria for a specific model * - * @return string + * @param \Phalcon\DiInterface $dependencyInjector + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function getReadConnectionService(): string; + public static function query(\Phalcon\DiInterface $dependencyInjector = null); /** - * Returns related records based on defined relations + * Allows to count how many records match the specified conditions * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param array $parameters + * @return int */ - public function getRelated(string $alias, $arguments = null); + public static function count($parameters = null); /** - * Returns schema name where table mapped is located + * Allows to calculate a sum on a column that match the specified conditions * - * @return string + * @param array $parameters + * @return double */ - public function getSchema(): string; + public static function sum($parameters = null); /** - * Returns table name mapped in the model + * Allows to get the maximum value of a column that match the specified conditions * - * @return string + * @param array $parameters + * @return mixed */ - public function getSource(): string; + public static function maximum($parameters = null); /** - * Gets internal database connection + * Allows to get the minimum value of a column that match the specified conditions * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param array $parameters + * @return mixed */ - public function getWriteConnection(): AdapterInterface; + public static function minimum($parameters = null); /** - * Returns DependencyInjection connection service used to write data + * Allows to calculate the average value on a column matching the specified conditions * - * @return string + * @param array $parameters + * @return double */ - public function getWriteConnectionService(): string; + public static function average($parameters = null); /** - * Allows to get the maximum value of a column that match the specified - * conditions + * Fires an event, implicitly calls behaviors and listeners in the events manager are notified * - * @param array $parameters - * @return mixed + * @param string $eventName + * @return boolean */ - public static function maximum($parameters = null); + public function fireEvent($eventName); /** - * Allows to get the minimum value of a column that match the specified - * conditions + * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * This method stops if one of the callbacks/listeners returns boolean false * - * @param array $parameters - * @return mixed + * @param string $eventName + * @return boolean */ - public static function minimum($parameters = null); + public function fireEventCancel($eventName); /** - * Create a criteria for a specific model + * Appends a customized message on the validation process * - * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @param \Phalcon\Mvc\Model\MessageInterface $message */ - public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface; + public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); /** - * Refreshes the model attributes re-querying the record from the database + * Check whether validation process has generated any messages * - * @return \Phalcon\Mvc\ModelInterface + * @return boolean */ - public function refresh(): ModelInterface; + public function validationHasFailed(); /** - * Inserts or updates a model instance. Returning true on success or false - * otherwise. + * Returns array of validation messages * - * @return bool + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function save(): bool; + public function getMessages(); /** - * Sets both read/write connection services + * Inserts or updates a model instance. Returning true on success or false otherwise. * - * @param string $connectionService + * @param array $data + * @param array $whiteList + * @return boolean */ - public function setConnectionService(string $connectionService); + public function save($data = null, $whiteList = null); /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ - * constants + * Inserts a model instance. If the instance already exists in the persistence it will throw an exception + * Returning true on success or false otherwise. * - * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @param array $data + * @param array $whiteList + * @return boolean */ - public function setDirtyState(int $dirtyState); + public function create($data = null, $whiteList = null); /** - * Sets the DependencyInjection connection service used to read data + * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception + * Returning true on success or false otherwise. * - * @param string $connectionService + * @param array $data + * @param array $whiteList + * @return boolean */ - public function setReadConnectionService(string $connectionService); + public function update($data = null, $whiteList = null); /** - * Sets the record's snapshot data. This method is used internally to set - * snapshot data when the model was set up to keep snapshot data + * Deletes a model instance. Returning true on success or false otherwise. * - * @param array $data - * @param array $columnMap + * @return boolean */ - public function setSnapshotData(array $data, $columnMap = null); + public function delete(); /** - * Sets a transaction related to the Model instance + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\ModelInterface + * @return int */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface; + public function getOperationMade(); /** - * Sets the DependencyInjection connection service used to write data - * - * @param string $connectionService + * Refreshes the model attributes re-querying the record from the database */ - public function setWriteConnectionService(string $connectionService); + public function refresh(); /** * Skips the current operation forcing a success state * * @param bool $skip */ - public function skipOperation(bool $skip); + public function skipOperation($skip); /** - * Allows to calculate a sum on a column that match the specified conditions + * Returns related records based on defined relations * - * @param array $parameters - * @return double + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public static function sum($parameters = null): float; + public function getRelated($alias, $arguments = null); /** - * Check whether validation process has generated any messages + * Sets the record's snapshot data. + * This method is used internally to set snapshot data when the model was set up to keep snapshot data * - * @return bool + * @param array $data + * @param array $columnMap */ - public function validationHasFailed(): bool; + public function setSnapshotData(array $data, $columnMap = null); /** - * Updates a model instance. If the instance doesn't exist in the - * persistence it will throw an exception. Returning true on success or - * false otherwise. - * - * @return bool + * Reset a model instance data */ - public function update(): bool; + public function reset(); } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index fe59a300..a1336e4e 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -13,15 +13,15 @@ interface ModuleDefinitionInterface /** * Registers an autoloader related to the module * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); + public function registerAutoloaders(\Phalcon\DiInterface $dependencyInjector = null); /** * Registers services related to the module * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function registerServices(\Phalcon\Di\DiInterface $container); + public function registerServices(\Phalcon\DiInterface $dependencyInjector); } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index 852feabd..69a4e1af 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -6,11 +6,11 @@ * Phalcon\Mvc\Router * * Phalcon\Mvc\Router is the standard framework router. Routing is the - * process of taking a URI endpoint (that part of the URI which comes after the - * base URL) and decomposing it into parameters to determine which module, - * controller, and action of that controller should receive the request + * process of taking a URI endpoint (that part of the URI which comes after the base URL) and + * decomposing it into parameters to determine which module, controller, and + * action of that controller should receive the request * - * ```php + * * use Phalcon\Mvc\Router; * * $router = new Router(); @@ -23,83 +23,87 @@ * ] * ); * - * $router->handle( - * "/documentation/1/examples.html" - * ); + * $router->handle(); * * echo $router->getControllerName(); - * ``` + * */ class Router implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { + const URI_SOURCE_GET_URL = 0; + + + const URI_SOURCE_SERVER_REQUEST_URI = 1; + + const POSITION_FIRST = 0; const POSITION_LAST = 1; - protected $action = null; + protected $_dependencyInjector; - protected $container; + protected $_eventsManager; - protected $controller = null; + protected $_uriSource; - protected $defaultAction; + protected $_namespace = null; - protected $defaultController; + protected $_module = null; - protected $defaultModule; + protected $_controller = null; - protected $defaultNamespace; + protected $_action = null; - protected $defaultParams = array(); + protected $_params = array(); - protected $eventsManager; + protected $_routes; - protected $keyRouteNames = array(); + protected $_matchedRoute; - protected $keyRouteIds = array(); + protected $_matches; - protected $matchedRoute; + protected $_wasMatched = false; - protected $matches; + protected $_defaultNamespace; - protected $module = null; + protected $_defaultModule; - protected $namespaceName = null; + protected $_defaultController; - protected $notFoundPaths; + protected $_defaultAction; - protected $params = array(); + protected $_defaultParams = array(); - protected $removeExtraSlashes; + protected $_removeExtraSlashes; - protected $routes; + protected $_notFoundPaths; - protected $uriSource; + protected $_keyRouteNames = array(); - protected $wasMatched = false; + protected $_keyRouteIds = array(); @@ -123,143 +127,141 @@ public function setKeyRouteIds($keyRouteIds) {} * * @param bool $defaultRoutes */ - public function __construct(bool $defaultRoutes = true) {} + public function __construct($defaultRoutes = true) {} /** - * Adds a route to the router without any HTTP constraint - * - * ```php - * use Phalcon\Mvc\Router; + * Sets the dependency injector * - * $router->add("/about", "About::index"); + * @param \Phalcon\DiInterface $dependencyInjector + */ + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + + /** + * Returns the internal dependency injector * - * $router->add( - * "/about", - * "About::index", - * ["GET", "POST"] - * ); + * @return \Phalcon\DiInterface + */ + public function getDI() {} + + /** + * Sets the events manager * - * $router->add( - * "/about", - * "About::index", - * ["GET", "POST"], - * Router::POSITION_FIRST - * ); - * ``` + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + + /** + * Returns the internal event manager * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Events\ManagerInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface {} + public function getEventsManager() {} /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Get rewrite info. This info is read from $_GET["_url"]. This returns '/' if the rewrite information cannot be read * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function getRewriteUri() {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Sets the URI source. One of the URI_SOURCE_ constants * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * + * $router->setUriSource( + * Router::URI_SOURCE_SERVER_REQUEST_URI + * ); + * + * + * @param mixed $uriSource + * @return RouterInterface */ - public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setUriSource($uriSource) {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Set whether router must remove the extra slashes in the handled routes * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param bool $remove + * @return RouterInterface */ - public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function removeExtraSlashes($remove) {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Sets the name of the default namespace * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $namespaceName + * @return RouterInterface */ - public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setDefaultNamespace($namespaceName) {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Sets the name of the default module * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName + * @return RouterInterface */ - public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setDefaultModule($moduleName) {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Sets the default controller name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $controllerName + * @return RouterInterface */ - public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setDefaultController($controllerName) {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Sets the default action name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $actionName + * @return RouterInterface */ - public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setDefaultAction($actionName) {} /** - * Adds a route to the router that only match if the HTTP method is PURGE - * (Squid and Varnish support) + * Sets an array of default paths. If a route is missing a path the router will use the defined here + * This method must not be used to set a 404 route * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * + * + * @param array $defaults + * @return RouterInterface */ - public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function setDefaults(array $defaults) {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Returns an array of default parameters * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array */ - public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function getDefaults() {} /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Handles routing information received from the rewrite engine * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * + * // Read the info from the rewrite engine + * $router->handle(); + * + * // Manually passing an URL + * $router->handle("/posts/edit/1"); + * + * + * @param string $uri */ - public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function handle($uri = null) {} /** * Attach Route object to the routes stack. * - * ```php + * * use Phalcon\Mvc\Router; * use Phalcon\Mvc\Router\Route; * @@ -273,226 +275,239 @@ public function addTrace(string $pattern, $paths = null, $position = Router::POS * new CustomRoute("/about", "About::index", ["GET", "HEAD"]), * Router::POSITION_FIRST * ); - * ``` + * * + * @todo Add to the interface for 4.0.0 * @param \Phalcon\Mvc\Router\RouteInterface $route * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface {} + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST) {} /** - * Removes all the pre-defined routes - */ - public function clear() {} - - /** - * Returns the internal dependency injector + * Adds a route to the router without any HTTP constraint + * + * + * use Phalcon\Mvc\Router; + * + * $router->add("/about", "About::index"); + * $router->add("/about", "About::index", ["GET", "POST"]); + * $router->add("/about", "About::index", ["GET", "POST"], Router::POSITION_FIRST); + * * - * @return \Phalcon\Di\DiInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getDI(): DiInterface {} + public function add($pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST) {} /** - * Returns the internal event manager + * Adds a route to the router that only match if the HTTP method is GET * - * @return \Phalcon\Events\ManagerInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getEventsManager(): ManagerInterface {} + public function addGet($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the processed action name + * Adds a route to the router that only match if the HTTP method is POST * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getActionName(): string {} + public function addPost($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the processed controller name + * Adds a route to the router that only match if the HTTP method is PUT * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getControllerName(): string {} + public function addPut($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the route that matches the handled URI + * Adds a route to the router that only match if the HTTP method is PATCH * + * @param string $pattern + * @param mixed $paths + * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getMatchedRoute(): RouteInterface {} + public function addPatch($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the sub expressions in the regular expression matched + * Adds a route to the router that only match if the HTTP method is DELETE * - * @return array + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getMatches(): array {} + public function addDelete($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the processed module name + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getModuleName(): string {} + public function addOptions($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the processed namespace name + * Adds a route to the router that only match if the HTTP method is HEAD * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getNamespaceName(): string {} + public function addHead($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns the processed parameters + * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) * - * @return array + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getParams(): array {} + public function addPurge($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns a route object by its id + * Adds a route to the router that only match if the HTTP method is TRACE * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRouteById($id) {} + public function addTrace($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns a route object by its name + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRouteByName(string $name) {} + public function addConnect($pattern, $paths = null, $position = Router::POSITION_LAST) {} /** - * Returns all the routes defined in the router + * Mounts a group of routes in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function getRoutes(): array {} + public function mount(\Phalcon\Mvc\Router\GroupInterface $group) {} /** - * Handles routing information received from the rewrite engine - * - * ```php - * // Passing a URL - * $router->handle("/posts/edit/1"); - * ``` + * Set a group of paths to be returned when none of the defined routes are matched * - * @param string $uri + * @param mixed $paths + * @return RouterInterface */ - public function handle(string $uri) {} + public function notFound($paths) {} /** - * Returns whether controller name should not be mangled - * - * @return bool + * Removes all the pre-defined routes */ - public function isExactControllerName(): bool {} + public function clear() {} /** - * Mounts a group of routes in the router + * Returns the processed namespace name * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return string */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface {} + public function getNamespaceName() {} /** - * Set a group of paths to be returned when none of the defined routes are - * matched + * Returns the processed module name * - * @param mixed $paths - * @return RouterInterface + * @return string */ - public function notFound($paths): RouterInterface {} + public function getModuleName() {} /** - * Set whether router must remove the extra slashes in the handled routes + * Returns the processed controller name * - * @param bool $remove - * @return RouterInterface + * @return string */ - public function removeExtraSlashes(bool $remove): RouterInterface {} + public function getControllerName() {} /** - * Sets the default action name + * Returns the processed action name * - * @param string $actionName - * @return RouterInterface + * @return string */ - public function setDefaultAction(string $actionName): RouterInterface {} + public function getActionName() {} /** - * Sets the default controller name + * Returns the processed parameters * - * @param string $controllerName - * @return RouterInterface + * @return array */ - public function setDefaultController(string $controllerName): RouterInterface {} + public function getParams() {} /** - * Sets the name of the default module + * Returns the route that matches the handled URI * - * @param string $moduleName - * @return RouterInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultModule(string $moduleName): RouterInterface {} + public function getMatchedRoute() {} /** - * Sets the name of the default namespace + * Returns the sub expressions in the regular expression matched * - * @param string $namespaceName - * @return RouterInterface + * @return array */ - public function setDefaultNamespace(string $namespaceName): RouterInterface {} + public function getMatches() {} /** - * Sets an array of default paths. If a route is missing a path the router - * will use the defined here. This method must not be used to set a 404 - * route - * - * ```php - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * ``` + * Checks if the router matches any of the defined routes * - * @param array $defaults - * @return RouterInterface + * @return bool */ - public function setDefaults(array $defaults): RouterInterface {} + public function wasMatched() {} /** - * Returns an array of default parameters + * Returns all the routes defined in the router * - * @return array + * @return \Phalcon\Mvc\Router\RouteInterface[] */ - public function getDefaults(): array {} + public function getRoutes() {} /** - * Sets the dependency injector + * Returns a route object by its id * - * @param \Phalcon\Di\DiInterface $container + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getRouteById($id) {} /** - * Sets the events manager + * Returns a route object by its name * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function getRouteByName($name) {} /** - * Checks if the router matches any of the defined routes + * Returns whether controller name should not be mangled * * @return bool */ - public function wasMatched(): bool {} + public function isExactControllerName() {} } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index f78d3286..6f7adef2 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -3,56 +3,57 @@ namespace Phalcon\Mvc; /** + * Phalcon\Mvc\RouterInterface + * * Interface for Phalcon\Mvc\Router */ interface RouterInterface { /** - * Adds a route to the router on any HTTP method + * Sets the name of the default module * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName */ - public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; + public function setDefaultModule($moduleName); /** - * Attach Route object to the routes stack. + * Sets the default controller name * - * @param \Phalcon\Mvc\Router\RouteInterface $route - * @param mixed $position - * @return RouterInterface + * @param string $controllerName */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; + public function setDefaultController($controllerName); /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Sets the default action name * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $actionName */ - public function addConnect(string $pattern, $paths = null): RouteInterface; + public function setDefaultAction($actionName); /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Sets an array of default paths * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param array $defaults */ - public function addDelete(string $pattern, $paths = null): RouteInterface; + public function setDefaults(array $defaults); /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Handles routing information received from the rewrite engine + * + * @param string $uri + */ + public function handle($uri = null); + + /** + * Adds a route to the router on any HTTP method * * @param string $pattern * @param mixed $paths + * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addHead(string $pattern, $paths = null): RouteInterface; + public function add($pattern, $paths = null, $httpMethods = null); /** * Adds a route to the router that only match if the HTTP method is GET @@ -61,188 +62,179 @@ public function addHead(string $pattern, $paths = null): RouteInterface; * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet(string $pattern, $paths = null): RouteInterface; + public function addGet($pattern, $paths = null); /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Adds a route to the router that only match if the HTTP method is POST * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addOptions(string $pattern, $paths = null): RouteInterface; + public function addPost($pattern, $paths = null); /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch(string $pattern, $paths = null): RouteInterface; + public function addPut($pattern, $paths = null); /** - * Adds a route to the router that only match if the HTTP method is POST + * Adds a route to the router that only match if the HTTP method is PATCH * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost(string $pattern, $paths = null): RouteInterface; + public function addPatch($pattern, $paths = null); /** - * Adds a route to the router that only match if the HTTP method is PURGE - * (Squid and Varnish support) + * Adds a route to the router that only match if the HTTP method is DELETE * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPurge(string $pattern, $paths = null): RouteInterface; + public function addDelete($pattern, $paths = null); /** - * Adds a route to the router that only match if the HTTP method is PUT + * Add a route to the router that only match if the HTTP method is OPTIONS * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPut(string $pattern, $paths = null): RouteInterface; + public function addOptions($pattern, $paths = null); /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Adds a route to the router that only match if the HTTP method is HEAD * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addTrace(string $pattern, $paths = null): RouteInterface; + public function addHead($pattern, $paths = null); /** - * Removes all the defined routes + * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) + * + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function clear(); + public function addPurge($pattern, $paths = null); /** - * Returns processed action name + * Adds a route to the router that only match if the HTTP method is TRACE * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getActionName(): string; + public function addTrace($pattern, $paths = null); /** - * Returns processed controller name + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getControllerName(): string; + public function addConnect($pattern, $paths = null); /** - * Returns the route that matches the handled URI + * Mounts a group of routes in the router * - * @return \Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function getMatchedRoute(): RouteInterface; + public function mount(\Phalcon\Mvc\Router\GroupInterface $group); /** - * Return the sub expressions in the regular expression matched - * - * @return array + * Removes all the defined routes */ - public function getMatches(): array; + public function clear(); /** * Returns processed module name * * @return string */ - public function getModuleName(): string; + public function getModuleName(); /** * Returns processed namespace name * * @return string */ - public function getNamespaceName(): string; + public function getNamespaceName(); /** - * Returns processed extra params - * - * @return array - */ - public function getParams(): array; - - /** - * Return all the routes defined in the router - * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] - */ - public function getRoutes(): array; - - /** - * Returns a route object by its id + * Returns processed controller name * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function getRouteById($id); + public function getControllerName(); /** - * Returns a route object by its name + * Returns processed action name * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function getRouteByName(string $name); + public function getActionName(); /** - * Handles routing information received from the rewrite engine + * Returns processed extra params * - * @param string $uri + * @return array */ - public function handle(string $uri); + public function getParams(); /** - * Mounts a group of routes in the router + * Returns the route that matches the handled URI * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface; + public function getMatchedRoute(); /** - * Sets the default action name + * Return the sub expressions in the regular expression matched * - * @param string $actionName + * @return array */ - public function setDefaultAction(string $actionName); + public function getMatches(); /** - * Sets the default controller name + * Check if the router matches any of the defined routes * - * @param string $controllerName + * @return bool */ - public function setDefaultController(string $controllerName); + public function wasMatched(); /** - * Sets the name of the default module + * Return all the routes defined in the router * - * @param string $moduleName + * @return \Phalcon\Mvc\Router\RouteInterface[] */ - public function setDefaultModule(string $moduleName); + public function getRoutes(); /** - * Sets an array of default paths + * Returns a route object by its id * - * @param array $defaults + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function setDefaults(array $defaults); + public function getRouteById($id); /** - * Check if the router matches any of the defined routes + * Returns a route object by its name * - * @return bool + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function wasMatched(): bool; + public function getRouteByName($name); } diff --git a/src/Phalcon/mvc/Url.php b/src/Phalcon/mvc/Url.php new file mode 100644 index 00000000..92b6e69a --- /dev/null +++ b/src/Phalcon/mvc/Url.php @@ -0,0 +1,184 @@ + + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2012", + * ] + * ); + * + */ +class Url implements \Phalcon\Mvc\UrlInterface, \Phalcon\Di\InjectionAwareInterface +{ + + protected $_dependencyInjector; + + + protected $_baseUri = null; + + + protected $_staticBaseUri = null; + + + protected $_basePath = null; + + + protected $_router; + + + /** + * Sets the DependencyInjector container + * + * @param \Phalcon\DiInterface $dependencyInjector + */ + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + + /** + * Returns the DependencyInjector container + * + * @return \Phalcon\DiInterface + */ + public function getDI() {} + + /** + * Sets a prefix for all the URIs to be generated + * + * + * $url->setBaseUri("/invo/"); + * + * $url->setBaseUri("/invo/index.php/"); + * + * + * @param string $baseUri + * @return Url + */ + public function setBaseUri($baseUri) {} + + /** + * Sets a prefix for all static URLs generated + * + * + * $url->setStaticBaseUri("/invo/"); + * + * + * @param string $staticBaseUri + * @return Url + */ + public function setStaticBaseUri($staticBaseUri) {} + + /** + * Returns the prefix for all the generated urls. By default / + * + * @return string + */ + public function getBaseUri() {} + + /** + * Returns the prefix for all the generated static urls. By default / + * + * @return string + */ + public function getStaticBaseUri() {} + + /** + * Sets a base path for all the generated paths + * + * + * $url->setBasePath("/var/www/htdocs/"); + * + * + * @param string $basePath + * @return Url + */ + public function setBasePath($basePath) {} + + /** + * Returns the base path + * + * @return string + */ + public function getBasePath() {} + + /** + * Generates a URL + * + * + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2015", + * ] + * ); + * + * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) + * echo $url->get( + * "show/products", + * [ + * "id" => 1, + * "name" => "Carrots", + * ] + * ); + * + * // Generate an absolute URL by setting the third parameter as false. + * echo $url->get( + * "https://phalconphp.com/", + * null, + * false + * ); + * + * + * @param mixed $uri + * @param mixed $args + * @param mixed $local + * @param mixed $baseUri + * @return string + */ + public function get($uri = null, $args = null, $local = null, $baseUri = null) {} + + /** + * Generates a URL for a static resource + * + * + * // Generate a URL for a static resource + * echo $url->getStatic("img/logo.png"); + * + * // Generate a URL for a static predefined route + * echo $url->getStatic( + * [ + * "for" => "logo-cdn", + * ] + * ); + * + * + * @param mixed $uri + * @return string + */ + public function getStatic($uri = null) {} + + /** + * Generates a local path + * + * @param string $path + * @return string + */ + public function path($path = null) {} + +} diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/mvc/UrlInterface.php similarity index 61% rename from src/Phalcon/url/UrlInterface.php rename to src/Phalcon/mvc/UrlInterface.php index e67b5ed5..567b066a 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/mvc/UrlInterface.php @@ -1,52 +1,53 @@ * use Phalcon\Mvc\View; * * $view = new View(); @@ -26,19 +25,19 @@ * * // Printing views output * echo $view->getContent(); - * ``` + * */ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface { /** - * Render Level: To the action view + * Render Level: To the main layout */ - const LEVEL_ACTION_VIEW = 1; + const LEVEL_MAIN_LAYOUT = 5; /** - * Render Level: To the templates "before" + * Render Level: Render to the templates "after" */ - const LEVEL_BEFORE_TEMPLATE = 2; + const LEVEL_AFTER_TEMPLATE = 4; /** * Render Level: To the controller layout @@ -46,9 +45,14 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_LAYOUT = 3; /** - * Render Level: To the main layout + * Render Level: To the templates "before" */ - const LEVEL_MAIN_LAYOUT = 5; + const LEVEL_BEFORE_TEMPLATE = 2; + + /** + * Render Level: To the action view + */ + const LEVEL_ACTION_VIEW = 1; /** * Render Level: No render any view @@ -56,86 +60,99 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_NO_RENDER = 0; /** - * Render Level: Render to the templates "after" + * Cache Mode */ - const LEVEL_AFTER_TEMPLATE = 4; + const CACHE_MODE_NONE = 0; - protected $actionName; + const CACHE_MODE_INVERSE = 1; - protected $activeRenderPaths; + protected $_options; - protected $basePath = ''; + protected $_basePath = ''; - protected $content = ''; + protected $_content = ''; - protected $controllerName; + protected $_renderLevel = 5; - protected $currentRenderLevel = 0; + protected $_currentRenderLevel = 0; - protected $disabled = false; + protected $_disabledLevels; - protected $disabledLevels; + protected $_viewParams = array(); - protected $engines = false; + protected $_layout; - protected $layout; + protected $_layoutsDir = ''; - protected $layoutsDir = ''; + protected $_partialsDir = ''; - protected $mainView = 'index'; + protected $_viewsDirs = array(); - protected $options = array(); + protected $_templatesBefore = array(); - protected $params; + protected $_templatesAfter = array(); - protected $pickView; + protected $_engines = false; + /** + * @var array + */ + protected $_registeredEngines; - protected $partialsDir = ''; + protected $_mainView = 'index'; - protected $registeredEngines = array(); + protected $_controllerName; - protected $renderLevel = 5; + protected $_actionName; - protected $templatesAfter = array(); + protected $_params; - protected $templatesBefore = array(); + protected $_pickView; - protected $viewsDirs = array(); + protected $_cache; - protected $viewParams = array(); + protected $_cacheLevel = 0; - public function getCurrentRenderLevel() {} + protected $_activeRenderPaths; - public function getRegisteredEngines() {} + protected $_disabled = false; + public function getRenderLevel() {} + + public function getCurrentRenderLevel() {} + + /** + * @return array + */ + public function getRegisteredEngines() {} + /** * Phalcon\Mvc\View constructor * @@ -144,542 +161,563 @@ public function getRenderLevel() {} public function __construct(array $options = array()) {} /** - * Magic method to retrieve a variable passed to the view - * - * ```php - * echo $this->view->products; - * ``` + * Checks if a path is absolute or not * - * @param string $key - * @return mixed|null + * @param string $path */ - public function __get(string $key): ? {} + protected final function _isAbsolutePath($path) {} /** - * Magic method to retrieve if a variable is set in the view - * - * ```php - * echo isset($this->view->products); - * ``` + * Sets the views directory. Depending of your platform, + * always add a trailing slash or backslash * - * @param string $key - * @return bool + * @param mixed $viewsDir + * @return View */ - public function __isset(string $key): bool {} + public function setViewsDir($viewsDir) {} /** - * Magic method to pass variables to the views - * - * ```php - * $this->view->products = $products; - * ``` + * Gets views directory * - * @param string $key - * @param mixed $value + * @return string|array */ - public function __set(string $key, $value) {} + public function getViewsDir() {} /** - * Resets any template before layouts + * Sets the layouts sub-directory. Must be a directory under the views directory. + * Depending of your platform, always add a trailing slash or backslash * + * + * $view->setLayoutsDir("../common/layouts/"); + * + * + * @param string $layoutsDir * @return View */ - public function cleanTemplateAfter(): View {} + public function setLayoutsDir($layoutsDir) {} /** - * Resets any "template before" layouts + * Gets the current layouts sub-directory * - * @return View + * @return string */ - public function cleanTemplateBefore(): View {} + public function getLayoutsDir() {} /** - * Disables a specific level of rendering + * Sets a partials sub-directory. Must be a directory under the views directory. + * Depending of your platform, always add a trailing slash or backslash * - * ```php - * // Render all levels except ACTION level - * $this->view->disableLevel( - * View::LEVEL_ACTION_VIEW - * ); - * ``` + * + * $view->setPartialsDir("../common/partials/"); + * * - * @param mixed $level - * @return \Phalcon\Mvc\ViewInterface + * @param string $partialsDir + * @return View */ - public function disableLevel($level): ViewInterface {} + public function setPartialsDir($partialsDir) {} /** - * Disables the auto-rendering process + * Gets the current partials sub-directory * - * @return View + * @return string */ - public function disable(): View {} + public function getPartialsDir() {} /** - * Enables the auto-rendering process + * Sets base path. Depending of your platform, always add a trailing slash or backslash + * + * + * $view->setBasePath(__DIR__ . "/"); + * * + * @param string $basePath * @return View */ - public function enable(): View {} + public function setBasePath($basePath) {} /** - * Checks whether view exists + * Gets base path * - * @param string $view - * @return bool + * @return string */ - public function exists(string $view): bool {} + public function getBasePath() {} /** - * Finishes the render process by stopping the output buffering + * Sets the render level for the view * + * + * // Render the view related to the controller only + * $this->view->setRenderLevel( + * View::LEVEL_LAYOUT + * ); + * + * + * @param int $level * @return View */ - public function finish(): View {} + public function setRenderLevel($level) {} /** - * Gets the name of the action rendered + * Disables a specific level of rendering * - * @return string - */ - public function getActionName(): string {} - - /** - * Returns the path (or paths) of the views that are currently rendered + * + * // Render all levels except ACTION level + * $this->view->disableLevel( + * View::LEVEL_ACTION_VIEW + * ); + * * - * @return string|array + * @param mixed $level + * @return View */ - public function getActiveRenderPath() {} + public function disableLevel($level) {} /** - * Gets base path + * Sets default view name. Must be a file without extension in the views directory * - * @return string + * + * // Renders as main view views-dir/base.phtml + * $this->view->setMainView("base"); + * + * + * @param string $viewPath + * @return View */ - public function getBasePath(): string {} + public function setMainView($viewPath) {} /** - * Returns output from another view stage + * Returns the name of the main view * * @return string */ - public function getContent(): string {} + public function getMainView() {} /** - * Gets the name of the controller rendered + * Change the layout to be used instead of using the name of the latest controller name * - * @return string + * + * $this->view->setLayout("main"); + * + * + * @param string $layout + * @return View */ - public function getControllerName(): string {} + public function setLayout($layout) {} /** * Returns the name of the main view * * @return string */ - public function getLayout(): string {} + public function getLayout() {} /** - * Gets the current layouts sub-directory + * Sets a template before the controller layout * - * @return string + * @param mixed $templateBefore + * @return View */ - public function getLayoutsDir(): string {} + public function setTemplateBefore($templateBefore) {} /** - * Returns the name of the main view + * Resets any "template before" layouts * - * @return string + * @return View */ - public function getMainView(): string {} + public function cleanTemplateBefore() {} /** - * Returns parameters to views + * Sets a "template after" controller layout * - * @return array + * @param mixed $templateAfter + * @return View */ - public function getParamsToView(): array {} + public function setTemplateAfter($templateAfter) {} /** - * Renders a partial view - * - * ```php - * // Retrieve the contents of a partial - * echo $this->getPartial("shared/footer"); - * ``` - * - * ```php - * // Retrieve the contents of a partial with arguments - * echo $this->getPartial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * ``` + * Resets any template before layouts * - * @param string $partialPath - * @param mixed $params - * @return string + * @return View */ - public function getPartial(string $partialPath, $params = null): string {} + public function cleanTemplateAfter() {} /** - * Gets the current partials sub-directory + * Adds parameters to views (alias of setVar) * - * @return string + * + * $this->view->setParamToView("products", $products); + * + * + * @param string $key + * @param mixed $value + * @return View */ - public function getPartialsDir(): string {} + public function setParamToView($key, $value) {} /** - * Perform the automatic rendering returning the output as a string + * Set all the render params * - * ```php - * $template = $this->view->getRender( - * "products", - * "show", + * + * $this->view->setVars( * [ * "products" => $products, * ] * ); - * ``` + * * - * @param string $controllerName - * @param string $actionName * @param array $params - * @param mixed $configCallback - * @return string + * @param bool $merge + * @return View */ - public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string {} + public function setVars(array $params, $merge = true) {} /** - * Returns a parameter previously set in the view + * Set a single view parameter + * + * + * $this->view->setVar("products", $products); + * * * @param string $key + * @param mixed $value + * @return View */ - public function getVar(string $key) {} + public function setVar($key, $value) {} /** - * Gets views directory + * Returns a parameter previously set in the view * - * @return string|array + * @param string $key */ - public function getViewsDir() {} + public function getVar($key) {} /** - * Gets views directories + * Returns parameters to views * * @return array */ - protected function getViewsDirs(): array {} + public function getParamsToView() {} /** - * Whether automatic rendering is enabled + * Gets the name of the controller rendered * - * @return bool + * @return string */ - public function isDisabled(): bool {} + public function getControllerName() {} /** - * Renders a partial view - * - * ```php - * // Show a partial inside another view - * $this->partial("shared/footer"); - * ``` - * - * ```php - * // Show a partial inside another view with parameters - * $this->partial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * ``` + * Gets the name of the action rendered * - * @param string $partialPath - * @param mixed $params + * @return string */ - public function partial(string $partialPath, $params = null) {} + public function getActionName() {} /** - * Choose a different view to render instead of last-controller/last-action + * Gets extra parameters of the action rendered * - * ```php - * use Phalcon\Mvc\Controller; + * @deprecated Will be removed in 4.0.0 + * @deprecated + * @return array + */ + public function getParams() {} + + /** + * Starts rendering process enabling the output buffering * - * class ProductsController extends Controller - * { - * public function saveAction() - * { - * // Do some save stuff... + * @return View + */ + public function start() {} + + /** + * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php * - * // Then show the list view - * $this->view->pick("products/list"); - * } - * } - * ``` + * @return array + */ + protected function _loadTemplateEngines() {} + + /** + * Checks whether view exists on registered extensions and render it * - * @param mixed $renderView - * @return View + * @param array $engines + * @param string $viewPath + * @param boolean $silence + * @param boolean $mustClean + * @param \Phalcon\Cache\BackendInterface $cache */ - public function pick($renderView): View {} + protected function _engineRender($engines, $viewPath, $silence, $mustClean, \Phalcon\Cache\BackendInterface $cache = null) {} /** * Register templating engines * - * ```php + * * $this->view->registerEngines( * [ - * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, - * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, - * ".mhtml" => \MyCustomEngine::class, + * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", + * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", + * ".mhtml" => "MyCustomEngine", * ] * ); - * ``` + * * * @param array $engines * @return View */ - public function registerEngines(array $engines): View {} + public function registerEngines(array $engines) {} + + /** + * Checks whether view exists + * + * @param string $view + * @return bool + */ + public function exists($view) {} /** * Executes render process from dispatching data * - * ```php + * * // Shows recent posts view (app/views/posts/recent.phtml) * $view->start()->render("posts", "recent")->finish(); - * ``` + * * * @param string $controllerName * @param string $actionName * @param array $params * @return bool|View */ - public function render(string $controllerName, string $actionName, array $params = array()) {} + public function render($controllerName, $actionName, $params = null) {} /** - * Resets the view component to its factory default values + * Choose a different view to render instead of last-controller/last-action + * + * + * use Phalcon\Mvc\Controller; * + * class ProductsController extends Controller + * { + * public function saveAction() + * { + * // Do some save stuff... + * + * // Then show the list view + * $this->view->pick("products/list"); + * } + * } + * + * + * @param mixed $renderView * @return View */ - public function reset(): View {} + public function pick($renderView) {} /** - * Sets base path. Depending of your platform, always add a trailing slash - * or backslash + * Renders a partial view * - * ```php - * $view->setBasePath(__DIR__ . "/"); - * ``` + * + * // Retrieve the contents of a partial + * echo $this->getPartial("shared/footer"); + * * - * @param string $basePath - * @return View + * + * // Retrieve the contents of a partial with arguments + * echo $this->getPartial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * + * + * @param string $partialPath + * @param mixed $params + * @return string */ - public function setBasePath(string $basePath): View {} + public function getPartial($partialPath, $params = null) {} /** - * Externally sets the view content + * Renders a partial view * - * ```php - * $this->view->setContent("

hello

"); - * ``` + * + * // Show a partial inside another view + * $this->partial("shared/footer"); + * * - * @param string $content - * @return View + * + * // Show a partial inside another view with parameters + * $this->partial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * + * + * @param string $partialPath + * @param mixed $params */ - public function setContent(string $content): View {} + public function partial($partialPath, $params = null) {} /** - * Change the layout to be used instead of using the name of the latest - * controller name + * Perform the automatic rendering returning the output as a string * - * ```php - * $this->view->setLayout("main"); - * ``` + * + * $template = $this->view->getRender( + * "products", + * "show", + * [ + * "products" => $products, + * ] + * ); + * * - * @param string $layout - * @return View + * @param string $controllerName + * @param string $actionName + * @param array $params + * @param mixed $configCallback + * @return string */ - public function setLayout(string $layout): View {} + public function getRender($controllerName, $actionName, $params = null, $configCallback = null) {} /** - * Sets the layouts sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or - * backslash - * - * ```php - * $view->setLayoutsDir("../common/layouts/"); - * ``` + * Finishes the render process by stopping the output buffering * - * @param string $layoutsDir * @return View */ - public function setLayoutsDir(string $layoutsDir): View {} + public function finish() {} /** - * Sets default view name. Must be a file without extension in the views - * directory + * Create a Phalcon\Cache based on the internal cache options * - * ```php - * // Renders as main view views-dir/base.phtml - * $this->view->setMainView("base"); - * ``` - * - * @param string $viewPath - * @return View + * @return \Phalcon\Cache\BackendInterface */ - public function setMainView(string $viewPath): View {} + protected function _createCache() {} /** - * Sets a partials sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or - * backslash + * Check if the component is currently caching the output content * - * ```php - * $view->setPartialsDir("../common/partials/"); - * ``` - * - * @param string $partialsDir - * @return View + * @return bool */ - public function setPartialsDir(string $partialsDir): View {} + public function isCaching() {} /** - * Adds parameters to views (alias of setVar) - * - * ```php - * $this->view->setParamToView("products", $products); - * ``` + * Returns the cache instance used to cache * - * @param string $key - * @param mixed $value - * @return View + * @return \Phalcon\Cache\BackendInterface */ - public function setParamToView(string $key, $value): View {} + public function getCache() {} /** - * Sets the render level for the view + * Cache the actual view render to certain level * - * ```php - * // Render the view related to the controller only - * $this->view->setRenderLevel( - * View::LEVEL_LAYOUT + * + * $this->view->cache( + * [ + * "key" => "my-key", + * "lifetime" => 86400, + * ] * ); - * ``` + * * - * @param int $level - * @return \Phalcon\Mvc\ViewInterface + * @param mixed $options + * @return View */ - public function setRenderLevel(int $level): ViewInterface {} + public function cache($options = true) {} /** - * Sets a "template after" controller layout + * Externally sets the view content * - * @param mixed $templateAfter + * + * $this->view->setContent("

hello

"); + *
+ * + * @param string $content * @return View */ - public function setTemplateAfter($templateAfter): View {} + public function setContent($content) {} /** - * Sets a template before the controller layout + * Returns cached output from another view stage * - * @param mixed $templateBefore - * @return View + * @return string */ - public function setTemplateBefore($templateBefore): View {} + public function getContent() {} /** - * Set a single view parameter - * - * ```php - * $this->view->setVar("products", $products); - * ``` + * Returns the path (or paths) of the views that are currently rendered * - * @param string $key - * @param mixed $value - * @return View + * @return string|array */ - public function setVar(string $key, $value): View {} + public function getActiveRenderPath() {} /** - * Set all the render params - * - * ```php - * $this->view->setVars( - * [ - * "products" => $products, - * ] - * ); - * ``` + * Disables the auto-rendering process * - * @param array $params - * @param bool $merge * @return View */ - public function setVars(array $params, bool $merge = true): View {} + public function disable() {} /** - * Sets the views directory. Depending of your platform, - * always add a trailing slash or backslash + * Enables the auto-rendering process * - * @param mixed $viewsDir * @return View */ - public function setViewsDir($viewsDir): View {} + public function enable() {} /** - * Starts rendering process enabling the output buffering + * Resets the view component to its factory default values * * @return View */ - public function start(): View {} + public function reset() {} /** - * Renders the view and returns it as a string + * Magic method to pass variables to the views * - * @param string $controllerName - * @param string $actionName - * @param array $params - * @return string + * + * $this->view->products = $products; + * + * + * @param string $key + * @param mixed $value */ - public function toString(string $controllerName, string $actionName, array $params = array()): string {} + public function __set($key, $value) {} /** - * Checks whether view exists on registered extensions and render it + * Magic method to retrieve a variable passed to the view * - * @param array $engines - * @param string $viewPath - * @param bool $silence - * @param bool $mustClean + * + * echo $this->view->products; + * + * + * @param string $key + * @return mixed|null */ - protected function engineRender(array $engines, string $viewPath, bool $silence, bool $mustClean = true) {} + public function __get($key) {} /** - * Checks if a path is absolute or not + * Whether automatic rendering is enabled * - * @param string $path + * @return bool */ - final protected function isAbsolutePath(string $path) {} + public function isDisabled() {} /** - * Loads registered template engines, if none is registered it will use - * Phalcon\Mvc\View\Engine\Php + * Magic method to retrieve if a variable is set in the view * - * @return array + * + * echo isset($this->view->products); + * + * + * @param string $key + * @return bool */ - protected function loadTemplateEngines(): array {} + public function __isset($key) {} /** - * Processes the view and templates; Fires events if needed + * Gets views directories * - * @param string $controllerName - * @param string $actionName - * @param array $params - * @param bool $fireEvents - * @return bool + * @return array */ - public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool {} + protected function getViewsDirs() {} } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index a88fca68..d0821d61 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -11,63 +11,76 @@ interface ViewBaseInterface { /** - * Returns cached output from another view stage + * Sets views directory. Depending of your platform, always add a trailing slash or backslash * - * @return string + * @param string $viewsDir */ - public function getContent(): string; + public function setViewsDir($viewsDir); /** - * Returns parameters to views + * Gets views directory * - * @return array + * @return string|array */ - public function getParamsToView(): array; + public function getViewsDir(); /** - * Gets views directory + * Adds parameters to views (alias of setVar) * - * @return string|array + * @param string $key + * @param mixed $value */ - public function getViewsDir(); + public function setParamToView($key, $value); /** - * Renders a partial view + * Adds parameters to views * - * @param string $partialPath - * @param mixed $params + * @param string $key + * @param mixed $value */ - public function partial(string $partialPath, $params = null); + public function setVar($key, $value); /** - * Externally sets the view content + * Returns parameters to views * - * @param string $content + * @return array */ - public function setContent(string $content); + public function getParamsToView(); /** - * Adds parameters to views (alias of setVar) + * Returns the cache instance used to cache * - * @param string $key - * @param mixed $value + * @return \Phalcon\Cache\BackendInterface */ - public function setParamToView(string $key, $value); + public function getCache(); /** - * Adds parameters to views + * Cache the actual view render to certain level * - * @param string $key - * @param mixed $value + * @param mixed $options */ - public function setVar(string $key, $value); + public function cache($options = true); /** - * Sets views directory. Depending of your platform, always add a trailing - * slash or backslash + * Externally sets the view content * - * @param string $viewsDir + * @param string $content + */ + public function setContent($content); + + /** + * Returns cached output from another view stage + * + * @return string + */ + public function getContent(); + + /** + * Renders a partial view + * + * @param string $partialPath + * @param mixed $params */ - public function setViewsDir(string $viewsDir); + public function partial($partialPath, $params = null); } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index c27c5ca3..fb0b5082 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -11,189 +11,191 @@ interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface { /** - * Resets any template before layouts + * Sets the layouts sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or backslash + * + * @param string $layoutsDir */ - public function cleanTemplateAfter(); + public function setLayoutsDir($layoutsDir); /** - * Resets any template before layouts + * Gets the current layouts sub-directory + * + * @return string */ - public function cleanTemplateBefore(); + public function getLayoutsDir(); /** - * Disables the auto-rendering process + * Sets a partials sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or backslash + * + * @param string $partialsDir */ - public function disable(); + public function setPartialsDir($partialsDir); /** - * Enables the auto-rendering process + * Gets the current partials sub-directory + * + * @return string */ - public function enable(); + public function getPartialsDir(); /** - * Finishes the render process by stopping the output buffering + * Sets base path. Depending of your platform, always add a trailing slash or backslash + * + * @param string $basePath */ - public function finish(); + public function setBasePath($basePath); /** - * Gets the name of the action rendered + * Gets base path * * @return string */ - public function getActionName(): string; + public function getBasePath(); /** - * Returns the path of the view that is currently rendered + * Sets the render level for the view * - * @return string|array + * @param int $level */ - public function getActiveRenderPath(); + public function setRenderLevel($level); /** - * Gets base path + * Sets default view name. Must be a file without extension in the views directory * - * @return string + * @param string $viewPath */ - public function getBasePath(): string; + public function setMainView($viewPath); /** - * Gets the name of the controller rendered + * Returns the name of the main view * * @return string */ - public function getControllerName(): string; + public function getMainView(); /** - * Returns the name of the main view + * Change the layout to be used instead of using the name of the latest controller name * - * @return string + * @param string $layout */ - public function getLayout(): string; + public function setLayout($layout); /** - * Gets the current layouts sub-directory + * Returns the name of the main view * * @return string */ - public function getLayoutsDir(): string; + public function getLayout(); /** - * Returns the name of the main view + * Appends template before controller layout * - * @return string + * @param string|array $templateBefore */ - public function getMainView(): string; + public function setTemplateBefore($templateBefore); /** - * Gets the current partials sub-directory - * - * @return string + * Resets any template before layouts */ - public function getPartialsDir(): string; + public function cleanTemplateBefore(); /** - * Whether the automatic rendering is disabled + * Appends template after controller layout * - * @return bool + * @param string|array $templateAfter */ - public function isDisabled(): bool; + public function setTemplateAfter($templateAfter); /** - * Choose a view different to render than last-controller/last-action + * Resets any template before layouts + */ + public function cleanTemplateAfter(); + + /** + * Gets the name of the controller rendered * - * @param string $renderView + * @return string */ - public function pick(string $renderView); + public function getControllerName(); /** - * Register templating engines + * Gets the name of the action rendered * - * @param array $engines + * @return string */ - public function registerEngines(array $engines); + public function getActionName(); /** - * Executes render process from dispatching data + * Gets extra parameters of the action rendered * - * @param string $controllerName - * @param string $actionName - * @param array $params - * @return bool|ViewInterface + * @deprecated Will be removed in 4.0.0 + * @deprecated + * @return array */ - public function render(string $controllerName, string $actionName, array $params = array()); + public function getParams(); /** - * Resets the view component to its factory default values + * Starts rendering process enabling the output buffering */ - public function reset(); + public function start(); /** - * Sets base path. Depending of your platform, always add a trailing slash - * or backslash + * Register templating engines * - * @param string $basePath + * @param array $engines */ - public function setBasePath(string $basePath); + public function registerEngines(array $engines); /** - * Change the layout to be used instead of using the name of the latest - * controller name + * Executes render process from dispatching data * - * @param string $layout + * @param string $controllerName + * @param string $actionName + * @param array $params */ - public function setLayout(string $layout); + public function render($controllerName, $actionName, $params = null); /** - * Sets the layouts sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or - * backslash + * Choose a view different to render than last-controller/last-action * - * @param string $layoutsDir + * @param string $renderView */ - public function setLayoutsDir(string $layoutsDir); + public function pick($renderView); /** - * Sets default view name. Must be a file without extension in the views - * directory - * - * @param string $viewPath + * Finishes the render process by stopping the output buffering */ - public function setMainView(string $viewPath); + public function finish(); /** - * Sets a partials sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or - * backslash + * Returns the path of the view that is currently rendered * - * @param string $partialsDir + * @return string|array */ - public function setPartialsDir(string $partialsDir); + public function getActiveRenderPath(); /** - * Sets the render level for the view - * - * @param int $level - * @return ViewInterface + * Disables the auto-rendering process */ - public function setRenderLevel(int $level): ViewInterface; + public function disable(); /** - * Appends template after controller layout - * - * @param string|array $templateAfter + * Enables the auto-rendering process */ - public function setTemplateAfter($templateAfter); + public function enable(); /** - * Appends template before controller layout - * - * @param string|array $templateBefore + * Resets the view component to its factory default values */ - public function setTemplateBefore($templateBefore); + public function reset(); /** - * Starts rendering process enabling the output buffering + * Whether the automatic rendering is disabled + * + * @return bool */ - public function start(); + public function isDisabled(); } diff --git a/src/Phalcon/mvc/collection/Behavior.php b/src/Phalcon/mvc/collection/Behavior.php index b0683096..7ad66958 100644 --- a/src/Phalcon/mvc/collection/Behavior.php +++ b/src/Phalcon/mvc/collection/Behavior.php @@ -10,7 +10,7 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface { - protected $options; + protected $_options; /** @@ -18,39 +18,39 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct($options = null) {} /** - * Returns the behavior options related to an event + * Checks whether the behavior must take action on certain event * * @param string $eventName - * @return array + * @return bool */ - protected function getOptions(string $eventName = null) {} + protected function mustTakeAction($eventName) {} /** - * Acts as fallbacks when a missing method is called on the collection + * Returns the behavior options related to an event * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $method - * @param array $arguments + * @param string $eventName + * @return array */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $method, array $arguments = array()) {} + protected function getOptions($eventName = null) {} /** - * Checks whether the behavior must take action on certain event + * This method receives the notifications from the EventsManager * - * @param string $eventName - * @return bool + * @param string $type + * @param \Phalcon\Mvc\CollectionInterface $model */ - protected function mustTakeAction(string $eventName): bool {} + public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} /** - * This method receives the notifications from the EventsManager + * Acts as fallbacks when a missing method is called on the collection * - * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $method + * @param mixed $arguments */ - public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $method, $arguments = null) {} } diff --git a/src/Phalcon/mvc/collection/BehaviorInterface.php b/src/Phalcon/mvc/collection/BehaviorInterface.php index 0a5b1437..a3d877ba 100644 --- a/src/Phalcon/mvc/collection/BehaviorInterface.php +++ b/src/Phalcon/mvc/collection/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * Calls a method when it's missing in the collection + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, string $method, array $arguments = array()); + public function notify($type, \Phalcon\Mvc\CollectionInterface $collection); /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the collection * - * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection + * @param string $method + * @param mixed $arguments */ - public function notify(string $type, \Phalcon\Mvc\CollectionInterface $collection); + public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, $method, $arguments = null); } diff --git a/src/Phalcon/mvc/collection/Document.php b/src/Phalcon/mvc/collection/Document.php index 94efc018..bbc95b98 100644 --- a/src/Phalcon/mvc/collection/Document.php +++ b/src/Phalcon/mvc/collection/Document.php @@ -12,20 +12,19 @@ class Document implements \Phalcon\Mvc\EntityInterface, \ArrayAccess { /** - * Returns the value of a field using the ArrayAccess interfase + * Checks whether an offset exists in the document * - * @param mixed $index - * @return mixed + * @param int $index + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index) {} /** - * Checks whether an offset exists in the document + * Returns the value of a field using the ArrayAccess interfase * * @param mixed $index - * @return bool */ - public function offsetExists($index): bool {} + public function offsetGet($index) {} /** * Change a value using the ArrayAccess interface @@ -38,39 +37,39 @@ public function offsetSet($index, $value) {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @param mixed $index + * @param string $offset */ - public function offsetUnset($index) {} + public function offsetUnset($offset) {} /** * Reads an attribute value by its name * - * ```php + * * echo $robot->readAttribute("name"); - * ``` + * * * @param string $attribute - * @return mixed|null - */ - public function readAttribute(string $attribute): ? {} - - /** - * Returns the instance as an array representation - * - * @return array + * @return mixed */ - public function toArray(): array {} + public function readAttribute($attribute) {} /** * Writes an attribute value by its name * - * ```php + * * $robot->writeAttribute("name", "Rosey"); - * ``` + * * * @param string $attribute * @param mixed $value */ - public function writeAttribute(string $attribute, $value) {} + public function writeAttribute($attribute, $value) {} + + /** + * Returns the instance as an array representation + * + * @return array + */ + public function toArray() {} } diff --git a/src/Phalcon/mvc/collection/Manager.php b/src/Phalcon/mvc/collection/Manager.php index 8be4af53..dc635c26 100644 --- a/src/Phalcon/mvc/collection/Manager.php +++ b/src/Phalcon/mvc/collection/Manager.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * ```php + * * $di = new \Phalcon\Di(); * * $di->set( @@ -21,36 +21,36 @@ * ); * * $robot = new Robots($di); - * ``` + * */ class Manager implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $behaviors; + protected $_dependencyInjector; - protected $connectionServices; + protected $_initialized; - protected $container; + protected $_lastInitialized; - protected $customEventsManager; + protected $_eventsManager; - protected $eventsManager; + protected $_customEventsManager; - protected $implicitObjectsIds; + protected $_connectionServices; - protected $initialized; + protected $_implicitObjectsIds; - protected $lastInitialized; + protected $_behaviors; - protected $serviceName = 'mongo'; + protected $_serviceName = 'mongo'; @@ -62,138 +62,138 @@ public function getServiceName() {} public function setServiceName($serviceName) {} /** - * Binds a behavior to a model + * Sets the DependencyInjector container * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param \Phalcon\DiInterface $dependencyInjector */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Returns a custom events manager related to a model + * Returns the DependencyInjector container * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return mixed|null + * @return \Phalcon\DiInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): ? {} + public function getDI() {} /** - * Returns the connection related to a model + * Sets the event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Mongo + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Gets a connection service for a specific model + * Returns the internal event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model): string {} + public function getEventsManager() {} /** - * Returns the DependencyInjector container + * Sets a custom events manager for a specific model * - * @return \Phalcon\Di\DiInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getDI(): DiInterface {} + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns the internal event manager + * Returns a custom events manager related to a model * - * @return \Phalcon\Events\ManagerInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @return mixed|null */ - public function getEventsManager(): ManagerInterface {} + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Get the latest initialized model + * Initializes a model in the models manager * - * @return \Phalcon\Mvc\CollectionInterface + * @param \Phalcon\Mvc\CollectionInterface $model */ - public function getLastInitialized(): CollectionInterface {} + public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Checks if a model is using implicit object ids + * Check whether a model is already initialized * - * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $modelName * @return bool */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool {} + public function isInitialized($modelName) {} /** - * Check whether a model is already initialized + * Get the latest initialized model * - * @param string $className - * @return bool + * @return \Phalcon\Mvc\CollectionInterface */ - public function isInitialized(string $className): bool {} + public function getLastInitialized() {} /** - * Initializes a model in the models manager + * Sets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $connectionService */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService) {} /** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented + * Gets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $eventName - * @param mixed $data - * @return bool + * @return string */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $eventName, $data): bool {} + public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets whether a model must use implicit objects ids * - * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model + * @param bool $useImplicitObjectIds */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model) {} + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds) {} /** - * Sets a custom events manager for a specific model + * Checks if a model is using implicit object ids * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return bool */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Sets a connection service for a specific model + * Returns the connection related to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService + * @return \Mongo */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService) {} + public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Sets the DependencyInjector container + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * - * @param \Phalcon\Di\DiInterface $container + * @param string $eventName + * @param \Phalcon\Mvc\CollectionInterface $model */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model) {} /** - * Sets the event manager + * Dispatch an event to the listeners and behaviors + * This method expects that the endpoint listeners/behaviors returns true + * meaning that at least one was implemented * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $eventName + * @param mixed $data + * @return bool */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $eventName, $data) {} /** - * Sets whether a model must use implicit objects ids + * Binds a behavior to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds) {} + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} } diff --git a/src/Phalcon/mvc/collection/ManagerInterface.php b/src/Phalcon/mvc/collection/ManagerInterface.php index 1d575f79..da8edc32 100644 --- a/src/Phalcon/mvc/collection/ManagerInterface.php +++ b/src/Phalcon/mvc/collection/ManagerInterface.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * ```php + * * $di = new \Phalcon\Di(); * * $di->set( @@ -21,96 +21,96 @@ * ); * * $robot = new Robots(di); - * ``` + * */ interface ManagerInterface { /** - * Binds a behavior to a collection + * Sets a custom events manager for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); /** - * Returns the connection related to a model + * Returns a custom events manager related to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return \Phalcon\Events\ManagerInterface */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model): AdapterInterface; + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model); /** - * Returns a custom events manager related to a model + * Initializes a model in the models manager * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Events\ManagerInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): EventsManagerInterface; + public function initialize(\Phalcon\Mvc\CollectionInterface $model); /** - * Get the latest initialized model + * Check whether a model is already initialized * - * @return \Phalcon\Mvc\CollectionInterface + * @param string $modelName + * @return bool */ - public function getLastInitialized(): CollectionInterface; + public function isInitialized($modelName); /** - * Initializes a model in the models manager + * Get the latest initialized model * - * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Phalcon\Mvc\CollectionInterface */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model); + public function getLastInitialized(); /** - * Check whether a model is already initialized + * Sets a connection service for a specific model * - * @param string $className - * @return bool + * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $connectionService */ - public function isInitialized(string $className): bool; + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService); /** - * Checks if a model is using implicit object ids + * Sets if a model must use implicit objects ids * * @param \Phalcon\Mvc\CollectionInterface $model - * @return bool + * @param bool $useImplicitObjectIds */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool; + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds); /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Checks if a model is using implicit object ids * - * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model + * @return bool */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model); + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model); /** - * Sets a custom events manager for a specific model + * Returns the connection related to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return \Phalcon\Db\AdapterInterface */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); + public function getConnection(\Phalcon\Mvc\CollectionInterface $model); /** - * Sets a connection service for a specific model + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService); + public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model); /** - * Sets if a model must use implicit objects ids + * Binds a behavior to a collection * * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds); + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); } diff --git a/src/Phalcon/mvc/collection/behavior/SoftDelete.php b/src/Phalcon/mvc/collection/behavior/SoftDelete.php index 18c2959f..59621249 100644 --- a/src/Phalcon/mvc/collection/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/collection/behavior/SoftDelete.php @@ -17,6 +17,6 @@ class SoftDelete extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/collection/behavior/Timestampable.php b/src/Phalcon/mvc/collection/behavior/Timestampable.php index 09ebb023..d9803981 100644 --- a/src/Phalcon/mvc/collection/behavior/Timestampable.php +++ b/src/Phalcon/mvc/collection/behavior/Timestampable.php @@ -17,6 +17,6 @@ class Timestampable extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 84e98de1..1bffa5d2 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -15,6 +15,6 @@ interface BindModelInterface * * @return string */ - public static function getModelName(): string; + public static function getModelName(); } diff --git a/src/Phalcon/mvc/dispatcher/Exception.php b/src/Phalcon/mvc/dispatcher/Exception.php index b7f06862..685af95f 100644 --- a/src/Phalcon/mvc/dispatcher/Exception.php +++ b/src/Phalcon/mvc/dispatcher/Exception.php @@ -7,7 +7,7 @@ * * Exceptions thrown in Phalcon\Mvc\Dispatcher will use this class */ -class Exception extends \Phalcon\Dispatcher\Exception +class Exception extends \Phalcon\Exception { } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 5c1ba381..8b312466 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -7,7 +7,7 @@ * * Groups Micro-Mvc handlers as controllers * - * ```php + * * $app = new \Phalcon\Mvc\Micro(); * * $collection = new Collection(); @@ -19,185 +19,175 @@ * $collection->get("/posts/edit/{id}", "edit"); * * $app->mount($collection); - * ``` + * */ class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { - protected $handler; + protected $_prefix; - protected $handlers = array(); + protected $_lazy; - protected $lazy; + protected $_handler; - protected $prefix; + protected $_handlers; /** - * Maps a route to a handler that only matches if the HTTP method is DELETE. + * Internal function to add a handler to the group * + * @param string|array $method * @param string $routePattern - * @param callable|string $handler + * @param mixed $handler * @param string $name - * @return CollectionInterface */ - public function delete(string $routePattern, $handler, string $name = null): CollectionInterface {} + protected function _addMap($method, $routePattern, $handler, $name) {} /** - * Maps a route to a handler that only matches if the HTTP method is GET. + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable|string $handler - * @param string $name + * @param string $prefix * @return CollectionInterface */ - public function get(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function setPrefix($prefix) {} /** - * Returns the main handler + * Returns the collection prefix if any * - * @return mixed + * @return string */ - public function getHandler() {} + public function getPrefix() {} /** * Returns the registered handlers * * @return array */ - public function getHandlers(): array {} + public function getHandlers() {} /** - * Returns the collection prefix if any + * Sets the main handler * - * @return string + * @param mixed $handler + * @param boolean $lazy + * @return Collection */ - public function getPrefix(): string {} + public function setHandler($handler, $lazy = false) {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD. + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable|string $handler - * @param string $name + * @param bool $lazy * @return CollectionInterface */ - public function head(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function setLazy($lazy) {} /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy(): bool {} + public function isLazy() {} /** - * Maps a route to a handler. + * Returns the main handler * - * @param string $routePattern - * @param callable|string $handler - * @param string $name - * @return CollectionInterface + * @return mixed */ - public function map(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function getHandler() {} /** - * Maps a route to a handler via methods. - * - * ```php - * $collection->mapVia( - * "/test", - * "indexAction", - * ["POST", "GET"], - * "test" - * ); - * ``` + * Maps a route to a handler * * @param string $routePattern * @param callable $handler - * @param string|array $method * @param string $name - * @return CollectionInterface + * @return Collection */ - public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface {} + public function map($routePattern, $handler, $name = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is - * OPTIONS. + * Maps a route to a handler via methods * * @param string $routePattern - * @param callable|string $handler + * @param callable $handler + * @param string|array $method * @param string $name - * @return CollectionInterface + * @return Collection */ - public function options(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function mapVia($routePattern, $handler, $method, $name = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH. + * Maps a route to a handler that only matches if the HTTP method is GET * * @param string $routePattern - * @param callable|string $handler + * @param callable $handler * @param string $name - * @return CollectionInterface + * @return Collection */ - public function patch(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function get($routePattern, $handler, $name = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is POST. + * Maps a route to a handler that only matches if the HTTP method is POST * * @param string $routePattern - * @param callable|string $handler + * @param callable $handler * @param string $name - * @return CollectionInterface + * @return Collection */ - public function post(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function post($routePattern, $handler, $name = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT. + * Maps a route to a handler that only matches if the HTTP method is PUT * * @param string $routePattern - * @param callable|string $handler + * @param callable $handler * @param string $name - * @return CollectionInterface + * @return Collection */ - public function put(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function put($routePattern, $handler, $name = null) {} /** - * Sets the main handler. + * Maps a route to a handler that only matches if the HTTP method is PATCH * - * @param callable|string $handler - * @param bool $lazy - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return Collection */ - public function setHandler($handler, bool $lazy = false): CollectionInterface {} + public function patch($routePattern, $handler, $name = null) {} /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param bool $lazy - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return Collection */ - public function setLazy(bool $lazy): CollectionInterface {} + public function head($routePattern, $handler, $name = null) {} /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @param string $prefix - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return Collection */ - public function setPrefix(string $prefix): CollectionInterface {} + public function delete($routePattern, $handler, $name = null) {} /** - * Internal function to add a handler to the group. + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * - * @param string|array $method * @param string $routePattern - * @param callable|string $handler - * @param string $name + * @param callable $handler + * @param mixed $name + * @return Collection */ - protected function addMap($method, string $routePattern, $handler, string $name) {} + public function options($routePattern, $handler, $name = null) {} } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index 8254ccc9..ad71ea2e 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -11,62 +11,57 @@ interface CollectionInterface { /** - * Maps a route to a handler that only matches if the HTTP method is DELETE - * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return CollectionInterface - */ - public function delete(string $routePattern, $handler, string $name = null): CollectionInterface; - - /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable $handler - * @param string $name + * @param string $prefix * @return CollectionInterface */ - public function get(string $routePattern, $handler, string $name = null): CollectionInterface; + public function setPrefix($prefix); /** - * Returns the main handler + * Returns the collection prefix if any * - * @return mixed + * @return string */ - public function getHandler(); + public function getPrefix(); /** * Returns the registered handlers * * @return array */ - public function getHandlers(): array; + public function getHandlers(); /** - * Returns the collection prefix if any + * Sets the main handler * - * @return string + * @param mixed $handler + * @param boolean $lazy + * @return \Phalcon\Mvc\Micro\Collection */ - public function getPrefix(): string; + public function setHandler($handler, $lazy = false); /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable $handler - * @param string $name + * @param bool $lazy * @return CollectionInterface */ - public function head(string $routePattern, $handler, string $name = null): CollectionInterface; + public function setLazy($lazy); /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy(): bool; + public function isLazy(); + + /** + * Returns the main handler + * + * @return mixed + */ + public function getHandler(); /** * Maps a route to a handler @@ -74,73 +69,78 @@ public function isLazy(): bool; * @param string $routePattern * @param callable $handler * @param string $name - * @return CollectionInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function map(string $routePattern, $handler, string $name = null): CollectionInterface; + public function map($routePattern, $handler, $name = null); /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Maps a route to a handler that only matches if the HTTP method is GET * * @param string $routePattern * @param callable $handler * @param string $name - * @return CollectionInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function options(string $routePattern, $handler, string $name = null): CollectionInterface; + public function get($routePattern, $handler, $name = null); /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Maps a route to a handler that only matches if the HTTP method is POST * * @param string $routePattern * @param callable $handler * @param string $name - * @return CollectionInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function patch(string $routePattern, $handler, string $name = null): CollectionInterface; + public function post($routePattern, $handler, $name = null); /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Maps a route to a handler that only matches if the HTTP method is PUT * * @param string $routePattern * @param callable $handler * @param string $name - * @return CollectionInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function post(string $routePattern, $handler, string $name = null): CollectionInterface; + public function put($routePattern, $handler, $name = null); /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Maps a route to a handler that only matches if the HTTP method is PATCH * * @param string $routePattern * @param callable $handler * @param string $name - * @return CollectionInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function put(string $routePattern, $handler, string $name = null): CollectionInterface; + public function patch($routePattern, $handler, $name = null); /** - * Sets the main handler + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param mixed $handler - * @param bool $lazy - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setHandler($handler, bool $lazy = false): CollectionInterface; + public function head($routePattern, $handler, $name = null); /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @param bool $lazy - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setLazy(bool $lazy): CollectionInterface; + public function delete($routePattern, $handler, $name = null); /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * - * @param string $prefix - * @return CollectionInterface + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPrefix(string $prefix): CollectionInterface; + public function options($routePattern, $handler, $name = null); } diff --git a/src/Phalcon/mvc/micro/Exception.php b/src/Phalcon/mvc/micro/Exception.php index cd352fc1..1c22e5f4 100644 --- a/src/Phalcon/mvc/micro/Exception.php +++ b/src/Phalcon/mvc/micro/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Mvc\Micro; /** + * Phalcon\Mvc\Micro\Exception + * * Exceptions thrown in Phalcon\Mvc\Micro will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index d7cb0a66..e083b411 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -10,10 +10,13 @@ class LazyLoader { - protected $handler; + protected $_handler; - protected $definition; + protected $_modelBinder; + + + protected $_definition; @@ -24,7 +27,16 @@ public function getDefinition() {} * * @param string $definition */ - public function __construct(string $definition) {} + public function __construct($definition) {} + + /** + * Initializes the internal handler, calling functions on it + * + * @param string $method + * @param array $arguments + * @return mixed + */ + public function __call($method, $arguments) {} /** * Calling __call method @@ -34,6 +46,6 @@ public function __construct(string $definition) {} * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @return mixed */ - public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} + public function callMethod($method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index daa73549..ee19ff86 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -3,6 +3,8 @@ namespace Phalcon\Mvc\Micro; /** + * Phalcon\Mvc\Micro\MiddlewareInterface + * * Allows to implement Phalcon\Mvc\Micro middleware in classes */ interface MiddlewareInterface diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index e3366fdd..4c5bc910 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -9,10 +9,8 @@ */ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface { - /** - * @var array - */ - protected $options; + + protected $_options; /** @@ -20,39 +18,39 @@ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct($options = null) {} /** - * Returns the behavior options related to an event + * Checks whether the behavior must take action on certain event * * @param string $eventName - * @return array + * @return bool */ - protected function getOptions(string $eventName = null) {} + protected function mustTakeAction($eventName) {} /** - * Acts as fallbacks when a missing method is called on the model + * Returns the behavior options related to an event * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments + * @param string $eventName + * @return array */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) {} + protected function getOptions($eventName = null) {} /** - * Checks whether the behavior must take action on certain event + * This method receives the notifications from the EventsManager * - * @param string $eventName - * @return bool + * @param string $type + * @param \Phalcon\Mvc\ModelInterface $model */ - protected function mustTakeAction(string $eventName): bool {} + public function notify($type, \Phalcon\Mvc\ModelInterface $model) {} /** - * This method receives the notifications from the EventsManager + * Acts as fallbacks when a missing method is called on the model * - * @param string $type * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null) {} } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 77ed3cc6..084b49fd 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * Calls a method when it's missing in the model + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()); + public function notify($type, \Phalcon\Mvc\ModelInterface $model); /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the model * - * @param string $type * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null); } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index 086ca316..dbe0bf78 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -37,7 +37,7 @@ class Binder implements \Phalcon\Mvc\Model\BinderInterface * * @return array */ - public function getBoundModels(): array {} + public function getBoundModels() {} /** * Array for original values @@ -47,9 +47,24 @@ public function getOriginalValues() {} /** * Phalcon\Mvc\Model\Binder constructor * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param \Phalcon\Cache\BackendInterface $cache */ - public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct(\Phalcon\Cache\BackendInterface $cache = null) {} + + /** + * Gets cache instance + * + * @param \Phalcon\Cache\BackendInterface $cache + * @return BinderInterface + */ + public function setCache(\Phalcon\Cache\BackendInterface $cache) {} + + /** + * Sets cache instance + * + * @return \Phalcon\Cache\BackendInterface + */ + public function getCache() {} /** * Bind models into params in proper handler @@ -57,10 +72,10 @@ public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = nul * @param object $handler * @param array $params * @param string $cacheKey - * @param string $methodName + * @param mixed $methodName * @return array */ - public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array {} + public function bindToHandler($handler, array $params, $cacheKey, $methodName = null) {} /** * Find the model by param value. @@ -69,14 +84,7 @@ public function bindToHandler($handler, array $params, string $cacheKey, string * @param string $className * @return object|bool */ - protected function findBoundModel($paramValue, string $className): bool {} - - /** - * Sets cache instance - * - * @return \Phalcon\Cache\Adapter\AdapterInterface - */ - public function getCache(): AdapterInterface {} + protected function findBoundModel($paramValue, $className) {} /** * Get params classes from cache by key @@ -84,7 +92,7 @@ public function getCache(): AdapterInterface {} * @param string $cacheKey * @return array|null */ - protected function getParamsFromCache(string $cacheKey): ?array {} + protected function getParamsFromCache($cacheKey) {} /** * Get modified params for handler using reflection @@ -92,17 +100,9 @@ protected function getParamsFromCache(string $cacheKey): ?array {} * @param object $handler * @param array $params * @param string $cacheKey - * @param string $methodName + * @param mixed $methodName * @return array */ - protected function getParamsFromReflection($handler, array $params, string $cacheKey, string $methodName): array {} - - /** - * Gets cache instance - * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @return BinderInterface - */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface {} + protected function getParamsFromReflection($handler, array $params, $cacheKey, $methodName) {} } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index 811f792e..ddd77ec2 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -10,37 +10,37 @@ interface BinderInterface { - /** - * Bind models into params in proper handler - * - * @param object $handler - * @param array $params - * @param string $cacheKey - * @param string $methodName - * @return array - */ - public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array; - /** * Gets active bound models * * @return array */ - public function getBoundModels(): array; + public function getBoundModels(); /** * Gets cache instance * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Cache\BackendInterface */ - public function getCache(): AdapterInterface; + public function getCache(); /** * Sets cache instance * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param \Phalcon\Cache\BackendInterface $cache * @return BinderInterface */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; + public function setCache(\Phalcon\Cache\BackendInterface $cache); + + /** + * Bind models into params in proper handler + * + * @param object $handler + * @param array $params + * @param string $cacheKey + * @param mixed $methodName + * @return array + */ + public function bindToHandler($handler, array $params, $cacheKey, $methodName = null); } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index 99b5a18f..e39987a0 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -6,10 +6,10 @@ * Phalcon\Mvc\Model\Criteria * * This class is used to build the array parameter required by - * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() using an - * object-oriented interface. + * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() + * using an object-oriented interface. * - * ```php + * * $robots = Robots::query() * ->where("type = :type:") * ->andWhere("year < 2000") @@ -17,39 +17,39 @@ * ->limit(5, 10) * ->orderBy("name") * ->execute(); - * ``` + * */ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { - protected $bindParams; + protected $_model; - protected $bindTypes; + protected $_params; - protected $hiddenParamNumber = 0; + protected $_bindParams; - protected $model; + protected $_bindTypes; - protected $params = array(); + protected $_hiddenParamNumber = 0; /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return null|\Phalcon\DiInterface */ - public function getDI(): DiInterface {} + public function getDI() {} /** * Set a model on which the query will be executed @@ -57,14 +57,14 @@ public function getDI(): DiInterface {} * @param string $modelName * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function setModelName(string $modelName): CriteriaInterface {} + public function setModelName($modelName) {} /** * Returns an internal model name on which the criteria will be applied * * @return string */ - public function getModelName(): string {} + public function getModelName() {} /** * Sets the bound parameters in the criteria @@ -74,7 +74,7 @@ public function getModelName(): string {} * @param bool $merge * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bind(array $bindParams, bool $merge = false): CriteriaInterface {} + public function bind(array $bindParams, $merge = false) {} /** * Sets the bind types in the criteria @@ -83,130 +83,94 @@ public function bind(array $bindParams, bool $merge = false): CriteriaInterface * @param array $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bindTypes(array $bindTypes): CriteriaInterface {} + public function bindTypes(array $bindTypes) {} /** * Sets SELECT DISTINCT / SELECT ALL flag * * @param mixed $distinct - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function distinct($distinct): CriteriaInterface {} + public function distinct($distinct) {} /** * Sets the columns to be queried * - * ```php + * * $criteria->columns( * [ * "id", * "name", * ] * ); - * ``` + * * * @param string|array $columns - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function columns($columns): CriteriaInterface {} + public function columns($columns) {} /** * Adds an INNER join to the query * - * ```php - * $criteria->join( - * Robots::class - * ); - * - * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id" - * ); - * - * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * - * $criteria->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r", - * "LEFT" - * ); - * ``` + * + * $criteria->join("Robots"); + * $criteria->join("Robots", "r.id = RobotsParts.robots_id"); + * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r"); + * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); + * * * @param string $model * @param mixed $conditions * @param mixed $alias * @param mixed $type - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface {} + public function join($model, $conditions = null, $alias = null, $type = null) {} /** * Adds an INNER join to the query * - * ```php - * $criteria->innerJoin( - * Robots::class - * ); - * - * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id" - * ); - * - * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * + * $criteria->innerJoin("Robots"); + * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id"); + * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function innerJoin($model, $conditions = null, $alias = null) {} /** * Adds a LEFT join to the query * - * ```php - * $criteria->leftJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * + * $criteria->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function leftJoin($model, $conditions = null, $alias = null) {} /** * Adds a RIGHT join to the query * - * ```php - * $criteria->rightJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * + * $criteria->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function rightJoin($model, $conditions = null, $alias = null) {} /** * Sets the conditions parameter in the criteria @@ -216,7 +180,20 @@ public function rightJoin(string $model, $conditions = null, $alias = null): Cri * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function where($conditions, $bindParams = null, $bindTypes = null) {} + + /** + * Appends a condition to the current conditions using an AND operator (deprecated) + * + * @deprecated 1.0.0 + * @see \Phalcon\Mvc\Model\Criteria::andWhere() + * @param string $conditions + * @param mixed $bindParams + * @param mixed $bindTypes + * @deprecated + * @return Criteria + */ + public function addWhere($conditions, $bindParams = null, $bindTypes = null) {} /** * Appends a condition to the current conditions using an AND operator @@ -226,7 +203,7 @@ public function where(string $conditions, $bindParams = null, $bindTypes = null) * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} /** * Appends a condition to the current conditions using an OR operator @@ -236,61 +213,61 @@ public function andWhere(string $conditions, $bindParams = null, $bindTypes = nu * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} /** * Appends a BETWEEN condition to the current conditions * - * ```php + * * $criteria->betweenWhere("price", 100.25, 200.50); - * ``` + * * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} + public function betweenWhere($expr, $minimum, $maximum) {} /** * Appends a NOT BETWEEN condition to the current conditions * - * ```php + * * $criteria->notBetweenWhere("price", 100.25, 200.50); - * ``` + * * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} + public function notBetweenWhere($expr, $minimum, $maximum) {} /** * Appends an IN condition to the current conditions * - * ```php + * * $criteria->inWhere("id", [1, 2, 3]); - * ``` + * * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function inWhere(string $expr, array $values): CriteriaInterface {} + public function inWhere($expr, array $values) {} /** * Appends a NOT IN condition to the current conditions * - * ```php + * * $criteria->notInWhere("id", [1, 2, 3]); - * ``` + * * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notInWhere(string $expr, array $values): CriteriaInterface {} + public function notInWhere($expr, array $values) {} /** * Adds the conditions parameter to the criteria @@ -298,7 +275,17 @@ public function notInWhere(string $expr, array $values): CriteriaInterface {} * @param string $conditions * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function conditions(string $conditions): CriteriaInterface {} + public function conditions($conditions) {} + + /** + * Adds the order-by parameter to the criteria (deprecated) + * + * @see \Phalcon\Mvc\Model\Criteria::orderBy() + * @param string $orderColumns + * @deprecated + * @return Criteria + */ + public function order($orderColumns) {} /** * Adds the order-by clause to the criteria @@ -306,38 +293,38 @@ public function conditions(string $conditions): CriteriaInterface {} * @param string $orderColumns * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orderBy(string $orderColumns): CriteriaInterface {} + public function orderBy($orderColumns) {} /** * Adds the group-by clause to the criteria * * @param mixed $group - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function groupBy($group): CriteriaInterface {} + public function groupBy($group) {} /** * Adds the having clause to the criteria * * @param mixed $having - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function having($having): CriteriaInterface {} + public function having($having) {} /** * Adds the limit parameter to the criteria. * - * ```php + * * $criteria->limit(100); * $criteria->limit(100, 200); * $criteria->limit("100", "200"); - * ``` + * * * @param int $limit - * @param int $offset + * @param mixed $offset * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function limit(int $limit, int $offset = 0): CriteriaInterface {} + public function limit($limit, $offset = null) {} /** * Adds the "for_update" parameter to the criteria @@ -345,7 +332,7 @@ public function limit(int $limit, int $offset = 0): CriteriaInterface {} * @param bool $forUpdate * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function forUpdate(bool $forUpdate = true): CriteriaInterface {} + public function forUpdate($forUpdate = true) {} /** * Adds the "shared_lock" parameter to the criteria @@ -353,53 +340,54 @@ public function forUpdate(bool $forUpdate = true): CriteriaInterface {} * @param bool $sharedLock * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function sharedLock(bool $sharedLock = true): CriteriaInterface {} + public function sharedLock($sharedLock = true) {} /** * Sets the cache options in the criteria * This method replaces all previously set cache options * * @param array $cache - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public function cache(array $cache): CriteriaInterface {} + public function cache(array $cache) {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getWhere(): ?string {} + public function getWhere() {} /** * Returns the columns to be queried * * @return string|null */ - public function getColumns(): ?string {} + public function getColumns() {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getConditions(): ?string {} + public function getConditions() {} /** - * Returns the limit parameter in the criteria, which will be an integer if - * limit was set without an offset, an array with 'number' and 'offset' keys - * if an offset was set with the limit, or null if limit has not been set. + * Returns the limit parameter in the criteria, which will be + * an integer if limit was set without an offset, + * an array with 'number' and 'offset' keys if an offset was set with the limit, + * or null if limit has not been set. * * @return string|null */ - public function getLimit(): ?string {} + public function getLimit() {} /** * Returns the order clause in the criteria * * @return string|null */ - public function getOrderBy(): ?string {} + public function getOrderBy() {} /** * Returns the group clause in the criteria @@ -416,38 +404,38 @@ public function getHaving() {} * * @return array */ - public function getParams(): array {} + public function getParams() {} /** * Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @param string $modelName * @param array $data * @param string $operator - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return Criteria */ - public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface {} + public static function fromInput(\Phalcon\DiInterface $dependencyInjector, $modelName, array $data, $operator = 'AND') {} /** * Creates a query builder from criteria. * - * ```php + * * $builder = Robots::query() * ->where("type = :type:") * ->bind(["type" => "mechanical"]) * ->createBuilder(); - * ``` + * * * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder(): BuilderInterface {} + public function createBuilder() {} /** * Executes a find using the parameters built with the criteria * * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function execute(): ResultsetInterface {} + public function execute() {} } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index 923f16b8..cd77f6dc 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -11,37 +11,29 @@ interface CriteriaInterface { /** - * Appends a condition to the current conditions using an AND operator + * Set a model on which the query will be executed * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes + * @param string $modelName * @return CriteriaInterface */ - public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; + public function setModelName($modelName); /** - * Appends a BETWEEN condition to the current conditions - * - * ```php - * $criteria->betweenWhere("price", 100.25, 200.50); - * ``` + * Returns an internal model name on which the criteria will be applied * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @return CriteriaInterface + * @return string */ - public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; + public function getModelName(); /** * Sets the bound parameters in the criteria * This method replaces all previously set bound parameters * * @param array $bindParams + * @param bool $merge * @return CriteriaInterface */ - public function bind(array $bindParams): CriteriaInterface; + public function bind(array $bindParams, $merge = false); /** * Sets the bind types in the criteria @@ -50,16 +42,17 @@ public function bind(array $bindParams): CriteriaInterface; * @param array $bindTypes * @return CriteriaInterface */ - public function bindTypes(array $bindTypes): CriteriaInterface; + public function bindTypes(array $bindTypes); /** - * Sets the cache options in the criteria - * This method replaces all previously set cache options + * Sets the conditions parameter in the criteria * - * @param array $cache + * @param string $conditions + * @param mixed $bindParams + * @param mixed $bindTypes * @return CriteriaInterface */ - public function cache(array $cache): CriteriaInterface; + public function where($conditions, $bindParams = null, $bindTypes = null); /** * Adds the conditions parameter to the criteria @@ -67,22 +60,24 @@ public function cache(array $cache): CriteriaInterface; * @param string $conditions * @return CriteriaInterface */ - public function conditions(string $conditions): CriteriaInterface; + public function conditions($conditions); /** - * Sets SELECT DISTINCT / SELECT ALL flag + * Adds the order-by parameter to the criteria * - * @param mixed $distinct + * @param string $orderColumns * @return CriteriaInterface */ - public function distinct($distinct): CriteriaInterface; + public function orderBy($orderColumns); /** - * Executes a find using the parameters built with the criteria + * Sets the limit parameter to the criteria * - * @return ResultsetInterface + * @param int $limit + * @param int $offset + * @return CriteriaInterface */ - public function execute(): ResultsetInterface; + public function limit($limit, $offset = null); /** * Sets the "for_update" parameter to the criteria @@ -90,237 +85,133 @@ public function execute(): ResultsetInterface; * @param bool $forUpdate * @return CriteriaInterface */ - public function forUpdate(bool $forUpdate = true): CriteriaInterface; - - /** - * Returns the columns to be queried - * - * @return string|null - */ - public function getColumns(): ?string; - - /** - * Returns the conditions parameter in the criteria - * - * @return string|null - */ - public function getConditions(): ?string; - - /** - * Returns the group clause in the criteria - */ - public function getGroupBy(); - - /** - * Returns the having clause in the criteria - */ - public function getHaving(); - - /** - * Returns the limit parameter in the criteria, which will be an integer if - * limit was set without an offset, an array with 'number' and 'offset' keys - * if an offset was set with the limit, or null if limit has not been set. - * - * @return string|null - */ - public function getLimit(): ?string; - - /** - * Returns an internal model name on which the criteria will be applied - * - * @return string - */ - public function getModelName(): string; - - /** - * Returns the order parameter in the criteria - * - * @return string|null - */ - public function getOrderBy(): ?string; - - /** - * Returns all the parameters defined in the criteria - * - * @return array - */ - public function getParams(): array; - - /** - * Returns the conditions parameter in the criteria - * - * @return string|null - */ - public function getWhere(): ?string; + public function forUpdate($forUpdate = true); /** - * Adds the group-by clause to the criteria + * Sets the "shared_lock" parameter to the criteria * - * @param mixed $group + * @param bool $sharedLock * @return CriteriaInterface */ - public function groupBy($group): CriteriaInterface; + public function sharedLock($sharedLock = true); /** - * Adds the having clause to the criteria + * Appends a condition to the current conditions using an AND operator * - * @param mixed $having + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes * @return CriteriaInterface */ - public function having($having): CriteriaInterface; + public function andWhere($conditions, $bindParams = null, $bindTypes = null); /** - * Adds an INNER join to the query - * - * ```php - * $criteria->innerJoin( - * Robots::class - * ); - * - * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id" - * ); - * - * $criteria->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * Appends a condition to the current conditions using an OR operator * - * @param string $model - * @param mixed $conditions - * @param mixed $alias + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes * @return CriteriaInterface */ - public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; + public function orWhere($conditions, $bindParams = null, $bindTypes = null); /** - * Appends an IN condition to the current conditions + * Appends a BETWEEN condition to the current conditions * - * ```php - * $criteria->inWhere("id", [1, 2, 3]); - * ``` + * + * $criteria->betweenWhere("price", 100.25, 200.50); + * * * @param string $expr - * @param array $values + * @param mixed $minimum + * @param mixed $maximum * @return CriteriaInterface */ - public function inWhere(string $expr, array $values): CriteriaInterface; + public function betweenWhere($expr, $minimum, $maximum); /** - * Adds a LEFT join to the query - * - * ```php - * $criteria->leftJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * Appends a NOT BETWEEN condition to the current conditions * - * @param string $model - * @param mixed $conditions - * @param mixed $alias - * @return CriteriaInterface - */ - public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; - - /** - * Sets the limit parameter to the criteria + * + * $criteria->notBetweenWhere("price", 100.25, 200.50); + * * - * @param int $limit - * @param int $offset + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum * @return CriteriaInterface */ - public function limit(int $limit, int $offset = 0): CriteriaInterface; + public function notBetweenWhere($expr, $minimum, $maximum); /** - * Appends a NOT BETWEEN condition to the current conditions + * Appends an IN condition to the current conditions * - * ```php - * $criteria->notBetweenWhere("price", 100.25, 200.50); - * ``` + * + * $criteria->inWhere("id", [1, 2, 3]); + * * * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param array $values * @return CriteriaInterface */ - public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; + public function inWhere($expr, array $values); /** * Appends a NOT IN condition to the current conditions * - * ```php + * * $criteria->notInWhere("id", [1, 2, 3]); - * ``` + * * * @param string $expr * @param array $values * @return CriteriaInterface */ - public function notInWhere(string $expr, array $values): CriteriaInterface; + public function notInWhere($expr, array $values); /** - * Adds the order-by parameter to the criteria + * Returns the conditions parameter in the criteria * - * @param string $orderColumns - * @return CriteriaInterface + * @return string|null */ - public function orderBy(string $orderColumns): CriteriaInterface; + public function getWhere(); /** - * Appends a condition to the current conditions using an OR operator + * Returns the conditions parameter in the criteria * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return CriteriaInterface + * @return string|null */ - public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; + public function getConditions(); /** - * Adds a RIGHT join to the query + * Returns the limit parameter in the criteria, which will be + * an integer if limit was set without an offset, + * an array with 'number' and 'offset' keys if an offset was set with the limit, + * or null if limit has not been set. * - * ```php - * $criteria->rightJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` - * - * @param string $model - * @param mixed $conditions - * @param mixed $alias - * @return CriteriaInterface + * @return int|array|null */ - public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; + public function getLimit(); /** - * Set a model on which the query will be executed + * Returns the order parameter in the criteria * - * @param string $modelName - * @return CriteriaInterface + * @return string|null */ - public function setModelName(string $modelName): CriteriaInterface; + public function getOrderBy(); /** - * Sets the "shared_lock" parameter to the criteria + * Returns all the parameters defined in the criteria * - * @param bool $sharedLock - * @return CriteriaInterface + * @return array */ - public function sharedLock(bool $sharedLock = true): CriteriaInterface; + public function getParams(); /** - * Sets the conditions parameter in the criteria + * Executes a find using the parameters built with the criteria * - * @param string $conditions - * @return CriteriaInterface + * @return ResultsetInterface */ - public function where(string $conditions): CriteriaInterface; + public function execute(); } diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index a398bec4..f83fe1c8 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -5,13 +5,12 @@ /** * Phalcon\Mvc\Model\Manager * - * This components controls the initialization of models, keeping record of - * relations between the different models of the application. + * This components controls the initialization of models, keeping record of relations + * between the different models of the application. * - * A ModelsManager is injected to a model via a Dependency Injector/Services - * Container such as Phalcon\Di. + * A ModelsManager is injected to a model via a Dependency Injector/Services Container such as Phalcon\Di. * - * ```php + * * use Phalcon\Di; * use Phalcon\Mvc\Model\Manager as ModelsManager; * @@ -25,142 +24,145 @@ * ); * * $robot = new Robots($di); - * ``` + * */ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $aliases = array(); + protected $_dependencyInjector; - /** - * Models' behaviors - */ - protected $behaviors = array(); - /** - * Belongs to relations - */ - protected $belongsTo = array(); + protected $_eventsManager; - /** - * All the relationships by model - */ - protected $belongsToSingle = array(); + protected $_customEventsManager; - protected $container; + protected $_readConnectionServices; - protected $customEventsManager = array(); - /** - * Does the model use dynamic update, instead of updating all rows? - */ - protected $dynamicUpdate = array(); + protected $_writeConnectionServices; - protected $eventsManager; + protected $_aliases; + + + protected $_modelVisibility = array(); /** * Has many relations */ - protected $hasMany = array(); + protected $_hasMany; /** * Has many relations by model */ - protected $hasManySingle = array(); + protected $_hasManySingle; /** - * Has many-Through relations + * Has one relations */ - protected $hasManyToMany = array(); + protected $_hasOne; /** - * Has many-Through relations by model + * Has one relations by model */ - protected $hasManyToManySingle = array(); + protected $_hasOneSingle; /** - * Has one relations + * Belongs to relations */ - protected $hasOne = array(); + protected $_belongsTo; /** - * Has one relations by model + * All the relationships by model */ - protected $hasOneSingle = array(); + protected $_belongsToSingle; /** - * Mark initialized models + * Has many-Through relations */ - protected $initialized = array(); - - - protected $keepSnapshots = array(); + protected $_hasManyToMany; /** - * Last model initialized + * Has many-Through relations by model */ - protected $lastInitialized; + protected $_hasManyToManySingle; /** - * Last query created/executed + * Mark initialized models */ - protected $lastQuery; + protected $_initialized; - protected $modelVisibility = array(); + protected $_prefix = ''; - protected $prefix = ''; + protected $_sources; - protected $readConnectionServices = array(); + protected $_schemas; + /** + * Models' behaviors + */ + protected $_behaviors; - protected $sources = array(); + /** + * Last model initialized + */ + protected $_lastInitialized; + /** + * Last query created/executed + */ + protected $_lastQuery; - protected $schemas = array(); + /** + * Stores a list of reusable instances + */ + protected $_reusable; - protected $writeConnectionServices = array(); + protected $_keepSnapshots; /** - * Stores a list of reusable instances + * Does the model use dynamic update, instead of updating all rows? */ - protected $reusable = array(); + protected $_dynamicUpdate; + + + protected $_namespaceAliases; /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(): DiInterface {} + public function getDI() {} /** * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return \Phalcon\Mvc\Model\ManagerInterface + * @return Manager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): ManagerInterface {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): EventsManagerInterface {} + public function getEventsManager() {} /** * Sets a custom events manager for a specific model @@ -184,63 +186,73 @@ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function initialize(\Phalcon\Mvc\ModelInterface $model): bool {} + public function initialize(\Phalcon\Mvc\ModelInterface $model) {} /** * Check whether a model is already initialized * - * @param string $className + * @param string $modelName * @return bool */ - public function isInitialized(string $className): bool {} + public function isInitialized($modelName) {} /** * Get last initialized model * * @return \Phalcon\Mvc\ModelInterface */ - public function getLastInitialized(): ModelInterface {} + public function getLastInitialized() {} /** * Loads a model throwing an exception if it doesn't exist * * @param string $modelName + * @param bool $newInstance * @return \Phalcon\Mvc\ModelInterface */ - public function load(string $modelName): ModelInterface {} + public function load($modelName, $newInstance = false) {} /** * Sets the prefix for all model sources. * - * ```php + * * use Phalcon\Mvc\Model\Manager; * - * $di->set( - * "modelsManager", - * function () { - * $modelsManager = new Manager(); + * $di->set("modelsManager", function () { + * $modelsManager = new Manager(); + * $modelsManager->setModelPrefix("wp_"); * - * $modelsManager->setModelPrefix("wp_"); - * - * return $modelsManager; - * } - * ); + * return $modelsManager; + * }); * * $robots = new Robots(); - * * echo $robots->getSource(); // wp_robots - * ``` + * * * @param string $prefix */ - public function setModelPrefix(string $prefix) {} + public function setModelPrefix($prefix) {} /** * Returns the prefix for all model sources. * + * + * use Phalcon\Mvc\Model\Manager; + * + * $di->set("modelsManager", function () { + * $modelsManager = new Manager(); + * $modelsManager->setModelPrefix("wp_"); + * + * return $modelsManager; + * }); + * + * $robots = new Robots(); + * echo $robots->getSource(); // wp_robots + * + * * @return string */ - public function getModelPrefix(): string {} + public function getModelPrefix() {} /** * Sets the mapped source for a model @@ -248,23 +260,23 @@ public function getModelPrefix(): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $source */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) {} + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source) {} /** * Check whether a model property is declared as public. * - * ```php + * * $isPublic = $manager->isVisibleModelProperty( * new Robots(), * "name" * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @param string $property * @return bool */ - final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool {} + public final function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, $property) {} /** * Returns the mapped source for a model @@ -272,7 +284,7 @@ final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} + public function getModelSource(\Phalcon\Mvc\ModelInterface $model) {} /** * Sets the mapped schema for a model @@ -280,7 +292,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) {} + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema) {} /** * Returns the mapped schema for a model @@ -288,7 +300,7 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schem * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model) {} /** * Sets both write and read connection service for a model @@ -296,7 +308,7 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} /** * Sets write connection service for a model @@ -304,7 +316,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} /** * Sets read connection service for a model @@ -312,32 +324,32 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} /** * Returns the connection to read data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return \Phalcon\Db\AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return \Phalcon\Db\AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns the connection to read or write data related to a model depending on the connection services. * * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $connectionServices - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return \Phalcon\Db\AdapterInterface */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface {} + protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} /** * Returns the connection service name used to read data related to a model @@ -345,7 +357,7 @@ protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectio * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns the connection service name used to write data related to a model @@ -353,7 +365,7 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): st * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns the connection service name used to read or write data related to @@ -363,17 +375,16 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): s * @param mixed $connectionServices * @return string */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string {} + public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} /** - * Receives events generated in the models and dispatches them to an - * events-manager if available. Notify the behaviors that are listening in - * the model + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) {} + public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model) {} /** * Dispatch an event to the listeners and behaviors @@ -384,7 +395,7 @@ public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $mode * @param string $eventName * @param mixed $data */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data) {} /** * Binds a behavior to a model @@ -400,7 +411,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) {} + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, $keepSnapshots) {} /** * Checks if a model is keeping snapshots for the queried records @@ -408,7 +419,7 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model) {} /** * Sets if a model must use dynamic update instead of the all-field update @@ -416,7 +427,7 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) {} + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, $dynamicUpdate) {} /** * Checks if a model is using dynamic update instead of all-field update @@ -424,58 +435,78 @@ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynam * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool {} + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model) {} /** * Setup a 1-1 relation between two models * - * @param \Phalcon\Mvc\ModelInterface $model + * @param mixed fields + * @param string referencedModel + * @param mixed referencedFields + * @param array options + * @param \Phalcon\Mvc\Model $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} /** * Setup a relation reverse many to one between two models * - * @param \Phalcon\Mvc\ModelInterface $model + * @param mixed fields + * @param string referencedModel + * @param mixed referencedFields + * @param array options + * @param \Phalcon\Mvc\Model $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} /** * Setup a relation 1-n between two models * + * @param mixed fields + * @param string referencedModel + * @param mixed referencedFields + * @param array options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param mixed $options + * @param $Phalcon\Mvc\ModelInterface model + * @return \Phalcon\Mvc\Model\Relation */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} /** * Setups a relation n-m between two models * + * @param string fields + * @param string intermediateModel + * @param string intermediateFields + * @param string intermediateReferencedFields + * @param string referencedModel + * @param string referencedFields * @param \Phalcon\Mvc\ModelInterface $model - * @param string $fields + * @param mixed $fields * @param string $intermediateModel - * @param string $intermediateFields - * @param string $intermediateReferencedFields + * @param mixed $intermediateFields + * @param mixed $intermediateReferencedFields * @param string $referencedModel - * @param string $referencedFields + * @param mixed $referencedFields * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param $Phalcon\Mvc\ModelInterface model + * @return \Phalcon\Mvc\Model\Relation */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referencedModel, $referencedFields, $options = null) {} /** * Checks whether a model has a belongsTo relation with another model @@ -484,7 +515,7 @@ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, st * @param string $modelRelation * @return bool */ - public function existsBelongsTo(string $modelName, string $modelRelation): bool {} + public function existsBelongsTo($modelName, $modelRelation) {} /** * Checks whether a model has a hasMany relation with another model @@ -493,7 +524,7 @@ public function existsBelongsTo(string $modelName, string $modelRelation): bool * @param string $modelRelation * @return bool */ - public function existsHasMany(string $modelName, string $modelRelation): bool {} + public function existsHasMany($modelName, $modelRelation) {} /** * Checks whether a model has a hasOne relation with another model @@ -502,7 +533,7 @@ public function existsHasMany(string $modelName, string $modelRelation): bool {} * @param string $modelRelation * @return bool */ - public function existsHasOne(string $modelName, string $modelRelation): bool {} + public function existsHasOne($modelName, $modelRelation) {} /** * Checks whether a model has a hasManyToMany relation with another model @@ -511,16 +542,16 @@ public function existsHasOne(string $modelName, string $modelRelation): bool {} * @param string $modelRelation * @return bool */ - public function existsHasManyToMany(string $modelName, string $modelRelation): bool {} + public function existsHasManyToMany($modelName, $modelRelation) {} /** * Returns a relation by its alias * * @param string $modelName * @param string $alias - * @return bool|\Phalcon\Mvc\Model\RelationInterface + * @return bool|\Phalcon\Mvc\Model\Relation */ - public function getRelationByAlias(string $modelName, string $alias) {} + public function getRelationByAlias($modelName, $alias) {} /** * Merge two arrays of find parameters @@ -529,18 +560,18 @@ public function getRelationByAlias(string $modelName, string $alias) {} * @param mixed $findParamsTwo * @return array */ - final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): array {} + protected final function _mergeFindParameters($findParamsOne, $findParamsTwo) {} /** * Helper method to query records based on a relation definition * * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @param string $method * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters - * @param string $method * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, $method, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} /** * Returns a reusable object from the internal list @@ -548,7 +579,7 @@ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relatio * @param string $modelName * @param string $key */ - public function getReusableRecords(string $modelName, string $key) {} + public function getReusableRecords($modelName, $key) {} /** * Stores a reusable record in the internal list @@ -557,7 +588,7 @@ public function getReusableRecords(string $modelName, string $key) {} * @param string $key * @param mixed $records */ - public function setReusableRecords(string $modelName, string $key, $records) {} + public function setReusableRecords($modelName, $key, $records) {} /** * Clears the internal reusable list @@ -567,52 +598,52 @@ public function clearReusableObjects() {} /** * Gets belongsTo related records from a model * + * @param string $method * @param string $modelName - * @param string $modelRelation + * @param mixed $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters - * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} /** * Gets hasMany related records from a model * + * @param string $method * @param string $modelName - * @param string $modelRelation + * @param mixed $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters - * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} /** * Gets belongsTo related records from a model * + * @param string $method * @param string $modelName - * @param string $modelRelation + * @param mixed $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters - * @param string $method * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} /** * Gets all the belongsTo relations defined in a model * - * ```php + * * $relations = $modelsManager->getBelongsTo( * new Robots() * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model) {} /** * Gets hasMany relations defined on a model @@ -620,7 +651,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasMany(\Phalcon\Mvc\ModelInterface $model) {} /** * Gets hasOne relations defined on a model @@ -628,7 +659,7 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasOne(\Phalcon\Mvc\ModelInterface $model) {} /** * Gets hasManyToMany relations defined on a model @@ -636,32 +667,32 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model) {} /** * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model) {} /** * Query all the relationships defined on a model * * @param string $modelName - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelations(string $modelName): array {} + public function getRelations($modelName) {} /** * Query the first relationship defined between two models * * @param string $first * @param string $second - * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] + * @return bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelationsBetween(string $first, string $second) {} + public function getRelationsBetween($first, $second) {} /** * Creates a Phalcon\Mvc\Model\Query without execute it @@ -669,7 +700,7 @@ public function getRelationsBetween(string $first, string $second) {} * @param string $phql * @return \Phalcon\Mvc\Model\QueryInterface */ - public function createQuery(string $phql): QueryInterface {} + public function createQuery($phql) {} /** * Creates a Phalcon\Mvc\Model\Query and execute it @@ -679,7 +710,7 @@ public function createQuery(string $phql): QueryInterface {} * @param mixed $types * @return \Phalcon\Mvc\Model\QueryInterface */ - public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface {} + public function executeQuery($phql, $placeholders = null, $types = null) {} /** * Creates a Phalcon\Mvc\Model\Query\Builder @@ -687,14 +718,37 @@ public function executeQuery(string $phql, $placeholders = null, $types = null): * @param mixed $params * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder($params = null): BuilderInterface {} + public function createBuilder($params = null) {} /** * Returns the last query created or executed in the models manager * * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getLastQuery(): QueryInterface {} + public function getLastQuery() {} + + /** + * Registers shorter aliases for namespaces in PHQL statements + * + * @param string $alias + * @param string $namespaceName + */ + public function registerNamespaceAlias($alias, $namespaceName) {} + + /** + * Returns a real namespace from its alias + * + * @param string $alias + * @return string + */ + public function getNamespaceAlias($alias) {} + + /** + * Returns all the registered namespace aliases + * + * @return array + */ + public function getNamespaceAliases() {} /** * Destroys the current PHQL cache diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 9cd12efc..27bc4070 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -11,362 +11,331 @@ interface ManagerInterface { /** - * Binds a behavior to a model + * Initializes a model in the model manager * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); + public function initialize(\Phalcon\Mvc\ModelInterface $model); /** - * Setup a relation reverse 1-1 between two models + * Sets the mapped source for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param string $source */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source); /** - * Setup a relation 1-n between two models + * Returns the mapped source for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @return string */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function getModelSource(\Phalcon\Mvc\ModelInterface $model); /** - * Setup a 1-1 relation between two models + * Sets the mapped schema for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @param string $schema */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema); /** - * Setups a relation n-m between two models + * Returns the mapped schema for a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $fields - * @param string $intermediateModel - * @param string $intermediateFields - * @param string $intermediateReferencedFields - * @param string $referencedModel - * @param string $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\RelationInterface - */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; - - /** - * Creates a Phalcon\Mvc\Model\Query\Builder - * - * @param string $params - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string */ - public function createBuilder($params = null): BuilderInterface; + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model); /** - * Creates a Phalcon\Mvc\Model\Query without execute it + * Sets both write and read connection service for a model * - * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService */ - public function createQuery(string $phql): QueryInterface; + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); /** - * Creates a Phalcon\Mvc\Model\Query and execute it + * Sets read connection service for a model * - * @param string $phql - * @param array $placeholders - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService */ - public function executeQuery(string $phql, $placeholders = null): QueryInterface; + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); /** - * Checks whether a model has a belongsTo relation with another model + * Returns the connection service name used to read data related to a model * - * @param string $modelName - * @param string $modelRelation - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @return string */ - public function existsBelongsTo(string $modelName, string $modelRelation): bool; + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model); /** - * Checks whether a model has a hasMany relation with another model + * Sets write connection service for a model * - * @param string $modelName - * @param string $modelRelation - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService */ - public function existsHasMany(string $modelName, string $modelRelation): bool; + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); /** - * Checks whether a model has a hasOne relation with another model + * Returns the connection service name used to write data related to a model * - * @param string $modelName - * @param string $modelRelation - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @return string */ - public function existsHasOne(string $modelName, string $modelRelation): bool; + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model); /** - * Checks whether a model has a hasManyToMany relation with another model + * Returns the connection to read data related to a model * - * @param string $modelName - * @param string $modelRelation - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @return \Phalcon\Db\AdapterInterface */ - public function existsHasManyToMany(string $modelName, string $modelRelation): bool; + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model); /** - * Gets belongsTo relations defined on a model + * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Db\AdapterInterface */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model); /** - * Gets belongsTo related records from a model + * Check of a model is already initialized * * @param string $modelName - * @param string $modelRelation - * @param ModelInterface $record - * @param array|string|null $parameters - * @param string|null $method - * @return bool|ResultsetInterface + * @return bool */ - public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function isInitialized($modelName); /** - * Gets hasMany relations defined on a model + * Get last initialized model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; + public function getLastInitialized(); /** - * Gets hasMany related records from a model + * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @param string $modelRelation - * @param ModelInterface $record - * @param array|string|null $parameters - * @param string|null $method - * @return bool|ResultsetInterface + * @param bool $newInstance + * @return \Phalcon\Mvc\ModelInterface */ - public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function load($modelName, $newInstance = false); /** - * Gets hasManyToMany relations defined on a model + * Setup a 1-1 relation between two models * + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); /** - * Gets hasOne relations defined on a model + * Setup a relation reverse 1-1 between two models * + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param mixed $options + * @param $\Phalcon\Mvc\ModelInterface $model + * @return */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); /** - * Gets hasOne relations defined on a model + * Setup a relation 1-n between two models * + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param mixed $options + * @param $\Phalcon\Mvc\ModelInterface $model + * @return */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); /** - * Gets belongsTo related records from a model + * Checks whether a model has a belongsTo relation with another model * * @param string $modelName * @param string $modelRelation - * @param ModelInterface $record - * @param array|string|null $parameters - * @param string|null $method - * @return bool|\Phalcon\Mvc\ModelInterface - */ - public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); - - /** - * Get last initialized model - * - * @return \Phalcon\Mvc\ModelInterface + * @param $string $modelRelation + * @return */ - public function getLastInitialized(): ModelInterface; + public function existsBelongsTo($modelName, $modelRelation); /** - * Returns the last query created or executed in the models manager - * - * @return \Phalcon\Mvc\Model\QueryInterface - */ - public function getLastQuery(): QueryInterface; - - /** - * Returns the mapped schema for a model - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string - */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string; - - /** - * Returns the mapped source for a model + * Checks whether a model has a hasMany relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $modelName + * @param string $modelRelation + * @param $string $modelRelation + * @return */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string; + public function existsHasMany($modelName, $modelRelation); /** - * Returns the connection to read data related to a model + * Checks whether a model has a hasOne relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param string $modelName + * @param string $modelRelation + * @param $string $modelRelation + * @return */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + public function existsHasOne($modelName, $modelRelation); /** - * Returns the connection service name used to read data related to a model + * Gets belongsTo related records from a model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $method + * @param string $modelName + * @param string $modelRelation + * @param \Phalcon\Mvc\Model $record + * @param array $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); /** - * Returns a relation by its alias + * Gets hasMany related records from a model * + * @param string $method * @param string $modelName - * @param string $alias - * @return bool|Relation + * @param string $modelRelation + * @param \Phalcon\Mvc\Model $record + * @param array $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getRelationByAlias(string $modelName, string $alias); + public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); /** - * Helper method to query records based on a relation definition + * Gets belongsTo related records from a model * - * @param \Phalcon\Mvc\Model\RelationInterface $relation - * @param \Phalcon\Mvc\ModelInterface $record - * @param mixed $parameters * @param string $method - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false + * @param string $modelName + * @param string $modelRelation + * @param \Phalcon\Mvc\Model $record + * @param array $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); /** - * Query all the relationships defined on a model + * Gets belongsTo relations defined on a model * - * @param string $modelName - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getRelations(string $modelName): array; + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model); /** - * Query the relations between two models + * Gets hasMany relations defined on a model * - * @param string $first - * @param string $second - * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getRelationsBetween(string $first, string $second); + public function getHasMany(\Phalcon\Mvc\ModelInterface $model); /** - * Returns the connection to write data related to a model + * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return array */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + public function getHasOne(\Phalcon\Mvc\ModelInterface $model); /** - * Returns the connection service name used to write data related to a model + * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model); /** - * Loads a model throwing an exception if it doesn't exist + * Query all the relationships defined on a model * * @param string $modelName - * @return \Phalcon\Mvc\ModelInterface + * @return \Phalcon\Mvc\Model\RelationInterface[] */ - public function load(string $modelName): ModelInterface; + public function getRelations($modelName); /** - * Initializes a model in the model manager + * Query the relations between two models * - * @param \Phalcon\Mvc\ModelInterface $model + * @param string $first + * @param string $second + * @return array */ - public function initialize(\Phalcon\Mvc\ModelInterface $model); + public function getRelationsBetween($first, $second); /** - * Check of a model is already initialized + * Creates a Phalcon\Mvc\Model\Query without execute it * - * @param string $className - * @return bool + * @param string $phql + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function isInitialized(string $className): bool; + public function createQuery($phql); /** - * Checks if a model is keeping snapshots for the queried records + * Creates a Phalcon\Mvc\Model\Query and execute it * - * @param \Phalcon\Mvc\ModelInterface $model - * @return bool + * @param string $phql + * @param array $placeholders + * @param array $types + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool; + public function executeQuery($phql, $placeholders = null, $types = null); /** - * Checks if a model is using dynamic update instead of all-field update + * Creates a Phalcon\Mvc\Model\Query\Builder * - * @param \Phalcon\Mvc\ModelInterface $model - * @return bool + * @param string $params + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; + public function createBuilder($params = null); /** - * Check whether a model property is declared as public. - * - * ```php - * $isPublic = $manager->isVisibleModelProperty( - * new Robots(), - * "name" - * ); - * ``` + * Binds a behavior to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $property - * @return bool + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); /** - * Sets if a model must keep snapshots + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model - * @param bool $keepSnapshots */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); + public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model); /** * Dispatch an event to the listeners and behaviors @@ -376,65 +345,24 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * @param \Phalcon\Mvc\ModelInterface $model * @param string $eventName * @param array $data - * @return bool - */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); - - /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - * - * @param string $eventName - * @param \Phalcon\Mvc\ModelInterface $model - */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model); - - /** - * Sets both write and read connection service for a model - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @return boolean */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data); /** - * Sets read connection service for a model - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService - */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); - - /** - * Sets the mapped schema for a model - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $schema - */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); - - /** - * Sets the mapped source for a model - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $source - */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); - - /** - * Sets write connection service for a model + * Returns the last query created or executed in the models manager * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function getLastQuery(); /** - * Sets if a model must use dynamic update instead of the all-field update + * Returns a relation by its alias * - * @param \Phalcon\Mvc\ModelInterface $model - * @param bool $dynamicUpdate + * @param string $modelName + * @param string $alias + * @return \Phalcon\Mvc\Model\Relation */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); + public function getRelationByAlias($modelName, $alias); } diff --git a/src/Phalcon/mvc/model/Message.php b/src/Phalcon/mvc/model/Message.php new file mode 100644 index 00000000..971efcd9 --- /dev/null +++ b/src/Phalcon/mvc/model/Message.php @@ -0,0 +1,147 @@ + + * use Phalcon\Mvc\Model\Message as Message; + * + * class Robots extends \Phalcon\Mvc\Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $text = "A robot cannot be named Peter"; + * $field = "name"; + * $type = "InvalidValue"; + * + * $message = new Message($text, $field, $type); + * + * $this->appendMessage($message); + * } + * } + * } + * + */ +class Message implements \Phalcon\Mvc\Model\MessageInterface +{ + /** + * @var string + */ + protected $_type; + + /** + * @var string + */ + protected $_message; + + + protected $_field; + + + protected $_model; + + + protected $_code; + + + /** + * @return string + */ + public function getType() {} + + /** + * @return string + */ + public function getMessage() {} + + /** + * Phalcon\Mvc\Model\Message constructor + * + * @param string $message + * @param string|array $field + * @param string $type + * @param \Phalcon\Mvc\ModelInterface $model + * @param int|null $code + */ + public function __construct($message, $field = null, $type = null, $model = null, $code = null) {} + + /** + * Sets message type + * + * @param string $type + * @return Message + */ + public function setType($type) {} + + /** + * Sets verbose message + * + * @param string $message + * @return Message + */ + public function setMessage($message) {} + + /** + * Sets field name related to message + * + * @param mixed $field + * @return Message + */ + public function setField($field) {} + + /** + * Returns field name related to message + */ + public function getField() {} + + /** + * Set the model who generates the message + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return Message + */ + public function setModel(\Phalcon\Mvc\ModelInterface $model) {} + + /** + * Sets code for the message + * + * @param int $code + * @return Message + */ + public function setCode($code) {} + + /** + * Returns the model that produced the message + * + * @return \Phalcon\Mvc\ModelInterface + */ + public function getModel() {} + + /** + * Returns the message code + * + * @return int + */ + public function getCode() {} + + /** + * Magic __toString method returns verbose message + * + * @return string + */ + public function __toString() {} + + /** + * Magic __set_state helps to re-build messages variable exporting + * + * @param array $message + * @return \Phalcon\Mvc\Model\MessageInterface + */ + public static function __set_state(array $message) {} + +} diff --git a/src/Phalcon/mvc/model/MessageInterface.php b/src/Phalcon/mvc/model/MessageInterface.php new file mode 100644 index 00000000..ffdb410e --- /dev/null +++ b/src/Phalcon/mvc/model/MessageInterface.php @@ -0,0 +1,70 @@ +Because Phalcon\Mvc\Model requires meta-data like field names, data types, primary keys, etc. + * this component collect them and store for further querying by Phalcon\Mvc\Model. + * Phalcon\Mvc\Model\MetaData can also use adapters to store temporarily or permanently the meta-data.

* - * A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes: + *

A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes:

* - * ```php + * * $metaData = new \Phalcon\Mvc\Model\MetaData\Memory(); * * $attributes = $metaData->getAttributes( @@ -20,7 +19,7 @@ * ); * * print_r($attributes); - * ``` + * */ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface { @@ -28,431 +27,357 @@ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon const MODELS_ATTRIBUTES = 0; - const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; + const MODELS_PRIMARY_KEY = 1; - const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; + const MODELS_NON_PRIMARY_KEY = 2; - const MODELS_COLUMN_MAP = 0; + const MODELS_NOT_NULL = 3; - const MODELS_DATE_AT = 6; + const MODELS_DATA_TYPES = 4; - const MODELS_DATE_IN = 7; + const MODELS_DATA_TYPES_NUMERIC = 5; - const MODELS_DATA_TYPES = 4; + const MODELS_DATE_AT = 6; - const MODELS_DATA_TYPES_BIND = 9; + const MODELS_DATE_IN = 7; - const MODELS_DATA_TYPES_NUMERIC = 5; + const MODELS_IDENTITY_COLUMN = 8; - const MODELS_DEFAULT_VALUES = 12; + const MODELS_DATA_TYPES_BIND = 9; - const MODELS_EMPTY_STRING_VALUES = 13; + const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; - const MODELS_IDENTITY_COLUMN = 8; + const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; - const MODELS_NON_PRIMARY_KEY = 2; + const MODELS_DEFAULT_VALUES = 12; - const MODELS_NOT_NULL = 3; + const MODELS_EMPTY_STRING_VALUES = 13; - const MODELS_PRIMARY_KEY = 1; + const MODELS_COLUMN_MAP = 0; const MODELS_REVERSE_COLUMN_MAP = 1; - /** - * @var CacheAdapterInterface - */ - protected $adapter; - - protected $columnMap; + protected $_dependencyInjector; - protected $container; + protected $_strategy; - protected $metaData = array(); + protected $_metaData; - protected $strategy; + protected $_columnMap; /** - * Returns table attributes names (fields) - * - * ```php - * print_r( - * $metaData->getAttributes( - * new Robots() - * ) - * ); - * ``` + * Initialize the metadata for certain table * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param mixed $key + * @param mixed $table + * @param mixed $schema */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + protected final function _initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Sets the DependencyInjector container * - * ```php - * print_r( - * $metaData->getAutomaticCreateAttributes( - * new Robots() - * ) - * ); - * ``` + * @param \Phalcon\DiInterface $dependencyInjector + */ + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + + /** + * Returns the DependencyInjector container * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\DiInterface */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getDI() {} /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Set the meta-data extraction strategy * - * ```php - * print_r( - * $metaData->getAutomaticUpdateAttributes( - * new Robots() - * ) - * ); - * ``` + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + */ + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} + + /** + * Return the strategy to obtain the meta-data * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getStrategy() {} /** - * Returns attributes and their bind data types + * Reads the complete meta-data for certain model * - * ```php + * * print_r( - * $metaData->getBindTypes( + * $metaData->readMetaData( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array {} + public final function readMetaData(\Phalcon\Mvc\ModelInterface $model) {} /** - * Returns the column map if any + * Reads meta-data for certain model * - * ```php + * * print_r( - * $metaData->getColumnMap( - * new Robots() + * $metaData->readMetaDataIndex( + * new Robots(), + * 0 * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} + public final function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} /** - * Returns attributes (which have default values) and their default values + * Writes meta-data for certain model using a MODEL_ constant * - * ```php + * * print_r( - * $metaData->getDefaultValues( - * new Robots() + * $metaData->writeColumnMapIndex( + * new Robots(), + * MetaData::MODELS_REVERSE_COLUMN_MAP, + * [ + * "leName" => "name", + * ] * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index + * @param mixed $data */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array {} + public final function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data) {} /** - * Returns attributes and their data types + * Reads the ordered/reversed column map for certain model * - * ```php + * * print_r( - * $metaData->getDataTypes( + * $metaData->readColumnMap( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array {} + public final function readColumnMap(\Phalcon\Mvc\ModelInterface $model) {} /** - * Returns attributes which types are numerical + * Reads column-map information for certain model using a MODEL_ constant * - * ```php + * * print_r( - * $metaData->getDataTypesNumeric( - * new Robots() + * $metaData->readColumnMapIndex( + * new Robots(), + * MetaData::MODELS_REVERSE_COLUMN_MAP * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array - */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface + * @param int $index */ - public function getDI(): DiInterface {} + public final function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} /** - * Returns attributes allow empty strings + * Returns table attributes names (fields) * - * ```php + * * print_r( - * $metaData->getEmptyStringAttributes( + * $metaData->getAttributes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Returns the name of identity field (if one is present) + * Returns an array of fields which are part of the primary key * - * ```php + * * print_r( - * $metaData->getIdentityField( + * $metaData->getPrimaryKeyAttributes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string {} + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns an array of fields which are not part of the primary key * - * ```php + * * print_r( * $metaData->getNonPrimaryKeyAttributes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** * Returns an array of not null attributes * - * ```php + * * print_r( * $metaData->getNotNullAttributes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Returns an array of fields which are part of the primary key + * Returns attributes and their data types * - * ```php + * * print_r( - * $metaData->getPrimaryKeyAttributes( + * $metaData->getDataTypes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Returns the reverse column map if any + * Returns attributes which types are numerical * - * ```php + * * print_r( - * $metaData->getReverseColumnMap( + * $metaData->getDataTypesNumeric( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} - - /** - * Return the strategy to obtain the meta-data - * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface - */ - public function getStrategy(): StrategyInterface {} + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model) {} /** - * Check if a model has certain attribute - * - * ```php - * var_dump( - * $metaData->hasAttribute( - * new Robots(), - * "name" - * ) - * ); - * ``` - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool - */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool {} - - /** - * Checks if the internal meta-data container is empty - * - * ```php - * var_dump( - * $metaData->isEmpty() - * ); - * ``` - * - * @return bool - */ - public function isEmpty(): bool {} - - /** - * Reads metadata from the adapter - * - * @param string $key - * @return array|null - */ - public function read(string $key): ?array {} - - /** - * Reads the ordered/reversed column map for certain model + * Returns the name of identity field (if one is present) * - * ```php + * * print_r( - * $metaData->readColumnMap( + * $metaData->getIdentityField( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|null + * @return string */ - final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array {} + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model) {} /** - * Reads column-map information for certain model using a MODEL_ constant + * Returns attributes and their bind data types * - * ```php + * * print_r( - * $metaData->readColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP + * $metaData->getBindTypes( + * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Reads the complete meta-data for certain model + * Returns attributes that must be ignored from the INSERT SQL generation * - * ```php + * * print_r( - * $metaData->readMetaData( + * $metaData->getAutomaticCreateAttributes( * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array {} + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Reads meta-data for certain model + * Returns attributes that must be ignored from the UPDATE SQL generation * - * ```php + * * print_r( - * $metaData->readMetaDataIndex( - * new Robots(), - * 0 + * $metaData->getAutomaticUpdateAttributes( + * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - */ - final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} - - /** - * Resets internal meta-data in order to regenerate it - * - * ```php - * $metaData->reset(); - * ``` + * @return array */ - public function reset() {} + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** * Set the attributes that must be ignored from the INSERT SQL generation * - * ```php + * * $metaData->setAutomaticCreateAttributes( * new Robots(), * [ * "created_at" => true, * ] * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -462,14 +387,14 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that must be ignored from the UPDATE SQL generation * - * ```php + * * $metaData->setAutomaticUpdateAttributes( * new Robots(), * [ * "modified_at" => true, * ] * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -479,14 +404,14 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that allow empty string values * - * ```php + * * $metaData->setEmptyStringAttributes( * new Robots(), * [ * "name" => true, * ] * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -494,63 +419,107 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} /** - * Sets the DependencyInjector container + * Returns attributes allow empty strings * - * @param \Phalcon\Di\DiInterface $container + * + * print_r( + * $metaData->getEmptyStringAttributes( + * new Robots() + * ) + * ); + * + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model) {} /** - * Set the meta-data extraction strategy + * Returns attributes (which have default values) and their default values * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * + * print_r( + * $metaData->getDefaultValues( + * new Robots() + * ) + * ); + * + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model) {} /** - * Writes the metadata to adapter + * Returns the column map if any + * + * + * print_r( + * $metaData->getColumnMap( + * new Robots() + * ) + * ); + * * - * @param string $key - * @param array $data + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function write(string $key, array $data) {} + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model) {} /** - * Writes meta-data for certain model using a MODEL_ constant + * Returns the reverse column map if any * - * ```php + * * print_r( - * $metaData->writeColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP, - * [ - * "leName" => "name", - * ] + * $metaData->getReverseColumnMap( + * new Robots() * ) * ); - * ``` + * * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * @return array */ - final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) {} + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model) {} /** - * Initialize the metadata for certain table + * Check if a model has certain attribute + * + * + * var_dump( + * $metaData->hasAttribute( + * new Robots(), + * "name" + * ) + * ); + * * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $key - * @param mixed $table - * @param mixed $schema + * @param string $attribute + * @return bool */ - final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute) {} /** - * Throws an exception when the metadata cannot be written + * Checks if the internal meta-data container is empty + * + * + * var_dump( + * $metaData->isEmpty() + * ); + * * - * @param mixed $option + * @return bool + */ + public function isEmpty() {} + + /** + * Resets internal meta-data in order to regenerate it + * + * + * $metaData->reset(); + * */ - private function throwWriteException($option) {} + public function reset() {} } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index bea647c2..502ec310 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -11,225 +11,225 @@ interface MetaDataInterface { /** - * Returns table attributes names (fields) + * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Return the strategy to obtain the meta-data * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getStrategy(); /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Reads meta-data for certain model * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function readMetaData(\Phalcon\Mvc\ModelInterface $model); /** - * Returns attributes and their bind data types + * Reads meta-data for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index + * @return mixed */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array; + public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index); /** - * Returns the column map if any + * Writes meta-data for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index + * @param mixed $data */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array; + public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data); /** - * Returns attributes (which have default values) and their default values + * Reads the ordered/reversed column map for certain model * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array; + public function readColumnMap(\Phalcon\Mvc\ModelInterface $model); /** - * Returns attributes and their data types + * Reads column-map information for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array; + public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index); /** - * Returns attributes which types are numerical + * Returns table attributes names (fields) * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array; + public function getAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Returns attributes allow empty strings + * Returns an array of fields which are part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Returns the name of identity field (if one is present) + * Returns an array of fields which are not part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string; + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Returns an array of fields which are not part of the primary key + * Returns an array of not null attributes * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Returns an array of not null attributes + * Returns attributes and their data types * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model); /** - * Returns an array of fields which are part of the primary key + * Returns attributes which types are numerical * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model); /** - * Returns the reverse column map if any + * Returns the name of identity field (if one is present) * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model); /** - * Return the strategy to obtain the meta-data + * Returns attributes and their bind data types * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getStrategy(): StrategyInterface; + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model); /** - * Check if a model has certain attribute + * Returns attributes that must be ignored from the INSERT SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool + * @return array */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool; + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Checks if the internal meta-data container is empty + * Returns attributes that must be ignored from the UPDATE SQL generation * - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function isEmpty(): bool; + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Reads meta-data from the adapter + * Set the attributes that must be ignored from the INSERT SQL generation * - * @param string $key - * @return array|null + * @param \Phalcon\Mvc\ModelInterface $model + * @param array $attributes */ - public function read(string $key): ?array; + public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Reads the ordered/reversed column map for certain model + * Set the attributes that must be ignored from the UPDATE SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|null + * @param array $attributes */ - public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array; + public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Reads column-map information for certain model using a MODEL_ constant + * Set the attributes that allow empty string values * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @param array $attributes */ - public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index); + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Reads meta-data for certain model + * Returns attributes allow empty strings * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array; + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model); /** - * Reads meta-data for certain model using a MODEL_ constant + * Returns attributes (which have default values) and their default values * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @return mixed + * @return array */ - public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index); + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model); /** - * Resets internal meta-data in order to regenerate it + * Returns the column map if any + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function reset(); + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model); /** - * Set the attributes that must be ignored from the INSERT SQL generation + * Returns the reverse column map if any * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @return array */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model); /** - * Set the attributes that must be ignored from the UPDATE SQL generation + * Check if a model has certain attribute * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @param string $attribute + * @return bool */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute); /** - * Set the attributes that allow empty string values + * Checks if the internal meta-data container is empty * - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @return boolean */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function isEmpty(); /** - * Writes meta-data for certain model using a MODEL_ constant - * - * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * Resets internal meta-data in order to regenerate it */ - public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data); + public function reset(); /** - * Set the meta-data extraction strategy + * Reads meta-data from the adapter * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * @param string $key + * @return array */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); + public function read($key); /** * Writes meta-data to the adapter @@ -237,6 +237,6 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strat * @param string $key * @param array $data */ - public function write(string $key, array $data); + public function write($key, $data); } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index 5d33d3c1..dd7594e6 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -7,7 +7,7 @@ * * This class takes a PHQL intermediate representation and executes it. * - * ```php + * * $phql = "SELECT c.price0.16 AS taxes, c. FROM Cars AS c JOIN Brands AS b * WHERE b.name = :name: ORDER BY c.name"; * @@ -49,107 +49,103 @@ * $resultWithEntries = $queryWithTransaction->execute(); * * $queryWithOutTransaction = new Query($phql, $di); - * $resultWithOutEntries = $queryWithTransaction->execute(); - * ``` + * $resultWithOutEntries = $queryWithTransaction->execute() + * + * */ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { - const TYPE_DELETE = 303; + const TYPE_SELECT = 309; const TYPE_INSERT = 306; - const TYPE_SELECT = 309; - - const TYPE_UPDATE = 300; - protected $ast; - - - protected $bindParams; + const TYPE_DELETE = 303; - protected $bindTypes; + protected $_dependencyInjector; - protected $cache; + protected $_manager; - protected $cacheOptions; + protected $_metaData; - protected $container; + protected $_type; - protected $enableImplicitJoins; + protected $_phql; - protected $intermediate; + protected $_ast; - protected $manager; + protected $_intermediate; - protected $metaData; + protected $_models; - protected $models; + protected $_sqlAliases; - protected $modelsInstances; + protected $_sqlAliasesModels; - protected $nestingLevel = -1; + protected $_sqlModelsAliases; - protected $phql; + protected $_sqlAliasesModelsInstances; - protected $sharedLock; + protected $_sqlColumnAliases; - protected $sqlAliases; + protected $_modelsInstances; - protected $sqlAliasesModels; + protected $_cache; - protected $sqlAliasesModelsInstances; + protected $_cacheOptions; - protected $sqlColumnAliases = array(); + protected $_uniqueRow; - protected $sqlModelsAliases; + protected $_bindParams; - protected $type; + protected $_bindTypes; - protected $uniqueRow; + protected $_enableImplicitJoins; - static protected $_irPhqlCache; + protected $_sharedLock; /** * TransactionInterface so that the query can wrap a transaction * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local - * transaction instead of this one + * however if a model got a transaction set inside it will use the local transaction instead of this one */ protected $_transaction; + static protected $_irPhqlCache; + + /** * TransactionInterface so that the query can wrap a transaction * * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local - * transaction instead of this one + * however if a model got a transaction set inside it will use the local transaction instead of this one */ public function getTransaction() {} @@ -157,50 +153,47 @@ public function getTransaction() {} * Phalcon\Mvc\Model\Query constructor * * @param string $phql - * @param \Phalcon\Di\DiInterface $container - * @param array $options + * @param \Phalcon\DiInterface $dependencyInjector + * @param mixed $options */ - public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) {} + public function __construct($phql = null, \Phalcon\DiInterface $dependencyInjector = null, $options = null) {} /** * Sets the dependency injection container * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the dependency injection container * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(): DiInterface {} + public function getDI() {} /** - * Tells to the query if only the first row in the resultset must be - * returned + * Tells to the query if only the first row in the resultset must be returned * * @param bool $uniqueRow - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setUniqueRow(bool $uniqueRow): QueryInterface {} + public function setUniqueRow($uniqueRow) {} /** - * Check if the query is programmed to get only the first row in the - * resultset + * Check if the query is programmed to get only the first row in the resultset * * @return bool */ - public function getUniqueRow(): bool {} + public function getUniqueRow() {} /** - * Replaces the model's name to its source name in a qualified-name - * expression + * Replaces the model's name to its source name in a qualified-name expression * * @param array $expr * @return array */ - final protected function _getQualified(array $expr): array {} + protected final function _getQualified(array $expr) {} /** * Resolves an expression in a single call argument @@ -208,7 +201,7 @@ final protected function _getQualified(array $expr): array {} * @param array $argument * @return array */ - final protected function _getCallArgument(array $argument): array {} + protected final function _getCallArgument(array $argument) {} /** * Resolves an expression in a single call argument @@ -216,7 +209,7 @@ final protected function _getCallArgument(array $argument): array {} * @param array $expr * @return array */ - final protected function _getCaseExpression(array $expr): array {} + protected final function _getCaseExpression(array $expr) {} /** * Resolves an expression in a single call argument @@ -224,25 +217,25 @@ final protected function _getCaseExpression(array $expr): array {} * @param array $expr * @return array */ - final protected function _getFunctionCall(array $expr): array {} + protected final function _getFunctionCall(array $expr) {} /** * Resolves an expression from its intermediate code into a string * * @param array $expr - * @param bool $quoting + * @param boolean $quoting * @return string */ - final protected function _getExpression(array $expr, bool $quoting = true): string {} + protected final function _getExpression($expr, $quoting = true) {} /** - * Resolves a column from its intermediate representation into an array - * used to determine if the resultset produced is simple or complex + * Resolves a column from its intermediate representation into an array used to determine + * if the resultset produced is simple or complex * * @param array $column * @return array */ - final protected function _getSelectColumn(array $column): array {} + protected final function _getSelectColumn(array $column) {} /** * Resolves a table in a SELECT statement checking if the model exists @@ -251,16 +244,16 @@ final protected function _getSelectColumn(array $column): array {} * @param array $qualifiedName * @return string */ - final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) {} + protected final function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, $qualifiedName) {} /** * Resolves a JOIN clause checking if the associated models exist * * @param \Phalcon\Mvc\Model\ManagerInterface $manager - * @param array $join + * @param mixed $join * @return array */ - final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array {} + protected final function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, $join) {} /** * Resolves a JOIN type @@ -268,7 +261,7 @@ final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, * @param array $join * @return string */ - final protected function _getJoinType(array $join): string {} + protected final function _getJoinType($join) {} /** * Resolves joins involving has-one/belongs-to/has-many relations @@ -280,7 +273,7 @@ final protected function _getJoinType(array $join): string {} * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} + protected final function _getSingleJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} /** * Resolves joins involving many-to-many relations @@ -292,16 +285,15 @@ final protected function _getSingleJoin(string $joinType, $joinSource, string $m * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} + protected final function _getMultiJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} /** - * Processes the JOINs in the query returning an internal representation for - * the database dialect + * Processes the JOINs in the query returning an internal representation for the database dialect * * @param array $select * @return array */ - final protected function _getJoins(array $select): array {} + protected final function _getJoins($select) {} /** * Returns a processed order clause for a SELECT statement @@ -309,7 +301,7 @@ final protected function _getJoins(array $select): array {} * @param array|string $order * @return array */ - final protected function _getOrderClause($order): array {} + protected final function _getOrderClause($order) {} /** * Returns a processed group clause for a SELECT statement @@ -317,7 +309,7 @@ final protected function _getOrderClause($order): array {} * @param array $group * @return array */ - final protected function _getGroupClause(array $group): array {} + protected final function _getGroupClause(array $group) {} /** * Returns a processed limit clause for a SELECT statement @@ -325,104 +317,96 @@ final protected function _getGroupClause(array $group): array {} * @param array $limitClause * @return array */ - final protected function _getLimitClause(array $limitClause): array {} + protected final function _getLimitClause(array $limitClause) {} /** * Analyzes a SELECT intermediate code and produces an array to be executed later * * @param mixed $ast - * @param bool $merge + * @param mixed $merge * @return array */ - final protected function _prepareSelect($ast = null, bool $merge = false): array {} + protected final function _prepareSelect($ast = null, $merge = null) {} /** - * Analyzes an INSERT intermediate code and produces an array to be executed - * later + * Analyzes an INSERT intermediate code and produces an array to be executed later * * @return array */ - final protected function _prepareInsert(): array {} + protected final function _prepareInsert() {} /** - * Analyzes an UPDATE intermediate code and produces an array to be executed - * later + * Analyzes an UPDATE intermediate code and produces an array to be executed later * * @return array */ - final protected function _prepareUpdate(): array {} + protected final function _prepareUpdate() {} /** - * Analyzes a DELETE intermediate code and produces an array to be executed - * later + * Analyzes a DELETE intermediate code and produces an array to be executed later * * @return array */ - final protected function _prepareDelete(): array {} + protected final function _prepareDelete() {} /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang - * generating another intermediate representation that could be executed by - * Phalcon\Mvc\Model\Query + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another + * intermediate representation that could be executed by Phalcon\Mvc\Model\Query * * @return array */ - public function parse(): array {} + public function parse() {} /** * Returns the current cache backend instance * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Cache\BackendInterface */ - public function getCache(): AdapterInterface {} + public function getCache() {} /** - * Executes the SELECT intermediate representation producing a - * Phalcon\Mvc\Model\Resultset + * Executes the SELECT intermediate representation producing a Phalcon\Mvc\Model\Resultset * - * @param array $intermediate - * @param array $bindParams - * @param array $bindTypes + * @param mixed $intermediate + * @param mixed $bindParams + * @param mixed $bindTypes * @param bool $simulate * @return array|\Phalcon\Mvc\Model\ResultsetInterface */ - final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) {} + protected final function _executeSelect($intermediate, $bindParams, $bindTypes, $simulate = false) {} /** - * Executes the INSERT intermediate representation producing a - * Phalcon\Mvc\Model\Query\Status + * Executes the INSERT intermediate representation producing a Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + protected final function _executeInsert($intermediate, $bindParams, $bindTypes) {} /** - * Executes the UPDATE intermediate representation producing a - * Phalcon\Mvc\Model\Query\Status + * Executes the UPDATE intermediate representation producing a Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + protected final function _executeUpdate($intermediate, $bindParams, $bindTypes) {} /** - * Executes the DELETE intermediate representation producing a - * Phalcon\Mvc\Model\Query\Status + * Executes the DELETE intermediate representation producing a Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + protected final function _executeDelete($intermediate, $bindParams, $bindTypes) {} /** - * Query the records on which the UPDATE/DELETE operation will be done + * Query the records on which the UPDATE/DELETE operation well be done * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate @@ -430,7 +414,7 @@ final protected function _executeDelete(array $intermediate, array $bindParams, * @param array $bindTypes * @return \Phalcon\Mvc\Model\ResultsetInterface */ - final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface {} + protected final function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, $intermediate, $bindParams, $bindTypes) {} /** * Executes a parsed PHQL statement @@ -439,7 +423,7 @@ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, * @param array $bindTypes * @return mixed */ - public function execute(array $bindParams = array(), array $bindTypes = array()) {} + public function execute($bindParams = null, $bindTypes = null) {} /** * Executes the query returning the first result @@ -448,100 +432,99 @@ public function execute(array $bindParams = array(), array $bindTypes = array()) * @param array $bindTypes * @return \Phalcon\Mvc\ModelInterface */ - public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface {} + public function getSingleResult($bindParams = null, $bindTypes = null) {} /** * Sets the type of PHQL statement to be executed * * @param int $type - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setType(int $type): QueryInterface {} + public function setType($type) {} /** * Gets the type of PHQL statement executed * * @return int */ - public function getType(): int {} + public function getType() {} /** * Set default bind parameters * * @param array $bindParams * @param bool $merge - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setBindParams(array $bindParams, bool $merge = false): QueryInterface {} + public function setBindParams(array $bindParams, $merge = false) {} /** * Returns default bind params * * @return array */ - public function getBindParams(): array {} + public function getBindParams() {} /** * Set default bind parameters * * @param array $bindTypes * @param bool $merge - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface {} + public function setBindTypes(array $bindTypes, $merge = false) {} /** * Set SHARED LOCK clause * * @param bool $sharedLock - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setSharedLock(bool $sharedLock = false): QueryInterface {} + public function setSharedLock($sharedLock = false) {} /** * Returns default bind types * * @return array */ - public function getBindTypes(): array {} + public function getBindTypes() {} /** * Allows to set the IR to be executed * * @param array $intermediate - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setIntermediate(array $intermediate): QueryInterface {} + public function setIntermediate(array $intermediate) {} /** * Returns the intermediate representation of the PHQL statement * * @return array */ - public function getIntermediate(): array {} + public function getIntermediate() {} /** * Sets the cache parameters of the query * - * @param array $cacheOptions - * @return \Phalcon\Mvc\Model\QueryInterface + * @param mixed $cacheOptions + * @return Query */ - public function cache(array $cacheOptions): QueryInterface {} + public function cache($cacheOptions) {} /** * Returns the current cache options * - * @return array + * @param array */ - public function getCacheOptions(): array {} + public function getCacheOptions() {} /** - * Returns the SQL to be generated by the internal PHQL (only works in - * SELECT statements) + * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) * * @return array */ - public function getSql(): array {} + public function getSql() {} /** * Destroys the internal PHQL cache @@ -549,35 +532,33 @@ public function getSql(): array {} public static function clean() {} /** - * Gets the read connection from the model if there is no transaction set - * inside the query object + * Gets the read connection from the model if there is no transaction set inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Db\AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} + protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} /** - * Gets the write connection from the model if there is no transaction - * inside the query object + * Gets the write connection from the model if there is no transaction inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Db\AdapterInterface */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} + protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} /** * allows to wrap a transaction around all queries * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\Model\QueryInterface + * @return Query */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 80c28f29..197dbcd6 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -11,106 +11,50 @@ interface QueryInterface { /** - * Sets the cache parameters of the query - * - * @param array $cacheOptions - * @return QueryInterface - */ - public function cache(array $cacheOptions): QueryInterface; - - /** - * Executes a parsed PHQL statement - * - * @param array $bindParams - * @param array $bindTypes - * @return mixed - */ - public function execute(array $bindParams = array(), array $bindTypes = array()); - - /** - * Returns default bind params - * - * @return array - */ - public function getBindParams(): array; - - /** - * Returns the current cache options + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another + * intermediate representation that could be executed by Phalcon\Mvc\Model\Query * * @return array */ - public function getCacheOptions(): array; + public function parse(); /** - * Returns default bind types + * Sets the cache parameters of the query * - * @return array + * @param array $cacheOptions + * @return \Phalcon\Mvc\Model\Query */ - public function getBindTypes(): array; + public function cache($cacheOptions); /** - * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) + * Returns the current cache options * - * @return array + * @param array */ - public function getSql(): array; + public function getCacheOptions(); /** - * Executes the query returning the first result + * Tells to the query if only the first row in the resultset must be returned * - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\ModelInterface + * @param boolean $uniqueRow + * @return \Phalcon\Mvc\Model\Query */ - public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface; + public function setUniqueRow($uniqueRow); /** * Check if the query is programmed to get only the first row in the resultset * - * @return bool + * @return boolean */ - public function getUniqueRow(): bool; + public function getUniqueRow(); /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another - * intermediate representation that could be executed by Phalcon\Mvc\Model\Query - * - * @return array - */ - public function parse(): array; - - /** - * Set default bind parameters + * Executes a parsed PHQL statement * * @param array $bindParams - * @param bool $merge - * @return QueryInterface - */ - public function setBindParams(array $bindParams, bool $merge = false): QueryInterface; - - /** - * Set default bind parameters - * * @param array $bindTypes - * @param bool $merge - * @return QueryInterface - */ - public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface; - - /** - * Set SHARED LOCK clause - * - * @param bool $sharedLock - * @return QueryInterface - */ - public function setSharedLock(bool $sharedLock = false): QueryInterface; - - /** - * Tells to the query if only the first row in the resultset must be returned - * - * @param bool $uniqueRow - * @return QueryInterface + * @return mixed */ - public function setUniqueRow(bool $uniqueRow): QueryInterface; + public function execute($bindParams = null, $bindTypes = null); } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index 4284bf95..362d73ff 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -10,52 +10,52 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface { - const ACTION_CASCADE = 2; + const BELONGS_TO = 0; - const ACTION_RESTRICT = 1; + const HAS_ONE = 1; - const BELONGS_TO = 0; + const HAS_MANY = 2; - const HAS_MANY = 2; + const HAS_ONE_THROUGH = 3; const HAS_MANY_THROUGH = 4; - const HAS_ONE = 1; + const NO_ACTION = 0; - const HAS_ONE_THROUGH = 3; + const ACTION_RESTRICT = 1; - const NO_ACTION = 0; + const ACTION_CASCADE = 2; - protected $fields; + protected $_type; - protected $intermediateFields; + protected $_referencedModel; - protected $intermediateModel; + protected $_fields; - protected $intermediateReferencedFields; + protected $_referencedFields; - protected $options; + protected $_intermediateModel; - protected $referencedFields; + protected $_intermediateFields; - protected $referencedModel; + protected $_intermediateReferencedFields; - protected $type; + protected $_options; /** @@ -67,114 +67,114 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface * @param string|array $referencedFields * @param array $options */ - public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) {} + public function __construct($type, $referencedModel, $fields, $referencedFields, $options = null) {} /** - * Returns the fields - * - * @return string|array - */ - public function getFields() {} - - /** - * Returns the foreign key configuration + * Sets the intermediate model data for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string $intermediateReferencedFields */ - public function getForeignKey() {} + public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields) {} /** - * Gets the intermediate fields for has--through relations + * Returns the relation type * - * @return string|array + * @return int */ - public function getIntermediateFields() {} + public function getType() {} /** - * Gets the intermediate model for has--through relations + * Returns the referenced model * * @return string */ - public function getIntermediateModel(): string {} + public function getReferencedModel() {} /** - * Gets the intermediate referenced fields for has--through relations + * Returns the fields * * @return string|array */ - public function getIntermediateReferencedFields() {} + public function getFields() {} /** - * Returns an option by the specified name - * If the option doesn't exist null is returned + * Returns the referenced fields * - * @param string $name + * @return string|array */ - public function getOption(string $name) {} + public function getReferencedFields() {} /** * Returns the options * - * @return array + * @return string|array */ - public function getOptions(): array {} + public function getOptions() {} /** - * Returns parameters that must be always used when the related records are obtained + * Returns an option by the specified name + * If the option doesn't exist null is returned * - * @return array + * @param string $name */ - public function getParams() {} + public function getOption($name) {} /** - * Returns the relation type + * Check whether the relation act as a foreign key * - * @return int + * @return bool */ - public function getType(): int {} + public function isForeignKey() {} /** - * Returns the referenced fields + * Returns the foreign key configuration * * @return string|array */ - public function getReferencedFields() {} + public function getForeignKey() {} /** - * Returns the referenced model + * Returns parameters that must be always used when the related records are obtained * - * @return string + * @return array */ - public function getReferencedModel(): string {} + public function getParams() {} /** - * Check whether the relation act as a foreign key + * Check whether the relation is a 'many-to-many' relation or not * * @return bool */ - public function isForeignKey(): bool {} + public function isThrough() {} /** - * Check whether the relation is a 'many-to-many' relation or not + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * * @return bool */ - public function isThrough(): bool {} + public function isReusable() {} /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Gets the intermediate fields for has--through relations * - * @return bool + * @return string|array */ - public function isReusable(): bool {} + public function getIntermediateFields() {} /** - * Sets the intermediate model data for has--through relations + * Gets the intermediate model for has--through relations * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string $intermediateReferencedFields + * @return string */ - public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) {} + public function getIntermediateModel() {} + + /** + * Gets the intermediate referenced fields for has--through relations + * + * @return string|array + */ + public function getIntermediateReferencedFields() {} } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index 4f018af5..992893d1 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -11,111 +11,104 @@ interface RelationInterface { /** - * Returns the fields + * Sets the intermediate model dat for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string|array $intermediateReferencedFields */ - public function getFields(); + public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields); /** - * Returns the foreign key configuration + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * - * @return string|array + * @return bool */ - public function getForeignKey(); + public function isReusable(); /** - * Gets the intermediate fields for has--through relations + * Returns the relations type * - * @return string|array + * @return int */ - public function getIntermediateFields(); + public function getType(); /** - * Gets the intermediate model for has--through relations + * Returns the referenced model * * @return string */ - public function getIntermediateModel(): string; + public function getReferencedModel(); /** - * Gets the intermediate referenced fields for has--through relations + * Returns the fields * * @return string|array */ - public function getIntermediateReferencedFields(); + public function getFields(); /** - * Returns an option by the specified name - * If the option doesn't exist null is returned + * Returns the referenced fields * - * @param string $name + * @return string|array */ - public function getOption(string $name); + public function getReferencedFields(); /** * Returns the options * - * @return array - */ - public function getOptions(): array; - - /** - * Returns parameters that must be always used when the related records are obtained - * - * @return array + * @return string|array */ - public function getParams(); + public function getOptions(); /** - * Returns the referenced fields + * Returns an option by the specified name + * If the option doesn't exist null is returned * - * @return string|array + * @param string $name */ - public function getReferencedFields(); + public function getOption($name); /** - * Returns the referenced model + * Check whether the relation act as a foreign key * - * @return string + * @return bool */ - public function getReferencedModel(): string; + public function isForeignKey(); /** - * Returns the relations type + * Returns the foreign key configuration * - * @return int + * @return string|array */ - public function getType(): int; + public function getForeignKey(); /** - * Check whether the relation act as a foreign key + * Check whether the relation is a 'many-to-many' relation or not * * @return bool */ - public function isForeignKey(): bool; + public function isThrough(); /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Gets the intermediate fields for has--through relations * - * @return bool + * @return string|array */ - public function isReusable(): bool; + public function getIntermediateFields(); /** - * Check whether the relation is a 'many-to-many' relation or not + * Gets the intermediate model for has--through relations * - * @return bool + * @return string */ - public function isThrough(): bool; + public function getIntermediateModel(); /** - * Sets the intermediate model dat for has--through relations + * Gets the intermediate referenced fields for has--through relations * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string|array $intermediateReferencedFields + * @return string|array */ - public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); + public function getIntermediateReferencedFields(); } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 9ba8f10b..12423705 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -13,9 +13,8 @@ interface ResultInterface /** * Sets the object's state * - * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @param integer $dirtyState */ - public function setDirtyState(int $dirtyState); + public function setDirtyState($dirtyState); } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index 4064c4a7..5e2e1bb8 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -10,7 +10,7 @@ * it will dump all the rows into a big array. Then unserialize will retrieve the rows as they were before * serializing. * - * ```php + * * * // Using a standard foreach * $robots = Robots::find( @@ -41,248 +41,247 @@ * * $robots->next(); * } - * ``` + * */ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { - const HYDRATE_ARRAYS = 1; + const TYPE_RESULT_FULL = 0; - const HYDRATE_OBJECTS = 2; + const TYPE_RESULT_PARTIAL = 1; const HYDRATE_RECORDS = 0; - const TYPE_RESULT_FULL = 0; + const HYDRATE_OBJECTS = 2; - const TYPE_RESULT_PARTIAL = 1; + const HYDRATE_ARRAYS = 1; + /** + * Phalcon\Db\ResultInterface or false for empty resultset + */ + protected $_result = false; - protected $activeRow = null; + protected $_cache; - protected $cache; + protected $_isFresh = true; - protected $count; + protected $_pointer = 0; - protected $errorMessages; + protected $_count; - protected $hydrateMode = 0; + protected $_activeRow = null; - protected $isFresh = true; + protected $_rows = null; - protected $pointer = 0; + protected $_row = null; - protected $row = null; + protected $_errorMessages; - protected $rows = null; - /** - * Phalcon\Db\ResultInterface or false for empty resultset - */ - protected $result; + protected $_hydrateMode = 0; /** * Phalcon\Mvc\Model\Resultset constructor * * @param \Phalcon\Db\ResultInterface|false $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param \Phalcon\Cache\BackendInterface $cache */ - public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct($result, \Phalcon\Cache\BackendInterface $cache = null) {} /** - * Counts how many rows are in the resultset - * - * @return int + * Moves cursor to next row in the resultset */ - final public function count(): int {} + public function next() {} /** - * Deletes every record in the resultset + * Check whether internal resource has rows to fetch * - * @param \Closure $conditionCallback * @return bool */ - public function delete(\Closure $conditionCallback = null): bool {} + public function valid() {} /** - * Filters a resultset returning only those the developer requires - * - * ```php - * $filtered = $robots->filter( - * function ($robot) { - * if ($robot->id < 3) { - * return $robot; - * } - * } - * ); - * ``` + * Gets pointer number of active row in the resultset * - * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] + * @return int|null */ - public function filter($filter): array {} + public function key() {} /** - * Returns the associated cache for the resultset - * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * Rewinds resultset to its beginning */ - public function getCache(): AdapterInterface {} + public final function rewind() {} /** - * Get first row in the resultset + * Changes the internal pointer to a specific position in the resultset. + * Set the new position if required, and then set this->_row * - * @return null|\Phalcon\Mvc\ModelInterface + * @param mixed $position */ - public function getFirst(): ?ModelInterface {} + public final function seek($position) {} /** - * Returns the current hydration mode + * Counts how many rows are in the resultset * * @return int */ - public function getHydrateMode(): int {} + public final function count() {} /** - * Get last row in the resultset + * Checks whether offset exists in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @param mixed $index + * @return bool */ - public function getLast(): ?ModelInterface {} + public function offsetExists($index) {} /** - * Returns the error messages produced by a batch operation + * Gets row in a specific position of the resultset * - * @return array|\Phalcon\Messages\MessageInterface[] + * @param mixed $index + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getMessages(): array {} + public function offsetGet($index) {} /** - * Returns the internal type of data retrieval that the resultset is using + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @return int + * @param int $index + * @param \Phalcon\Mvc\ModelInterface $value */ - public function getType(): int {} + public function offsetSet($index, $value) {} /** - * Tell if the resultset if fresh or an old one cached + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @return bool + * @param mixed $offset */ - public function isFresh(): bool {} + public function offsetUnset($offset) {} /** - * Returns serialised model objects as array for json_encode. - * Calls jsonSerialize on each object if present - * - * ```php - * $robots = Robots::find(); - * - * echo json_encode($robots); - * ``` + * Returns the internal type of data retrieval that the resultset is using * - * @return array + * @return int */ - public function jsonSerialize(): array {} + public function getType() {} /** - * Gets pointer number of active row in the resultset + * Get first row in the resultset * - * @return int|null + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function key(): ?int {} + public function getFirst() {} /** - * Moves cursor to next row in the resultset + * Get last row in the resultset + * + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function next() {} + public function getLast() {} /** - * Gets row in a specific position of the resultset + * Set if the resultset is fresh or an old one cached * - * @param mixed $index - * @return bool|\Phalcon\Mvc\ModelInterface + * @param bool $isFresh + * @return Resultset */ - public function offsetGet($index) {} + public function setIsFresh($isFresh) {} /** - * Checks whether offset exists in the resultset + * Tell if the resultset if fresh or an old one cached * - * @param mixed $index * @return bool */ - public function offsetExists($index): bool {} + public function isFresh() {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Sets the hydration mode in the resultset * - * @param int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @param int $hydrateMode + * @return Resultset */ - public function offsetSet($index, $value) {} + public function setHydrateMode($hydrateMode) {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Returns the current hydration mode * - * @param mixed $offset + * @return int */ - public function offsetUnset($offset) {} + public function getHydrateMode() {} /** - * Rewinds resultset to its beginning + * Returns the associated cache for the resultset + * + * @return \Phalcon\Cache\BackendInterface */ - final public function rewind() {} + public function getCache() {} /** - * Changes the internal pointer to a specific position in the resultset. - * Set the new position if required, and then set this->row + * Returns the error messages produced by a batch operation * - * @param mixed $position + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - final public function seek($position) {} + public function getMessages() {} /** - * Sets the hydration mode in the resultset + * Updates every record in the resultset * - * @param int $hydrateMode - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param array $data + * @param \Closure $conditionCallback + * @return bool */ - public function setHydrateMode(int $hydrateMode): ResultsetInterface {} + public function update($data, \Closure $conditionCallback = null) {} /** - * Set if the resultset is fresh or an old one cached + * Deletes every record in the resultset * - * @param bool $isFresh - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param \Closure $conditionCallback + * @return bool */ - public function setIsFresh(bool $isFresh): ResultsetInterface {} + public function delete(\Closure $conditionCallback = null) {} /** - * Updates every record in the resultset + * Filters a resultset returning only those the developer requires * - * @param array $data - * @param \Closure $conditionCallback - * @return bool + * + * $filtered = $robots->filter( + * function ($robot) { + * if ($robot->id < 3) { + * return $robot; + * } + * } + * ); + * + * + * @param callback $filter + * @return array */ - public function update($data, \Closure $conditionCallback = null): bool {} + public function filter($filter) {} /** - * Check whether internal resource has rows to fetch + * Returns serialised model objects as array for json_encode. + * Calls jsonSerialize on each object if present * - * @return bool + * + * $robots = Robots::find(); + * echo json_encode($robots); + * + * + * @return array */ - public function valid(): bool {} + public function jsonSerialize() {} } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index b36b34d7..f1252a35 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -11,95 +11,46 @@ interface ResultsetInterface { /** - * Deletes every record in the resultset - * - * @param \Closure $conditionCallback - * @return bool - */ - public function delete(\Closure $conditionCallback = null): bool; - - /** - * Filters a resultset returning only those the developer requires - * - * ```php - * $filtered = $robots->filter( - * function ($robot) { - * if ($robot->id < 3) { - * return $robot; - * } - * } - * ); - * ``` - * - * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] - */ - public function filter($filter): array; - - /** - * Returns the associated cache for the resultset + * Returns the internal type of data retrieval that the resultset is using * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return int */ - public function getCache(): AdapterInterface; + public function getType(); /** * Get first row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getFirst(): ?ModelInterface; - - /** - * Returns the current hydration mode - * - * @return int - */ - public function getHydrateMode(): int; + public function getFirst(); /** * Get last row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface - */ - public function getLast(): ?ModelInterface; - - /** - * Returns the error messages produced by a batch operation - * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getMessages(): array; + public function getLast(); /** - * Returns the internal type of data retrieval that the resultset is using + * Set if the resultset is fresh or an old one cached * - * @return int + * @param bool $isFresh */ - public function getType(): int; + public function setIsFresh($isFresh); /** * Tell if the resultset if fresh or an old one cached * * @return bool */ - public function isFresh(): bool; + public function isFresh(); /** - * Sets the hydration mode in the resultset - * - * @param int $hydrateMode - * @return ResultsetInterface - */ - public function setHydrateMode(int $hydrateMode): ResultsetInterface; - - /** - * Set if the resultset is fresh or an old one cached + * Returns the associated cache for the resultset * - * @param bool $isFresh - * @return ResultsetInterface + * @return \Phalcon\Cache\BackendInterface */ - public function setIsFresh(bool $isFresh): ResultsetInterface; + public function getCache(); /** * Returns a complete resultset as an array, if the resultset has a big number of rows @@ -107,15 +58,6 @@ public function setIsFresh(bool $isFresh): ResultsetInterface; * * @return array */ - public function toArray(): array; - - /** - * Updates every record in the resultset - * - * @param array $data - * @param \Closure $conditionCallback - * @return bool - */ - public function update($data, \Closure $conditionCallback = null): bool; + public function toArray(); } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 9d9200e2..4d910b69 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -12,29 +12,28 @@ class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInte { /** - * Serializes the object for json_encode + * Set the current object's state * - * @return array + * @param int $dirtyState + * @return bool */ - public function jsonSerialize(): array {} + public function setDirtyState($dirtyState) {} /** - * Gets a record in a specific position of the row - * - * @param string|int index + * Checks whether offset exists in the row * - * @param mixed $index - * @return mixed + * @param string|int $index + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index) {} /** - * Checks whether offset exists in the row + * Gets a record in a specific position of the row * * @param string|int $index - * @return bool + * @return string|Phalcon\Mvc\ModelInterface */ - public function offsetExists($index): bool {} + public function offsetGet($index) {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface @@ -54,40 +53,39 @@ public function offsetUnset($offset) {} /** * Reads an attribute value by its name * - * ```php + * * echo $robot->readAttribute("name"); - * ``` + * * * @param string $attribute * @return mixed */ - public function readAttribute(string $attribute) {} + public function readAttribute($attribute) {} /** - * Set the current object's state + * Writes an attribute value by its name * - * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * + * $robot->writeAttribute("name", "Rosey"); + * + * + * @param string $attribute + * @param mixed $value */ - public function setDirtyState(int $dirtyState) {} + public function writeAttribute($attribute, $value) {} /** * Returns the instance as an array representation * * @return array */ - public function toArray(): array {} + public function toArray() {} /** - * Writes an attribute value by its name - * - * ```php - * $robot->writeAttribute("name", "Rosey"); - * ``` + * Serializes the object for json_encode * - * @param string $attribute - * @param mixed $value + * @return array */ - public function writeAttribute(string $attribute, $value) {} + public function jsonSerialize() {} } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index 6559b68e..072d0f35 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -5,12 +5,11 @@ /** * Phalcon\Mvc\Model\Transaction * - * Transactions are protective blocks where SQL statements are only permanent if - * they can all succeed as one atomic action. Phalcon\Transaction is intended to - * be used with Phalcon_Model_Base. Phalcon Transactions should be created using - * Phalcon\Transaction\Manager. + * Transactions are protective blocks where SQL statements are only permanent if they can + * all succeed as one atomic action. Phalcon\Transaction is intended to be used with Phalcon_Model_Base. + * Phalcon Transactions should be created using Phalcon\Transaction\Manager. * - * ```php + * * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -44,108 +43,112 @@ * } catch(Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * ``` + * */ class Transaction implements \Phalcon\Mvc\Model\TransactionInterface { - protected $activeTransaction = false; + protected $_connection; - protected $connection; + protected $_activeTransaction = false; - protected $isNewTransaction = true; + protected $_isNewTransaction = true; - protected $manager; + protected $_rollbackOnAbort = false; - protected $messages; + protected $_manager; - protected $rollbackRecord; + protected $_messages; - protected $rollbackOnAbort = false; - - - protected $rollbackThrowException = false; + protected $_rollbackRecord; /** * Phalcon\Mvc\Model\Transaction constructor * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @param bool $autoBegin * @param string $service */ - public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') {} + public function __construct(\Phalcon\DiInterface $dependencyInjector, $autoBegin = false, $service = null) {} + + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} /** * Starts the transaction * * @return bool */ - public function begin(): bool {} + public function begin() {} /** * Commits the transaction * * @return bool */ - public function commit(): bool {} + public function commit() {} /** - * Returns the connection related to transaction + * Rollbacks the transaction * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param mixed $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord + * @return bool */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface {} + public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null) {} /** - * Returns validations messages from last save try + * Returns the connection related to transaction * - * @return array + * @return \Phalcon\Db\AdapterInterface */ - public function getMessages(): array {} + public function getConnection() {} /** - * Checks whether transaction is managed by a transaction manager + * Sets if is a reused transaction or new once * - * @return bool + * @param bool $isNew */ - public function isManaged(): bool {} + public function setIsNewTransaction($isNew) {} /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid(): bool {} + public function setRollbackOnAbort($rollbackOnAbort) {} /** - * Rollbacks the transaction + * Checks whether transaction is managed by a transaction manager * - * @param string $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool {} + public function isManaged() {} /** - * Sets if is a reused transaction or new once + * Returns validations messages from last save try * - * @param bool $isNew + * @return array */ - public function setIsNewTransaction(bool $isNew) {} + public function getMessages() {} /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort(bool $rollbackOnAbort) {} + public function isValid() {} /** * Sets object which generates rollback action @@ -154,19 +157,4 @@ public function setRollbackOnAbort(bool $rollbackOnAbort) {} */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) {} - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} - - /** - * Enables throwing exception - * - * @param bool $status - * @return \Phalcon\Mvc\Model\TransactionInterface - */ - public function throwRollbackException(bool $status): TransactionInterface {} - } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index da437029..d1715dee 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -10,70 +10,76 @@ interface TransactionInterface { + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); + /** * Starts the transaction * * @return bool */ - public function begin(): bool; + public function begin(); /** * Commits the transaction * * @return bool */ - public function commit(): bool; + public function commit(); /** - * Returns connection related to transaction + * Rollbacks the transaction * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @param mixed $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface; + public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null); /** - * Returns validations messages from last save try + * Returns connection related to transaction * - * @return array + * @return \Phalcon\Db\AdapterInterface */ - public function getMessages(): array; + public function getConnection(); /** - * Checks whether transaction is managed by a transaction manager + * Sets if is a reused transaction or new once * - * @return bool + * @param bool $isNew */ - public function isManaged(): bool; + public function setIsNewTransaction($isNew); /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid(): bool; + public function setRollbackOnAbort($rollbackOnAbort); /** - * Rollbacks the transaction + * Checks whether transaction is managed by a transaction manager * - * @param string $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool; + public function isManaged(); /** - * Sets if is a reused transaction or new once + * Returns validations messages from last save try * - * @param bool $isNew + * @return array */ - public function setIsNewTransaction(bool $isNew); + public function getMessages(); /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort(bool $rollbackOnAbort); + public function isValid(); /** * Sets object which generates rollback action @@ -82,19 +88,4 @@ public function setRollbackOnAbort(bool $rollbackOnAbort); */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); - - /** - * Enables throwing exception - * - * @param bool $status - * @return TransactionInterface - */ - public function throwRollbackException(bool $status): TransactionInterface; - } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index e64943b7..f491a341 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -11,32 +11,32 @@ class ValidationFailed extends \Phalcon\Mvc\Model\Exception { - protected $messages; + protected $_model; - protected $model; + protected $_messages; /** * Phalcon\Mvc\Model\ValidationFailed constructor * - * @param \Phalcon\Mvc\ModelInterface $model + * @param Model $model * @param Message[] $validationMessages */ - public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) {} + public function __construct(\Phalcon\Mvc\Model $model, array $validationMessages) {} /** - * Returns the complete group of messages produced in the validation + * Returns the model that generated the messages * - * @return array|Message[] + * @return \Phalcon\Mvc\Model */ - public function getMessages(): array {} + public function getModel() {} /** - * Returns the model that generated the messages + * Returns the complete group of messages produced in the validation * - * @return \Phalcon\Mvc\ModelInterface + * @return Message[] */ - public function getModel(): ModelInterface {} + public function getMessages() {} } diff --git a/src/Phalcon/mvc/model/Validator.php b/src/Phalcon/mvc/model/Validator.php new file mode 100644 index 00000000..a5b17579 --- /dev/null +++ b/src/Phalcon/mvc/model/Validator.php @@ -0,0 +1,73 @@ + + * $metaData = new \Phalcon\Mvc\Model\Metadata\Apc( + * [ + * "prefix" => "my-app-id", + * "lifetime" => 86400, + * ] + * ); + * + * + * @deprecated Deprecated since 3.3.0, will be removed in 4.0.0 + * @see Phalcon\Mvc\Model\Metadata\Apcu + */ +class Apc extends \Phalcon\Mvc\Model\MetaData +{ + + protected $_prefix = ''; + + + protected $_ttl = 172800; + + + protected $_metaData = array(); + + + /** + * Phalcon\Mvc\Model\MetaData\Apc constructor + * + * @param array $options + */ + public function __construct($options = null) {} + + /** + * Reads meta-data from APC + * + * @param string $key + * @return array|null + */ + public function read($key) {} + + /** + * Writes the meta-data to APC + * + * @param string $key + * @param mixed $data + */ + public function write($key, $data) {} + +} diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index b676700d..d27a7af2 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -11,24 +11,48 @@ * * You can query the meta-data by printing apcu_fetch('$PMM$') or apcu_fetch('$PMM$my-app-id') * - * ```php - * $metaData = new \Phalcon\Mvc\Model\MetaData\Apcu( + * + * $metaData = new \Phalcon\Mvc\Model\Metadata\Apcu( * [ * "prefix" => "my-app-id", * "lifetime" => 86400, * ] * ); - * ``` + * */ class Apcu extends \Phalcon\Mvc\Model\MetaData { + protected $_prefix = ''; + + + protected $_ttl = 172800; + + + protected $_metaData = array(); + + /** * Phalcon\Mvc\Model\MetaData\Apcu constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) {} + public function __construct($options = null) {} + + /** + * Reads meta-data from APCu + * + * @param string $key + * @return array|null + */ + public function read($key) {} + + /** + * Writes the meta-data to APCu + * + * @param string $key + * @param mixed $data + */ + public function write($key, $data) {} } diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Files.php similarity index 57% rename from src/Phalcon/mvc/model/metadata/Stream.php rename to src/Phalcon/mvc/model/metadata/Files.php index c14155d6..419c3016 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Files.php @@ -3,22 +3,25 @@ namespace Phalcon\Mvc\Model\MetaData; /** - * Phalcon\Mvc\Model\MetaData\Stream + * Phalcon\Mvc\Model\MetaData\Files * * Stores model meta-data in PHP files. * - * ```php + * * $metaData = new \Phalcon\Mvc\Model\MetaData\Files( * [ * "metaDataDir" => "app/cache/metadata/", * ] * ); - * ``` + * */ -class Stream extends \Phalcon\Mvc\Model\MetaData +class Files extends \Phalcon\Mvc\Model\MetaData { - protected $metaDataDir = './'; + protected $_metaDataDir = './'; + + + protected $_metaData = array(); /** @@ -32,9 +35,9 @@ public function __construct($options = null) {} * Reads meta-data from files * * @param string $key - * @return array|null + * @return mixed */ - public function read(string $key): ?array {} + public function read($key) {} /** * Writes the meta-data to files @@ -42,13 +45,6 @@ public function read(string $key): ?array {} * @param string $key * @param array $data */ - public function write(string $key, array $data) {} - - /** - * Throws an exception when the metadata cannot be written - * - * @param mixed $option - */ - private function throwWriteException($option) {} + public function write($key, $data) {} } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index fad94fe0..ef4640b7 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -8,17 +8,61 @@ * Stores model meta-data in the Memcache. * * By default meta-data is stored for 48 hours (172800 seconds) + * + * + * $metaData = new Phalcon\Mvc\Model\Metadata\Libmemcached( + * [ + * "servers" => [ + * [ + * "host" => "localhost", + * "port" => 11211, + * "weight" => 1, + * ], + * ], + * "client" => [ + * Memcached::OPT_HASH => Memcached::HASH_MD5, + * Memcached::OPT_PREFIX_KEY => "prefix.", + * ], + * "lifetime" => 3600, + * "prefix" => "my_", + * ] + * ); + * */ class Libmemcached extends \Phalcon\Mvc\Model\MetaData { + protected $_ttl = 172800; + + + protected $_memcache = null; + + + protected $_metaData = array(); + + /** * Phalcon\Mvc\Model\MetaData\Libmemcached constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} + public function __construct($options = null) {} + + /** + * Reads metadata from Memcache + * + * @param string $key + * @return array|null + */ + public function read($key) {} + + /** + * Writes the metadata to Memcache + * + * @param string $key + * @param mixed $data + */ + public function write($key, $data) {} /** * Flush Memcache data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Memcache.php b/src/Phalcon/mvc/model/metadata/Memcache.php new file mode 100644 index 00000000..b846ab98 --- /dev/null +++ b/src/Phalcon/mvc/model/metadata/Memcache.php @@ -0,0 +1,64 @@ + + * $metaData = new Phalcon\Mvc\Model\Metadata\Memcache( + * [ + * "prefix" => "my-app-id", + * "lifetime" => 86400, + * "host" => "localhost", + * "port" => 11211, + * "persistent" => false, + * ] + * ); + * + */ +class Memcache extends \Phalcon\Mvc\Model\MetaData +{ + + protected $_ttl = 172800; + + + protected $_memcache = null; + + + protected $_metaData = array(); + + + /** + * Phalcon\Mvc\Model\MetaData\Memcache constructor + * + * @param array $options + */ + public function __construct($options = null) {} + + /** + * Reads metadata from Memcache + * + * @param string $key + * @return array|null + */ + public function read($key) {} + + /** + * Writes the metadata to Memcache + * + * @param string $key + * @param mixed $data + */ + public function write($key, $data) {} + + /** + * Flush Memcache data and resets internal meta-data in order to regenerate it + */ + public function reset() {} + +} diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index c647040f..57966816 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -10,6 +10,9 @@ class Memory extends \Phalcon\Mvc\Model\MetaData { + protected $_metaData = array(); + + /** * Phalcon\Mvc\Model\MetaData\Memory constructor * @@ -21,9 +24,9 @@ public function __construct($options = null) {} * Reads the meta-data from temporal memory * * @param string $key - * @return array|null + * @return array */ - public function read(string $key): ?array {} + public function read($key) {} /** * Writes the meta-data to temporal memory @@ -31,6 +34,6 @@ public function read(string $key): ?array {} * @param string $key * @param array $data */ - public function write(string $key, array $data) {} + public function write($key, $data) {} } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index c32c0bca..6b357aec 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -9,30 +9,55 @@ * * By default meta-data is stored for 48 hours (172800 seconds) * - * ```php - * use Phalcon\Mvc\Model\MetaData\Redis; + * + * use Phalcon\Mvc\Model\Metadata\Redis; * * $metaData = new Redis( * [ * "host" => "127.0.0.1", * "port" => 6379, * "persistent" => 0, + * "statsKey" => "_PHCM_MM", * "lifetime" => 172800, * "index" => 2, * ] * ); - * ``` + * */ class Redis extends \Phalcon\Mvc\Model\MetaData { + protected $_ttl = 172800; + + + protected $_redis = null; + + + protected $_metaData = array(); + + /** * Phalcon\Mvc\Model\MetaData\Redis constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} + public function __construct($options = null) {} + + /** + * Reads metadata from Redis + * + * @param string $key + * @return array|null + */ + public function read($key) {} + + /** + * Writes the metadata to Redis + * + * @param string $key + * @param mixed $data + */ + public function write($key, $data) {} /** * Flush Redis data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Session.php b/src/Phalcon/mvc/model/metadata/Session.php new file mode 100644 index 00000000..048388de --- /dev/null +++ b/src/Phalcon/mvc/model/metadata/Session.php @@ -0,0 +1,50 @@ + + * $metaData = new \Phalcon\Mvc\Model\Metadata\Session( + * [ + * "prefix" => "my-app-id", + * ] + * ); + * + */ +class Session extends \Phalcon\Mvc\Model\MetaData +{ + + protected $_prefix = ''; + + + /** + * Phalcon\Mvc\Model\MetaData\Session constructor + * + * @param array $options + */ + public function __construct($options = null) {} + + /** + * Reads meta-data from $_SESSION + * + * @param string $key + * @return array + */ + public function read($key) {} + + /** + * Writes the meta-data to $_SESSION + * + * @param string $key + * @param array $data + */ + public function write($key, $data) {} + +} diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/StrategyInterface.php index 9ba73ec4..82b2a4d6 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/StrategyInterface.php @@ -2,34 +2,27 @@ namespace Phalcon\Mvc\Model\MetaData; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ + interface StrategyInterface { /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * - * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; + public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * + * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; + public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); } diff --git a/src/Phalcon/mvc/model/metadata/Xcache.php b/src/Phalcon/mvc/model/metadata/Xcache.php new file mode 100644 index 00000000..bffa8d74 --- /dev/null +++ b/src/Phalcon/mvc/model/metadata/Xcache.php @@ -0,0 +1,58 @@ + + * $metaData = new Phalcon\Mvc\Model\Metadata\Xcache( + * [ + * "prefix" => "my-app-id", + * "lifetime" => 86400, + * ] + * ); + * + */ +class Xcache extends \Phalcon\Mvc\Model\MetaData +{ + + protected $_prefix = ''; + + + protected $_ttl = 172800; + + + protected $_metaData = array(); + + + /** + * Phalcon\Mvc\Model\MetaData\Xcache constructor + * + * @param array $options + */ + public function __construct($options = null) {} + + /** + * Reads metadata from XCache + * + * @param string $key + * @return array + */ + public function read($key) {} + + /** + * Writes the metadata to XCache + * + * @param string $key + * @param array $data + */ + public function write($key, $data) {} + +} diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 86f0806f..af7790fa 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -2,33 +2,26 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ + class Annotations implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index 361aa28e..3f61fd1a 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -11,21 +11,21 @@ class Introspection implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index 73447ad5..df6ecfc3 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -7,11 +7,9 @@ * * Helps to create PHQL queries using an OO interface * - * ```php + * * $params = [ - * "models" => [ - * Users::class, - * ], + * "models" => ["Users"], * "columns" => ["id", "name", "status"], * "conditions" => [ * [ @@ -36,176 +34,111 @@ * ]; * * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); - * ``` + * */ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { - protected $bindParams; + protected $_dependencyInjector; - protected $bindTypes; + protected $_columns; - protected $columns; + protected $_models; - protected $conditions; + protected $_joins; + /** + * @deprecated Will be removed in version 4.0.0 + */ + protected $_with; - protected $container; + protected $_conditions; - protected $distinct; + protected $_group; - protected $forUpdate; - /** - * @var array - */ - protected $group; + protected $_having; - protected $having; + protected $_order; - protected $hiddenParamNumber = 0; + protected $_limit; - protected $joins; + protected $_offset; - protected $limit; + protected $_forUpdate; - protected $models; + protected $_sharedLock; - protected $offset; + protected $_bindParams; - protected $order; + protected $_bindTypes; - protected $sharedLock; + protected $_distinct; - /** - * Phalcon\Mvc\Model\Query\Builder constructor - * - * @param mixed $params - * @param \Phalcon\Di\DiInterface $container - */ - public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) {} + protected $_hiddenParamNumber = 0; - /** - * Add a model to take part of the query - * - * ```php - * // Load data from models Robots - * $builder->addFrom( - * Robots::class - * ); - * - * // Load data from model 'Robots' using 'r' as alias in PHQL - * $builder->addFrom( - * Robots::class, - * "r" - * ); - * ``` - * - * @param string $model - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface - */ - public function addFrom(string $model, string $alias = null): BuilderInterface {} /** - * Appends a condition to the current HAVING conditions clause using a AND operator - * - * ```php - * $builder->andHaving("SUM(Robots.price) > 0"); - * - * $builder->andHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] - * ); - * ``` + * Phalcon\Mvc\Model\Query\Builder constructor * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param mixed $params + * @param \Phalcon\DiInterface $dependencyInjector */ - public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function __construct($params = null, \Phalcon\DiInterface $dependencyInjector = null) {} /** - * Appends a condition to the current WHERE conditions using a AND operator - * - * ```php - * $builder->andWhere("name = 'Peter'"); - * - * $builder->andWhere( - * "name = :name: AND id > :id:", - * [ - * "name" => "Peter", - * "id" => 100, - * ] - * ); - * ``` + * Sets the DependencyInjector container * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param \Phalcon\DiInterface $dependencyInjector + * @return Builder */ - public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Automatically escapes identifiers but only if they need to be escaped. + * Returns the DependencyInjector container * - * @param string $identifier - * @return string + * @return \Phalcon\DiInterface */ - final public function autoescape(string $identifier): string {} + public function getDI() {} /** - * Appends a BETWEEN condition to the current HAVING conditions clause + * Sets SELECT DISTINCT / SELECT ALL flag * - * ```php - * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); - * ``` + * + * $builder->distinct("status"); + * $builder->distinct(null); + * * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param mixed $distinct + * @return Builder */ - public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function distinct($distinct) {} /** - * Appends a BETWEEN condition to the current WHERE conditions - * - * ```php - * $builder->betweenWhere("price", 100.25, 200.50); - * ``` + * Returns SELECT DISTINCT / SELECT ALL flag * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return bool */ - public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function getDistinct() {} /** * Sets the columns to be queried * - * ```php + * * $builder->columns("id, name"); * * $builder->columns( @@ -221,100 +154,65 @@ public function betweenWhere(string $expr, $minimum, $maximum, string $operator * "number" => "COUNT()", * ] * ); - * ``` + * * * @param mixed $columns - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function columns($columns): BuilderInterface {} + public function columns($columns) {} /** - * Sets SELECT DISTINCT / SELECT ALL flag - * - * ```php - * $builder->distinct("status"); - * $builder->distinct(null); - * ``` - * - * @param mixed $distinct - * @return \Phalcon\Mvc\Model\Query\BuilderInterface - */ - public function distinct($distinct): BuilderInterface {} - - /** - * Sets a FOR UPDATE clause - * - * ```php - * $builder->forUpdate(true); - * ``` + * Return the columns to be queried * - * @param bool $forUpdate - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string|array */ - public function forUpdate(bool $forUpdate): BuilderInterface {} + public function getColumns() {} /** * Sets the models who makes part of the query * - * ```php - * $builder->from( - * Robots::class - * ); + * + * $builder->from("Robots"); * * $builder->from( * [ - * Robots::class, - * RobotsParts::class, + * "Robots", + * "RobotsParts", * ] * ); * * $builder->from( * [ - * "r" => Robots::class, - * "rp" => RobotsParts::class, + * "r" => "Robots", + * "rp" => "RobotsParts", * ] * ); - * ``` + * * * @param mixed $models - * @return \Phalcon\Mvc\Model\Query\BuilderInterface - */ - public function from($models): BuilderInterface {} - - /** - * Returns default bind params - * - * @return array + * @return Builder */ - public function getBindParams(): array {} + public function from($models) {} /** - * Returns default bind types + * Add a model to take part of the query * - * @return array - */ - public function getBindTypes(): array {} - - /** - * Return the columns to be queried + * NOTE: The third parameter $with is deprecated and will be removed in future releases. * - * @return string|array - */ - public function getColumns() {} - - /** - * Returns the DependencyInjector container + * + * // Load data from models Robots + * $builder->addFrom("Robots"); * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns SELECT DISTINCT / SELECT ALL flag + * // Load data from model 'Robots' using 'r' as alias in PHQL + * $builder->addFrom("Robots", "r"); + * * - * @return bool + * @param mixed $model + * @param mixed $alias + * @param mixed $with + * @return Builder */ - public function getDistinct(): bool {} + public function addFrom($model, $alias = null, $with = null) {} /** * Return the models who makes part of the query @@ -324,439 +222,466 @@ public function getDistinct(): bool {} public function getFrom() {} /** - * Returns the GROUP BY clause + * Adds an :type: join (by default type - INNER) to the query * - * @return array - */ - public function getGroupBy(): array {} - - /** - * Return the current having clause + * + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->join("Robots"); * - * @return string - */ - public function getHaving(): string {} - - /** - * Return join parts of the query + * // Inner Join model 'Robots' specifying conditions + * $builder->join("Robots", "Robots.id = RobotsParts.robots_id"); * - * @return array - */ - public function getJoins(): array {} - - /** - * Returns the current LIMIT clause + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r"); * - * @return string|array - */ - public function getLimit() {} - - /** - * Returns the models involved in the query + * // Left Join model 'Robots' specifying conditions, alias and type of join + * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); + * * - * @return string|array|null + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return Builder */ - public function getModels() {} + public function join($model, $conditions = null, $alias = null, $type = null) {} /** - * Returns the current OFFSET clause + * Adds an INNER join to the query + * + * + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->innerJoin("Robots"); * - * @return int + * // Inner Join model 'Robots' specifying conditions + * $builder->innerJoin("Robots", "Robots.id = RobotsParts.robots_id"); + * + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * + * + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return Builder */ - public function getOffset(): int {} + public function innerJoin($model, $conditions = null, $alias = null) {} /** - * Returns the set ORDER BY clause + * Adds a LEFT join to the query * - * @return string|array + * + * $builder->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * + * + * @param string $model + * @param string $conditions + * @param string $alias + * @return Builder */ - public function getOrderBy() {} + public function leftJoin($model, $conditions = null, $alias = null) {} /** - * Returns a PHQL statement built based on the builder parameters + * Adds a RIGHT join to the query * - * @return string + * + * $builder->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); + * + * + * @param string $model + * @param string $conditions + * @param string $alias + * @return Builder */ - final public function getPhql(): string {} + public function rightJoin($model, $conditions = null, $alias = null) {} /** - * Returns the query built + * Return join parts of the query * - * @return \Phalcon\Mvc\Model\QueryInterface + * @return array */ - public function getQuery(): QueryInterface {} + public function getJoins() {} /** - * Return the conditions for the query + * Sets the query WHERE conditions * - * @return string|array + * + * $builder->where(100); + * + * $builder->where("name = 'Peter'"); + * + * $builder->where( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * + * + * @param mixed $conditions + * @param array $bindParams + * @param array $bindTypes + * @return Builder */ - public function getWhere() {} + public function where($conditions, $bindParams = null, $bindTypes = null) {} /** - * Sets a GROUP BY clause + * Appends a condition to the current WHERE conditions using a AND operator * - * ```php - * $builder->groupBy( + * + * $builder->andWhere("name = 'Peter'"); + * + * $builder->andWhere( + * "name = :name: AND id > :id:", * [ - * "Robots.name", + * "name" => "Peter", + * "id" => 100, * ] * ); - * ``` + * * - * @param string|array $group - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return Builder */ - public function groupBy($group): BuilderInterface {} + public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} /** - * Sets the HAVING condition clause + * Appends a condition to the current conditions using an OR operator * - * ```php - * $builder->having("SUM(Robots.price) > 0"); + * + * $builder->orWhere("name = 'Peter'"); * - * $builder->having( - * "SUM(Robots.price) > :sum:", + * $builder->orWhere( + * "name = :name: AND id > :id:", * [ - * "sum" => 100, + * "name" => "Peter", + * "id" => 100, * ] * ); - * ``` + * * - * @param mixed $conditions + * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} /** - * Appends an IN condition to the current HAVING conditions clause + * Appends a BETWEEN condition to the current WHERE conditions * - * ```php - * $builder->inHaving("SUM(Robots.price)", [100, 200]); - * ``` + * + * $builder->betweenWhere("price", 100.25, 200.50); + * * * @param string $expr - * @param array $values + * @param mixed $minimum + * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Adds an INNER join to the query + * Appends a NOT BETWEEN condition to the current WHERE conditions * - * ```php - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->innerJoin( - * Robots::class - * ); + * + * $builder->notBetweenWhere("price", 100.25, 200.50); + * * - * // Inner Join model 'Robots' specifying conditions - * $builder->innerJoin( - * Robots::class, - * "Robots.id = RobotsParts.robots_id" - * ); + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return Builder + */ + public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + + /** + * Appends an IN condition to the current WHERE conditions * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->innerJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); - * ``` + * + * $builder->inWhere("id", [1, 2, 3]); + * * - * @param string $model - * @param string $conditions - * @param string $alias + * @param string $expr + * @param array $values + * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Appends an IN condition to the current WHERE conditions + * Appends a NOT IN condition to the current WHERE conditions * - * ```php - * $builder->inWhere( - * "id", - * [1, 2, 3] - * ); - * ``` + * + * $builder->notInWhere("id", [1, 2, 3]); + * * * @param string $expr * @param array $values * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Adds an :type: join (by default type - INNER) to the query + * Return the conditions for the query * - * ```php - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->join( - * Robots::class - * ); + * @return string|array + */ + public function getWhere() {} + + /** + * Sets an ORDER BY condition clause * - * // Inner Join model 'Robots' specifying conditions - * $builder->join( - * Robots::class, - * "Robots.id = RobotsParts.robots_id" - * ); + * + * $builder->orderBy("Robots.name"); + * $builder->orderBy(["1", "Robots.name"]); + * $builder->orderBy(["Robots.name DESC"]); + * * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" - * ); + * @param string|array $orderBy + * @return Builder + */ + public function orderBy($orderBy) {} + + /** + * Returns the set ORDER BY clause * - * // Left Join model 'Robots' specifying conditions, alias and type of join - * $builder->join( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r", - * "LEFT" + * @return string|array + */ + public function getOrderBy() {} + + /** + * Sets the HAVING condition clause + * + * + * $builder->having("SUM(Robots.price) > 0"); + * + * $builder->having( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] * ); - * ``` + * * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param mixed $conditions + * @param array $bindParams + * @param array $bindTypes + * @return Builder */ - public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface {} + public function having($conditions, $bindParams = null, $bindTypes = null) {} /** - * Adds a LEFT join to the query + * Appends a condition to the current HAVING conditions clause using a AND operator + * + * + * $builder->andHaving("SUM(Robots.price) > 0"); * - * ```php - * $builder->leftJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * $builder->andHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] * ); - * ``` + * * - * @param string $model * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param array $bindParams + * @param array $bindTypes + * @return Builder */ - public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function andHaving($conditions, $bindParams = null, $bindTypes = null) {} /** - * Sets a LIMIT clause, optionally an offset clause + * Appends a condition to the current HAVING conditions clause using an OR operator * - * ```php - * $builder->limit(100); - * $builder->limit(100, 20); - * $builder->limit("100", "20"); - * ``` + * + * $builder->orHaving("SUM(Robots.price) > 0"); * - * @param int $limit - * @param mixed $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * $builder->orHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] + * ); + * + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return Builder */ - public function limit(int $limit, $offset = null): BuilderInterface {} + public function orHaving($conditions, $bindParams = null, $bindTypes = null) {} /** - * Appends a NOT BETWEEN condition to the current HAVING conditions clause + * Appends a BETWEEN condition to the current HAVING conditions clause * - * ```php - * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); - * ``` + * + * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); + * * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function betweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Appends a NOT BETWEEN condition to the current WHERE conditions + * Appends a NOT BETWEEN condition to the current HAVING conditions clause * - * ```php - * $builder->notBetweenWhere("price", 100.25, 200.50); - * ``` + * + * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); + * * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notBetweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Appends a NOT IN condition to the current HAVING conditions clause + * Appends an IN condition to the current HAVING conditions clause * - * ```php - * $builder->notInHaving("SUM(Robots.price)", [100, 200]); - * ``` + * + * $builder->inHaving("SUM(Robots.price)", [100, 200]); + * * * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function inHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Appends a NOT IN condition to the current WHERE conditions + * Appends a NOT IN condition to the current HAVING conditions clause * - * ```php - * $builder->notInWhere("id", [1, 2, 3]); - * ``` + * + * $builder->notInHaving("SUM(Robots.price)", [100, 200]); + * * * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notInHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} /** - * Sets an OFFSET clause - * - * ```php - * $builder->offset(30); - * ``` + * Return the current having clause * - * @param int $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string */ - public function offset(int $offset): BuilderInterface {} + public function getHaving() {} /** - * Sets an ORDER BY condition clause + * Sets a FOR UPDATE clause * - * ```php - * $builder->orderBy("Robots.name"); - * $builder->orderBy(["1", "Robots.name"]); - * $builder->orderBy(["Robots.name DESC"]); - * ``` + * + * $builder->forUpdate(true); + * * - * @param string|array $orderBy - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param bool $forUpdate + * @return Builder */ - public function orderBy($orderBy): BuilderInterface {} + public function forUpdate($forUpdate) {} /** - * Appends a condition to the current HAVING conditions clause using an OR operator + * Sets a LIMIT clause, optionally an offset clause * - * ```php - * $builder->orHaving("SUM(Robots.price) > 0"); + * + * $builder->limit(100); + * $builder->limit(100, 20); + * $builder->limit("100", "20"); + * * - * $builder->orHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] - * ); - * ``` + * @param int $limit + * @param mixed $offset + * @return Builder + */ + public function limit($limit, $offset = null) {} + + /** + * Returns the current LIMIT clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string|array */ - public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function getLimit() {} /** - * Appends a condition to the current conditions using an OR operator + * Sets an OFFSET clause * - * ```php - * $builder->orWhere("name = 'Peter'"); + * + * $builder->offset(30); + * * - * $builder->orWhere( - * "name = :name: AND id > :id:", - * [ - * "name" => "Peter", - * "id" => 100, - * ] - * ); - * ``` + * @param int $offset + * @return Builder + */ + public function offset($offset) {} + + /** + * Returns the current OFFSET clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string|array */ - public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function getOffset() {} /** - * Adds a RIGHT join to the query + * Sets a GROUP BY clause * - * ```php - * $builder->rightJoin( - * Robots::class, - * "r.id = RobotsParts.robots_id", - * "r" + * + * $builder->groupBy( + * [ + * "Robots.name", + * ] * ); - * ``` + * * - * @param string $model - * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string|array $group + * @return Builder */ - public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function groupBy($group) {} /** - * Set default bind parameters + * Returns the GROUP BY clause * - * @param array $bindParams - * @param bool $merge - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string */ - public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface {} + public function getGroupBy() {} /** - * Set default bind types + * Returns a PHQL statement built based on the builder parameters * - * @param array $bindTypes - * @param bool $merge - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string */ - public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface {} + public final function getPhql() {} /** - * Sets the DependencyInjector container + * Returns the query built * - * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setDI(\Phalcon\Di\DiInterface $container): BuilderInterface {} + public function getQuery() {} /** - * Sets the query WHERE conditions - * - * ```php - * $builder->where(100); - * - * $builder->where("name = 'Peter'"); - * - * $builder->where( - * "name = :name: AND id > :id:", - * [ - * "name" => "Peter", - * "id" => 100, - * ] - * ); - * ``` + * Automatically escapes identifiers but only if they need to be escaped. * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $identifier + * @return string */ - public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + final public function autoescape($identifier) {} /** * Appends a BETWEEN condition @@ -766,32 +691,32 @@ public function where(string $conditions, array $bindParams = array(), array $bi * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} + protected function _conditionBetween($clause, $operator, $expr, $minimum, $maximum) {} /** - * Appends an IN condition + * Appends a NOT BETWEEN condition * * @param string $clause * @param string $operator * @param string $expr - * @param array $values - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param mixed $minimum + * @param mixed $maximum + * @return Builder */ - protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} + protected function _conditionNotBetween($clause, $operator, $expr, $minimum, $maximum) {} /** - * Appends a NOT BETWEEN condition + * Appends an IN condition * * @param string $clause * @param string $operator * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param array $values + * @return Builder */ - protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} + protected function _conditionIn($clause, $operator, $expr, array $values) {} /** * Appends a NOT IN condition @@ -800,8 +725,8 @@ protected function conditionNotBetween(string $clause, string $operator, string * @param string $operator * @param string $expr * @param array $values - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return Builder */ - protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} + protected function _conditionNotIn($clause, $operator, $expr, array $values) {} } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index 636c17c6..ced90250 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -10,110 +10,43 @@ interface BuilderInterface { - const OPERATOR_AND = 'and'; - - const OPERATOR_OR = 'or'; - /** - * Add a model to take part of the query - * - * @param string $model - * @param string $alias - * @return BuilderInterface - */ - public function addFrom(string $model, string $alias = null): BuilderInterface; - - /** - * Appends a condition to the current conditions using a AND operator - * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return BuilderInterface - */ - public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + const OPERATOR_AND = 'and'; - /** - * Appends a BETWEEN condition to the current conditions - * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return BuilderInterface - */ - public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** * Sets the columns to be queried * * @param string|array $columns - * @return BuilderInterface - */ - public function columns($columns): BuilderInterface; - - /** - * Sets SELECT DISTINCT / SELECT ALL flag - * - * ```php - * $builder->distinct("status"); - * $builder->distinct(null); - * ``` - * - * @param mixed $distinct - * @return BuilderInterface + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function distinct($distinct): BuilderInterface; + public function columns($columns); /** - * Sets a FOR UPDATE clause - * - * ```php - * $builder->forUpdate(true); - * ``` + * Return the columns to be queried * - * @param bool $forUpdate - * @return BuilderInterface + * @return string|array */ - public function forUpdate(bool $forUpdate): BuilderInterface; + public function getColumns(); /** * Sets the models who makes part of the query * * @param string|array $models - * @return BuilderInterface + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function from($models): BuilderInterface; + public function from($models); /** - * Returns default bind params - * - * @return array - */ - public function getBindParams(): array; - - /** - * Returns default bind types - * - * @return array - */ - public function getBindTypes(): array; - - /** - * Return the columns to be queried - * - * @return string|array - */ - public function getColumns(); - - /** - * Returns SELECT DISTINCT / SELECT ALL flag + * Add a model to take part of the query * - * @return bool + * @param string $model + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getDistinct(): bool; + public function addFrom($model, $alias = null); /** * Return the models who makes part of the query @@ -123,93 +56,105 @@ public function getDistinct(): bool; public function getFrom(); /** - * Returns the GROUP BY clause - * - * @return array - */ - public function getGroupBy(): array; - - /** - * Returns the HAVING condition clause - * - * @return string - */ - public function getHaving(): string; - - /** - * Return join parts of the query + * Adds an :type: join (by default type - INNER) to the query * - * @return array + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getJoins(): array; + public function join($model, $conditions = null, $alias = null, $type = null); /** - * Returns the current LIMIT clause + * Adds an INNER join to the query * - * @return string|array + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getLimit(); + public function innerJoin($model, $conditions = null, $alias = null); /** - * Returns the current OFFSET clause + * Adds a LEFT join to the query * - * @return int + * @param string $model + * @param string $conditions + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getOffset(): int; + public function leftJoin($model, $conditions = null, $alias = null); /** - * Return the set ORDER BY clause + * Adds a RIGHT join to the query * - * @return string|array + * @param string $model + * @param string $conditions + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getOrderBy(); + public function rightJoin($model, $conditions = null, $alias = null); /** - * Returns a PHQL statement built based on the builder parameters + * Return join parts of the query * - * @return string + * @return array */ - public function getPhql(): string; + public function getJoins(); /** - * Returns the query built + * Sets conditions for the query * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getQuery(): QueryInterface; + public function where($conditions, $bindParams = null, $bindTypes = null); /** - * Return the conditions for the query + * Appends a condition to the current conditions using a AND operator * - * @return string|array + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getWhere(); + public function andWhere($conditions, $bindParams = null, $bindTypes = null); /** - * Sets a GROUP BY clause + * Appends a condition to the current conditions using an OR operator * - * @param string|array $group - * @return BuilderInterface + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function groupBy($group): BuilderInterface; + public function orWhere($conditions, $bindParams = null, $bindTypes = null); /** - * Sets a HAVING condition clause + * Appends a BETWEEN condition to the current conditions * - * @param string $having - * @return BuilderInterface + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function having(string $having): BuilderInterface; + public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); /** - * Adds an INNER join to the query + * Appends a NOT BETWEEN condition to the current conditions * - * @param string $model - * @param string $conditions - * @param string $alias - * @return BuilderInterface + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\Builder */ - public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; + public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); /** * Appends an IN condition to the current conditions @@ -219,128 +164,98 @@ public function innerJoin(string $model, string $conditions = null, string $alia * @param string $operator * @return BuilderInterface */ - public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; + public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); /** - * Adds an :type: join (by default type - INNER) to the query + * Appends a NOT IN condition to the current conditions * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type + * @param string $expr + * @param array $values + * @param string $operator * @return BuilderInterface */ - public function join(string $model, string $conditions = null, string $alias = null): BuilderInterface; + public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); /** - * Adds a LEFT join to the query + * Return the conditions for the query * - * @param string $model - * @param string $conditions - * @param string $alias - * @return BuilderInterface + * @return string|array */ - public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; + public function getWhere(); /** - * Sets a LIMIT clause + * Sets an ORDER BY condition clause * - * @param int $limit - * @param int $offset - * @return BuilderInterface + * @param string $orderBy + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function limit(int $limit, $offset = null): BuilderInterface; + public function orderBy($orderBy); /** - * Returns the models involved in the query + * Return the set ORDER BY clause * - * @return string|array|null + * @return string|array */ - public function getModels(); + public function getOrderBy(); /** - * Appends a NOT BETWEEN condition to the current conditions + * Sets a HAVING condition clause * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return BuilderInterface + * @param string $having + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; + public function having($having); /** - * Appends a NOT IN condition to the current conditions + * Returns the HAVING condition clause * - * @param string $expr - * @param array $values - * @param string $operator - * @return BuilderInterface + * @return string|array */ - public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; + public function getHaving(); /** - * Sets an OFFSET clause + * Sets a LIMIT clause * + * @param int $limit * @param int $offset - * @return BuilderInterface - */ - public function offset(int $offset): BuilderInterface; - - /** - * Sets an ORDER BY condition clause - * - * @param string $orderBy - * @return BuilderInterface + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orderBy(string $orderBy): BuilderInterface; + public function limit($limit, $offset = null); /** - * Appends a condition to the current conditions using an OR operator + * Returns the current LIMIT clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return BuilderInterface + * @return string|array */ - public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + public function getLimit(); /** - * Adds a RIGHT join to the query + * Sets a LIMIT clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return BuilderInterface + * @param string|array $group + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; + public function groupBy($group); /** - * Set default bind parameters + * Returns the GROUP BY clause * - * @param array $bindParams - * @param bool $merge - * @return BuilderInterface + * @return string */ - public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface; + public function getGroupBy(); /** - * Set default bind types + * Returns a PHQL statement built based on the builder parameters * - * @param array $bindTypes - * @param bool $merge - * @return BuilderInterface + * @return string */ - public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface; + public function getPhql(); /** - * Sets conditions for the query + * Returns the query built * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return BuilderInterface + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + public function getQuery(); } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 28727de1..5f453526 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -15,11 +15,9 @@ * the same technology as SQLite. This technology provides a small in-memory * parser with a very low memory footprint that is also thread-safe. * - * ```php - * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL( - * "SELECT r. FROM Robots r LIMIT 10" - * ); - * ``` + * + * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL("SELECT r. FROM Robots r LIMIT 10"); + * */ abstract class Lang { @@ -30,6 +28,6 @@ abstract class Lang * @param string $phql * @return string */ - public static function parsePHQL(string $phql): string {} + public static function parsePHQL($phql) {} } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index f902467d..ba75ee6d 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -10,7 +10,7 @@ * information and the related messages produced by the * model which finally executes the operations when it fails * - * ```php + * * $phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:"; * * $status = $app->modelsManager->executeQuery( @@ -24,18 +24,18 @@ * ); * * // Check if the update was successful - * if ($status->success()) { + * if ($status->success() === true) { * echo "OK"; * } - * ``` + * */ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { - protected $model; + protected $_success; - protected $success; + protected $_model; /** @@ -44,27 +44,27 @@ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface * @param bool $success * @param \Phalcon\Mvc\ModelInterface $model */ - public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) {} + public function __construct($success, \Phalcon\Mvc\ModelInterface $model = null) {} /** - * Returns the messages produced because of a failed operation + * Returns the model that executed the action * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages(): array {} + public function getModel() {} /** - * Returns the model that executed the action + * Returns the messages produced because of a failed operation * - * @return \Phalcon\Mvc\ModelInterface + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function getModel(): ModelInterface {} + public function getMessages() {} /** * Allows to check if the executed operation was successful * * @return bool */ - public function success(): bool {} + public function success() {} } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index 1f16632c..b2980bec 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -11,24 +11,24 @@ interface StatusInterface { /** - * Returns the messages produced by an operation failed + * Returns the model which executed the action * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages(): array; + public function getModel(); /** - * Returns the model which executed the action + * Returns the messages produced by an operation failed * - * @return \Phalcon\Mvc\ModelInterface + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function getModel(): ModelInterface; + public function getMessages(); /** * Allows to check if the executed operation was successful * * @return bool */ - public function success(): bool; + public function success(); } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 7f057733..793e38d0 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -11,13 +11,12 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model\ResultsetInterface { - protected $columnTypes; + protected $_columnTypes; /** - * Unserialised result-set hydrated all rows already. unserialise() sets - * disableHydration to true + * Unserialised result-set hydrated all rows already. unserialise() sets _disableHydration to true */ - protected $disableHydration = false; + protected $_disableHydration = false; /** @@ -25,31 +24,31 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model * * @param array $columnTypes * @param \Phalcon\Db\ResultInterface $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param \Phalcon\Cache\BackendInterface $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\BackendInterface $cache = null) {} /** * Returns current row in the resultset * * @return bool|ModelInterface */ - final public function current() {} + public final function current() {} /** - * Returns a complete resultset as an array, if the resultset has a big - * number of rows it could consume more memory than currently it does. + * Returns a complete resultset as an array, if the resultset has a big number of rows + * it could consume more memory than currently it does. * * @return array */ - public function toArray(): array {} + public function toArray() {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize(): string {} + public function serialize() {} /** * Unserializing a resultset will allow to only works on the rows present in the saved state diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 1209af8a..8d377287 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -11,15 +11,13 @@ class Simple extends \Phalcon\Mvc\Model\Resultset { - protected $columnMap; + protected $_model; - protected $model; + protected $_columnMap; - /** - * @var bool - */ - protected $keepSnapshots = false; + + protected $_keepSnapshots = false; /** @@ -27,40 +25,38 @@ class Simple extends \Phalcon\Mvc\Model\Resultset * * @param array $columnMap * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $model - * @param mixed $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @param bool $keepSnapshots + * @param \Phalcon\Db\Result\Pdo|null $result + * @param \Phalcon\Cache\BackendInterface $cache + * @param boolean $keepSnapshots */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) {} + public function __construct($columnMap, $model, $result, \Phalcon\Cache\BackendInterface $cache = null, $keepSnapshots = null) {} /** * Returns current row in the resultset * - * @return null|ModelInterface + * @return bool|ModelInterface */ - final public function current(): ?ModelInterface {} + public final function current() {} /** - * Returns a complete resultset as an array, if the resultset has a big - * number of rows it could consume more memory than currently it does. - * Export the resultset to an array couldn't be faster with a large number - * of records + * Returns a complete resultset as an array, if the resultset has a big number of rows + * it could consume more memory than currently it does. Export the resultset to an array + * couldn't be faster with a large number of records * * @param bool $renameColumns * @return array */ - public function toArray(bool $renameColumns = true): array {} + public function toArray($renameColumns = true) {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize(): string {} + public function serialize() {} /** - * Unserializing a resultset will allow to only works on the rows present in - * the saved state + * Unserializing a resultset will allow to only works on the rows present in the saved state * * @param mixed $data */ diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 08fa28f4..725b413e 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -10,7 +10,7 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception { - protected $record = null; + protected $_record = null; /** @@ -19,20 +19,20 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception * @param string $message * @param \Phalcon\Mvc\ModelInterface $record */ - public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) {} + public function __construct($message, \Phalcon\Mvc\ModelInterface $record = null) {} /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\ModelInterface + * @return \Phalcon\Mvc\Model\MessageInterface[] */ - public function getRecord(): ModelInterface {} + public function getRecordMessages() {} /** * Returns validation record messages which stop the transaction * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getRecordMessages(): array {} + public function getRecord() {} } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index 31af4afd..faf1aa4a 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -5,15 +5,14 @@ /** * Phalcon\Mvc\Model\Transaction\Manager * - * A transaction acts on a single database connection. If you have multiple - * class-specific databases, the transaction will not protect interaction among - * them. + * A transaction acts on a single database connection. If you have multiple class-specific + * databases, the transaction will not protect interaction among them. * * This class manages the objects that compose a transaction. - * A transaction produces a unique connection that is passed to every object - * part of the transaction. + * A transaction produces a unique connection that is passed to every + * object part of the transaction. * - * ```php + * * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -29,7 +28,7 @@ * $robot->name = "WALL·E"; * $robot->created_at = date("Y-m-d"); * - * if ($robot->save() === false) { + * if ($robot->save() === false){ * $transaction->rollback("Can't save robot"); * } * @@ -47,150 +46,146 @@ * } catch (Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * ``` + * */ class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { - protected $container; + protected $_dependencyInjector; - protected $initialized = false; + protected $_initialized = false; - protected $number = 0; + protected $_rollbackPendent = true; - protected $rollbackPendent = true; + protected $_number = 0; - protected $service = 'db'; + protected $_service = 'db'; - /** - * @var array - */ - protected $transactions = array(); + + protected $_transactions; /** * Phalcon\Mvc\Model\Transaction\Manager constructor * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\DiInterface $dependencyInjector */ - public function __construct(\Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} /** - * Remove all the transactions from the manager + * Sets the dependency injection container + * + * @param \Phalcon\DiInterface $dependencyInjector */ - public function collectTransactions() {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Commits active transactions within the manager + * Returns the dependency injection container + * + * @return \Phalcon\DiInterface */ - public function commit() {} + public function getDI() {} /** - * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once - * This method registers a shutdown function to rollback active connections + * Sets the database service used to run the isolated transactions * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param string $service + * @return Manager */ - public function get(bool $autoBegin = true): TransactionInterface {} + public function setDbService($service) {} /** * Returns the database service used to isolate the transaction * * @return string */ - public function getDbService(): string {} - - /** - * Returns the dependency injection container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} + public function getDbService() {} /** - * Create/Returns a new transaction or an existing one + * Set if the transaction manager must register a shutdown function to clean up pendent transactions * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param bool $rollbackPendent + * @return Manager */ - public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface {} + public function setRollbackPendent($rollbackPendent) {} /** - * Check if the transaction manager is registering a shutdown function to - * clean up pendent transactions + * Check if the transaction manager is registering a shutdown function to clean up pendent transactions * * @return bool */ - public function getRollbackPendent(): bool {} + public function getRollbackPendent() {} /** * Checks whether the manager has an active transaction * * @return bool */ - public function has(): bool {} + public function has() {} /** - * Notifies the manager about a committed transaction + * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once + * This method registers a shutdown function to rollback active connections * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function get($autoBegin = true) {} /** - * Notifies the manager about a rollbacked transaction + * Create/Returns a new transaction or an existing one * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function getOrCreateTransaction($autoBegin = true) {} /** * Rollbacks active transactions within the manager - * Collect will remove the transaction from the manager - * - * @param bool $collect */ - public function rollback(bool $collect = true) {} + public function rollbackPendent() {} /** - * Rollbacks active transactions within the manager + * Commits active transactions within the manager */ - public function rollbackPendent() {} + public function commit() {} /** - * Sets the database service used to run the isolated transactions + * Rollbacks active transactions within the manager + * Collect will remove the transaction from the manager * - * @param string $service - * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface + * @param boolean $collect */ - public function setDbService(string $service): ManagerInterface {} + public function rollback($collect = true) {} /** - * Sets the dependency injection container + * Notifies the manager about a rollbacked transaction * - * @param \Phalcon\Di\DiInterface $container + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** - * Set if the transaction manager must register a shutdown function to clean - * up pendent transactions + * Notifies the manager about a committed transaction * - * @param bool $rollbackPendent - * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function setRollbackPendent(bool $rollbackPendent): ManagerInterface {} + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** * Removes transactions from the TransactionManager * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + protected function _collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + + /** + * Remove all the transactions from the manager + */ + public function collectTransactions() {} } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index 21fa668d..d2c1b841 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -11,14 +11,11 @@ interface ManagerInterface { /** - * Remove all the transactions from the manager - */ - public function collectTransactions(); - - /** - * Commits active transactions within the manager + * Checks whether manager has an active transaction + * + * @return bool */ - public function commit(); + public function has(); /** * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once @@ -26,35 +23,25 @@ public function commit(); * @param bool $autoBegin * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function get(bool $autoBegin = true): TransactionInterface; + public function get($autoBegin = true); /** - * Returns the database service used to isolate the transaction - * - * @return string - */ - public function getDbService(): string; - - /** - * Check if the transaction manager is registering a shutdown function to clean up pendent transactions - * - * @return bool + * Rollbacks active transactions within the manager */ - public function getRollbackPendent(): bool; + public function rollbackPendent(); /** - * Checks whether manager has an active transaction - * - * @return bool + * Commits active transactions within the manager */ - public function has(): bool; + public function commit(); /** - * Notifies the manager about a committed transaction + * Rollbacks active transactions within the manager + * Collect will remove transaction from the manager * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param boolean $collect */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function rollback($collect = false); /** * Notifies the manager about a rollbacked transaction @@ -64,32 +51,15 @@ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transactio public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** - * Rollbacks active transactions within the manager - * Collect will remove transaction from the manager - * - * @param bool $collect - */ - public function rollback(bool $collect = false); - - /** - * Rollbacks active transactions within the manager - */ - public function rollbackPendent(); - - /** - * Sets the database service used to run the isolated transactions + * Notifies the manager about a committed transaction * - * @param string $service - * @return ManagerInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function setDbService(string $service): ManagerInterface; + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** - * Set if the transaction manager must register a shutdown function to clean up pendent transactions - * - * @param bool $rollbackPendent - * @return ManagerInterface + * Remove all the transactions from the manager */ - public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; + public function collectTransactions(); } diff --git a/src/Phalcon/mvc/model/validator/Email.php b/src/Phalcon/mvc/model/validator/Email.php new file mode 100644 index 00000000..62825bce --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Email.php @@ -0,0 +1,49 @@ + + * use Phalcon\Mvc\Model\Validator\Email as EmailValidator; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new EmailValidator( + * [ + * "field" => "electronic_mail", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\Email + */ +class Email extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Exclusionin.php b/src/Phalcon/mvc/model/validator/Exclusionin.php new file mode 100644 index 00000000..cd444ce3 --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Exclusionin.php @@ -0,0 +1,50 @@ + + * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionInValidator; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new ExclusionInValidator( + * [ + * "field" => "status", + * "domain" => ["A", "I"], + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\EclusionIn + */ +class Exclusionin extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Inclusionin.php b/src/Phalcon/mvc/model/validator/Inclusionin.php new file mode 100644 index 00000000..d506ab45 --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Inclusionin.php @@ -0,0 +1,50 @@ + + * use Phalcon\Mvc\Model\Validator\InclusionIn as InclusionInValidator; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new InclusionInValidator( + * [ + * "field" => "status", + * "domain" => ["A", "I"], + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\InclusionIn + */ +class Inclusionin extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Ip.php b/src/Phalcon/mvc/model/validator/Ip.php new file mode 100644 index 00000000..f6ca5e5d --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Ip.php @@ -0,0 +1,82 @@ + + * use Phalcon\Mvc\Model\Validator\Ip; + * + * class Data extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * // Any pubic IP + * $this->validate( + * new IP( + * [ + * "field" => "server_ip", + * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified + * "allowReserved" => false, // False if not specified. Ignored for v6 + * "allowPrivate" => false, // False if not specified + * "message" => "IP address has to be correct", + * ] + * ) + * ); + * + * // Any public v4 address + * $this->validate( + * new IP( + * [ + * "field" => "ip_4", + * "version" => IP::VERSION_4, + * "message" => "IP address has to be correct", + * ] + * ) + * ); + * + * // Any v6 address + * $this->validate( + * new IP( + * [ + * "field" => "ip6", + * "version" => IP::VERSION_6, + * "allowPrivate" => true, + * "message" => "IP address has to be correct", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + */ +class Ip extends \Phalcon\Mvc\Model\Validator +{ + + const VERSION_4 = 1048576; + + + const VERSION_6 = 2097152; + + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Numericality.php b/src/Phalcon/mvc/model/validator/Numericality.php new file mode 100644 index 00000000..9878eac2 --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Numericality.php @@ -0,0 +1,49 @@ + + * use Phalcon\Mvc\Model\Validator\Numericality as NumericalityValidator; + * + * class Products extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new NumericalityValidator( + * [ + * "field" => "price", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\Numericality + */ +class Numericality extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/PresenceOf.php b/src/Phalcon/mvc/model/validator/PresenceOf.php new file mode 100644 index 00000000..229e417c --- /dev/null +++ b/src/Phalcon/mvc/model/validator/PresenceOf.php @@ -0,0 +1,50 @@ + + * use Phalcon\Mvc\Model\Validator\PresenceOf; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new PresenceOf( + * [ + * "field" => "name", + * "message" => "The name is required", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\PresenceOf + */ +class PresenceOf extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Regex.php b/src/Phalcon/mvc/model/validator/Regex.php new file mode 100644 index 00000000..64b6ee12 --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Regex.php @@ -0,0 +1,50 @@ + + * use Phalcon\Mvc\Model\Validator\Regex as RegexValidator; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new RegexValidator( + * [ + * "field" => "created_at", + * "pattern" => "/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])/", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() == true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\Regex + */ +class Regex extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/StringLength.php b/src/Phalcon/mvc/model/validator/StringLength.php new file mode 100644 index 00000000..91a7701f --- /dev/null +++ b/src/Phalcon/mvc/model/validator/StringLength.php @@ -0,0 +1,53 @@ + + * use Phalcon\Mvc\Model\Validator\StringLength as StringLengthValidator; + * + * class Subscriptors extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new StringLengthValidator( + * [ + * "field" => "name_last", + * "max" => 50, + * "min" => 2, + * "messageMaximum" => "We don't like really long names", + * "messageMinimum" => "We want more than just their initials", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\StringLength + */ +class StringLength extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Uniqueness.php b/src/Phalcon/mvc/model/validator/Uniqueness.php new file mode 100644 index 00000000..c9cb687b --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Uniqueness.php @@ -0,0 +1,52 @@ + + * use Phalcon\Mvc\Collection; + * use Phalcon\Mvc\Model\Validator\Uniqueness; + * + * class Subscriptors extends Collection + * { + * public function validation() + * { + * $this->validate( + * new Uniqueness( + * [ + * "field" => "email", + * "message" => "Value of field 'email' is already present in another record", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\Uniqueness + */ +class Uniqueness extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/model/validator/Url.php b/src/Phalcon/mvc/model/validator/Url.php new file mode 100644 index 00000000..28ee074f --- /dev/null +++ b/src/Phalcon/mvc/model/validator/Url.php @@ -0,0 +1,49 @@ + + * use Phalcon\Mvc\Model\Validator\Url as UrlValidator; + * + * class Posts extends \Phalcon\Mvc\Collection + * { + * public function validation() + * { + * $this->validate( + * new UrlValidator( + * [ + * "field" => "source_url", + * ] + * ) + * ); + * + * if ($this->validationHasFailed() === true) { + * return false; + * } + * } + * } + * + * + * @deprecated 3.1.0 + * @see Phalcon\Validation\Validator\Url + */ +class Url extends \Phalcon\Mvc\Model\Validator +{ + + /** + * Executes the validator + * + * @param \Phalcon\Mvc\EntityInterface $record + * @return bool + */ + public function validate(\Phalcon\Mvc\EntityInterface $record) {} + +} diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index b8adad00..18c4db8c 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -7,7 +7,7 @@ * * A router that reads routes annotations from classes/resources * - * ```php + * * use Phalcon\Mvc\Router\Annotations; * * $di->setShared( @@ -22,58 +22,59 @@ * return $router; * } * ); - * ``` + * */ class Annotations extends \Phalcon\Mvc\Router { - protected $actionSuffix = 'Action'; + protected $_handlers = array(); - protected $controllerSuffix = 'Controller'; + protected $_controllerSuffix = 'Controller'; - protected $handlers = array(); + protected $_actionSuffix = 'Action'; - protected $routePrefix; + protected $_routePrefix; /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations - * The class is located in a module * - * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addModuleResource(string $module, string $handler, string $prefix = null): Annotations {} + public function addResource($handler, $prefix = null) {} /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations + * The class is located in a module * + * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addResource(string $handler, string $prefix = null): Annotations {} + public function addModuleResource($module, $handler, $prefix = null) {} /** - * Return the registered resources + * Produce the routing parameters from the rewrite information * - * @return array + * @param string $uri */ - public function getResources(): array {} + public function handle($uri = null) {} /** - * Produce the routing parameters from the rewrite information + * Checks for annotations in the controller docblock * - * @param string $uri + * @param string $handler + * @param \Phalcon\Annotations\Annotation $annotation */ - public function handle(string $uri) {} + public function processControllerAnnotation($handler, \Phalcon\Annotations\Annotation $annotation) {} /** * Checks for annotations in the public methods of the controller @@ -84,28 +85,27 @@ public function handle(string $uri) {} * @param string $action * @param \Phalcon\Annotations\Annotation $annotation */ - public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) {} + public function processActionAnnotation($module, $namespaceName, $controller, $action, \Phalcon\Annotations\Annotation $annotation) {} /** - * Checks for annotations in the controller docblock + * Changes the controller class suffix * - * @param string $handler - * @param \Phalcon\Annotations\Annotation $annotation + * @param string $controllerSuffix */ - public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) {} + public function setControllerSuffix($controllerSuffix) {} /** * Changes the action method suffix * * @param string $actionSuffix */ - public function setActionSuffix(string $actionSuffix) {} + public function setActionSuffix($actionSuffix) {} /** - * Changes the controller class suffix + * Return the registered resources * - * @param string $controllerSuffix + * @return array */ - public function setControllerSuffix(string $controllerSuffix) {} + public function getResources() {} } diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index 864e7821..e89389c2 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -7,7 +7,7 @@ * * Helper class to create a group of routes with common attributes * - * ```php + * * $router = new \Phalcon\Mvc\Router(); * * //Create a group with a common module and controller @@ -48,24 +48,24 @@ * * //Add the group to the router * $router->mount($blog); - * ``` + * */ class Group implements \Phalcon\Mvc\Router\GroupInterface { - protected $beforeMatch; + protected $_prefix; - protected $hostname; + protected $_hostname; - protected $paths; + protected $_paths; - protected $prefix; + protected $_routes; - protected $routes; + protected $_beforeMatch; /** @@ -76,182 +76,155 @@ class Group implements \Phalcon\Mvc\Router\GroupInterface public function __construct($paths = null) {} /** - * Adds a route to the router on any HTTP method - * - * ```php - * $router->add("/about", "About::index"); - * ``` + * Set a hostname restriction for all the routes in the group * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @return RouteInterface + * @param string $hostname + * @return GroupInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} + public function setHostname($hostname) {} /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns the hostname restriction * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @return string */ - public function addConnect(string $pattern, $paths = null): RouteInterface {} + public function getHostname() {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Set a common uri prefix for all the routes in this group * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @param string $prefix + * @return GroupInterface */ - public function addDelete(string $pattern, $paths = null): RouteInterface {} + public function setPrefix($prefix) {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Returns the common prefix for all the routes * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @return string */ - public function addGet(string $pattern, $paths = null): RouteInterface {} + public function getPrefix() {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addHead(string $pattern, $paths = null): RouteInterface {} + public function beforeMatch($beforeMatch) {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the 'before match' callback if any * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @return callable */ - public function addOptions(string $pattern, $paths = null): RouteInterface {} + public function getBeforeMatch() {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Set common paths for all the routes in the group * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @param mixed $paths + * @return GroupInterface */ - public function addPatch(string $pattern, $paths = null): RouteInterface {} + public function setPaths($paths) {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Returns the common paths defined for this group * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @return array|string */ - public function addPost(string $pattern, $paths = null): RouteInterface {} + public function getPaths() {} /** - * Adds a route to the router that only match if the HTTP method is PURGE + * Returns the routes added to the group * - * @param string $pattern - * @param string|array $paths - * @return RouteInterface + * @return RouteInterface[] */ - public function addPurge(string $pattern, $paths = null): RouteInterface {} + public function getRoutes() {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Adds a route to the router on any HTTP method + * + * + * $router->add("/about", "About::index"); + * * * @param string $pattern - * @param string|array $paths + * @param mixed $paths + * @param mixed $httpMethods * @return RouteInterface */ - public function addPut(string $pattern, $paths = null): RouteInterface {} + public function add($pattern, $paths = null, $httpMethods = null) {} /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern - * @param string|array $paths + * @param string/array $paths * @return RouteInterface */ - public function addTrace(string $pattern, $paths = null): RouteInterface {} - - /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched - * - * @param callable $beforeMatch - * @return GroupInterface - */ - public function beforeMatch($beforeMatch): GroupInterface {} - - /** - * Removes all the pre-defined routes - */ - public function clear() {} - - /** - * Returns the 'before match' callback if any - * - * @return callable - */ - public function getBeforeMatch() {} + public function addGet($pattern, $paths = null) {} /** - * Returns the hostname restriction + * Adds a route to the router that only match if the HTTP method is POST * - * @return string + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function getHostname(): string {} + public function addPost($pattern, $paths = null) {} /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is PUT * - * @return array|string + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function getPaths() {} + public function addPut($pattern, $paths = null) {} /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is PATCH * - * @return string + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function getPrefix(): string {} + public function addPatch($pattern, $paths = null) {} /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is DELETE * - * @return array|RouteInterface[] + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function getRoutes(): array {} + public function addDelete($pattern, $paths = null) {} /** - * Set a hostname restriction for all the routes in the group + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string $hostname - * @return GroupInterface + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function setHostname(string $hostname): GroupInterface {} + public function addOptions($pattern, $paths = null) {} /** - * Set common paths for all the routes in the group + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param mixed $paths - * @return GroupInterface + * @param string $pattern + * @param string/array $paths + * @return RouteInterface */ - public function setPaths($paths): GroupInterface {} + public function addHead($pattern, $paths = null) {} /** - * Set a common uri prefix for all the routes in this group - * - * @param string $prefix - * @return GroupInterface + * Removes all the pre-defined routes */ - public function setPrefix(string $prefix): GroupInterface {} + public function clear() {} /** * Adds a route applying the common attributes @@ -261,6 +234,6 @@ public function setPrefix(string $prefix): GroupInterface {} * @param mixed $httpMethods * @return RouteInterface */ - protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} + protected function _addRoute($pattern, $paths = null, $httpMethods = null) {} } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index 33d59115..dd9a10b1 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -5,7 +5,7 @@ /** * Phalcon\Mvc\Router\GroupInterface * - * ```php + * * $router = new \Phalcon\Mvc\Router(); * * // Create a group with a common module and controller @@ -46,187 +46,160 @@ * * // Add the group to the router * $router->mount($blog); - * ``` + * */ interface GroupInterface { /** - * Adds a route to the router on any HTTP method - * - * ```php - * router->add("/about", "About::index"); - * ``` + * Set a hostname restriction for all the routes in the group * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $hostname + * @return GroupInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; + public function setHostname($hostname); /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns the hostname restriction * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addConnect(string $pattern, $paths = null): RouteInterface; + public function getHostname(); /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Set a common uri prefix for all the routes in this group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $prefix + * @return GroupInterface */ - public function addDelete(string $pattern, $paths = null): RouteInterface; + public function setPrefix($prefix); /** - * Adds a route to the router that only match if the HTTP method is GET + * Returns the common prefix for all the routes * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addGet(string $pattern, $paths = null): RouteInterface; + public function getPrefix(); /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addHead(string $pattern, $paths = null): RouteInterface; + public function beforeMatch($beforeMatch); /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the 'before match' callback if any * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return callable */ - public function addOptions(string $pattern, $paths = null): RouteInterface; + public function getBeforeMatch(); /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Set common paths for all the routes in the group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param array $paths + * @return GroupInterface */ - public function addPatch(string $pattern, $paths = null): RouteInterface; + public function setPaths($paths); /** - * Adds a route to the router that only match if the HTTP method is POST + * Returns the common paths defined for this group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array|string */ - public function addPost(string $pattern, $paths = null): RouteInterface; + public function getPaths(); /** - * Adds a route to the router that only match if the HTTP method is PURGE + * Returns the routes added to the group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Mvc\Router\RouteInterface[] */ - public function addPurge(string $pattern, $paths = null): RouteInterface; + public function getRoutes(); /** - * Adds a route to the router that only match if the HTTP method is PUT + * Adds a route to the router on any HTTP method + * + * + * router->add("/about", "About::index"); + * * * @param string $pattern * @param mixed $paths + * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPut(string $pattern, $paths = null): RouteInterface; + public function add($pattern, $paths = null, $httpMethods = null); /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addTrace(string $pattern, $paths = null): RouteInterface; + public function addGet($pattern, $paths = null); /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched - * - * @param callable $beforeMatch - * @return GroupInterface - */ - public function beforeMatch($beforeMatch): GroupInterface; - - /** - * Removes all the pre-defined routes - */ - public function clear(); - - /** - * Returns the 'before match' callback if any - * - * @return callable - */ - public function getBeforeMatch(); - - /** - * Returns the hostname restriction + * Adds a route to the router that only match if the HTTP method is POST * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getHostname(): string; + public function addPost($pattern, $paths = null); /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is PUT * - * @return array|string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPaths(); + public function addPut($pattern, $paths = null); /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is PATCH * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPrefix(): string; + public function addPatch($pattern, $paths = null); /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is DELETE * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRoutes(): array; + public function addDelete($pattern, $paths = null); /** - * Set a hostname restriction for all the routes in the group + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string $hostname - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setHostname(string $hostname): GroupInterface; + public function addOptions($pattern, $paths = null); /** - * Set common paths for all the routes in the group + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param array $paths - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPaths($paths): GroupInterface; + public function addHead($pattern, $paths = null); /** - * Set a common uri prefix for all the routes in this group - * - * @param string $prefix - * @return GroupInterface + * Removes all the pre-defined routes */ - public function setPrefix(string $prefix): GroupInterface; + public function clear(); } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 5f86e634..8397b84f 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -10,40 +10,40 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface { - protected $beforeMatch; + protected $_pattern; - protected $compiledPattern; + protected $_compiledPattern; - protected $converters; + protected $_paths; - protected $group; + protected $_methods; - protected $hostname; + protected $_hostname; - protected $id; + protected $_converters; - protected $methods; + protected $_id; - protected $match; + protected $_name; - protected $name; + protected $_beforeMatch; - protected $paths; + protected $_match; - protected $pattern; + protected $_group; - static protected $uniqueId = 0; + static protected $_uniqueId; @@ -56,36 +56,7 @@ public function getId() {} * @param mixed $paths * @param mixed $httpMethods */ - public function __construct(string $pattern, $paths = null, $httpMethods = null) {} - - /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched - * - * ```php - * $router->add( - * "/login", - * [ - * "module" => "admin", - * "controller" => "session", - * ] - * )->beforeMatch( - * function ($uri, $route) { - * // Check if the request was made with Ajax - * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { - * return false; - * } - * - * return true; - * } - * ); - * ``` - * - * @param mixed $callback - * @return RouteInterface - */ - public function beforeMatch($callback): RouteInterface {} + public function __construct($pattern, $paths = null, $httpMethods = null) {} /** * Replaces placeholders from pattern returning a valid PCRE regular expression @@ -93,16 +64,26 @@ public function beforeMatch($callback): RouteInterface {} * @param string $pattern * @return string */ - public function compilePattern(string $pattern): string {} + public function compilePattern($pattern) {} /** - * {@inheritdoc} + * Set one or more HTTP methods that constraint the matching of the route * - * @param string $name - * @param mixed $converter - * @return RouteInterface + * + * $route->via("GET"); + * + * $route->via( + * [ + * "GET", + * "POST", + * ] + * ); + * + * + * @param mixed $httpMethods + * @return Route */ - public function convert(string $name, $converter): RouteInterface {} + public function via($httpMethods) {} /** * Extracts parameters from a string @@ -110,49 +91,102 @@ public function convert(string $name, $converter): RouteInterface {} * @param string $pattern * @return array|bool */ - public function extractNamedParams(string $pattern) {} + public function extractNamedParams($pattern) {} /** - * Returns the 'before match' callback if any + * Reconfigure the route adding a new pattern and a set of paths * - * @return callable + * @param string $pattern + * @param mixed $paths */ - public function getBeforeMatch() {} + public function reConfigure($pattern, $paths = null) {} /** - * Returns the route's compiled pattern + * Returns routePaths + * + * @param mixed $paths + * @return array + */ + public static function getRoutePaths($paths = null) {} + + /** + * Returns the route's name * * @return string */ - public function getCompiledPattern(): string {} + public function getName() {} /** - * Returns the router converter + * Sets the route's name * - * @return array + * + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * + * + * @param string $name + * @return Route */ - public function getConverters(): array {} + public function setName($name) {} /** - * Returns the group associated with the route + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @return null|GroupInterface + * + * $router->add( + * "/login", + * [ + * "module" => "admin", + * "controller" => "session", + * ] + * )->beforeMatch( + * function ($uri, $route) { + * // Check if the request was made with Ajax + * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { + * return false; + * } + * + * return true; + * } + * ); + * + * + * @param mixed $callback + * @return Route */ - public function getGroup(): ?GroupInterface {} + public function beforeMatch($callback) {} /** - * Returns the HTTP methods that constraint matching the route + * Returns the 'before match' callback if any * - * @return array|string + * @return callable */ - public function getHttpMethods() {} + public function getBeforeMatch() {} /** - * Returns the hostname restriction if any + * Allows to set a callback to handle the request directly in the route * - * @return string + * + * $router->add( + * "/help", + * [] + * )->match( + * function () { + * return $this->getResponse()->redirect("https://support.google.com/", true); + * } + * ); + * + * + * @param mixed $callback + * @return Route */ - public function getHostname(): string {} + public function match($callback) {} /** * Returns the 'match' callback if any @@ -162,153 +196,137 @@ public function getHostname(): string {} public function getMatch() {} /** - * Returns the route's name + * Returns the route's id * * @return string */ - public function getName(): string {} + public function getRouteId() {} /** - * Returns the paths + * Returns the route's pattern * - * @return array + * @return string */ - public function getPaths(): array {} + public function getPattern() {} /** - * Returns the route's pattern + * Returns the route's compiled pattern * * @return string */ - public function getPattern(): string {} + public function getCompiledPattern() {} /** - * Returns the paths using positions as keys and names as values + * Returns the paths * * @return array */ - public function getReversedPaths(): array {} + public function getPaths() {} /** - * Returns the route's id + * Returns the paths using positions as keys and names as values * - * @return string + * @return array */ - public function getRouteId(): string {} + public function getReversedPaths() {} /** - * Returns routePaths + * Sets a set of HTTP methods that constraint the matching of the route (alias of via) * - * @param mixed $paths - * @return array + * + * $route->setHttpMethods("GET"); + * $route->setHttpMethods(["GET", "POST"]); + * + * + * @param mixed $httpMethods + * @return RouteInterface */ - public static function getRoutePaths($paths = null): array {} + public function setHttpMethods($httpMethods) {} /** - * Allows to set a callback to handle the request directly in the route - * - * ```php - * $router->add( - * "/help", - * [] - * )->match( - * function () { - * return $this->getResponse()->redirect("https://support.google.com/", true); - * } - * ); - * ``` + * Returns the HTTP methods that constraint matching the route * - * @param mixed $callback - * @return RouteInterface + * @return array|string */ - public function match($callback): RouteInterface {} + public function getHttpMethods() {} /** - * Reconfigure the route adding a new pattern and a set of paths + * Sets a hostname restriction to the route * - * @param string $pattern - * @param mixed $paths + * + * $route->setHostname("localhost"); + * + * + * @param string $hostname + * @return RouteInterface */ - public function reConfigure(string $pattern, $paths = null) {} + public function setHostname($hostname) {} /** - * Resets the internal route id generator + * Returns the hostname restriction if any + * + * @return string */ - public static function reset() {} + public function getHostname() {} /** * Sets the group associated with the route * * @param GroupInterface $group - * @return RouteInterface + * @return Route */ - public function setGroup(GroupInterface $group): RouteInterface {} + public function setGroup(GroupInterface $group) {} /** - * Sets a set of HTTP methods that constraint the matching of the route (alias of via) - * - * ```php - * $route->setHttpMethods("GET"); - * - * $route->setHttpMethods( - * [ - * "GET", - * "POST", - * ] - * ); - * ``` + * Returns the group associated with the route * - * @param mixed $httpMethods - * @return RouteInterface + * @return null|GroupInterface */ - public function setHttpMethods($httpMethods): RouteInterface {} + public function getGroup() {} /** - * Sets a hostname restriction to the route - * - * ```php - * $route->setHostname("localhost"); - * ``` + * Adds a converter to perform an additional transformation for certain parameter + * + * + * $router = new Phalcon\Mvc\Router(false); //create Router without default routes + * $route = $router->add("/catalog/([a-zA-Z0-9\_\-]+)/([^\?]+)", [ + * "controller" => "catalog", + * "action" => "show", + * "name" => 1, + * "params_" => 2, + * ]); + * + * //additional parsing + * $route->convert( + * 'params_', + * function ($string) { + * $array = explode('/', $string); + * array_walk($array, function (&$string) { + * $string = explode('-', $string); + * }); + * + * return $array; + * }); + * $router->handle("https://site.com/controller_name/param1-val1-val2/param2-val3"); + * //result is: `["params_"] = [["param1","val1","val2"], ["param2","val3"]]` + * * - * @param string $hostname - * @return RouteInterface + * @param string $name + * @param mixed $converter + * @return Route */ - public function setHostname(string $hostname): RouteInterface {} + public function convert($name, $converter) {} /** - * Sets the route's name - * - * ```php - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * ``` + * Returns the router converter * - * @param string $name - * @return RouteInterface + * @return array */ - public function setName(string $name): RouteInterface {} + public function getConverters() {} /** - * Set one or more HTTP methods that constraint the matching of the route - * - * ```php - * $route->via("GET"); - * - * $route->via( - * [ - * "GET", - * "POST", - * ] - * ); - * ``` - * - * @param mixed $httpMethods - * @return RouteInterface + * Resets the internal route id generator */ - public function via($httpMethods): RouteInterface {} + public static function reset() {} } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index 77877799..f6f1f632 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -11,119 +11,110 @@ interface RouteInterface { /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Sets a hostname restriction to the route * - * @param string $pattern - * @return string + * @param string $hostname + * @return RouteInterface */ - public function compilePattern(string $pattern): string; + public function setHostname($hostname); /** - * Adds a converter to perform an additional transformation for certain parameter. + * Returns the hostname restriction if any * - * @param string $name - * @param mixed $converter - * @return RouteInterface + * @return string */ - public function convert(string $name, $converter): RouteInterface; + public function getHostname(); /** - * Returns the route's pattern + * Replaces placeholders from pattern returning a valid PCRE regular expression * + * @param string $pattern * @return string */ - public function getCompiledPattern(): string; + public function compilePattern($pattern); /** - * Returns the hostname restriction if any + * Set one or more HTTP methods that constraint the matching of the route * - * @return string + * @param mixed $httpMethods */ - public function getHostname(): string; + public function via($httpMethods); /** - * Returns the HTTP methods that constraint matching the route + * Reconfigure the route adding a new pattern and a set of paths * - * @return string|array + * @param string $pattern + * @param mixed $paths */ - public function getHttpMethods(); + public function reConfigure($pattern, $paths = null); /** * Returns the route's name * * @return string */ - public function getName(): string; + public function getName(); /** - * Returns the paths + * Sets the route's name * - * @return array + * @param string $name */ - public function getPaths(): array; + public function setName($name); /** - * Returns the route's pattern + * Sets a set of HTTP methods that constraint the matching of the route * - * @return string + * @param mixed $httpMethods + * @return RouteInterface */ - public function getPattern(): string; + public function setHttpMethods($httpMethods); /** - * Returns the paths using positions as keys and names as values + * Returns the route's id * - * @return array + * @return string */ - public function getReversedPaths(): array; + public function getRouteId(); /** - * Returns the route's id + * Returns the route's pattern * * @return string */ - public function getRouteId(): string; + public function getPattern(); /** - * Sets a hostname restriction to the route + * Returns the route's pattern * - * @param string $hostname - * @return RouteInterface + * @return string */ - public function setHostname(string $hostname): RouteInterface; + public function getCompiledPattern(); /** - * Sets a set of HTTP methods that constraint the matching of the route + * Returns the paths * - * @param mixed $httpMethods - * @return RouteInterface + * @return array */ - public function setHttpMethods($httpMethods): RouteInterface; + public function getPaths(); /** - * Sets the route's name + * Returns the paths using positions as keys and names as values * - * @param string $name + * @return array */ - public function setName(string $name); + public function getReversedPaths(); /** - * Reconfigure the route adding a new pattern and a set of paths + * Returns the HTTP methods that constraint matching the route * - * @param string $pattern - * @param mixed $paths + * @return string|array */ - public function reConfigure(string $pattern, $paths = null); + public function getHttpMethods(); /** * Resets the internal route id generator */ public static function reset(); - /** - * Set one or more HTTP methods that constraint the matching of the route - * - * @param mixed $httpMethods - */ - public function via($httpMethods); - } diff --git a/src/Phalcon/mvc/url/Exception.php b/src/Phalcon/mvc/url/Exception.php new file mode 100644 index 00000000..f10048ee --- /dev/null +++ b/src/Phalcon/mvc/url/Exception.php @@ -0,0 +1,13 @@ + * use Phalcon\Mvc\View\Simple as View; * * $view = new View(); @@ -27,43 +27,49 @@ * "parameter" => $here, * ] * ); - * ``` + * */ class Simple extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewBaseInterface { - protected $activeRenderPath; + protected $_options; - protected $content; + protected $_viewsDir; - /** - * @var \Phalcon\Mvc\View\EngineInterface[]|false - */ - protected $engines = false; + protected $_partialsDir; - protected $options; + protected $_viewParams; - protected $partialsDir; + /** + * @var \Phalcon\Mvc\View\EngineInterface[]|false + */ + protected $_engines = false; /** * @var array|null */ - protected $registeredEngines; + protected $_registeredEngines; + + + protected $_activeRenderPath; + + protected $_content; - protected $viewsDir; + protected $_cache = false; - protected $viewParams = array(); + + protected $_cacheOptions; /** * @return array|null */ - public function getRegisteredEngines(): ?array {} + public function getRegisteredEngines() {} /** * Phalcon\Mvc\View\Simple constructor @@ -73,74 +79,69 @@ public function getRegisteredEngines(): ?array {} public function __construct(array $options = array()) {} /** - * Magic method to retrieve a variable passed to the view - * - * ```php - * echo $this->view->products; - * ``` + * Sets views directory. Depending of your platform, always add a trailing slash or backslash * - * @param string $key - * @return mixed|null - */ - public function __get(string $key): ? {} - - /** - * Magic method to pass variables to the views - * - * ```php - * $this->view->products = $products; - * ``` - * - * @param string $key - * @param mixed $value + * @param string $viewsDir */ - public function __set(string $key, $value) {} + public function setViewsDir($viewsDir) {} /** - * Returns the path of the view that is currently rendered + * Gets views directory * * @return string */ - public function getActiveRenderPath(): string {} + public function getViewsDir() {} /** - * Returns output from another view stage + * Register templating engines * - * @return string + * + * $this->view->registerEngines( + * [ + * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", + * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", + * ".mhtml" => "MyCustomEngine", + * ] + * ); + * + * + * @param array $engines */ - public function getContent(): string {} + public function registerEngines(array $engines) {} /** - * Returns parameters to views + * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php * * @return array */ - public function getParamsToView(): array {} + protected function _loadTemplateEngines() {} /** - * Returns a parameter previously set in the view + * Tries to render the view with every engine registered in the component * - * @param string $key - * @return mixed|null + * @param string $path + * @param array $params */ - public function getVar(string $key): ? {} + protected final function _internalRender($path, $params) {} /** - * Gets views directory + * Renders a view * + * @param string $path + * @param array $params * @return string */ - public function getViewsDir(): string {} + public function render($path, $params = null) {} /** * Renders a partial view * - * ```php + * * // Show a partial inside another view * $this->partial("shared/footer"); - * ``` + * * - * ```php + * * // Show a partial inside another view with parameters * $this->partial( * "shared/footer", @@ -148,115 +149,165 @@ public function getViewsDir(): string {} * "content" => $html, * ] * ); - * ``` + * * * @param string $partialPath * @param mixed $params */ - public function partial(string $partialPath, $params = null) {} + public function partial($partialPath, $params = null) {} /** - * Register templating engines + * Sets the cache options * - * ```php - * $this->view->registerEngines( - * [ - * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, - * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, - * ".mhtml" => \MyCustomEngine::class, - * ] - * ); - * ``` - * - * @param array $engines + * @param array $options + * @return Simple */ - public function registerEngines(array $engines) {} + public function setCacheOptions(array $options) {} /** - * Renders a view + * Returns the cache options * - * @param string $path - * @param array $params - * @return string + * @return array */ - public function render(string $path, array $params = array()): string {} + public function getCacheOptions() {} /** - * Externally sets the view content + * Create a Phalcon\Cache based on the internal cache options * - * ```php - * $this->view->setContent("

hello

"); - * ``` + * @return \Phalcon\Cache\BackendInterface + */ + protected function _createCache() {} + + /** + * Returns the cache instance used to cache * - * @param string $content - * @return Simple + * @return \Phalcon\Cache\BackendInterface */ - public function setContent(string $content): Simple {} + public function getCache() {} /** - * Adds parameters to views (alias of setVar) + * Cache the actual view render to certain level * - * ```php - * $this->view->setParamToView("products", $products); - * ``` + * + * $this->view->cache( + * [ + * "key" => "my-key", + * "lifetime" => 86400, + * ] + * ); + * * - * @param string $key - * @param mixed $value + * @param mixed $options * @return Simple */ - public function setParamToView(string $key, $value): Simple {} + public function cache($options = true) {} /** - * Set a single view parameter + * Adds parameters to views (alias of setVar) * - * ```php - * $this->view->setVar("products", $products); - * ``` + * + * $this->view->setParamToView("products", $products); + * * * @param string $key * @param mixed $value * @return Simple */ - public function setVar(string $key, $value): Simple {} + public function setParamToView($key, $value) {} /** * Set all the render params * - * ```php + * * $this->view->setVars( * [ * "products" => $products, * ] * ); - * ``` + * * * @param array $params * @param bool $merge * @return Simple */ - public function setVars(array $params, bool $merge = true): Simple {} + public function setVars(array $params, $merge = true) {} /** - * Sets views directory + * Set a single view parameter * - * @param string $viewsDir + * + * $this->view->setVar("products", $products); + * + * + * @param string $key + * @param mixed $value + * @return Simple + */ + public function setVar($key, $value) {} + + /** + * Returns a parameter previously set in the view + * + * @param string $key + * @return mixed|null */ - public function setViewsDir(string $viewsDir) {} + public function getVar($key) {} /** - * Loads registered template engines, if none are registered it will use - * Phalcon\Mvc\View\Engine\Php + * Returns parameters to views * * @return array */ - protected function loadTemplateEngines(): array {} + public function getParamsToView() {} /** - * Tries to render the view with every engine registered in the component + * Externally sets the view content * - * @param string $path - * @param array $params + * + * $this->view->setContent("

hello

"); + *
+ * + * @param string $content + * @return Simple + */ + public function setContent($content) {} + + /** + * Returns cached output from another view stage + * + * @return string + */ + public function getContent() {} + + /** + * Returns the path of the view that is currently rendered + * + * @return string + */ + public function getActiveRenderPath() {} + + /** + * Magic method to pass variables to the views + * + * + * $this->view->products = $products; + * + * + * @param string $key + * @param mixed $value + */ + public function __set($key, $value) {} + + /** + * Magic method to retrieve a variable passed to the view + * + * + * echo $this->view->products; + * + * + * @param string $key + * @return mixed|null */ - final protected function internalRender(string $path, $params) {} + public function __get($key) {} } diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index fb3cbc4f..181e9786 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -3,9 +3,11 @@ namespace Phalcon\Mvc\View\Engine; /** + * Phalcon\Mvc\View\Engine\Php + * * Adapter to use PHP itself as templating engine */ -class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine +class Php extends \Phalcon\Mvc\View\Engine { /** @@ -15,6 +17,6 @@ class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine * @param mixed $params * @param bool $mustClean */ - public function render(string $path, $params, bool $mustClean = false) {} + public function render($path, $params, $mustClean = false) {} } diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index 32da40c4..58c65d88 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -3,61 +3,51 @@ namespace Phalcon\Mvc\View\Engine; /** + * Phalcon\Mvc\View\Engine\Volt + * * Designer friendly and fast template engine for PHP written in Zephir/C */ -class Volt extends \Phalcon\Mvc\View\Engine\AbstractEngine +class Volt extends \Phalcon\Mvc\View\Engine { - protected $compiler; + protected $_options; - protected $macros; + protected $_compiler; - protected $options; + protected $_macros; /** - * Checks if a macro is defined and calls it + * Set Volt's options * - * @param string $name - * @param array $arguments - * @return mixed + * @param array $options */ - public function callMacro(string $name, array $arguments = array()) {} + public function setOptions(array $options) {} /** - * Performs a string conversion + * Return Volt's options * - * @param string $text - * @param string $from - * @param string $to - * @return string + * @return array */ - public function convertEncoding(string $text, string $from, string $to): string {} + public function getOptions() {} /** * Returns the Volt's compiler * * @return \Phalcon\Mvc\View\Engine\Volt\Compiler */ - public function getCompiler(): Compiler {} - - /** - * Return Volt's options - * - * @return array - */ - public function getOptions(): array {} + public function getCompiler() {} /** - * Checks if the needle is included in the haystack + * Renders a view using the template engine * - * @param mixed $needle - * @param mixed $haystack - * @return bool + * @param string $templatePath + * @param mixed $params + * @param bool $mustClean */ - public function isIncluded($needle, $haystack): bool {} + public function render($templatePath, $params, $mustClean = false) {} /** * Length filter. If an array/object is passed a count is performed otherwise a strlen/mb_strlen @@ -65,23 +55,26 @@ public function isIncluded($needle, $haystack): bool {} * @param mixed $item * @return int */ - public function length($item): int {} + public function length($item) {} /** - * Renders a view using the template engine + * Checks if the needle is included in the haystack * - * @param string $templatePath - * @param mixed $params - * @param bool $mustClean + * @param mixed $needle + * @param mixed $haystack + * @return bool */ - public function render(string $templatePath, $params, bool $mustClean = false) {} + public function isIncluded($needle, $haystack) {} /** - * Set Volt's options + * Performs a string conversion * - * @param array $options + * @param string $text + * @param string $from + * @param string $to + * @return string */ - public function setOptions(array $options) {} + public function convertEncoding($text, $from, $to) {} /** * Extracts a slice from a string/array/traversable object value @@ -90,7 +83,7 @@ public function setOptions(array $options) {} * @param int $start * @param mixed $end */ - public function slice($value, int $start = 0, $end = null) {} + public function slice($value, $start = 0, $end = null) {} /** * Sorts an array @@ -98,6 +91,15 @@ public function slice($value, int $start = 0, $end = null) {} * @param array $value * @return array */ - public function sort(array $value): array {} + public function sort(array $value) {} + + /** + * Checks if a macro is defined and calls it + * + * @param string $name + * @param array $arguments + * @return mixed + */ + public function callMacro($name, array $arguments = array()) {} } diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 74db5d01..5762e67c 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -3,80 +3,85 @@ namespace Phalcon\Mvc\View\Engine\Volt; /** + * Phalcon\Mvc\View\Engine\Volt\Compiler + * * This class reads and compiles Volt templates into PHP plain code * - * ```php + * * $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); * * $compiler->compile("views/partials/header.volt"); * * require $compiler->getCompiledTemplatePath(); - * ``` + * */ class Compiler implements \Phalcon\Di\InjectionAwareInterface { - protected $autoescape = false; + protected $_dependencyInjector; + + + protected $_view; - protected $blockLevel = 0; + protected $_options; - protected $blocks; + protected $_arrayHelpers; - protected $container; + protected $_level = 0; - protected $compiledTemplatePath; + protected $_foreachLevel = 0; - protected $currentBlock; + protected $_blockLevel = 0; - protected $currentPath; + protected $_exprLevel = 0; - protected $exprLevel = 0; + protected $_extended = false; - protected $extended = false; + protected $_autoescape = false; - protected $extensions; + protected $_extendedBlocks; - protected $extendedBlocks; + protected $_currentBlock; - protected $filters; + protected $_blocks; - protected $foreachLevel = 0; + protected $_forElsePointers; - protected $forElsePointers; + protected $_loopPointers; - protected $functions; + protected $_extensions; - protected $level = 0; + protected $_functions; - protected $loopPointers; + protected $_filters; - protected $macros; + protected $_macros; - protected $options; + protected $_prefix; - protected $prefix; + protected $_currentPath; - protected $view; + protected $_compiledTemplatePath; /** @@ -87,393 +92,391 @@ class Compiler implements \Phalcon\Di\InjectionAwareInterface public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) {} /** - * Registers a Volt's extension + * Sets the dependency injector * - * @param mixed $extension - * @return Compiler + * @param \Phalcon\DiInterface $dependencyInjector */ - public function addExtension($extension): Compiler {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Register a new filter in the compiler + * Returns the internal dependency injector * - * @param string $name - * @param mixed $definition - * @return Compiler + * @return \Phalcon\DiInterface */ - public function addFilter(string $name, $definition): Compiler {} + public function getDI() {} /** - * Register a new function in the compiler + * Sets the compiler options * - * @param string $name - * @param mixed $definition - * @return Compiler + * @param array $options */ - public function addFunction(string $name, $definition): Compiler {} + public function setOptions(array $options) {} /** - * Resolves attribute reading + * Sets a single compiler option * - * @param array $expr - * @return string + * @param string $option + * @param mixed $value */ - public function attributeReader(array $expr): string {} + public function setOption($option, $value) {} /** - * Compiles a template into a file applying the compiler options - * This method does not return the compiled path if the template was not compiled - * - * ```php - * $compiler->compile("views/layouts/main.volt"); - * - * require $compiler->getCompiledTemplatePath(); - * ``` + * Returns a compiler's option * - * @param string $templatePath - * @param bool $extendsMode + * @param string $option + * @return string */ - public function compile(string $templatePath, bool $extendsMode = false) {} + public function getOption($option) {} /** - * Compiles a "autoescape" statement returning PHP code + * Returns the compiler options * - * @param array $statement - * @param bool $extendsMode - * @return string + * @return array */ - public function compileAutoEscape(array $statement, bool $extendsMode): string {} + public function getOptions() {} /** - * Compiles a "cache" statement returning PHP code + * Fires an event to registered extensions * - * @param array $statement - * @param bool $extendsMode - * @return string + * @param string $name + * @param array $arguments + * @return mixed */ - public function compileCache(array $statement, bool $extendsMode = false): string {} + public final function fireExtensionEvent($name, $arguments = null) {} /** - * Compiles calls to macros + * Registers a Volt's extension * - * @param array $statement - * @param bool $extendsMode + * @param mixed $extension + * @return Compiler */ - public function compileCall(array $statement, bool $extendsMode) {} + public function addExtension($extension) {} /** - * Compiles a "case"/"default" clause returning PHP code + * Returns the list of extensions registered in Volt * - * @param array $statement - * @param bool $caseClause - * @return string + * @return array */ - public function compileCase(array $statement, bool $caseClause = true): string {} + public function getExtensions() {} /** - * Compiles a "do" statement returning PHP code + * Register a new function in the compiler * - * @param array $statement - * @return string + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function compileDo(array $statement): string {} + public function addFunction($name, $definition) {} /** - * Compiles a {% raw %}`{{` `}}`{% endraw %} statement returning PHP code + * Register the user registered functions * - * @param array $statement - * @return string + * @return array */ - public function compileEcho(array $statement): string {} + public function getFunctions() {} /** - * Compiles a "elseif" statement returning PHP code + * Register a new filter in the compiler * - * @param array $statement - * @return string + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function compileElseIf(array $statement): string {} + public function addFilter($name, $definition) {} /** - * Compiles a template into a file forcing the destination path - * - * ```php - * $compiler->compileFile( - * "views/layouts/main.volt", - * "views/layouts/main.volt.php" - * ); - * ``` + * Register the user registered filters * - * @param string $path - * @param string $compiledPath - * @param bool $extendsMode - * @return string|array + * @return array */ - public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) {} + public function getFilters() {} /** - * Compiles a "foreach" intermediate code representation into plain PHP code + * Set a unique prefix to be used as prefix for compiled variables * - * @param array $statement - * @param bool $extendsMode - * @return string + * @param string $prefix + * @return Compiler */ - public function compileForeach(array $statement, bool $extendsMode = false): string {} + public function setUniquePrefix($prefix) {} /** - * Generates a 'forelse' PHP code + * Return a unique prefix to be used as prefix for compiled variables and contexts * * @return string */ - public function compileForElse(): string {} + public function getUniquePrefix() {} /** - * Compiles a 'if' statement returning PHP code + * Resolves attribute reading * - * @param array $statement - * @param bool $extendsMode + * @param array $expr * @return string */ - public function compileIf(array $statement, bool $extendsMode = false): string {} + public function attributeReader(array $expr) {} /** - * Compiles a 'include' statement returning PHP code + * Resolves function intermediate code into PHP function calls * - * @param array $statement + * @param array $expr * @return string */ - public function compileInclude(array $statement): string {} + public function functionCall(array $expr) {} /** - * Compiles macros + * Resolves filter intermediate code into a valid PHP expression * - * @param array $statement - * @param bool $extendsMode + * @param array $test + * @param string $left * @return string */ - public function compileMacro(array $statement, bool $extendsMode): string {} + public function resolveTest(array $test, $left) {} /** - * Compiles a "return" statement returning PHP code + * Resolves filter intermediate code into PHP function calls * - * @param array $statement + * @param array $filter + * @param string $left * @return string */ - public function compileReturn(array $statement): string {} + final protected function resolveFilter(array $filter, $left) {} /** - * Compiles a "set" statement returning PHP code + * Resolves an expression node in an AST volt tree * - * @param array $statement + * @param array $expr * @return string */ - public function compileSet(array $statement): string {} + final public function expression(array $expr) {} /** - * Compiles a template into a string - * - * ```php - * echo $compiler->compileString({% raw %}'{{ "hello world" }}'{% endraw %}); - * ``` + * Compiles a block of statements * - * @param string $viewCode - * @param bool $extendsMode - * @return string + * @param array $statements + * @return string|array */ - public function compileString(string $viewCode, bool $extendsMode = false): string {} + final protected function _statementListOrExtends($statements) {} /** - * Compiles a 'switch' statement returning PHP code + * Compiles a "foreach" intermediate code representation into plain PHP code * * @param array $statement * @param bool $extendsMode * @return string */ - public function compileSwitch(array $statement, bool $extendsMode = false): string {} + public function compileForeach(array $statement, $extendsMode = false) {} /** - * Resolves an expression node in an AST volt tree + * Generates a 'forelse' PHP code * - * @param array $expr * @return string */ - final public function expression(array $expr): string {} + public function compileForElse() {} /** - * Fires an event to registered extensions + * Compiles a 'if' statement returning PHP code * - * @param string $name - * @param array $arguments - * @return mixed + * @param array $statement + * @param bool $extendsMode + * @return string */ - final public function fireExtensionEvent(string $name, $arguments = null) {} + public function compileIf(array $statement, $extendsMode = false) {} /** - * Resolves function intermediate code into PHP function calls + * Compiles a 'switch' statement returning PHP code * - * @param array $expr + * @param array $statement + * @param bool $extendsMode * @return string */ - public function functionCall(array $expr): string {} + public function compileSwitch(array $statement, $extendsMode = false) {} /** - * Returns the path to the last compiled template + * Compiles a "case"/"default" clause returning PHP code * + * @param array $statement + * @param bool $caseClause * @return string */ - public function getCompiledTemplatePath(): string {} + public function compileCase(array $statement, $caseClause = true) {} /** - * Returns the internal dependency injector + * Compiles a "elseif" statement returning PHP code * - * @return \Phalcon\Di\DiInterface + * @param array $statement + * @return string */ - public function getDI(): DiInterface {} + public function compileElseIf(array $statement) {} /** - * Returns the list of extensions registered in Volt + * Compiles a "cache" statement returning PHP code * - * @return array + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function getExtensions(): array {} + public function compileCache(array $statement, $extendsMode = false) {} /** - * Register the user registered filters + * Compiles a "set" statement returning PHP code * - * @return array + * @param array $statement + * @return string */ - public function getFilters(): array {} + public function compileSet(array $statement) {} /** - * Register the user registered functions + * Compiles a "do" statement returning PHP code * - * @return array + * @param array $statement + * @return string */ - public function getFunctions(): array {} + public function compileDo(array $statement) {} /** - * Returns a compiler's option + * Compiles a "return" statement returning PHP code * - * @param string $option + * @param array $statement * @return string */ - public function getOption(string $option) {} + public function compileReturn(array $statement) {} /** - * Returns the compiler options + * Compiles a "autoescape" statement returning PHP code * - * @return array + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function getOptions(): array {} + public function compileAutoEscape(array $statement, $extendsMode) {} /** - * Returns the path that is currently being compiled + * Compiles a '{{' '}}' statement returning PHP code * + * @param array $statement + * @param boolean $extendsMode * @return string */ - public function getTemplatePath(): string {} + public function compileEcho(array $statement) {} /** - * Return a unique prefix to be used as prefix for compiled variables and - * contexts + * Compiles a 'include' statement returning PHP code * + * @param array $statement * @return string */ - public function getUniquePrefix(): string {} + public function compileInclude(array $statement) {} /** - * Parses a Volt template returning its intermediate representation - * - * ```php - * print_r( - * $compiler->parse("{% raw %}{{ 3 + 2 }}{% endraw %}") - * ); - * ``` + * Compiles macros * - * @param string $viewCode - * @return array + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function parse(string $viewCode) {} + public function compileMacro(array $statement, $extendsMode) {} /** - * Resolves filter intermediate code into a valid PHP expression + * Compiles calls to macros * - * @param array $test - * @param string $left + * @param array $statement + * @param boolean $extendsMode * @return string */ - public function resolveTest(array $test, string $left): string {} + public function compileCall(array $statement, $extendsMode) {} /** - * Sets the dependency injector + * Traverses a statement list compiling each of its nodes * - * @param \Phalcon\Di\DiInterface $container + * @param array $statements + * @param bool $extendsMode + * @return string */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + final protected function _statementList(array $statements, $extendsMode = false) {} /** - * Sets a single compiler option + * Compiles a Volt source code returning a PHP plain version * - * @param string $option - * @param mixed $value + * @param string $viewCode + * @param bool $extendsMode + * @return string */ - public function setOption(string $option, $value) {} + protected function _compileSource($viewCode, $extendsMode = false) {} /** - * Sets the compiler options + * Compiles a template into a string * - * @param array $options + * + * echo $compiler->compileString('{{ "hello world" }}'); + * + * + * @param string $viewCode + * @param bool $extendsMode + * @return string */ - public function setOptions(array $options) {} + public function compileString($viewCode, $extendsMode = false) {} /** - * Set a unique prefix to be used as prefix for compiled variables + * Compiles a template into a file forcing the destination path * - * @param string $prefix - * @return Compiler + * + * $compiler->compileFile("views/layouts/main.volt", "views/layouts/main.volt.php"); + * + * + * @param string $path + * @param string $compiledPath + * @param boolean $extendsMode + * @return string|array */ - public function setUniquePrefix(string $prefix): Compiler {} + public function compileFile($path, $compiledPath, $extendsMode = false) {} /** - * Compiles a Volt source code returning a PHP plain version + * Compiles a template into a file applying the compiler options + * This method does not return the compiled path if the template was not compiled * - * @param string $viewCode + * + * $compiler->compile("views/layouts/main.volt"); + * + * require $compiler->getCompiledTemplatePath(); + * + * + * @param string $templatePath * @param bool $extendsMode - * @return string */ - protected function compileSource(string $viewCode, bool $extendsMode = false): string {} + public function compile($templatePath, $extendsMode = false) {} /** - * Gets the final path with VIEW + * Returns the path that is currently being compiled * - * @param string $path + * @return string */ - protected function getFinalPath(string $path) {} + public function getTemplatePath() {} /** - * Resolves filter intermediate code into PHP function calls + * Returns the path to the last compiled template * - * @param array $filter - * @param string $left * @return string */ - final protected function resolveFilter(array $filter, string $left): string {} + public function getCompiledTemplatePath() {} /** - * Traverses a statement list compiling each of its nodes + * Parses a Volt template returning its intermediate representation * - * @param array $statements - * @param bool $extendsMode - * @return string + * + * print_r( + * $compiler->parse("{{ 3 + 2 }}") + * ); + * + * + * @param string $viewCode + * @return array */ - final protected function statementList(array $statements, bool $extendsMode = false): string {} + public function parse($viewCode) {} /** - * Compiles a block of statements + * Gets the final path with VIEW * - * @param array $statements - * @return string|array + * @param string $path */ - final protected function statementListOrExtends($statements) {} + protected function getFinalPath($path) {} } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 8f230a7c..0c9ec29b 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -3,6 +3,8 @@ namespace Phalcon\Mvc\View\Engine\Volt; /** + * Phalcon\Mvc\View\Exception + * * Class for exceptions thrown by Phalcon\Mvc\View */ class Exception extends \Phalcon\Mvc\View\Exception @@ -17,13 +19,13 @@ class Exception extends \Phalcon\Mvc\View\Exception * @param int $code * @param \Exception $previous */ - public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) {} + public function __construct($message = '', array $statement = array(), $code = 0, \Exception $previous = null) {} /** * Gets currently parsed statement (if any). * * @return array */ - public function getStatement(): array {} + public function getStatement() {} } diff --git a/src/Phalcon/paginator/Adapter.php b/src/Phalcon/paginator/Adapter.php new file mode 100644 index 00000000..20238657 --- /dev/null +++ b/src/Phalcon/paginator/Adapter.php @@ -0,0 +1,44 @@ + + * use Phalcon\Paginator\Factory; + * $builder = $this->modelsManager->createBuilder() + * ->columns("id, name") + * ->from("Robots") + * ->orderBy("name"); + * + * $options = [ + * "builder" => $builder, + * "limit" => 20, + * "page" => 1, + * "adapter" => "queryBuilder", + * ]; + * $paginator = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + +} diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php deleted file mode 100644 index 1b6a8f76..00000000 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class PaginatorFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * AdapterFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Factory to create an instace from a Config object - * - * ```php - * use Phalcon\Paginator\PaginatorFactory; - * - * $builder = $this - * ->modelsManager - * ->createBuilder() - * ->columns("id, name") - * ->from(Robots::class) - * ->orderBy("name"); - * - * $options = [ - * "builder" => $builder, - * "limit" => 20, - * "page" => 1, - * "adapter" => "queryBuilder", - * ]; - * - * $paginator = (new PaginatorFactory())->load($options); - * ``` - * - * @param mixed $config - * @return mixed - */ - public function load($config) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @param array $options - * @return \Phalcon\Paginator\Adapter\AbstractAdapter - */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index 1d5fe849..03fc7b1c 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -5,123 +5,106 @@ /** * Phalcon\Paginator\Repository * - * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() + * Repository of current state Phalcon\Paginator\AdapterInterface::getPaginate() */ -class Repository implements \Phalcon\Paginator\RepositoryInterface +class Repository implements RepositoryInterface { - /** - * @var array - */ - protected $aliases = array(); - - /** - * @var array - */ - protected $properties = array(); - - - /** - * {@inheritdoc} - * - * @param string $property - * @return mixed|null - */ - public function __get(string $property): ? {} - - /** - * {@inheritdoc} - * - * @return array - */ - public function getAliases(): array {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getCurrent(): int {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getFirst(): int {} - - /** - * {@inheritdoc} - * - * @return mixed - */ - public function getItems() {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getLast(): int {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getLimit(): int {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getNext(): int {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getPrevious(): int {} - - /** - * {@inheritdoc} - * - * @return int - */ - public function getTotalItems(): int {} - - /** - * {@inheritdoc} - * - * @param array $aliases - * @return RepositoryInterface - */ - public function setAliases(array $aliases): RepositoryInterface {} - - /** - * {@inheritdoc} - * - * @param array $properties - * @return RepositoryInterface - */ - public function setProperties(array $properties): RepositoryInterface {} - - /** - * Gets value of property by name - * - * @param string $property - * @param mixed $defaultValue - * @return mixed - */ - protected function getProperty(string $property, $defaultValue = null) {} - - /** - * Resolve alias property name - * - * @param string $property - * @return string - */ - protected function getRealNameProperty(string $property): string {} - + protected $_properties = []; + protected $_aliases = []; + + /** + * {@inheritdoc} + */ + public function setProperties(array $properties) : RepositoryInterface + { + } + + /** + * {@inheritdoc} + */ + public function setAliases(array $aliases) : RepositoryInterface + { + } + + /** + * {@inheritdoc} + */ + public function getAliases() : array + { + } + + /** + * {@inheritdoc} + */ + public function getItems() { + } + + /** + * {@inheritdoc} + */ + public function getTotalItems() : int + { + } + + /** + * {@inheritdoc} + */ + public function getLimit() : int + { + } + + /** + * {@inheritdoc} + */ + public function getFirst() : int + { + } + + /** + * {@inheritdoc} + */ + public function getPrevious() : int + { + } + + /** + * {@inheritdoc} + */ + public function getCurrent() : int + { + } + + /** + * {@inheritdoc} + */ + public function getNext() : int + { + } + + /** + * {@inheritdoc} + */ + public function getLast() : int + { + } + + /** + * {@inheritdoc} + */ + public function __get(string $property) + { + } + + /** + * Gets value of property by name + */ + protected function getProperty(string $property, $defaultValue = null) { + } + + /** + * Resolve legacy alias for compatibility with version 2.0.x + */ + protected function getRealNameProperty(string $property) : string + { + } } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php deleted file mode 100644 index 94b41503..00000000 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ /dev/null @@ -1,117 +0,0 @@ - * use Phalcon\Paginator\Adapter\Model; * * $paginator = new Model( @@ -19,17 +18,37 @@ * ] * ); * - * $paginate = $paginator->paginate(); - * ``` + * $paginate = $paginator->getPaginate(); + * */ -class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter +class Model extends \Phalcon\Paginator\Adapter { + /** + * Configuration of paginator by model + */ + protected $_config = null; + + + /** + * Phalcon\Paginator\Adapter\Model constructor + * + * @param array $config + */ + public function __construct(array $config) {} + + /** + * Returns a slice of the resultset to show in the pagination + * + * @deprecated will be removed after 4.0 + * @return \stdClass + */ + public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @return \stdClass */ - public function paginate(): RepositoryInterface {} + public function paginate() {} } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 36547901..39fee906 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -7,7 +7,7 @@ * * Pagination using a PHP array as source of data * - * ```php + * * use Phalcon\Paginator\Adapter\NativeArray; * * $paginator = new NativeArray( @@ -23,16 +23,36 @@ * "page" => $currentPage, * ] * ); - * ``` + * */ -class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter +class NativeArray extends \Phalcon\Paginator\Adapter { + /** + * Configuration of the paginator + */ + protected $_config = null; + + + /** + * Phalcon\Paginator\Adapter\NativeArray constructor + * + * @param array $config + */ + public function __construct(array $config) {} + + /** + * Returns a slice of the resultset to show in the pagination + * + * @deprecated will be removed after 4.0 + * @return \stdClass + */ + public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @return \stdClass */ - public function paginate(): RepositoryInterface {} + public function paginate() {} } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index 7e810c18..ed229f0a 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -7,12 +7,12 @@ * * Pagination using a PHQL query builder as source of data * - * ```php + * * use Phalcon\Paginator\Adapter\QueryBuilder; * * $builder = $this->modelsManager->createBuilder() * ->columns("id, name") - * ->from(Robots::class) + * ->from("Robots") * ->orderBy("name"); * * $paginator = new QueryBuilder( @@ -22,19 +22,24 @@ * "page" => 1, * ] * ); - * ``` + * */ -class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter +class QueryBuilder extends \Phalcon\Paginator\Adapter { + /** + * Configuration of paginator by model + */ + protected $_config; + /** * Paginator's data */ - protected $builder; + protected $_builder; /** * Columns for count query if builder has having */ - protected $columns; + protected $_columns; /** @@ -49,28 +54,36 @@ public function __construct(array $config) {} * * @return int */ - public function getCurrentPage(): int {} + public function getCurrentPage() {} + + /** + * Set query builder object + * + * @param \Phalcon\Mvc\Model\Query\Builder $builder + * @return QueryBuilder + */ + public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder) {} /** * Get query builder object * * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getQueryBuilder(): Builder {} + public function getQueryBuilder() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @deprecated `will be removed after 4.0 + * @return \stdClass */ - public function paginate(): RepositoryInterface {} + public function getPaginate() {} /** - * Set query builder object + * Returns a slice of the resultset to show in the pagination * - * @param \Phalcon\Mvc\Model\Query\Builder $builder - * @return QueryBuilder + * @return \stdClass */ - public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder {} + public function paginate() {} } diff --git a/src/Phalcon/queue/Beanstalk.php b/src/Phalcon/queue/Beanstalk.php new file mode 100644 index 00000000..fb1308ce --- /dev/null +++ b/src/Phalcon/queue/Beanstalk.php @@ -0,0 +1,269 @@ + + * use Phalcon\Queue\Beanstalk; + * + * $queue = new Beanstalk( + * [ + * "host" => "127.0.0.1", + * "port" => 11300, + * "persistent" => true, + * ] + * ); + * + * + * @link http://www.igvita.com/2010/05/20/scalable-work-queues-with-beanstalk/ + */ +class Beanstalk +{ + /** + * Seconds to wait before putting the job in the ready queue. + * The job will be in the "delayed" state during this time. + * + * @const integer + */ + const DEFAULT_DELAY = 0; + + /** + * Jobs with smaller priority values will be scheduled before jobs with larger priorities. + * The most urgent priority is 0, the least urgent priority is 4294967295. + * + * @const integer + */ + const DEFAULT_PRIORITY = 100; + + /** + * Time to run - number of seconds to allow a worker to run this job. + * The minimum ttr is 1. + * + * @const integer + */ + const DEFAULT_TTR = 86400; + + /** + * Default tube name + * + * @const string + */ + const DEFAULT_TUBE = 'default'; + + /** + * Default connected host + * + * @const string + */ + const DEFAULT_HOST = '127.0.0.1'; + + /** + * Default connected port + * + * @const integer + */ + const DEFAULT_PORT = 11300; + + /** + * Connection resource + * + * @var resource + */ + protected $_connection; + + /** + * Connection options + * + * @var array + */ + protected $_parameters; + + + /** + * Phalcon\Queue\Beanstalk + * + * @param array $parameters + */ + public function __construct(array $parameters = array()) {} + + /** + * Makes a connection to the Beanstalkd server + * + * @return resource + */ + public function connect() {} + + /** + * Puts a job on the queue using specified tube. + * + * @param mixed $data + * @param array $options + * @return int|bool + */ + public function put($data, array $options = null) {} + + /** + * Reserves/locks a ready job from the specified tube. + * + * @param mixed $timeout + * @return bool|\Phalcon\Queue\Beanstalk\Job + */ + public function reserve($timeout = null) {} + + /** + * Change the active tube. By default the tube is "default". + * + * @param string $tube + * @return bool|string + */ + public function choose($tube) {} + + /** + * The watch command adds the named tube to the watch list for the current connection. + * + * @param string $tube + * @return bool|int + */ + public function watch($tube) {} + + /** + * It removes the named tube from the watch list for the current connection. + * + * @param string $tube + * @return bool|int + */ + public function ignore($tube) {} + + /** + * Can delay any new job being reserved for a given time. + * + * @param string $tube + * @param int $delay + * @return bool + */ + public function pauseTube($tube, $delay) {} + + /** + * The kick command applies only to the currently used tube. + * + * @param int $bound + * @return bool|int + */ + public function kick($bound) {} + + /** + * Gives statistical information about the system as a whole. + * + * @return bool|array + */ + public function stats() {} + + /** + * Gives statistical information about the specified tube if it exists. + * + * @param string $tube + * @return bool|array + */ + public function statsTube($tube) {} + + /** + * Returns a list of all existing tubes. + * + * @return bool|array + */ + public function listTubes() {} + + /** + * Returns the tube currently being used by the client. + * + * @return bool|string + */ + public function listTubeUsed() {} + + /** + * Returns a list tubes currently being watched by the client. + * + * @return bool|array + */ + public function listTubesWatched() {} + + /** + * Inspect the next ready job. + * + * @return bool|\Phalcon\Queue\Beanstalk\Job + */ + public function peekReady() {} + + /** + * Return the next job in the list of buried jobs. + * + * @return bool|\Phalcon\Queue\Beanstalk\Job + */ + public function peekBuried() {} + + /** + * Return the next job in the list of buried jobs. + * + * @return bool|\Phalcon\Queue\Beanstalk\Job + */ + public function peekDelayed() {} + + /** + * The peek commands let the client inspect a job in the system. + * + * @param int $id + * @return bool|\Phalcon\Queue\Beanstalk\Job + */ + public function jobPeek($id) {} + + /** + * Reads the latest status from the Beanstalkd server + * + * @return array + */ + final public function readStatus() {} + + /** + * Fetch a YAML payload from the Beanstalkd server + * + * @return array + */ + final public function readYaml() {} + + /** + * Reads a packet from the socket. Prior to reading from the socket will + * check for availability of the connection. + * + * @param int $length + * @return bool|string + */ + public function read($length = 0) {} + + /** + * Writes data to the socket. Performs a connection if none is available + * + * @param string $data + * @return bool|int + */ + public function write($data) {} + + /** + * Closes the connection to the beanstalk server. + * + * @return bool + */ + public function disconnect() {} + + /** + * Simply closes the connection. + * + * @return bool + */ + public function quit() {} + +} diff --git a/src/Phalcon/queue/beanstalk/Exception.php b/src/Phalcon/queue/beanstalk/Exception.php new file mode 100644 index 00000000..e2bb63bc --- /dev/null +++ b/src/Phalcon/queue/beanstalk/Exception.php @@ -0,0 +1,13 @@ + * $random = new \Phalcon\Security\Random(); * * // Random binary string @@ -68,7 +68,7 @@ * echo $random->base58(); // Umjxqf7ZPwh765yR * echo $random->base58(24); // qoXcgmw4A9dys26HaNEdCRj9 * echo $random->base58(7); // 774SJD3vgP - * ``` + * * * This class partially borrows SecureRandom library from Ruby * @@ -77,21 +77,61 @@ class Random { + /** + * Generates a random binary string + * + * The `Random::bytes` method returns a string and accepts as input an int + * representing the length in bytes to be returned. + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The result may contain any byte: "x00" - "xFF". + * + * + * $random = new \Phalcon\Security\Random(); + * + * $bytes = $random->bytes(); + * var_dump(bin2hex($bytes)); + * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" + * + * + * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len + * @return string + */ + public function bytes($len = 16) {} + + /** + * Generates a random hex string + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The length of the result string is usually greater of $len. + * + * + * $random = new \Phalcon\Security\Random(); + * + * echo $random->hex(10); // a29f470508d5ccb8e289 + * + * + * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len + * @return string + */ + public function hex($len = null) {} + /** * Generates a random base58 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The result may contain alphanumeric characters except 0, O, I and l. * - * It is similar to `Phalcon\Security\Random::base64()` but has been - * modified to avoid both non-alphanumeric characters and letters which - * might look ambiguous when printed. + * It is similar to `Phalcon\Security\Random:base64` but has been modified to avoid both non-alphanumeric + * characters and letters which might look ambiguous when printed. * - * ```php + * * $random = new \Phalcon\Security\Random(); * * echo $random->base58(); // 4kUgL2pdQMSCQtjE - * ``` + * * * @see \Phalcon\Security\Random:base64 * @link https://en.wikipedia.org/wiki/Base58 @@ -99,49 +139,47 @@ class Random * @param int $len * @return string */ - public function base58(int $len = null): string {} + public function base58($len = null) {} /** * Generates a random base62 string * * If $len is not specified, 16 is assumed. It may be larger in future. * - * It is similar to `Phalcon\Security\Random::base58()` but has been - * modified to provide the largest value that can safely be used in URLs - * without needing to take extra characters into consideration because it is - * [A-Za-z0-9]. + * It is similar to `Phalcon\Security\Random:base58` but has been modified to provide the largest value that can + * safely be used in URLs without needing to take extra characters into consideration because it is [A-Za-z0-9]. * - * ```php + * * $random = new \Phalcon\Security\Random(); * * echo $random->base62(); // z0RkwHfh8ErDM1xw - * ``` + * * * @see \Phalcon\Security\Random:base58 * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base62(int $len = null): string {} + public function base62($len = null) {} /** * Generates a random base64 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. - * Size formula: 4 ($len / 3) rounded up to a multiple of 4. + * Size formula: 4 ($len / 3) and this need to be rounded up to a multiple of 4. * - * ```php + * * $random = new \Phalcon\Security\Random(); * * echo $random->base64(12); // 3rcq39QzGK9fUqh8 - * ``` + * * * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base64(int $len = null): string {} + public function base64($len = null) {} /** * Generates a random URL-safe base64 string @@ -149,16 +187,15 @@ public function base64(int $len = null): string {} * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. * - * By default, padding is not generated because "=" may be used as a URL - * delimiter. The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also - * used if $padding is true. See RFC 3548 for the definition of URL-safe - * base64. + * By default, padding is not generated because "=" may be used as a URL delimiter. + * The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if $padding is true. + * See RFC 3548 for the definition of URL-safe base64. * - * ```php + * * $random = new \Phalcon\Security\Random(); * * echo $random->base64Safe(); // GD8JojhzSTrqX7Q8J6uug - * ``` + * * * @link https://www.ietf.org/rfc/rfc3548.txt * @throws Exception If secure random number generator is not available or unexpected partial read @@ -166,94 +203,50 @@ public function base64(int $len = null): string {} * @param bool $padding * @return string */ - public function base64Safe(int $len = null, bool $padding = false): string {} + public function base64Safe($len = null, $padding = false) {} /** - * Generates a random binary string - * - * The `Random::bytes` method returns a string and accepts as input an int - * representing the length in bytes to be returned. - * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The result may contain any byte: "x00" - "xFF". - * - * ```php - * $random = new \Phalcon\Security\Random(); - * - * $bytes = $random->bytes(); - * var_dump(bin2hex($bytes)); - * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" - * ``` + * Generates a v4 random UUID (Universally Unique IDentifier) * - * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len - * @return string - */ - public function bytes(int $len = 16): string {} - - /** - * Generates a random hex string + * The version 4 UUID is purely random (except the version). It doesn't contain meaningful + * information such as MAC address, time, etc. See RFC 4122 for details of UUID. * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The length of the result string is usually greater of $len. + * This algorithm sets the version number (4 bits) as well as two reserved bits. + * All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. + * Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal + * digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). * - * ```php + * * $random = new \Phalcon\Security\Random(); * - * echo $random->hex(10); // a29f470508d5ccb8e289 - * ``` + * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 + * * + * @link https://www.ietf.org/rfc/rfc4122.txt * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len * @return string */ - public function hex(int $len = null): string {} + public function uuid() {} /** * Generates a random number between 0 and $len * * Returns an integer: 0 <= result <= $len. * - * ```php + * * $random = new \Phalcon\Security\Random(); * * echo $random->number(16); // 8 - * ``` + * * * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 * @param int $len * @return int */ - public function number(int $len): int {} - - /** - * Generates a v4 random UUID (Universally Unique IDentifier) - * - * The version 4 UUID is purely random (except the version). It doesn't - * contain meaningful information such as MAC address, time, etc. See RFC - * 4122 for details of UUID. - * - * This algorithm sets the version number (4 bits) as well as two reserved - * bits. All other bits (the remaining 122 bits) are set using a random or - * pseudorandom data source. Version 4 UUIDs have the form - * xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and - * y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). - * - * ```php - * $random = new \Phalcon\Security\Random(); - * - * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 - * ``` - * - * @link https://www.ietf.org/rfc/rfc4122.txt - * @throws Exception If secure random number generator is not available or unexpected partial read - * @return string - */ - public function uuid(): string {} + public function number($len) {} /** - * Generates a random string based on the number ($base) of characters - * ($alphabet). + * Generates a random string based on the number ($base) of characters ($alphabet). * * If $n is not specified, 16 is assumed. It may be larger in future. * @@ -263,6 +256,6 @@ public function uuid(): string {} * @param mixed $n * @return string */ - protected function base(string $alphabet, int $base, $n = null): string {} + protected function base($alphabet, $base, $n = null) {} } diff --git a/src/Phalcon/service/Exception.php b/src/Phalcon/service/Exception.php new file mode 100644 index 00000000..22ac2332 --- /dev/null +++ b/src/Phalcon/service/Exception.php @@ -0,0 +1,12 @@ + + * $session->setOptions( + * [ + * "uniqueId" => "my-private-app", + * ] + * ); + * + * + * @param array $options + */ + public function setOptions(array $options) {} + + /** + * Get internal options + * + * @return array + */ + public function getOptions() {} + + /** + * Set session name + * + * @param string $name + */ + public function setName($name) {} + + /** + * Get session name + * + * @return string + */ + public function getName() {} + + /** + * {@inheritdoc} + * + * @param bool $deleteOldSession + * @return AdapterInterface + */ + public function regenerateId($deleteOldSession = true) {} + + /** + * Gets a session variable from an application context + * + * + * $session->get("auth", "yes"); + * + * + * @param string $index + * @param mixed $defaultValue + * @param bool $remove + * @return mixed + */ + public function get($index, $defaultValue = null, $remove = false) {} + + /** + * Sets a session variable in an application context + * + * + * $session->set("auth", "yes"); + * + * + * @param string $index + * @param mixed $value + */ + public function set($index, $value) {} + + /** + * Check whether a session variable is set in an application context + * + * + * var_dump( + * $session->has("auth") + * ); + * + * + * @param string $index + * @return bool + */ + public function has($index) {} + + /** + * Removes a session variable from an application context + * + * + * $session->remove("auth"); + * + * + * @param string $index + */ + public function remove($index) {} + + /** + * Returns active session id + * + * + * echo $session->getId(); + * + * + * @return string + */ + public function getId() {} + + /** + * Set the current session id + * + * + * $session->setId($id); + * + * + * @param string $id + */ + public function setId($id) {} + + /** + * Check whether the session has been started + * + * + * var_dump( + * $session->isStarted() + * ); + * + * + * @return bool + */ + public function isStarted() {} + + /** + * Destroys the active session + * + * + * var_dump( + * $session->destroy() + * ); + * + * var_dump( + * $session->destroy(true) + * ); + * + * + * @param mixed $removeData + * @return bool + */ + public function destroy($removeData = null) {} + + /** + * Returns the status of the current session. + * + * + * var_dump( + * $session->status() + * ); + * + * if ($session->status() !== $session::SESSION_ACTIVE) { + * $session->start(); + * } + * + * + * @return int + */ + public function status() {} + + /** + * Alias: Gets a session variable from an application context + * + * @param string $index + * @return mixed + */ + public function __get($index) {} + + /** + * Alias: Sets a session variable in an application context + * + * @param string $index + * @param mixed $value + */ + public function __set($index, $value) {} + + /** + * Alias: Check whether a session variable is set in an application context + * + * @param string $index + * @return bool + */ + public function __isset($index) {} + + /** + * Alias: Removes a session variable from an application context + * + * + * unset($session->auth); + * + * + * @param string $index + */ + public function __unset($index) {} + + + public function __destruct() {} + + + protected function removeSessionData() {} + +} diff --git a/src/Phalcon/session/AdapterInterface.php b/src/Phalcon/session/AdapterInterface.php new file mode 100644 index 00000000..aba0f232 --- /dev/null +++ b/src/Phalcon/session/AdapterInterface.php @@ -0,0 +1,108 @@ + * $user = new \Phalcon\Session\Bag("user"); * * $user->name = "Kimbra Johnson"; * $user->age = 22; - * ``` + * */ -class Bag extends \Phalcon\Collection implements \Phalcon\Di\InjectionAwareInterface +class Bag implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Session\BagInterface, \IteratorAggregate, \ArrayAccess, \Countable { - private $container; + protected $_dependencyInjector; - private $name = null; + protected $_name = null; - private $session; + protected $_data; + + + protected $_initialized = false; + + + protected $_session; /** @@ -33,47 +38,176 @@ class Bag extends \Phalcon\Collection implements \Phalcon\Di\InjectionAwareInter * * @param string $name */ - public function __construct(string $name) {} + public function __construct($name) {} /** - * Destroys the session bag + * Sets the DependencyInjector container + * + * @param \Phalcon\DiInterface $dependencyInjector */ - public function clear() {} + public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return \Phalcon\DiInterface */ - public function getDI(): DiInterface {} + public function getDI() {} /** - * Removes a property from the internal bag - * - * @param array $data + * Initializes the session bag. This method must not be called directly, the + * class calls it when its internal data is accessed */ - public function init(array $data = array()) {} + public function initialize() {} /** - * Removes a property from the internal bag + * Destroys the session bag * - * @param string $element + * + * $user->destroy(); + * */ - public function remove(string $element) {} + public function destroy() {} /** * Sets a value in the session bag * - * @param string $element + * + * $user->set("name", "Kimbra"); + * + * + * @param string $property * @param mixed $value */ - public function set(string $element, $value) {} + public function set($property, $value) {} /** - * Sets the DependencyInjector container + * Magic setter to assign values to the session bag + * + * + * $user->name = "Kimbra"; + * + * + * @param string $property + * @param mixed $value + */ + public function __set($property, $value) {} + + /** + * Obtains a value from the session bag optionally setting a default value + * + * + * echo $user->get("name", "Kimbra"); + * + * + * @param string $property + * @param mixed $defaultValue + */ + public function get($property, $defaultValue = null) {} + + /** + * Magic getter to obtain values from the session bag + * + * + * echo $user->name; + * + * + * @param string $property + * @return mixed + */ + public function __get($property) {} + + /** + * Check whether a property is defined in the internal bag + * + * + * var_dump( + * $user->has("name") + * ); + * + * + * @param string $property + * @return bool + */ + public function has($property) {} + + /** + * Magic isset to check whether a property is defined in the bag * - * @param \Phalcon\Di\DiInterface $container + * + * var_dump( + * isset($user["name"]) + * ); + * + * + * @param string $property + * @return bool + */ + public function __isset($property) {} + + /** + * Removes a property from the internal bag + * + * + * $user->remove("name"); + * + * + * @param string $property + * @return bool + */ + public function remove($property) {} + + /** + * Magic unset to remove items using the array syntax + * + * + * unset($user["name"]); + * + * + * @param string $property + * @return bool + */ + public function __unset($property) {} + + /** + * Return length of bag + * + * + * echo $user->count(); + * + * + * @return int + */ + public final function count() {} + + /** + *  Returns the bag iterator + * + * @return \ArrayIterator + */ + public final function getIterator() {} + + /** + * @param mixed $property + * @param mixed $value + */ + public final function offsetSet($property, $value) {} + + /** + * @param mixed $property + * @return bool + */ + public final function offsetExists($property) {} + + /** + * @param mixed $property + */ + public final function offsetUnset($property) {} + + /** + * @param mixed $property + * @return mixed */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public final function offsetGet($property) {} } diff --git a/src/Phalcon/session/BagInterface.php b/src/Phalcon/session/BagInterface.php new file mode 100644 index 00000000..ed3afba4 --- /dev/null +++ b/src/Phalcon/session/BagInterface.php @@ -0,0 +1,73 @@ + + * use Phalcon\Session\Factory; + * + * $options = [ + * "uniqueId" => "my-private-app", + * "host" => "127.0.0.1", + * "port" => 11211, + * "persistent" => true, + * "lifetime" => 3600, + * "prefix" => "my_", + * "adapter" => "memcache", + * ]; + * $session = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + +} diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 1ce22d22..19b0c3b4 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -2,237 +2,238 @@ namespace Phalcon\Session; +use InvalidArgumentException; +use RuntimeException; +use SessionHandlerInterface; +use Phalcon\DiInterface; +use Phalcon\DI\InjectionAwareInterface; +use Phalcon\Helper\Arr; +use Phalcon\Session\ManagerInterface; + /** * Phalcon\Session\Manager * * Session manager class */ -class Manager implements \Phalcon\Session\ManagerInterface, \Phalcon\DI\InjectionAwareInterface +class Manager implements ManagerInterface, InjectionAwareInterface { /** * @var */ private $container; - /** - * @var |null - */ - private $handler = null; - - /** - * @var string - */ - private $name = ''; - - /** - * @var array - */ - private $options = array(); - - /** - * @var string - */ - private $uniqueId = ''; - - - /** - * Manager constructor. - * - * @param array $options - */ - public function __construct(array $options = array()) {} - - /** - * Alias: Gets a session variable from an application context - * - * @param string $key - * @return mixed - */ - public function __get(string $key) {} - - /** - * Alias: Check whether a session variable is set in an application context - * - * @param string $key - * @return bool - */ - public function __isset(string $key): bool {} - - /** - * Alias: Sets a session variable in an application context - * - * @param string $key - * @param mixed $value - */ - public function __set(string $key, $value) {} - - /** - * Alias: Removes a session variable from an application context - * - * @param string $key - */ - public function __unset(string $key) {} - - /** - * Destroy/end a session - */ - public function destroy() {} - - /** - * Check whether the session has been started - * - * @return bool - */ - public function exists(): bool {} - - /** - * Gets a session variable from an application context - * - * @param string $key - * @param mixed $defaultValue - * @param bool $remove - * @return mixed - */ - public function get(string $key, $defaultValue = null, bool $remove = false) {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns the stored session handler - * - * @return \SessionHandlerInterface - */ - public function getHandler(): SessionHandlerInterface {} - - /** - * Returns the session id - * - * @return string - */ - public function getId(): string {} - - /** - * Returns the name of the session - * - * @return string - */ - public function getName(): string {} - - /** - * Check whether a session variable is set in an application context - * - * @param string $key - * @return bool - */ - public function has(string $key): bool {} - - /** - * Get internal options - * - * @return array - */ - public function getOptions(): array {} - - /** - * Regenerates the session id using the handler. - * - * @param mixed $deleteOldSession - * @return \Phalcon\Session\ManagerInterface - */ - public function regenerateId($deleteOldSession = true): ManagerInterface {} - - /** - * Registers a handler with the session - * - * @param \SessionHandlerInterface $handler - * @return bool - */ - public function registerHandler(\SessionHandlerInterface $handler): bool {} - - /** - * Removes a session variable from an application context - * - * @param string $key - */ - public function remove(string $key) {} - - /** - * Sets a session variable in an application context - * - * @param string $key - * @param mixed $value - */ - public function set(string $key, $value) {} - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Set the handler for the session - * - * @param \SessionHandlerInterface $handler - * @return \Phalcon\Session\ManagerInterface - */ - public function setHandler(\SessionHandlerInterface $handler): ManagerInterface {} - - /** - * Set session Id - * - * @param string $id - * @return \Phalcon\Session\ManagerInterface - */ - public function setId(string $id): ManagerInterface {} - - /** - * Set the session name. Throw exception if the session has started - * and do not allow poop names - * - * @param string name - * - * @throws InvalidArgumentException - * - * @param string $name - * @return \Phalcon\Session\ManagerInterface - */ - public function setName(string $name): ManagerInterface {} - - /** - * Sets session's options - * - * @param array $options - */ - public function setOptions(array $options) {} - - /** - * Starts the session (if headers are already sent the session will not be - * started) - * - * @return bool - */ - public function start(): bool {} - - /** - * Returns the status of the current session. - * - * @return int - */ - public function status(): int {} - - /** - * Returns the key prefixed - * - * @param string $key - * @return string - */ - private function getUniqueKey(string $key): string {} - + /** + * @var |null + */ + private $handler = null; + + /** + * @var string + */ + private $name = ""; + + /** + * @var array + */ + private $options = []; + + /** + * @var string + */ + private $uniqueId = ""; + + /** + * Manager constructor. + * + * @param array options + */ + public function __construct(array $options = []) + { + } + + + /** + * Alias: Gets a session variable from an application context + */ + public function __get(string $key) { + } + + /** + * Alias: Check whether a session variable is set in an application context + */ + public function __isset(string $key) : bool + { + } + + /** + * Alias: Sets a session variable in an application context + */ + public function __set(string $key, $value) : void + { + } + + /** + * Alias: Removes a session variable from an application context + */ + public function __unset(string $key) + { + } + + /** + * Destroy/end a session + */ + public function destroy() : void + { + } + + /** + * Check whether the session has been started + */ + public function exists() : bool + { + } + + /** + * Gets a session variable from an application context + */ + public function get(string $key, $defaultValue = null, bool $remove = false) { + } + + /** + * Returns the DependencyInjector container + */ + public function getDI() : DiInterface + { + } + + /** + * Returns the stored session handler + */ + public function getHandler() : SessionHandlerInterface + { + } + + /** + * Returns the session id + */ + public function getId() : string + { + } + + /** + * Returns the name of the session + */ + public function getName() : string + { + } + + /** + * Check whether a session variable is set in an application context + */ + public function has(string $key) : bool + { + } + + /** + * Get internal options + */ + public function getOptions() : array + { + } + + /** + * Regenerates the session id using the handler. + */ + public function regenerateId($deleteOldSession = true) : ManagerInterface + { + } + + /** + * Registers a handler with the session + */ + public function registerHandler(SessionHandlerInterface $handler) : bool + { + } + + /** + * Removes a session variable from an application context + */ + public function remove(string $key) + { + } + + /** + * Sets a session variable in an application context + */ + public function set(string $key, $value) : void + { + } + + /** + * Sets the DependencyInjector container + */ + public function setDI(DiInterface $container) + { + } + + /** + * Set the handler for the session + */ + public function setHandler(SessionHandlerInterface $handler) : ManagerInterface + { + } + + /** + * Set session Id + */ + public function setId(string $id) : ManagerInterface + { + } + + /** + * Set the session name. Throw exception if the session has started + * and do not allow poop names + * + * @param string name + * + * @throws InvalidArgumentException + * + * @return Manager + */ + public function setName(string $name) : ManagerInterface + { + } + + /** + * Sets session's options + * + * @param array options + */ + public function setOptions(array $options) : void + { + } + + /** + * Starts the session (if headers are already sent the session will not be + * started) + */ + public function start() : bool + { + } + + /** + * Returns the status of the current session. + * + * @return int + */ + public function status() : int + { + } + + /** + * Returns the key prefixed + */ + private function getUniqueKey(string $key) : string + { + } } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php deleted file mode 100644 index 0bdb4024..00000000 --- a/src/Phalcon/session/ManagerInterface.php +++ /dev/null @@ -1,189 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -abstract class AbstractAdapter implements \SessionHandlerInterface -{ - /** - * @var - */ - protected $adapter; - - - /** - * Close - * - * @return bool - */ - public function close(): bool {} - - /** - * Destroy - * - * @param mixed $id - * @return bool - */ - public function destroy($id): bool {} - - /** - * Garbage Collector - * - * @param mixed $maxlifetime - * @return bool - */ - public function gc($maxlifetime): bool {} - - /** - * Read - * - * @param mixed $id - * @return string - */ - public function read($id): string {} - - /** - * Open - * - * @param mixed $savePath - * @param mixed $sessionName - * @return bool - */ - public function open($savePath, $sessionName): bool {} - - /** - * Write - * - * @param mixed $id - * @param mixed $data - * @return bool - */ - public function write($id, $data): bool {} - -} diff --git a/src/Phalcon/session/adapter/Files.php b/src/Phalcon/session/adapter/Files.php new file mode 100644 index 00000000..ffe3b7f0 --- /dev/null +++ b/src/Phalcon/session/adapter/Files.php @@ -0,0 +1,29 @@ + + * use Phalcon\Session\Adapter\Files; + * + * $session = new Files( + * [ + * "uniqueId" => "my-private-app", + * ] + * ); + * + * $session->start(); + * + * $session->set("var", "some-value"); + * + * echo $session->get("var"); + * + */ +class Files extends \Phalcon\Session\Adapter +{ + +} diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 83668e14..c1d60223 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -4,16 +4,100 @@ /** * Phalcon\Session\Adapter\Libmemcached + * + * This adapter store sessions in libmemcached + * + * + * use Phalcon\Session\Adapter\Libmemcached; + * + * $session = new Libmemcached( + * [ + * "servers" => [ + * [ + * "host" => "localhost", + * "port" => 11211, + * "weight" => 1, + * ], + * ], + * "client" => [ + * \Memcached::OPT_HASH => \Memcached::HASH_MD5, + * \Memcached::OPT_PREFIX_KEY => "prefix.", + * ], + * "lifetime" => 3600, + * "prefix" => "my_", + * ] + * ); + * + * $session->start(); + * + * $session->set("var", "some-value"); + * + * echo $session->get("var"); + * */ -class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter +class Libmemcached extends \Phalcon\Session\Adapter { + protected $_libmemcached = null; + + + protected $_lifetime = 8600; + + + + public function getLibmemcached() {} + + + public function getLifetime() {} + /** - * Constructor + * Phalcon\Session\Adapter\Libmemcached constructor * - * @param \Phalcon\Storage\AdapterFactory $factory + * @throws \Phalcon\Session\Exception * @param array $options */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} + public function __construct(array $options) {} + + /** + * @return bool + */ + public function open() {} + + /** + * @return bool + */ + public function close() {} + + /** + * {@inheritdoc} + * + * @param string $sessionId + * @return string + */ + public function read($sessionId) {} + + /** + * {@inheritdoc} + * + * @param string $sessionId + * @param string $data + * @return bool + */ + public function write($sessionId, $data) {} + + /** + * {@inheritdoc} + * + * @param mixed $sessionId + * @return bool + */ + public function destroy($sessionId = null) {} + + /** + * {@inheritdoc} + * + * @return bool + */ + public function gc() {} } diff --git a/src/Phalcon/session/adapter/Memcache.php b/src/Phalcon/session/adapter/Memcache.php new file mode 100644 index 00000000..c5cac728 --- /dev/null +++ b/src/Phalcon/session/adapter/Memcache.php @@ -0,0 +1,95 @@ + + * use Phalcon\Session\Adapter\Memcache; + * + * $session = new Memcache( + * [ + * "uniqueId" => "my-private-app", + * "host" => "127.0.0.1", + * "port" => 11211, + * "persistent" => true, + * "lifetime" => 3600, + * "prefix" => "my_", + * ] + * ); + * + * $session->start(); + * + * $session->set("var", "some-value"); + * + * echo $session->get("var"); + * + */ +class Memcache extends \Phalcon\Session\Adapter +{ + + protected $_memcache = null; + + + protected $_lifetime = 8600; + + + + public function getMemcache() {} + + + public function getLifetime() {} + + /** + * Phalcon\Session\Adapter\Memcache constructor + * + * @param array $options + */ + public function __construct(array $options = array()) {} + + /** + * @return bool + */ + public function open() {} + + /** + * @return bool + */ + public function close() {} + + /** + * {@inheritdoc} + * + * @param string $sessionId + * @return string + */ + public function read($sessionId) {} + + /** + * {@inheritdoc} + * + * @param string $sessionId + * @param string $data + * @return bool + */ + public function write($sessionId, $data) {} + + /** + * {@inheritdoc} + * + * @param mixed $sessionId + * @return bool + */ + public function destroy($sessionId = null) {} + + /** + * {@inheritdoc} + * + * @return bool + */ + public function gc() {} + +} diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index 02a62873..ed866229 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -2,13 +2,15 @@ namespace Phalcon\Session\Adapter; +use SessionHandlerInterface; + /** * Phalcon\Session\Adapter\Noop * * This is an "empty" or null adapter. It can be used for testing or any * other purpose that no session needs to be invoked * - * ```php + * * setHandler(new Noop()); - * ``` + * */ -class Noop implements \SessionHandlerInterface +class Noop implements SessionHandlerInterface { /** * The connection of some adapters */ - protected $connection; + protected $connection; - /** - * Session options - * - * @var array - */ - protected $options = array(); + /** + * Session options + * + * @var array + */ + protected $options = []; - /** - * Session prefix - * - * @var string - */ - protected $prefix = ''; + /** + * Session prefix + * + * @var string + */ + protected $prefix = ""; - /** - * Time To Live - * - * @var int - */ - protected $ttl = 8600; + /** + * Time To Live + * + * @var int + */ + protected $ttl = 8600; + /** + * Constructor + */ + public function __construct(array $options = []) + { + } - /** - * Constructor - * - * @param array $options - */ - public function __construct(array $options = array()) {} + /** + * Close + */ + public function close() : bool + { + } - /** - * Close - * - * @return bool - */ - public function close(): bool {} + /** + * Destroy + */ + public function destroy($id) : bool + { + } - /** - * Destroy - * - * @param mixed $id - * @return bool - */ - public function destroy($id): bool {} + /** + * Garbage Collector + */ + public function gc($maxlifetime) : bool + { + } - /** - * Garbage Collector - * - * @param mixed $maxlifetime - * @return bool - */ - public function gc($maxlifetime): bool {} - - /** - * Read - * - * @param mixed $id - * @return string - */ - public function read($id): string {} - - /** - * Open - * - * @param mixed $savePath - * @param mixed $sessionName - * @return bool - */ - public function open($savePath, $sessionName): bool {} + /** + * Read + */ + public function read($id) : string + { + } - /** - * Write - * - * @param mixed $id - * @param mixed $data - * @return bool - */ - public function write($id, $data): bool {} + /** + * Open + */ + public function open($savePath, $sessionName) : bool + { + } - /** - * Helper method to get the name prefixed - * - * @param mixed $name - * @return string - */ - protected function getPrefixedName($name): string {} + /** + * Write + */ + public function write($id, $data) : bool + { + } + /** + * Helper method to get the name prefixed + */ + protected function getPrefixedName($name) : string + { + } } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 9df67fd7..179e2d47 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -4,16 +4,98 @@ /** * Phalcon\Session\Adapter\Redis + * + * This adapter store sessions in Redis + * + * + * use Phalcon\Session\Adapter\Redis; + * + * $session = new Redis( + * [ + * "uniqueId" => "my-private-app", + * "host" => "localhost", + * "port" => 6379, + * "auth" => "foobared", + * "persistent" => false, + * "lifetime" => 3600, + * "prefix" => "my", + * "index" => 1, + * ] + * ); + * + * $session->start(); + * + * $session->set("var", "some-value"); + * + * echo $session->get("var"); + * */ -class Redis extends \Phalcon\Session\Adapter\AbstractAdapter +class Redis extends \Phalcon\Session\Adapter { + protected $_redis = null; + + + protected $_lifetime = 8600; + + + + public function getRedis() {} + + + public function getLifetime() {} + /** - * Constructor + * Phalcon\Session\Adapter\Redis constructor * - * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} + public function __construct(array $options = array()) {} + + /** + * {@inheritdoc} + * + * @return bool + */ + public function open() {} + + /** + * {@inheritdoc} + * + * @return bool + */ + public function close() {} + + /** + * {@inheritdoc} + * + * @param mixed $sessionId + * @return string + */ + public function read($sessionId) {} + + /** + * {@inheritdoc} + * + * @param string $sessionId + * @param string $data + * @return bool + */ + public function write($sessionId, $data) {} + + /** + * {@inheritdoc} + * + * @param mixed $sessionId + * @return bool + */ + public function destroy($sessionId = null) {} + + /** + * {@inheritdoc} + * + * @return bool + */ + public function gc() {} } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php deleted file mode 100644 index 50f4da55..00000000 --- a/src/Phalcon/session/adapter/Stream.php +++ /dev/null @@ -1,70 +0,0 @@ - '/tmp', - * ] - * ); - * $session->setHandler($files); - * ``` - */ -class Stream extends \Phalcon\Session\Adapter\Noop -{ - /** - * @var string - */ - private $path = ''; - - - /** - * @param array $options - */ - public function __construct(array $options = array()) {} - - /** - * @param mixed $id - * @return bool - */ - public function destroy($id): bool {} - - /** - * @param mixed $maxlifetime - * @return bool - */ - public function gc($maxlifetime): bool {} - - /** - * @param mixed $savePath - * @param mixed $sessionName - * @return bool - */ - public function open($savePath, $sessionName): bool {} - - /** - * @param mixed $id - * @return string - */ - public function read($id): string {} - - /** - * @param mixed $id - * @param mixed $data - * @return bool - */ - public function write($id, $data): bool {} - -} diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php deleted file mode 100644 index 22477029..00000000 --- a/src/Phalcon/storage/AdapterFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class AdapterFactory extends \Phalcon\Factory\AbstractFactory -{ - /** - * @var - */ - private $serializerFactory; - - - /** - * AdapterFactory constructor. - * - * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $services - */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @param array $options - * @return \Phalcon\Storage\Adapter\AbstractAdapter - */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/storage/Exception.php b/src/Phalcon/storage/Exception.php deleted file mode 100644 index e699f6fa..00000000 --- a/src/Phalcon/storage/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class SerializerFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * SerializerFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * @param string name - * - * @throws Exception - * @param string $name - * @return \Phalcon\Storage\Serializer\SerializerInterface - */ - public function newInstance(string $name): SerializerInterface {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php deleted file mode 100644 index ec177404..00000000 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ /dev/null @@ -1,195 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface -{ - /** - * @var mixed - */ - protected $adapter; - - /** - * Name of the default serializer class - * - * @var string - */ - protected $defaultSerializer = 'Php'; - - /** - * Name of the default TTL (time to live) - * - * @var int - */ - protected $lifetime = 3600; - - /** - * @var string - */ - protected $prefix = ''; - - /** - * Serializer - * - * @var - */ - protected $serializer; - - /** - * Serializer Factory - * - * @var - */ - protected $serializerFactory; - - - /** - * Name of the default serializer class - * - * @return string - */ - public function getDefaultSerializer(): string {} - - /** - * Name of the default serializer class - * - * @param string $defaultSerializer - */ - public function setDefaultSerializer(string $defaultSerializer) {} - - /** - * @return string - */ - public function getPrefix(): string {} - - /** - * Sets parameters based on options - * - * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options - */ - protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) {} - - /** - * Flushes/clears the cache - * - * @return bool - */ - abstract public function clear(): bool; - - /** - * Decrements a stored number - * - * @param string $key - * @param int $value - * @return int|bool - */ - abstract public function decrement(string $key, int $value = 1); - - /** - * Deletes data from the adapter - * - * @param string $key - * @return bool - */ - abstract public function delete(string $key): bool; - - /** - * Reads data from the adapter - * - * @param string $key - * @return mixed - */ - abstract public function get(string $key); - - /** - * Returns the adapter - connects to the storage if not connected - * - * @return mixed - */ - abstract public function getAdapter(); - - /** - * Returns all the keys stored - * - * @return array - */ - abstract public function getKeys(): array; - - /** - * Checks if an element exists in the cache - * - * @param string $key - * @return bool - */ - abstract public function has(string $key): bool; - - /** - * Increments a stored number - * - * @param string $key - * @param int $value - * @return int|bool - */ - abstract public function increment(string $key, int $value = 1); - - /** - * Stores data in the adapter - * - * @param string $key - * @param mixed $value - * @param mixed $ttl - * @return bool - */ - abstract public function set(string $key, $value, $ttl = null): bool; - - /** - * Returns the key requested, prefixed - * - * @param mixed $key - * @return string - */ - protected function getPrefixedKey($key): string {} - - /** - * Returns serialized data - * - * @param mixed $content - * @return mixed - */ - protected function getSerializedData($content) {} - - /** - * Calculates the TTL for a cache item - * - * @param DateInterval|int|null $ttl - * - * @throws Exception - * @param mixed $ttl - * @return int - */ - protected function getTtl($ttl): int {} - - /** - * Returns unserialized data - * - * @param mixed $content - * @param mixed $defaultValue - * @return mixed - */ - protected function getUnserializedData($content, $defaultValue = null) {} - - /** - * Initializes the serializer - */ - protected function initSerializer() {} - -} diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php deleted file mode 100644 index a7f35523..00000000 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface -{ - /** - * @var mixed - */ - protected $data = null; - - - /** - * @return mixed - */ - public function getData() {} - - /** - * @param mixed $data - */ - public function setData($data) {} - - /** - * Constructor - * - * @param mixed $data - */ - public function __construct($data = null) {} - - /** - * If this returns true, then the data returns back as is - * - * @param mixed $data - * @return bool - */ - protected function isSerializable($data): bool {} - -} diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php deleted file mode 100644 index 6dfbad46..00000000 --- a/src/Phalcon/storage/serializer/Base64.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php deleted file mode 100644 index 5047c4bc..00000000 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php deleted file mode 100644 index ef79de7a..00000000 --- a/src/Phalcon/storage/serializer/Json.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Json extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php deleted file mode 100644 index 8b8a3e80..00000000 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string|null - */ - public function serialize(): ?string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php deleted file mode 100644 index bba29154..00000000 --- a/src/Phalcon/storage/serializer/None.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class None extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php deleted file mode 100644 index ea6e0ef6..00000000 --- a/src/Phalcon/storage/serializer/Php.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class Php extends \Phalcon\Storage\Serializer\AbstractSerializer -{ - - /** - * Serializes data - * - * @return string - */ - public function serialize(): string {} - - /** - * Unserializes data - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php deleted file mode 100644 index b13acdd3..00000000 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -interface SerializerInterface extends \Serializable -{ - - /** - * @return mixed - */ - public function getData(); - - /** - * @param mixed $data - * @param $data - */ - public function setData($data); - -} diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 5f1f29fe..551efc84 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -5,8 +5,7 @@ /** * Phalcon\Tag\Select * - * Generates a SELECT html tag using a static array of values or a - * Phalcon\Mvc\Model resultset + * Generates a SELECT html tag using a static array of values or a Phalcon\Mvc\Model resultset */ abstract class Select { @@ -16,29 +15,26 @@ abstract class Select * * @param array $parameters * @param array $data - * @return string */ - public static function selectField($parameters, $data = null): string {} + public static function selectField($parameters, $data = null) {} /** - * Generate the OPTION tags based on an array + * Generate the OPTION tags based on a resultset * - * @param array $data + * @param \Phalcon\Mvc\Model\Resultset $resultset + * @param array $using * @param mixed $value * @param string $closeOption - * @return string */ - private static function optionsFromArray(array $data, $value, string $closeOption): string {} + private static function _optionsFromResultset($resultset, $using, $value, $closeOption) {} /** - * Generate the OPTION tags based on a resultset + * Generate the OPTION tags based on an array * - * @param \Phalcon\Mvc\Model\ResulsetInterface $resultset - * @param array $using + * @param array $data * @param mixed $value * @param string $closeOption - * @return string */ - private static function optionsFromResultset(\Phalcon\Mvc\Model\ResulsetInterface $resultset, $using, $value, string $closeOption): string {} + private static function _optionsFromArray($data, $value, $closeOption) {} } diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/translate/Adapter.php similarity index 58% rename from src/Phalcon/translate/adapter/AbstractAdapter.php rename to src/Phalcon/translate/Adapter.php index 8d221db3..42b3d83b 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/translate/Adapter.php @@ -1,79 +1,79 @@ + * use Phalcon\Translate\Factory; + * + * $options = [ + * "locale" => "de_DE.UTF-8", + * "defaultDomain" => "translations", + * "directory" => "/path/to/application/locales", + * "category" => LC_MESSAGES, + * "adapter" => "gettext", + * ]; + * $translate = Factory::load($options); + * + */ +class Factory extends \Phalcon\Factory +{ + + /** + * @param \Phalcon\Config|array $config + * @return AdapterInterface + */ + public static function load($config) {} + +} diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php deleted file mode 100644 index 5907eda6..00000000 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class InterpolatorFactory extends \Phalcon\Factory\AbstractFactory -{ - /** - * @var array - */ - private $mapper = array(); - - /** - * @var array - */ - private $services = array(); - - - /** - * AdapterFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @return \Phalcon\Translate\Adapter\AdapterInterface - */ - public function newInstance(string $name): AdapterInterface {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/translate/InterpolatorInterface.php b/src/Phalcon/translate/InterpolatorInterface.php new file mode 100644 index 00000000..ebd37966 --- /dev/null +++ b/src/Phalcon/translate/InterpolatorInterface.php @@ -0,0 +1,22 @@ + - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class TranslateFactory extends \Phalcon\Factory\AbstractFactory -{ - /** - * @var InterpolatorFactory - */ - private $interpolator; - - - /** - * AdapterFactory constructor. - * - * @param \Phalcon\Translate\InterpolatorFactory $interpolator - * @param array $services - */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) {} - - /** - * Factory to create an instace from a Config object - * - * @param mixed $config - * @return mixed - */ - public function load($config) {} - - /** - * Create a new instance of the adapter - * - * @param string $name - * @param array $options - * @return AbstractAdapter - */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 85b504c7..fb8ea068 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -7,29 +7,28 @@ * * Allows to define translation lists using CSV file */ -class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Csv extends \Phalcon\Translate\Adapter implements \ArrayAccess { - /** - * @var array - */ - protected $translate = array(); + + protected $_translate = array(); /** * Phalcon\Translate\Adapter\Csv constructor * - * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(array $options) {} /** - * Check whether is defined a translation key in the internal array + * Load translates from file * - * @param string $index - * @return bool + * @param string $file + * @param int $length + * @param string $delimiter + * @param string $enclosure */ - public function exists(string $index): bool {} + private function _load($file, $length, $delimiter, $enclosure) {} /** * Returns the translation related to the given key @@ -38,16 +37,14 @@ public function exists(string $index): bool {} * @param mixed $placeholders * @return string */ - public function query(string $index, $placeholders = null): string {} + public function query($index, $placeholders = null) {} /** - * Load translates from file + * Check whether is defined a translation key in the internal array * - * @param string $file - * @param int $length - * @param string $delimiter - * @param string $enclosure + * @param string $index + * @return bool */ - private function load(string $file, int $length, string $delimiter, string $enclosure) {} + public function exists($index) {} } diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 50833867..925e0ffb 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -5,7 +5,7 @@ /** * Phalcon\Translate\Adapter\Gettext * - * ```php + * * use Phalcon\Translate\Adapter\Gettext; * * $adapter = new Gettext( @@ -16,60 +16,72 @@ * "category" => LC_MESSAGES, * ] * ); - * ``` + * * * Allows translate using gettext */ -class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Gettext extends \Phalcon\Translate\Adapter implements \ArrayAccess { /** - * @var int + * @var string|array */ - protected $category; + protected $_directory; /** * @var string */ - protected $defaultDomain; + protected $_defaultDomain; /** - * @var string|array + * @var string */ - protected $directory; + protected $_locale; /** - * @var string + * @var int */ - protected $locale; + protected $_category; /** - * @return int + * @return string|array */ - public function getCategory(): int {} + public function getDirectory() {} /** * @return string */ - public function getDefaultDomain(): string {} + public function getDefaultDomain() {} /** - * @return string|array + * @return string */ - public function getDirectory() {} + public function getLocale() {} /** - * @return string + * @return int */ - public function getLocale(): string {} + public function getCategory() {} /** * Phalcon\Translate\Adapter\Gettext constructor * - * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(array $options) {} + + /** + * Returns the translation related to the given key. + * + * + * $translator->query("你好 %name%!", ["name" => "Phalcon"]); + * + * + * @param string $index + * @param mixed $placeholders + * @return string + */ + public function query($index, $placeholders = null) {} /** * Check whether is defined a translation key in the internal array @@ -77,12 +89,11 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param string $index * @return bool */ - public function exists(string $index): bool {} + public function exists($index) {} /** * The plural version of gettext(). - * Some languages have more than one form for plural messages dependent on - * the count. + * Some languages have more than one form for plural messages dependent on the count. * * @param string $msgid1 * @param string $msgid2 @@ -91,39 +102,34 @@ public function exists(string $index): bool {} * @param string $domain * @return string */ - public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string {} + public function nquery($msgid1, $msgid2, $count, $placeholders = null, $domain = null) {} /** - * Returns the translation related to the given key. - * - * ```php - * $translator->query("你好 %name%!", ["name" => "Phalcon"]); - * ``` + * Changes the current domain (i.e. the translation file) * - * @param string $index - * @param array $placeholders + * @param mixed $domain * @return string */ - public function query(string $index, $placeholders = null): string {} + public function setDomain($domain) {} /** * Sets the default domain * * @return string */ - public function resetDomain(): string {} + public function resetDomain() {} /** * Sets the domain default to search within when calls are made to gettext() * * @param string $domain */ - public function setDefaultDomain(string $domain) {} + public function setDefaultDomain($domain) {} /** * Sets the path for a domain * - * ```php + * * // Set the directory path * $gettext->setDirectory("/path/to/the/messages"); * @@ -134,49 +140,41 @@ public function setDefaultDomain(string $domain) {} * "another" => "/path/to/the/another", * ] * ); - * ``` + * * * @param string|array $directory The directory path or an array of directories and domains */ public function setDirectory($directory) {} - /** - * Changes the current domain (i.e. the translation file) - * - * @param mixed $domain - * @return string - */ - public function setDomain($domain): string {} - /** * Sets locale information * - * ```php + * * // Set locale to Dutch * $gettext->setLocale(LC_ALL, "nl_NL"); * * // Try different possible locale names for german * $gettext->setLocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge"); - * ``` + * * * @param int $category * @param string $locale * @return string|bool */ - public function setLocale(int $category, string $locale) {} + public function setLocale($category, $locale) {} /** - * Gets default options + * Validator for constructor * - * @return array + * @param array $options */ - protected function getOptionsDefault(): array {} + protected function prepareOptions(array $options) {} /** - * Validator for constructor + * Gets default options * - * @param array $options + * @return array */ - protected function prepareOptions(array $options) {} + protected function getOptionsDefault() {} } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index 710d5661..bd5f98c6 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -7,50 +7,34 @@ * * Allows to define translation lists using PHP arrays */ -class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class NativeArray extends \Phalcon\Translate\Adapter implements \ArrayAccess { - /** - * @var array - */ - private $translate; - /** - * @var bool - */ - private $triggerError = false; + protected $_translate; /** * Phalcon\Translate\Adapter\NativeArray constructor * - * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} - - /** - * Check whether is defined a translation key in the internal array - * - * @param string $index - * @return bool - */ - public function exists(string $index): bool {} + public function __construct(array $options) {} /** - * Whenever a key is not found this medhod will be called + * Returns the translation related to the given key * * @param string $index + * @param mixed $placeholders * @return string */ - public function notFound(string $index): string {} + public function query($index, $placeholders = null) {} /** - * Returns the translation related to the given key + * Check whether is defined a translation key in the internal array * * @param string $index - * @param mixed $placeholders - * @return string + * @return bool */ - public function query(string $index, $placeholders = null): string {} + public function exists($index) {} } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index 55bc4363..cfb6f050 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -2,24 +2,17 @@ namespace Phalcon\Translate\Interpolator; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface + +class AssociativeArray implements \Phalcon\Translate\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param array $placeholders + * @param mixed $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string {} + public function replacePlaceholders($translation, $placeholders = null) {} } diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index af57aa6f..f668236e 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -2,24 +2,17 @@ namespace Phalcon\Translate\Interpolator; -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface + +class IndexedArray implements \Phalcon\Translate\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param array $placeholders + * @param mixed $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string {} + public function replacePlaceholders($translation, $placeholders = null) {} } diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php deleted file mode 100644 index 4adb6a41..00000000 --- a/src/Phalcon/translate/interpolator/InterpolatorInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -class ValidatorFactory extends \Phalcon\Factory\AbstractFactory -{ - - /** - * TagFactory constructor. - * - * @param array $services - */ - public function __construct(array $services = array()) {} - - /** - * Creates a new instance - * - * @param string $name - * @return mixed - */ - public function newInstance(string $name) {} - - /** - * @return array - */ - protected function getAdapters(): array {} - -} diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 307747be..5cf7d765 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -3,68 +3,38 @@ namespace Phalcon\Validation; /** - * Interface for Phalcon\Validation\AbstractValidator + * Phalcon\Validation\ValidatorInterface + * + * Interface for Phalcon\Validation\Validator */ interface ValidatorInterface { /** - * Returns an option in the validator's options - * Returns null if the option hasn't set + * Checks if an option is defined * * @param string $key - * @param mixed $defaultValue - * @return mixed + * @return bool */ - public function getOption(string $key, $defaultValue = null); + public function hasOption($key); /** - * Checks if an option is defined + * Returns an option in the validator's options + * Returns null if the option hasn't set * * @param string $key - * @return bool + * @param mixed $defaultValue + * @return mixed */ - public function hasOption(string $key): bool; + public function getOption($key, $defaultValue = null); /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $attribute * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool; - - /** - * Get the template message - * - * @throw InvalidArgumentException When the field does not exists - * @param string $field - * @return string - */ - public function getTemplate(string $field): string; - - /** - * Get message templates - * - * @return array - */ - public function getTemplates(): array; - - /** - * Clear current template and set new from an array, - * - * @param array $templates - * @return ValidatorInterface - */ - public function setTemplates(array $templates): ValidatorInterface; - - /** - * Set a new temlate message - * - * @param string $template - * @return ValidatorInterface - */ - public function setTemplate(string $template): ValidatorInterface; + public function validate(\Phalcon\Validation $validation, $attribute); } diff --git a/src/Phalcon/validation/message/Group.php b/src/Phalcon/validation/message/Group.php new file mode 100644 index 00000000..34a8301c --- /dev/null +++ b/src/Phalcon/validation/message/Group.php @@ -0,0 +1,155 @@ + + * print_r( + * $messages[0] + * ); + * + * + * @param int $index + * @return bool|\Phalcon\Validation\Message + */ + public function offsetGet($index) {} + + /** + * Sets an attribute using the array-syntax + * + * + * $messages[0] = new \Phalcon\Validation\Message("This is a message"); + * + * + * @param int $index + * @param \Phalcon\Validation\Message $message + */ + public function offsetSet($index, $message) {} + + /** + * Checks if an index exists + * + * + * var_dump( + * isset($message["database"]) + * ); + * + * + * @param int $index + * @return bool + */ + public function offsetExists($index) {} + + /** + * Removes a message from the list + * + * + * unset($message["database"]); + * + * + * @param mixed $index + */ + public function offsetUnset($index) {} + + /** + * Appends a message to the group + * + * + * $messages->appendMessage( + * new \Phalcon\Validation\Message("This is a message") + * ); + * + * + * @param \Phalcon\Validation\MessageInterface $message + */ + public function appendMessage(\Phalcon\Validation\MessageInterface $message) {} + + /** + * Appends an array of messages to the group + * + * + * $messages->appendMessages($messagesArray); + * + * + * @param \Phalcon\Validation\MessageInterface[] $messages + */ + public function appendMessages($messages) {} + + /** + * Filters the message group by field name + * + * @param string $fieldName + * @return array + */ + public function filter($fieldName) {} + + /** + * Returns the number of messages in the list + * + * @return int + */ + public function count() {} + + /** + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Returns the current message in the iterator + * + * @return \Phalcon\Validation\Message + */ + public function current() {} + + /** + * Returns the current position/key in the iterator + * + * @return int + */ + public function key() {} + + /** + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Check if the current message in the iterator is valid + * + * @return bool + */ + public function valid() {} + + /** + * Magic __set_state helps to re-build messages variable when exporting + * + * @param array $group + * @return \Phalcon\Validation\Message\Group + */ + public static function __set_state($group) {} + +} diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index e44a4154..c73c1ad4 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Alnum + * * Check for alphanumeric character(s) * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alnum as AlnumValidator; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Alnum extends \Phalcon\Validation\AbstractValidator +class Alnum extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must contain only letters and numbers'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index c4a0ef8c..87c1dd50 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Alpha + * * Check for alphabetic character(s) * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alpha as AlphaValidator; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Alpha extends \Phalcon\Validation\AbstractValidator +class Alpha extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must contain only letters'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 62ae2db7..a6ec67a6 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -3,10 +3,12 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Between + * * Validates that a value is between an inclusive range of two values. * For a value x, the test is passed if minimum<=x<=maximum. * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Between; * @@ -45,21 +47,18 @@ * ] * ) * ); - * ``` + * */ -class Between extends \Phalcon\Validation\AbstractValidator +class Between extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be within the range of :min to :max'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 61c7a9fa..6915f1e6 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Callback + * * Calls user function for validation * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Callback as CallbackValidator; * use Phalcon\Validation\Validator\Numericality as NumericalityValidator; @@ -44,21 +46,18 @@ * ] * ) * ); - * ``` + * */ -class Callback extends \Phalcon\Validation\AbstractValidator +class Callback extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must match the callback function'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 9adbf563..2c235c3d 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Confirmation + * * Checks that two values have the same value * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Confirmation; * @@ -39,22 +41,19 @@ * ] * ) * ); - * ``` + * */ -class Confirmation extends \Phalcon\Validation\AbstractValidator +class Confirmation extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be the same as :with'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} /** * Compare strings @@ -63,6 +62,6 @@ public function validate(\Phalcon\Validation $validation, $field): bool {} * @param string $b * @return bool */ - final protected function compare(string $a, string $b): bool {} + protected final function compare($a, $b) {} } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index 659e1445..fcef5b6f 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\CreditCard + * * Checks if a value has a valid credit card number * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\CreditCard as CreditCardValidator; * @@ -34,30 +36,26 @@ * ] * ) * ); - * ``` + * */ -class CreditCard extends \Phalcon\Validation\AbstractValidator +class CreditCard extends \Phalcon\Validation\Validator { - protected $template = 'Field :field is not valid for a credit card number'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} /** - * is a simple checksum formula used to validate a variety of identification - * numbers + * is a simple checksum formula used to validate a variety of identification numbers * * @param string $number * @return bool */ - private function verifyByLuhnAlgorithm(string $number): bool {} + private function verifyByLuhnAlgorithm($number) {} } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index 47ce72e1..f5a354ed 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Date + * * Checks if a value is a valid date * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Date as DateValidator; * @@ -39,28 +41,25 @@ * ] * ) * ); - * ``` + * */ -class Date extends \Phalcon\Validation\AbstractValidator +class Date extends \Phalcon\Validation\Validator { - protected $template = 'Field :field is not a valid date'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} /** * @param mixed $value * @param mixed $format * @return bool */ - private function checkDate($value, $format): bool {} + private function checkDate($value, $format) {} } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 038cb5d8..4bcc361b 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Digit + * * Check for numeric character(s) * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Digit as DigitValidator; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Digit extends \Phalcon\Validation\AbstractValidator +class Digit extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be numeric'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 93b774b3..804d42f2 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Email + * * Checks if a value has a correct e-mail format * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Email as EmailValidator; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Email extends \Phalcon\Validation\AbstractValidator +class Email extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be an email address'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Exception.php b/src/Phalcon/validation/validator/Exception.php index 240b1809..6e0f3fbf 100644 --- a/src/Phalcon/validation/validator/Exception.php +++ b/src/Phalcon/validation/validator/Exception.php @@ -3,8 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this - * class + * Phalcon\Validation\Exception + * + * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index aa870b04..f4eac992 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\ExclusionIn + * * Check if a value is not included into a list of values * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\ExclusionIn; * @@ -45,21 +47,18 @@ * ] * ) * ); - * ``` + * */ -class ExclusionIn extends \Phalcon\Validation\AbstractValidator +class ExclusionIn extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must not be a part of list: :domain'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index 3ab08575..aef472d0 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\File + * * Checks if a value has a correct file * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\File as FileValidator; * @@ -16,14 +18,14 @@ * new FileValidator( * [ * "maxSize" => "2M", - * "messageSize" => ":field exceeds the max filesize (:size)", + * "messageSize" => ":field exceeds the max filesize (:max)", * "allowedTypes" => [ * "image/jpeg", * "image/png", * ], * "messageType" => "Allowed file types are :types", * "maxResolution" => "800x600", - * "messageMaxResolution" => "Max resolution of :field is :resolution", + * "messageMaxResolution" => "Max resolution of :field is :max", * ] * ) * ); @@ -67,16 +69,27 @@ * ] * ) * ); - * ``` + * */ -class File extends \Phalcon\Validation\AbstractValidatorComposite +class File extends \Phalcon\Validation\Validator { /** - * Constructor + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param string $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field) {} + + /** + * Check on empty * - * @param array $options + * @param \Phalcon\Validation $validation + * @param string $field + * @return bool */ - public function __construct(array $options = array()) {} + public function isAllowEmpty(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 152a25ab..9a28f586 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Identical + * * Checks if a value is identical to other * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Identical; * @@ -39,21 +41,18 @@ * ] * ) * ); - * ``` + * */ -class Identical extends \Phalcon\Validation\AbstractValidator +class Identical extends \Phalcon\Validation\Validator { - protected $template = 'Field :field does not have the expected value'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 2b69130e..b55343d3 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\InclusionIn + * * Check if a value is included into a list of values * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\InclusionIn; * @@ -39,21 +41,18 @@ * ] * ) * ); - * ``` + * */ -class InclusionIn extends \Phalcon\Validation\AbstractValidator +class InclusionIn extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be a part of list: :domain'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 485fdb5b..7193c835 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -2,21 +2,27 @@ namespace Phalcon\Validation\Validator; +use Phalcon\Validation; +use Phalcon\Validation\Validator; +use Phalcon\Messages\Message; + /** - * Check for IP addresses + * Phalcon\Validation\Validator\ip + * + * Check for ip addresses * - * ```php + * * use Phalcon\Validation\Validator\Ip as IpValidator; * * $validator->add( * "ip_address", * new IpValidator( * [ - * "message" => ":field must contain only ip addresses", - * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified + * "message" => ":field must contain only ip addresses", + * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified * "allowReserved" => false, // False if not specified. Ignored for v6 - * "allowPrivate" => false, // False if not specified - * "allowEmpty" => false, + * "allowPrivate" => false, // False if not specified + * "allowEmpty" => false, * ] * ) * ); @@ -29,49 +35,39 @@ * new IpValidator( * [ * "message" => [ - * "source_address" => "source_address must be a valid IP address", - * "destination_address" => "destination_address must be a valid IP address", + * "source_address" => "source_address must contain only ip addresses", + * "destination_address" => "destination_address must contain only ip addresses", * ], * "version" => [ - * "source_address" => Ip::VERSION_4 | IP::VERSION_6, + * "source_address" => Ip::VERSION_4 | IP::VERSION_6, * "destination_address" => Ip::VERSION_4, * ], * "allowReserved" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowPrivate" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowEmpty" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * ] * ) * ); - * ``` + * */ -class Ip extends \Phalcon\Validation\AbstractValidator +class Ip extends Validator { + const VERSION_4 = FILTER_FLAG_IPV4; + const VERSION_6 = FILTER_FLAG_IPV6; - const VERSION_4 = 1048576; - - - const VERSION_6 = 2097152; - - - protected $template = 'Field :field must be a valid IP address'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + /** + * Executes the validation + */ + public function validate(Validation $validation, $field) : bool + { + } } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index 4a55030b..baf05fe8 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Numericality + * * Check for a valid numeric value * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Numericality; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Numericality extends \Phalcon\Validation\AbstractValidator +class Numericality extends \Phalcon\Validation\Validator { - protected $template = 'Field :field does not have a valid numeric format'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index f7e1a631..046f395b 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\PresenceOf + * * Validates that a value is not null or empty string * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\PresenceOf; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class PresenceOf extends \Phalcon\Validation\AbstractValidator +class PresenceOf extends \Phalcon\Validation\Validator { - protected $template = 'Field :field is required'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index 23aa7ec5..f3f431b9 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Regex + * * Allows validate if the value of a field matches a regular expression * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Regex as RegexValidator; * @@ -39,21 +41,18 @@ * ] * ) * ); - * ``` + * */ -class Regex extends \Phalcon\Validation\AbstractValidator +class Regex extends \Phalcon\Validation\Validator { - protected $template = 'Field :field does not match the required format'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index 7cded7d9..b95904f7 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -3,12 +3,13 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\StringLength + * * Validates that a string has the specified maximum and minimum constraints * The test is passed if for a string's length L, min<=L<=max, i.e. L must * be at least min, and at most max. - * Since Phalcon v4.0 this valitor works like a container * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\StringLength as StringLength; * @@ -18,12 +19,10 @@ * "name_last", * new StringLength( * [ - * "max" => 50, - * "min" => 2, - * "messageMaximum" => "We don't like really long names", - * "messageMinimum" => "We want more than just their initials", - * "includedMaximum" => true, - * "includedMinimum" => false, + * "max" => 50, + * "min" => 2, + * "messageMaximum" => "We don't like really long names", + * "messageMinimum" => "We want more than just their initials", * ] * ) * ); @@ -50,28 +49,22 @@ * "messageMinimum" => [ * "name_last" => "We don't like too short last names", * "name_first" => "We don't like too short first names", - * ], - * "includedMaximum" => [ - * "name_last" => false, - * "name_first" => true, - * ], - * "includedMinimum" => [ - * "name_last" => false, - * "name_first" => true, * ] * ] * ) * ); - * ``` + * */ -class StringLength extends \Phalcon\Validation\AbstractValidatorComposite +class StringLength extends \Phalcon\Validation\Validator { /** - * Constructor + * Executes the validation * - * @param array $options + * @param \Phalcon\Validation $validation + * @param string $field + * @return bool */ - public function __construct(array $options = array()) {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index fa70ed86..26b77fb4 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Uniqueness + * * Check that a field is unique in the related table * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; * @@ -20,10 +22,10 @@ * ] * ) * ); - * ``` + * * * Different attribute from the field: - * ```php + * * $validator->add( * "username", * new UniquenessValidator( @@ -33,18 +35,18 @@ * ] * ) * ); - * ``` + * * * In model: - * ```php + * * $validator->add( * "username", * new UniquenessValidator() * ); - * ``` + * * * Combination of fields in model: - * ```php + * * $validator->add( * [ * "firstName", @@ -52,12 +54,12 @@ * ], * new UniquenessValidator() * ); - * ``` + * * * It is possible to convert values before validation. This is useful in * situations where values need to be converted to do the database lookup: * - * ```php + * * $validator->add( * "username", * new UniquenessValidator( @@ -70,14 +72,11 @@ * ] * ) * ); - * ``` + * */ -class Uniqueness extends \Phalcon\Validation\AbstractCombinedFieldsValidator +class Uniqueness extends \Phalcon\Validation\CombinedFieldsValidator { - protected $template = 'Field :field must be unique'; - - private $columnMap = null; @@ -88,7 +87,14 @@ class Uniqueness extends \Phalcon\Validation\AbstractCombinedFieldsValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} + + /** + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + protected function isUniqueness(\Phalcon\Validation $validation, $field) {} /** * The column map is used in the case to get real column name @@ -97,31 +103,24 @@ public function validate(\Phalcon\Validation $validation, $field): bool {} * @param string $field * @return string */ - protected function getColumnNameReal($record, string $field): string {} + protected function getColumnNameReal($record, $field) {} /** - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - protected function isUniqueness(\Phalcon\Validation $validation, $field): bool {} - - /** - * Uniqueness method used for collection + * Uniqueness method used for model * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessCollection($record, array $field, array $values) {} + protected function isUniquenessModel($record, array $field, array $values) {} /** - * Uniqueness method used for model + * Uniqueness method used for collection * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessModel($record, array $field, array $values) {} + protected function isUniquenessCollection($record, array $field, array $values) {} } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 0c85f1f0..b3e86bd5 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -3,9 +3,11 @@ namespace Phalcon\Validation\Validator; /** + * Phalcon\Validation\Validator\Url + * * Checks if a value has a url format * - * ```php + * * use Phalcon\Validation; * use Phalcon\Validation\Validator\Url as UrlValidator; * @@ -34,21 +36,18 @@ * ] * ) * ); - * ``` + * */ -class Url extends \Phalcon\Validation\AbstractValidator +class Url extends \Phalcon\Validation\Validator { - protected $template = 'Field :field must be a url'; - - /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param mixed $field + * @param string $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field) {} } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php deleted file mode 100644 index 2a2c15cd..00000000 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ /dev/null @@ -1,151 +0,0 @@ -add( - * "file", - * new Size( - * [ - * "maxSize" => "2M", - * "messageSize" => ":field exceeds the max filesize (:size)", - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new FileValidator( - * [ - * "maxSize" => [ - * "file" => "2M", - * "anotherFile" => "4M", - * ], - * "messageSize" => [ - * "file" => "file exceeds the max filesize 2M", - * "anotherFile" => "anotherFile exceeds the max filesize 4M", - * ], - * ] - * ) - * ); - * ``` - */ -abstract class AbstractFile extends \Phalcon\Validation\AbstractValidator -{ - /** - * Empty is empty - */ - protected $messageFileEmpty = 'Field :field must not be empty'; - - /** - * File exceeed the file size setted in PHP configuration - */ - protected $messageIniSize = 'File :field exceeds the maximum file size'; - - /** - * File is not valid - */ - protected $messageValid = 'Field :field is not valid'; - - - /** - * Empty is empty - */ - public function getMessageFileEmpty() {} - - /** - * Empty is empty - * - * @param mixed $messageFileEmpty - */ - public function setMessageFileEmpty($messageFileEmpty) {} - - /** - * File exceeed the file size setted in PHP configuration - */ - public function getMessageIniSize() {} - - /** - * File exceeed the file size setted in PHP configuration - * - * @param mixed $messageIniSize - */ - public function setMessageIniSize($messageIniSize) {} - - /** - * File is not valid - */ - public function getMessageValid() {} - - /** - * File is not valid - * - * @param mixed $messageValid - */ - public function setMessageValid($messageValid) {} - - /** - * Check on empty - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool {} - - /** - * Check upload - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function checkUpload(\Phalcon\Validation $validation, $field): bool {} - - /** - * Check if uploaded file is larger than PHP allowed size - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool {} - - /** - * Check if upload is empty - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool {} - - /** - * Check if upload is valid - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool {} - - /** - * Convert a string like "2.5MB" in bytes - * - * @param string $size - * @return double - */ - public function getFileSizeInBytes(string $size): float {} - -} diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php deleted file mode 100644 index b642b371..00000000 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ /dev/null @@ -1,68 +0,0 @@ -add( - * "file", - * new MimeType( - * [ - * "types" => [ - * "image/jpeg", - * "image/png", - * ], - * "message" => "Allowed file types are :types" - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new MimeType( - * [ - * "types" => [ - * "file" => [ - * "image/jpeg", - * "image/png", - * ], - * "anotherFile" => [ - * "image/gif", - * "image/bmp", - * ], - * ], - * "message" => [ - * "file" => "Allowed file types are image/jpeg and image/png", - * "anotherFile" => "Allowed file types are image/gif and image/bmp", - * ] - * ] - * ) - * ); - * ``` - */ -class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field must be of type: :types'; - - - /** - * Executes the validation - * - * @param Valiation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php deleted file mode 100644 index cc59fdd6..00000000 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ /dev/null @@ -1,59 +0,0 @@ -add( - * "file", - * new Equal( - * [ - * "resolution" => "800x600", - * "message" => "The resolution of the field :field has to be equal :resolution", - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Equal( - * [ - * "resolution" => [ - * "file" => "800x600", - * "anotherFile" => "1024x768", - * ], - * "message" => [ - * "file" => "Equal resolution of file has to be 800x600", - * "anotherFile" => "Equal resolution of file has to be 1024x768", - * ], - * ] - * ) - * ); - * ``` - */ -class Equal extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'The resolution of the field :field has to be equal :resolution'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php deleted file mode 100644 index 32ca0ec1..00000000 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - * "file", - * new Max( - * [ - * "resolution" => "800x600", - * "message" => "Max resolution of :field is :resolution", - * "included" => true, - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Max( - * [ - * "resolution" => [ - * "file" => "800x600", - * "anotherFile" => "1024x768", - * ], - * "included" => [ - * "file" => false, - * "anotherFile" => true, - * ], - * "message" => [ - * "file" => "Max resolution of file is 800x600", - * "anotherFile" => "Max resolution of file is 1024x768", - * ], - * ] - * ) - * ); - * ``` - */ -class Max extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field exceeds the maximum resolution of :resolution'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php deleted file mode 100644 index db1e4db0..00000000 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - * "file", - * new Min( - * [ - * "resolution" => "800x600", - * "message" => "Min resolution of :field is :resolution", - * "included" => true, - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Min( - * [ - * "resolution" => [ - * "file" => "800x600", - * "anotherFile" => "1024x768", - * ], - * "included" => [ - * "file" => false, - * "anotherFile" => true, - * ], - * "message" => [ - * "file" => "Min resolution of file is 800x600", - * "anotherFile" => "Min resolution of file is 1024x768", - * ], - * ] - * ) - * ); - * ``` - */ -class Min extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field can not have the minimum resolution of :resolution'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php deleted file mode 100644 index 2e7de623..00000000 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - * "file", - * new Equal( - * [ - * "size" => "2M", - * "included" => true, - * "message" => ":field exceeds the equal filesize (:size)", - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Equal( - * [ - * "size" => [ - * "file" => "2M", - * "anotherFile" => "4M", - * ], - * "included" => [ - * "file" => false, - * "anotherFile" => true, - * ], - * "message" => [ - * "file" => "file does not have the rigth filesize", - * "anotherFile" => "anotherFile wrong filesize (4MB)", - * ], - * ] - * ) - * ); - * ``` - */ -class Equal extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field does not have the exact :size filesize'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php deleted file mode 100644 index 1e634676..00000000 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - * "file", - * new Max( - * [ - * "size" => "2M", - * "included" => true, - * "message" => ":field exceeds the max filesize (:size)", - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Max( - * [ - * "size" => [ - * "file" => "2M", - * "anotherFile" => "4M", - * ], - * "included" => [ - * "file" => false, - * "anotherFile" => true, - * ], - * "message" => [ - * "file" => "file exceeds the max filesize 2M", - * "anotherFile" => "anotherFile exceeds the max filesize 4M", - * ], - * ] - * ) - * ); - * ``` - */ -class Max extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field exceeds the size of :size'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php deleted file mode 100644 index 92d65f3f..00000000 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - * "file", - * new Min( - * [ - * "size" => "2M", - * "included" => true, - * "message" => ":field exceeds the min filesize (:size)", - * ] - * ) - * ); - * - * $validator->add( - * [ - * "file", - * "anotherFile", - * ], - * new Min( - * [ - * "size" => [ - * "file" => "2M", - * "anotherFile" => "4M", - * ], - * "included" => [ - * "file" => false, - * "anotherFile" => true, - * ], - * "message" => [ - * "file" => "file exceeds the min filesize 2M", - * "anotherFile" => "anotherFile exceeds the min filesize 4M", - * ], - * ] - * ) - * ); - * ``` - */ -class Min extends \Phalcon\Validation\Validator\File\AbstractFile -{ - - protected $template = 'File :field can not have the minimum size of :size'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php deleted file mode 100644 index fe294b5f..00000000 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ /dev/null @@ -1,66 +0,0 @@ -add( - * "name_last", - * new Max( - * [ - * "max" => 50, - * "message" => "We don't like really long names", - * "included" => true - * ] - * ) - * ); - * - * $validation->add( - * [ - * "name_last", - * "name_first", - * ], - * new Max( - * [ - * "max" => [ - * "name_last" => 50, - * "name_first" => 40, - * ], - * "message" => [ - * "name_last" => "We don't like really long last names", - * "name_first" => "We don't like really long first names", - * ], - * "included" => [ - * "name_last" => false, - * "name_first" => true, - * ] - * ] - * ) - * ); - * ``` - */ -class Max extends \Phalcon\Validation\AbstractValidator -{ - - protected $template = 'Field :field must not exceed :max characters long'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php deleted file mode 100644 index 606924c0..00000000 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ /dev/null @@ -1,66 +0,0 @@ -add( - * "name_last", - * new Min( - * [ - * "min" => 2, - * "message" => "We want more than just their initials", - * "included" => true - * ] - * ) - * ); - * - * $validation->add( - * [ - * "name_last", - * "name_first", - * ], - * new Min( - * [ - * "min" => [ - * "name_last" => 2, - * "name_first" => 4, - * ], - * "message" => [ - * "name_last" => "We don't like too short last names", - * "name_first" => "We don't like too short first names", - * ], - * "included" => [ - * "name_last" => false, - * "name_first" => true, - * ] - * ] - * ) - * ); - * ``` - */ -class Min extends \Phalcon\Validation\AbstractValidator -{ - - protected $template = 'Field :field must be at least :min characters long'; - - - /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - -} From 2ffafb5f10c23c3c3082b266af4840b6245b8a92 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Wed, 24 Jul 2019 22:52:00 +0300 Subject: [PATCH 09/25] Generated stubs for Phalcon v4.0.0-beta.1 --- src/Phalcon/Acl.php | 60 - src/Phalcon/Cache.php | 164 ++ src/Phalcon/Collection.php | 217 ++ src/Phalcon/Config.php | 180 +- src/Phalcon/Container.php | 55 +- src/Phalcon/Crypt.php | 306 ++- src/Phalcon/CryptInterface.php | 86 - src/Phalcon/Db.php | 108 - src/Phalcon/Debug.php | 191 +- src/Phalcon/Di.php | 363 ++- src/Phalcon/Escaper.php | 130 +- src/Phalcon/Exception.php | 8 +- src/Phalcon/Factory.php | 15 - src/Phalcon/FactoryInterface.php | 15 - src/Phalcon/Filter.php | 103 - src/Phalcon/FilterInterface.php | 38 - src/Phalcon/Flash.php | 181 -- src/Phalcon/FlashInterface.php | 49 - src/Phalcon/Image.php | 36 - src/Phalcon/Kernel.php | 4 +- src/Phalcon/Loader.php | 214 +- src/Phalcon/Logger.php | 55 - src/Phalcon/Plugin.php | 4 +- src/Phalcon/Registry.php | 184 +- src/Phalcon/Security.php | 202 +- src/Phalcon/Tag.php | 932 +++---- src/Phalcon/Text.php | 250 +- src/Phalcon/Translate.php | 14 - src/Phalcon/Url.php | 334 +-- src/Phalcon/Urlinterface.php | 44 - src/Phalcon/Validation.php | 153 +- src/Phalcon/Version.php | 50 +- src/Phalcon/acl/Component.php | 53 +- ...{Componentaware.php => ComponentAware.php} | 10 +- src/Phalcon/acl/ComponentInterface.php | 32 + src/Phalcon/acl/Componentinterface.php | 27 - src/Phalcon/acl/Enum.php | 17 + src/Phalcon/acl/Exception.php | 2 - src/Phalcon/acl/Role.php | 16 +- src/Phalcon/acl/RoleAware.php | 5 +- src/Phalcon/acl/RoleInterface.php | 8 +- .../AbstractAdapter.php} | 72 +- .../acl/{ => adapter}/AdapterInterface.php | 112 +- src/Phalcon/acl/adapter/Memory.php | 159 +- src/Phalcon/annotations/Annotation.php | 74 +- .../annotations/AnnotationsFactory.php | 42 + src/Phalcon/annotations/Collection.php | 87 +- src/Phalcon/annotations/Exception.php | 4 +- src/Phalcon/annotations/Factory.php | 28 - src/Phalcon/annotations/Reader.php | 8 +- src/Phalcon/annotations/ReaderInterface.php | 10 +- src/Phalcon/annotations/Reflection.php | 37 +- .../AbstractAdapter.php} | 64 +- .../{ => adapter}/AdapterInterface.php | 52 +- src/Phalcon/annotations/adapter/Apc.php | 51 - src/Phalcon/annotations/adapter/Apcu.php | 27 +- src/Phalcon/annotations/adapter/Memory.php | 15 +- .../adapter/{Files.php => Stream.php} | 26 +- src/Phalcon/annotations/adapter/Xcache.php | 33 - .../AbstractApplication.php} | 98 +- src/Phalcon/application/Exception.php | 2 - src/Phalcon/assets/Asset.php | 405 +-- src/Phalcon/assets/AssetInterface.php | 63 + src/Phalcon/assets/Assetinterface.php | 46 - src/Phalcon/assets/Collection.php | 376 +-- src/Phalcon/assets/Exception.php | 2 - src/Phalcon/assets/FilterInterface.php | 4 +- src/Phalcon/assets/Inline.php | 78 +- src/Phalcon/assets/Manager.php | 271 +- src/Phalcon/assets/Resource.php | 199 -- src/Phalcon/assets/ResourceInterface.php | 65 - src/Phalcon/assets/asset/Css.php | 25 +- src/Phalcon/assets/asset/Js.php | 25 +- src/Phalcon/assets/filters/Cssmin.php | 8 +- src/Phalcon/assets/filters/Jsmin.php | 11 +- src/Phalcon/assets/filters/None.php | 6 +- src/Phalcon/assets/inline/Css.php | 10 +- src/Phalcon/assets/inline/Js.php | 12 +- src/Phalcon/assets/resource/Css.php | 23 - src/Phalcon/assets/resource/Js.php | 23 - src/Phalcon/cache/AdapterFactory.php | 40 + src/Phalcon/cache/Backend.php | 103 - src/Phalcon/cache/BackendInterface.php | 116 - src/Phalcon/cache/CacheFactory.php | 40 + src/Phalcon/cache/Exception.php | 13 - src/Phalcon/cache/FrontendInterface.php | 58 - src/Phalcon/cache/Multiple.php | 139 -- .../cache/adapter/AdapterInterface.php | 11 + src/Phalcon/cache/adapter/Apcu.php | 11 + src/Phalcon/cache/adapter/Libmemcached.php | 11 + src/Phalcon/cache/adapter/Memory.php | 11 + src/Phalcon/cache/adapter/Redis.php | 11 + src/Phalcon/cache/adapter/Stream.php | 11 + src/Phalcon/cache/backend/Apc.php | 129 - src/Phalcon/cache/backend/Apcu.php | 126 - src/Phalcon/cache/backend/Factory.php | 35 - src/Phalcon/cache/backend/File.php | 152 -- src/Phalcon/cache/backend/Libmemcached.php | 162 -- src/Phalcon/cache/backend/Memcache.php | 148 -- src/Phalcon/cache/backend/Memory.php | 123 - src/Phalcon/cache/backend/Mongo.php | 146 -- src/Phalcon/cache/backend/Redis.php | 147 -- src/Phalcon/cache/backend/Xcache.php | 123 - src/Phalcon/cache/exception/Exception.php | 11 + .../exception/InvalidArgumentException.php | 11 + src/Phalcon/cache/frontend/Base64.php | 110 - src/Phalcon/cache/frontend/Data.php | 114 - src/Phalcon/cache/frontend/Factory.php | 33 - src/Phalcon/cache/frontend/Igbinary.php | 109 - src/Phalcon/cache/frontend/Json.php | 102 - src/Phalcon/cache/frontend/Msgpack.php | 115 - src/Phalcon/cache/frontend/None.php | 98 - src/Phalcon/cache/frontend/Output.php | 120 - src/Phalcon/cli/Console.php | 35 +- src/Phalcon/cli/Dispatcher.php | 133 +- src/Phalcon/cli/DispatcherInterface.php | 57 +- src/Phalcon/cli/Router.php | 195 +- src/Phalcon/cli/RouterInterface.php | 106 +- src/Phalcon/cli/Task.php | 16 +- src/Phalcon/cli/TaskInterface.php | 2 - src/Phalcon/cli/console/Exception.php | 2 - src/Phalcon/cli/dispatcher/Exception.php | 4 +- src/Phalcon/cli/router/Exception.php | 2 - src/Phalcon/cli/router/Route.php | 162 +- src/Phalcon/cli/router/RouteInterface.php | 75 +- src/Phalcon/collection/Exception.php | 11 + src/Phalcon/collection/ReadOnly.php | 26 + src/Phalcon/config/ConfigFactory.php | 55 + src/Phalcon/config/Exception.php | 2 - src/Phalcon/config/Factory.php | 33 - src/Phalcon/config/adapter/Grouped.php | 19 +- src/Phalcon/config/adapter/Ini.php | 56 +- src/Phalcon/config/adapter/Json.php | 16 +- src/Phalcon/config/adapter/Php.php | 16 +- src/Phalcon/config/adapter/Yaml.php | 17 +- src/Phalcon/crypt/CryptInterface.php | 137 + src/Phalcon/crypt/Exception.php | 2 - src/Phalcon/crypt/Mismatch.php | 2 - src/Phalcon/db/AbstractDb.php | 58 + src/Phalcon/db/Column.php | 317 +-- src/Phalcon/db/ColumnInterface.php | 97 +- src/Phalcon/db/Dialect.php | 254 +- src/Phalcon/db/DialectInterface.php | 242 +- src/Phalcon/db/Enum.php | 62 + src/Phalcon/db/Exception.php | 2 - src/Phalcon/db/Index.php | 50 +- src/Phalcon/db/IndexInterface.php | 22 +- src/Phalcon/db/Profiler.php | 62 +- src/Phalcon/db/RawValue.php | 12 +- src/Phalcon/db/Reference.php | 106 +- src/Phalcon/db/ReferenceInterface.php | 44 +- src/Phalcon/db/ResultInterface.php | 63 +- .../AbstractAdapter.php} | 958 +++---- .../db/{ => adapter}/AdapterInterface.php | 559 +++-- src/Phalcon/db/adapter/PdoFactory.php | 47 + .../adapter/{Pdo.php => pdo/AbstractPdo.php} | 341 +-- src/Phalcon/db/adapter/pdo/Factory.php | 31 - src/Phalcon/db/adapter/pdo/Mysql.php | 61 +- src/Phalcon/db/adapter/pdo/Postgresql.php | 113 +- src/Phalcon/db/adapter/pdo/Sqlite.php | 85 +- src/Phalcon/db/dialect/Mysql.php | 220 +- src/Phalcon/db/dialect/Postgresql.php | 208 +- src/Phalcon/db/dialect/Sqlite.php | 219 +- src/Phalcon/db/profiler/Item.php | 80 +- src/Phalcon/db/result/Pdo.php | 165 +- src/Phalcon/debug/Dump.php | 120 +- src/Phalcon/debug/Exception.php | 2 - src/Phalcon/{ => di}/DiInterface.php | 114 +- src/Phalcon/di/Exception.php | 2 - src/Phalcon/di/FactoryDefault.php | 7 +- src/Phalcon/di/Injectable.php | 53 +- src/Phalcon/di/InjectionAwareInterface.php | 14 +- src/Phalcon/di/Service.php | 99 +- src/Phalcon/di/ServiceInterface.php | 48 +- src/Phalcon/di/ServiceProviderInterface.php | 25 +- .../exception/ServiceResolutionException.php | 11 + .../exception/Serviceresolutionexception.php | 11 - src/Phalcon/di/service/Builder.php | 28 +- .../AbstractDispatcher.php} | 421 ++-- .../{ => dispatcher}/DispatcherInterface.php | 127 +- src/Phalcon/dispatcher/Exception.php | 29 + src/Phalcon/domain/payload/Payload.php | 121 + src/Phalcon/domain/payload/PayloadFactory.php | 18 + .../domain/payload/PayloadInterface.php | 11 + .../domain/payload/ReadableInterface.php | 47 + src/Phalcon/domain/payload/Status.php | 76 + .../domain/payload/WriteableInterface.php | 54 + .../{ => escaper}/EscaperInterface.php | 56 +- src/Phalcon/escaper/Exception.php | 2 - src/Phalcon/events/Event.php | 95 +- src/Phalcon/events/EventInterface.php | 38 +- src/Phalcon/events/EventsAwareInterface.php | 15 +- src/Phalcon/events/Manager.php | 116 +- src/Phalcon/events/ManagerInterface.php | 28 +- src/Phalcon/factory/AbstractFactory.php | 55 + src/Phalcon/factory/Exception.php | 7 +- src/Phalcon/filter/Filter.php | 154 ++ src/Phalcon/filter/FilterFactory.php | 29 + src/Phalcon/filter/FilterInterface.php | 21 + src/Phalcon/filter/Filterlocator.php | 51 - src/Phalcon/filter/Filterlocatorfactory.php | 42 - src/Phalcon/filter/UserFilterInterface.php | 20 - .../sanitize/{Absint.php => AbsInt.php} | 12 +- src/Phalcon/filter/sanitize/Alnum.php | 12 +- src/Phalcon/filter/sanitize/Alpha.php | 12 +- .../sanitize/{Boolval.php => BoolVal.php} | 12 +- src/Phalcon/filter/sanitize/Email.php | 12 +- .../sanitize/{Floatval.php => FloatVal.php} | 12 +- .../sanitize/{Intval.php => IntVal.php} | 12 +- src/Phalcon/filter/sanitize/Lower.php | 12 +- .../{Lowerfirst.php => LowerFirst.php} | 12 +- src/Phalcon/filter/sanitize/Regex.php | 14 +- src/Phalcon/filter/sanitize/Remove.php | 13 +- src/Phalcon/filter/sanitize/Replace.php | 14 +- src/Phalcon/filter/sanitize/Special.php | 12 +- .../{Specialfull.php => SpecialFull.php} | 12 +- .../sanitize/{Stringval.php => StringVal.php} | 12 +- src/Phalcon/filter/sanitize/Striptags.php | 12 +- src/Phalcon/filter/sanitize/Trim.php | 12 +- src/Phalcon/filter/sanitize/Upper.php | 12 +- .../{Upperfirst.php => UpperFirst.php} | 12 +- .../{Upperwords.php => UpperWords.php} | 12 +- src/Phalcon/filter/sanitize/Url.php | 12 +- src/Phalcon/firewall/Exception.php | 11 + .../firewall/adapter/AbstractAdapter.php | 190 ++ src/Phalcon/firewall/adapter/Acl.php | 174 ++ .../firewall/adapter/AdapterInterface.php | 61 + src/Phalcon/firewall/adapter/Annotations.php | 108 + src/Phalcon/firewall/adapter/micro/Acl.php | 197 ++ src/Phalcon/flash/AbstractFlash.php | 234 ++ src/Phalcon/flash/Direct.php | 11 +- src/Phalcon/flash/Exception.php | 2 - src/Phalcon/flash/FlashInterface.php | 53 + src/Phalcon/flash/Session.php | 53 +- src/Phalcon/forms/Exception.php | 2 - src/Phalcon/forms/Form.php | 258 +- src/Phalcon/forms/Manager.php | 12 +- .../AbstractElement.php} | 253 +- src/Phalcon/forms/element/Check.php | 4 +- src/Phalcon/forms/element/Date.php | 6 +- .../forms/{ => element}/ElementInterface.php | 224 +- src/Phalcon/forms/element/Email.php | 4 +- src/Phalcon/forms/element/File.php | 6 +- src/Phalcon/forms/element/Hidden.php | 4 +- src/Phalcon/forms/element/Numeric.php | 4 +- src/Phalcon/forms/element/Password.php | 4 +- src/Phalcon/forms/element/Radio.php | 4 +- src/Phalcon/forms/element/Select.php | 30 +- src/Phalcon/forms/element/Submit.php | 6 +- src/Phalcon/forms/element/Text.php | 4 +- src/Phalcon/forms/element/TextArea.php | 6 +- src/Phalcon/helper/Arr.php | 241 +- src/Phalcon/helper/Exception.php | 3 - src/Phalcon/helper/Number.php | 23 + src/Phalcon/helper/Str.php | 413 +++ src/Phalcon/html/Attributes.php | 25 + src/Phalcon/html/Breadcrumbs.php | 79 +- src/Phalcon/html/Exception.php | 1 - src/Phalcon/html/Tag.php | 2222 +++++++++-------- src/Phalcon/html/TagFactory.php | 38 + src/Phalcon/html/Taglocator.php | 14 - src/Phalcon/html/Taglocatorfactory.php | 42 - .../html/attributes/AttributesInterface.php | 28 + .../html/attributes/RenderInterface.php | 20 + src/Phalcon/html/helper/AbstractHelper.php | 73 + src/Phalcon/html/helper/Abstracthelper.php | 54 - src/Phalcon/html/helper/Anchor.php | 21 +- src/Phalcon/html/helper/AnchorRaw.php | 21 + src/Phalcon/html/helper/Body.php | 19 + src/Phalcon/html/helper/Button.php | 19 +- src/Phalcon/html/helper/Close.php | 21 + src/Phalcon/html/helper/Element.php | 21 +- src/Phalcon/html/helper/ElementRaw.php | 24 + src/Phalcon/html/helper/Form.php | 17 +- src/Phalcon/html/helper/Formclose.php | 20 - src/Phalcon/html/helper/Img.php | 23 + src/Phalcon/html/helper/Label.php | 22 + src/Phalcon/html/helper/TextArea.php | 20 + src/Phalcon/html/helper/Textarea.php | 21 - src/Phalcon/http/Cookie.php | 201 +- src/Phalcon/http/CookieInterface.php | 118 +- src/Phalcon/http/Request.php | 715 +++--- src/Phalcon/http/RequestInterface.php | 418 +++- src/Phalcon/http/Response.php | 382 +-- src/Phalcon/http/ResponseInterface.php | 122 +- src/Phalcon/http/message/AbstractCommon.php | 41 + src/Phalcon/http/message/AbstractMessage.php | 369 +++ src/Phalcon/http/message/AbstractRequest.php | 165 ++ src/Phalcon/http/message/Request.php | 21 + src/Phalcon/http/message/RequestFactory.php | 22 + src/Phalcon/http/message/Response.php | 123 + src/Phalcon/http/message/ResponseFactory.php | 25 + src/Phalcon/http/message/ServerRequest.php | 331 +++ .../http/message/ServerRequestFactory.php | 209 ++ src/Phalcon/http/message/Stream.php | 195 ++ src/Phalcon/http/message/StreamFactory.php | 52 + src/Phalcon/http/message/UploadedFile.php | 240 ++ .../http/message/UploadedFileFactory.php | 34 + src/Phalcon/http/message/Uri.php | 432 ++++ src/Phalcon/http/message/UriFactory.php | 20 + .../exception/InvalidArgumentException.php | 16 + src/Phalcon/http/message/stream/Input.php | 76 + src/Phalcon/http/message/stream/Memory.php | 22 + src/Phalcon/http/message/stream/Temp.php | 22 + src/Phalcon/http/request/File.php | 80 +- src/Phalcon/http/request/FileInterface.php | 28 +- src/Phalcon/http/response/Cookies.php | 129 +- .../http/response/CookiesInterface.php | 66 +- src/Phalcon/http/response/Headers.php | 46 +- .../http/response/HeadersInterface.php | 34 +- .../http/server/AbstractMiddleware.php | 28 + .../http/server/AbstractRequestHandler.php | 24 + src/Phalcon/image/AdapterInterface.php | 98 - src/Phalcon/image/Enum.php | 43 + src/Phalcon/image/Exception.php | 9 +- src/Phalcon/image/Factory.php | 35 - src/Phalcon/image/ImageFactory.php | 42 + .../AbstractAdapter.php} | 193 +- .../image/adapter/AdapterInterface.php | 105 + src/Phalcon/image/adapter/Gd.php | 130 +- src/Phalcon/image/adapter/Imagick.php | 183 +- src/Phalcon/logger/Adapter.php | 174 -- src/Phalcon/logger/AdapterFactory.php | 38 + src/Phalcon/logger/AdapterInterface.php | 144 -- src/Phalcon/logger/Factory.php | 33 - src/Phalcon/logger/Formatter.php | 30 - src/Phalcon/logger/FormatterInterface.php | 24 - src/Phalcon/logger/Item.php | 47 +- src/Phalcon/logger/Logger.php | 268 ++ src/Phalcon/logger/LoggerFactory.php | 42 + src/Phalcon/logger/Multiple.php | 125 - .../logger/adapter/AbstractAdapter.php | 105 + .../logger/adapter/Abstractadapter.php | 100 - .../logger/adapter/AdapterInterface.php | 70 + .../logger/adapter/Adapterinterface.php | 54 - src/Phalcon/logger/adapter/Blackhole.php | 37 - src/Phalcon/logger/adapter/File.php | 82 - src/Phalcon/logger/adapter/Firephp.php | 55 - src/Phalcon/logger/adapter/Noop.php | 34 +- src/Phalcon/logger/adapter/Stream.php | 71 +- src/Phalcon/logger/adapter/Syslog.php | 56 +- .../logger/formatter/AbstractFormatter.php | 25 + .../logger/formatter/Abstractformatter.php | 19 - src/Phalcon/logger/formatter/Firephp.php | 72 - ...erinterface.php => FormatterInterface.php} | 20 +- src/Phalcon/logger/formatter/Json.php | 37 +- src/Phalcon/logger/formatter/Line.php | 23 +- src/Phalcon/logger/formatter/Syslog.php | 9 +- src/Phalcon/messages/Exception.php | 3 +- src/Phalcon/messages/Message.php | 244 +- src/Phalcon/messages/MessageInterface.php | 95 + src/Phalcon/messages/Messageinterface.php | 72 - src/Phalcon/messages/Messages.php | 299 ++- src/Phalcon/mvc/Application.php | 43 +- src/Phalcon/mvc/Collection.php | 857 +++---- src/Phalcon/mvc/CollectionInterface.php | 143 +- src/Phalcon/mvc/Controller.php | 16 +- src/Phalcon/mvc/Dispatcher.php | 175 +- src/Phalcon/mvc/DispatcherInterface.php | 38 +- src/Phalcon/mvc/EntityInterface.php | 6 +- src/Phalcon/mvc/Micro.php | 308 +-- src/Phalcon/mvc/Model.php | 2067 ++++++++------- src/Phalcon/mvc/ModelInterface.php | 314 +-- src/Phalcon/mvc/ModuleDefinitionInterface.php | 8 +- src/Phalcon/mvc/Router.php | 467 ++-- src/Phalcon/mvc/RouterInterface.php | 188 +- src/Phalcon/mvc/Url.php | 184 -- src/Phalcon/mvc/View.php | 708 +++--- src/Phalcon/mvc/ViewBaseInterface.php | 69 +- src/Phalcon/mvc/ViewInterface.php | 176 +- src/Phalcon/mvc/collection/Behavior.php | 34 +- .../mvc/collection/BehaviorInterface.php | 14 +- src/Phalcon/mvc/collection/Document.php | 45 +- src/Phalcon/mvc/collection/Manager.php | 142 +- .../mvc/collection/ManagerInterface.php | 74 +- .../mvc/collection/behavior/SoftDelete.php | 2 +- .../mvc/collection/behavior/Timestampable.php | 2 +- .../mvc/controller/BindModelInterface.php | 2 +- src/Phalcon/mvc/dispatcher/Exception.php | 2 +- src/Phalcon/mvc/micro/Collection.php | 154 +- src/Phalcon/mvc/micro/CollectionInterface.php | 110 +- src/Phalcon/mvc/micro/Exception.php | 2 - src/Phalcon/mvc/micro/LazyLoader.php | 20 +- src/Phalcon/mvc/micro/MiddlewareInterface.php | 2 - src/Phalcon/mvc/model/Behavior.php | 38 +- src/Phalcon/mvc/model/BehaviorInterface.php | 14 +- src/Phalcon/mvc/model/Binder.php | 48 +- src/Phalcon/mvc/model/BinderInterface.php | 32 +- src/Phalcon/mvc/model/Criteria.php | 246 +- src/Phalcon/mvc/model/CriteriaInterface.php | 273 +- src/Phalcon/mvc/model/Manager.php | 374 ++- src/Phalcon/mvc/model/ManagerInterface.php | 426 ++-- src/Phalcon/mvc/model/Message.php | 147 -- src/Phalcon/mvc/model/MessageInterface.php | 70 - src/Phalcon/mvc/model/MetaData.php | 465 ++-- src/Phalcon/mvc/model/MetaDataInterface.php | 170 +- src/Phalcon/mvc/model/Query.php | 263 +- src/Phalcon/mvc/model/QueryInterface.php | 94 +- src/Phalcon/mvc/model/Relation.php | 124 +- src/Phalcon/mvc/model/RelationInterface.php | 89 +- src/Phalcon/mvc/model/ResultInterface.php | 5 +- src/Phalcon/mvc/model/Resultset.php | 227 +- src/Phalcon/mvc/model/ResultsetInterface.php | 88 +- src/Phalcon/mvc/model/Row.php | 54 +- src/Phalcon/mvc/model/Transaction.php | 102 +- .../mvc/model/TransactionInterface.php | 69 +- src/Phalcon/mvc/model/ValidationFailed.php | 20 +- src/Phalcon/mvc/model/Validator.php | 73 - src/Phalcon/mvc/model/ValidatorInterface.php | 31 - src/Phalcon/mvc/model/behavior/SoftDelete.php | 6 +- .../mvc/model/behavior/Timestampable.php | 11 +- .../mvc/model/binder/BindableInterface.php | 3 +- src/Phalcon/mvc/model/metadata/Apc.php | 61 - src/Phalcon/mvc/model/metadata/Apcu.php | 34 +- .../mvc/model/metadata/Libmemcached.php | 48 +- src/Phalcon/mvc/model/metadata/Memcache.php | 64 - src/Phalcon/mvc/model/metadata/Memory.php | 9 +- src/Phalcon/mvc/model/metadata/Redis.php | 35 +- src/Phalcon/mvc/model/metadata/Session.php | 50 - .../mvc/model/metadata/StrategyInterface.php | 23 +- .../model/metadata/{Files.php => Stream.php} | 26 +- src/Phalcon/mvc/model/metadata/Xcache.php | 58 - .../model/metadata/strategy/Annotations.php | 21 +- .../model/metadata/strategy/Introspection.php | 12 +- src/Phalcon/mvc/model/query/Builder.php | 835 ++++--- .../mvc/model/query/BuilderInterface.php | 319 ++- src/Phalcon/mvc/model/query/Lang.php | 10 +- src/Phalcon/mvc/model/query/Status.php | 26 +- .../mvc/model/query/StatusInterface.php | 14 +- src/Phalcon/mvc/model/resultset/Complex.php | 21 +- src/Phalcon/mvc/model/resultset/Simple.php | 36 +- src/Phalcon/mvc/model/transaction/Failed.php | 12 +- src/Phalcon/mvc/model/transaction/Manager.php | 133 +- .../model/transaction/ManagerInterface.php | 66 +- src/Phalcon/mvc/model/validator/Email.php | 49 - .../mvc/model/validator/Exclusionin.php | 50 - .../mvc/model/validator/Inclusionin.php | 50 - src/Phalcon/mvc/model/validator/Ip.php | 82 - .../mvc/model/validator/Numericality.php | 49 - .../mvc/model/validator/PresenceOf.php | 50 - src/Phalcon/mvc/model/validator/Regex.php | 50 - .../mvc/model/validator/StringLength.php | 53 - .../mvc/model/validator/Uniqueness.php | 52 - src/Phalcon/mvc/model/validator/Url.php | 49 - src/Phalcon/mvc/router/Annotations.php | 50 +- src/Phalcon/mvc/router/Group.php | 195 +- src/Phalcon/mvc/router/GroupInterface.php | 179 +- src/Phalcon/mvc/router/Route.php | 332 ++- src/Phalcon/mvc/router/RouteInterface.php | 93 +- src/Phalcon/mvc/url/Exception.php | 13 - src/Phalcon/mvc/user/Component.php | 14 - src/Phalcon/mvc/user/Module.php | 14 - src/Phalcon/mvc/user/Plugin.php | 14 - src/Phalcon/mvc/view/Simple.php | 255 +- .../{Engine.php => engine/AbstractEngine.php} | 30 +- .../mvc/view/{ => engine}/EngineInterface.php | 10 +- src/Phalcon/mvc/view/engine/Php.php | 6 +- src/Phalcon/mvc/view/engine/Volt.php | 80 +- src/Phalcon/mvc/view/engine/volt/Compiler.php | 433 ++-- .../mvc/view/engine/volt/Exception.php | 6 +- src/Phalcon/paginator/Adapter.php | 44 - src/Phalcon/paginator/Factory.php | 33 - src/Phalcon/paginator/PaginatorFactory.php | 65 + src/Phalcon/paginator/Repository.php | 217 +- src/Phalcon/paginator/RepositoryInterface.php | 117 + src/Phalcon/paginator/Repositoryinterface.php | 75 - .../paginator/adapter/AbstractAdapter.php | 79 + .../{ => adapter}/AdapterInterface.php | 25 +- src/Phalcon/paginator/adapter/Model.php | 35 +- src/Phalcon/paginator/adapter/NativeArray.php | 30 +- .../paginator/adapter/QueryBuilder.php | 41 +- src/Phalcon/queue/Beanstalk.php | 269 -- src/Phalcon/queue/beanstalk/Exception.php | 13 - src/Phalcon/queue/beanstalk/Job.php | 104 - src/Phalcon/security/Random.php | 167 +- src/Phalcon/service/Exception.php | 12 - src/Phalcon/service/Locator.php | 59 - .../service/Locatorfactoryinterface.php | 18 - src/Phalcon/service/Locatorinterface.php | 27 - src/Phalcon/session/Adapter.php | 251 -- src/Phalcon/session/AdapterInterface.php | 108 - src/Phalcon/session/Bag.php | 186 +- src/Phalcon/session/BagInterface.php | 73 - src/Phalcon/session/Factory.php | 32 - src/Phalcon/session/Manager.php | 445 ++-- src/Phalcon/session/ManagerInterface.php | 189 ++ src/Phalcon/session/Managerinterface.php | 139 -- .../session/adapter/AbstractAdapter.php | 70 + src/Phalcon/session/adapter/Files.php | 29 - src/Phalcon/session/adapter/Libmemcached.php | 92 +- src/Phalcon/session/adapter/Memcache.php | 95 - src/Phalcon/session/adapter/Noop.php | 152 +- src/Phalcon/session/adapter/Redis.php | 90 +- src/Phalcon/session/adapter/Stream.php | 70 + src/Phalcon/storage/AdapterFactory.php | 43 + src/Phalcon/storage/Exception.php | 13 + src/Phalcon/storage/SerializerFactory.php | 37 + .../storage/adapter/AbstractAdapter.php | 195 ++ .../storage/adapter/AdapterInterface.php | 92 + src/Phalcon/storage/adapter/Apcu.php | 112 + src/Phalcon/storage/adapter/Libmemcached.php | 125 + src/Phalcon/storage/adapter/Memory.php | 116 + src/Phalcon/storage/adapter/Redis.php | 128 + src/Phalcon/storage/adapter/Stream.php | 156 ++ .../storage/serializer/AbstractSerializer.php | 46 + src/Phalcon/storage/serializer/Base64.php | 30 + src/Phalcon/storage/serializer/Igbinary.php | 30 + src/Phalcon/storage/serializer/Json.php | 30 + src/Phalcon/storage/serializer/Msgpack.php | 30 + src/Phalcon/storage/serializer/None.php | 30 + src/Phalcon/storage/serializer/Php.php | 30 + .../serializer/SerializerInterface.php | 27 + src/Phalcon/tag/Select.php | 22 +- src/Phalcon/translate/Factory.php | 30 - src/Phalcon/translate/InterpolatorFactory.php | 46 + .../translate/InterpolatorInterface.php | 22 - src/Phalcon/translate/TranslateFactory.php | 51 + .../AbstractAdapter.php} | 58 +- .../{ => adapter}/AdapterInterface.php | 32 +- src/Phalcon/translate/adapter/Csv.php | 33 +- src/Phalcon/translate/adapter/Gettext.php | 102 +- src/Phalcon/translate/adapter/NativeArray.php | 34 +- .../interpolator/AssociativeArray.php | 15 +- .../translate/interpolator/IndexedArray.php | 15 +- .../interpolator/InterpolatorInterface.php | 22 + src/Phalcon/{mvc => url}/UrlInterface.php | 45 +- .../AbstractCombinedFieldsValidator.php | 11 + src/Phalcon/validation/AbstractValidator.php | 132 + .../validation/AbstractValidatorComposite.php | 30 + .../validation/CombinedFieldsValidator.php | 13 - src/Phalcon/validation/Exception.php | 2 - src/Phalcon/validation/Message.php | 110 - src/Phalcon/validation/MessageInterface.php | 73 - .../{ => validation}/ValidationInterface.php | 121 +- src/Phalcon/validation/Validator.php | 97 - .../ValidatorCompositeInterface.php | 27 + src/Phalcon/validation/ValidatorFactory.php | 36 + src/Phalcon/validation/ValidatorInterface.php | 56 +- src/Phalcon/validation/message/Group.php | 155 -- src/Phalcon/validation/validator/Alnum.php | 15 +- src/Phalcon/validation/validator/Alpha.php | 15 +- src/Phalcon/validation/validator/Between.php | 15 +- src/Phalcon/validation/validator/Callback.php | 15 +- .../validation/validator/Confirmation.php | 17 +- .../validation/validator/CreditCard.php | 20 +- src/Phalcon/validation/validator/Date.php | 17 +- src/Phalcon/validation/validator/Digit.php | 15 +- src/Phalcon/validation/validator/Email.php | 15 +- .../validation/validator/Exception.php | 5 +- .../validation/validator/ExclusionIn.php | 15 +- src/Phalcon/validation/validator/File.php | 29 +- .../validation/validator/Identical.php | 15 +- .../validation/validator/InclusionIn.php | 15 +- src/Phalcon/validation/validator/Ip.php | 60 +- .../validation/validator/Numericality.php | 15 +- .../validation/validator/PresenceOf.php | 15 +- src/Phalcon/validation/validator/Regex.php | 15 +- .../validation/validator/StringLength.php | 35 +- .../validation/validator/Uniqueness.php | 53 +- src/Phalcon/validation/validator/Url.php | 15 +- .../validator/file/AbstractFile.php | 151 ++ .../validation/validator/file/MimeType.php | 68 + .../validator/file/resolution/Equal.php | 59 + .../validator/file/resolution/Max.php | 64 + .../validator/file/resolution/Min.php | 64 + .../validation/validator/file/size/Equal.php | 64 + .../validation/validator/file/size/Max.php | 64 + .../validation/validator/file/size/Min.php | 64 + .../validation/validator/stringlength/Max.php | 66 + .../validation/validator/stringlength/Min.php | 66 + 570 files changed, 28064 insertions(+), 25274 deletions(-) delete mode 100644 src/Phalcon/Acl.php create mode 100644 src/Phalcon/Cache.php create mode 100644 src/Phalcon/Collection.php delete mode 100644 src/Phalcon/CryptInterface.php delete mode 100644 src/Phalcon/Db.php delete mode 100644 src/Phalcon/Factory.php delete mode 100644 src/Phalcon/FactoryInterface.php delete mode 100644 src/Phalcon/Filter.php delete mode 100644 src/Phalcon/FilterInterface.php delete mode 100644 src/Phalcon/Flash.php delete mode 100644 src/Phalcon/FlashInterface.php delete mode 100644 src/Phalcon/Image.php delete mode 100644 src/Phalcon/Logger.php delete mode 100644 src/Phalcon/Translate.php delete mode 100644 src/Phalcon/Urlinterface.php rename src/Phalcon/acl/{Componentaware.php => ComponentAware.php} (66%) create mode 100644 src/Phalcon/acl/ComponentInterface.php delete mode 100644 src/Phalcon/acl/Componentinterface.php create mode 100644 src/Phalcon/acl/Enum.php rename src/Phalcon/acl/{Adapter.php => adapter/AbstractAdapter.php} (58%) rename src/Phalcon/acl/{ => adapter}/AdapterInterface.php (57%) create mode 100644 src/Phalcon/annotations/AnnotationsFactory.php delete mode 100644 src/Phalcon/annotations/Factory.php rename src/Phalcon/annotations/{Adapter.php => adapter/AbstractAdapter.php} (63%) rename src/Phalcon/annotations/{ => adapter}/AdapterInterface.php (72%) delete mode 100644 src/Phalcon/annotations/adapter/Apc.php rename src/Phalcon/annotations/adapter/{Files.php => Stream.php} (55%) delete mode 100644 src/Phalcon/annotations/adapter/Xcache.php rename src/Phalcon/{Application.php => application/AbstractApplication.php} (58%) create mode 100644 src/Phalcon/assets/AssetInterface.php delete mode 100644 src/Phalcon/assets/Assetinterface.php delete mode 100644 src/Phalcon/assets/Resource.php delete mode 100644 src/Phalcon/assets/ResourceInterface.php delete mode 100644 src/Phalcon/assets/resource/Css.php delete mode 100644 src/Phalcon/assets/resource/Js.php create mode 100644 src/Phalcon/cache/AdapterFactory.php delete mode 100644 src/Phalcon/cache/Backend.php delete mode 100644 src/Phalcon/cache/BackendInterface.php create mode 100644 src/Phalcon/cache/CacheFactory.php delete mode 100644 src/Phalcon/cache/Exception.php delete mode 100644 src/Phalcon/cache/FrontendInterface.php delete mode 100644 src/Phalcon/cache/Multiple.php create mode 100644 src/Phalcon/cache/adapter/AdapterInterface.php create mode 100644 src/Phalcon/cache/adapter/Apcu.php create mode 100644 src/Phalcon/cache/adapter/Libmemcached.php create mode 100644 src/Phalcon/cache/adapter/Memory.php create mode 100644 src/Phalcon/cache/adapter/Redis.php create mode 100644 src/Phalcon/cache/adapter/Stream.php delete mode 100644 src/Phalcon/cache/backend/Apc.php delete mode 100644 src/Phalcon/cache/backend/Apcu.php delete mode 100644 src/Phalcon/cache/backend/Factory.php delete mode 100644 src/Phalcon/cache/backend/File.php delete mode 100644 src/Phalcon/cache/backend/Libmemcached.php delete mode 100644 src/Phalcon/cache/backend/Memcache.php delete mode 100644 src/Phalcon/cache/backend/Memory.php delete mode 100644 src/Phalcon/cache/backend/Mongo.php delete mode 100644 src/Phalcon/cache/backend/Redis.php delete mode 100644 src/Phalcon/cache/backend/Xcache.php create mode 100644 src/Phalcon/cache/exception/Exception.php create mode 100644 src/Phalcon/cache/exception/InvalidArgumentException.php delete mode 100644 src/Phalcon/cache/frontend/Base64.php delete mode 100644 src/Phalcon/cache/frontend/Data.php delete mode 100644 src/Phalcon/cache/frontend/Factory.php delete mode 100644 src/Phalcon/cache/frontend/Igbinary.php delete mode 100644 src/Phalcon/cache/frontend/Json.php delete mode 100644 src/Phalcon/cache/frontend/Msgpack.php delete mode 100644 src/Phalcon/cache/frontend/None.php delete mode 100644 src/Phalcon/cache/frontend/Output.php create mode 100644 src/Phalcon/collection/Exception.php create mode 100644 src/Phalcon/collection/ReadOnly.php create mode 100644 src/Phalcon/config/ConfigFactory.php delete mode 100644 src/Phalcon/config/Factory.php create mode 100644 src/Phalcon/crypt/CryptInterface.php create mode 100644 src/Phalcon/db/AbstractDb.php create mode 100644 src/Phalcon/db/Enum.php rename src/Phalcon/db/{Adapter.php => adapter/AbstractAdapter.php} (68%) rename src/Phalcon/db/{ => adapter}/AdapterInterface.php (52%) create mode 100644 src/Phalcon/db/adapter/PdoFactory.php rename src/Phalcon/db/adapter/{Pdo.php => pdo/AbstractPdo.php} (75%) delete mode 100644 src/Phalcon/db/adapter/pdo/Factory.php rename src/Phalcon/{ => di}/DiInterface.php (63%) create mode 100644 src/Phalcon/di/exception/ServiceResolutionException.php delete mode 100644 src/Phalcon/di/exception/Serviceresolutionexception.php rename src/Phalcon/{Dispatcher.php => dispatcher/AbstractDispatcher.php} (54%) rename src/Phalcon/{ => dispatcher}/DispatcherInterface.php (63%) create mode 100644 src/Phalcon/dispatcher/Exception.php create mode 100644 src/Phalcon/domain/payload/Payload.php create mode 100644 src/Phalcon/domain/payload/PayloadFactory.php create mode 100644 src/Phalcon/domain/payload/PayloadInterface.php create mode 100644 src/Phalcon/domain/payload/ReadableInterface.php create mode 100644 src/Phalcon/domain/payload/Status.php create mode 100644 src/Phalcon/domain/payload/WriteableInterface.php rename src/Phalcon/{ => escaper}/EscaperInterface.php (65%) create mode 100644 src/Phalcon/factory/AbstractFactory.php create mode 100644 src/Phalcon/filter/Filter.php create mode 100644 src/Phalcon/filter/FilterFactory.php create mode 100644 src/Phalcon/filter/FilterInterface.php delete mode 100644 src/Phalcon/filter/Filterlocator.php delete mode 100644 src/Phalcon/filter/Filterlocatorfactory.php delete mode 100644 src/Phalcon/filter/UserFilterInterface.php rename src/Phalcon/filter/sanitize/{Absint.php => AbsInt.php} (61%) rename src/Phalcon/filter/sanitize/{Boolval.php => BoolVal.php} (60%) rename src/Phalcon/filter/sanitize/{Floatval.php => FloatVal.php} (60%) rename src/Phalcon/filter/sanitize/{Intval.php => IntVal.php} (59%) rename src/Phalcon/filter/sanitize/{Lowerfirst.php => LowerFirst.php} (59%) rename src/Phalcon/filter/sanitize/{Specialfull.php => SpecialFull.php} (67%) rename src/Phalcon/filter/sanitize/{Stringval.php => StringVal.php} (60%) rename src/Phalcon/filter/sanitize/{Upperfirst.php => UpperFirst.php} (59%) rename src/Phalcon/filter/sanitize/{Upperwords.php => UpperWords.php} (64%) create mode 100644 src/Phalcon/firewall/Exception.php create mode 100644 src/Phalcon/firewall/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/firewall/adapter/Acl.php create mode 100644 src/Phalcon/firewall/adapter/AdapterInterface.php create mode 100644 src/Phalcon/firewall/adapter/Annotations.php create mode 100644 src/Phalcon/firewall/adapter/micro/Acl.php create mode 100644 src/Phalcon/flash/AbstractFlash.php create mode 100644 src/Phalcon/flash/FlashInterface.php rename src/Phalcon/forms/{Element.php => element/AbstractElement.php} (58%) rename src/Phalcon/forms/{ => element}/ElementInterface.php (67%) create mode 100644 src/Phalcon/helper/Number.php create mode 100644 src/Phalcon/helper/Str.php create mode 100644 src/Phalcon/html/Attributes.php create mode 100644 src/Phalcon/html/TagFactory.php delete mode 100644 src/Phalcon/html/Taglocator.php delete mode 100644 src/Phalcon/html/Taglocatorfactory.php create mode 100644 src/Phalcon/html/attributes/AttributesInterface.php create mode 100644 src/Phalcon/html/attributes/RenderInterface.php create mode 100644 src/Phalcon/html/helper/AbstractHelper.php delete mode 100644 src/Phalcon/html/helper/Abstracthelper.php create mode 100644 src/Phalcon/html/helper/AnchorRaw.php create mode 100644 src/Phalcon/html/helper/Body.php create mode 100644 src/Phalcon/html/helper/Close.php create mode 100644 src/Phalcon/html/helper/ElementRaw.php delete mode 100644 src/Phalcon/html/helper/Formclose.php create mode 100644 src/Phalcon/html/helper/Img.php create mode 100644 src/Phalcon/html/helper/Label.php create mode 100644 src/Phalcon/html/helper/TextArea.php delete mode 100644 src/Phalcon/html/helper/Textarea.php create mode 100644 src/Phalcon/http/message/AbstractCommon.php create mode 100644 src/Phalcon/http/message/AbstractMessage.php create mode 100644 src/Phalcon/http/message/AbstractRequest.php create mode 100644 src/Phalcon/http/message/Request.php create mode 100644 src/Phalcon/http/message/RequestFactory.php create mode 100644 src/Phalcon/http/message/Response.php create mode 100644 src/Phalcon/http/message/ResponseFactory.php create mode 100644 src/Phalcon/http/message/ServerRequest.php create mode 100644 src/Phalcon/http/message/ServerRequestFactory.php create mode 100644 src/Phalcon/http/message/Stream.php create mode 100644 src/Phalcon/http/message/StreamFactory.php create mode 100644 src/Phalcon/http/message/UploadedFile.php create mode 100644 src/Phalcon/http/message/UploadedFileFactory.php create mode 100644 src/Phalcon/http/message/Uri.php create mode 100644 src/Phalcon/http/message/UriFactory.php create mode 100644 src/Phalcon/http/message/exception/InvalidArgumentException.php create mode 100644 src/Phalcon/http/message/stream/Input.php create mode 100644 src/Phalcon/http/message/stream/Memory.php create mode 100644 src/Phalcon/http/message/stream/Temp.php create mode 100644 src/Phalcon/http/server/AbstractMiddleware.php create mode 100644 src/Phalcon/http/server/AbstractRequestHandler.php delete mode 100644 src/Phalcon/image/AdapterInterface.php create mode 100644 src/Phalcon/image/Enum.php delete mode 100644 src/Phalcon/image/Factory.php create mode 100644 src/Phalcon/image/ImageFactory.php rename src/Phalcon/image/{Adapter.php => adapter/AbstractAdapter.php} (63%) create mode 100644 src/Phalcon/image/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/logger/Adapter.php create mode 100644 src/Phalcon/logger/AdapterFactory.php delete mode 100644 src/Phalcon/logger/AdapterInterface.php delete mode 100644 src/Phalcon/logger/Factory.php delete mode 100644 src/Phalcon/logger/Formatter.php delete mode 100644 src/Phalcon/logger/FormatterInterface.php create mode 100644 src/Phalcon/logger/Logger.php create mode 100644 src/Phalcon/logger/LoggerFactory.php delete mode 100644 src/Phalcon/logger/Multiple.php create mode 100644 src/Phalcon/logger/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/logger/adapter/Abstractadapter.php create mode 100644 src/Phalcon/logger/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/logger/adapter/Adapterinterface.php delete mode 100644 src/Phalcon/logger/adapter/Blackhole.php delete mode 100644 src/Phalcon/logger/adapter/File.php delete mode 100644 src/Phalcon/logger/adapter/Firephp.php create mode 100644 src/Phalcon/logger/formatter/AbstractFormatter.php delete mode 100644 src/Phalcon/logger/formatter/Abstractformatter.php delete mode 100644 src/Phalcon/logger/formatter/Firephp.php rename src/Phalcon/logger/formatter/{Formatterinterface.php => FormatterInterface.php} (51%) create mode 100644 src/Phalcon/messages/MessageInterface.php delete mode 100644 src/Phalcon/messages/Messageinterface.php delete mode 100644 src/Phalcon/mvc/Url.php delete mode 100644 src/Phalcon/mvc/model/Message.php delete mode 100644 src/Phalcon/mvc/model/MessageInterface.php delete mode 100644 src/Phalcon/mvc/model/Validator.php delete mode 100644 src/Phalcon/mvc/model/ValidatorInterface.php delete mode 100644 src/Phalcon/mvc/model/metadata/Apc.php delete mode 100644 src/Phalcon/mvc/model/metadata/Memcache.php delete mode 100644 src/Phalcon/mvc/model/metadata/Session.php rename src/Phalcon/mvc/model/metadata/{Files.php => Stream.php} (57%) delete mode 100644 src/Phalcon/mvc/model/metadata/Xcache.php delete mode 100644 src/Phalcon/mvc/model/validator/Email.php delete mode 100644 src/Phalcon/mvc/model/validator/Exclusionin.php delete mode 100644 src/Phalcon/mvc/model/validator/Inclusionin.php delete mode 100644 src/Phalcon/mvc/model/validator/Ip.php delete mode 100644 src/Phalcon/mvc/model/validator/Numericality.php delete mode 100644 src/Phalcon/mvc/model/validator/PresenceOf.php delete mode 100644 src/Phalcon/mvc/model/validator/Regex.php delete mode 100644 src/Phalcon/mvc/model/validator/StringLength.php delete mode 100644 src/Phalcon/mvc/model/validator/Uniqueness.php delete mode 100644 src/Phalcon/mvc/model/validator/Url.php delete mode 100644 src/Phalcon/mvc/url/Exception.php delete mode 100644 src/Phalcon/mvc/user/Component.php delete mode 100644 src/Phalcon/mvc/user/Module.php delete mode 100644 src/Phalcon/mvc/user/Plugin.php rename src/Phalcon/mvc/view/{Engine.php => engine/AbstractEngine.php} (62%) rename src/Phalcon/mvc/view/{ => engine}/EngineInterface.php (68%) delete mode 100644 src/Phalcon/paginator/Adapter.php delete mode 100644 src/Phalcon/paginator/Factory.php create mode 100644 src/Phalcon/paginator/PaginatorFactory.php create mode 100644 src/Phalcon/paginator/RepositoryInterface.php delete mode 100644 src/Phalcon/paginator/Repositoryinterface.php create mode 100644 src/Phalcon/paginator/adapter/AbstractAdapter.php rename src/Phalcon/paginator/{ => adapter}/AdapterInterface.php (62%) delete mode 100644 src/Phalcon/queue/Beanstalk.php delete mode 100644 src/Phalcon/queue/beanstalk/Exception.php delete mode 100644 src/Phalcon/queue/beanstalk/Job.php delete mode 100644 src/Phalcon/service/Exception.php delete mode 100644 src/Phalcon/service/Locator.php delete mode 100644 src/Phalcon/service/Locatorfactoryinterface.php delete mode 100644 src/Phalcon/service/Locatorinterface.php delete mode 100644 src/Phalcon/session/Adapter.php delete mode 100644 src/Phalcon/session/AdapterInterface.php delete mode 100644 src/Phalcon/session/BagInterface.php delete mode 100644 src/Phalcon/session/Factory.php create mode 100644 src/Phalcon/session/ManagerInterface.php delete mode 100644 src/Phalcon/session/Managerinterface.php create mode 100644 src/Phalcon/session/adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/session/adapter/Files.php delete mode 100644 src/Phalcon/session/adapter/Memcache.php create mode 100644 src/Phalcon/session/adapter/Stream.php create mode 100644 src/Phalcon/storage/AdapterFactory.php create mode 100644 src/Phalcon/storage/Exception.php create mode 100644 src/Phalcon/storage/SerializerFactory.php create mode 100644 src/Phalcon/storage/adapter/AbstractAdapter.php create mode 100644 src/Phalcon/storage/adapter/AdapterInterface.php create mode 100644 src/Phalcon/storage/adapter/Apcu.php create mode 100644 src/Phalcon/storage/adapter/Libmemcached.php create mode 100644 src/Phalcon/storage/adapter/Memory.php create mode 100644 src/Phalcon/storage/adapter/Redis.php create mode 100644 src/Phalcon/storage/adapter/Stream.php create mode 100644 src/Phalcon/storage/serializer/AbstractSerializer.php create mode 100644 src/Phalcon/storage/serializer/Base64.php create mode 100644 src/Phalcon/storage/serializer/Igbinary.php create mode 100644 src/Phalcon/storage/serializer/Json.php create mode 100644 src/Phalcon/storage/serializer/Msgpack.php create mode 100644 src/Phalcon/storage/serializer/None.php create mode 100644 src/Phalcon/storage/serializer/Php.php create mode 100644 src/Phalcon/storage/serializer/SerializerInterface.php delete mode 100644 src/Phalcon/translate/Factory.php create mode 100644 src/Phalcon/translate/InterpolatorFactory.php delete mode 100644 src/Phalcon/translate/InterpolatorInterface.php create mode 100644 src/Phalcon/translate/TranslateFactory.php rename src/Phalcon/translate/{Adapter.php => adapter/AbstractAdapter.php} (58%) rename src/Phalcon/translate/{ => adapter}/AdapterInterface.php (53%) create mode 100644 src/Phalcon/translate/interpolator/InterpolatorInterface.php rename src/Phalcon/{mvc => url}/UrlInterface.php (61%) create mode 100644 src/Phalcon/validation/AbstractCombinedFieldsValidator.php create mode 100644 src/Phalcon/validation/AbstractValidator.php create mode 100644 src/Phalcon/validation/AbstractValidatorComposite.php delete mode 100644 src/Phalcon/validation/CombinedFieldsValidator.php delete mode 100644 src/Phalcon/validation/Message.php delete mode 100644 src/Phalcon/validation/MessageInterface.php rename src/Phalcon/{ => validation}/ValidationInterface.php (56%) delete mode 100644 src/Phalcon/validation/Validator.php create mode 100644 src/Phalcon/validation/ValidatorCompositeInterface.php create mode 100644 src/Phalcon/validation/ValidatorFactory.php delete mode 100644 src/Phalcon/validation/message/Group.php create mode 100644 src/Phalcon/validation/validator/file/AbstractFile.php create mode 100644 src/Phalcon/validation/validator/file/MimeType.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Equal.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Max.php create mode 100644 src/Phalcon/validation/validator/file/resolution/Min.php create mode 100644 src/Phalcon/validation/validator/file/size/Equal.php create mode 100644 src/Phalcon/validation/validator/file/size/Max.php create mode 100644 src/Phalcon/validation/validator/file/size/Min.php create mode 100644 src/Phalcon/validation/validator/stringlength/Max.php create mode 100644 src/Phalcon/validation/validator/stringlength/Min.php diff --git a/src/Phalcon/Acl.php b/src/Phalcon/Acl.php deleted file mode 100644 index 498be5ea..00000000 --- a/src/Phalcon/Acl.php +++ /dev/null @@ -1,60 +0,0 @@ - - * use Phalcon\Acl; - * use Phalcon\Acl\Role; - * use Phalcon\Acl\Resource; - * use Phalcon\Acl\Adapter\Memory; - * - * $acl = new Memory(); - * - * // Default action is deny access - * $acl->setDefaultAction(Acl::DENY); - * - * // Create some roles - * $roleAdmins = new Role("Administrators", "Super-User role"); - * $roleGuests = new Role("Guests"); - * - * // Add "Guests" role to acl - * $acl->addRole($roleGuests); - * - * // Add "Designers" role to acl - * $acl->addRole("Designers"); - * - * // Define the "Customers" resource - * $customersResource = new Resource("Customers", "Customers management"); - * - * // Add "customers" resource with a couple of operations - * $acl->addResource($customersResource, "search"); - * $acl->addResource($customersResource, ["create", "update"]); - * - * // Set access level for roles into resources - * $acl->allow("Guests", "Customers", "search"); - * $acl->allow("Guests", "Customers", "create"); - * $acl->deny("Guests", "Customers", "update"); - * - * // Check whether role has access to the operations - * $acl->isAllowed("Guests", "Customers", "edit"); // Returns 0 - * $acl->isAllowed("Guests", "Customers", "search"); // Returns 1 - * $acl->isAllowed("Guests", "Customers", "create"); // Returns 1 - * - */ -abstract class Acl -{ - - const ALLOW = 1; - - - const DENY = 0; - - -} diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php new file mode 100644 index 00000000..444fa3d7 --- /dev/null +++ b/src/Phalcon/Cache.php @@ -0,0 +1,164 @@ + value pairs. Cache keys that do not exist or are stale will have $default as value. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + * @param iterable $keys A list of keys that can obtained in a single operation. + * @param mixed $defaultValue + * @return mixed + */ + public function getMultiple($keys, $defaultValue = null) {} + + /** + * Determines whether an item is present in the cache. + * + * @param string $key The cache item key. + * + * @return bool + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + * @param mixed $key + * @return bool + */ + public function has($key): bool {} + + /** + * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. + * + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + * @param string $key The key of the item to store. + * @param mixed $value The value of the item to store. Must be serializable. + * @param mixed $ttl + * @return bool + */ + public function set($key, $value, $ttl = null): bool {} + + /** + * Persists a set of key => value pairs in the cache, with an optional TTL. + * + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws Phalcon\Cache\Exception\InvalidArgumentException + * MUST be thrown if $values is neither an array nor a Traversable, + * or if any of the $values are not a legal value. + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param mixed $ttl + * @return bool + */ + public function setMultiple($values, $ttl = null): bool {} + + /** + * Checks the key. If it contains invalid characters an exception is thrown + * + * @param mixed $key + */ + protected function checkKey($key) {} + + /** + * Checks the key. If it contains invalid characters an exception is thrown + * + * @param mixed $keys + */ + protected function checkKeys($keys) {} + +} diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php new file mode 100644 index 00000000..ecde5727 --- /dev/null +++ b/src/Phalcon/Collection.php @@ -0,0 +1,217 @@ + + * ```php * $config = new \Phalcon\Config( * [ * "database" => [ @@ -26,109 +25,30 @@ * ], * ] * ); - * + * ``` */ -class Config implements \ArrayAccess, \Countable +class Config extends \Phalcon\Collection { const DEFAULT_PATH_DELIMITER = '.'; - - static protected $_pathDelimiter; - - /** - * Phalcon\Config constructor - * - * @param array $arrayConfig + * @var string */ - public function __construct(array $arrayConfig = null) {} + protected $pathDelimiter = null; - /** - * Allows to check whether an attribute is defined using the array-syntax - * - * - * var_dump( - * isset($config["database"]) - * ); - * - * - * @param mixed $index - * @return bool - */ - public function offsetExists($index) {} /** - * Returns a value from current config using a dot separated path. - * - * - * echo $config->path("unknown.path", "default", "."); - * - * - * @param string $path - * @param mixed $defaultValue - * @param mixed $delimiter - * @return mixed - */ - public function path($path, $defaultValue = null, $delimiter = null) {} - - /** - * Gets an attribute from the configuration, if the attribute isn't defined returns null - * If the value is exactly null or is not defined the default value will be used instead - * - * - * echo $config->get("controllersDir", "../app/controllers/"); - * - * - * @param mixed $index - * @param mixed $defaultValue - * @return mixed - */ - public function get($index, $defaultValue = null) {} - - /** - * Gets an attribute using the array-syntax - * - * - * print_r( - * $config["database"] - * ); - * + * Gets the default path delimiter * - * @param mixed $index * @return string */ - public function offsetGet($index) {} - - /** - * Sets an attribute using the array-syntax - * - * - * $config["database"] = [ - * "type" => "Sqlite", - * ]; - * - * - * @param mixed $index - * @param mixed $value - */ - public function offsetSet($index, $value) {} - - /** - * Unsets an attribute using the array-syntax - * - * - * unset($config["database"]); - * - * - * @param mixed $index - */ - public function offsetUnset($index) {} + public function getPathDelimiter(): string {} /** * Merges a configuration into the current one * - * + * ```php * $appConfig = new \Phalcon\Config( * [ * "database" => [ @@ -138,74 +58,62 @@ public function offsetUnset($index) {} * ); * * $globalConfig->merge($appConfig); - * + * ``` * - * @param Config $config + * @param mixed $toMerge * @return Config */ - public function merge(Config $config) {} + public function merge($toMerge): Config {} /** - * Converts recursively the object to an array - * - * - * print_r( - * $config->toArray() - * ); - * - * - * @return array - */ - public function toArray() {} - - /** - * Returns the count of properties set in the config - * - * - * print count($config); - * - * - * or + * Returns a value from current config using a dot separated path. * - * - * print $config->count(); - * + * ```php + * echo $config->path("unknown.path", "default", "."); + * ``` * - * @return int + * @param string $path + * @param mixed $defaultValue + * @param mixed $delimiter */ - public function count() {} + public function path(string $path, $defaultValue = null, $delimiter = null) {} /** - * Restores the state of a Phalcon\Config object + * Sets the default path delimiter * - * @param array $data + * @param string $delimiter * @return Config */ - public static function __set_state(array $data) {} + public function setPathDelimiter(string $delimiter = null): Config {} /** - * Sets the default path delimiter + * Converts recursively the object to an array * - * @param string $delimiter + * ```php + * print_r( + * $config->toArray() + * ); + * ``` + * + * @return array */ - public static function setPathDelimiter($delimiter = null) {} + public function toArray(): array {} /** - * Gets the default path delimiter + * Performs a merge recursively * - * @return string + * @param array $source + * @param array $target + * @return array */ - public static function getPathDelimiter() {} + final protected function internalMerge(array $source, array $target): array {} /** - * Helper method for merge configs (forwarding nested config instance) - * - * @param Config instance = null + * Sets the collection data * - * @param Config $config - * @param mixed $instance - * @return Config + * @param mixed $element + * @param mixed $value */ - protected final function _merge(Config $config, $instance = null) {} + protected function setData($element, $value) {} } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 73a9f388..22b70ee1 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -2,33 +2,38 @@ namespace Phalcon; -use Psr\Container\ContainerInterface; -use Phalcon\DiInterface; - -class Container implements ContainerInterface +/** + * PSR-11 Wrapper for `Phalcon\Di` + */ +class Container implements \Psr\Container\ContainerInterface { - /** - * @var - */ - protected $container; + /** + * @var + */ + protected $container; + + + /** + * Phalcon\Container constructor + * + * @param \Phalcon\Di\DiInterface $container + */ + public function __construct(\Phalcon\Di\DiInterface $container) {} - /** - * Phalcon\Di constructor - */ - public function __construct(DiInterface $container) - { - } + /** + * Return the service + * + * @param mixed $name + * @return mixed + */ + public function get($name) {} - /** - * Return the service - */ - public function get($name) { - } + /** + * Whether a service exists or not in the container + * + * @param mixed $name + * @return bool + */ + public function has($name): bool {} - /** - * Whether a service exists or not in the container - */ - public function has($name) : bool - { - } } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 722ef5af..9a547569 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Crypt + * Provides encryption capabilities to Phalcon applications. * - * Provides encryption facilities to Phalcon applications. - * - * + * ```php * use Phalcon\Crypt; * * $crypt = new Crypt(); @@ -20,18 +18,15 @@ * $encrypted = $crypt->encrypt($text, $key); * * echo $crypt->decrypt($encrypted, $key); - * + * ``` */ -class Crypt implements \Phalcon\CryptInterface +class Crypt implements \Phalcon\Crypt\CryptInterface { - const PADDING_DEFAULT = 0; - - const PADDING_ANSI_X_923 = 1; - const PADDING_PKCS7 = 2; + const PADDING_DEFAULT = 0; const PADDING_ISO_10126 = 3; @@ -40,19 +35,43 @@ class Crypt implements \Phalcon\CryptInterface const PADDING_ISO_IEC_7816_4 = 4; - const PADDING_ZERO = 5; + const PADDING_PKCS7 = 2; const PADDING_SPACE = 6; - protected $_key; + const PADDING_ZERO = 5; + /** + * @var string + */ + protected $authTag; - protected $_padding = 0; + /** + * @var string + */ + protected $authData = ''; + + /** + * @var int + */ + protected $authTagLength = 16; + /** + * @var string + */ + protected $key; + + /** + * @var int + */ + protected $padding = 0; - protected $_cipher = 'aes-256-cfb'; + /** + * @var string + */ + protected $cipher = 'aes-256-cfb'; /** * Available cipher methods. @@ -77,224 +96,249 @@ class Crypt implements \Phalcon\CryptInterface /** * Whether calculating message digest enabled or not. - * NOTE: This feature will be enabled by default in Phalcon 4.0.0 * * @var bool */ - protected $useSigning = false; + protected $useSigning = true; + /** + * @return string + */ + public function getAuthTag(): string {} + + /** + * @return string + */ + public function getAuthData(): string {} + + /** + * @return int + */ + public function getAuthTagLength(): int {} + /** * Phalcon\Crypt constructor. * * @param string $cipher * @param bool $useSigning */ - public function __construct($cipher = 'aes-256-cfb', $useSigning = false) {} + public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = false) {} /** - * Changes the padding scheme used. + * Decrypts an encrypted text. * - * @param int $scheme - * @return \Phalcon\CryptInterface + * ```php + * $encrypted = $crypt->decrypt( + * $encrypted, + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * ``` + * + * @param string $text + * @param string $key + * @return string */ - public function setPadding($scheme) {} + public function decrypt(string $text, string $key = null): string {} /** - * Sets the cipher algorithm for data encryption and decryption. + * Decrypt a text that is coded as a base64 string. * - * The `aes-256-gcm' is the preferable cipher, but it is not usable - * until the openssl library is upgraded, which is available in PHP 7.1. + * @throws \Phalcon\Crypt\Mismatch + * @param string $text + * @param mixed $key + * @param bool $safe + * @return string + */ + public function decryptBase64(string $text, $key = null, bool $safe = false): string {} + + /** + * Encrypts a text. * - * The `aes-256-ctr' is arguably the best choice for cipher - * algorithm for current openssl library version. + * ```php + * $encrypted = $crypt->encrypt( + * "Top secret", + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * ``` * - * @param string $cipher - * @return \Phalcon\CryptInterface + * @param string $text + * @param string $key + * @return string */ - public function setCipher($cipher) {} + public function encrypt(string $text, string $key = null): string {} /** - * Returns the current cipher + * Encrypts a text returning the result as a base64 string. * + * @param string $text + * @param mixed $key + * @param bool $safe * @return string */ - public function getCipher() {} + public function encryptBase64(string $text, $key = null, bool $safe = false): string {} /** - * Sets the encryption key. - * - * The `$key' should have been previously generated in a cryptographically safe way. - * - * Bad key: - * "le password" - * - * Better (but still unsafe): - * "#1dj8$=dp?.ak//j1V$~%0X" - * - * Good key: - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * Returns a list of available ciphers. * - * @see \Phalcon\Security\Random - * @param string $key - * @return \Phalcon\CryptInterface + * @return array */ - public function setKey($key) {} + public function getAvailableCiphers(): array {} /** - * Returns the encryption key + * Return a list of registered hashing algorithms suitable for hash_hmac. * - * @return string + * @return array */ - public function getKey() {} + public function getAvailableHashAlgos(): array {} /** - * Set the name of hashing algorithm. + * Returns the current cipher * - * @throws \Phalcon\Crypt\Exception - * @param string $hashAlgo - * @return Crypt + * @return string */ - public function setHashAlgo($hashAlgo) {} + public function getCipher(): string {} /** * Get the name of hashing algorithm. * * @return string */ - public function getHashAlgo() {} + public function getHashAlgo(): string {} /** - * Sets if the calculating message digest must used. - * - * NOTE: This feature will be enabled by default in Phalcon 4.0.0 + * Returns the encryption key * - * @param bool $useSigning - * @return Crypt + * @return string */ - public function useSigning($useSigning) {} + public function getKey(): string {} /** - * Pads texts before encryption. - * - * @link http://www.di-mgt.com.au/cryptopad.html - * @param string $text - * @param string $mode - * @param int $blockSize - * @param int $paddingType + * @param string $tag + * @return \Phalcon\Crypt\CryptInterface */ - protected function _cryptPadText($text, $mode, $blockSize, $paddingType) {} + public function setAuthTag(string $tag): CryptInterface {} /** - * Removes a padding from a text. - * - * If the function detects that the text was not padded, it will return it unmodified. - * - * @param string $text Message to be unpadded - * @param string $mode Encryption mode; unpadding is applied only in CBC or ECB mode - * @param int $blockSize Cipher block size - * @param int $paddingType Padding scheme + * @param string $data + * @return \Phalcon\Crypt\CryptInterface */ - protected function _cryptUnpadText($text, $mode, $blockSize, $paddingType) {} + public function setAuthData(string $data): CryptInterface {} /** - * Encrypts a text. - * - * - * $encrypted = $crypt->encrypt( - * "Top secret", - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * - * - * @param string $text - * @param string $key - * @return string + * @param int $length + * @return \Phalcon\Crypt\CryptInterface */ - public function encrypt($text, $key = null) {} + public function setAuthTagLength(int $length): CryptInterface {} /** - * Decrypts an encrypted text. + * Sets the cipher algorithm for data encryption and decryption. * - * - * $encrypted = $crypt->decrypt( - * $encrypted, - * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" - * ); - * + * The `aes-256-gcm' is the preferable cipher, but it is not usable + * until the openssl library is upgraded, which is available in PHP 7.1. * - * @throws \Phalcon\Crypt\Mismatch - * @param string $text - * @param string $key - * @return string + * The `aes-256-ctr' is arguably the best choice for cipher + * algorithm for current openssl library version. + * + * @param string $cipher + * @return \Phalcon\Crypt\CryptInterface */ - public function decrypt($text, $key = null) {} + public function setCipher(string $cipher): CryptInterface {} /** - * Encrypts a text returning the result as a base64 string. + * Set the name of hashing algorithm. * - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string + * @throws \Phalcon\Crypt\Exception + * @param string $hashAlgo + * @return \Phalcon\Crypt\CryptInterface */ - public function encryptBase64($text, $key = null, $safe = false) {} + public function setHashAlgo(string $hashAlgo): CryptInterface {} /** - * Decrypt a text that is coded as a base64 string. + * Sets the encryption key. * - * @throws \Phalcon\Crypt\Mismatch - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string + * The `$key' should have been previously generated in a cryptographically + * safe way. + * + * Bad key: + * "le password" + * + * Better (but still unsafe): + * "#1dj8$=dp?.ak//j1V$~%0X" + * + * Good key: + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * + * @param string $key + * @return \Phalcon\Crypt\CryptInterface */ - public function decryptBase64($text, $key = null, $safe = false) {} + public function setKey(string $key): CryptInterface {} /** - * Returns a list of available ciphers. + * Changes the padding scheme used. * - * @return array + * @param int $scheme + * @return \Phalcon\Crypt\CryptInterface */ - public function getAvailableCiphers() {} + public function setPadding(int $scheme): CryptInterface {} /** - * Return a list of registered hashing algorithms suitable for hash_hmac. + * Sets if the calculating message digest must used. * - * @return array + * @param bool $useSigning + * @return \Phalcon\Crypt\CryptInterface */ - public function getAvailableHashAlgos() {} + public function useSigning(bool $useSigning): CryptInterface {} /** * Assert the cipher is available. * - * @throws \Phalcon\Crypt\Exception * @param string $cipher */ - protected function assertCipherIsAvailable($cipher) {} + protected function assertCipherIsAvailable(string $cipher) {} /** * Assert the hash algorithm is available. * - * @throws \Phalcon\Crypt\Exception * @param string $hashAlgo */ - protected function assertHashAlgorithmAvailable($hashAlgo) {} + protected function assertHashAlgorithmAvailable(string $hashAlgo) {} /** * Initialize available cipher algorithms. * - * @throws \Phalcon\Crypt\Exception * @param string $cipher * @return int */ - protected function getIvLength($cipher) {} + protected function getIvLength(string $cipher): int {} /** * Initialize available cipher algorithms. - * - * @throws \Phalcon\Crypt\Exception */ protected function initializeAvailableCiphers() {} + /** + * Pads texts before encryption. See [cryptopad](http://www.di-mgt.com.au/cryptopad.html) + * + * @param string $text + * @param string $mode + * @param int $blockSize + * @param int $paddingType + * @return string + */ + protected function cryptPadText(string $text, string $mode, int $blockSize, int $paddingType): string {} + + /** + * Removes a padding from a text. + * + * If the function detects that the text was not padded, it will return it + * unmodified. + * + * @param string $text + * @param string $mode + * @param int $blockSize + * @param int $paddingType + */ + protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) {} + } diff --git a/src/Phalcon/CryptInterface.php b/src/Phalcon/CryptInterface.php deleted file mode 100644 index d79c16f8..00000000 --- a/src/Phalcon/CryptInterface.php +++ /dev/null @@ -1,86 +0,0 @@ - - * use Phalcon\Db; - * use Phalcon\Db\Exception; - * use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; - * - * try { - * $connection = new MysqlConnection( - * [ - * "host" => "192.168.0.11", - * "username" => "sigma", - * "password" => "secret", - * "dbname" => "blog", - * "port" => "3306", - * ] - * ); - * - * $result = $connection->query( - * "SELECT FROM robots LIMIT 5" - * ); - * - * $result->setFetchMode(Db::FETCH_NUM); - * - * while ($robot = $result->fetch()) { - * print_r($robot); - * } - * } catch (Exception $e) { - * echo $e->getMessage(), PHP_EOL; - * } - * - */ -abstract class Db -{ - - const FETCH_LAZY = 1; - - - const FETCH_ASSOC = 2; - - - const FETCH_NAMED = 11; - - - const FETCH_NUM = 3; - - - const FETCH_BOTH = 4; - - - const FETCH_OBJ = 5; - - - const FETCH_BOUND = 6; - - - const FETCH_COLUMN = 7; - - - const FETCH_CLASS = 8; - - - const FETCH_INTO = 9; - - - const FETCH_FUNC = 10; - - - const FETCH_GROUP = 65536; - - - const FETCH_UNIQUE = 196608; - - - const FETCH_KEY_PAIR = 12; - - - const FETCH_CLASSTYPE = 262144; - - - const FETCH_SERIALIZE = 524288; - - - const FETCH_PROPS_LATE = 1048576; - - - /** - * Enables/disables options in the Database component - * - * @param array $options - */ - public static function setup(array $options) {} - -} diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index cfe5cfe6..291d4d30 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -3,69 +3,90 @@ namespace Phalcon; /** - * Phalcon\Debug - * * Provides debug capabilities to Phalcon applications */ class Debug { - - public $_uri = '//static.phalconphp.com/www/debug/3.0.x/'; - - - public $_theme = 'default'; - - - protected $_hideDocumentRoot = false; - - - protected $_showBackTrace = true; + /** + * @var array + */ + protected $blacklist = array('request' => array(), 'server' => array()); - protected $_showFiles = true; + protected $data; + /** + * @var bool + */ + protected $hideDocumentRoot = false; - protected $_showFileFragment = false; + /** + * @var bool + */ + static protected $isActive; + /** + * @var bool + */ + protected $showBackTrace = true; - protected $_data; + /** + * @var bool + */ + protected $showFileFragment = false; + /** + * @var bool + */ + protected $showFiles = true; - static protected $_isActive; + /** + * @var string + */ + protected $uri = 'https://assets.phalconphp.com/debug/4.0.x/'; /** - * Change the base URI for static resources + * Clears are variables added previously * - * @param string $uri * @return Debug */ - public function setUri($uri) {} + public function clearVars(): Debug {} /** - * Sets if files the exception's backtrace must be showed + * Adds a variable to the debug output * - * @param bool $showBackTrace + * @param mixed $varz + * @param string $key * @return Debug */ - public function setShowBackTrace($showBackTrace) {} + public function debugVar($varz, string $key = null): Debug {} /** - * Set if files part of the backtrace must be shown in the output + * Returns the css sources * - * @param bool $showFiles - * @return Debug + * @return string */ - public function setShowFiles($showFiles) {} + public function getCssSources(): string {} /** - * Sets if files must be completely opened and showed in the output - * or just the fragment related to the exception + * Returns the javascript sources * - * @param bool $showFileFragment - * @return Debug + * @return string */ - public function setShowFileFragment($showFileFragment) {} + public function getJsSources(): string {} + + /** + * Generates a link to the current version documentation + * + * @return string + */ + public function getVersion(): string {} + + /** + * Halts the request showing a backtrace + */ + public function halt() {} /** * Listen for uncaught exceptions and unsilent notices or warnings @@ -74,124 +95,114 @@ public function setShowFileFragment($showFileFragment) {} * @param bool $lowSeverity * @return Debug */ - public function listen($exceptions = true, $lowSeverity = false) {} + public function listen(bool $exceptions = true, bool $lowSeverity = false): Debug {} /** * Listen for uncaught exceptions * * @return Debug */ - public function listenExceptions() {} + public function listenExceptions(): Debug {} /** * Listen for unsilent notices or warnings * * @return Debug */ - public function listenLowSeverity() {} + public function listenLowSeverity(): Debug {} /** - * Halts the request showing a backtrace + * Handles uncaught exceptions + * + * @param \Exception $exception + * @return bool */ - public function halt() {} + public function onUncaughtException(\Exception $exception): bool {} /** - * Adds a variable to the debug output + * Throws an exception when a notice or warning is raised * - * @param mixed $varz - * @param string $key - * @return Debug + * @param mixed $severity + * @param mixed $message + * @param mixed $file + * @param mixed $line + * @param mixed $context */ - public function debugVar($varz, $key = null) {} + public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} /** - * Clears are variables added previously + * Sets if files the exception's backtrace must be showed * + * @param array $blacklist * @return Debug */ - public function clearVars() {} + public function setBlacklist(array $blacklist): Debug {} /** - * Escapes a string with htmlentities + * Sets if files the exception's backtrace must be showed * - * @param mixed $value - * @return string + * @param bool $showBackTrace + * @return Debug */ - protected function _escapeString($value) {} + public function setShowBackTrace(bool $showBackTrace): Debug {} /** - * Produces a recursive representation of an array + * Sets if files must be completely opened and showed in the output + * or just the fragment related to the exception * - * @param array $argument - * @param mixed $n - * @return string|null + * @param bool $showFileFragment + * @return Debug */ - protected function _getArrayDump(array $argument, $n = 0) {} + public function setShowFileFragment(bool $showFileFragment): Debug {} /** - * Produces an string representation of a variable + * Set if files part of the backtrace must be shown in the output * - * @param mixed $variable - * @return string + * @param bool $showFiles + * @return Debug */ - protected function _getVarDump($variable) {} + public function setShowFiles(bool $showFiles): Debug {} /** - * Returns the major framework's version + * Change the base URI for static resources * - * @deprecated Will be removed in 4.0.0 - * @see Phalcon\Version::getPart() - * @deprecated - * @return string + * @param string $uri + * @return Debug */ - public function getMajorVersion() {} + public function setUri(string $uri): Debug {} /** - * Generates a link to the current version documentation + * Escapes a string with htmlentities * + * @param mixed $value * @return string */ - public function getVersion() {} + protected function escapeString($value): string {} /** - * Returns the css sources + * Produces a recursive representation of an array * - * @return string + * @param array $argument + * @param mixed $n + * @return string|null */ - public function getCssSources() {} + protected function getArrayDump(array $argument, $n = 0): ?string {} /** - * Returns the javascript sources + * Produces an string representation of a variable * + * @param mixed $variable * @return string */ - public function getJsSources() {} + protected function getVarDump($variable): string {} /** * Shows a backtrace item * * @param int $n * @param array $trace + * @return string */ - protected final function showTraceItem($n, array $trace) {} - - /** - * Throws an exception when a notice or warning is raised - * - * @param mixed $severity - * @param mixed $message - * @param mixed $file - * @param mixed $line - * @param mixed $context - */ - public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} - - /** - * Handles uncaught exceptions - * - * @param \Exception $exception - * @return bool - */ - public function onUncaughtException(\Exception $exception) {} + final protected function showTraceItem(int $n, array $trace): string {} } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 1ebe86df..4f4d7bb0 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -3,23 +3,24 @@ namespace Phalcon; /** - * Phalcon\Di + * Phalcon\Di is a component that implements Dependency Injection/Service + * Location of services and it's itself a container for them. * - * Phalcon\Di is a component that implements Dependency Injection/Service Location - * of services and it's itself a container for them. + * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the + * different components of the framework. The developer can also use this + * component to inject dependencies and manage global instances of the different + * classes used in the application. * - * Since Phalcon is highly decoupled, Phalcon\Di is essential to integrate the different - * components of the framework. The developer can also use this component to inject dependencies - * and manage global instances of the different classes used in the application. + * Basically, this component implements the `Inversion of Control` pattern. + * Applying this, the objects do not receive their dependencies using setters or + * constructors, but requesting a service dependency injector. This reduces the + * overall complexity, since there is only one way to get the required + * dependencies within a component. * - * Basically, this component implements the `Inversion of Control` pattern. Applying this, - * the objects do not receive their dependencies using setters or constructors, but requesting - * a service dependency injector. This reduces the overall complexity, since there is only one - * way to get the required dependencies within a component. + * Additionally, this pattern increases testability in the code, thus making it + * less prone to errors. * - * Additionally, this pattern increases testability in the code, thus making it less prone to errors. - * - * + * ```php * use Phalcon\Di; * use Phalcon\Http\Request; * @@ -37,31 +38,26 @@ * ); * * $request = $di->getRequest(); - * + * ``` */ -class Di implements \Phalcon\DiInterface +class Di implements \Phalcon\Di\DiInterface { /** * List of registered services */ - protected $_services; + protected $services; /** * List of shared instances */ - protected $_sharedInstances; - - /** - * To know if the latest resolved instance was shared or not - */ - protected $_freshInstance = false; + protected $sharedInstances; /** * Events Manager * - * @var \Phalcon\Events\ManagerInterface + * @var ManagerInterface */ - protected $_eventsManager; + protected $eventsManager; /** * Latest DI build @@ -75,66 +71,48 @@ class Di implements \Phalcon\DiInterface public function __construct() {} /** - * Sets the internal event manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Returns the internal event manager + * Magic method to get or set services using setters/getters * - * @return \Phalcon\Events\ManagerInterface + * @param string $method + * @param array $arguments + * @return mixed|null */ - public function getInternalEventsManager() {} + public function __call(string $method, array $arguments = array()): ? {} /** - * Registers a service in the services container + * Attempts to register a service in the services container + * Only is successful if a service hasn't been registered previously + * with the same name * * @param string $name * @param mixed $definition * @param bool $shared - * @return \Phalcon\Di\ServiceInterface - */ - public function set($name, $definition, $shared = false) {} - - /** - * Registers an "always shared" service in the services container - * - * @param string $name - * @param mixed $definition - * @return \Phalcon\Di\ServiceInterface + * @return bool|\Phalcon\Di\ServiceInterface */ - public function setShared($name, $definition) {} + public function attempt(string $name, $definition, bool $shared = false) {} /** - * Removes a service in the services container - * It also removes any shared instance created for the service + * Resolves the service based on its configuration * * @param string $name + * @param mixed $parameters + * @return mixed */ - public function remove($name) {} + public function get(string $name, $parameters = null) {} /** - * Attempts to register a service in the services container - * Only is successful if a service hasn't been registered previously - * with the same name + * Return the latest DI created * - * @param string $name - * @param mixed $definition - * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return null|\Phalcon\Di\DiInterface */ - public function attempt($name, $definition, $shared = false) {} + public static function getDefault(): ?DiInterface {} /** - * Sets a service using a raw Phalcon\Di\Service definition + * Returns the internal event manager * - * @param string $name - * @param \Phalcon\Di\ServiceInterface $rawDefinition - * @return \Phalcon\Di\ServiceInterface + * @return \Phalcon\Events\ManagerInterface */ - public function setRaw($name, \Phalcon\Di\ServiceInterface $rawDefinition) {} + public function getInternalEventsManager(): ManagerInterface {} /** * Returns a service definition without resolving @@ -142,7 +120,7 @@ public function setRaw($name, \Phalcon\Di\ServiceInterface $rawDefinition) {} * @param string $name * @return mixed */ - public function getRaw($name) {} + public function getRaw(string $name) {} /** * Returns a Phalcon\Di\Service instance @@ -150,76 +128,118 @@ public function getRaw($name) {} * @param string $name * @return \Phalcon\Di\ServiceInterface */ - public function getService($name) {} + public function getService(string $name): ServiceInterface {} /** - * Resolves the service based on its configuration + * Return the services registered in the DI * - * @param string $name - * @param mixed $parameters - * @return mixed + * @return array|\Phalcon\Di\ServiceInterface[] */ - public function get($name, $parameters = null) {} + public function getServices(): array {} /** * Resolves a service, the resolved service is stored in the DI, subsequent * requests for this service will return the same instance * * @param string $name - * @param array $parameters + * @param mixed $parameters * @return mixed */ - public function getShared($name, $parameters = null) {} + public function getShared(string $name, $parameters = null) {} /** - * Check whether the DI contains a service by a name + * Loads services from a Config object. * - * @param string $name - * @return bool + * @param \Phalcon\Config $config */ - public function has($name) {} + protected function loadFromConfig(\Phalcon\Config $config) {} /** - * Check whether the last service obtained via getShared produced a fresh instance or an existing one + * Loads services from a php config file. * - * @return bool - */ - public function wasFreshInstance() {} - - /** - * Return the services registered in the DI + * ```php + * $di->loadFromPhp("path/services.php"); + * ``` + * + * And the services can be specified in the file as: + * + * ```php + * return [ + * 'myComponent' => [ + * 'className' => '\Acme\Components\MyComponent', + * 'shared' => true, + * ], + * 'group' => [ + * 'className' => '\Acme\Group', + * 'arguments' => [ + * [ + * 'type' => 'service', + * 'service' => 'myComponent', + * ], + * ], + * ], + * 'user' => [ + * 'className' => '\Acme\User', + * ], + * ]; + * ``` * - * @return \Phalcon\Di\Service[] + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath */ - public function getServices() {} + public function loadFromPhp(string $filePath) {} /** - * Check if a service is registered using the array syntax + * Loads services from a yaml file. * - * @param mixed $name - * @return bool + * ```php + * $di->loadFromYaml( + * "path/services.yaml", + * [ + * "!approot" => function ($value) { + * return dirname(__DIR__) . $value; + * } + * ] + * ); + * ``` + * + * And the services can be specified in the file as: + * + * ```php + * myComponent: + * className: \Acme\Components\MyComponent + * shared: true + * + * group: + * className: \Acme\Group + * arguments: + * - type: service + * name: myComponent + * + * user: + * className: \Acme\User + * ``` + * + * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @param string $filePath + * @param array $callbacks */ - public function offsetExists($name) {} + public function loadFromYaml(string $filePath, array $callbacks = null) {} /** - * Allows to register a shared service using the array syntax - * - * - * $di["request"] = new \Phalcon\Http\Request(); - * + * Check whether the DI contains a service by a name * - * @param mixed $name - * @param mixed $definition + * @param string $name * @return bool */ - public function offsetSet($name, $definition) {} + public function has(string $name): bool {} /** * Allows to obtain a shared service using the array syntax * - * + * ```php * var_dump($di["request"]); - * + * ``` * * @param mixed $name * @return mixed @@ -227,57 +247,64 @@ public function offsetSet($name, $definition) {} public function offsetGet($name) {} /** - * Removes a service from the services container using the array syntax + * Check if a service is registered using the array syntax * * @param mixed $name * @return bool */ - public function offsetUnset($name) {} + public function offsetExists($name): bool {} /** - * Magic method to get or set services using setters/getters + * Allows to register a shared service using the array syntax * - * @param string $method - * @param mixed $arguments - * @return mixed|null + * ```php + * $di["request"] = new \Phalcon\Http\Request(); + * ``` + * + * @param mixed $name + * @param mixed $definition */ - public function __call($method, $arguments = null) {} + public function offsetSet($name, $definition) {} + + /** + * Removes a service from the services container using the array syntax + * + * @param mixed $name + */ + public function offsetUnset($name) {} /** * Registers a service provider. * - * - * use Phalcon\DiInterface; + * ```php + * use Phalcon\Di\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared('service', function () { - * // ... - * }); + * $di->setShared( + * 'service', + * function () { + * // ... + * } + * ); * } * } - * + * ``` * * @param \Phalcon\Di\ServiceProviderInterface $provider */ public function register(\Phalcon\Di\ServiceProviderInterface $provider) {} /** - * Set a default dependency injection container to be obtained into static methods - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public static function setDefault(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Return the latest DI created + * Removes a service in the services container + * It also removes any shared instance created for the service * - * @return null|\Phalcon\DiInterface + * @param string $name */ - public static function getDefault() {} + public function remove(string $name) {} /** * Resets the internal default DI @@ -285,82 +312,46 @@ public static function getDefault() {} public static function reset() {} /** - * Loads services from a yaml file. - * - * - * $di->loadFromYaml( - * "path/services.yaml", - * [ - * "!approot" => function ($value) { - * return dirname(__DIR__) . $value; - * } - * ] - * ); - * - * - * And the services can be specified in the file as: - * - * - * myComponent: - * className: \Acme\Components\MyComponent - * shared: true - * - * group: - * className: \Acme\Group - * arguments: - * - type: service - * name: myComponent - * - * user: - * className: \Acme\User - * + * Registers a service in the services container * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath - * @param array $callbacks + * @param string $name + * @param mixed $definition + * @param bool $shared + * @return \Phalcon\Di\ServiceInterface */ - public function loadFromYaml($filePath, array $callbacks = null) {} + public function set(string $name, $definition, bool $shared = false): ServiceInterface {} /** - * Loads services from a php config file. + * Set a default dependency injection container to be obtained into static + * methods * - * - * $di->loadFromPhp("path/services.php"); - * - * - * And the services can be specified in the file as: + * @param \Phalcon\Di\DiInterface $container + */ + public static function setDefault(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets the internal event manager * - * - * return [ - * 'myComponent' => [ - * 'className' => '\Acme\Components\MyComponent', - * 'shared' => true, - * ], - * 'group' => [ - * 'className' => '\Acme\Group', - * 'arguments' => [ - * [ - * 'type' => 'service', - * 'service' => 'myComponent', - * ], - * ], - * ], - * 'user' => [ - * 'className' => '\Acme\User', - * ], - * ]; - * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + + /** + * Sets a service using a raw Phalcon\Di\Service definition * - * @link https://docs.phalconphp.com/en/latest/reference/di.html - * @param string $filePath + * @param string $name + * @param \Phalcon\Di\ServiceInterface $rawDefinition + * @return \Phalcon\Di\ServiceInterface */ - public function loadFromPhp($filePath) {} + public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface {} /** - * Loads services from a Config object. + * Registers an "always shared" service in the services container * - * @param \Phalcon\Config $config + * @param string $name + * @param mixed $definition + * @return \Phalcon\Di\ServiceInterface */ - protected function loadFromConfig(\Phalcon\Config $config) {} + public function setShared(string $name, $definition): ServiceInterface {} } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index 82b6b066..ea0b9e58 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -5,129 +5,137 @@ /** * Phalcon\Escaper * - * Escapes different kinds of text securing them. By using this component you may - * prevent XSS attacks. + * Escapes different kinds of text securing them. By using this component you + * may prevent XSS attacks. * - * This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support. + * This component only works with UTF-8. The PREG extension needs to be compiled + * with UTF-8 support. * - * + * ```php * $escaper = new \Phalcon\Escaper(); * * $escaped = $escaper->escapeCss("font-family: "); * * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E - * + * ``` */ -class Escaper implements \Phalcon\EscaperInterface +class Escaper implements \Phalcon\Escaper\EscaperInterface { + /** + * @var bool + */ + protected $doubleEncode = true; - protected $_encoding = 'utf-8'; - - - protected $_htmlEscapeMap = null; + /** + * @var string + */ + protected $encoding = 'utf-8'; - protected $_htmlQuoteType = 3; + protected $htmlEscapeMap = null; - protected $_doubleEncode = true; + protected $htmlQuoteType = 3; /** - * Sets the encoding to be used by the escaper - * - * - * $escaper->setEncoding("utf-8"); - * + * Detect the character encoding of a string to be handled by an encoder. + * Special-handling for chr(172) and chr(128) to chr(159) which fail to be + * detected by mb_detect_encoding() * - * @param string $encoding + * @param string $str + * @return string|null */ - public function setEncoding($encoding) {} + final public function detectEncoding(string $str): ?string {} /** - * Returns the internal encoding used by the escaper + * Escape CSS strings by replacing non-alphanumeric chars by their + * hexadecimal escaped representation * + * @param string $css * @return string */ - public function getEncoding() {} + public function escapeCss(string $css): string {} /** - * Sets the HTML quoting type for htmlspecialchars + * Escape javascript strings by replacing non-alphanumeric chars by their + * hexadecimal escaped representation * - * - * $escaper->setHtmlQuoteType(ENT_XHTML); - * - * - * @param int $quoteType + * @param string $js + * @return string */ - public function setHtmlQuoteType($quoteType) {} + public function escapeJs(string $js): string {} /** - * Sets the double_encode to be used by the escaper - * - * - * $escaper->setDoubleEncode(false); - * + * Escapes a HTML string. Internally uses htmlspecialchars * - * @param bool $doubleEncode + * @param string $text + * @return string */ - public function setDoubleEncode($doubleEncode) {} + public function escapeHtml(string $text): string {} /** - * Detect the character encoding of a string to be handled by an encoder - * Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding() + * Escapes a HTML attribute string * - * @param string $str - * @return string|null + * @param string $attribute + * @return string */ - public final function detectEncoding($str) {} + public function escapeHtmlAttr(string $attribute): string {} /** - * Utility to normalize a string's encoding to UTF-32. + * Escapes a URL. Internally uses rawurlencode * - * @param string $str + * @param string $url * @return string */ - public final function normalizeEncoding($str) {} + public function escapeUrl(string $url): string {} /** - * Escapes a HTML string. Internally uses htmlspecialchars + * Returns the internal encoding used by the escaper * - * @param string $text * @return string */ - public function escapeHtml($text) {} + public function getEncoding(): string {} /** - * Escapes a HTML attribute string + * Utility to normalize a string's encoding to UTF-32. * - * @param string $attribute + * @param string $str * @return string */ - public function escapeHtmlAttr($attribute) {} + final public function normalizeEncoding(string $str): string {} /** - * Escape CSS strings by replacing non-alphanumeric chars by their hexadecimal escaped representation + * Sets the double_encode to be used by the escaper * - * @param string $css - * @return string + * ```php + * $escaper->setDoubleEncode(false); + * ``` + * + * @param bool $doubleEncode */ - public function escapeCss($css) {} + public function setDoubleEncode(bool $doubleEncode) {} /** - * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation + * Sets the encoding to be used by the escaper * - * @param string $js - * @return string + * ```php + * $escaper->setEncoding("utf-8"); + * ``` + * + * @param string $encoding */ - public function escapeJs($js) {} + public function setEncoding(string $encoding) {} /** - * Escapes a URL. Internally uses rawurlencode + * Sets the HTML quoting type for htmlspecialchars * - * @param string $url - * @return string + * ```php + * $escaper->setHtmlQuoteType(ENT_XHTML); + * ``` + * + * @param int $quoteType */ - public function escapeUrl($url) {} + public function setHtmlQuoteType(int $quoteType) {} } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 95f9e054..1cbf0b74 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -7,7 +7,13 @@ * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception +class Exception extends Exception implements \Throwable { + /** + * @param string $service + * @return string + */ + public static function containerServiceNotFound(string $service): string {} + } diff --git a/src/Phalcon/Factory.php b/src/Phalcon/Factory.php deleted file mode 100644 index ace96d42..00000000 --- a/src/Phalcon/Factory.php +++ /dev/null @@ -1,15 +0,0 @@ - - * $filter = new \Phalcon\Filter(); - * - * $filter->sanitize("some(one)@exa\\mple.com", "email"); // returns "someone@example.com" - * $filter->sanitize("hello<<", "string"); // returns "hello" - * $filter->sanitize("!100a019", "int"); // returns "100019" - * $filter->sanitize("!100a019.01a", "float"); // returns "100019.01" - * - */ -class Filter implements \Phalcon\FilterInterface -{ - - const FILTER_EMAIL = 'email'; - - - const FILTER_ABSINT = 'absint'; - - - const FILTER_INT = 'int'; - - - const FILTER_INT_CAST = 'int!'; - - - const FILTER_STRING = 'string'; - - - const FILTER_FLOAT = 'float'; - - - const FILTER_FLOAT_CAST = 'float!'; - - - const FILTER_ALPHANUM = 'alphanum'; - - - const FILTER_TRIM = 'trim'; - - - const FILTER_STRIPTAGS = 'striptags'; - - - const FILTER_LOWER = 'lower'; - - - const FILTER_UPPER = 'upper'; - - - const FILTER_URL = 'url'; - - - const FILTER_SPECIAL_CHARS = 'special_chars'; - - - protected $_filters; - - - /** - * Adds a user-defined filter - * - * @param string $name - * @param mixed $handler - * @return \Phalcon\FilterInterface - */ - public function add($name, $handler) {} - - /** - * Sanitizes a value with a specified single or set of filters - * - * @param mixed $value - * @param mixed $filters - * @param bool $noRecursive - * @return mixed - */ - public function sanitize($value, $filters, $noRecursive = false) {} - - /** - * Internal sanitize wrapper to filter_var - * - * @param mixed $value - * @param string $filter - */ - protected function _sanitize($value, $filter) {} - - /** - * Return the user-defined filters in the instance - * - * @return array - */ - public function getFilters() {} - -} diff --git a/src/Phalcon/FilterInterface.php b/src/Phalcon/FilterInterface.php deleted file mode 100644 index 6ffc77e2..00000000 --- a/src/Phalcon/FilterInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * $flash->success("The record was successfully deleted"); - * $flash->error("Cannot open the file"); - * - */ -abstract class Flash implements \Phalcon\FlashInterface, \Phalcon\Di\InjectionAwareInterface -{ - - protected $_cssClasses; - - - protected $_implicitFlush = true; - - - protected $_automaticHtml = true; - - - protected $_escaperService = null; - - - protected $_autoescape = true; - - - protected $_dependencyInjector = null; - - - protected $_messages; - - - /** - * Phalcon\Flash constructor - * - * @param mixed $cssClasses - */ - public function __construct($cssClasses = null) {} - - /** - * Returns the autoescape mode in generated html - * - * @return bool - */ - public function getAutoescape() {} - - /** - * Set the autoescape mode in generated html - * - * @param bool $autoescape - * @return Flash - */ - public function setAutoescape($autoescape) {} - - /** - * Returns the Escaper Service - * - * @return EscaperInterface - */ - public function getEscaperService() {} - - /** - * Sets the Escaper Service - * - * @param EscaperInterface $escaperService - * @return Flash - */ - public function setEscaperService(EscaperInterface $escaperService) {} - - /** - * Sets the dependency injector - * - * @param DiInterface $dependencyInjector - * @return Flash - */ - public function setDI(DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector - * - * @return DiInterface - */ - public function getDI() {} - - /** - * Set whether the output must be implicitly flushed to the output or returned as string - * - * @param bool $implicitFlush - * @return FlashInterface - */ - public function setImplicitFlush($implicitFlush) {} - - /** - * Set if the output must be implicitly formatted with HTML - * - * @param bool $automaticHtml - * @return FlashInterface - */ - public function setAutomaticHtml($automaticHtml) {} - - /** - * Set an array with CSS classes to format the messages - * - * @param array $cssClasses - * @return FlashInterface - */ - public function setCssClasses(array $cssClasses) {} - - /** - * Shows a HTML error message - * - * - * $flash->error("This is an error"); - * - * - * @param mixed $message - * @return string - */ - public function error($message) {} - - /** - * Shows a HTML notice/information message - * - * - * $flash->notice("This is an information"); - * - * - * @param mixed $message - * @return string - */ - public function notice($message) {} - - /** - * Shows a HTML success message - * - * - * $flash->success("The process was finished successfully"); - * - * - * @param mixed $message - * @return string - */ - public function success($message) {} - - /** - * Shows a HTML warning message - * - * - * $flash->warning("Hey, this is important"); - * - * - * @param mixed $message - * @return string - */ - public function warning($message) {} - - /** - * Outputs a message formatting it with HTML - * - * - * $flash->outputMessage("error", $message); - * - * - * @param string $type - * @param string|array $message - * @return string|void - */ - public function outputMessage($type, $message) {} - - /** - * Clears accumulated messages when implicit flush is disabled - */ - public function clear() {} - -} diff --git a/src/Phalcon/FlashInterface.php b/src/Phalcon/FlashInterface.php deleted file mode 100644 index 9353fd25..00000000 --- a/src/Phalcon/FlashInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - + * ```php * use Phalcon\Loader; * * // Creates the autoloader @@ -27,144 +26,131 @@ * * // Requiring this class will automatically include file vendor/example/adapter/Some.php * $adapter = new \Example\Adapter\Some(); - * + * ``` */ class Loader implements \Phalcon\Events\EventsAwareInterface { - protected $_eventsManager = null; - - - protected $_foundPath = null; - - - protected $_checkedPath = null; - - - protected $_classes = array(); - - - protected $_extensions = array('php'); + protected $checkedPath = null; + /** + * @var array + */ + protected $classes = array(); - protected $_namespaces = array(); - + /** + * @var array + */ + protected $directories = array(); - protected $_directories = array(); + protected $eventsManager = null; - protected $_files = array(); + /** + * @var array + */ + protected $extensions = array('php'); - protected $_registered = false; + protected $fileCheckingCallback = 'is_file'; + /** + * @var array + */ + protected $files = array(); - protected $fileCheckingCallback = 'is_file'; + /** + * @var bool + */ + protected $foundPath = null; + /** + * @var array + */ + protected $namespaces = array(); /** - * Sets the file check callback. - * - * - * // Default behavior. - * $loader->setFileCheckingCallback("is_file"); - * - * // Faster than `is_file()`, but implies some issues if - * // the file is removed from the filesystem. - * $loader->setFileCheckingCallback("stream_resolve_include_path"); - * - * // Do not check file existence. - * $loader->setFileCheckingCallback(null); - * - * - * @param mixed $callback - * @return Loader + * @var bool */ - public function setFileCheckingCallback($callback = null) {} + protected $registered = false; + /** - * Sets the events manager + * Autoloads the registered classes * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $className + * @return bool */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function autoLoad(string $className): bool {} /** - * Returns the internal event manager + * Get the path the loader is checking for a path * - * @return \Phalcon\Events\ManagerInterface + * @return string */ - public function getEventsManager() {} + public function getCheckedPath(): string {} /** - * Sets an array of file extensions that the loader must try in each attempt to locate the file + * Returns the class-map currently registered in the autoloader * - * @param array $extensions - * @return Loader + * @return array */ - public function setExtensions(array $extensions) {} + public function getClasses(): array {} /** - * Returns the file extensions registered in the loader + * Returns the directories currently registered in the autoloader * * @return array */ - public function getExtensions() {} + public function getDirs(): array {} /** - * Register namespaces and their related directories + * Returns the internal event manager * - * @param array $namespaces - * @param bool $merge - * @return Loader + * @return \Phalcon\Events\ManagerInterface */ - public function registerNamespaces(array $namespaces, $merge = false) {} + public function getEventsManager(): ManagerInterface {} /** - * @param array $namespace + * Returns the file extensions registered in the loader + * * @return array */ - protected function prepareNamespace(array $namespace) {} + public function getExtensions(): array {} /** - * Returns the namespaces currently registered in the autoloader + * Returns the files currently registered in the autoloader * * @return array */ - public function getNamespaces() {} + public function getFiles(): array {} /** - * Register directories in which "not found" classes could be found + * Get the path when a class was found * - * @param array $directories - * @param bool $merge - * @return Loader + * @return string */ - public function registerDirs(array $directories, $merge = false) {} + public function getFoundPath(): string {} /** - * Returns the directories currently registered in the autoloader + * Returns the namespaces currently registered in the autoloader * * @return array */ - public function getDirs() {} + public function getNamespaces(): array {} /** - * Registers files that are "non-classes" hence need a "require". This is very useful for including files that only - * have functions - * - * @param array $files - * @param bool $merge - * @return Loader + * Checks if a file exists and then adds the file by doing virtual require */ - public function registerFiles(array $files, $merge = false) {} + public function loadFiles() {} /** - * Returns the files currently registered in the autoloader + * Register the autoload method * - * @return array + * @param bool $prepend + * @return Loader */ - public function getFiles() {} + public function register(bool $prepend = false): Loader {} /** * Register classes and their locations @@ -173,55 +159,83 @@ public function getFiles() {} * @param bool $merge * @return Loader */ - public function registerClasses(array $classes, $merge = false) {} + public function registerClasses(array $classes, bool $merge = false): Loader {} /** - * Returns the class-map currently registered in the autoloader + * Register directories in which "not found" classes could be found * - * @return array + * @param array $directories + * @param bool $merge + * @return Loader */ - public function getClasses() {} + public function registerDirs(array $directories, bool $merge = false): Loader {} /** - * Register the autoload method + * Registers files that are "non-classes" hence need a "require". This is + * very useful for including files that only have functions * - * @param bool $prepend + * @param array $files + * @param bool $merge * @return Loader */ - public function register($prepend = false) {} + public function registerFiles(array $files, bool $merge = false): Loader {} /** - * Unregister the autoload method + * Register namespaces and their related directories * + * @param array $namespaces + * @param bool $merge * @return Loader */ - public function unregister() {} + public function registerNamespaces(array $namespaces, bool $merge = false): Loader {} /** - * Checks if a file exists and then adds the file by doing virtual require + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function loadFiles() {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Autoloads the registered classes + * Sets an array of file extensions that the loader must try in each attempt + * to locate the file * - * @param string $className - * @return bool + * @param array $extensions + * @return Loader */ - public function autoLoad($className) {} + public function setExtensions(array $extensions): Loader {} /** - * Get the path when a class was found + * Sets the file check callback. * - * @return string + * ```php + * // Default behavior. + * $loader->setFileCheckingCallback("is_file"); + * + * // Faster than `is_file()`, but implies some issues if + * // the file is removed from the filesystem. + * $loader->setFileCheckingCallback("stream_resolve_include_path"); + * + * // Do not check file existence. + * $loader->setFileCheckingCallback(null); + * ``` + * + * @param mixed $callback + * @return Loader */ - public function getFoundPath() {} + public function setFileCheckingCallback($callback = null): Loader {} /** - * Get the path the loader is checking for a path + * Unregister the autoload method * - * @return string + * @return Loader + */ + public function unregister(): Loader {} + + /** + * @param array $namespaceName + * @return array */ - public function getCheckedPath() {} + protected function prepareNamespace(array $namespaceName): array {} } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php deleted file mode 100644 index 332e012a..00000000 --- a/src/Phalcon/Logger.php +++ /dev/null @@ -1,55 +0,0 @@ - - * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); - * $logger->log("This is a message"); - * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - */ -abstract class Logger -{ - - const SPECIAL = 9; - - - const CUSTOM = 8; - - - const DEBUG = 7; - - - const INFO = 6; - - - const NOTICE = 5; - - - const WARNING = 4; - - - const ERROR = 3; - - - const ALERT = 2; - - - const CRITICAL = 1; - - - const EMERGENCE = 0; - - - const EMERGENCY = 0; - - -} diff --git a/src/Phalcon/Plugin.php b/src/Phalcon/Plugin.php index 5689dbdb..ddc7559e 100644 --- a/src/Phalcon/Plugin.php +++ b/src/Phalcon/Plugin.php @@ -3,12 +3,10 @@ namespace Phalcon; /** - * Phalcon\Plugin - * * This class can be used to provide user plugins an easy access to services * in the application */ -class Plugin extends \Phalcon\Di\Injectable +abstract class Plugin extends \Phalcon\Di\Injectable { } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 5f4d660d..c86bd440 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -5,11 +5,11 @@ /** * Phalcon\Registry * - * A registry is a container for storing objects and values in the application space. - * By storing the value in a registry, the same object is always available throughout - * your application. + * A registry is a container for storing objects and values in the application + * space. By storing the value in a registry, the same object is always + * available throughout your application. * - * + * ```php * $registry = new \Phalcon\Registry(); * * // Set value @@ -31,13 +31,13 @@ * unset($registry->something); * // or * unset($registry["something"]); - * + * ``` * * In addition to ArrayAccess, Phalcon\Registry also implements Countable * (count($registry) will return the number of elements in the registry), - * Serializable and Iterator (you can iterate over the registry - * using a foreach loop) interfaces. For PHP 5.4 and higher, JsonSerializable - * interface is implemented. + * Serializable and Iterator (you can iterate over the registry using a foreach + * loop) interfaces. For PHP 5.4 and higher, JsonSerializable interface is + * implemented. * * Phalcon\Registry is very fast (it is typically faster than any userspace * implementation of the registry); however, this comes at a price: @@ -49,112 +49,186 @@ * is several times slower than $registry->property. * * Internally all the magic methods (and interfaces except JsonSerializable) - * are implemented using object handlers or similar techniques: this allows - * to bypass relatively slow method calls. + * are implemented using object handlers or similar techniques: this allows to + * bypass relatively slow method calls. */ -final class Registry implements \ArrayAccess, \Countable, \Iterator +final class Registry extends \Phalcon\Collection { - protected $_data; - - /** - * Registry constructor + * Constructor + * + * @param array $data */ - public final function __construct() {} + final public function __construct(array $data = null) {} /** - * Checks if the element is present in the registry + * Magic getter to get an element from the collection * - * @param mixed $offset - * @return bool + * @param string $element + * @return mixed */ - public final function offsetExists($offset) {} + final public function __get(string $element) {} /** - * Returns an index in the registry + * Magic isset to check whether an element exists or not * - * @param mixed $offset - * @return mixed + * @param string $element + * @return bool */ - public final function offsetGet($offset) {} + final public function __isset(string $element): bool {} /** - * Sets an element in the registry + * Magic setter to assign values to an element * - * @param mixed $offset + * @param string $element * @param mixed $value */ - public final function offsetSet($offset, $value) {} + final public function __set(string $element, $value) {} /** - * Unsets an element in the registry + * Magic unset to remove an element from the collection * - * @param mixed $offset + * @param string $element + */ + final public function __unset(string $element) {} + + /** + * Clears the internal collection */ - public final function offsetUnset($offset) {} + final public function clear() {} /** - * Checks how many elements are in the register + * Count elements of an object * + * @link https://php.net/manual/en/countable.count.php * @return int */ - public final function count() {} + final public function count(): int {} + + /** + * Get the element from the collection + * + * @param string $element + * @param mixed $defaultValue + * @return mixed + */ + final public function get(string $element, $defaultValue = null) {} /** - * Moves cursor to next row in the registry + * Returns the iterator of the class + * + * @return \Traversable */ - public final function next() {} + final public function getIterator(): Traversable {} /** - * Gets pointer number of active row in the registry + * Get the element from the collection * - * @return int + * @param string $element + * @return bool */ - public final function key() {} + final public function has(string $element): bool {} /** - * Rewinds the registry cursor to its beginning + * Initialize internal array + * + * @param array $data + */ + final public function init(array $data = array()) {} + + /** + * Specify data which should be serialized to JSON + * + * @link https://php.net/manual/en/jsonserializable.jsonserialize.php + * @return array */ - public final function rewind() {} + final public function jsonSerialize(): array {} /** - * Checks if the iterator is valid + * Whether a offset exists * + * @link https://php.net/manual/en/arrayaccess.offsetexists.php + * @param mixed $element * @return bool */ - public function valid() {} + final public function offsetExists($element): bool {} + + /** + * Offset to retrieve + * + * @link https://php.net/manual/en/arrayaccess.offsetget.php + * @param mixed $element + * @return mixed + */ + final public function offsetGet($element) {} + + /** + * Offset to set + * + * @link https://php.net/manual/en/arrayaccess.offsetset.php + * @param mixed $element + * @param mixed $value + */ + final public function offsetSet($element, $value) {} + + /** + * Offset to unset + * + * @link https://php.net/manual/en/arrayaccess.offsetunset.php + * @param mixed $element + */ + final public function offsetUnset($element) {} + + /** + * Delete the element from the collection + * + * @param string $element + */ + final public function remove(string $element) {} /** - * Obtains the current value in the internal iterator + * String representation of object + * + * @link https://php.net/manual/en/serializable.serialize.php + * @return string */ - public function current() {} + final public function serialize(): string {} /** - * Sets an element in the registry + * Set an element in the collection * - * @param string $key + * @param string $element * @param mixed $value */ - public final function __set($key, $value) {} + final public function set(string $element, $value) {} /** - * Returns an index in the registry + * Returns the object in an array format * - * @param string $key - * @return mixed + * @return array */ - public final function __get($key) {} + final public function toArray(): array {} /** - * @param string $key - * @return bool + * Returns the object in a JSON format + * + * The default string uses the following options for json_encode + * + * JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES + * + * @see https://www.ietf.org/rfc/rfc4627.txt + * @param int $options + * @return string */ - public final function __isset($key) {} + final public function toJson(int $options = 79): string {} /** - * @param string $key + * Constructs the object + * + * @link https://php.net/manual/en/serializable.unserialize.php + * @param mixed $serialized */ - public final function __unset($key) {} + final public function unserialize($serialized) {} } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 03661177..8a79b6be 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -3,11 +3,10 @@ namespace Phalcon; /** - * Phalcon\Security + * This component provides a set of functions to improve the security in Phalcon + * applications * - * This component provides a set of functions to improve the security in Phalcon applications - * - * + * ```php * $login = $this->request->getPost("login"); * $password = $this->request->getPost("password"); * @@ -18,7 +17,7 @@ * // The password is valid * } * } - * + * ``` */ class Security implements \Phalcon\Di\InjectionAwareInterface { @@ -26,15 +25,6 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_DEFAULT = 0; - const CRYPT_STD_DES = 1; - - - const CRYPT_EXT_DES = 2; - - - const CRYPT_MD5 = 3; - - const CRYPT_BLOWFISH = 4; @@ -47,37 +37,49 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_BLOWFISH_Y = 7; + const CRYPT_EXT_DES = 2; + + + const CRYPT_MD5 = 3; + + const CRYPT_SHA256 = 8; const CRYPT_SHA512 = 9; - protected $_dependencyInjector; + const CRYPT_STD_DES = 1; + + + protected $container; - protected $_workFactor = 8; + protected $defaultHash; - protected $_numberBytes = 16; + protected $numberBytes = 16; - protected $_tokenKeySessionID = '$PHALCON/CSRF/KEY$'; + protected $random; - protected $_tokenValueSessionID = '$PHALCON/CSRF$'; + protected $requestToken; - protected $_token; + protected $token; - protected $_tokenKey; + protected $tokenKey; - protected $_random; + protected $tokenKeySessionId = '$PHALCON/CSRF/KEY$'; - protected $_defaultHash; + protected $tokenValueSessionId = '$PHALCON/CSRF$'; + + + protected $workFactor = 8; /** @@ -94,124 +96,129 @@ public function getWorkFactor() {} public function __construct() {} /** - * Sets the dependency injector + * Checks a plain text password and its hash version to check if the + * password matches * - * @param \Phalcon\DiInterface $dependencyInjector + * @param string $password + * @param string $passwordHash + * @param int $maxPassLength + * @return bool */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool {} /** - * Returns the internal dependency injector + * Check if the CSRF token sent in the request is the same that the current + * in session * - * @return \Phalcon\DiInterface + * @param mixed $tokenKey + * @param mixed $tokenValue + * @param bool $destroyIfValid + * @return bool */ - public function getDI() {} + public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool {} /** - * Sets a number of bytes to be generated by the openssl pseudo random generator + * Computes a HMAC * - * @param long $randomBytes - * @return Security + * @param string $data + * @param string $key + * @param string $algo + * @param bool $raw + * @return string */ - public function setRandomBytes($randomBytes) {} + public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string {} /** - * Returns a number of bytes to be generated by the openssl pseudo random generator + * Removes the value of the CSRF token and key from session * - * @return string + * @return Security */ - public function getRandomBytes() {} + public function destroyToken(): Security {} /** - * Returns a secure random number generator instance + * Returns the default hash * - * @return \Phalcon\Security\Random + * @return int|null */ - public function getRandom() {} + public function getDefaultHash(): ?int {} /** - * Generate a >22-length pseudo random string to be used as salt for passwords + * Returns the internal dependency injector * - * @param int $numberBytes - * @return string + * @return \Phalcon\Di\DiInterface */ - public function getSaltBytes($numberBytes = 0) {} + public function getDI(): DiInterface {} /** - * Creates a password hash using bcrypt with a pseudo random salt + * Returns a secure random number generator instance * - * @param string $password - * @param int $workFactor - * @return string + * @return \Phalcon\Security\Random */ - public function hash($password, $workFactor = 0) {} + public function getRandom(): Random {} /** - * Checks a plain text password and its hash version to check if the password matches + * Returns a number of bytes to be generated by the openssl pseudo random + * generator * - * @param string $password - * @param string $passwordHash - * @param int $maxPassLength - * @return bool + * @return string */ - public function checkHash($password, $passwordHash, $maxPassLength = 0) {} + public function getRandomBytes(): string {} /** - * Checks if a password hash is a valid bcrypt's hash + * Returns the value of the CSRF token for the current request. * - * @param string $passwordHash - * @return bool + * @return string */ - public function isLegacyHash($passwordHash) {} + public function getRequestToken(): string {} /** - * Generates a pseudo random token key to be used as input's name in a CSRF check + * Returns the value of the CSRF token in session * * @return string */ - public function getTokenKey() {} + public function getSessionToken(): string {} /** - * Generates a pseudo random token value to be used as input's value in a CSRF check + * Generate a >22-length pseudo random string to be used as salt for + * passwords * + * @param int $numberBytes * @return string */ - public function getToken() {} + public function getSaltBytes(int $numberBytes = 0): string {} /** - * Check if the CSRF token sent in the request is the same that the current in session + * Generates a pseudo random token value to be used as input's value in a + * CSRF check * - * @param mixed $tokenKey - * @param mixed $tokenValue - * @param bool $destroyIfValid - * @return bool + * @return string */ - public function checkToken($tokenKey = null, $tokenValue = null, $destroyIfValid = true) {} + public function getToken(): string {} /** - * Returns the value of the CSRF token in session + * Generates a pseudo random token key to be used as input's name in a CSRF + * check * * @return string */ - public function getSessionToken() {} + public function getTokenKey(): string {} /** - * Removes the value of the CSRF token and key from session + * Creates a password hash using bcrypt with a pseudo random salt * - * @return Security + * @param string $password + * @param int $workFactor + * @return string */ - public function destroyToken() {} + public function hash(string $password, int $workFactor = 0): string {} /** - * Computes a HMAC + * Checks if a password hash is a valid bcrypt's hash * - * @param string $data - * @param string $key - * @param string $algo - * @param bool $raw - * @return string + * @param string $passwordHash + * @return bool */ - public function computeHmac($data, $key, $algo, $raw = false) {} + public function isLegacyHash(string $passwordHash): bool {} /** * Sets the default hash @@ -219,39 +226,22 @@ public function computeHmac($data, $key, $algo, $raw = false) {} * @param int $defaultHash * @return Security */ - public function setDefaultHash($defaultHash) {} + public function setDefaultHash(int $defaultHash): Security {} /** - * Returns the default hash - * - * @return int|null - */ - public function getDefaultHash() {} - - /** - * Testing for LibreSSL + * Sets the dependency injector * - * @deprecated Will be removed in 4.0.0 - * @return bool + * @param \Phalcon\Di\DiInterface $container */ - public function hasLibreSsl() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Getting OpenSSL or LibreSSL version. - * - * Parse OPENSSL_VERSION_TEXT because OPENSSL_VERSION_NUMBER is no use for LibreSSL. - * This constant show not the current system openssl library version but version PHP was compiled with. + * Sets a number of bytes to be generated by the openssl pseudo random + * generator * - * @deprecated Will be removed in 4.0.0 - * @link https://bugs.php.net/bug.php?id=71143 - * - * - * if ($security->getSslVersionNumber() >= 20105) { - * // ... - * } - * - * @return int + * @param long $randomBytes + * @return Security */ - public function getSslVersionNumber() {} + public function setRandomBytes(int $randomBytes): Security {} } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index cc253c01..75c84096 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Tag - * * Phalcon\Tag is designed to simplify building of HTML tags. * It provides a set of helpers to generate HTML in a dynamic way. - * This component is an abstract class that you can extend to add more helpers. + * This component is a class that you can extend to add more helpers. */ class Tag { @@ -44,539 +42,570 @@ class Tag const XHTML5 = 11; + + static protected $autoEscape = true; + /** - * Pre-assigned values for components + * Framework Dispatcher */ - static protected $_displayValues; + static protected $container; /** - * HTML document title + * Pre-assigned values for components */ - static protected $_documentTitle = null; + static protected $displayValues; - static protected $_documentAppendTitle = null; + static protected $dispatcherService = null; - static protected $_documentPrependTitle = null; + static protected $documentAppendTitle = null; - static protected $_documentTitleSeparator = null; - - - static protected $_documentType = 11; + static protected $documentPrependTitle = null; /** - * Framework Dispatcher + * HTML document title */ - static protected $_dependencyInjector; + static protected $documentTitle = null; - static protected $_urlService = null; + static protected $documentTitleSeparator = null; - static protected $_dispatcherService = null; + static protected $documentType = 11; - static protected $_escaperService = null; + static protected $escaperService = null; - static protected $_autoEscape = true; + static protected $urlService = null; /** - * Obtains the 'escaper' service if required + * Appends a text to current document title * - * @param array $params - * @return EscaperInterface + * @param mixed $title */ - public static function getEscaper(array $params) {} + public static function appendTitle($title) {} /** - * Renders parameters keeping order in their HTML attributes + * Builds a HTML input[type="check"] tag * - * @param string $code - * @param array $attributes + * ```php + * echo Phalcon\Tag::checkField( + * [ + * "terms", + * "value" => "Y", + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {{ check_field("terms") }} + * ``` + * + * @param array $parameters * @return string */ - public static function renderAttributes($code, array $attributes) {} + public static function checkField($parameters): string {} /** - * Sets the dependency injector container. + * Builds a HTML input[type="color"] tag * - * @param DiInterface $dependencyInjector + * @param array $parameters + * @return string */ - public static function setDI(DiInterface $dependencyInjector) {} + public static function colorField($parameters): string {} /** - * Internally gets the request dispatcher + * Builds a HTML input[type="date"] tag * - * @return DiInterface + * ```php + * echo Phalcon\Tag::dateField( + * [ + * "born", + * "value" => "14-12-1980", + * ] + * ); + * ``` + * + * @param array $parameters + * @return string */ - public static function getDI() {} + public static function dateField($parameters): string {} /** - * Returns a URL service from the default DI + * Builds a HTML input[type="datetime"] tag * - * @return \Phalcon\Mvc\UrlInterface + * @param array $parameters + * @return string */ - public static function getUrlService() {} + public static function dateTimeField($parameters): string {} /** - * Returns an Escaper service from the default DI + * Builds a HTML input[type="datetime-local"] tag * - * @return EscaperInterface + * @param array $parameters + * @return string */ - public static function getEscaperService() {} + public static function dateTimeLocalField($parameters): string {} /** - * Set autoescape mode in generated html + * Alias of Phalcon\Tag::setDefault() * - * @param bool $autoescape + * @param string $id + * @param string $value */ - public static function setAutoescape($autoescape) {} + public static function displayTo(string $id, $value) {} /** - * Assigns default values to generated tags by helpers + * Builds a HTML input[type="email"] tag * - * - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefault("name", "peter"); + * ```php + * echo Phalcon\Tag::emailField("email"); + * ``` * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * + * @param array $parameters + * @return string + */ + public static function emailField($parameters): string {} + + /** + * Builds a HTML close FORM tag * - * @param string $id - * @param string $value + * @return string */ - public static function setDefault($id, $value) {} + public static function endForm(): string {} /** - * Assigns default values to generated tags by helpers + * Builds a HTML input[type="file"] tag * - * - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefaults( + * ```php + * echo Phalcon\Tag::fileField("file"); + * ``` + * + * @param array $parameters + * @return string + */ + public static function fileField($parameters): string {} + + /** + * Builds a HTML FORM tag + * + * ```php + * echo Phalcon\Tag::form("posts/save"); + * + * echo Phalcon\Tag::form( * [ - * "name" => "peter", + * "posts/save", + * "method" => "post", * ] * ); + * ``` * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * + * Volt syntax: + * ```php + * {{ form("posts/save") }} + * {{ form("posts/save", "method": "post") }} + * ``` * - * @param array $values - * @param bool $merge + * @param array $parameters + * @return string */ - public static function setDefaults(array $values, $merge = false) {} + public static function form($parameters): string {} /** - * Alias of Phalcon\Tag::setDefault + * Converts texts into URL-friendly titles * - * @param string $id - * @param string $value + * ```php + * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") + * ``` + * + * @param string $text + * @param string $separator + * @param bool $lowercase + * @param mixed $replace + * @return string */ - public static function displayTo($id, $value) {} + public static function friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string {} /** - * Check if a helper has a default value set using Phalcon\Tag::setDefault or value from $_POST + * Get the document type declaration of content * - * @param string $name - * @return bool + * @return string */ - public static function hasValue($name) {} + public static function getDocType(): string {} /** - * Every helper calls this function to check whether a component has a predefined - * value using Phalcon\Tag::setDefault or value from $_POST + * Obtains the 'escaper' service if required * - * @param string $name * @param array $params - * @return mixed + * @return null|\Phalcon\Escaper\EscaperInterface */ - public static function getValue($name, $params = null) {} + public static function getEscaper(array $params): ?EscaperInterface {} /** - * Resets the request and internal values to avoid those fields will have any default value. + * Internally gets the request dispatcher * - * @deprecated Will be removed in 4.0.0 - * @deprecated + * @return \Phalcon\Di\DiInterface */ - public static function resetInput() {} + public static function getDI(): DiInterface {} /** - * Builds a HTML A tag using framework conventions - * - * - * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); + * Returns an Escaper service from the default DI * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!" - * ] - * ); + * @return \Phalcon\Escaper\EscaperInterface + */ + public static function getEscaperService(): EscaperInterface {} + + /** + * Gets the current document title. + * The title will be automatically escaped. * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!", - * "class" => "btn-primary", - * ] - * ); + * ```php + * Tag::prependTitle('Hello'); + * Tag::setTitle('World'); + * Tag::appendTitle('from Phalcon'); * - * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); + * echo Tag::getTitle(); // Hello World from Phalcon + * echo Tag::getTitle(false); // World from Phalcon + * echo Tag::getTitle(true, false); // Hello World + * echo Tag::getTitle(false, false); // World + * ``` * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * false, - * ] - * ); + * ```php + * {{ get_title() }} + * ``` * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * "local" => false, - * ] - * ); + * @param bool $prepend + * @param bool $append + * @return string + */ + public static function getTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Gets the current document title separator * - * echo Phalcon\Tag::linkTo( - * [ - * "action" => "http://phalconphp.com/", - * "text" => "Phalcon Home", - * "local" => false, - * "target" => "_new" - * ] - * ); + * ```php + * echo Phalcon\Tag::getTitleSeparator(); + * ``` * - * + * ```php + * {{ get_title_separator() }} + * ``` * - * @param array|string $parameters - * @param string $text - * @param boolean $local * @return string */ - public static function linkTo($parameters, $text = null, $local = true) {} + public static function getTitleSeparator(): string {} /** - * Builds generic INPUT tags + * Returns a URL service from the default DI * - * @param string $type - * @param array $parameters - * @param boolean $asValue - * @return string + * @return \Phalcon\Url\UrlInterface */ - static protected final function _inputField($type, $parameters, $asValue = false) {} + public static function getUrlService(): UrlInterface {} /** - * Builds INPUT tags that implements the checked attribute + * Every helper calls this function to check whether a component has a + * predefined value using Phalcon\Tag::setDefault() or value from $_POST * - * @param string $type - * @param array $parameters - * @return string + * @param string $name + * @param array $params + * @return mixed */ - static protected final function _inputFieldChecked($type, $parameters) {} + public static function getValue($name, array $params = array()) {} /** - * Builds a HTML input[type="color"] tag + * Check if a helper has a default value set using Phalcon\Tag::setDefault() + * or value from $_POST * - * @param array $parameters - * @return string + * @param string $name + * @return bool */ - public static function colorField($parameters) {} + public static function hasValue($name): bool {} /** - * Builds a HTML input[type="text"] tag + * Builds a HTML input[type="hidden"] tag * - * - * echo Phalcon\Tag::textField( + * ```php + * echo Phalcon\Tag::hiddenField( * [ * "name", - * "size" => 30, + * "value" => "mike", * ] * ); - * + * ``` * * @param array $parameters * @return string */ - public static function textField($parameters) {} + public static function hiddenField($parameters): string {} /** - * Builds a HTML input[type="number"] tag + * Builds HTML IMG tags * - * - * echo Phalcon\Tag::numericField( + * ```php + * echo Phalcon\Tag::image("img/bg.png"); + * + * echo Phalcon\Tag::image( * [ - * "price", - * "min" => "1", - * "max" => "5", + * "img/photo.jpg", + * "alt" => "Some Photo", * ] * ); - * - * - * @param array $parameters - * @return string - */ - public static function numericField($parameters) {} - - /** - * Builds a HTML input[type="range"] tag - * - * @param array $parameters - * @return string - */ - public static function rangeField($parameters) {} - - /** - * Builds a HTML input[type="email"] tag + * ``` * - * - * echo Phalcon\Tag::emailField("email"); - * + * Volt Syntax: + * ```php + * {{ image("img/bg.png") }} + * {{ image("img/photo.jpg", "alt": "Some Photo") }} + * {{ image("http://static.mywebsite.com/img/bg.png", false) }} + * ``` * * @param array $parameters + * @param bool $local * @return string */ - public static function emailField($parameters) {} + public static function image($parameters = null, bool $local = true): string {} /** - * Builds a HTML input[type="date"] tag + * Builds a HTML input[type="image"] tag * - * - * echo Phalcon\Tag::dateField( + * ```php + * echo Phalcon\Tag::imageInput( * [ - * "born", - * "value" => "14-12-1980", + * "src" => "/img/button.png", * ] * ); - * + * ``` * - * @param array $parameters - * @return string - */ - public static function dateField($parameters) {} - - /** - * Builds a HTML input[type="datetime"] tag + * Volt syntax: + * ```php + * {{ image_input("src": "/img/button.png") }} + * ``` * * @param array $parameters * @return string */ - public static function dateTimeField($parameters) {} + public static function imageInput($parameters): string {} /** - * Builds a HTML input[type="datetime-local"] tag + * Builds a SCRIPT[type="javascript"] tag * - * @param array $parameters - * @return string - */ - public static function dateTimeLocalField($parameters) {} - - /** - * Builds a HTML input[type="month"] tag + * ```php + * echo Phalcon\Tag::javascriptInclude( + * "http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", + * false + * ); * - * @param array $parameters - * @return string - */ - public static function monthField($parameters) {} - - /** - * Builds a HTML input[type="time"] tag + * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); + * ``` * - * @param array $parameters - * @return string - */ - public static function timeField($parameters) {} - - /** - * Builds a HTML input[type="week"] tag + * Volt syntax: + * ```php + * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} + * {{ javascript_include("javascript/jquery.js") }} + * ``` * * @param array $parameters + * @param bool $local * @return string */ - public static function weekField($parameters) {} + public static function javascriptInclude($parameters = null, bool $local = true): string {} /** - * Builds a HTML input[type="password"] tag + * Builds a HTML A tag using framework conventions * - * - * echo Phalcon\Tag::passwordField( + * ```php + * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); + * + * echo Phalcon\Tag::linkTo( * [ - * "name", - * "size" => 30, + * "signup/register", + * "Register Here!" * ] * ); - * * - * @param array $parameters - * @return string - */ - public static function passwordField($parameters) {} - - /** - * Builds a HTML input[type="hidden"] tag + * echo Phalcon\Tag::linkTo( + * [ + * "signup/register", + * "Register Here!", + * "class" => "btn-primary", + * ] + * ); * - * - * echo Phalcon\Tag::hiddenField( + * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); + * + * echo Phalcon\Tag::linkTo( * [ - * "name", - * "value" => "mike", + * "http://phalconphp.com/", + * "Phalcon Home", + * false, * ] * ); - * * - * @param array $parameters - * @return string - */ - public static function hiddenField($parameters) {} - - /** - * Builds a HTML input[type="file"] tag + * echo Phalcon\Tag::linkTo( + * [ + * "http://phalconphp.com/", + * "Phalcon Home", + * "local" => false, + * ] + * ); + * + * echo Phalcon\Tag::linkTo( + * [ + * "action" => "http://phalconphp.com/", + * "text" => "Phalcon Home", + * "local" => false, + * "target" => "_new" + * ] + * ); * - * - * echo Phalcon\Tag::fileField("file"); - * + * ``` * - * @param array $parameters + * @param array|string $parameters + * @param string $text + * @param bool $local * @return string */ - public static function fileField($parameters) {} + public static function linkTo($parameters, $text = null, $local = true): string {} /** - * Builds a HTML input[type="search"] tag + * Builds a HTML input[type="month"] tag * * @param array $parameters * @return string */ - public static function searchField($parameters) {} + public static function monthField($parameters): string {} /** - * Builds a HTML input[type="tel"] tag + * Builds a HTML input[type="number"] tag * - * @param array $parameters - * @return string - */ - public static function telField($parameters) {} - - /** - * Builds a HTML input[type="url"] tag + * ```php + * echo Phalcon\Tag::numericField( + * [ + * "price", + * "min" => "1", + * "max" => "5", + * ] + * ); + * ``` * * @param array $parameters * @return string */ - public static function urlField($parameters) {} + public static function numericField($parameters): string {} /** - * Builds a HTML input[type="check"] tag + * Builds a HTML input[type="password"] tag * - * - * echo Phalcon\Tag::checkField( + * ```php + * echo Phalcon\Tag::passwordField( * [ - * "terms", - * "value" => "Y", + * "name", + * "size" => 30, * ] * ); - * - * - * Volt syntax: - * - * {{ check_field("terms") }} - * + * ``` * * @param array $parameters * @return string */ - public static function checkField($parameters) {} + public static function passwordField($parameters): string {} + + /** + * Prepends a text to current document title + * + * @param mixed $title + */ + public static function prependTitle($title) {} /** * Builds a HTML input[type="radio"] tag * - * + * ```php * echo Phalcon\Tag::radioField( * [ * "weather", * "value" => "hot", * ] * ); - * + * ``` * * Volt syntax: - * + * ```php * {{ radio_field("Save") }} - * + * ``` * * @param array $parameters * @return string */ - public static function radioField($parameters) {} + public static function radioField($parameters): string {} /** - * Builds a HTML input[type="image"] tag - * - * - * echo Phalcon\Tag::imageInput( - * [ - * "src" => "/img/button.png", - * ] - * ); - * - * - * Volt syntax: - * - * {{ image_input("src": "/img/button.png") }} - * + * Builds a HTML input[type="range"] tag * * @param array $parameters * @return string */ - public static function imageInput($parameters) {} + public static function rangeField($parameters): string {} /** - * Builds a HTML input[type="submit"] tag + * Renders parameters keeping order in their HTML attributes * - * - * echo Phalcon\Tag::submitButton("Save") - * + * @param string $code + * @param array $attributes + * @return string + */ + public static function renderAttributes(string $code, array $attributes): string {} + + /** + * Renders the title with title tags. The title is automaticall escaped * - * Volt syntax: - * - * {{ submit_button("Save") }} - * + * ```php + * Tag::prependTitle('Hello'); + * Tag::setTitle('World'); + * Tag::appendTitle('from Phalcon'); * - * @param array $parameters + * echo Tag::renderTitle(); // Hello World from Phalcon + * echo Tag::renderTitle(false); // World from Phalcon + * echo Tag::renderTitle(true, false); // Hello World + * echo Tag::renderTitle(false, false); // World + * ``` + * + * ```php + * {{ render_title() }} + * ``` + * + * @param bool $prepend + * @param bool $append * @return string */ - public static function submitButton($parameters) {} + public static function renderTitle(bool $prepend = true, bool $append = true): string {} /** - * Builds a HTML SELECT tag using a PHP array for options + * Resets the request and internal values to avoid those fields will have + * any default value. * - * - * echo Phalcon\Tag::selectStatic( - * "status", - * [ - * "A" => "Active", - * "I" => "Inactive", - * ] - * ); - * + * @deprecated Will be removed in 4.0.0 + * @deprecated + */ + public static function resetInput() {} + + /** + * Builds a HTML input[type="search"] tag * * @param array $parameters - * @param array $data * @return string */ - public static function selectStatic($parameters, $data = null) {} + public static function searchField($parameters): string {} /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * - * + * ```php * echo Phalcon\Tag::select( * [ * "robotId", @@ -584,261 +613,272 @@ public static function selectStatic($parameters, $data = null) {} * "using" => ["id", "name"], * ] * ); - * + * ``` * * Volt syntax: - * + * ```php * {{ select("robotId", robots, "using": ["id", "name"]) }} - * + * ``` * * @param array $parameters * @param array $data * @return string */ - public static function select($parameters, $data = null) {} + public static function select($parameters, $data = null): string {} /** - * Builds a HTML TEXTAREA tag + * Builds a HTML SELECT tag using a PHP array for options * - * - * echo Phalcon\Tag::textArea( + * ```php + * echo Phalcon\Tag::selectStatic( + * "status", * [ - * "comments", - * "cols" => 10, - * "rows" => 4, + * "A" => "Active", + * "I" => "Inactive", * ] * ); - * - * - * Volt syntax: - * - * {{ text_area("comments", "cols": 10, "rows": 4) }} - * + * ``` * * @param array $parameters + * @param array $data * @return string */ - public static function textArea($parameters) {} + public static function selectStatic($parameters, $data = null): string {} /** - * Builds a HTML FORM tag + * Set autoescape mode in generated html * - * - * echo Phalcon\Tag::form("posts/save"); + * @param bool $autoescape + */ + public static function setAutoescape(bool $autoescape) {} + + /** + * Assigns default values to generated tags by helpers * - * echo Phalcon\Tag::form( + * ```php + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefault("name", "peter"); + * + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * ``` + * + * @param string $id + * @param string $value + */ + public static function setDefault(string $id, $value) {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * // Assigning "peter" to "name" component + * Phalcon\Tag::setDefaults( * [ - * "posts/save", - * "method" => "post", + * "name" => "peter", * ] * ); - * * - * Volt syntax: - * - * {{ form("posts/save") }} - * {{ form("posts/save", "method": "post") }} - * + * // Later in the view + * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default + * ``` * - * @param array $parameters - * @return string + * @param array $values + * @param bool $merge */ - public static function form($parameters) {} + public static function setDefaults(array $values, bool $merge = false) {} /** - * Builds a HTML close FORM tag + * Sets the dependency injector container. * - * @return string + * @param \Phalcon\Di\DiInterface $container */ - public static function endForm() {} + public static function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the document type of content + * + * @param int $doctype + */ + public static function setDocType(int $doctype) {} /** * Set the title of view content * - * + * ```php * Phalcon\Tag::setTitle("Welcome to my Page"); - * + * ``` * * @param string $title */ - public static function setTitle($title) {} + public static function setTitle(string $title) {} /** * Set the title separator of view content * - * + * ```php * Phalcon\Tag::setTitleSeparator("-"); - * + * ``` * * @param string $titleSeparator */ - public static function setTitleSeparator($titleSeparator) {} + public static function setTitleSeparator(string $titleSeparator) {} /** - * Appends a text to current document title + * Builds a LINK[rel="stylesheet"] tag * - * @param mixed $title - */ - public static function appendTitle($title) {} - - /** - * Prepends a text to current document title + * ```php + * echo Phalcon\Tag::stylesheetLink( + * "http://fonts.googleapis.com/css?family=Rosario", + * false + * ); * - * @param mixed $title + * echo Phalcon\Tag::stylesheetLink("css/style.css"); + * ``` + * + * Volt Syntax: + * ```php + * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} + * {{ stylesheet_link("css/style.css") }} + * ``` + * + * @param array $parameters + * @param bool $local + * @return string */ - public static function prependTitle($title) {} + public static function stylesheetLink($parameters = null, bool $local = true): string {} /** - * Gets the current document title. - * The title will be automatically escaped. + * Builds a HTML input[type="submit"] tag * - * - * echo Phalcon\Tag::getTitle(); - * + * ```php + * echo Phalcon\Tag::submitButton("Save") + * ``` * - * - * {{ get_title() }} - * + * Volt syntax: + * ```php + * {{ submit_button("Save") }} + * ``` * - * @param bool $tags + * @param array $parameters * @return string */ - public static function getTitle($tags = true) {} + public static function submitButton($parameters): string {} /** - * Gets the current document title separator - * - * - * echo Phalcon\Tag::getTitleSeparator(); - * - * - * - * {{ get_title_separator() }} - * + * Builds a HTML tag * + * @param string $tagName + * @param mixed $parameters + * @param bool $selfClose + * @param bool $onlyStart + * @param bool $useEol * @return string */ - public static function getTitleSeparator() {} + public static function tagHtml(string $tagName, $parameters = null, bool $selfClose = false, bool $onlyStart = false, bool $useEol = false): string {} /** - * Builds a LINK[rel="stylesheet"] tag + * Builds a HTML tag closing tag * - * - * echo Phalcon\Tag::stylesheetLink("http://fonts.googleapis.com/css?family=Rosario", false); - * echo Phalcon\Tag::stylesheetLink("css/style.css"); - * + * ```php + * echo Phalcon\Tag::tagHtmlClose("script", true); + * ``` * - * Volt Syntax: - * - * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} - * {{ stylesheet_link("css/style.css") }} - * + * @param string $tagName + * @param bool $useEol + * @return string + */ + public static function tagHtmlClose(string $tagName, bool $useEol = false): string {} + + /** + * Builds a HTML input[type="tel"] tag * * @param array $parameters - * @param boolean $local * @return string */ - public static function stylesheetLink($parameters = null, $local = true) {} + public static function telField($parameters): string {} /** - * Builds a SCRIPT[type="javascript"] tag + * Builds a HTML TEXTAREA tag * - * - * echo Phalcon\Tag::javascriptInclude("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false); - * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); - * + * ```php + * echo Phalcon\Tag::textArea( + * [ + * "comments", + * "cols" => 10, + * "rows" => 4, + * ] + * ); + * ``` * * Volt syntax: - * - * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} - * {{ javascript_include("javascript/jquery.js") }} - * + * ```php + * {{ text_area("comments", "cols": 10, "rows": 4) }} + * ``` * * @param array $parameters - * @param boolean $local * @return string */ - public static function javascriptInclude($parameters = null, $local = true) {} + public static function textArea($parameters): string {} /** - * Builds HTML IMG tags - * - * - * echo Phalcon\Tag::image("img/bg.png"); + * Builds a HTML input[type="text"] tag * - * echo Phalcon\Tag::image( + * ```php + * echo Phalcon\Tag::textField( * [ - * "img/photo.jpg", - * "alt" => "Some Photo", + * "name", + * "size" => 30, * ] * ); - * - * - * Volt Syntax: - * - * {{ image("img/bg.png") }} - * {{ image("img/photo.jpg", "alt": "Some Photo") }} - * {{ image("http://static.mywebsite.com/img/bg.png", false) }} - * + * ``` * * @param array $parameters - * @param boolean $local * @return string */ - public static function image($parameters = null, $local = true) {} + public static function textField($parameters): string {} /** - * Converts texts into URL-friendly titles - * - * - * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") - * + * Builds a HTML input[type="time"] tag * - * @param string $text - * @param string $separator - * @param bool $lowercase - * @param mixed $replace + * @param array $parameters * @return string */ - public static function friendlyTitle($text, $separator = '-', $lowercase = true, $replace = null) {} + public static function timeField($parameters): string {} /** - * Set the document type of content + * Builds a HTML input[type="url"] tag * - * @param int $doctype + * @param array $parameters + * @return string */ - public static function setDocType($doctype) {} + public static function urlField($parameters): string {} /** - * Get the document type declaration of content + * Builds a HTML input[type="week"] tag * + * @param array $parameters * @return string */ - public static function getDocType() {} + public static function weekField($parameters): string {} /** - * Builds a HTML tag + * Builds generic INPUT tags * - * @param string $tagName - * @param mixed $parameters - * @param bool $selfClose - * @param bool $onlyStart - * @param bool $useEol + * @param string $type + * @param array $parameters + * @param bool $asValue * @return string */ - public static function tagHtml($tagName, $parameters = null, $selfClose = false, $onlyStart = false, $useEol = false) {} + static final protected function inputField(string $type, $parameters, bool $asValue = false): string {} /** - * Builds a HTML tag closing tag - * - * - * echo Phalcon\Tag::tagHtmlClose("script", true); - * + * Builds INPUT tags that implements the checked attribute * - * @param string $tagName - * @param bool $useEol + * @param string $type + * @param array $parameters * @return string */ - public static function tagHtmlClose($tagName, $useEol = false) {} + static final protected function inputFieldChecked(string $type, $parameters): string {} } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 70eb7d2c..14589c93 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -3,11 +3,9 @@ namespace Phalcon; /** - * Phalcon\Text - * * Provides utilities to work with texts */ -abstract class Text +class Text { const RANDOM_ALNUM = 0; @@ -16,221 +14,233 @@ abstract class Text const RANDOM_ALPHA = 1; - const RANDOM_HEXDEC = 2; + const RANDOM_DISTINCT = 5; - const RANDOM_NUMERIC = 3; + const RANDOM_HEXDEC = 2; const RANDOM_NOZERO = 4; - const RANDOM_DISTINCT = 5; + const RANDOM_NUMERIC = 3; /** * Converts strings to camelize style * - * + * ```php * echo Phalcon\Text::camelize("coco_bongo"); // CocoBongo * echo Phalcon\Text::camelize("co_co-bon_go", "-"); // Co_coBon_go * echo Phalcon\Text::camelize("co_co-bon_go", "_-"); // CoCoBonGo - * + * ``` * - * @param string $str + * @param string $text * @param mixed $delimiter * @return string */ - public static function camelize($str, $delimiter = null) {} + public static function camelize(string $text, $delimiter = null): string {} /** - * Uncamelize strings which are camelized + * Concatenates strings using the separator only once without duplication in + * places concatenation * - * - * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo - * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo - * - * - * @param string $str - * @param mixed $delimiter - * @return string - */ - public static function uncamelize($str, $delimiter = null) {} - - /** - * Adds a number to a string or increment that number if it already is defined + * ```php + * $str = Phalcon\Text::concat( + * "/", + * "/tmp/", + * "/folder_1/", + * "/folder_2", + * "folder_3/" + * ); * - * - * echo Phalcon\Text::increment("a"); // "a_1" - * echo Phalcon\Text::increment("a_1"); // "a_2" - * + * // /tmp/folder_1/folder_2/folder_3/ + * echo $str; + * ``` * - * @param string $str * @param string $separator + * @param string $a + * @param string $b + * @param string $...N * @return string */ - public static function increment($str, $separator = '_') {} + public static function concat(): string {} /** - * Generates a random string based on the given type. Type is one of the RANDOM_ constants + * Generates random text in accordance with the template * - * - * use Phalcon\Text; + * ```php + * // Hi my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * // "aloiwkqz" - * echo Text::random(Text::RANDOM_ALNUM); - * + * // Hi my name is a Jon + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * @param int $type - * @param long $length - * @return string - */ - public static function random($type = 0, $length = 8) {} - - /** - * Check if a string starts with a given string + * // Hello my name is a Bob + * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); * - * - * echo Phalcon\Text::startsWith("Hello", "He"); // true - * echo Phalcon\Text::startsWith("Hello", "he", false); // false - * echo Phalcon\Text::startsWith("Hello", "he"); // true - * + * // Hello my name is a Zyxep + * echo Phalcon\Text::dynamic( + * "[Hi/Hello], my name is a [Zyxep/Mark]!", + * "[", "]", + * "/" + * ); + * ``` * - * @param string $str - * @param string $start - * @param bool $ignoreCase - * @return bool + * @param string $text + * @param string $leftDelimiter + * @param string $rightDelimiter + * @param string $separator + * @return string */ - public static function startsWith($str, $start, $ignoreCase = true) {} + public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string {} /** * Check if a string ends with a given string * - * + * ```php * echo Phalcon\Text::endsWith("Hello", "llo"); // true * echo Phalcon\Text::endsWith("Hello", "LLO", false); // false * echo Phalcon\Text::endsWith("Hello", "LLO"); // true - * + * ``` * - * @param string $str + * @param string $text * @param string $end * @param bool $ignoreCase * @return bool */ - public static function endsWith($str, $end, $ignoreCase = true) {} + public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool {} /** - * Lowercases a string, this function makes use of the mbstring extension if available + * Makes an underscored or dashed phrase human-readable * - * - * echo Phalcon\Text::lower("HELLO"); // hello - * + * ```php + * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" + * echo Phalcon\Text::humanize("five_cats"); // "five cats" + * ``` * - * @param string $str - * @param string $encoding + * @param string $text * @return string */ - public static function lower($str, $encoding = 'UTF-8') {} + public static function humanize(string $text): string {} /** - * Uppercases a string, this function makes use of the mbstring extension if available + * Adds a number to a string or increment that number if it already is + * defined * - * - * echo Phalcon\Text::upper("hello"); // HELLO - * + * ```php + * echo Phalcon\Text::increment("a"); // "a_1" + * echo Phalcon\Text::increment("a_1"); // "a_2" + * ``` * - * @param string $str - * @param string $encoding + * @param string $text + * @param string $separator * @return string */ - public static function upper($str, $encoding = 'UTF-8') {} + public static function increment(string $text, string $separator = '_'): string {} /** - * Reduces multiple slashes in a string to single slashes + * Lowercases a string, this function makes use of the mbstring extension if + * available * - * - * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); // foo/bar/baz - * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); // http://foo.bar/baz/buz - * + * ```php + * echo Phalcon\Text::lower("HELLO"); // hello + * ``` * - * @param string $str + * @param string $text + * @param string $encoding * @return string */ - public static function reduceSlashes($str) {} + public static function lower(string $text, string $encoding = 'UTF-8'): string {} /** - * Concatenates strings using the separator only once without duplication in places concatenation + * Check if a string starts with a given string * - * - * $str = Phalcon\Text::concat( - * "/", - * "/tmp/", - * "/folder_1/", - * "/folder_2", - * "folder_3/" - * ); + * ```php + * echo Phalcon\Text::startsWith("Hello", "He"); // true + * echo Phalcon\Text::startsWith("Hello", "he", false); // false + * echo Phalcon\Text::startsWith("Hello", "he"); // true + * ``` * - * // /tmp/folder_1/folder_2/folder_3/ - * echo $str; - * + * @param string $text + * @param string $start + * @param bool $ignoreCase + * @return bool + */ + public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool {} + + /** + * Generates a random string based on the given type. Type is one of the + * RANDOM_ constants * - * @param string $separator - * @param string $a - * @param string $b - * @param string $...N + * ```php + * use Phalcon\Text; + * + * // "aloiwkqz" + * echo Text::random(Text::RANDOM_ALNUM); + * ``` + * + * @param int $type + * @param long $length * @return string */ - public static function concat() {} + public static function random(int $type = 0, int $length = 8): string {} /** - * Generates random text in accordance with the template + * Reduces multiple slashes in a string to single slashes * - * - * // Hi my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * ```php + * // foo/bar/baz + * echo Phalcon\Text::reduceSlashes("foo//bar/baz"); * - * // Hi my name is a Jon - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * // http://foo.bar/baz/buz + * echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz"); + * ``` * - * // Hello my name is a Bob - * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); + * @param string $text + * @return string + */ + public static function reduceSlashes(string $text): string {} + + /** + * Uncamelize strings which are camelized * - * // Hello my name is a Zyxep - * echo Phalcon\Text::dynamic("[Hi/Hello], my name is a [Zyxep/Mark]!", "[", "]", "/"); - * + * ```php + * echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo + * echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo + * ``` * * @param string $text - * @param string $leftDelimiter - * @param string $rightDelimiter - * @param string $separator + * @param mixed $delimiter * @return string */ - public static function dynamic($text, $leftDelimiter = '{', $rightDelimiter = '}', $separator = '|') {} + public static function uncamelize(string $text, $delimiter = null): string {} /** * Makes a phrase underscored instead of spaced * - * + * ```php * echo Phalcon\Text::underscore("look behind"); // "look_behind" * echo Phalcon\Text::underscore("Awesome Phalcon"); // "Awesome_Phalcon" - * + * ``` * * @param string $text * @return string */ - public static function underscore($text) {} + public static function underscore(string $text): string {} /** - * Makes an underscored or dashed phrase human-readable + * Uppercases a string, this function makes use of the mbstring extension if + * available * - * - * echo Phalcon\Text::humanize("start-a-horse"); // "start a horse" - * echo Phalcon\Text::humanize("five_cats"); // "five cats" - * + * ```php + * echo Phalcon\Text::upper("hello"); // HELLO + * ``` * * @param string $text + * @param string $encoding * @return string */ - public static function humanize($text) {} + public static function upper(string $text, string $encoding = 'UTF-8'): string {} } diff --git a/src/Phalcon/Translate.php b/src/Phalcon/Translate.php deleted file mode 100644 index ad8cc91c..00000000 --- a/src/Phalcon/Translate.php +++ /dev/null @@ -1,14 +0,0 @@ - + * ```php * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * @@ -26,163 +17,174 @@ * "year" => "2012", * ] * ); - * + * ``` */ -class Url implements UrlInterface, InjectionAwareInterface +class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterface { + /** + * @var null | string + */ + protected $baseUri = null; + + /** + * @var null | string + */ + protected $basePath = null; + + /** + * @var + */ + protected $container; + + + protected $router; + + /** + * @var null | string + */ + protected $staticBaseUri = null; + + + /** + * Generates a URL + * + * ```php + * // Generate a URL appending the URI to the base URI + * echo $url->get("products/edit/1"); + * + * // Generate a URL for a predefined route + * echo $url->get( + * [ + * "for" => "blog-post", + * "title" => "some-cool-stuff", + * "year" => "2015", + * ] + * ); + * + * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) + * echo $url->get( + * "show/products", + * [ + * "id" => 1, + * "name" => "Carrots", + * ] + * ); + * + * // Generate an absolute URL by setting the third parameter as false. + * echo $url->get( + * "https://phalconphp.com/", + * null, + * false + * ); + * ``` + * + * @param mixed $uri + * @param mixed $args + * @param bool $local + * @param mixed $baseUri + * @return string + */ + public function get($uri = null, $args = null, bool $local = null, $baseUri = null): string {} + + /** + * Returns the base path + * + * @return string + */ + public function getBasePath(): string {} + + /** + * Returns the prefix for all the generated urls. By default / + * + * @return string + */ + public function getBaseUri(): string {} + + /** + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Generates a URL for a static resource + * + * ```php + * // Generate a URL for a static resource + * echo $url->getStatic("img/logo.png"); + * + * // Generate a URL for a static predefined route + * echo $url->getStatic( + * [ + * "for" => "logo-cdn", + * ] + * ); + * ``` + * + * @param mixed $uri + * @return string + */ + public function getStatic($uri = null): string {} + + /** + * Returns the prefix for all the generated static urls. By default / + * + * @return string + */ + public function getStaticBaseUri(): string {} + + /** + * Sets a base path for all the generated paths + * + * ```php + * $url->setBasePath("/var/www/htdocs/"); + * ``` + * + * @param string $basePath + * @return \Phalcon\Url\UrlInterface + */ + public function setBasePath(string $basePath): UrlInterface {} + + /** + * Sets a prefix for all the URIs to be generated + * + * ```php + * $url->setBaseUri("/invo/"); + * + * $url->setBaseUri("/invo/index.php/"); + * ``` + * + * @param string $baseUri + * @return \Phalcon\Url\UrlInterface + */ + public function setBaseUri(string $baseUri): UrlInterface {} + + /** + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets a prefix for all static URLs generated + * + * ```php + * $url->setStaticBaseUri("/invo/"); + * ``` + * + * @param string $staticBaseUri + * @return \Phalcon\Url\UrlInterface + */ + public function setStaticBaseUri(string $staticBaseUri): UrlInterface {} + + /** + * Generates a local path + * + * @param string $path + * @return string + */ + public function path(string $path = null): string {} - /** - * @var null | string - */ - protected $baseUri = null; - - /** - * @var null | string - */ - protected $basePath = null; - - /** - * @var - */ - protected $container; - - protected $router; - - /** - * @var null | string - */ - protected $staticBaseUri = null; - - /** - * Generates a URL - * - * - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2015", - * ] - * ); - * - * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) - * echo $url->get( - * "show/products", - * [ - * "id" => 1, - * "name" => "Carrots", - * ] - * ); - * - * // Generate an absolute URL by setting the third parameter as false. - * echo $url->get( - * "https://phalconphp.com/", - * null, - * false - * ); - * - */ - public function get($uri = null, $args = null, bool $local = null, $baseUri = null) : string - { - } - - /** - * Returns the base path - */ - public function getBasePath() : string - { - } - - /** - * Returns the prefix for all the generated urls. By default / - */ - public function getBaseUri() : string - { - } - - /** - * Returns the DependencyInjector container - */ - public function getDI() : DiInterface - { - } - - /** - * Generates a URL for a static resource - * - * - * // Generate a URL for a static resource - * echo $url->getStatic("img/logo.png"); - * - * // Generate a URL for a static predefined route - * echo $url->getStatic( - * [ - * "for" => "logo-cdn", - * ] - * ); - * - */ - public function getStatic($uri = null) : string - { - } - - /** - * Returns the prefix for all the generated static urls. By default / - */ - public function getStaticBaseUri() : string - { - } - - /** - * Sets a base path for all the generated paths - * - * - * $url->setBasePath("/var/www/htdocs/"); - * - */ - public function setBasePath(string $basePath) : UrlInterface - { - } - - /** - * Sets a prefix for all the URIs to be generated - * - * - * $url->setBaseUri("/invo/"); - * - * $url->setBaseUri("/invo/index.php/"); - * - */ - public function setBaseUri(string $baseUri) : UrlInterface - { - } - - /** - * Sets the DependencyInjector container - */ - public function setDI(DiInterface $dependencyInjector) - { - } - - /** - * Sets a prefix for all static URLs generated - * - * - * $url->setStaticBaseUri("/invo/"); - * - */ - public function setStaticBaseUri(string $staticBaseUri) : UrlInterface - { - } - - /** - * Generates a local path - */ - public function path(string $path = null) : string - { - } } diff --git a/src/Phalcon/Urlinterface.php b/src/Phalcon/Urlinterface.php deleted file mode 100644 index d107d252..00000000 --- a/src/Phalcon/Urlinterface.php +++ /dev/null @@ -1,44 +0,0 @@ - + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * + * ``` */ const VERSION_MAJOR = 0; /** * The constant referencing the major version. Returns 1 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MEDIUM * ); - * + * ``` */ const VERSION_MEDIUM = 1; /** * The constant referencing the major version. Returns 2 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MINOR * ); - * + * ``` */ const VERSION_MINOR = 2; /** * The constant referencing the major version. Returns 3 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL * ); - * + * ``` */ const VERSION_SPECIAL = 3; /** * The constant referencing the major version. Returns 4 * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_SPECIAL_NUMBER * ); - * + * ``` */ const VERSION_SPECIAL_NUMBER = 4; @@ -72,58 +70,56 @@ class Version * A - Major version * B - Med version (two digits) * C - Min version (two digits) - * D - Special release: 1 = Alpha, 2 = Beta, 3 = RC, 4 = Stable + * D - Special release: 1 = alpha, 2 = beta, 3 = RC, 4 = stable * E - Special release version i.e. RC1, Beta2 etc. * * @return array */ - protected static function _getVersion() {} + protected static function _getVersion(): array {} /** - * Translates a number to a special release - * - * If Special release = 1 this function will return ALPHA + * Translates a number to a special release. * * @param int $special * @return string */ - protected final static function _getSpecial($special) {} + protected final static function _getSpecial(int $special): string {} /** * Returns the active version (string) * - * + * ```php * echo Phalcon\Version::get(); - * + * ``` * * @return string */ - public static function get() {} + public static function get(): string {} /** * Returns the numeric active version * - * + * ```php * echo Phalcon\Version::getId(); - * + * ``` * * @return string */ - public static function getId() {} + public static function getId(): string {} /** * Returns a specific part of the version. If the wrong parameter is passed * it will return the full version * - * + * ```php * echo Phalcon\Version::getPart( * Phalcon\Version::VERSION_MAJOR * ); - * + * ``` * * @param int $part * @return string */ - public static function getPart($part) {} + public static function getPart(int $part): string {} } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 0730e294..4928abdd 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -2,46 +2,53 @@ namespace Phalcon\Acl; -use Phalcon\Acl\Exception; - /** - * Phalcon\Acl\Component - * * This class defines component entity and its description */ -class Component implements ComponentInterface +class Component implements \Phalcon\Acl\ComponentInterface { - /** - * Component description - * @var string - */ - private $description; - - /** - * Component name - * @var string - */ - private $name; + /** + * Component description + * + * @var string + */ + private $description; /** - * Phalcon\Acl\Component constructor - * @param string $name - * @param string|null $description + * Component name + * + * @var string */ - public function __construct(string $name, string $description = null) {} + private $name; + /** - * Returns component description + * Component description + * + * @return string */ public function getDescription(): string {} /** - * Returns the component name + * Component name + * + * @return string */ public function getName(): string {} /** - * Magic method __toString + * Component name + * + * @return string */ public function __toString(): string {} + + /** + * Phalcon\Acl\Component constructor + * + * @param string $name + * @param string $description + */ + public function __construct(string $name, string $description = null) {} + } diff --git a/src/Phalcon/acl/Componentaware.php b/src/Phalcon/acl/ComponentAware.php similarity index 66% rename from src/Phalcon/acl/Componentaware.php rename to src/Phalcon/acl/ComponentAware.php index 1f191edd..3539eb59 100644 --- a/src/Phalcon/acl/Componentaware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -3,14 +3,16 @@ namespace Phalcon\Acl; /** - * Phalcon\Acl\ComponentAware - * * Interface for classes which could be used in allow method as RESOURCE */ interface ComponentAware { + /** * Returns component name - */ - public function getComponentName() : string; + * + * @return string + */ + public function getComponentName(): string; + } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php new file mode 100644 index 00000000..b1e0960c --- /dev/null +++ b/src/Phalcon/acl/ComponentInterface.php @@ -0,0 +1,32 @@ +setDefaultAction( - * \Phalcon\Acl::DENY + * \Phalcon\Acl\Enum::DENY * ); * * // Register roles @@ -56,9 +51,9 @@ * } * * // Grant access to public areas to both users and guests - * foreach ($roles as $role){ + * foreach ($roles as $role) { * foreach ($publicComponents as $component => $actions) { - * $acl->allow($role->getName(), $component, "*"); + * $acl->allow($role->getName(), $component, ""); * } * } * @@ -68,9 +63,9 @@ * $acl->allow("Users", $component, $action); * } * } - *``` + * ``` */ -class Memory extends Adapter +class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter { /** * Access @@ -86,11 +81,11 @@ class Memory extends Adapter */ protected $accessList; - /** - * Returns latest function used to acquire access - * - * @var mixed - */ + /** + * Returns latest function used to acquire access + * + * @var mixed + */ protected $activeFunction; /** @@ -98,7 +93,7 @@ class Memory extends Adapter * * @var int */ - protected $activeFunctionCustomArgumentsCount; + protected $activeFunctionCustomArgumentsCount = 0; /** * Returns latest key used to acquire access @@ -133,7 +128,7 @@ class Memory extends Adapter * * @var mixed */ - protected $noArgumentsDefaultAction = Acl::DENY; + protected $noArgumentsDefaultAction = Enum::DENY; /** * Roles @@ -157,6 +152,27 @@ class Memory extends Adapter protected $rolesNames; + /** + * Returns latest function used to acquire access + * + * @return mixed + */ + public function getActiveFunction() {} + + /** + * Returns number of additional arguments(excluding role and resource) for active function + * + * @return int + */ + public function getActiveFunctionCustomArgumentsCount(): int {} + + /** + * Returns latest key used to acquire access + * + * @return string|null + */ + public function getActiveKey(): ?string {} + /** * Phalcon\Acl\Adapter\Memory constructor */ @@ -195,20 +211,21 @@ public function __construct() {} * ] * ); * ``` - * @param $componentValue - * @param $accessList + * + * @param mixed $componentValue + * @param mixed $accessList * @return bool */ - public function addComponent($componentValue, $accessList) : bool {} + public function addComponent($componentValue, $accessList): bool {} /** * Adds access to components * - * @param $componentName - * @param $accessList + * @param string $componentName + * @param mixed $accessList * @return bool */ - public function addComponentAccess(string $componentName, $accessList) : bool {} + public function addComponentAccess(string $componentName, $accessList): bool {} /** * Do a role inherit from another existing role @@ -219,10 +236,10 @@ public function addComponentAccess(string $componentName, $accessList) : bool {} * ``` * * @param string $roleName - * @param $roleToInherits + * @param mixed $roleToInherits * @return bool */ - public function addInherit(string $roleName, $roleToInherits) : bool {} + public function addInherit(string $roleName, $roleToInherits): bool {} /** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role @@ -237,14 +254,14 @@ public function addInherit(string $roleName, $roleToInherits) : bool {} * $acl->addRole("administrator", ["consultant", "consultant2"]); * ``` * - * @param $role - * @param null $accessInherits + * @param mixed $role + * @param mixed $accessInherits * @return bool */ - public function addRole($role, $accessInherits = null) : bool {} + public function addRole($role, $accessInherits = null): bool {} /** - * Allow access to a role on a component. You can use `*` as wildcard + * Allow access to a role on a component. You can use `` as wildcard * * ```php * // Allow access to guests to search on customers @@ -254,20 +271,20 @@ public function addRole($role, $accessInherits = null) : bool {} * $acl->allow("guests", "customers", ["search", "create"]); * * // Allow access to any role to browse on products - * $acl->allow("*", "products", "browse"); + * $acl->allow("", "products", "browse"); * * // Allow access to any role to browse on any component - * $acl->allow("*", "*", "browse"); + * $acl->allow("", "", "browse"); * * @param string $roleName * @param string $componentName - * @param $access - * @param null $func + * @param mixed $access + * @param mixed $func */ - public function allow(string $roleName, string $componentName, $access, $func = null) : void {} + public function allow(string $roleName, string $componentName, $access, $func = null) {} /** - * Deny access to a role on a component. You can use `*` as wildcard + * Deny access to a role on a component. You can use `` as wildcard * * ```php * // Deny access to guests to search on customers @@ -277,45 +294,48 @@ public function allow(string $roleName, string $componentName, $access, $func = * $acl->deny("guests", "customers", ["search", "create"]); * * // Deny access to any role to browse on products - * $acl->deny("*", "products", "browse"); + * $acl->deny("", "products", "browse"); * * // Deny access to any role to browse on any component - * $acl->deny("*", "*", "browse"); + * $acl->deny("", "", "browse"); * ``` * * @param string $roleName * @param string $componentName - * @param $access - * @param null $func + * @param mixed $access + * @param mixed $func */ - public function deny(string $roleName, string $componentName, $access, $func = null) : void {} + public function deny(string $roleName, string $componentName, $access, $func = null) {} /** * Removes an access from a component + * * @param string $componentName - * @param $accessList + * @param mixed $accessList */ - public function dropComponentAccess(string $componentName, $accessList) : void {} + public function dropComponentAccess(string $componentName, $accessList) {} /** * Returns the default ACL access level for no arguments provided in * `isAllowed` action if a `func` (callable) exists for `accessKey` + * + * @return int */ - public function getNoArgumentsDefaultAction() : int {} + public function getNoArgumentsDefaultAction(): int {} /** * Return an array with every role registered in the list * - * @return RoleInterface[] + * @return array|\Phalcon\Acl\RoleInterface[] */ - public function getRoles() : array {} + public function getRoles(): array {} /** * Return an array with every component registered in the list * - * @return ComponentInterface[] + * @return array|\Phalcon\Acl\ComponentInterface[] */ - public function getComponents() : array {} + public function getComponents(): array {} /** * Check whether a role is allowed to access an action from a component @@ -325,15 +345,16 @@ public function getComponents() : array {} * $acl->isAllowed("andres", "Products", "create"); * * // Do guests have access to any component to edit? - * $acl->isAllowed("guests", "*", "edit"); + * $acl->isAllowed("guests", "", "edit"); * ``` - * @param $roleName - * @param $componentName - * @param $access - * @param array|null $parameters + * + * @param mixed $roleName + * @param mixed $componentName + * @param string $access + * @param array $parameters * @return bool */ - public function isAllowed($roleName, $componentName, $access, ?array $parameters = null) : bool {} + public function isAllowed($roleName, $componentName, string $access, array $parameters = null): bool {} /** * Check whether role exist in the roles list @@ -341,7 +362,7 @@ public function isAllowed($roleName, $componentName, $access, ?array $parameters * @param string $roleName * @return bool */ - public function isRole(string $roleName) : bool {} + public function isRole(string $roleName): bool {} /** * Check whether component exist in the components list @@ -349,14 +370,36 @@ public function isRole(string $roleName) : bool {} * @param string $componentName * @return bool */ - public function isComponent(string $componentName) : bool {} + public function isComponent(string $componentName): bool {} /** - * Sets the default access level (`Phalcon\Acl::ALLOW` or `Phalcon\Acl::DENY`) + * Sets the default access level (`Phalcon\Enum::ALLOW` or `Phalcon\Enum::DENY`) * for no arguments provided in isAllowed action if there exists func for * accessKey * * @param int $defaultAccess */ - public function setNoArgumentsDefaultAction(int $defaultAccess) : void {} + public function setNoArgumentsDefaultAction(int $defaultAccess) {} + + /** + * Checks if a role has access to a component + * + * @param string $roleName + * @param string $componentName + * @param mixed $access + * @param mixed $action + * @param mixed $func + */ + private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) {} + + /** + * Check whether a role is allowed to access an action from a component + * + * @param string $roleName + * @param string $componentName + * @param string $access + * @return string|bool + */ + private function canAccess(string $roleName, string $componentName, string $access) {} + } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index 0819c6fd..09c42994 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -3,32 +3,30 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Annotation - * * Represents a single annotation in an annotations collection */ class Annotation { /** - * Annotation Name + * Annotation Arguments * - * @var string + * @var array */ - protected $_name; + protected $arguments; /** - * Annotation Arguments + * Annotation ExprArguments * * @var string */ - protected $_arguments; + protected $exprArguments; /** - * Annotation ExprArguments + * Annotation Name * * @var string */ - protected $_exprArguments; + protected $name; /** @@ -39,71 +37,69 @@ class Annotation public function __construct(array $reflectionData) {} /** - * Returns the annotation's name + * Returns an argument in a specific position * - * @return string + * @param mixed $position */ - public function getName() {} + public function getArgument($position) {} /** - * Resolves an annotation expression + * Returns the expression arguments * - * @param array $expr - * @return mixed + * @return array */ - public function getExpression(array $expr) {} + public function getArguments(): array {} /** * Returns the expression arguments without resolving * * @return array */ - public function getExprArguments() {} + public function getExprArguments(): array {} /** - * Returns the expression arguments + * Resolves an annotation expression * - * @return array + * @param array $expr + * @return mixed */ - public function getArguments() {} + public function getExpression(array $expr) {} /** - * Returns the number of arguments that the annotation has + * Returns the annotation's name * - * @return int + * @return string */ - public function numberArguments() {} + public function getName(): string {} /** - * Returns an argument in a specific position + * Returns a named argument * - * @param int|string $position - * @return mixed + * @param string $name */ - public function getArgument($position) {} + public function getNamedArgument(string $name) {} /** - * Returns an argument in a specific position + * Returns a named parameter * - * @param int|string $position - * @return bool + * @param string $name + * @return mixed */ - public function hasArgument($position) {} + public function getNamedParameter(string $name) {} /** - * Returns a named argument + * Returns an argument in a specific position * - * @param string $name - * @return mixed + * @param mixed $position + * @return bool */ - public function getNamedArgument($name) {} + public function hasArgument($position): bool {} /** - * Returns a named parameter + * Returns the number of arguments that the annotation has * - * @param string $name - * @return mixed + * @return int */ - public function getNamedParameter($name) {} + public function numberArguments(): int {} } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php new file mode 100644 index 00000000..474b8c63 --- /dev/null +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -0,0 +1,42 @@ + - * //Traverse annotations + * ```php + * // Traverse annotations * foreach ($classAnnotations as $annotation) { * echo "Name=", $annotation->getName(), PHP_EOL; * } * - * //Check if the annotations has a specific + * // Check if the annotations has a specific * var_dump($classAnnotations->has("Cacheable")); * - * //Get an specific annotation in the collection + * // Get an specific annotation in the collection * $annotation = $classAnnotations->get("Cacheable"); - * + * ``` */ class Collection implements \Iterator, \Countable { + /** + * @var array + */ + protected $annotations; - protected $_position = 0; - - - protected $_annotations; + /** + * @var int + */ + protected $position = 0; /** @@ -34,19 +37,14 @@ class Collection implements \Iterator, \Countable * * @param array $reflectionData */ - public function __construct($reflectionData = null) {} + public function __construct(array $reflectionData = array()) {} /** * Returns the number of annotations in the collection * * @return int */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} + public function count(): int {} /** * Returns the current annotation in the iterator @@ -56,53 +54,58 @@ public function rewind() {} public function current() {} /** - * Returns the current position/key in the iterator + * Returns the first annotation that match a name * - * @return int - */ - public function key() {} - - /** - * Moves the internal iteration pointer to the next position + * @param string $name + * @return \Phalcon\Annotations\Annotation */ - public function next() {} + public function get(string $name): Annotation {} /** - * Check if the current annotation in the iterator is valid + * Returns all the annotations that match a name * - * @return bool + * @param string $name + * @return array|\Phalcon\Annotations\Annotation[] */ - public function valid() {} + public function getAll(string $name): array {} /** * Returns the internal annotations as an array * - * @return \Phalcon\Annotations\Annotation[] + * @return array|\Phalcon\Annotations\Annotation[] */ - public function getAnnotations() {} + public function getAnnotations(): array {} /** - * Returns the first annotation that match a name + * Check if an annotation exists in a collection * * @param string $name - * @return \Phalcon\Annotations\Annotation + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Returns all the annotations that match a name + * Returns the current position/key in the iterator * - * @param string $name - * @return \Phalcon\Annotations\Annotation[] + * @return int */ - public function getAll($name) {} + public function key(): int {} /** - * Check if an annotation exists in a collection + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Check if the current annotation in the iterator is valid * - * @param string $name * @return bool */ - public function has($name) {} + public function valid(): bool {} } diff --git a/src/Phalcon/annotations/Exception.php b/src/Phalcon/annotations/Exception.php index 22e5decf..8864d544 100644 --- a/src/Phalcon/annotations/Exception.php +++ b/src/Phalcon/annotations/Exception.php @@ -3,11 +3,9 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Exception - * * Class for exceptions thrown by Phalcon\Annotations */ -class Exception extends \Exception +class Exception extends \Phalcon\Exception { } diff --git a/src/Phalcon/annotations/Factory.php b/src/Phalcon/annotations/Factory.php deleted file mode 100644 index 63dd2a8a..00000000 --- a/src/Phalcon/annotations/Factory.php +++ /dev/null @@ -1,28 +0,0 @@ - - * use Phalcon\Annotations\Factory; - * - * $options = [ - * "prefix" => "annotations", - * "lifetime" => "3600", - * "adapter" => "apc", - * ]; - * $annotations = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index 3208daf9..fdc95680 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -3,20 +3,18 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reader - * * Parses docblocks returning an array with the found annotations */ class Reader implements \Phalcon\Annotations\ReaderInterface { /** - * Reads annotations from the class dockblocks, its methods and/or properties + * Reads annotations from the class docblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse($className) {} + public function parse(string $className): array {} /** * Parses a raw doc block returning the annotations found @@ -26,6 +24,6 @@ public function parse($className) {} * @param mixed $line * @return array */ - public static function parseDocBlock($docBlock, $file = null, $line = null) {} + public static function parseDocBlock(string $docBlock, $file = null, $line = null): array {} } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index 1e6ce946..5ba4b965 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -3,29 +3,27 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reader - * * Parses docblocks returning an array with the found annotations */ interface ReaderInterface { /** - * Reads annotations from the class dockblocks, its methods and/or properties + * Reads annotations from the class docblocks, its methods and/or properties * * @param string $className * @return array */ - public function parse($className); + public function parse(string $className): array; /** - * Parses a raw doc block returning the annotations found + * Parses a raw docblock returning the annotations found * * @param string $docBlock * @param mixed $file * @param mixed $line * @return array */ - public static function parseDocBlock($docBlock, $file = null, $line = null); + public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index 6bca75ff..97072543 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -3,11 +3,9 @@ namespace Phalcon\Annotations; /** - * Phalcon\Annotations\Reflection - * * Allows to manipulate the annotations reflection in an OO manner * - * + * ```php * use Phalcon\Annotations\Reader; * use Phalcon\Annotations\Reflection; * @@ -20,21 +18,23 @@ * * // Get the annotations in the class docblock * $classAnnotations = $reflection->getClassAnnotations(); - * + * ``` */ class Reflection { - protected $_reflectionData; - + protected $classAnnotations; - protected $_classAnnotations; + protected $methodAnnotations; - protected $_methodAnnotations; + protected $propertyAnnotations; - protected $_propertyAnnotations; + /** + * @var array + */ + protected $reflectionData; /** @@ -42,7 +42,7 @@ class Reflection * * @param array $reflectionData */ - public function __construct($reflectionData = null) {} + public function __construct(array $reflectionData = array()) {} /** * Returns the annotations found in the class docblock @@ -54,30 +54,23 @@ public function getClassAnnotations() {} /** * Returns the annotations found in the methods' docblocks * - * @return bool|\Phalcon\Annotations\Collection[] + * @return array|bool|\Phalcon\Annotations\Collection[] */ public function getMethodsAnnotations() {} /** * Returns the annotations found in the properties' docblocks * - * @return bool|\Phalcon\Annotations\Collection[] + * @return array|bool|\Phalcon\Annotations\Collection[] */ public function getPropertiesAnnotations() {} /** - * Returns the raw parsing intermediate definitions used to construct the reflection + * Returns the raw parsing intermediate definitions used to construct the + * reflection * * @return array */ - public function getReflectionData() {} - - /** - * Restores the state of a Phalcon\Annotations\Reflection variable export - * - * @param mixed $data - * @return Reflection - */ - public static function __set_state($data) {} + public function getReflectionData(): array {} } diff --git a/src/Phalcon/annotations/Adapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php similarity index 63% rename from src/Phalcon/annotations/Adapter.php rename to src/Phalcon/annotations/adapter/AbstractAdapter.php index 2b9a8b55..e20924a3 100644 --- a/src/Phalcon/annotations/Adapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -1,42 +1,39 @@ - * use Phalcon\Annotations\Adapter\Apc; - * - * $annotations = new Apc(); - * - * - * @see \Phalcon\Annotations\Adapter\Apcu - * @deprecated - */ -class Apc extends \Phalcon\Annotations\Adapter -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - /** - * Phalcon\Annotations\Adapter\Apc constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads parsed annotations from APC - * - * @param string $key - * @return bool|\Phalcon\Annotations\Reflection - */ - public function read($key) {} - - /** - * Writes parsed annotations to APC - * - * @param string $key - * @param \Phalcon\Annotations\Reflection $data - */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} - -} diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index 0eabb8a8..3eedce01 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -3,23 +3,25 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Apcu - * * Stores the parsed annotations in APCu. This adapter is suitable for production * - * + * ```php * use Phalcon\Annotations\Adapter\Apcu; * * $annotations = new Apcu(); - * + * ``` */ -class Apcu extends \Phalcon\Annotations\Adapter +class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter { + /** + * @var string + */ + protected $prefix = ''; - protected $_prefix = ''; - - - protected $_ttl = 172800; + /** + * @var int + */ + protected $ttl = 172800; /** @@ -27,7 +29,7 @@ class Apcu extends \Phalcon\Annotations\Adapter * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** * Reads parsed annotations from APCu @@ -35,14 +37,15 @@ public function __construct($options = null) {} * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to APCu * * @param string $key * @param \Phalcon\Annotations\Reflection $data + * @return bool */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data): bool {} } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index 421aa079..dff5586e 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -3,18 +3,15 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Memory - * - * Stores the parsed annotations in memory. This adapter is the suitable development/testing + * Stores the parsed annotations in memory. This adapter is the suitable + * development/testing */ -class Memory extends \Phalcon\Annotations\Adapter +class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter { /** - * Data - * * @var mixed */ - protected $_data; + protected $data; /** @@ -23,7 +20,7 @@ class Memory extends \Phalcon\Annotations\Adapter * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to memory @@ -31,6 +28,6 @@ public function read($key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Files.php b/src/Phalcon/annotations/adapter/Stream.php similarity index 55% rename from src/Phalcon/annotations/adapter/Files.php rename to src/Phalcon/annotations/adapter/Stream.php index fc5be66d..1ceda655 100644 --- a/src/Phalcon/annotations/adapter/Files.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -3,32 +3,32 @@ namespace Phalcon\Annotations\Adapter; /** - * Phalcon\Annotations\Adapter\Files - * * Stores the parsed annotations in files. This adapter is suitable for production * - * - * use Phalcon\Annotations\Adapter\Files; + * ```php + * use Phalcon\Annotations\Adapter\Stream; * - * $annotations = new Files( + * $annotations = new Stream( * [ * "annotationsDir" => "app/cache/annotations/", * ] * ); - * + * ``` */ -class Files extends \Phalcon\Annotations\Adapter +class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter { - - protected $_annotationsDir = './'; + /** + * @var string + */ + protected $annotationsDir = './'; /** - * Phalcon\Annotations\Adapter\Files constructor + * Phalcon\Annotations\Adapter\Stream constructor * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** * Reads parsed annotations from files @@ -36,7 +36,7 @@ public function __construct($options = null) {} * @param string $key * @return bool|int|\Phalcon\Annotations\Reflection */ - public function read($key) {} + public function read(string $key) {} /** * Writes parsed annotations to files @@ -44,6 +44,6 @@ public function read($key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} + public function write(string $key, \Phalcon\Annotations\Reflection $data) {} } diff --git a/src/Phalcon/annotations/adapter/Xcache.php b/src/Phalcon/annotations/adapter/Xcache.php deleted file mode 100644 index 504b2674..00000000 --- a/src/Phalcon/annotations/adapter/Xcache.php +++ /dev/null @@ -1,33 +0,0 @@ - - * $annotations = new \Phalcon\Annotations\Adapter\Xcache(); - * - */ -class Xcache extends \Phalcon\Annotations\Adapter -{ - - /** - * Reads parsed annotations from XCache - * - * @param string $key - * @return bool|\Phalcon\Annotations\Reflection - */ - public function read($key) {} - - /** - * Writes parsed annotations to XCache - * - * @param string $key - * @param \Phalcon\Annotations\Reflection $data - */ - public function write($key, \Phalcon\Annotations\Reflection $data) {} - -} diff --git a/src/Phalcon/Application.php b/src/Phalcon/application/AbstractApplication.php similarity index 58% rename from src/Phalcon/Application.php rename to src/Phalcon/application/AbstractApplication.php index 6b5b964a..b0376906 100644 --- a/src/Phalcon/Application.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -1,91 +1,97 @@ + * ```php * $this->registerModules( * [ * "frontend" => [ - * "className" => "Multiple\\Frontend\\Module", + * "className" => \Multiple\Frontend\Module::class, * "path" => "../apps/frontend/Module.php", * ], * "backend" => [ - * "className" => "Multiple\\Backend\\Module", + * "className" => \Multiple\Backend\Module::class, * "path" => "../apps/backend/Module.php", * ], * ] * ); - * + * ``` * * @param array $modules * @param bool $merge * @return Application */ - public function registerModules(array $modules, $merge = false) {} - - /** - * Return the modules registered in the application - * - * @return array - */ - public function getModules() {} - - /** - * Gets the module definition registered in the application via module name - * - * @param string $name - * @return array|object - */ - public function getModule($name) {} + public function registerModules(array $modules, bool $merge = false): Application {} /** * Sets the module name to be used if the router doesn't return a valid module @@ -93,18 +99,14 @@ public function getModule($name) {} * @param string $defaultModule * @return Application */ - public function setDefaultModule($defaultModule) {} + public function setDefaultModule(string $defaultModule): Application {} /** - * Returns the default module name + * Sets the events manager * - * @return string - */ - public function getDefaultModule() {} - - /** - * Handles a request + * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return Application */ - abstract public function handle(); + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): Application {} } diff --git a/src/Phalcon/application/Exception.php b/src/Phalcon/application/Exception.php index f400d62a..9e2d5a57 100644 --- a/src/Phalcon/application/Exception.php +++ b/src/Phalcon/application/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Application; /** - * Phalcon\Application\Exception - * * Exceptions thrown in Phalcon\Application class will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 16acb66d..431db7dc 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -3,176 +3,247 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Asset - * * Represents an asset asset * - * + * ```php * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); - * + * ``` */ -class Asset implements AssetInterface +class Asset implements \Phalcon\Assets\AssetInterface { - /** - * @var array | null - */ - protected $attributes; - - /** - * @var bool - */ - protected $filter; - - /** - * @var bool - */ - protected $local; - - /** - * @var string - */ - protected $path; - - /** - * @var string - */ - protected $sourcePath; - - /** - * @var string - */ - protected $targetPath; - - /** - * @var string - */ - protected $targetUri; - - /** - * @var string - */ - protected $type; - - /** - * Phalcon\Assets\Asset constructor - */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = []) - { - } - - /** - * Sets the asset's type - */ - public function setType(string $type) : AssetInterface - { - } - - /** - * Sets the asset's path - */ - public function setPath(string $path) : AssetInterface - { - } - - /** - * Sets if the asset is local or external - */ - public function setLocal(bool $local) : AssetInterface - { - } - - /** - * Sets if the asset must be filtered or not - */ - public function setFilter(bool $filter) : AssetInterface - { - } - - /** - * Sets extra HTML attributes - */ - public function setAttributes(array $attributes) : AssetInterface - { - } - - /** - * Sets a target uri for the generated HTML - */ - public function setTargetUri(string $targetUri) : AssetInterface - { - } - - /** - * Sets the asset's source path - */ - public function setSourcePath(string $sourcePath) : AssetInterface - { - } - - /** - * Sets the asset's target path - */ - public function setTargetPath(string $targetPath) : AssetInterface - { - } - - /** - * Returns the content of the asset as an string - * Optionally a base path where the asset is located can be set - */ - public function getContent(string $basePath = null) : string - { - } - - /** - * Returns the real target uri for the generated HTML - */ - public function getRealTargetUri() : string - { - } - - /** - * Returns the complete location where the asset is located - */ - public function getRealSourcePath(string $basePath = null) : string - { - } - - /** - * Returns the complete location where the asset must be written - */ - public function getRealTargetPath(string $basePath = null) : string - { - } - - /** - * Gets the asset's key. - */ - public function getAssetKey() : string - { - } - - /** - * Gets the asset's type. - */ - public function getType(): string - { - // TODO: Implement getType() method. - } - - /** - * Gets if the asset must be filtered or not. - */ - public function getFilter(): bool - { - // TODO: Implement getFilter() method. - } - - /** - * Gets extra HTML attributes. - */ - public function getAttributes(): array - { - // TODO: Implement getAttributes() method. - } + /** + * @var array | null + */ + protected $attributes; + + /** + * @var bool + */ + protected $autoVersion = false; + + /** + * @var bool + */ + protected $filter; + + /** + * @var bool + */ + protected $local; + + /** + * @var string + */ + protected $path; + + /** + * @var string + */ + protected $sourcePath; + + /** + * @var string + */ + protected $targetPath; + + /** + * @var string + */ + protected $targetUri; + + /** + * @var string + */ + protected $type; + + /** + * Version of resource + * + * @var string + */ + protected $version; + + + /** + * @return array|null + */ + public function getAttributes(): ?array {} + + /** + * @param bool $autoVersion + */ + public function setAutoVersion(bool $autoVersion) {} + + /** + * @return bool + */ + public function getFilter(): bool {} + + /** + * @return bool + */ + public function getLocal(): bool {} + + /** + * @return string + */ + public function getPath(): string {} + + /** + * @return string + */ + public function getSourcePath(): string {} + + /** + * @return string + */ + public function getTargetPath(): string {} + + /** + * @return string + */ + public function getTargetUri(): string {} + + /** + * @return string + */ + public function getType(): string {} + + /** + * Version of resource + * + * @return string + */ + public function getVersion(): string {} + + /** + * Version of resource + * + * @param string $version + */ + public function setVersion(string $version) {} + + /** + * Phalcon\Assets\Asset constructor + * + * @param string $type + * @param string $path + * @param bool $local + * @param bool $filter + * @param array $attributes + * @param string $version + * @param bool $autoVersion + */ + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} + + /** + * Gets the asset's key. + * + * @return string + */ + public function getAssetKey(): string {} + + /** + * Returns the content of the asset as an string + * Optionally a base path where the asset is located can be set + * + * @param string $basePath + * @return string + */ + public function getContent(string $basePath = null): string {} + + /** + * Returns the complete location where the asset is located + * + * @param string $basePath + * @return string + */ + public function getRealSourcePath(string $basePath = null): string {} + + /** + * Returns the complete location where the asset must be written + * + * @param string $basePath + * @return string + */ + public function getRealTargetPath(string $basePath = null): string {} + + /** + * Returns the real target uri for the generated HTML + * + * @return string + */ + public function getRealTargetUri(): string {} + + /** + * Checks if resource is using auto version + * + * @return bool + */ + public function isAutoVersion(): bool {} + + /** + * Sets extra HTML attributes + * + * @param array $attributes + * @return AssetInterface + */ + public function setAttributes(array $attributes): AssetInterface {} + + /** + * Sets if the asset must be filtered or not + * + * @param bool $filter + * @return AssetInterface + */ + public function setFilter(bool $filter): AssetInterface {} + + /** + * Sets if the asset is local or external + * + * @param bool $local + * @return AssetInterface + */ + public function setLocal(bool $local): AssetInterface {} + + /** + * Sets the asset's source path + * + * @param string $sourcePath + * @return AssetInterface + */ + public function setSourcePath(string $sourcePath): AssetInterface {} + + /** + * Sets the asset's target path + * + * @param string $targetPath + * @return AssetInterface + */ + public function setTargetPath(string $targetPath): AssetInterface {} + + /** + * Sets a target uri for the generated HTML + * + * @param string $targetUri + * @return AssetInterface + */ + public function setTargetUri(string $targetUri): AssetInterface {} + + /** + * Sets the asset's type + * + * @param string $type + * @return AssetInterface + */ + public function setType(string $type): AssetInterface {} + + /** + * Sets the asset's path + * + * @param string $path + * @return AssetInterface + */ + public function setPath(string $path): AssetInterface {} + } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php new file mode 100644 index 00000000..c7bdf739 --- /dev/null +++ b/src/Phalcon/assets/AssetInterface.php @@ -0,0 +1,63 @@ + - * use Phalcon\Assets\Resource; - * use Phalcon\Assets\Collection; - * - * $collection = new Collection(); - * $resource = new Resource("js", "js/jquery.js"); - * $collection->add($resource); - * $collection->has($resource); // true - * + * Adds a filter to the collection * - * @param ResourceInterface $resource - * @return bool + * @param \Phalcon\Assets\FilterInterface $filter + * @return Collection */ - public function has(ResourceInterface $resource) {} + public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection {} /** - * Adds a CSS resource to the collection + * Adds an inline code to the collection * - * @param string $path - * @param mixed $local - * @param bool $filter - * @param mixed $attributes + * @param \Phalcon\Assets\Inline $code * @return Collection */ - public function addCss($path, $local = null, $filter = true, $attributes = null) {} + public function addInline(\Phalcon\Assets\Inline $code): Collection {} /** * Adds an inline CSS to the collection @@ -143,122 +218,138 @@ public function addCss($path, $local = null, $filter = true, $attributes = null) * @param mixed $attributes * @return Collection */ - public function addInlineCss($content, $filter = true, $attributes = null) {} + public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection {} /** - * Adds a javascript resource to the collection + * Adds an inline javascript to the collection * - * @param string $path - * @param boolean $local - * @param boolean $filter - * @param array $attributes + * @param string $content + * @param bool $filter + * @param mixed $attributes * @return Collection */ - public function addJs($path, $local = null, $filter = true, $attributes = null) {} + public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection {} /** - * Adds an inline javascript to the collection + * Adds a javascript asset to the collection * - * @param string $content + * @param string $path + * @param mixed $local * @param bool $filter - * @param mixed $attributes + * @param array $attributes + * @param string $version + * @param bool $autoVersion * @return Collection */ - public function addInlineJs($content, $filter = true, $attributes = null) {} + public function addJs(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection {} /** * Returns the number of elements in the form * * @return int */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} + public function count(): int {} /** - * Returns the current resource in the iterator + * Returns the current asset in the iterator * - * @return \Phalcon\Assets\Resource + * @return \Phalcon\Assets\Asset */ - public function current() {} + public function current(): Asset {} /** - * Returns the current position/key in the iterator + * Returns the complete location where the joined/filtered collection must + * be written * - * @return int + * @param string $basePath + * @return string */ - public function key() {} + public function getRealTargetPath(string $basePath): string {} /** - * Moves the internal iteration pointer to the next position + * Checks this the asset is added to the collection. + * + * ```php + * use Phalcon\Assets\Asset; + * use Phalcon\Assets\Collection; + * + * $collection = new Collection(); + * + * $asset = new Asset("js", "js/jquery.js"); + * + * $collection->add($asset); + * $collection->has($asset); // true + * ``` + * + * @param AssetInterface $asset + * @return bool */ - public function next() {} + public function has(AssetInterface $asset): bool {} /** - * Check if the current element in the iterator is valid + * Checks if collection is using auto version * * @return bool */ - public function valid() {} + public function isAutoVersion(): bool {} /** - * Sets the target path of the file for the filtered/join output + * Sets if all filtered assets in the collection must be joined in a single + * result file * - * @param string $targetPath + * @param bool $join * @return Collection */ - public function setTargetPath($targetPath) {} + public function join(bool $join): Collection {} /** - * Sets a base source path for all the resources in this collection + * Returns the current position/key in the iterator * - * @param string $sourcePath - * @return Collection + * @return int */ - public function setSourcePath($sourcePath) {} + public function key(): int {} /** - * Sets a target uri for the generated HTML - * - * @param string $targetUri - * @return Collection + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Rewinds the internal iterator */ - public function setTargetUri($targetUri) {} + public function rewind() {} /** - * Sets a common prefix for all the resources + * Sets extra HTML attributes * - * @param string $prefix + * @param array $attributes * @return Collection */ - public function setPrefix($prefix) {} + public function setAttributes(array $attributes): Collection {} /** - * Sets if the collection uses local resources by default + * Sets an array of filters in the collection * - * @param bool $local + * @param array $filters * @return Collection */ - public function setLocal($local) {} + public function setFilters(array $filters): Collection {} /** - * Sets extra HTML attributes + * Sets if the collection uses local assets by default * - * @param array $attributes + * @param bool $local * @return Collection */ - public function setAttributes(array $attributes) {} + public function setLocal(bool $local): Collection {} /** - * Sets an array of filters in the collection + * Sets a common prefix for all the assets * - * @param array $filters + * @param string $prefix * @return Collection */ - public function setFilters(array $filters) {} + public function setPrefix(string $prefix): Collection {} /** * Sets the target local @@ -266,38 +357,45 @@ public function setFilters(array $filters) {} * @param bool $targetLocal * @return Collection */ - public function setTargetLocal($targetLocal) {} + public function setTargetLocal(bool $targetLocal): Collection {} /** - * Sets if all filtered resources in the collection must be joined in a single result file + * Sets the target path of the file for the filtered/join output * - * @param bool $join + * @param string $targetPath * @return Collection */ - public function join($join) {} + public function setTargetPath(string $targetPath): Collection {} /** - * Returns the complete location where the joined/filtered collection must be written + * Sets a target uri for the generated HTML * - * @param string $basePath - * @return string + * @param string $targetUri + * @return Collection */ - public function getRealTargetPath($basePath) {} + public function setTargetUri(string $targetUri): Collection {} /** - * Adds a filter to the collection + * Sets a base source path for all the assets in this collection * - * @param \Phalcon\Assets\FilterInterface $filter + * @param string $sourcePath * @return Collection */ - public function addFilter(\Phalcon\Assets\FilterInterface $filter) {} + public function setSourcePath(string $sourcePath): Collection {} + + /** + * Check if the current element in the iterator is valid + * + * @return bool + */ + public function valid(): bool {} /** - * Adds a resource or inline-code to the collection + * Adds a asset or inline-code to the collection * - * @param ResourceInterface $resource + * @param AssetInterface $asset * @return bool */ - protected final function addResource(ResourceInterface $resource) {} + final protected function addAsset(AssetInterface $asset): bool {} } diff --git a/src/Phalcon/assets/Exception.php b/src/Phalcon/assets/Exception.php index c3104d8d..49148351 100644 --- a/src/Phalcon/assets/Exception.php +++ b/src/Phalcon/assets/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Exception - * * Exceptions thrown in Phalcon\Assets will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index 4d1d4911..e0ba66c2 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\FilterInterface - * * Interface for custom Phalcon\Assets filters */ interface FilterInterface @@ -16,6 +14,6 @@ interface FilterInterface * @param string $content * @return string */ - public function filter($content); + public function filter(string $content): string; } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index 15b0be65..de5d3bef 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -3,92 +3,94 @@ namespace Phalcon\Assets; /** - * Phalcon\Assets\Inline - * * Represents an inline asset * - * + * ```php * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); - * + * ``` */ -class Inline implements \Phalcon\Assets\ResourceInterface +class Inline implements \Phalcon\Assets\AssetInterface { /** - * @var string + * @var array | null */ - protected $_type; + protected $attributes; - - protected $_content; + /** + * @var string + */ + protected $content; /** * @var bool */ - protected $_filter; + protected $filter; + /** + * @var string + */ + protected $type; - protected $_attributes; + /** + * @return array|null + */ + public function getAttributes(): ?array {} /** * @return string */ - public function getType() {} - - - public function getContent() {} + public function getContent(): string {} /** * @return bool */ - public function getFilter() {} + public function getFilter(): bool {} /** - * Phalcon\Assets\Inline constructor - * - * @param string $type - * @param string $content - * @param boolean $filter - * @param array $attributes + * @return string */ - public function __construct($type, $content, $filter = true, $attributes = null) {} + public function getType(): string {} /** - * Sets the inline's type + * Phalcon\Assets\Inline constructor * * @param string $type - * @return ResourceInterface + * @param string $content + * @param bool $filter + * @param array $attributes */ - public function setType($type) {} + public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) {} /** - * Sets if the resource must be filtered or not + * Gets the asset's key. * - * @param bool $filter - * @return ResourceInterface + * @return string */ - public function setFilter($filter) {} + public function getAssetKey(): string {} /** * Sets extra HTML attributes * * @param array $attributes - * @return ResourceInterface + * @return AssetInterface */ - public function setAttributes(array $attributes) {} + public function setAttributes(array $attributes): AssetInterface {} /** - * returns extra HTML attributes + * Sets if the asset must be filtered or not * - * @return array|null + * @param bool $filter + * @return AssetInterface */ - public function getAttributes() {} + public function setFilter(bool $filter): AssetInterface {} /** - * Gets the resource's key. + * Sets the inline's type * - * @return string + * @param string $type + * @return AssetInterface */ - public function getResourceKey() {} + public function setType(string $type): AssetInterface {} } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index d93e5abb..f34300b8 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -7,203 +7,217 @@ * * Manages collections of CSS/Javascript assets */ -class Manager +class Manager implements \Phalcon\Di\InjectionAwareInterface { + + protected $collections; + + /** + * @var DiInterface + */ + protected $container; + /** * Options configure * * @var array */ - protected $_options; + protected $options; - - protected $_collections; - - - protected $_implicitOutput = true; + /** + * @var bool + */ + protected $implicitOutput = true; /** - * Phalcon\Assets\Manager + * Phalcon\Assets\Manager constructor * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Sets the manager options + * Adds a raw asset to the manager * - * @param array $options + * ```php + * $assets->addAsset( + * new Phalcon\Assets\Asset("css", "css/style.css") + * ); + * ``` + * + * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function setOptions(array $options) {} + public function addAsset(\Phalcon\Assets\Asset $asset): Manager {} /** - * Returns the manager options + * Adds a asset by its type * - * @return array - */ - public function getOptions() {} - - /** - * Sets if the HTML generated must be directly printed or returned + * ```php + * $assets->addAssetByType( + * "css", + * new \Phalcon\Assets\Asset\Css("css/style.css") + * ); + * ``` * - * @param bool $implicitOutput + * @param string $type + * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function useImplicitOutput($implicitOutput) {} + public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager {} /** - * Adds a Css resource to the 'css' collection + * Adds a Css asset to the 'css' collection * - * + * ```php * $assets->addCss("css/bootstrap.css"); * $assets->addCss("http://bootstrap.my-cdn.com/style.css", false); - * + * ``` * * @param string $path * @param mixed $local - * @param mixed $filter + * @param bool $filter * @param mixed $attributes + * @param string $version + * @param bool $autoVersion * @return Manager */ - public function addCss($path, $local = true, $filter = true, $attributes = null) {} + public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} /** - * Adds an inline Css to the 'css' collection + * Adds a raw inline code to the manager * - * @param string $content - * @param mixed $filter - * @param mixed $attributes + * @param Inline $code * @return Manager */ - public function addInlineCss($content, $filter = true, $attributes = null) {} + public function addInlineCode(Inline $code): Manager {} /** - * Adds a javascript resource to the 'js' collection - * - * - * $assets->addJs("scripts/jquery.js"); - * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); - * + * Adds an inline code by its type * - * @param string $path - * @param mixed $local - * @param mixed $filter - * @param mixed $attributes + * @param string $type + * @param Inline $code * @return Manager */ - public function addJs($path, $local = true, $filter = true, $attributes = null) {} + public function addInlineCodeByType(string $type, Inline $code): Manager {} /** - * Adds an inline javascript to the 'js' collection + * Adds an inline Css to the 'css' collection * * @param string $content * @param mixed $filter * @param mixed $attributes * @return Manager */ - public function addInlineJs($content, $filter = true, $attributes = null) {} + public function addInlineCss(string $content, $filter = true, $attributes = null): Manager {} /** - * Adds a resource by its type - * - * - * $assets->addResourceByType("css", - * new \Phalcon\Assets\Resource\Css("css/style.css") - * ); - * + * Adds an inline javascript to the 'js' collection * - * @param string $type - * @param \Phalcon\Assets\Resource $resource + * @param string $content + * @param mixed $filter + * @param mixed $attributes * @return Manager */ - public function addResourceByType($type, \Phalcon\Assets\Resource $resource) {} + public function addInlineJs(string $content, $filter = true, $attributes = null): Manager {} /** - * Adds an inline code by its type + * Adds a javascript asset to the 'js' collection * - * @param string $type - * @param Inline $code + * ```php + * $assets->addJs("scripts/jquery.js"); + * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); + * ``` + * + * @param string $path + * @param mixed $local + * @param bool $filter + * @param mixed $attributes + * @param string $version + * @param bool $autoVersion * @return Manager */ - public function addInlineCodeByType($type, Inline $code) {} + public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} /** - * Adds a raw resource to the manager + * Creates/Returns a collection of assets * - * - * $assets->addResource( - * new Phalcon\Assets\Resource("css", "css/style.css") - * ); - * - * - * @param \Phalcon\Assets\Resource $resource - * @return Manager + * @param string $name + * @return \Phalcon\Assets\Collection */ - public function addResource(\Phalcon\Assets\Resource $resource) {} + public function collection(string $name): Collection {} /** - * Adds a raw inline code to the manager + * Creates/Returns a collection of assets by type * - * @param Inline $code - * @return Manager + * @param array $assets + * @param string $type + * @return array */ - public function addInlineCode(Inline $code) {} + public function collectionAssetsByType(array $assets, string $type): array {} /** - * Sets a collection in the Assets Manager + * Returns true or false if collection exists. * - * - * $assets->set("js", $collection); - * + * ```php + * if ($assets->exists("jsHeader")) { + * // \Phalcon\Assets\Collection + * $collection = $assets->get("jsHeader"); + * } + * ``` * * @param string $id - * @param \Phalcon\Assets\Collection $collection - * @return Manager + * @return bool */ - public function set($id, \Phalcon\Assets\Collection $collection) {} + public function exists(string $id): bool {} /** * Returns a collection by its id. * - * + * ```php * $scripts = $assets->get("js"); - * + * ``` * * @param string $id * @return \Phalcon\Assets\Collection */ - public function get($id) {} + public function get(string $id): Collection {} /** - * Returns the CSS collection of assets + * Returns existing collections in the manager * - * @return \Phalcon\Assets\Collection + * @return array|\Phalcon\Assets\Collection[] */ - public function getCss() {} + public function getCollections(): array {} /** * Returns the CSS collection of assets * * @return \Phalcon\Assets\Collection */ - public function getJs() {} + public function getCss(): Collection {} /** - * Creates/Returns a collection of resources + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the CSS collection of assets * - * @param string $name * @return \Phalcon\Assets\Collection */ - public function collection($name) {} + public function getJs(): Collection {} /** - * @param array $resources - * @param string $type + * Returns the manager options + * * @return array */ - public function collectionResourcesByType(array $resources, $type) {} + public function getOptions(): array {} /** * Traverses a collection calling the callback to generate its HTML @@ -213,7 +227,15 @@ public function collectionResourcesByType(array $resources, $type) {} * @param string $type * @return string|null */ - public function output(\Phalcon\Assets\Collection $collection, $callback, $type) {} + public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string {} + + /** + * Prints the HTML for CSS assets + * + * @param string $collectionName + * @return string + */ + public function outputCss(string $collectionName = null): string {} /** * Traverses a collection and generate its HTML @@ -222,60 +244,75 @@ public function output(\Phalcon\Assets\Collection $collection, $callback, $type) * @param string $type * @return string */ - public function outputInline(\Phalcon\Assets\Collection $collection, $type) {} + public function outputInline(\Phalcon\Assets\Collection $collection, $type): string {} /** - * Prints the HTML for CSS resources + * Prints the HTML for inline CSS * * @param string $collectionName * @return string */ - public function outputCss($collectionName = null) {} + public function outputInlineCss(string $collectionName = null): string {} /** - * Prints the HTML for inline CSS + * Prints the HTML for inline JS * * @param string $collectionName * @return string */ - public function outputInlineCss($collectionName = null) {} + public function outputInlineJs(string $collectionName = null): string {} /** - * Prints the HTML for JS resources + * Prints the HTML for JS assets * * @param string $collectionName * @return string */ - public function outputJs($collectionName = null) {} + public function outputJs(string $collectionName = null): string {} /** - * Prints the HTML for inline JS + * Sets a collection in the Assets Manager * - * @param string $collectionName - * @return string + * ```php + * $assets->set("js", $collection); + * ``` + * + * @param string $id + * @param \Phalcon\Assets\Collection $collection + * @return Manager */ - public function outputInlineJs($collectionName = null) {} + public function set(string $id, \Phalcon\Assets\Collection $collection): Manager {} /** - * Returns existing collections in the manager + * Sets the dependency injector * - * @return \Phalcon\Assets\Collection[] + * @param \Phalcon\Di\DiInterface $container */ - public function getCollections() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns true or false if collection exists. + * Sets the manager options * - * - * if ($assets->exists("jsHeader")) { - * // \Phalcon\Assets\Collection - * $collection = $assets->get("jsHeader"); - * } - * + * @param array $options + * @return Manager + */ + public function setOptions(array $options): Manager {} + + /** + * Sets if the HTML generated must be directly printed or returned * - * @param string $id - * @return bool + * @param bool $implicitOutput + * @return Manager + */ + public function useImplicitOutput(bool $implicitOutput): Manager {} + + /** + * Returns the prefixed path + * + * @param \Phalcon\Assets\Collection $collection + * @param string $path + * @return string */ - public function exists($id) {} + private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string {} } diff --git a/src/Phalcon/assets/Resource.php b/src/Phalcon/assets/Resource.php deleted file mode 100644 index 82a0acf8..00000000 --- a/src/Phalcon/assets/Resource.php +++ /dev/null @@ -1,199 +0,0 @@ - - * $resource = new \Phalcon\Assets\Resource("js", "javascripts/jquery.js"); - * - */ -class Resource implements \Phalcon\Assets\ResourceInterface -{ - /** - * @var string - */ - protected $_type; - - /** - * @var string - */ - protected $_path; - - /** - * @var boolean - */ - protected $_local; - - /** - * @var bool - */ - protected $_filter; - - /** - * @var array | null - */ - protected $_attributes; - - - protected $_sourcePath; - - - protected $_targetPath; - - - protected $_targetUri; - - - /** - * @return string - */ - public function getType() {} - - /** - * @return string - */ - public function getPath() {} - - /** - * @return boolean - */ - public function getLocal() {} - - /** - * @return bool - */ - public function getFilter() {} - - /** - * @return array|null - */ - public function getAttributes() {} - - - public function getSourcePath() {} - - - public function getTargetPath() {} - - - public function getTargetUri() {} - - /** - * Phalcon\Assets\Resource constructor - * - * @param string $type - * @param string $path - * @param boolean $local - * @param boolean $filter - * @param array $attributes - */ - public function __construct($type, $path, $local = true, $filter = true, $attributes = null) {} - - /** - * Sets the resource's type - * - * @param string $type - * @return ResourceInterface - */ - public function setType($type) {} - - /** - * Sets the resource's path - * - * @param string $path - * @return Resource - */ - public function setPath($path) {} - - /** - * Sets if the resource is local or external - * - * @param bool $local - * @return Resource - */ - public function setLocal($local) {} - - /** - * Sets if the resource must be filtered or not - * - * @param bool $filter - * @return ResourceInterface - */ - public function setFilter($filter) {} - - /** - * Sets extra HTML attributes - * - * @param array $attributes - * @return ResourceInterface - */ - public function setAttributes(array $attributes) {} - - /** - * Sets a target uri for the generated HTML - * - * @param string $targetUri - * @return Resource - */ - public function setTargetUri($targetUri) {} - - /** - * Sets the resource's source path - * - * @param string $sourcePath - * @return Resource - */ - public function setSourcePath($sourcePath) {} - - /** - * Sets the resource's target path - * - * @param string $targetPath - * @return Resource - */ - public function setTargetPath($targetPath) {} - - /** - * Returns the content of the resource as an string - * Optionally a base path where the resource is located can be set - * - * @param string $basePath - * @return string - */ - public function getContent($basePath = null) {} - - /** - * Returns the real target uri for the generated HTML - * - * @return string - */ - public function getRealTargetUri() {} - - /** - * Returns the complete location where the resource is located - * - * @param string $basePath - * @return string - */ - public function getRealSourcePath($basePath = null) {} - - /** - * Returns the complete location where the resource must be written - * - * @param string $basePath - * @return string - */ - public function getRealTargetPath($basePath = null) {} - - /** - * Gets the resource's key. - * - * @return string - */ - public function getResourceKey() {} - -} diff --git a/src/Phalcon/assets/ResourceInterface.php b/src/Phalcon/assets/ResourceInterface.php deleted file mode 100644 index c34ad4b7..00000000 --- a/src/Phalcon/assets/ResourceInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * use Phalcon\Cache\Frontend\Data as DataFrontend; - * use Phalcon\Cache\Multiple; - * use Phalcon\Cache\Backend\Apc as ApcCache; - * use Phalcon\Cache\Backend\Memcache as MemcacheCache; - * use Phalcon\Cache\Backend\File as FileCache; - * - * $ultraFastFrontend = new DataFrontend( - * [ - * "lifetime" => 3600, - * ] - * ); - * - * $fastFrontend = new DataFrontend( - * [ - * "lifetime" => 86400, - * ] - * ); - * - * $slowFrontend = new DataFrontend( - * [ - * "lifetime" => 604800, - * ] - * ); - * - * //Backends are registered from the fastest to the slower - * $cache = new Multiple( - * [ - * new ApcCache( - * $ultraFastFrontend, - * [ - * "prefix" => "cache", - * ] - * ), - * new MemcacheCache( - * $fastFrontend, - * [ - * "prefix" => "cache", - * "host" => "localhost", - * "port" => "11211", - * ] - * ), - * new FileCache( - * $slowFrontend, - * [ - * "prefix" => "cache", - * "cacheDir" => "../app/cache/", - * ] - * ), - * ] - * ); - * - * //Save, saves in every backend - * $cache->save("my-key", $data); - * - */ -class Multiple -{ - - protected $_backends; - - - /** - * Phalcon\Cache\Multiple constructor - * - * @param Phalcon\Cache\BackendInterface[] backends - * @param mixed $backends - */ - public function __construct($backends = null) {} - - /** - * Adds a backend - * - * @param \Phalcon\Cache\BackendInterface $backend - * @return Multiple - */ - public function push(\Phalcon\Cache\BackendInterface $backend) {} - - /** - * Returns a cached content reading the internal backends - * - * @param string|int $keyName - * @param int $lifetime - * @return mixed - */ - public function get($keyName, $lifetime = null) {} - - /** - * Starts every backend - * - * @param string|int $keyName - * @param int $lifetime - */ - public function start($keyName, $lifetime = null) {} - - /** - * Stores cached content into all backends and stops the frontend - * - * @param string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = null) {} - - /** - * Deletes a value from each backend - * - * @param string|int $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Checks if cache exists in at least one backend - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Flush all backend(s) - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php new file mode 100644 index 00000000..0acab0d8 --- /dev/null +++ b/src/Phalcon/cache/adapter/AdapterInterface.php @@ -0,0 +1,11 @@ + - * use Phalcon\Cache\Backend\Apc; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Apc( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - * - * @see \Phalcon\Cache\Backend\Apcu - * @deprecated - */ -class Apc extends \Phalcon\Cache\Backend -{ - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the APC backend and stops the frontend - * - * @param string|int $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Immediately invalidates all existing items. - * - * - * use Phalcon\Cache\Backend\Apc; - * - * $cache = new Apc($frontCache, ["prefix" => "app-data"]); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Apcu.php b/src/Phalcon/cache/backend/Apcu.php deleted file mode 100644 index 66151d00..00000000 --- a/src/Phalcon/cache/backend/Apcu.php +++ /dev/null @@ -1,126 +0,0 @@ - - * use Phalcon\Cache\Backend\Apcu; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Apcu( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Apcu extends \Phalcon\Cache\Backend -{ - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the APCu backend and stops the frontend - * - * @param string|int $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Immediately invalidates all existing items. - * - * - * use Phalcon\Cache\Backend\Apcu; - * - * $cache = new Apcu($frontCache, ["prefix" => "app-data"]); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Factory.php b/src/Phalcon/cache/backend/Factory.php deleted file mode 100644 index ffb31f6b..00000000 --- a/src/Phalcon/cache/backend/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ - - * use Phalcon\Cache\Backend\Factory; - * use Phalcon\Cache\Frontend\Data; - * - * $options = [ - * "prefix" => "app-data", - * "frontend" => new Data(), - * "adapter" => "apc", - * ]; - * $backendCache = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Cache\BackendInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/cache/backend/File.php b/src/Phalcon/cache/backend/File.php deleted file mode 100644 index 06837215..00000000 --- a/src/Phalcon/cache/backend/File.php +++ /dev/null @@ -1,152 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Output as FrontOutput; - * - * // Cache the file for 2 days - * $frontendOptions = [ - * "lifetime" => 172800, - * ]; - * - * // Create an output cache - * $frontCache = FrontOutput($frontOptions); - * - * // Set the cache directory - * $backendOptions = [ - * "cacheDir" => "../app/cache/", - * ]; - * - * // Create the File backend - * $cache = new File($frontCache, $backendOptions); - * - * $content = $cache->start("my-cache"); - * - * if ($content === null) { - * echo "

", time(), "

"; - * - * $cache->save(); - * } else { - * echo $content; - * } - * - */ -class File extends \Phalcon\Cache\Backend -{ - /** - * Default to false for backwards compatibility - * - * @var boolean - */ - private $_useSafeKey = false; - - - /** - * Phalcon\Cache\Backend\File constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, array $options) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of a given key, by number $value - * - * @param string|int $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of a given key, by number $value - * - * @param string|int $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - - /** - * Return a file-system safe identifier for a given key - * - * @param mixed $key - * @return string - */ - public function getKey($key) {} - - /** - * Set whether to use the safekey or not - * - * @param bool $useSafeKey - * @return File - */ - public function useSafeKey($useSafeKey) {} - -} diff --git a/src/Phalcon/cache/backend/Libmemcached.php b/src/Phalcon/cache/backend/Libmemcached.php deleted file mode 100644 index 89bb77a9..00000000 --- a/src/Phalcon/cache/backend/Libmemcached.php +++ /dev/null @@ -1,162 +0,0 @@ - - * use Phalcon\Cache\Backend\Libmemcached; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new Libmemcached( - * $frontCache, - * [ - * "servers" => [ - * [ - * "host" => "127.0.0.1", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * \Memcached::OPT_HASH => \Memcached::HASH_MD5, - * \Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Libmemcached extends \Phalcon\Cache\Backend -{ - - protected $_memcache = null; - - - /** - * Phalcon\Cache\Backend\Memcache constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to memcached - */ - public function _connect() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * Memcached does not support flush() per default. If you require flush() support, set $config["statsKey"]. - * All modified keys are stored in "statsKey". Note: statsKey has a negative performance impact. - * - * - * $cache = new \Phalcon\Cache\Backend\Libmemcached( - * $frontCache, - * [ - * "statsKey" => "_PHCM", - * ] - * ); - * - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // 'my-data' and all other used keys are deleted - * $cache->flush(); - * - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Memcache.php b/src/Phalcon/cache/backend/Memcache.php deleted file mode 100644 index 446c7c63..00000000 --- a/src/Phalcon/cache/backend/Memcache.php +++ /dev/null @@ -1,148 +0,0 @@ - - * use Phalcon\Cache\Backend\Memcache; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new Memcache( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Memcache extends \Phalcon\Cache\Backend -{ - - protected $_memcache = null; - - - /** - * Phalcon\Cache\Backend\Memcache constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to memcached - */ - public function _connect() {} - - /** - * Add servers to memcache pool - * - * @param string $host - * @param int $port - * @param bool $persistent - * @return bool - */ - public function addServers($host, $port, $persistent = false) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|bool - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Memory.php b/src/Phalcon/cache/backend/Memory.php deleted file mode 100644 index f4ca7853..00000000 --- a/src/Phalcon/cache/backend/Memory.php +++ /dev/null @@ -1,123 +0,0 @@ - - * use Phalcon\Cache\Backend\Memory; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data - * $frontCache = new FrontData(); - * - * $cache = new Memory($frontCache); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Memory extends \Phalcon\Cache\Backend implements \Serializable -{ - - protected $_data; - - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the backend and stops the frontend - * - * @param string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it hasn't expired - * - * @param string|int $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - - /** - * Required for interface \Serializable - * - * @return string - */ - public function serialize() {} - - /** - * Required for interface \Serializable - * - * @param mixed $data - */ - public function unserialize($data) {} - -} diff --git a/src/Phalcon/cache/backend/Mongo.php b/src/Phalcon/cache/backend/Mongo.php deleted file mode 100644 index fe92cb29..00000000 --- a/src/Phalcon/cache/backend/Mongo.php +++ /dev/null @@ -1,146 +0,0 @@ - - * use Phalcon\Cache\Backend\Mongo; - * use Phalcon\Cache\Frontend\Base64; - * - * // Cache data for 2 days - * $frontCache = new Base64( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create a MongoDB cache - * $cache = new Mongo( - * $frontCache, - * [ - * "server" => "mongodb://localhost", - * "db" => "caches", - * "collection" => "images", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save( - * "my-data", - * file_get_contents("some-image.jpg") - * ); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Mongo extends \Phalcon\Cache\Backend -{ - - protected $_collection = null; - - - /** - * Phalcon\Cache\Backend\Mongo constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Returns a MongoDb collection based on the backend parameters - * - * @return MongoCollection - */ - protected final function _getCollection() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * gc - * - * @return collection->remove(...) - */ - public function gc() {} - - /** - * Increment of a given key by $value - * - * @param int|string $keyName - * @param int $value - * @return int|null - */ - public function increment($keyName, $value = 1) {} - - /** - * Decrement of a given key by $value - * - * @param int|string $keyName - * @param int $value - * @return int|null - */ - public function decrement($keyName, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Redis.php b/src/Phalcon/cache/backend/Redis.php deleted file mode 100644 index 731df280..00000000 --- a/src/Phalcon/cache/backend/Redis.php +++ /dev/null @@ -1,147 +0,0 @@ - - * use Phalcon\Cache\Backend\Redis; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the Cache setting redis connection options - * $cache = new Redis( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 6379, - * "auth" => "foobared", - * "persistent" => false, - * "index" => 0, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Redis extends \Phalcon\Cache\Backend -{ - - protected $_redis = null; - - - /** - * Phalcon\Cache\Backend\Redis constructor - * - * @param Phalcon\Cache\FrontendInterface frontend - * @param array options - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param mixed $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Create internal connection to redis - */ - public function _connect() {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * - * $cache->save("my-key", $data); - * - * // Save data termlessly - * $cache->save("my-key", $data, -1); - * - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return bool - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Increment of given $keyName by $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function increment($keyName = null, $value = 1) {} - - /** - * Decrement of $keyName by given $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function decrement($keyName = null, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/backend/Xcache.php b/src/Phalcon/cache/backend/Xcache.php deleted file mode 100644 index f1ef2761..00000000 --- a/src/Phalcon/cache/backend/Xcache.php +++ /dev/null @@ -1,123 +0,0 @@ - - * use Phalcon\Cache\Backend\Xcache; - * use Phalcon\Cache\Frontend\Data as FrontData; - * - * // Cache data for 2 days - * $frontCache = new FrontData( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * $cache = new Xcache( - * $frontCache, - * [ - * "prefix" => "app-data", - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Xcache extends \Phalcon\Cache\Backend -{ - - /** - * Phalcon\Cache\Backend\Xcache constructor - * - * @param \Phalcon\Cache\FrontendInterface $frontend - * @param array $options - */ - public function __construct(\Phalcon\Cache\FrontendInterface $frontend, $options = null) {} - - /** - * Returns a cached content - * - * @param string $keyName - * @param int $lifetime - * @return mixed|null - */ - public function get($keyName, $lifetime = null) {} - - /** - * Stores cached content into the file backend and stops the frontend - * - * @param int|string $keyName - * @param string $content - * @param int $lifetime - * @param boolean $stopBuffer - * @return bool - */ - public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true) {} - - /** - * Deletes a value from the cache by its key - * - * @param int|string $keyName - * @return boolean - */ - public function delete($keyName) {} - - /** - * Query the existing cached keys. - * - * - * $cache->save("users-ids", [1, 2, 3]); - * $cache->save("projects-ids", [4, 5, 6]); - * - * var_dump($cache->queryKeys("users")); // ["users-ids"] - * - * - * @param string $prefix - * @return array - */ - public function queryKeys($prefix = null) {} - - /** - * Checks if cache exists and it isn't expired - * - * @param string $keyName - * @param int $lifetime - * @return bool - */ - public function exists($keyName = null, $lifetime = null) {} - - /** - * Atomic increment of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function increment($keyName, $value = 1) {} - - /** - * Atomic decrement of a given key, by number $value - * - * @param string $keyName - * @param int $value - * @return int - */ - public function decrement($keyName, $value = 1) {} - - /** - * Immediately invalidates all existing items. - * - * @return bool - */ - public function flush() {} - -} diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php new file mode 100644 index 00000000..cd483e0a --- /dev/null +++ b/src/Phalcon/cache/exception/Exception.php @@ -0,0 +1,11 @@ + - * 172800, - * ] - * ); - * - * //Create a MongoDB cache - * $cache = new \Phalcon\Cache\Backend\Mongo( - * $frontCache, - * [ - * "server" => "mongodb://localhost", - * "db" => "caches", - * "collection" => "images", - * ] - * ); - * - * $cacheKey = "some-image.jpg.cache"; - * - * // Try to get cached image - * $image = $cache->get($cacheKey); - * - * if ($image === null) { - * // Store the image in the cache - * $cache->save( - * $cacheKey, - * file_get_contents("tmp-dir/some-image.jpg") - * ); - * } - * - * header("Content-Type: image/jpeg"); - * - * echo $image; - * - */ -class Base64 implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Base64 constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing in this adapter - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Data.php b/src/Phalcon/cache/frontend/Data.php deleted file mode 100644 index 4ea0ef05..00000000 --- a/src/Phalcon/cache/frontend/Data.php +++ /dev/null @@ -1,114 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Data; - * - * // Cache the files for 2 days using a Data frontend - * $frontCache = new Data( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Data" to a 'File' backend - * // Set the cache file directory - important to keep the '/' at the end of - * // of the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data does not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Data implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Data constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Factory.php b/src/Phalcon/cache/frontend/Factory.php deleted file mode 100644 index 61fd18e3..00000000 --- a/src/Phalcon/cache/frontend/Factory.php +++ /dev/null @@ -1,33 +0,0 @@ - - * use Phalcon\Cache\Frontend\Factory; - * - * $options = [ - * "lifetime" => 172800, - * "adapter" => "data", - * ]; - * $frontendCache = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Cache\FrontendInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/cache/frontend/Igbinary.php b/src/Phalcon/cache/frontend/Igbinary.php deleted file mode 100644 index 3b366e4f..00000000 --- a/src/Phalcon/cache/frontend/Igbinary.php +++ /dev/null @@ -1,109 +0,0 @@ - - * // Cache the files for 2 days using Igbinary frontend - * $frontCache = new \Phalcon\Cache\Frontend\Igbinary( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Igbinary" to a "File" backend - * // Set the cache file directory - important to keep the "/" at the end of - * // of the value for the folder - * $cache = new \Phalcon\Cache\Backend\File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data do not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Igbinary extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Phalcon\Cache\Frontend\Data constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Json.php b/src/Phalcon/cache/frontend/Json.php deleted file mode 100644 index 05bf6fc5..00000000 --- a/src/Phalcon/cache/frontend/Json.php +++ /dev/null @@ -1,102 +0,0 @@ - - * 172800, - * ] - * ); - * - * // Create the Cache setting memcached connection options - * $cache = new \Phalcon\Cache\Backend\Memcache( - * $frontCache, - * [ - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - * // Cache arbitrary data - * $cache->save("my-data", [1, 2, 3, 4, 5]); - * - * // Get data - * $data = $cache->get("my-data"); - * - */ -class Json implements \Phalcon\Cache\FrontendInterface -{ - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Base64 constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Msgpack.php b/src/Phalcon/cache/frontend/Msgpack.php deleted file mode 100644 index 66bb57fe..00000000 --- a/src/Phalcon/cache/frontend/Msgpack.php +++ /dev/null @@ -1,115 +0,0 @@ - - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Msgpack; - * - * // Cache the files for 2 days using Msgpack frontend - * $frontCache = new Msgpack( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache "Msgpack" to a "File" backend - * // Set the cache file directory - important to keep the "/" at the end of - * // of the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // Try to get cached records - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // $robots is null due to cache expiration or data do not exist - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * // Store it in the cache - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class Msgpack extends \Phalcon\Cache\Frontend\Data implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Phalcon\Cache\Frontend\Msgpack constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Actually, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return null - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/None.php b/src/Phalcon/cache/frontend/None.php deleted file mode 100644 index acce1cd2..00000000 --- a/src/Phalcon/cache/frontend/None.php +++ /dev/null @@ -1,98 +0,0 @@ - - * "localhost", - * "port" => "11211", - * ] - * ); - * - * $cacheKey = "robots_order_id.cache"; - * - * // This Frontend always return the data as it's returned by the backend - * $robots = $cache->get($cacheKey); - * - * if ($robots === null) { - * // This cache doesn't perform any expiration checking, so the data is always expired - * // Make the database call and populate the variable - * $robots = Robots::find( - * [ - * "order" => "id", - * ] - * ); - * - * $cache->save($cacheKey, $robots); - * } - * - * // Use $robots :) - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - */ -class None implements \Phalcon\Cache\FrontendInterface -{ - - /** - * Returns cache lifetime, always one second expiring content - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output, always false - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Prepare data to be stored - * - * @param mixed $data - */ - public function beforeStore($data) {} - - /** - * Prepares data to be retrieved to user - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cache/frontend/Output.php b/src/Phalcon/cache/frontend/Output.php deleted file mode 100644 index eddcb223..00000000 --- a/src/Phalcon/cache/frontend/Output.php +++ /dev/null @@ -1,120 +0,0 @@ - - * use Phalcon\Tag; - * use Phalcon\Cache\Backend\File; - * use Phalcon\Cache\Frontend\Output; - * - * // Create an Output frontend. Cache the files for 2 days - * $frontCache = new Output( - * [ - * "lifetime" => 172800, - * ] - * ); - * - * // Create the component that will cache from the "Output" to a "File" backend - * // Set the cache file directory - it's important to keep the "/" at the end of - * // the value for the folder - * $cache = new File( - * $frontCache, - * [ - * "cacheDir" => "../app/cache/", - * ] - * ); - * - * // Get/Set the cache file to ../app/cache/my-cache.html - * $content = $cache->start("my-cache.html"); - * - * // If $content is null then the content will be generated for the cache - * if (null === $content) { - * // Print date and time - * echo date("r"); - * - * // Generate a link to the sign-up action - * echo Tag::linkTo( - * [ - * "user/signup", - * "Sign Up", - * "class" => "signup-button", - * ] - * ); - * - * // Store the output into the cache file - * $cache->save(); - * } else { - * // Echo the cached output - * echo $content; - * } - * - */ -class Output implements \Phalcon\Cache\FrontendInterface -{ - - protected $_buffering = false; - - - protected $_frontendOptions; - - - /** - * Phalcon\Cache\Frontend\Output constructor - * - * @param array $frontendOptions - */ - public function __construct($frontendOptions = null) {} - - /** - * Returns the cache lifetime - * - * @return int - */ - public function getLifetime() {} - - /** - * Check whether if frontend is buffering output - * - * @return bool - */ - public function isBuffering() {} - - /** - * Starts output frontend. Currently, does nothing - */ - public function start() {} - - /** - * Returns output cached content - * - * @return string - */ - public function getContent() {} - - /** - * Stops output frontend - */ - public function stop() {} - - /** - * Serializes data before storing them - * - * @param mixed $data - * @return string - */ - public function beforeStore($data) {} - - /** - * Unserializes data after retrieval - * - * @param mixed $data - * @return mixed - */ - public function afterRetrieve($data) {} - -} diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 01123b6d..2da7a60c 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -3,37 +3,20 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Console - * * This component allows to create CLI applications using Phalcon */ -class Console extends \Phalcon\Application +class Console extends \Phalcon\Application\AbstractApplication { - - protected $_arguments = array(); - - - protected $_options = array(); - + /** + * @var array + */ + protected $arguments = array(); /** - * Merge modules with the existing ones - * - * - * $application->addModules( - * [ - * "admin" => [ - * "className" => "Multiple\\Admin\\Module", - * "path" => "../apps/admin/Module.php", - * ], - * ] - * ); - * - * - * @param array $modules - * @deprecated + * @var array */ - public function addModules(array $modules) {} + protected $options = array(); + /** * Handle the whole command-line tasks @@ -50,6 +33,6 @@ public function handle(array $arguments = null) {} * @param bool $shift * @return Console */ - public function setArgument(array $arguments = null, $str = true, $shift = true) {} + public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console {} } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index 28f105ea..3771ce22 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -3,18 +3,18 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Dispatcher + * Dispatching is the process of taking the command-line arguments, extracting + * the module name, task name, action name, and optional parameters contained in + * it, and then instantiating a task and calling an action on it. * - * Dispatching is the process of taking the command-line arguments, extracting the module name, - * task name, action name, and optional parameters contained in it, and then - * instantiating a task and calling an action on it. - * - * + * ```php * use Phalcon\Di; * use Phalcon\Cli\Dispatcher; * * $di = new Di(); + * * $dispatcher = new Dispatcher(); + * * $dispatcher->setDi($di); * * $dispatcher->setTaskName("posts"); @@ -22,79 +22,100 @@ * $dispatcher->setParams([]); * * $handle = $dispatcher->dispatch(); - * + * ``` */ -class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface { + /** + * @var string + */ + protected $defaultHandler = 'main'; - protected $_handlerSuffix = 'Task'; - - - protected $_defaultHandler = 'main'; - + /** + * @var string + */ + protected $defaultAction = 'main'; - protected $_defaultAction = 'main'; + /** + * @var string + */ + protected $handlerSuffix = 'Task'; + /** + * @var array + */ + protected $options = array(); - protected $_options = array(); + /** + * Calls the action method. + * + * @param mixed $handler + * @param string $actionMethod + * @param array $params + * @return mixed + */ + public function callActionMethod($handler, string $actionMethod, array $params = array()) {} /** - * Sets the default task suffix + * Returns the active task in the dispatcher * - * @param string $taskSuffix + * @return TaskInterface */ - public function setTaskSuffix($taskSuffix) {} + public function getActiveTask(): TaskInterface {} /** - * Sets the default task name + * Returns the latest dispatched controller * - * @param string $taskName + * @return TaskInterface */ - public function setDefaultTask($taskName) {} + public function getLastTask(): TaskInterface {} /** - * Sets the task name to be dispatched + * Gets an option by its name or numeric index * - * @param string $taskName + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setTaskName($taskName) {} + public function getOption($option, $filters = null, $defaultValue = null) {} /** - * Gets last dispatched task name + * Get dispatched options * - * @return string + * @return array */ - public function getTaskName() {} + public function getOptions(): array {} /** - * Throws an internal exception + * Gets last dispatched task name * - * @param string $message - * @param int $exceptionCode + * @return string */ - protected function _throwDispatchException($message, $exceptionCode = 0) {} + public function getTaskName(): string {} /** - * Handles a user exception + * Gets the default task suffix * - * @param \Exception $exception + * @return string */ - protected function _handleException(\Exception $exception) {} + public function getTaskSuffix(): string {} /** - * Returns the latest dispatched controller + * Check if an option exists * - * @return TaskInterface + * @param mixed $option + * @return bool */ - public function getLastTask() {} + public function hasOption($option): bool {} /** - * Returns the active task in the dispatcher + * Sets the default task name * - * @return TaskInterface + * @param string $taskName */ - public function getActiveTask() {} + public function setDefaultTask(string $taskName) {} /** * Set the options to be dispatched @@ -104,38 +125,32 @@ public function getActiveTask() {} public function setOptions(array $options) {} /** - * Get dispatched options + * Sets the task name to be dispatched * - * @return array + * @param string $taskName */ - public function getOptions() {} + public function setTaskName(string $taskName) {} /** - * Gets an option by its name or numeric index + * Sets the default task suffix * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @param string $taskSuffix */ - public function getOption($option, $filters = null, $defaultValue = null) {} + public function setTaskSuffix(string $taskSuffix) {} /** - * Check if an option exists + * Handles a user exception * - * @param mixed $option - * @return bool + * @param \Exception $exception */ - public function hasOption($option) {} + protected function handleException(\Exception $exception) {} /** - * Calls the action method. + * Throws an internal exception * - * @param mixed $handler - * @param string $actionMethod - * @param array $params - * @return mixed + * @param string $message + * @param int $exceptionCode */ - public function callActionMethod($handler, $actionMethod, array $params = array()) {} + protected function throwDispatchException(string $message, int $exceptionCode = 0) {} } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index 99a31ecc..eed77c38 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -3,53 +3,72 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\DispatcherInterface - * * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends \Phalcon\DispatcherInterface +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** - * Sets the default task suffix + * Returns the active task in the dispatcher * - * @param string $taskSuffix + * @return TaskInterface */ - public function setTaskSuffix($taskSuffix); + public function getActiveTask(): TaskInterface; /** - * Sets the default task name + * Returns the latest dispatched controller * - * @param string $taskName + * @return TaskInterface */ - public function setDefaultTask($taskName); + public function getLastTask(): TaskInterface; /** - * Sets the task name to be dispatched + * Get dispatched options * - * @param string $taskName + * @return array */ - public function setTaskName($taskName); + public function getOptions(): array; /** * Gets last dispatched task name * * @return string */ - public function getTaskName(); + public function getTaskName(): string; /** - * Returns the latest dispatched controller + * Gets default task suffix * - * @return TaskInterface + * @return string */ - public function getLastTask(); + public function getTaskSuffix(): string; /** - * Returns the active task in the dispatcher + * Sets the default task name * - * @return TaskInterface + * @param string $taskName + */ + public function setDefaultTask(string $taskName); + + /** + * Set the options to be dispatched + * + * @param array $options + */ + public function setOptions(array $options); + + /** + * Sets the task name to be dispatched + * + * @param string $taskName + */ + public function setTaskName(string $taskName); + + /** + * Sets the default task suffix + * + * @param string $taskSuffix */ - public function getActiveTask(); + public function setTaskSuffix(string $taskSuffix); } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 09c0cf0c..541e64b1 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -3,14 +3,12 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Router + * Phalcon\Cli\Router is the standard framework router. Routing is the process + * of taking a command-line arguments and decomposing it into parameters to + * determine which module, task, and action of that task should receive the + * request. * - *

Phalcon\Cli\Router is the standard framework router. Routing is the - * process of taking a command-line arguments and - * decomposing it into parameters to determine which module, task, and - * action of that task should receive the request

- * - * + * ```php * $router = new \Phalcon\Cli\Router(); * * $router->handle( @@ -22,48 +20,52 @@ * ); * * echo $router->getTaskName(); - * + * ``` */ class Router implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $action; - protected $_module; + protected $container; - protected $_task; + protected $defaultAction = null; - protected $_action; + protected $defaultModule = null; - protected $_params = array(); - + /** + * @var array + */ + protected $defaultParams = array(); - protected $_defaultModule = null; + protected $defaultTask = null; - protected $_defaultTask = null; + protected $matchedRoute; - protected $_defaultAction = null; + protected $matches; - protected $_defaultParams = array(); + protected $module; - protected $_routes; + /** + * @var array + */ + protected $params = array(); - protected $_matchedRoute; + protected $routes; - protected $_matches; + protected $task; - protected $_wasMatched = false; + protected $wasMatched = false; /** @@ -71,151 +73,152 @@ class Router implements \Phalcon\Di\InjectionAwareInterface * * @param bool $defaultRoutes */ - public function __construct($defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) {} /** - * Sets the dependency injector + * Adds a route to the router + * + * ```php + * $router->add("/about", "About::main"); + * ``` * - * @param \Phalcon\DiInterface $dependencyInjector + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function add(string $pattern, $paths = null): RouteInterface {} /** - * Returns the internal dependency injector + * Returns processed action name * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getActionName(): string {} /** - * Sets the name of the default module + * Returns the internal dependency injector * - * @param string $moduleName + * @return \Phalcon\Di\DiInterface */ - public function setDefaultModule($moduleName) {} + public function getDI(): DiInterface {} /** - * Sets the default controller name + * Returns the route that matches the handled URI * - * @param string $taskName + * @return RouteInterface */ - public function setDefaultTask($taskName) {} + public function getMatchedRoute(): RouteInterface {} /** - * Sets the default action name + * Returns the sub expressions in the regular expression matched * - * @param string $actionName + * @return array */ - public function setDefaultAction($actionName) {} + public function getMatches(): array {} /** - * Sets an array of default paths. If a route is missing a path the router will use the defined here - * This method must not be used to set a 404 route - * - * - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * + * Returns processed module name * - * @param array $defaults - * @return Router + * @return string */ - public function setDefaults(array $defaults) {} + public function getModuleName(): string {} /** - * Handles routing information received from command-line arguments + * Returns processed extra params * - * @param array $arguments + * @return array */ - public function handle($arguments = null) {} + public function getParams(): array {} /** - * Adds a route to the router - * - * - * $router->add("/about", "About::main"); - * + * Returns a route object by its id * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @param int $id + * @return bool|RouteInterface */ - public function add($pattern, $paths = null) {} + public function getRouteById($id) {} /** - * Returns processed module name + * Returns a route object by its name * - * @return string + * @param string $name + * @return bool|RouteInterface */ - public function getModuleName() {} + public function getRouteByName(string $name) {} /** - * Returns processed task name + * Returns all the routes defined in the router * - * @return string + * @return array|\Phalcon\Cli\Router\Route[] */ - public function getTaskName() {} + public function getRoutes(): array {} /** - * Returns processed action name + * Returns processed task name * * @return string */ - public function getActionName() {} + public function getTaskName(): string {} /** - * Returns processed extra params + * Handles routing information received from command-line arguments * - * @return array + * @param array $arguments */ - public function getParams() {} + public function handle($arguments = null) {} /** - * Returns the route that matches the handled URI + * Sets the default action name * - * @return RouteInterface + * @param string $actionName */ - public function getMatchedRoute() {} + public function setDefaultAction(string $actionName) {} /** - * Returns the sub expressions in the regular expression matched + * Sets the name of the default module * - * @return array + * @param string $moduleName */ - public function getMatches() {} + public function setDefaultModule(string $moduleName) {} /** - * Checks if the router matches any of the defined routes + * Sets an array of default paths. If a route is missing a path the router + * will use the defined here. This method must not be used to set a 404 + * route * - * @return bool + * ```php + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * ``` + * + * @param array $defaults + * @return Router */ - public function wasMatched() {} + public function setDefaults(array $defaults): Router {} /** - * Returns all the routes defined in the router + * Sets the default controller name * - * @return \Phalcon\Cli\Router\Route[] + * @param string $taskName */ - public function getRoutes() {} + public function setDefaultTask(string $taskName) {} /** - * Returns a route object by its id + * Sets the dependency injector * - * @param int $id - * @return bool|RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getRouteById($id) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns a route object by its name + * Checks if the router matches any of the defined routes * - * @param string $name - * @return bool|RouteInterface + * @return bool */ - public function getRouteByName($name) {} + public function wasMatched(): bool {} } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 1d28c053..7f3d4abe 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -3,127 +3,125 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\RouterInterface - * * Interface for Phalcon\Cli\Router */ interface RouterInterface { /** - * Sets the name of the default module + * Adds a route to the router on any HTTP method * - * @param string $moduleName + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Cli\Router\RouteInterface */ - public function setDefaultModule($moduleName); + public function add(string $pattern, $paths = null): RouteInterface; /** - * Sets the default task name + * Returns processed action name * - * @param string $taskName + * @return string */ - public function setDefaultTask($taskName); + public function getActionName(): string; /** - * Sets the default action name + * Returns the route that matches the handled URI * - * @param string $actionName + * @return \Phalcon\Cli\Router\RouteInterface */ - public function setDefaultAction($actionName); + public function getMatchedRoute(): RouteInterface; /** - * Sets an array of default paths + * Return the sub expressions in the regular expression matched * - * @param array $defaults + * @return array */ - public function setDefaults(array $defaults); + public function getMatches(): array; /** - * Handles routing information received from the rewrite engine + * Returns processed module name * - * @param array $arguments + * @return string */ - public function handle($arguments = null); + public function getModuleName(): string; /** - * Adds a route to the router on any HTTP method + * Returns processed extra params * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Cli\Router\RouteInterface + * @return array */ - public function add($pattern, $paths = null); + public function getParams(): array; /** - * Returns processed module name + * Returns a route object by its id * - * @return string + * @param mixed $id + * @return \Phalcon\Cli\Router\RouteInterface */ - public function getModuleName(); + public function getRouteById($id): RouteInterface; /** - * Returns processed task name + * Returns a route object by its name * - * @return string + * @param string $name + * @return \Phalcon\Cli\Router\RouteInterface */ - public function getTaskName(); + public function getRouteByName(string $name): RouteInterface; /** - * Returns processed action name + * Return all the routes defined in the router * - * @return string + * @return array|\Phalcon\Cli\Router\RouteInterface[] */ - public function getActionName(); + public function getRoutes(): array; /** - * Returns processed extra params + * Returns processed task name * - * @return array + * @return string */ - public function getParams(); + public function getTaskName(): string; /** - * Returns the route that matches the handled URI + * Handles routing information received from the rewrite engine * - * @return \Phalcon\Cli\Router\RouteInterface + * @param array $arguments */ - public function getMatchedRoute(); + public function handle($arguments = null); /** - * Return the sub expressions in the regular expression matched + * Sets the default action name * - * @return array + * @param string $actionName */ - public function getMatches(); + public function setDefaultAction(string $actionName); /** - * Check if the router matches any of the defined routes + * Sets the name of the default module * - * @return bool + * @param string $moduleName */ - public function wasMatched(); + public function setDefaultModule(string $moduleName); /** - * Return all the routes defined in the router + * Sets an array of default paths * - * @return \Phalcon\Cli\Router\RouteInterface[] + * @param array $defaults */ - public function getRoutes(); + public function setDefaults(array $defaults); /** - * Returns a route object by its id + * Sets the default task name * - * @param mixed $id - * @return \Phalcon\Cli\Router\RouteInterface + * @param string $taskName */ - public function getRouteById($id); + public function setDefaultTask(string $taskName); /** - * Returns a route object by its name + * Check if the router matches any of the defined routes * - * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return bool */ - public function getRouteByName($name); + public function wasMatched(): bool; } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 038a6603..41ba3342 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -3,14 +3,14 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\Task + * Every command-line task should extend this class that encapsulates all the + * task functionality * - * Every command-line task should extend this class that encapsulates all the task functionality + * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, + * or anything that you want. The Task class should at least have a "mainAction" + * method. * - * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, or anything that you want. - * The Task class should at least have a "mainAction" method - * - * + * ```php * class HelloTask extends \Phalcon\Cli\Task * { * // This action will be executed by default @@ -24,7 +24,7 @@ * * } * } - * + * ``` */ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface { @@ -32,6 +32,6 @@ class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface /** * Phalcon\Cli\Task constructor */ - public final function __construct() {} + final public function __construct() {} } diff --git a/src/Phalcon/cli/TaskInterface.php b/src/Phalcon/cli/TaskInterface.php index 2b561c82..9ceb7d69 100644 --- a/src/Phalcon/cli/TaskInterface.php +++ b/src/Phalcon/cli/TaskInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli; /** - * Phalcon\Cli\TaskInterface - * * Interface for task handlers */ interface TaskInterface diff --git a/src/Phalcon/cli/console/Exception.php b/src/Phalcon/cli/console/Exception.php index 602a4879..09649fa2 100644 --- a/src/Phalcon/cli/console/Exception.php +++ b/src/Phalcon/cli/console/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Console; /** - * Phalcon\Cli\Console\Exception - * * Exceptions thrown in Phalcon\Cli\Console will use this class */ class Exception extends \Phalcon\Application\Exception diff --git a/src/Phalcon/cli/dispatcher/Exception.php b/src/Phalcon/cli/dispatcher/Exception.php index 416f26a6..d03f5450 100644 --- a/src/Phalcon/cli/dispatcher/Exception.php +++ b/src/Phalcon/cli/dispatcher/Exception.php @@ -3,11 +3,9 @@ namespace Phalcon\Cli\Dispatcher; /** - * Phalcon\Cli\Dispatcher\Exception - * * Exceptions thrown in Phalcon\Cli\Dispatcher will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Phalcon\Dispatcher\Exception { } diff --git a/src/Phalcon/cli/router/Exception.php b/src/Phalcon/cli/router/Exception.php index 6b6d0485..06f5a678 100644 --- a/src/Phalcon/cli/router/Exception.php +++ b/src/Phalcon/cli/router/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\Exception - * * Exceptions thrown in Phalcon\Cli\Router will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 5b5e8ca6..5e0e0997 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -3,8 +3,6 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\Route - * * This class represents every route added to the router */ class Route @@ -13,159 +11,166 @@ class Route const DEFAULT_DELIMITER = ' '; - protected $_pattern; + protected $beforeMatch; - protected $_compiledPattern; + protected $compiledPattern; - protected $_paths; + protected $converters; - protected $_converters; + protected $delimiter; - protected $_id; + static protected $delimiterPath = self::DEFAULT_DELIMITER; - protected $_name; + protected $description; - protected $_beforeMatch; + protected $id; - protected $_delimiter; + protected $name; - static protected $_uniqueId; + protected $paths; - static protected $_delimiterPath; + protected $pattern; + + + static protected $uniqueId = 0; /** - * Phalcon\Cli\Router\Route constructor - * * @param string $pattern - * @param array $paths + * @param array|string $paths */ - public function __construct($pattern, $paths = null) {} + public function __construct(string $pattern, $paths = null) {} /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @return string + * @param callback $callback + * @return RouteInterface */ - public function compilePattern($pattern) {} + public function beforeMatch($callback): RouteInterface {} /** - * Extracts parameters from a string + * Replaces placeholders from pattern returning a valid PCRE regular + * expression * * @param string $pattern - * @return array|boolean + * @return string */ - public function extractNamedParams($pattern) {} + public function compilePattern(string $pattern): string {} /** - * Reconfigure the route adding a new pattern and a set of paths + * Adds a converter to perform an additional transformation for certain + * parameter * - * @param string $pattern - * @param array $paths + * @param string $name + * @param callable $converter + * @return RouteInterface */ - public function reConfigure($pattern, $paths = null) {} + public function convert(string $name, $converter): RouteInterface {} /** - * Returns the route's name + * Set the routing delimiter * - * @return string + * @param string $delimiter */ - public function getName() {} + public static function delimiter(string $delimiter = null) {} /** - * Sets the route's name + * Extracts parameters from a string * - * - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * + * @param string $pattern + * @return array|bool + */ + public function extractNamedParams(string $pattern) {} + + /** + * Returns the 'before match' callback if any * - * @param string $name - * @return Route + * @return mixed */ - public function setName($name) {} + public function getBeforeMatch() {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Returns the route's compiled pattern * - * @param callback $callback - * @return Route + * @return string */ - public function beforeMatch($callback) {} + public function getCompiledPattern(): string {} /** - * Returns the 'before match' callback if any + * Returns the router converter * - * @return mixed + * @return array */ - public function getBeforeMatch() {} + public function getConverters(): array {} /** - * Returns the route's id + * Get routing delimiter * * @return string */ - public function getRouteId() {} + public static function getDelimiter(): string {} /** - * Returns the route's pattern + * Returns the route's description * * @return string */ - public function getPattern() {} + public function getDescription(): string {} /** - * Returns the route's compiled pattern + * Returns the route's name * * @return string */ - public function getCompiledPattern() {} + public function getName(): string {} /** * Returns the paths * * @return array */ - public function getPaths() {} + public function getPaths(): array {} + + /** + * Returns the route's pattern + * + * @return string + */ + public function getPattern(): string {} /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths() {} + public function getReversedPaths(): array {} /** - * Adds a converter to perform an additional transformation for certain parameter + * Returns the route's id * - * @param string $name - * @param callable $converter - * @return Route + * @return string */ - public function convert($name, $converter) {} + public function getRouteId(): string {} /** - * Returns the router converter + * Reconfigure the route adding a new pattern and a set of paths * - * @return array + * @param string $pattern + * @param array|string $paths */ - public function getConverters() {} + public function reConfigure(string $pattern, $paths = null) {} /** * Resets the internal route id generator @@ -173,17 +178,28 @@ public function getConverters() {} public static function reset() {} /** - * Set the routing delimiter + * Sets the route's description * - * @param string $delimiter + * @param string $description + * @return RouteInterface */ - public static function delimiter($delimiter = null) {} + public function setDescription(string $description): RouteInterface {} /** - * Get routing delimiter + * Sets the route's name * - * @return string + * ```php + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * ``` + * + * @param string $name + * @return RouteInterface */ - public static function getDelimiter() {} + public function setName(string $name): RouteInterface {} } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index cec93a31..d5cff844 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -3,81 +3,110 @@ namespace Phalcon\Cli\Router; /** - * Phalcon\Cli\Router\RouteInterface - * * Interface for Phalcon\Cli\Router\Route */ interface RouteInterface { /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Replaces placeholders from pattern returning a valid PCRE regular + * expression * * @param string $pattern * @return string */ - public function compilePattern($pattern); + public function compilePattern(string $pattern): string; /** - * Reconfigure the route adding a new pattern and a set of paths + * Set the routing delimiter * - * @param string $pattern - * @param mixed $paths + * @param string $delimiter */ - public function reConfigure($pattern, $paths = null); + public static function delimiter(string $delimiter = null); /** - * Returns the route's name + * Returns the route's pattern * * @return string */ - public function getName(); + public function getCompiledPattern(): string; /** - * Sets the route's name + * Get routing delimiter * - * @param string $name + * @return string */ - public function setName($name); + public static function getDelimiter(): string; /** - * Returns the route's id + * Returns the route's description * * @return string */ - public function getRouteId(); + public function getDescription(): string; /** - * Returns the route's pattern + * Returns the route's name * * @return string */ - public function getPattern(); + public function getName(): string; + + /** + * Returns the paths + * + * @return array + */ + public function getPaths(): array; /** * Returns the route's pattern * * @return string */ - public function getCompiledPattern(); + public function getPattern(): string; /** - * Returns the paths + * Returns the paths using positions as keys and names as values * * @return array */ - public function getPaths(); + public function getReversedPaths(): array; /** - * Returns the paths using positions as keys and names as values + * Returns the route's id * - * @return array + * @return string + */ + public function getRouteId(): string; + + /** + * Reconfigure the route adding a new pattern and a set of paths + * + * @param string $pattern + * @param mixed $paths */ - public function getReversedPaths(); + public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator */ public static function reset(); + /** + * Sets the route's description + * + * @param string $description + * @return RouteInterface + */ + public function setDescription(string $description): RouteInterface; + + /** + * Sets the route's name + * + * @param string $name + * @return RouteInterface + */ + public function setName(string $name): RouteInterface; + } diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php new file mode 100644 index 00000000..58194464 --- /dev/null +++ b/src/Phalcon/collection/Exception.php @@ -0,0 +1,11 @@ + "path/config", + * "adapter" => "php", + * ]; + * + * $config = (new ConfigFactory())->load($options); + * ``` + */ +class ConfigFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * ConfigFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Load a config to create a new instance + * + * @param mixed $config + * @return object + */ + public function load($config) {} + + /** + * Returns a new Config instance + * + * @param string $name + * @param string $fileName + * @param mixed $params + * @return object + */ + public function newInstance(string $name, string $fileName, $params = null) {} + + /** + * Returns the adapters for the factory + * + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/config/Exception.php b/src/Phalcon/config/Exception.php index f365baad..80954ccc 100644 --- a/src/Phalcon/config/Exception.php +++ b/src/Phalcon/config/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Config; /** - * Phalcon\Config\Exception - * * Exceptions thrown in Phalcon\Config will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/config/Factory.php b/src/Phalcon/config/Factory.php deleted file mode 100644 index 1fe15287..00000000 --- a/src/Phalcon/config/Factory.php +++ /dev/null @@ -1,33 +0,0 @@ - - * use Phalcon\Config\Factory; - * - * $options = [ - * "filePath" => "path/config", - * "adapter" => "php", - * ]; - * $config = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Config - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 348b9b5f..5de00ac0 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Grouped - * * Reads multiple files (or arrays) and merges them all together. * - * @see Phalcon\Config\Factory::load To load Config Adapter class using 'adapter' option. + * See `Phalcon\Config\Factory::load` To load Config Adapter class using 'adapter' option. * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -18,9 +16,9 @@ * "path/to/config.dist.php", * ] * ); - * + * ``` * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -30,9 +28,9 @@ * ], * "json" * ); - * + * ``` * - * + * ```php * use Phalcon\Config\Adapter\Grouped; * * $config = new Grouped( @@ -49,10 +47,11 @@ * "adapter" => "array", * "config" => [ * "property" => "value", + * ], * ], * ], * ); - * + * ``` */ class Grouped extends \Phalcon\Config { @@ -63,6 +62,6 @@ class Grouped extends \Phalcon\Config * @param array $arrayConfig * @param string $defaultAdapter */ - public function __construct(array $arrayConfig, $defaultAdapter = 'php') {} + public function __construct(array $arrayConfig, string $defaultAdapter = 'php') {} } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 63694376..d2679230 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Ini - * * Reads ini files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * + * ```ini * [database] * adapter = Mysql * host = localhost @@ -21,68 +19,58 @@ * controllersDir = "../app/controllers/" * modelsDir = "../app/models/" * viewsDir = "../app/views/" - * + * ``` * * You can read it as follows: * - * - * $config = new \Phalcon\Config\Adapter\Ini("path/config.ini"); + * ```php + * use Phalcon\Config\Adapter\Ini; + * + * $config = new Ini("path/config.ini"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * + * ``` * * PHP constants may also be parsed in the ini file, so if you define a constant * as an ini value before calling the constructor, the constant's value will be * integrated into the results. To use it this way you must specify the optional - * second parameter as INI_SCANNER_NORMAL when calling the constructor: + * second parameter as `INI_SCANNER_NORMAL` when calling the constructor: * - * + * ```php * $config = new \Phalcon\Config\Adapter\Ini( * "path/config-with-constants.ini", * INI_SCANNER_NORMAL * ); - * + * ``` */ class Ini extends \Phalcon\Config { /** - * Phalcon\Config\Adapter\Ini constructor + * Ini constructor. * * @param string $filePath * @param mixed $mode */ - public function __construct($filePath, $mode = null) {} + public function __construct(string $filePath, $mode = null) {} /** - * Build multidimensional array from string - * - * - * $this->_parseIniString("path.hello.world", "value for last key"); + * We have to cast values manually because parse_ini_file() has a poor + * implementation. * - * // result - * [ - * "path" => [ - * "hello" => [ - * "world" => "value for last key", - * ], - * ], - * ]; - * - * - * @param string $path - * @param mixed $value - * @return array + * @param mixed $ini + * @return bool|null|double|int|string */ - protected function _parseIniString($path, $value) {} + protected function cast($ini) {} /** - * We have to cast values manually because parse_ini_file() has a poor implementation. + * Build multidimensional array from string * - * @param mixed $ini The array casted by `parse_ini_file` - * @return bool|null|double|int|string + * @param string $path + * @param mixed $value + * @return array */ - protected function _cast($ini) {} + protected function parseIniString(string $path, $value): array {} } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 5c9f5761..6f20d09f 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -3,24 +3,24 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Json - * * Reads JSON files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * + * ```json * {"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"}} - * + * ``` * * You can read it as follows: * - * - * $config = new Phalcon\Config\Adapter\Json("path/config.json"); + * ```php + * use Phalcon\Config\Adapter\Json; + * + * $config = new Json("path/config.json"); * * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * + * ``` */ class Json extends \Phalcon\Config { @@ -30,6 +30,6 @@ class Json extends \Phalcon\Config * * @param string $filePath */ - public function __construct($filePath) {} + public function __construct(string $filePath) {} } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index 844d44e6..cea8c07c 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -3,13 +3,11 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Php - * * Reads php files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * + * ```php * "../app/views/", * ], * ]; - * + * ``` * * You can read it as follows: * - * - * $config = new \Phalcon\Config\Adapter\Php("path/config.php"); + * ```php + * use Phalcon\Config\Adapter\Php; + * + * $config = new Php("path/config.php"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * + * ``` */ class Php extends \Phalcon\Config { @@ -45,6 +45,6 @@ class Php extends \Phalcon\Config * * @param string $filePath */ - public function __construct($filePath) {} + public function __construct(string $filePath) {} } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index a0beca14..b0d7dc11 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -3,29 +3,29 @@ namespace Phalcon\Config\Adapter; /** - * Phalcon\Config\Adapter\Yaml - * * Reads YAML files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * + * ```yaml * phalcon: * baseuri: /phalcon/ * controllersDir: !approot /app/controllers/ * models: * metadata: memory - * + * ``` * * You can read it as follows: * - * + * ```php * define( * "APPROOT", * dirname(__DIR__) * ); * - * $config = new \Phalcon\Config\Adapter\Yaml( + * use Phalcon\Config\Adapter\Yaml; + * + * $config = new Yaml( * "path/config.yaml", * [ * "!approot" => function($value) { @@ -37,7 +37,7 @@ * echo $config->phalcon->controllersDir; * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * + * ``` */ class Yaml extends \Phalcon\Config { @@ -45,10 +45,9 @@ class Yaml extends \Phalcon\Config /** * Phalcon\Config\Adapter\Yaml constructor * - * @throws \Phalcon\Config\Exception * @param string $filePath * @param array $callbacks */ - public function __construct($filePath, array $callbacks = null) {} + public function __construct(string $filePath, array $callbacks = null) {} } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php new file mode 100644 index 00000000..2758e631 --- /dev/null +++ b/src/Phalcon/crypt/CryptInterface.php @@ -0,0 +1,137 @@ + "192.168.0.11", + * "username" => "sigma", + * "password" => "secret", + * "dbname" => "blog", + * "port" => "3306", + * ] + * ); + * + * $result = $connection->query( + * "SELECT FROM robots LIMIT 5" + * ); + * + * $result->setFetchMode(Enum::FETCH_NUM); + * + * while ($robot = $result->fetch()) { + * print_r($robot); + * } + * } catch (Exception $e) { + * echo $e->getMessage(), PHP_EOL; + * } + * ``` + */ +abstract class AbstractDb +{ + + /** + * Enables/disables options in the Database component + * + * @param array $options + */ + public static function setup(array $options) {} + +} diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 4c08e763..30f71f34 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -3,11 +3,9 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Column - * * Allows to define columns to be used on create or alter table operations * - * + * ```php * use Phalcon\Db\Column as Column; * * // Column definition @@ -25,188 +23,198 @@ * * // Add column to existing table * $connection->addColumn("robots", null, $column); - * + * ``` */ class Column implements \Phalcon\Db\ColumnInterface { /** - * Integer abstract type + * Bind Type Blob */ - const TYPE_INTEGER = 0; + const BIND_PARAM_BLOB = 3; /** - * Date abstract type + * Bind Type Bool */ - const TYPE_DATE = 1; + const BIND_PARAM_BOOL = 5; /** - * Varchar abstract type + * Bind Type Decimal */ - const TYPE_VARCHAR = 2; + const BIND_PARAM_DECIMAL = 32; /** - * Decimal abstract type + * Bind Type Integer */ - const TYPE_DECIMAL = 3; + const BIND_PARAM_INT = 1; /** - * Datetime abstract type + * Bind Type Null */ - const TYPE_DATETIME = 4; + const BIND_PARAM_NULL = 0; /** - * Char abstract type + * Bind Type String */ - const TYPE_CHAR = 5; + const BIND_PARAM_STR = 2; /** - * Text abstract data type + * Skip binding by type */ - const TYPE_TEXT = 6; + const BIND_SKIP = 1024; /** - * Float abstract data type + * Big integer abstract data type */ - const TYPE_FLOAT = 7; + const TYPE_BIGINTEGER = 14; /** - * Boolean abstract data type + * Bit abstract data type + */ + const TYPE_BIT = 19; + + /** + * Blob abstract data type + */ + const TYPE_BLOB = 11; + + /** + * Bool abstract data type */ const TYPE_BOOLEAN = 8; /** - * Double abstract data type + * Char abstract data type */ - const TYPE_DOUBLE = 9; + const TYPE_CHAR = 5; /** - * Tinyblob abstract data type + * Date abstract data type */ - const TYPE_TINYBLOB = 10; + const TYPE_DATE = 1; /** - * Blob abstract data type + * Datetime abstract data type */ - const TYPE_BLOB = 11; + const TYPE_DATETIME = 4; /** - * Mediumblob abstract data type + * Decimal abstract data type */ - const TYPE_MEDIUMBLOB = 12; + const TYPE_DECIMAL = 3; /** - * Longblob abstract data type + * Double abstract data type */ - const TYPE_LONGBLOB = 13; + const TYPE_DOUBLE = 9; /** - * Big integer abstract data type + * Enum abstract data type */ - const TYPE_BIGINTEGER = 14; + const TYPE_ENUM = 18; /** - * Json abstract type + * Float abstract data type + */ + const TYPE_FLOAT = 7; + + /** + * Int abstract data type + */ + const TYPE_INTEGER = 0; + + /** + * Json abstract data type */ const TYPE_JSON = 15; /** - * Jsonb abstract type + * Jsonb abstract data type */ const TYPE_JSONB = 16; /** - * Datetime abstract type + * Longblob abstract data type */ - const TYPE_TIMESTAMP = 17; + const TYPE_LONGBLOB = 13; /** - * Bind Type Null + * Longtext abstract data type */ - const BIND_PARAM_NULL = 0; + const TYPE_LONGTEXT = 24; /** - * Bind Type Integer + * Mediumblob abstract data type */ - const BIND_PARAM_INT = 1; + const TYPE_MEDIUMBLOB = 12; /** - * Bind Type String + * Mediumintegerr abstract data type */ - const BIND_PARAM_STR = 2; + const TYPE_MEDIUMINTEGER = 21; /** - * Bind Type Blob + * Mediumtext abstract data type */ - const BIND_PARAM_BLOB = 3; + const TYPE_MEDIUMTEXT = 23; /** - * Bind Type Bool + * Smallint abstract data type */ - const BIND_PARAM_BOOL = 5; + const TYPE_SMALLINTEGER = 22; /** - * Bind Type Decimal + * Text abstract data type */ - const BIND_PARAM_DECIMAL = 32; + const TYPE_TEXT = 6; /** - * Skip binding by type + * Time abstract data type */ - const BIND_SKIP = 1024; + const TYPE_TIME = 20; /** - * Column's name - * - * @var string + * Timestamp abstract data type */ - protected $_name; + const TYPE_TIMESTAMP = 17; /** - * Schema which table related is - * - * @var string + * Tinyblob abstract data type */ - protected $_schemaName; + const TYPE_TINYBLOB = 10; /** - * Column data type - * - * @var int|string + * Tinyint abstract data type */ - protected $_type; + const TYPE_TINYINTEGER = 26; /** - * Column data type reference - * - * @var int + * Tinytext abstract data type */ - protected $_typeReference = -1; + const TYPE_TINYTEXT = 25; /** - * Column data type values - * - * @var array|string + * Varchar abstract data type */ - protected $_typeValues; + const TYPE_VARCHAR = 2; /** - * The column have some numeric type? + * Column Position + * + * @var string */ - protected $_isNumeric = false; + protected $after; /** - * Integer column size + * Column is autoIncrement? * - * @var int + * @var bool */ - protected $_size = 0; + protected $autoIncrement = false; /** - * Integer column number scale - * - * @var int + * Bind Type */ - protected $_scale = 0; + protected $bindType = 2; /** * Default column value @@ -214,104 +222,125 @@ class Column implements \Phalcon\Db\ColumnInterface protected $_default = null; /** - * Integer column unsigned? + * Position is first + * + * @var bool + */ + protected $first = false; + + /** + * The column have some numeric type? + */ + protected $isNumeric = false; + + /** + * Column's name * - * @var boolean + * @var string */ - protected $_unsigned = false; + protected $name; /** * Column not nullable? * - * @var boolean + * @var bool */ - protected $_notNull = false; + protected $notNull = false; /** * Column is part of the primary key? */ - protected $_primary = false; + protected $primary = false; /** - * Column is autoIncrement? + * Integer column number scale * - * @var boolean + * @var int */ - protected $_autoIncrement = false; + protected $scale = 0; /** - * Position is first + * Integer column size * - * @var boolean + * @var int */ - protected $_first = false; + protected $size = 0; /** - * Column Position + * Column data type * - * @var string + * @var int */ - protected $_after; + protected $type; /** - * Bind Type + * Column data type reference + * + * @var int */ - protected $_bindType = 2; - + protected $typeReference = -1; /** - * Column's name + * Column data type values * - * @return string + * @var array|string */ - public function getName() {} + protected $typeValues; /** - * Schema which table related is + * Integer column unsigned? * - * @return string + * @var bool */ - public function getSchemaName() {} + protected $unsigned = false; + /** - * Column data type + * Default column value + */ + public function getDefault() {} + + /** + * Column's name * - * @return int|string + * @return string */ - public function getType() {} + public function getName(): string {} /** - * Column data type reference + * Integer column number scale * * @return int */ - public function getTypeReference() {} + public function getScale(): int {} /** - * Column data type values + * Integer column size * - * @return array|string + * @return int */ - public function getTypeValues() {} + public function getSize(): int {} /** - * Integer column size + * Column data type * * @return int */ - public function getSize() {} + public function getType(): int {} /** - * Integer column number scale + * Column data type reference * * @return int */ - public function getScale() {} + public function getTypeReference(): int {} /** - * Default column value + * Column data type values + * + * @return array|string */ - public function getDefault() {} + public function getTypeValues() {} /** * Phalcon\Db\Column constructor @@ -319,77 +348,69 @@ public function getDefault() {} * @param string $name * @param array $definition */ - public function __construct($name, array $definition) {} + public function __construct(string $name, array $definition) {} /** - * Returns true if number column is unsigned + * Check whether field absolute to position in table * - * @return bool + * @return string */ - public function isUnsigned() {} + public function getAfterPosition(): string {} /** - * Not null + * Returns the type of bind handling * - * @return bool + * @return int */ - public function isNotNull() {} + public function getBindType(): int {} /** - * Column is part of the primary key? + * Check whether column has default value * * @return bool */ - public function isPrimary() {} + public function hasDefault(): bool {} /** * Auto-Increment * * @return bool */ - public function isAutoIncrement() {} - - /** - * Check whether column have an numeric type - * - * @return bool - */ - public function isNumeric() {} + public function isAutoIncrement(): bool {} /** * Check whether column have first position in table * * @return bool */ - public function isFirst() {} + public function isFirst(): bool {} /** - * Check whether field absolute to position in table + * Not null * - * @return string + * @return bool */ - public function getAfterPosition() {} + public function isNotNull(): bool {} /** - * Returns the type of bind handling + * Check whether column have an numeric type * - * @return int + * @return bool */ - public function getBindType() {} + public function isNumeric(): bool {} /** - * Restores the internal state of a Phalcon\Db\Column object + * Column is part of the primary key? * - * @param array $data - * @return \Phalcon\Db\ColumnInterface + * @return bool */ - public static function __set_state(array $data) {} + public function isPrimary(): bool {} /** - * Check whether column has default value + * Returns true if number column is unsigned * * @return bool */ - public function hasDefault() {} + public function isUnsigned(): bool {} } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index dcf8d0c1..2fc8226d 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -3,138 +3,121 @@ namespace Phalcon\Db; /** - * Phalcon\Db\ColumnInterface - * * Interface for Phalcon\Db\Column */ interface ColumnInterface { /** - * Returns schema's table related to column + * Check whether field absolute to position in table * * @return string */ - public function getSchemaName(); + public function getAfterPosition(): string; /** - * Returns column name + * Returns the type of bind handling * - * @return string + * @return int */ - public function getName(); + public function getBindType(): int; /** - * Returns column type + * Returns default value of column * - * @return int + * @return mixed */ - public function getType(); + public function getDefault(); /** - * Returns column type reference + * Returns column name * - * @return int + * @return string */ - public function getTypeReference(); + public function getName(): string; /** - * Returns column type values + * Returns column scale * * @return int */ - public function getTypeValues(); + public function getScale(): int; /** * Returns column size * * @return int */ - public function getSize(); + public function getSize(): int; /** - * Returns column scale + * Returns column type * * @return int */ - public function getScale(); + public function getType(): int; /** - * Returns true if number column is unsigned + * Returns column type reference * - * @return boolean + * @return int */ - public function isUnsigned(); + public function getTypeReference(): int; /** - * Not null + * Returns column type values * - * @return boolean + * @return array|string */ - public function isNotNull(); + public function getTypeValues(); /** - * Column is part of the primary key? + * Check whether column has default value * - * @return boolean + * @return bool */ - public function isPrimary(); + public function hasDefault(): bool; /** * Auto-Increment * - * @return boolean - */ - public function isAutoIncrement(); - - /** - * Check whether column have an numeric type - * - * @return boolean + * @return bool */ - public function isNumeric(); + public function isAutoIncrement(): bool; /** * Check whether column have first position in table * - * @return boolean - */ - public function isFirst(); - - /** - * Check whether field absolute to position in table - * - * @return string + * @return bool */ - public function getAfterPosition(); + public function isFirst(): bool; /** - * Returns the type of bind handling + * Not null * - * @return int + * @return bool */ - public function getBindType(); + public function isNotNull(): bool; /** - * Returns default value of column + * Check whether column have an numeric type * - * @return int + * @return bool */ - public function getDefault(); + public function isNumeric(): bool; /** - * Check whether column has default value + * Column is part of the primary key? * * @return bool */ - public function hasDefault(); + public function isPrimary(): bool; /** - * Restores the internal state of a Phalcon\Db\Column object + * Returns true if number column is unsigned * - * @param array $data - * @return ColumnInterface + * @return bool */ - public static function __set_state(array $data); + public function isUnsigned(): bool; } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index d6021102..f72935c0 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -3,44 +3,25 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Dialect - * * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ abstract class Dialect implements \Phalcon\Db\DialectInterface { - protected $_escapeChar; + protected $escapeChar; - protected $_customFunctions; + protected $customFunctions; /** - * Registers custom SQL functions + * Generate SQL to create a new savepoint * * @param string $name - * @param callable $customFunction - * @return Dialect - */ - public function registerCustomFunction($name, $customFunction) {} - - /** - * Returns registered functions - * - * @return array - */ - public function getCustomFunctions() {} - - /** - * Escape Schema - * - * @param string $str - * @param string $escapeChar * @return string */ - public final function escapeSchema($str, $escapeChar = null) {} + public function createSavepoint(string $name): string {} /** * Escape identifiers @@ -49,56 +30,56 @@ public final function escapeSchema($str, $escapeChar = null) {} * @param string $escapeChar * @return string */ - public final function escape($str, $escapeChar = null) {} + final public function escape(string $str, string $escapeChar = null): string {} /** - * Generates the SQL for LIMIT clause - * - * - * $sql = $dialect->limit("SELECT FROM robots", 10); - * echo $sql; // SELECT FROM robots LIMIT 10 - * - * $sql = $dialect->limit("SELECT FROM robots", [10, 50]); - * echo $sql; // SELECT FROM robots LIMIT 10 OFFSET 50 - * + * Escape Schema * - * @param string $sqlQuery - * @param mixed $number + * @param string $str + * @param string $escapeChar * @return string */ - public function limit($sqlQuery, $number) {} + final public function escapeSchema(string $str, string $escapeChar = null): string {} /** * Returns a SQL modified with a FOR UPDATE clause * - * + * ```php * $sql = $dialect->forUpdate("SELECT FROM robots"); + * * echo $sql; // SELECT FROM robots FOR UPDATE - * + * ``` * * @param string $sqlQuery * @return string */ - public function forUpdate($sqlQuery) {} + public function forUpdate(string $sqlQuery): string {} /** * Gets a list of columns with escaped identifiers * - * + * ```php * echo $dialect->getColumnList( * [ * "column1", * "column", * ] * ); - * + * ``` * * @param array $columnList * @param string $escapeChar * @param mixed $bindCounts * @return string */ - public final function getColumnList(array $columnList, $escapeChar = null, $bindCounts = null) {} + final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string {} + + /** + * Returns registered functions + * + * @return array + */ + public function getCustomFunctions(): array {} /** * Resolve Column expressions @@ -108,7 +89,7 @@ public final function getColumnList(array $columnList, $escapeChar = null, $bind * @param mixed $bindCounts * @return string */ - public final function getSqlColumn($column, $escapeChar = null, $bindCounts = null) {} + final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string {} /** * Transforms an intermediate representation for an expression into a database system valid expression @@ -118,16 +99,65 @@ public final function getSqlColumn($column, $escapeChar = null, $bindCounts = nu * @param mixed $bindCounts * @return string */ - public function getSqlExpression(array $expression, $escapeChar = null, $bindCounts = null) {} + public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Transform an intermediate representation of a schema/table into a database system valid expression + * Transform an intermediate representation of a schema/table into a + * database system valid expression * * @param mixed $table * @param string $escapeChar * @return string */ - public final function getSqlTable($table, $escapeChar = null) {} + final public function getSqlTable($table, string $escapeChar = null): string {} + + /** + * Generates the SQL for LIMIT clause + * + * ```php + * // SELECT FROM robots LIMIT 10 + * echo $dialect->limit( + * "SELECT FROM robots", + * 10 + * ); + * + * // SELECT FROM robots LIMIT 10 OFFSET 50 + * echo $dialect->limit( + * "SELECT FROM robots", + * [10, 50] + * ); + * ``` + * + * @param string $sqlQuery + * @param mixed $number + * @return string + */ + public function limit(string $sqlQuery, $number): string {} + + /** + * Registers custom SQL functions + * + * @param string $name + * @param callable $customFunction + * @return Dialect + */ + public function registerCustomFunction(string $name, $customFunction): Dialect {} + + /** + * Generate SQL to release a savepoint + * + * @param string $name + * @return string + */ + public function releaseSavepoint(string $name): string {} + + /** + * Generate SQL to rollback a savepoint + * + * @param string $name + * @return string + */ + public function rollbackSavepoint(string $name): string {} /** * Builds a SELECT statement @@ -135,222 +165,230 @@ public final function getSqlTable($table, $escapeChar = null) {} * @param array $definition * @return string */ - public function select(array $definition) {} + public function select(array $definition): string {} /** * Checks whether the platform supports savepoints * * @return bool */ - public function supportsSavepoints() {} + public function supportsSavepoints(): bool {} /** * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsReleaseSavepoints() {} + public function supportsReleaseSavepoints(): bool {} /** - * Generate SQL to create a new savepoint + * Returns the size of the column enclosed in parentheses * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function createSavepoint($name) {} + protected function getColumnSize(ColumnInterface $column): string {} /** - * Generate SQL to release a savepoint + * Returns the column size and scale enclosed in parentheses * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function releaseSavepoint($name) {} + protected function getColumnSizeAndScale(ColumnInterface $column): string {} /** - * Generate SQL to rollback a savepoint + * Checks the column type and if not string it returns the type reference * - * @param string $name + * @param ColumnInterface $column * @return string */ - public function rollbackSavepoint($name) {} + protected function checkColumnType(ColumnInterface $column): string {} /** - * Resolve Column expressions + * Checks the column type and returns the updated SQL statement * - * @param array $expression - * @param string $escapeChar - * @param mixed $bindCounts + * @param ColumnInterface $column * @return string */ - protected final function getSqlExpressionScalar(array $expression, $escapeChar = null, $bindCounts = null) {} + protected function checkColumnTypeSql(ColumnInterface $column): string {} /** - * Resolve object expressions + * Resolve * * @param array $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionObject(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionAll(array $expression, string $escapeChar = null): string {} /** - * Resolve qualified expressions + * Resolve binary operations expressions * * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionQualified(array $expression, $escapeChar = null) {} + final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve binary operations expressions + * Resolve CASE expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionBinaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve unary operations expressions + * Resolve CAST of values * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionUnaryOperations(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve function calls + * Resolve CONVERT of values encodings * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionFunctionCall(array $expression, $escapeChar = null, $bindCounts) {} + final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve Lists + * Resolve a FROM clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar - * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionList(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionFrom($expression, string $escapeChar = null): string {} /** - * Resolve + * Resolve function calls * * @param array $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionAll(array $expression, $escapeChar = null) {} + final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string {} /** - * Resolve CAST of values + * Resolve a GROUP BY clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionCastValue(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve CONVERT of values encodings + * Resolve a HAVING clause * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionConvertValue(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve CASE expressions + * Resolve a JOINs clause * - * @param array $expression + * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionCase(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a FROM clause + * Resolve a LIMIT clause * * @param mixed $expression * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionFrom($expression, $escapeChar = null) {} + final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a JOINs clause + * Resolve Lists * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionJoins($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a WHERE clause + * Resolve object expressions * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionWhere($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a GROUP BY clause + * Resolve an ORDER BY clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionGroupBy($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a HAVING clause + * Resolve qualified expressions + * + * @param array $expression + * @param string $escapeChar + * @return string + */ + final protected function getSqlExpressionQualified(array $expression, string $escapeChar = null): string {} + + /** + * Resolve Column expressions * * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionHaving(array $expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve an ORDER BY clause + * Resolve unary operations expressions * - * @param mixed $expression + * @param array $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionOrderBy($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} /** - * Resolve a LIMIT clause + * Resolve a WHERE clause * * @param mixed $expression * @param string $escapeChar * @param mixed $bindCounts * @return string */ - protected final function getSqlExpressionLimit($expression, $escapeChar = null, $bindCounts = null) {} + final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string {} /** * Prepares column for this RDBMS @@ -360,7 +398,7 @@ protected final function getSqlExpressionLimit($expression, $escapeChar = null, * @param string $escapeChar * @return string */ - protected function prepareColumnAlias($qualified, $alias = null, $escapeChar = null) {} + protected function prepareColumnAlias(string $qualified, string $alias = null, string $escapeChar = null): string {} /** * Prepares table for this RDBMS @@ -371,7 +409,7 @@ protected function prepareColumnAlias($qualified, $alias = null, $escapeChar = n * @param string $escapeChar * @return string */ - protected function prepareTable($table, $schema = null, $alias = null, $escapeChar = null) {} + protected function prepareTable(string $table, string $schema = null, string $alias = null, string $escapeChar = null): string {} /** * Prepares qualified for this RDBMS @@ -381,6 +419,6 @@ protected function prepareTable($table, $schema = null, $alias = null, $escapeCh * @param string $escapeChar * @return string */ - protected function prepareQualified($column, $domain = null, $escapeChar = null) {} + protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string {} } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 5345aabd..0e8e587d 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -3,82 +3,105 @@ namespace Phalcon\Db; /** - * Phalcon\Db\DialectInterface - * * Interface for Phalcon\Db dialects */ interface DialectInterface { /** - * Generates the SQL for LIMIT clause + * Generates SQL to add a column to a table * - * @param string $sqlQuery - * @param mixed $number + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function limit($sqlQuery, $number); + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string; /** - * Returns a SQL modified with a FOR UPDATE clause + * Generates SQL to add an index to a table * - * @param string $sqlQuery + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function forUpdate($sqlQuery); + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string; /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Generates SQL to add an index to a table * - * @param string $sqlQuery + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function sharedLock($sqlQuery); + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; /** - * Builds a SELECT statement + * Generates SQL to add the primary key to a table * - * @param array $definition + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function select(array $definition); + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; /** - * Gets a list of columns + * Generate SQL to create a new savepoint * - * @param array $columnList + * @param string $name * @return string */ - public function getColumnList(array $columnList); + public function createSavepoint(string $name): string; /** - * Gets the column name in RDBMS + * Generates SQL to create a table * - * @param \Phalcon\Db\ColumnInterface $column + * @param string $tableName + * @param string $schemaName + * @param array $definition * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column); + public function createTable(string $tableName, string $schemaName, array $definition): string; /** - * Generates SQL to add a column to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column); + public function createView(string $viewName, array $definition, string $schemaName = null): string; /** - * Generates SQL to modify a column in a table + * Generates SQL to describe a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param string $table + * @param string $schema * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null); + public function describeColumns(string $table, string $schema = null): string; + + /** + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string; + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string; /** * Generates SQL to delete a column from a table @@ -88,17 +111,17 @@ public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterfac * @param string $columnName * @return string */ - public function dropColumn($tableName, $schemaName, $columnName); + public function dropColumn(string $tableName, string $schemaName, string $columnName): string; /** - * Generates SQL to add an index to a table + * Generates SQL to delete a foreign key from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param string $referenceName * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string; /** * Generates SQL to delete an index from a table @@ -108,183 +131,186 @@ public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $in * @param string $indexName * @return string */ - public function dropIndex($tableName, $schemaName, $indexName); + public function dropIndex(string $tableName, string $schemaName, string $indexName): string; /** - * Generates SQL to add the primary key to a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index); + public function dropPrimaryKey(string $tableName, string $schemaName): string; /** - * Generates SQL to delete primary key from a table + * Generates SQL to drop a table * * @param string $tableName * @param string $schemaName * @return string */ - public function dropPrimaryKey($tableName, $schemaName); + public function dropTable(string $tableName, string $schemaName): string; /** - * Generates SQL to add an index to a table + * Generates SQL to drop a view * - * @param string $tableName + * @param string $viewName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param bool $ifExists * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference); + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string; /** - * Generates SQL to delete a foreign key from a table + * Returns a SQL modified with a FOR UPDATE clause * - * @param string $tableName - * @param string $schemaName - * @param string $referenceName + * @param string $sqlQuery * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName); + public function forUpdate(string $sqlQuery): string; /** - * Generates SQL to create a table + * Gets the column name in RDBMS * - * @param string $tableName - * @param string $schemaName - * @param array $definition + * @param \Phalcon\Db\ColumnInterface $column + * @return string */ - public function createTable($tableName, $schemaName, array $definition); + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; /** - * Generates SQL to create a view + * Gets a list of columns * - * @param string $viewName - * @param array $definition - * @param string $schemaName + * @param array $columnList * @return string */ - public function createView($viewName, array $definition, $schemaName = null); + public function getColumnList(array $columnList): string; /** - * Generates SQL to drop a table + * Returns registered functions * - * @param string $tableName - * @param string $schemaName + * @return array + */ + public function getCustomFunctions(): array; + + /** + * Transforms an intermediate representation for an expression into a + * database system valid expression + * + * @param array $expression + * @param string $escapeChar + * @param mixed $bindCounts * @return string */ - public function dropTable($tableName, $schemaName); + public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string; /** - * Generates SQL to drop a view + * Generates the SQL for LIMIT clause * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param string $sqlQuery + * @param mixed $number * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true); + public function limit(string $sqlQuery, $number): string; /** - * Generates SQL checking for the existence of a schema.table + * List all tables in database * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null); + public function listTables(string $schemaName = null): string; /** - * Generates SQL checking for the existence of a schema.view + * Generates SQL to modify a column in a table * - * @param string $viewName + * @param string $tableName * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function viewExists($viewName, $schemaName = null); + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string; /** - * Generates SQL to describe a table + * Registers custom SQL functions * - * @param string $table - * @param string $schema - * @return string + * @param string $name + * @param callable $customFunction + * @return Dialect */ - public function describeColumns($table, $schema = null); + public function registerCustomFunction(string $name, $customFunction): Dialect; /** - * List all tables in database + * Generate SQL to release a savepoint * - * @param string $schemaName + * @param string $name * @return string */ - public function listTables($schemaName = null); + public function releaseSavepoint(string $name): string; /** - * Generates SQL to query indexes on a table + * Generate SQL to rollback a savepoint * - * @param string $table - * @param string $schema + * @param string $name * @return string */ - public function describeIndexes($table, $schema = null); + public function rollbackSavepoint(string $name): string; /** - * Generates SQL to query foreign keys on a table + * Builds a SELECT statement * - * @param string $table - * @param string $schema + * @param array $definition * @return string */ - public function describeReferences($table, $schema = null); + public function select(array $definition): string; /** - * Generates the SQL to describe the table creation options + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $table - * @param string $schema + * @param string $sqlQuery * @return string */ - public function tableOptions($table, $schema = null); + public function sharedLock(string $sqlQuery): string; /** - * Checks whether the platform supports savepoints + * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsSavepoints(); + public function supportsReleaseSavepoints(): bool; /** - * Checks whether the platform supports releasing savepoints. + * Checks whether the platform supports savepoints * * @return bool */ - public function supportsReleaseSavepoints(); + public function supportsSavepoints(): bool; /** - * Generate SQL to create a new savepoint + * Generates SQL checking for the existence of a schema.table * - * @param string $name + * @param string $tableName + * @param string $schemaName * @return string */ - public function createSavepoint($name); + public function tableExists(string $tableName, string $schemaName = null): string; /** - * Generate SQL to release a savepoint + * Generates the SQL to describe the table creation options * - * @param string $name + * @param string $table + * @param string $schema * @return string */ - public function releaseSavepoint($name); + public function tableOptions(string $table, string $schema = null): string; /** - * Generate SQL to rollback a savepoint + * Generates SQL checking for the existence of a schema.view * - * @param string $name + * @param string $viewName + * @param string $schemaName * @return string */ - public function rollbackSavepoint($name); + public function viewExists(string $viewName, string $schemaName = null): string; } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php new file mode 100644 index 00000000..3049c8f7 --- /dev/null +++ b/src/Phalcon/db/Enum.php @@ -0,0 +1,62 @@ + + * ```php * // Define new unique index * $index_unique = new \Phalcon\Db\Index( * 'column_UNIQUE', * [ * 'column', - * 'column' + * 'column', * ], * 'UNIQUE' * ); @@ -24,75 +22,67 @@ * $index_primary = new \Phalcon\Db\Index( * 'PRIMARY', * [ - * 'column' + * 'column', * ] * ); * * // Add index to existing table * $connection->addIndex("robots", null, $index_unique); * $connection->addIndex("robots", null, $index_primary); - * + * ``` */ class Index implements \Phalcon\Db\IndexInterface { /** - * Index name + * Index columns * - * @var string + * @var array */ - protected $_name; + protected $columns; /** - * Index columns + * Index name * - * @var array + * @var string */ - protected $_columns; + protected $name; /** * Index type * * @var string */ - protected $_type; + protected $type; /** - * Index name + * Index columns * - * @return string + * @return array */ - public function getName() {} + public function getColumns(): array {} /** - * Index columns + * Index name * - * @return array + * @return string */ - public function getColumns() {} + public function getName(): string {} /** * Index type * * @return string */ - public function getType() {} + public function getType(): string {} /** * Phalcon\Db\Index constructor * * @param string $name * @param array $columns - * @param mixed $type - */ - public function __construct($name, array $columns, $type = null) {} - - /** - * Restore a Phalcon\Db\Index object from export - * - * @param array $data - * @return IndexInterface + * @param string $type */ - public static function __set_state(array $data) {} + public function __construct(string $name, array $columns, string $type = '') {} } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index 46e8eea8..036ed333 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -3,40 +3,30 @@ namespace Phalcon\Db; /** - * Phalcon\Db\IndexInterface - * * Interface for Phalcon\Db\Index */ interface IndexInterface { - /** - * Gets the index name - * - * @return string - */ - public function getName(); - /** * Gets the columns that corresponds the index * * @return array */ - public function getColumns(); + public function getColumns(): array; /** - * Gets the index type + * Gets the index name * * @return string */ - public function getType(); + public function getName(): string; /** - * Restore a Phalcon\Db\Index object from export + * Gets the index type * - * @param array $data - * @return IndexInterface + * @return string */ - public static function __set_state(array $data); + public function getType(): string; } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index 17e3ecad..c0e49136 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -3,14 +3,12 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Profiler - * * Instances of Phalcon\Db can generate execution profiles * on SQL statements sent to the relational database. Profiled * information includes execution time in milliseconds. * This helps you to identify bottlenecks in your applications. * - * + * ```php * use Phalcon\Db\Profiler; * use Phalcon\Events\Event; * use Phalcon\Events\Manager; @@ -52,82 +50,82 @@ * echo "Start Time: ", $profile->getInitialTime(), "\n"; * echo "Final Time: ", $profile->getFinalTime(), "\n"; * echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n"; - * + * ``` */ class Profiler { /** - * All the Phalcon\Db\Profiler\Item in the active profile + * Active Phalcon\Db\Profiler\Item * - * @var \Phalcon\Db\Profiler\Item[] + * @var Phalcon\Db\Profiler\Item */ - protected $_allProfiles; + protected $activeProfile; /** - * Active Phalcon\Db\Profiler\Item + * All the Phalcon\Db\Profiler\Item in the active profile * - * @var Phalcon\Db\Profiler\Item + * @var \Phalcon\Db\Profiler\Item[] */ - protected $_activeProfile; + protected $allProfiles; /** * Total time spent by all profiles to complete * * @var float */ - protected $_totalSeconds = 0; + protected $totalSeconds = 0; /** - * Starts the profile of a SQL sentence - * - * @param string $sqlStatement - * @param mixed $sqlVariables - * @param mixed $sqlBindTypes - * @return Profiler - */ - public function startProfile($sqlStatement, $sqlVariables = null, $sqlBindTypes = null) {} - - /** - * Stops the active profile + * Returns the last profile executed in the profiler * - * @return Profiler + * @return \Phalcon\Db\Profiler\Item */ - public function stopProfile() {} + public function getLastProfile(): Item {} /** * Returns the total number of SQL statements processed * * @return int */ - public function getNumberTotalStatements() {} + public function getNumberTotalStatements(): int {} /** * Returns the total time in seconds spent by the profiles * * @return double */ - public function getTotalElapsedSeconds() {} + public function getTotalElapsedSeconds(): float {} /** * Returns all the processed profiles * - * @return \Phalcon\Db\Profiler\Item[] + * @return array|\Phalcon\Db\Profiler\Item[] */ - public function getProfiles() {} + public function getProfiles(): array {} /** * Resets the profiler, cleaning up all the profiles * * @return Profiler */ - public function reset() {} + public function reset(): Profiler {} /** - * Returns the last profile executed in the profiler + * Starts the profile of a SQL sentence * - * @return \Phalcon\Db\Profiler\Item + * @param string $sqlStatement + * @param mixed $sqlVariables + * @param mixed $sqlBindTypes + * @return Profiler + */ + public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBindTypes = null): Profiler {} + + /** + * Stops the active profile + * + * @return Profiler */ - public function getLastProfile() {} + public function stopProfile(): Profiler {} } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index 84723bd0..e4f65201 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -3,20 +3,18 @@ namespace Phalcon\Db; /** - * Phalcon\Db\RawValue - * * This class allows to insert/update raw data without quoting or formatting. * * The next example shows how to use the MySQL now() function as a field value. * - * + * ```php * $subscriber = new Subscribers(); * * $subscriber->email = "andres@phalconphp.com"; * $subscriber->createdAt = new \Phalcon\Db\RawValue("now()"); * * $subscriber->save(); - * + * ``` */ class RawValue { @@ -25,7 +23,7 @@ class RawValue * * @var string */ - protected $_value; + protected $value; /** @@ -33,14 +31,14 @@ class RawValue * * @return string */ - public function getValue() {} + public function getValue(): string {} /** * Raw value without quoting or formatting * * @return string */ - public function __toString() {} + public function __toString(): string {} /** * Phalcon\Db\RawValue constructor diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index c9874b1a..43eb5a35 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -3,18 +3,16 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Reference - * * Allows to define reference constraints on tables * - * + * ```php * $reference = new \Phalcon\Db\Reference( * "field_fk", * [ * "referencedSchema" => "invoicing", * "referencedTable" => "products", * "columns" => [ - * "product_type", + * "producttype", * "product_code", * ], * "referencedColumns" => [ @@ -23,106 +21,122 @@ * ], * ] * ); - * + * ``` */ class Reference implements \Phalcon\Db\ReferenceInterface { + /** + * Local reference columns + * + * @var array + */ + protected $columns; + /** * Constraint name * * @var string */ - protected $_name; - + protected $name; - protected $_schemaName; - - - protected $_referencedSchema; + /** + * Referenced Columns + * + * @var array + */ + protected $referencedColumns; /** - * Referenced Table + * Referenced Schema * * @var string */ - protected $_referencedTable; + protected $referencedSchema; /** - * Local reference columns + * Referenced Table * - * @var array + * @var string */ - protected $_columns; + protected $referencedTable; /** - * Referenced Columns + * Schema name * - * @var array + * @var string */ - protected $_referencedColumns; + protected $schemaName; /** * ON DELETE * - * @var array + * @var string */ - protected $_onDelete; + protected $onDelete; /** * ON UPDATE * - * @var array + * @var string */ - protected $_onUpdate; + protected $onUpdate; + /** + * Local reference columns + * + * @return array + */ + public function getColumns(): array {} + /** * Constraint name * * @return string */ - public function getName() {} - - - public function getSchemaName() {} - + public function getName(): string {} - public function getReferencedSchema() {} + /** + * Referenced Columns + * + * @return array + */ + public function getReferencedColumns(): array {} /** - * Referenced Table + * Referenced Schema * * @return string */ - public function getReferencedTable() {} + public function getReferencedSchema(): string {} /** - * Local reference columns + * Referenced Table * - * @return array + * @return string */ - public function getColumns() {} + public function getReferencedTable(): string {} /** - * Referenced Columns + * Schema name * - * @return array + * @return string */ - public function getReferencedColumns() {} + public function getSchemaName(): string {} /** * ON DELETE * - * @return array + * @return string */ - public function getOnDelete() {} + public function getOnDelete(): string {} /** * ON UPDATE * - * @return array + * @return string */ - public function getOnUpdate() {} + public function getOnUpdate(): string {} /** * Phalcon\Db\Reference constructor @@ -130,14 +144,6 @@ public function getOnUpdate() {} * @param string $name * @param array $definition */ - public function __construct($name, array $definition) {} - - /** - * Restore a Phalcon\Db\Reference object from export - * - * @param array $data - * @return ReferenceInterface - */ - public static function __set_state(array $data) {} + public function __construct(string $name, array $definition) {} } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 735af8e1..738157ac 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -3,75 +3,65 @@ namespace Phalcon\Db; /** - * Phalcon\Db\Reference - * * Interface for Phalcon\Db\Reference */ interface ReferenceInterface { /** - * Gets the index name + * Gets local columns which reference is based * - * @return string + * @return array */ - public function getName(); + public function getColumns(): array; /** - * Gets the schema where referenced table is + * Gets the index name * * @return string */ - public function getSchemaName(); + public function getName(): string; /** - * Gets the schema where referenced table is + * Gets the referenced on delete * * @return string */ - public function getReferencedSchema(); - - /** - * Gets local columns which reference is based - * - * @return array - */ - public function getColumns(); + public function getOnDelete(): string; /** - * Gets the referenced table + * Gets the referenced on update * * @return string */ - public function getReferencedTable(); + public function getOnUpdate(): string; /** * Gets referenced columns * * @return array */ - public function getReferencedColumns(); + public function getReferencedColumns(): array; /** - * Gets the referenced on delete + * Gets the schema where referenced table is * * @return string */ - public function getOnDelete(); + public function getReferencedSchema(): string; /** - * Gets the referenced on update + * Gets the referenced table * * @return string */ - public function getOnUpdate(); + public function getReferencedTable(): string; /** - * Restore a Phalcon\Db\Reference object from export + * Gets the schema where referenced table is * - * @param array $data - * @return ReferenceInterface + * @return string */ - public static function __set_state(array $data); + public function getSchemaName(): string; } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index 368397cc..a6baa4b2 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -3,74 +3,75 @@ namespace Phalcon\Db; /** - * Phalcon\Db\ResultInterface - * * Interface for Phalcon\Db\Result objects */ interface ResultInterface { /** - * Allows to executes the statement again. Some database systems don't support scrollable cursors, - * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining + * Moves internal resultset cursor to another position letting us to fetch a + * certain row * - * @return boolean + * @param long $number */ - public function execute(); + public function dataSeek(int $number); /** - * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Allows to executes the statement again. Some database systems don't + * support scrollable cursors. So, as cursors are forward only, we need to + * execute the cursor again to fetch rows from the begining * - * @return mixed + * @return bool */ - public function fetch(); + public function execute(): bool; /** - * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Fetches an array/object of strings that corresponds to the fetched row, + * or FALSE if there are no more rows. This method is affected by the active + * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * * @return mixed */ - public function fetchArray(); + public function fetch(); /** - * Returns an array of arrays containing all the records in the result - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Returns an array of arrays containing all the records in the result. This + * method is affected by the active fetch flag set using + * `Phalcon\Db\Result\Pdo::setFetchMode()` * * @return array */ - public function fetchAll(); + public function fetchAll(): array; /** - * Gets number of rows returned by a resultset + * Returns an array of strings that corresponds to the fetched row, or FALSE + * if there are no more rows. This method is affected by the active fetch + * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * @return int + * @return mixed */ - public function numRows(); + public function fetchArray(); /** - * Moves internal resultset cursor to another position letting us to fetch a certain row + * Gets the internal PDO result object * - * @param int $number + * @return \PDOStatement */ - public function dataSeek($number); + public function getInternalResult(): \PDOStatement; /** - * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() + * Gets number of rows returned by a resultset * - * @param int $fetchMode - * @param mixed $colNoOrClassNameOrObject - * @param mixed $ctorargs - * @return bool + * @return int */ - public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null); + public function numRows(): int; /** - * Gets the internal PDO result object + * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * @return \PDOStatement + * @param int $fetchMode + * @return bool */ - public function getInternalResult(); + public function setFetchMode(int $fetchMode): bool; } diff --git a/src/Phalcon/db/Adapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php similarity index 68% rename from src/Phalcon/db/Adapter.php rename to src/Phalcon/db/adapter/AbstractAdapter.php index 2de182e2..e6cbc176 100644 --- a/src/Phalcon/db/Adapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -1,101 +1,107 @@ - * // Getting first robot - * $robot = $connection->fetchOne("SELECT FROM robots"); - * print_r($robot); + * @param string $name + * @return bool + */ + public function createSavepoint(string $name): bool {} + + /** + * Creates a table * - * // Getting first robot with associative indexes only - * $robot = $connection->fetchOne("SELECT FROM robots", \Phalcon\Db::FETCH_ASSOC); - * print_r($robot); - * + * @param string $tableName + * @param string $schemaName + * @param array $definition + * @return bool + */ + public function createTable(string $tableName, string $schemaName, array $definition): bool {} + + /** + * Creates a view * - * @param string $sqlQuery - * @param mixed $fetchMode - * @param mixed $bindParams - * @param mixed $bindTypes - * @return array + * @param string $viewName + * @param array $definition + * @param string $schemaName + * @return bool + */ + public function createView(string $viewName, array $definition, string $schemaName = null): bool {} + + /** + * Deletes data from a table using custom RBDM SQL syntax + * + * ```php + * // Deleting existing robot + * $success = $connection->delete( + * "robots", + * "id = 101" + * ); + * + * // Next SQL sentence is generated + * DELETE FROM `robots` WHERE `id` = 101 + * ``` + * + * @param mixed $table + * @param mixed $whereCondition + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool + */ + public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool {} + + /** + * Lists table indexes + * + * ```php + * print_r( + * $connection->describeIndexes("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\IndexInterface[] */ - public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} + public function describeIndexes(string $table, string $schema = null): array {} + + /** + * Lists table references + * + * ```php + * print_r( + * $connection->describeReferences("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ReferenceInterface[] + */ + public function describeReferences(string $table, string $schema = null): array {} + + /** + * Drops a column from a table + * + * @param string $tableName + * @param string $schemaName + * @param string $columnName + * @return bool + */ + public function dropColumn(string $tableName, string $schemaName, string $columnName): bool {} + + /** + * Drops a foreign key from a table + * + * @param string $tableName + * @param string $schemaName + * @param string $referenceName + * @return bool + */ + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): bool {} + + /** + * Drop an index from a table + * + * @param string $tableName + * @param string $schemaName + * @param mixed $indexName + * @return bool + */ + public function dropIndex(string $tableName, string $schemaName, $indexName): bool {} + + /** + * Drops a table's primary key + * + * @param string $tableName + * @param string $schemaName + * @return bool + */ + public function dropPrimaryKey(string $tableName, string $schemaName): bool {} + + /** + * Drops a table from a schema/database + * + * @param string $tableName + * @param string $schemaName + * @param bool $ifExists + * @return bool + */ + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): bool {} + + /** + * Drops a view + * + * @param string $viewName + * @param string $schemaName + * @param bool $ifExists + * @return bool + */ + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): bool {} + + /** + * Escapes a column/table/schema name + * + * ```php + * $escapedTable = $connection->escapeIdentifier( + * "robots" + * ); + * + * $escapedTable = $connection->escapeIdentifier( + * [ + * "store", + * "robots", + * ] + * ); + * ``` + * + * @param mixed $identifier + * @return string + */ + public function escapeIdentifier($identifier): string {} /** * Dumps the complete result of a query into an array * - * + * ```php * // Getting all robots with associative indexes only * $robots = $connection->fetchAll( * "SELECT FROM robots", - * \Phalcon\Db::FETCH_ASSOC + * \Phalcon\Db\Enum::FETCH_ASSOC * ); * * foreach ($robots as $robot) { @@ -170,7 +327,7 @@ public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * // Getting all robots that contains word "robot" withing the name * $robots = $connection->fetchAll( * "SELECT FROM robots WHERE name LIKE :name", - * \Phalcon\Db::FETCH_ASSOC, + * \Phalcon\Db\Enum::FETCH_ASSOC, * [ * "name" => "%robot%", * ] @@ -178,20 +335,20 @@ public function fetchOne($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * foreach($robots as $robot) { * print_r($robot); * } - * + * ``` * * @param string $sqlQuery * @param int $fetchMode - * @param array $bindParams - * @param array $bindTypes + * @param mixed $bindParams + * @param mixed $bindTypes * @return array */ - public function fetchAll($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = null, $bindTypes = null) {} + public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} /** * Returns the n'th field of first row in a SQL query result * - * + * ```php * // Getting count of robots * $robotsCount = $connection->fetchColumn("SELECT count() FROM robots"); * print_r($robotsCount); @@ -202,603 +359,446 @@ public function fetchAll($sqlQuery, $fetchMode = Db::FETCH_ASSOC, $bindParams = * 1 * ); * print_r($robot); - * + * ``` * * @param string $sqlQuery * @param array $placeholders - * @param int|string $column + * @param mixed $column * @return string|bool */ - public function fetchColumn($sqlQuery, $placeholders = null, $column = 0) {} + public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) {} /** - * Inserts data into a table using custom RDBMS SQL syntax + * Returns the first row in a SQL query result * - * - * // Inserting a new robot - * $success = $connection->insert( - * "robots", - * ["Astro Boy", 1952], - * ["name", "year"] - * ); + * ```php + * // Getting first robot + * $robot = $connection->fetchOne("SELECT FROM robots"); + * print_r($robot); * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * + * // Getting first robot with associative indexes only + * $robot = $connection->fetchOne( + * "SELECT FROM robots", + * \Phalcon\Db\Enum::FETCH_ASSOC + * ); + * print_r($robot); + * ``` * - * @param string|array $table - * @param array $values - * @param mixed $fields - * @param mixed $dataTypes - * @param $array dataTypes - * @return bool + * @param string $sqlQuery + * @param mixed $fetchMode + * @param mixed $bindParams + * @param mixed $bindTypes + * @return array */ - public function insert($table, array $values, $fields = null, $dataTypes = null) {} + public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} /** - * Inserts data into a table using custom RBDM SQL syntax - * - * - * // Inserting a new robot - * $success = $connection->insertAsDict( - * "robots", - * [ - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); + * Returns a SQL modified with a FOR UPDATE clause * - * // Next SQL sentence is sent to the database system - * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); - * + * @param string $sqlQuery + * @return string + */ + public function forUpdate(string $sqlQuery): string {} + + /** + * Returns the SQL column definition from a column * - * @param mixed $table - * @param mixed $data - * @param mixed $dataTypes - * @param $string table - * @param $array dataTypes - * @return bool + * @param \Phalcon\Db\ColumnInterface $column + * @return string */ - public function insertAsDict($table, $data, $dataTypes = null) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Updates data on a table using custom RBDM SQL syntax + * Gets a list of columns * - * - * // Updating existing robot - * $success = $connection->update( - * "robots", - * ["name"], - * ["New Astro Boy"], - * "id = 101" - * ); + * @param mixed $columnList + * @return string + */ + public function getColumnList($columnList): string {} + + /** + * Gets the active connection unique identifier * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * @return string + */ + public function getConnectionId(): string {} + + /** + * Returns the default identity value to be inserted in an identity column * - * // Updating existing robot with array condition and $dataTypes - * $success = $connection->update( + * ```php + * // Inserting a new robot with a valid default value for the column 'id' + * $success = $connection->insert( * "robots", - * ["name"], - * ["New Astro Boy"], * [ - * "conditions" => "id = ?", - * "bind" => [$some_unsafe_id], - * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param + * $connection->getDefaultIdValue(), + * "Astro Boy", + * 1952, * ], * [ - * PDO::PARAM_STR + * "id", + * "name", + * "year", * ] * ); + * ``` * - * - * - * Warning! If $whereCondition is string it not escaped. - * - * @param string|array $table - * @param mixed $fields - * @param mixed $values - * @param mixed $whereCondition - * @param mixed $dataTypes - * @param $array dataTypes - * @param $string|array whereCondition - * @return bool + * @return \Phalcon\Db\RawValue */ - public function update($table, $fields, $values, $whereCondition = null, $dataTypes = null) {} + public function getDefaultIdValue(): RawValue {} /** - * Updates data on a table using custom RBDM SQL syntax - * Another, more convenient syntax + * Returns the default value to make the RBDM use the default value declared + * in the table definition * - * - * // Updating existing robot - * $success = $connection->updateAsDict( + * ```php + * // Inserting a new robot with a valid default value for the column 'year' + * $success = $connection->insert( * "robots", * [ - * "name" => "New Astro Boy", + * "Astro Boy", + * $connection->getDefaultValue() * ], - * "id = 101" + * [ + * "name", + * "year", + * ] * ); + * ``` * - * // Next SQL sentence is sent to the database system - * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 - * - * - * @param mixed $table - * @param mixed $data - * @param mixed $whereCondition - * @param mixed $dataTypes - * @param $string whereCondition - * @param $array dataTypes - * @return bool + * @return \Phalcon\Db\RawValue */ - public function updateAsDict($table, $data, $whereCondition = null, $dataTypes = null) {} + public function getDefaultValue(): RawValue {} /** - * Deletes data from a table using custom RBDM SQL syntax - * - * - * // Deleting existing robot - * $success = $connection->delete( - * "robots", - * "id = 101" - * ); - * - * // Next SQL sentence is generated - * DELETE FROM `robots` WHERE `id` = 101 - * + * Return descriptor used to connect to the active database * - * @param string|array $table - * @param string $whereCondition - * @param array $placeholders - * @param array $dataTypes - * @return bool + * @return array */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null) {} + public function getDescriptor(): array {} /** - * Escapes a column/table/schema name - * - * - * $escapedTable = $connection->escapeIdentifier( - * "robots" - * ); - * - * $escapedTable = $connection->escapeIdentifier( - * [ - * "store", - * "robots", - * ] - * ); - * + * Returns internal dialect instance * - * @param array|string $identifier - * @return string + * @return DialectInterface */ - public function escapeIdentifier($identifier) {} + public function getDialect(): DialectInterface {} /** - * Gets a list of columns + * Returns the internal event manager * - * @param array columnList - * @return string - * @param mixed $columnList - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getColumnList($columnList) {} + public function getEventsManager(): ManagerInterface {} /** - * Appends a LIMIT clause to $sqlQuery argument - * - * - * echo $connection->limit("SELECT FROM robots", 5); - * + * Returns the savepoint name to use for nested transactions * - * @param string $sqlQuery - * @param int $number * @return string */ - public function limit($sqlQuery, $number) {} + public function getNestedTransactionSavepointName(): string {} /** - * Generates SQL checking for the existence of a schema.table - * - * - * var_dump( - * $connection->tableExists("blog", "posts") - * ); - * + * Active SQL statement in the object without replace bound parameters * - * @param string $tableName - * @param string $schemaName - * @return bool + * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function getRealSQLStatement(): string {} /** - * Generates SQL checking for the existence of a schema.view - * - * - * var_dump( - * $connection->viewExists("active_users", "posts") - * ); - * + * Active SQL statement in the object * - * @param string $viewName - * @param string $schemaName - * @return bool + * @return array */ - public function viewExists($viewName, $schemaName = null) {} + public function getSQLBindTypes(): array {} /** - * Returns a SQL modified with a FOR UPDATE clause + * Active SQL statement in the object * - * @param string $sqlQuery * @return string */ - public function forUpdate($sqlQuery) {} + public function getSQLStatement(): string {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause + * Inserts data into a table using custom RDBMS SQL syntax * - * @param string $sqlQuery - * @return string - */ - public function sharedLock($sqlQuery) {} - - /** - * Creates a table + * ```php + * // Inserting a new robot + * $success = $connection->insert( + * "robots", + * ["Astro Boy", 1952], + * ["name", "year"] + * ); * - * @param string $tableName - * @param string $schemaName - * @param array $definition - * @return bool - */ - public function createTable($tableName, $schemaName, array $definition) {} - - /** - * Drops a table from a schema/database + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` * - * @param string $tableName - * @param string $schemaName - * @param bool $ifExists + * @param string $table + * @param array $values + * @param mixed $fields + * @param mixed $dataTypes * @return bool */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool {} /** - * Creates a view + * Inserts data into a table using custom RBDM SQL syntax * - * @param string $viewName - * @param array $definition - * @param string $schemaName - * @return bool - */ - public function createView($viewName, array $definition, $schemaName = null) {} - - /** - * Drops a view + * ```php + * // Inserting a new robot + * $success = $connection->insertAsDict( + * "robots", + * [ + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists - * @return bool - */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} - - /** - * Adds a column to a table + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param string $table + * @param mixed $data + * @param mixed $dataTypes * @return bool */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function insertAsDict(string $table, $data, $dataTypes = null): bool {} /** - * Modifies a table column based on a definition + * Returns if nested transactions should use savepoints * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function isNestedTransactionsWithSavepoints(): bool {} /** - * Drops a column from a table + * Appends a LIMIT clause to $sqlQuery argument * - * @param string $tableName - * @param string $schemaName - * @param string $columnName - * @return bool + * ```php + * echo $connection->limit("SELECT FROM robots", 5); + * ``` + * + * @param string $sqlQuery + * @param int $number + * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function limit(string $sqlQuery, int $number): string {} /** - * Adds an index to a table + * List all tables on a database + * + * ```php + * print_r( + * $connection->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName - * @param IndexInterface $index - * @return bool + * @return array */ - public function addIndex($tableName, $schemaName, IndexInterface $index) {} + public function listTables(string $schemaName = null): array {} /** - * Drop an index from a table + * List all views on a database + * + * ```php + * print_r( + * $connection->listViews("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName - * @param mixed $indexName - * @return bool + * @return array */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function listViews(string $schemaName = null): array {} /** - * Adds a primary key to a table + * Modifies a table column based on a definition * * @param string $tableName * @param string $schemaName - * @param IndexInterface $index + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function addPrimaryKey($tableName, $schemaName, IndexInterface $index) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} /** - * Drops a table's primary key + * Releases given savepoint * - * @param string $tableName - * @param string $schemaName + * @param string $name * @return bool */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function releaseSavepoint(string $name): bool {} /** - * Adds a foreign key to a table + * Rollbacks given savepoint * - * @param string $tableName - * @param string $schemaName - * @param ReferenceInterface $reference + * @param string $name * @return bool */ - public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference) {} + public function rollbackSavepoint(string $name): bool {} /** - * Drops a foreign key from a table + * Sets the event manager * - * @param string $tableName - * @param string $schemaName - * @param string $referenceName - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns the SQL column definition from a column + * Sets the dialect used to produce the SQL * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @param DialectInterface $dialect */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + public function setDialect(DialectInterface $dialect) {} /** - * List all tables on a database - * - * - * print_r( - * $connection->listTables("blog") - * ); - * + * Set if nested transactions should use savepoints * - * @param string $schemaName - * @return array + * @param bool $nestedTransactionsWithSavepoints + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function listTables($schemaName = null) {} + public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface {} /** - * List all views on a database - * - * - * print_r( - * $connection->listViews("blog") - * ); - * + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $schemaName - * @return array + * @param string $sqlQuery + * @return string */ - public function listViews($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Lists table indexes + * Check whether the database system requires a sequence to produce + * auto-numeric values * - * - * print_r( - * $connection->describeIndexes("robots_parts") - * ); - * - * - * @param string table - * @param string schema - * @return Phalcon\Db\Index[] - * @param string $table - * @param string $schema - * @return IndexInterface[] + * @return bool */ - public function describeIndexes($table, $schema = null) {} + public function supportSequences(): bool {} /** - * Lists table references + * Generates SQL checking for the existence of a schema.table * - * - * print_r( - * $connection->describeReferences("robots_parts") + * ```php + * var_dump( + * $connection->tableExists("blog", "posts") * ); - * + * ``` * - * @param string $table - * @param string $schema - * @return ReferenceInterface[] + * @param string $tableName + * @param string $schemaName + * @return bool */ - public function describeReferences($table, $schema = null) {} + public function tableExists(string $tableName, string $schemaName = null): bool {} /** * Gets creation options from a table * - * + * ```php * print_r( * $connection->tableOptions("robots") * ); - * + * ``` * * @param string $tableName * @param string $schemaName * @return array */ - public function tableOptions($tableName, $schemaName = null) {} - - /** - * Creates a new savepoint - * - * @param string $name - * @return bool - */ - public function createSavepoint($name) {} - - /** - * Releases given savepoint - * - * @param string $name - * @return bool - */ - public function releaseSavepoint($name) {} - - /** - * Rollbacks given savepoint - * - * @param string $name - * @return bool - */ - public function rollbackSavepoint($name) {} - - /** - * Set if nested transactions should use savepoints - * - * @param bool $nestedTransactionsWithSavepoints - * @return AdapterInterface - */ - public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints) {} + public function tableOptions(string $tableName, string $schemaName = null): array {} /** - * Returns if nested transactions should use savepoints + * Updates data on a table using custom RBDM SQL syntax * - * @return bool - */ - public function isNestedTransactionsWithSavepoints() {} - - /** - * Returns the savepoint name to use for nested transactions + * ```php + * // Updating existing robot + * $success = $connection->update( + * "robots", + * ["name"], + * ["New Astro Boy"], + * "id = 101" + * ); * - * @return string - */ - public function getNestedTransactionSavepointName() {} - - /** - * Returns the default identity value to be inserted in an identity column + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 * - * - * // Inserting a new robot with a valid default value for the column 'id' - * $success = $connection->insert( + * // Updating existing robot with array condition and $dataTypes + * $success = $connection->update( * "robots", + * ["name"], + * ["New Astro Boy"], * [ - * $connection->getDefaultIdValue(), - * "Astro Boy", - * 1952, + * "conditions" => "id = ?", + * "bind" => [$some_unsafe_id], + * "bindTypes" => [PDO::PARAM_INT], // use only if you use $dataTypes param * ], * [ - * "id", - * "name", - * "year", + * PDO::PARAM_STR * ] * ); - * * - * @return RawValue + * ``` + * + * Warning! If $whereCondition is string it not escaped. + * + * @param string $table + * @param mixed $fields + * @param mixed $values + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool */ - public function getDefaultIdValue() {} + public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool {} /** - * Returns the default value to make the RBDM use the default value declared in the table definition + * Updates data on a table using custom RBDM SQL syntax + * Another, more convenient syntax * - * - * // Inserting a new robot with a valid default value for the column 'year' - * $success = $connection->insert( + * ```php + * // Updating existing robot + * $success = $connection->updateAsDict( * "robots", * [ - * "Astro Boy", - * $connection->getDefaultValue() + * "name" => "New Astro Boy", * ], - * [ - * "name", - * "year", - * ] + * "id = 101" * ); - * * - * @return RawValue - */ - public function getDefaultValue() {} - - /** - * Check whether the database system requires a sequence to produce auto-numeric values + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * ``` * + * @param string $table + * @param mixed $data + * @param mixed $whereCondition + * @param mixed $dataTypes * @return bool */ - public function supportSequences() {} + public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool {} /** - * Check whether the database system requires an explicit value for identity columns + * Check whether the database system requires an explicit value for identity + * columns * * @return bool */ - public function useExplicitIdValue() {} - - /** - * Return descriptor used to connect to the active database - * - * @return array - */ - public function getDescriptor() {} - - /** - * Gets the active connection unique identifier - * - * @return string - */ - public function getConnectionId() {} + public function useExplicitIdValue(): bool {} /** - * Active SQL statement in the object - * - * @return string - */ - public function getSQLStatement() {} - - /** - * Active SQL statement in the object without replace bound parameters + * Generates SQL checking for the existence of a schema.view * - * @return string - */ - public function getRealSQLStatement() {} - - /** - * Active SQL statement in the object + * ```php + * var_dump( + * $connection->viewExists("active_users", "posts") + * ); + * ``` * - * @return array + * @param string $viewName + * @param string $schemaName + * @return bool */ - public function getSQLBindTypes() {} + public function viewExists(string $viewName, string $schemaName = null): bool {} } diff --git a/src/Phalcon/db/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php similarity index 52% rename from src/Phalcon/db/AdapterInterface.php rename to src/Phalcon/db/adapter/AdapterInterface.php index d207a62d..e136e02f 100644 --- a/src/Phalcon/db/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -1,126 +1,101 @@ fetchColumn("SELECT count() FROM robots"); + * print_r($robotsCount); + * + * // Getting name of last edited robot + * $robot = $connection->fetchColumn( + * "SELECT id, name FROM robots order by modified desc", + * 1 + * ); + * print_r($robot); + * ``` + * + * @param string $sqlQuery + * @param array $placeholders + * @param mixed $column + * @return string|bool + */ + public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0); + + /** + * Returns the first row in a SQL query result * + * @param string $sqlQuery + * @param int $fetchMode + * @param mixed $placeholders * @return array */ - public function getDescriptor(); + public function fetchOne(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array; /** - * Gets the active connection unique identifier + * Returns a SQL modified with a FOR UPDATE clause * + * @param string $sqlQuery * @return string */ - public function getConnectionId(); + public function forUpdate(string $sqlQuery): string; /** - * Active SQL statement in the object + * Returns the SQL column definition from a column * + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getSQLStatement(); + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; /** - * Active SQL statement in the object without replace bound parameters + * Gets a list of columns * + * @param mixed $columnList * @return string */ - public function getRealSQLStatement(); + public function getColumnList($columnList): string; /** - * Active SQL statement in the object + * Gets the active connection unique identifier * - * @return array + * @return string */ - public function getSQLVariables(); + public function getConnectionId(): string; /** - * Active SQL statement in the object + * Return descriptor used to connect to the active database * * @return array */ - public function getSQLBindTypes(); + public function getDescriptor(): array; /** - * Returns type of database system the adapter is used for + * Returns internal dialect instance * - * @return string + * @return DialectInterface */ - public function getType(); + public function getDialect(): DialectInterface; /** * Returns the name of the dialect used * * @return string */ - public function getDialectType(); + public function getDialectType(): string; /** - * Returns internal dialect instance + * Return the default identity value to insert in an identity column * - * @return DialectInterface + * @return \Phalcon\Db\RawValue */ - public function getDialect(); + public function getDefaultIdValue(): RawValue; /** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection + * Return internal PDO handler * - * @param array $descriptor - * @return bool + * @return \Pdo */ - public function connect(array $descriptor = null); + public function getInternalHandler(): \Pdo; /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server return rows + * Returns the savepoint name to use for nested transactions * - * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool|ResultInterface + * @return string */ - public function query($sqlStatement, $placeholders = null, $dataTypes = null); + public function getNestedTransactionSavepointName(): string; /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't return any rows + * Active SQL statement in the object without replace bound parameters * - * @param string $sqlStatement - * @param mixed $placeholders - * @param mixed $dataTypes - * @return bool + * @return string */ - public function execute($sqlStatement, $placeholders = null, $dataTypes = null); + public function getRealSQLStatement(): string; /** - * Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system + * Active SQL statement in the object * - * @return int + * @return string */ - public function affectedRows(); + public function getSQLStatement(): string; /** - * Closes active connection returning success. Phalcon automatically closes - * and destroys active connections within Phalcon\Db\Pool + * Active SQL statement in the object * - * @return bool + * @return array */ - public function close(); + public function getSQLBindTypes(): array; /** - * Escapes a column/table/schema name + * Active SQL statement in the object * - * @param string $identifier - * @return string + * @return array */ - public function escapeIdentifier($identifier); + public function getSQLVariables(): array; /** - * Escapes a value to avoid SQL injections + * Returns type of database system the adapter is used for * - * @param string $str * @return string */ - public function escapeString($str); + public function getType(): string; /** - * Returns insert id for the auto_increment column inserted in the last SQL statement - * - * @param string $sequenceName - * @return int - */ - public function lastInsertId($sequenceName = null); - - /** - * Starts a transaction in the connection + * Inserts data into a table using custom RDBMS SQL syntax * - * @param bool $nesting + * @param string $table + * @param array $values + * @param mixed $fields + * @param mixed $dataTypes * @return bool */ - public function begin($nesting = true); + public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool; /** - * Rollbacks the active transaction in the connection + * Inserts data into a table using custom RBDM SQL syntax * - * @param bool $nesting + * ```php + * // Inserting a new robot + * $success = $connection->insertAsDict( + * "robots", + * [ + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); + * + * // Next SQL sentence is sent to the database system + * INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952); + * ``` + * + * @param string $table + * @param mixed $data + * @param mixed $dataTypes * @return bool */ - public function rollback($nesting = true); + public function insertAsDict(string $table, $data, $dataTypes = null): bool; /** - * Commits the active transaction in the connection + * Returns if nested transactions should use savepoints * - * @param bool $nesting * @return bool */ - public function commit($nesting = true); + public function isNestedTransactionsWithSavepoints(): bool; /** * Checks whether connection is under database transaction * * @return bool */ - public function isUnderTransaction(); + public function isUnderTransaction(): bool; /** - * Return internal PDO handler + * Returns insert id for the auto_increment column inserted in the last SQL + * statement * - * @return \Pdo + * @param mixed $sequenceName */ - public function getInternalHandler(); + public function lastInsertId($sequenceName = null); /** - * Lists table indexes + * Appends a LIMIT clause to sqlQuery argument * - * @param string $table - * @param string $schema - * @return IndexInterface[] + * @param string $sqlQuery + * @param int $number + * @return string */ - public function describeIndexes($table, $schema = null); + public function limit(string $sqlQuery, int $number): string; /** - * Lists table references + * List all tables on a database * - * @param string $table - * @param string $schema - * @return ReferenceInterface[] + * @param string $schemaName + * @return array */ - public function describeReferences($table, $schema = null); + public function listTables(string $schemaName = null): array; /** - * Gets creation options from a table + * List all views on a database * - * @param string $tableName * @param string $schemaName * @return array */ - public function tableOptions($tableName, $schemaName = null); + public function listViews(string $schemaName = null): array; /** - * Check whether the database system requires an explicit value for identity columns + * Modifies a table column based on a definition * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function useExplicitIdValue(); + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool; /** - * Return the default identity value to insert in an identity column + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server returns + * rows * - * @return RawValue + * @param string $sqlStatement + * @param mixed $placeholders + * @param mixed $dataTypes + * @return bool|ResultInterface */ - public function getDefaultIdValue(); + public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); /** - * Check whether the database system requires a sequence to produce auto-numeric values + * Releases given savepoint * + * @param string $name * @return bool */ - public function supportSequences(); + public function releaseSavepoint(string $name): bool; /** - * Creates a new savepoint + * Rollbacks the active transaction in the connection * - * @param string $name + * @param bool $nesting * @return bool */ - public function createSavepoint($name); + public function rollback(bool $nesting = true): bool; /** - * Releases given savepoint + * Rollbacks given savepoint * * @param string $name * @return bool */ - public function releaseSavepoint($name); + public function rollbackSavepoint(string $name): bool; /** - * Rollbacks given savepoint + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * @param string $name - * @return bool + * @param string $sqlQuery + * @return string */ - public function rollbackSavepoint($name); + public function sharedLock(string $sqlQuery): string; /** * Set if nested transactions should use savepoints @@ -525,29 +536,87 @@ public function rollbackSavepoint($name); * @param bool $nestedTransactionsWithSavepoints * @return AdapterInterface */ - public function setNestedTransactionsWithSavepoints($nestedTransactionsWithSavepoints); + public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface; /** - * Returns if nested transactions should use savepoints + * Check whether the database system requires a sequence to produce + * auto-numeric values * * @return bool */ - public function isNestedTransactionsWithSavepoints(); + public function supportSequences(): bool; /** - * Returns the savepoint name to use for nested transactions + * Generates SQL checking for the existence of a schema.table * - * @return string + * @param string $tableName + * @param string $schemaName + * @return bool */ - public function getNestedTransactionSavepointName(); + public function tableExists(string $tableName, string $schemaName = null): bool; /** - * Returns an array of Phalcon\Db\Column objects describing a table + * Gets creation options from a table + * + * @param string $tableName + * @param string $schemaName + * @return array + */ + public function tableOptions(string $tableName, string $schemaName = null): array; + + /** + * Updates data on a table using custom RDBMS SQL syntax * * @param string $table - * @param string $schema - * @return ColumnInterface[] + * @param mixed $fields + * @param mixed $values + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool + */ + public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool; + + /** + * Updates data on a table using custom RBDM SQL syntax + * Another, more convenient syntax + * + * ```php + * // Updating existing robot + * $success = $connection->updateAsDict( + * "robots", + * [ + * "name" => "New Astro Boy", + * ], + * "id = 101" + * ); + * + * // Next SQL sentence is sent to the database system + * UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101 + * ``` + * + * @param string $table + * @param mixed $data + * @param mixed $whereCondition + * @param mixed $dataTypes + * @return bool + */ + public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool; + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool; + + /** + * Generates SQL checking for the existence of a schema.view + * + * @param string $viewName + * @param string $schemaName + * @return bool */ - public function describeColumns($table, $schema = null); + public function viewExists(string $viewName, string $schemaName = null): bool; } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php new file mode 100644 index 00000000..1d71f837 --- /dev/null +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class PdoFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * Constructor + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Annotations\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * Returns the available adapters + * + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/db/adapter/Pdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php similarity index 75% rename from src/Phalcon/db/adapter/Pdo.php rename to src/Phalcon/db/adapter/pdo/AbstractPdo.php index 81eb783d..80be64a0 100644 --- a/src/Phalcon/db/adapter/Pdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -1,13 +1,12 @@ + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -19,21 +18,21 @@ * ]; * * $connection = new Mysql($config); - * + * ``` */ -abstract class Pdo extends \Phalcon\Db\Adapter +abstract class AbstractPdo extends \Phalcon\Db\Adapter\AbstractAdapter { /** - * PDO Handler - * - * @var \Pdo + * Last affected rows */ - protected $_pdo; + protected $affectedRows; /** - * Last affected rows + * PDO Handler + * + * @var \Pdo */ - protected $_affectedRows; + protected $pdo; /** @@ -44,11 +43,52 @@ abstract class Pdo extends \Phalcon\Db\Adapter public function __construct(array $descriptor) {} /** - * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. + * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE + * executed in the database system + * + * ```php + * $connection->execute( + * "DELETE FROM robots" + * ); + * + * echo $connection->affectedRows(), " were deleted"; + * ``` + * + * @return int + */ + public function affectedRows(): int {} + + /** + * Starts a transaction in the connection + * + * @param bool $nesting + * @return bool + */ + public function begin(bool $nesting = true): bool {} + + /** + * Commits the active transaction in the connection + * + * @param bool $nesting + * @return bool + */ + public function commit(bool $nesting = true): bool {} + + /** + * Closes the active connection returning success. Phalcon automatically + * closes and destroys active connections when the request ends + * + * @return bool + */ + public function close(): bool {} + + /** + * This method is automatically called in \Phalcon\Db\Adapter\Pdo + * constructor. * * Call it when you need to restore a database connection. * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * // Make a connection @@ -64,97 +104,52 @@ public function __construct(array $descriptor) {} * * // Reconnect * $connection->connect(); - * + * ``` * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null) {} - - /** - * Returns a PDO prepared statement to be executed with 'executePrepared' - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT FROM robots WHERE name = :name" - * ); - * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] - * ); - * - * - * @param string $sqlStatement - * @return \PDOStatement - */ - public function prepare($sqlStatement) {} + public function connect(array $descriptor = null): bool {} /** - * Executes a prepared statement binding. This function uses integer indexes starting from zero - * - * - * use Phalcon\Db\Column; - * - * $statement = $db->prepare( - * "SELECT FROM robots WHERE name = :name" - * ); + * Converts bound parameters such as :name: or ?1 into PDO bind params ? * - * $result = $connection->executePrepared( - * $statement, - * [ - * "name" => "Voltron", - * ], - * [ - * "name" => Column::BIND_PARAM_INT, - * ] + * ```php + * print_r( + * $connection->convertBoundParams( + * "SELECT FROM robots WHERE name = :name:", + * [ + * "Bender", + * ] + * ) * ); - * + * ``` * - * @param \PDOStatement $statement - * @param array $placeholders - * @param array $dataTypes - * @return \PDOStatement + * @param string $sql + * @param array $params + * @return array */ - public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes) {} + public function convertBoundParams(string $sql, array $params = array()): array {} /** - * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server is returning rows + * Escapes a value to avoid SQL injections according to the active charset + * in the connection * - * - * // Querying data - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = 'mechanical'" - * ); - * - * $resultset = $connection->query( - * "SELECT FROM robots WHERE type = ?", - * [ - * "mechanical", - * ] - * ); - * + * ```php + * $escapedStr = $connection->escapeString("some dangerous value"); + * ``` * - * @param string $sqlStatement - * @param mixed $bindParams - * @param mixed $bindTypes - * @return bool|\Phalcon\Db\ResultInterface + * @param string $str + * @return string */ - public function query($sqlStatement, $bindParams = null, $bindTypes = null) {} + public function escapeString(string $str): string {} /** * Sends SQL statements to the database server returning the success state. - * Use this method only when the SQL statement sent to the server doesn't return any rows + * Use this method only when the SQL statement sent to the server doesn't + * return any rows * - * + * ```php * // Inserting data * $success = $connection->execute( * "INSERT INTO robots VALUES (1, 'Astro Boy')" @@ -167,74 +162,84 @@ public function query($sqlStatement, $bindParams = null, $bindTypes = null) {} * "Astro Boy", * ] * ); - * + * ``` * * @param string $sqlStatement * @param mixed $bindParams * @param mixed $bindTypes * @return bool */ - public function execute($sqlStatement, $bindParams = null, $bindTypes = null) {} + public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool {} /** - * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE executed in the database system + * Executes a prepared statement binding. This function uses integer indexes + * starting from zero * - * - * $connection->execute( - * "DELETE FROM robots" + * ```php + * use Phalcon\Db\Column; + * + * $statement = $db->prepare( + * "SELECT FROM robots WHERE name = :name" * ); * - * echo $connection->affectedRows(), " were deleted"; - * + * $result = $connection->executePrepared( + * $statement, + * [ + * "name" => "Voltron", + * ], + * [ + * "name" => Column::BIND_PARAM_INT, + * ] + * ); + * ``` * - * @return int + * @param \PDOStatement $statement + * @param array $placeholders + * @param mixed $dataTypes + * @return \PDOStatement */ - public function affectedRows() {} + public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement {} /** - * Closes the active connection returning success. Phalcon automatically closes and destroys - * active connections when the request ends - * - * @return bool + * Return the error info, if any */ - public function close() {} + public function getErrorInfo() {} /** - * Escapes a value to avoid SQL injections according to the active charset in the connection + * Return internal PDO handler * - * - * $escapedStr = $connection->escapeString("some dangerous value"); - * + * @return \Pdo + */ + public function getInternalHandler(): \Pdo {} + + /** + * Returns the current transaction nesting level * - * @param string $str - * @return string + * @return int */ - public function escapeString($str) {} + public function getTransactionLevel(): int {} /** - * Converts bound parameters such as :name: or ?1 into PDO bind params ? + * Checks whether the connection is under a transaction * - * - * print_r( - * $connection->convertBoundParams( - * "SELECT FROM robots WHERE name = :name:", - * [ - * "Bender", - * ] - * ) + * ```php + * $connection->begin(); + * + * // true + * var_dump( + * $connection->isUnderTransaction() * ); - * + * ``` * - * @param string $sql - * @param array $params - * @return array + * @return bool */ - public function convertBoundParams($sql, array $params = array()) {} + public function isUnderTransaction(): bool {} /** - * Returns the insert id for the auto_increment/serial column inserted in the latest executed SQL statement + * Returns the insert id for the auto_increment/serial column inserted in + * the latest executed SQL statement * - * + * ```php * // Inserting a new robot * $success = $connection->insert( * "robots", @@ -250,72 +255,78 @@ public function convertBoundParams($sql, array $params = array()) {} * * // Getting the generated id * $id = $connection->lastInsertId(); - * + * ``` * - * @param string $sequenceName + * @param mixed $sequenceName * @return int|bool */ public function lastInsertId($sequenceName = null) {} /** - * Starts a transaction in the connection + * Returns a PDO prepared statement to be executed with 'executePrepared' * - * @param bool $nesting - * @return bool - */ - public function begin($nesting = true) {} - - /** - * Rollbacks the active transaction in the connection + * ```php + * use Phalcon\Db\Column; * - * @param bool $nesting - * @return bool - */ - public function rollback($nesting = true) {} - - /** - * Commits the active transaction in the connection + * $statement = $db->prepare( + * "SELECT FROM robots WHERE name = :name" + * ); * - * @param bool $nesting - * @return bool - */ - public function commit($nesting = true) {} - - /** - * Returns the current transaction nesting level + * $result = $connection->executePrepared( + * $statement, + * [ + * "name" => "Voltron", + * ], + * [ + * "name" => Column::BIND_PARAM_INT, + * ] + * ); + * ``` * - * @return int + * @param string $sqlStatement + * @return \PDOStatement */ - public function getTransactionLevel() {} + public function prepare(string $sqlStatement): \PDOStatement {} /** - * Checks whether the connection is under a transaction + * Sends SQL statements to the database server returning the success state. + * Use this method only when the SQL statement sent to the server is + * returning rows * - * - * $connection->begin(); + * ```php + * // Querying data + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = 'mechanical'" + * ); * - * // true - * var_dump( - * $connection->isUnderTransaction() + * $resultset = $connection->query( + * "SELECT FROM robots WHERE type = ?", + * [ + * "mechanical", + * ] * ); - * + * ``` * - * @return bool + * @param string $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes + * @return bool|\Phalcon\Db\ResultInterface */ - public function isUnderTransaction() {} + public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) {} /** - * Return internal PDO handler + * Rollbacks the active transaction in the connection * - * @return \Pdo + * @param bool $nesting + * @return bool */ - public function getInternalHandler() {} + public function rollback(bool $nesting = true): bool {} /** - * Return the error info, if any + * Returns PDO adapter DSN defaults as a key-value map. * * @return array */ - public function getErrorInfo() {} + abstract protected function getDsnDefaults(): array; } diff --git a/src/Phalcon/db/adapter/pdo/Factory.php b/src/Phalcon/db/adapter/pdo/Factory.php deleted file mode 100644 index 1a089408..00000000 --- a/src/Phalcon/db/adapter/pdo/Factory.php +++ /dev/null @@ -1,31 +0,0 @@ - - * use Phalcon\Db\Adapter\Pdo\Factory; - * - * $options = [ - * "host" => "localhost", - * "dbname" => "blog", - * "port" => 3306, - * "username" => "sigma", - * "password" => "secret", - * "adapter" => "mysql", - * ]; - * $db = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return \Phalcon\Db\AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index 9f505dd2..7e03f623 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Mysql - * * Specific functions for the Mysql database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -19,70 +17,81 @@ * ]; * * $connection = new Mysql($config); - * + * ``` */ -class Mysql extends \Phalcon\Db\Adapter\Pdo +class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'mysql'; - protected $_type = 'mysql'; - + /** + * @var string + */ + protected $type = 'mysql'; - protected $_dialectType = 'mysql'; + /** + * Adds a foreign key to a table + * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ReferenceInterface $reference + * @return bool + */ + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool {} /** * Returns an array of Phalcon\Db\Column objects describing a table * - * + * ```php * print_r( * $connection->describeColumns("posts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns($table, $schema = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** * Lists table indexes * - * + * ```php * print_r( * $connection->describeIndexes("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\IndexInterface[] + * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes($table, $schema = null) {} + public function describeIndexes(string $table, string $schema = null): array {} /** * Lists table references * - * + * ```php * print_r( * $connection->describeReferences("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ReferenceInterface[] + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences($table, $schema = null) {} + public function describeReferences(string $table, string $schema = null): array {} /** - * Adds a foreign key to a table + * Returns PDO adapter DSN defaults as a key-value map. * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference - * @return bool + * @return array */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 25eacf0b..16662427 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Postgresql - * * Specific functions for the Postgresql database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Postgresql; * * $config = [ @@ -19,40 +17,36 @@ * ]; * * $connection = new Postgresql($config); - * + * ``` */ -class Postgresql extends \Phalcon\Db\Adapter\Pdo +class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'postgresql'; - protected $_type = 'pgsql'; - - - protected $_dialectType = 'postgresql'; + /** + * @var string + */ + protected $type = 'pgsql'; /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection. + * Constructor for Phalcon\Db\Adapter\Pdo\Postgresql * * @param array $descriptor - * @return bool */ - public function connect(array $descriptor = null) {} + public function __construct(array $descriptor) {} /** - * Returns an array of Phalcon\Db\Column objects describing a table + * This method is automatically called in Phalcon\Db\Adapter\Pdo + * constructor. Call it when you need to restore a database connection. * - * - * print_r( - * $connection->describeColumns("posts") - * ); - * - * - * @param string $table - * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @param array $descriptor + * @return bool */ - public function describeColumns($table, $schema = null) {} + public function connect(array $descriptor = null): bool {} /** * Creates a table @@ -62,30 +56,42 @@ public function describeColumns($table, $schema = null) {} * @param array $definition * @return bool */ - public function createTable($tableName, $schemaName, array $definition) {} + public function createTable(string $tableName, string $schemaName, array $definition): bool {} /** - * Modifies a table column based on a definition + * Returns an array of Phalcon\Db\Column objects describing a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn - * @return bool + * ```php + * print_r( + * $connection->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** - * Check whether the database system requires an explicit value for identity columns + * Lists table references * - * @return bool + * ```php + * print_r( + * $connection->describeReferences("robots_parts") + * ); + * ``` + * + * @param string $table + * @param string $schema + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function useExplicitIdValue() {} + public function describeReferences(string $table, string $schema = null): array {} /** * Returns the default identity value to be inserted in an identity column * - * + * ```php * // Inserting a new robot with a valid default value for the column 'id' * $success = $connection->insert( * "robots", @@ -100,17 +106,44 @@ public function useExplicitIdValue() {} * "year", * ] * ); - * + * ``` * * @return \Phalcon\Db\RawValue */ - public function getDefaultIdValue() {} + public function getDefaultIdValue(): RawValue {} /** - * Check whether the database system requires a sequence to produce auto-numeric values + * Modifies a table column based on a definition * + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function supportSequences() {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} + + /** + * Check whether the database system requires a sequence to produce + * auto-numeric values + * + * @return bool + */ + public function supportSequences(): bool {} + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool {} + + /** + * Returns PDO adapter DSN defaults as a key-value map. + * + * @return array + */ + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index bcf551fa..8acf592d 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -3,11 +3,9 @@ namespace Phalcon\Db\Adapter\Pdo; /** - * Phalcon\Db\Adapter\Pdo\Sqlite - * * Specific functions for the Sqlite database system * - * + * ```php * use Phalcon\Db\Adapter\Pdo\Sqlite; * * $connection = new Sqlite( @@ -15,79 +13,81 @@ * "dbname" => "/tmp/test.sqlite", * ] * ); - * + * ``` */ -class Sqlite extends \Phalcon\Db\Adapter\Pdo +class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** + * @var string + */ + protected $dialectType = 'sqlite'; - protected $_type = 'sqlite'; - + /** + * @var string + */ + protected $type = 'sqlite'; - protected $_dialectType = 'sqlite'; + /** + * Constructor for Phalcon\Db\Adapter\Pdo\Sqlite + * + * @param array $descriptor + */ + public function __construct(array $descriptor) {} /** - * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. - * Call it when you need to restore a database connection. + * This method is automatically called in Phalcon\Db\Adapter\Pdo + * constructor. Call it when you need to restore a database connection. * * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null) {} + public function connect(array $descriptor = null): bool {} /** * Returns an array of Phalcon\Db\Column objects describing a table * - * + * ```php * print_r( * $connection->describeColumns("posts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\ColumnInterface[] + * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns($table, $schema = null) {} + public function describeColumns(string $table, string $schema = null): array {} /** * Lists table indexes * - * + * ```php * print_r( * $connection->describeIndexes("robots_parts") * ); - * + * ``` * * @param string $table * @param string $schema - * @return \Phalcon\Db\IndexInterface[] + * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes($table, $schema = null) {} + public function describeIndexes(string $table, string $schema = null): array {} /** * Lists table references * - * @param string table - * @param string schema - * @return Phalcon\Db\ReferenceInterface[] * @param string $table * @param string $schema - * @return \Phalcon\Db\ReferenceInterface[] - */ - public function describeReferences($table, $schema = null) {} - - /** - * Check whether the database system requires an explicit value for identity columns - * - * @return bool + * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function useExplicitIdValue() {} + public function describeReferences(string $table, string $schema = null): array {} /** - * Returns the default value to make the RBDM use the default value declared in the table definition + * Returns the default value to make the RBDM use the default value declared + * in the table definition * - * + * ```php * // Inserting a new robot with a valid default value for the column 'year' * $success = $connection->insert( * "robots", @@ -100,10 +100,25 @@ public function useExplicitIdValue() {} * "year", * ] * ); - * + * ``` * * @return \Phalcon\Db\RawValue */ - public function getDefaultValue() {} + public function getDefaultValue(): RawValue {} + + /** + * Check whether the database system requires an explicit value for identity + * columns + * + * @return bool + */ + public function useExplicitIdValue(): bool {} + + /** + * Returns PDO adapter DSN defaults as a key-value map. + * + * @return array + */ + protected function getDsnDefaults(): array {} } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 7f2170b0..85905487 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Mysql - * * Generates database specific SQL for the MySQL RDBMS */ class Mysql extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '`'; - - /** - * Gets the column name in MySQL - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '`'; + /** * Generates SQL to add a column to a table @@ -29,77 +21,100 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $columnName * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** * Generates SQL to delete a foreign key from a table @@ -109,26 +124,26 @@ public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInte * @param string $referenceName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param string $indexName * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** * Generates SQL to drop a table @@ -138,115 +153,121 @@ public function truncateTable($tableName, $schemaName) {} * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a view * * @param string $viewName - * @param array $definition * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to drop a view + * Gets the column name in MySQL * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL checking for the existence of a schema.table + * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. * - * - * echo $dialect->tableExists("posts", "blog"); + * @return string + */ + public function getForeignKeyChecks(): string {} + + /** + * List all tables in database * - * echo $dialect->tableExists("posts"); - * + * ```php + * print_r( + * $dialect->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to list all views of a schema or user * - * @param string $viewName * @param string $schemaName * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates SQL describing a table - * - * - * print_r( - * $dialect->describeColumns("posts") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function describeColumns($table, $schema = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * List all tables in database + * Returns a SQL modified with a LOCK IN SHARE MODE clause * - * - * print_r( - * $dialect->listTables("blog") - * ); - * + * ```php + * $sql = $dialect->sharedLock("SELECT FROM robots"); * - * @param string $schemaName + * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE + * ``` + * + * @param string $sqlQuery * @return string */ - public function listTables($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.table + * + * ```php + * echo $dialect->tableExists("posts", "blog"); + * + * echo $dialect->tableExists("posts"); + * ``` * + * @param string $tableName * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query indexes on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeIndexes($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL checking for the existence of a schema.view * - * @param string $table - * @param string $schema + * @param string $viewName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function viewExists(string $viewName, string $schemaName = null): string {} /** * Generates SQL to add the table creation options @@ -254,26 +275,23 @@ public function tableOptions($table, $schema = null) {} * @param array $definition * @return string */ - protected function _getTableOptions(array $definition) {} + protected function getTableOptions(array $definition): string {} /** - * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. + * Checks if the size and/or scale are present and encloses those values + * in parentheses if need be * + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getForeignKeyChecks() {} + private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string {} /** - * Returns a SQL modified with a LOCK IN SHARE MODE clause - * - * - * $sql = $dialect->sharedLock("SELECT FROM robots"); - * echo $sql; // SELECT FROM robots LOCK IN SHARE MODE - * + * Checks if a column is unsigned or not and returns the relevant SQL syntax * - * @param string $sqlQuery + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function sharedLock($sqlQuery) {} + private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string {} } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index ff800073..2ef5c5ff 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Postgresql - * * Generates database specific SQL for the PostgreSQL RDBMS */ class Postgresql extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '\\\"'; - - /** - * Gets the column name in PostgreSQL - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '\\\"'; + /** * Generates SQL to add a column to a table @@ -29,77 +21,100 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $columnName * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** * Generates SQL to delete a foreign key from a table @@ -109,26 +124,26 @@ public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInte * @param string $referenceName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName - * @param array $definition - * @return string|array + * @param string $indexName + * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** * Generates SQL to drop a table @@ -138,135 +153,120 @@ public function truncateTable($tableName, $schemaName) {} * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a view * * @param string $viewName - * @param array $definition * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL to drop a view + * Gets the column name in PostgreSQL * - * @param string $viewName - * @param string $schemaName - * @param bool $ifExists + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL checking for the existence of a schema.table - * - * - * echo $dialect->tableExists("posts", "blog"); + * List all tables in database * - * echo $dialect->tableExists("posts"); - * + * ```php + * print_r( + * $dialect->listTables("blog") + * ); + * ``` * - * @param string $tableName * @param string $schemaName * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** - * Generates SQL checking for the existence of a schema.view + * Generates the SQL to list all views of a schema or user * - * @param string $viewName * @param string $schemaName * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates SQL describing a table - * - * - * print_r( - * $dialect->describeColumns("posts") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function describeColumns($table, $schema = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * List all tables in database - * - * - * print_r( - * $dialect->listTables("blog") - * ); - * + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query * - * @param string $schemaName + * @param string $sqlQuery * @return string */ - public function listTables($schemaName = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates the SQL to list all views of a schema or user + * Generates SQL checking for the existence of a schema.table + * + * ```php + * echo $dialect->tableExists("posts", "blog"); * + * echo $dialect->tableExists("posts"); + * ``` + * + * @param string $tableName * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query indexes on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeIndexes($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeReferences($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL checking for the existence of a schema.view * - * @param string $table - * @param string $schema + * @param string $viewName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function viewExists(string $viewName, string $schemaName = null): string {} /** * @param \Phalcon\Db\ColumnInterface $column * @return string */ - protected function _castDefault(\Phalcon\Db\ColumnInterface $column) {} + protected function castDefault(\Phalcon\Db\ColumnInterface $column): string {} /** * @param array $definition * @return string */ - protected function _getTableOptions(array $definition) {} - - /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query - * - * @param string $sqlQuery - * @return string - */ - public function sharedLock($sqlQuery) {} + protected function getTableOptions(array $definition): string {} } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index f71e0ab8..f00fed05 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -3,23 +3,15 @@ namespace Phalcon\Db\Dialect; /** - * Phalcon\Db\Dialect\Sqlite - * - * Generates database specific SQL for the Sqlite RDBMS + * Generates database specific SQL for the SQLite RDBMS */ class Sqlite extends \Phalcon\Db\Dialect { - - protected $_escapeChar = '\\\"'; - - /** - * Gets the column name in SQLite - * - * @param \Phalcon\Db\ColumnInterface $column - * @return string + * @var string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} + protected $escapeChar = '\\\"'; + /** * Generates SQL to add a column to a table @@ -29,126 +21,147 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column) {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column) {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL to modify a column in a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function modifyColumn($tableName, $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null) {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} /** - * Generates SQL to delete a column from a table + * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param string $columnName + * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function dropColumn($tableName, $schemaName, $columnName) {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} /** - * Generates SQL to delete an index from a table + * Generates SQL to create a table * * @param string $tableName * @param string $schemaName - * @param string $indexName + * @param array $definition * @return string */ - public function dropIndex($tableName, $schemaName, $indexName) {} + public function createTable(string $tableName, string $schemaName, array $definition): string {} /** - * Generates SQL to add the primary key to a table + * Generates SQL to create a view * - * @param string $tableName + * @param string $viewName + * @param array $definition * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey($tableName, $schemaName, \Phalcon\Db\IndexInterface $index) {} + public function createView(string $viewName, array $definition, string $schemaName = null): string {} /** - * Generates SQL to delete primary key from a table + * Generates SQL describing a table * - * @param string $tableName - * @param string $schemaName + * ```php + * print_r( + * $dialect->describeColumns("posts") + * ); + * ``` + * + * @param string $table + * @param string $schema * @return string */ - public function dropPrimaryKey($tableName, $schemaName) {} + public function describeColumns(string $table, string $schema = null): string {} /** - * Generates SQL to add an index to a table + * Generates SQL to query indexes detail on a table * - * @param string $tableName - * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param string $index * @return string */ - public function addForeignKey($tableName, $schemaName, \Phalcon\Db\ReferenceInterface $reference) {} + public function describeIndex(string $index): string {} /** - * Generates SQL to delete a foreign key from a table + * Generates SQL to query indexes on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeIndexes(string $table, string $schema = null): string {} + + /** + * Generates SQL to query foreign keys on a table + * + * @param string $table + * @param string $schema + * @return string + */ + public function describeReferences(string $table, string $schema = null): string {} + + /** + * Generates SQL to delete a column from a table * * @param string $tableName * @param string $schemaName - * @param string $referenceName + * @param string $columnName * @return string */ - public function dropForeignKey($tableName, $schemaName, $referenceName) {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} /** - * Generates SQL to create a table + * Generates SQL to delete a foreign key from a table * * @param string $tableName * @param string $schemaName - * @param array $definition + * @param string $referenceName * @return string */ - public function createTable($tableName, $schemaName, array $definition) {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} /** - * Generates SQL to truncate a table + * Generates SQL to delete an index from a table * * @param string $tableName * @param string $schemaName + * @param string $indexName * @return string */ - public function truncateTable($tableName, $schemaName) {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} /** - * Generates SQL to drop a table + * Generates SQL to delete primary key from a table * * @param string $tableName * @param string $schemaName - * @param bool $ifExists * @return string */ - public function dropTable($tableName, $schemaName = null, $ifExists = true) {} + public function dropPrimaryKey(string $tableName, string $schemaName): string {} /** - * Generates SQL to create a view + * Generates SQL to drop a table * - * @param string $viewName - * @param array $definition + * @param string $tableName * @param string $schemaName + * @param bool $ifExists * @return string */ - public function createView($viewName, array $definition, $schemaName = null) {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} /** * Generates SQL to drop a view @@ -158,60 +171,54 @@ public function createView($viewName, array $definition, $schemaName = null) {} * @param bool $ifExists * @return string */ - public function dropView($viewName, $schemaName = null, $ifExists = true) {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} /** - * Generates SQL checking for the existence of a schema.table + * Returns a SQL modified with a FOR UPDATE clause. For SQLite it returns + * the original query * - * - * echo $dialect->tableExists("posts", "blog"); - * - * echo $dialect->tableExists("posts"); - * - * - * @param string $tableName - * @param string $schemaName + * @param string $sqlQuery * @return string */ - public function tableExists($tableName, $schemaName = null) {} + public function forUpdate(string $sqlQuery): string {} /** - * Generates SQL checking for the existence of a schema.view + * Gets the column name in SQLite * - * @param string $viewName - * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function viewExists($viewName, $schemaName = null) {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} /** - * Generates SQL describing a table + * Generates the SQL to get query list of indexes * - * + * ```php * print_r( - * $dialect->describeColumns("posts") + * $dialect->listIndexesSql("blog") * ); - * + * ``` * * @param string $table * @param string $schema + * @param string $keyName * @return string */ - public function describeColumns($table, $schema = null) {} + public function listIndexesSql(string $table, string $schema = null, string $keyName = null): string {} /** * List all tables in database * - * + * ```php * print_r( * $dialect->listTables("blog") * ); - * + * ``` * * @param string $schemaName * @return string */ - public function listTables($schemaName = null) {} + public function listTables(string $schemaName = null): string {} /** * Generates the SQL to list all views of a schema or user @@ -219,66 +226,68 @@ public function listTables($schemaName = null) {} * @param string $schemaName * @return string */ - public function listViews($schemaName = null) {} + public function listViews(string $schemaName = null): string {} /** - * Generates the SQL to get query list of indexes - * - * - * print_r( - * $dialect->listIndexesSql("blog") - * ); - * + * Generates SQL to modify a column in a table * - * @param string $table - * @param string $schema - * @param string $keyName + * @param string $tableName + * @param string $schemaName + * @param \Phalcon\Db\ColumnInterface $column + * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function listIndexesSql($table, $schema = null, $keyName = null) {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} /** - * Generates SQL to query indexes on a table + * Returns a SQL modified a shared lock statement. For now this method + * returns the original query * - * @param string $table - * @param string $schema + * @param string $sqlQuery * @return string */ - public function describeIndexes($table, $schema = null) {} + public function sharedLock(string $sqlQuery): string {} /** - * Generates SQL to query indexes detail on a table + * Generates SQL checking for the existence of a schema.table * - * @param string $index + * ```php + * echo $dialect->tableExists("posts", "blog"); + * + * echo $dialect->tableExists("posts"); + * ``` + * + * @param string $tableName + * @param string $schemaName * @return string */ - public function describeIndex($index) {} + public function tableExists(string $tableName, string $schemaName = null): string {} /** - * Generates SQL to query foreign keys on a table + * Generates the SQL to describe the table creation options * * @param string $table * @param string $schema * @return string */ - public function describeReferences($table, $schema = null) {} + public function tableOptions(string $table, string $schema = null): string {} /** - * Generates the SQL to describe the table creation options + * Generates SQL to truncate a table * - * @param string $table - * @param string $schema + * @param string $tableName + * @param string $schemaName * @return string */ - public function tableOptions($table, $schema = null) {} + public function truncateTable(string $tableName, string $schemaName): string {} /** - * Returns a SQL modified a shared lock statement. For now this method - * returns the original query + * Generates SQL checking for the existence of a schema.view * - * @param string $sqlQuery + * @param string $viewName + * @param string $schemaName * @return string */ - public function sharedLock($sqlQuery) {} + public function viewExists(string $viewName, string $schemaName = null): string {} } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 80149305..8e0bce9e 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -3,75 +3,73 @@ namespace Phalcon\Db\Profiler; /** - * Phalcon\Db\Profiler\Item - * * This class identifies each profile in a Phalcon\Db\Profiler */ class Item { /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @var string + * @var double */ - protected $_sqlStatement; + protected $finalTime; /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @var array + * @var double */ - protected $_sqlVariables; + protected $initialTime; /** * SQL bind types related to the profile * * @var array */ - protected $_sqlBindTypes; + protected $sqlBindTypes; /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @var double + * @var string */ - protected $_initialTime; + protected $sqlStatement; /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @var double + * @var array */ - protected $_finalTime; + protected $sqlVariables; /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @param string $sqlStatement + * @param double $finalTime */ - public function setSqlStatement($sqlStatement) {} + public function setFinalTime(float $finalTime) {} /** - * SQL statement related to the profile + * Timestamp when the profile ended * - * @return string + * @return double */ - public function getSqlStatement() {} + public function getFinalTime(): float {} /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @param array $sqlVariables + * @param double $initialTime */ - public function setSqlVariables(array $sqlVariables) {} + public function setInitialTime(float $initialTime) {} /** - * SQL variables related to the profile + * Timestamp when the profile started * - * @return array + * @return double */ - public function getSqlVariables() {} + public function getInitialTime(): float {} /** * SQL bind types related to the profile @@ -85,41 +83,41 @@ public function setSqlBindTypes(array $sqlBindTypes) {} * * @return array */ - public function getSqlBindTypes() {} + public function getSqlBindTypes(): array {} /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @param double $initialTime + * @param string $sqlStatement */ - public function setInitialTime($initialTime) {} + public function setSqlStatement(string $sqlStatement) {} /** - * Timestamp when the profile started + * SQL statement related to the profile * - * @return double + * @return string */ - public function getInitialTime() {} + public function getSqlStatement(): string {} /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @param double $finalTime + * @param array $sqlVariables */ - public function setFinalTime($finalTime) {} + public function setSqlVariables(array $sqlVariables) {} /** - * Timestamp when the profile ended + * SQL variables related to the profile * - * @return double + * @return array */ - public function getFinalTime() {} + public function getSqlVariables(): array {} /** * Returns the total time in seconds spent by the profile * * @return double */ - public function getTotalElapsedSeconds() {} + public function getTotalElapsedSeconds(): float {} } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index b7d9bdfa..42675919 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -3,89 +3,109 @@ namespace Phalcon\Db\Result; /** - * Phalcon\Db\Result\Pdo - * * Encapsulates the resultset internals * - * + * ```php * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM + * \Phalcon\Db\Enum::FETCH_NUM * ); * * while ($robot = $result->fetchArray()) { * print_r($robot); * } - * + * ``` */ class Pdo implements \Phalcon\Db\ResultInterface { - protected $_connection; + protected $bindParams; + + + protected $bindTypes; - protected $_result; + protected $connection; /** * Active fetch mode */ - protected $_fetchMode = Db::FETCH_OBJ; + protected $fetchMode = Enum::FETCH_OBJ; /** * Internal resultset * * @var \PDOStatement */ - protected $_pdoStatement; - - - protected $_sqlStatement; + protected $pdoStatement; - protected $_bindParams; + protected $result; - protected $_bindTypes; + protected $rowCount = false; - protected $_rowCount = false; + protected $sqlStatement; /** * Phalcon\Db\Result\Pdo constructor * - * @param \Phalcon\Db\AdapterInterface $connection + * @param Db\AdapterInterface $connection * @param \PDOStatement $result - * @param string $sqlStatement - * @param array $bindParams - * @param array $bindTypes + * @param mixed $sqlStatement + * @param mixed $bindParams + * @param mixed $bindTypes */ public function __construct(Db\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} /** - * Allows to execute the statement again. Some database systems don't support scrollable cursors, - * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining + * Moves internal resultset cursor to another position letting us to fetch a + * certain row + * + * ```php + * $result = $connection->query( + * "SELECT FROM robots ORDER BY name" + * ); + * + * // Move to third row on result + * $result->dataSeek(2); + * + * // Fetch third row + * $row = $result->fetch(); + * ``` + * + * @param long $number + */ + public function dataSeek(int $number) {} + + /** + * Allows to execute the statement again. Some database systems don't + * support scrollable cursors. So, as cursors are forward only, we need to + * execute the cursor again to fetch rows from the begining * * @return bool */ - public function execute() {} + public function execute(): bool {} /** - * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * Fetches an array/object of strings that corresponds to the fetched row, + * or FALSE if there are no more rows. This method is affected by the active + * fetch flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * + * ```php * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( - * \Phalcon\Db::FETCH_OBJ + * \Phalcon\Enum::FETCH_OBJ * ); * * while ($robot = $result->fetch()) { * echo $robot->name; * } - * + * ``` * * @param mixed $fetchStyle * @param mixed $cursorOrientation @@ -93,114 +113,97 @@ public function execute() {} */ public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) {} - /** - * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode - * - * - * $result = $connection->query("SELECT FROM robots ORDER BY name"); - * - * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM - * ); - * - * while ($robot = result->fetchArray()) { - * print_r($robot); - * } - * - */ - public function fetchArray() {} - /** * Returns an array of arrays containing all the records in the result - * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode + * This method is affected by the active fetch flag set using + * `Phalcon\Db\Result\Pdo::setFetchMode()` * - * + * ```php * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * * $robots = $result->fetchAll(); - * + * ``` * * @param mixed $fetchStyle * @param mixed $fetchArgument * @param mixed $ctorArgs * @return array */ - public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null) {} + public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null): array {} /** - * Gets number of rows returned by a resultset + * Returns an array of strings that corresponds to the fetched row, or FALSE + * if there are no more rows. This method is affected by the active fetch + * flag set using `Phalcon\Db\Result\Pdo::setFetchMode()` * - * - * $result = $connection->query( - * "SELECT FROM robots ORDER BY name" + * ```php + * $result = $connection->query("SELECT FROM robots ORDER BY name"); + * + * $result->setFetchMode( + * \Phalcon\Enum::FETCH_NUM * ); * - * echo "There are ", $result->numRows(), " rows in the resultset"; - * + * while ($robot = result->fetchArray()) { + * print_r($robot); + * } + * ``` + */ + public function fetchArray() {} + + /** + * Gets the internal PDO result object * - * @return int + * @return \PDOStatement */ - public function numRows() {} + public function getInternalResult(): \PDOStatement {} /** - * Moves internal resultset cursor to another position letting us to fetch a certain row + * Gets number of rows returned by a resultset * - * + * ```php * $result = $connection->query( * "SELECT FROM robots ORDER BY name" * ); * - * // Move to third row on result - * $result->dataSeek(2); - * - * // Fetch third row - * $row = $result->fetch(); - * + * echo "There are ", $result->numRows(), " rows in the resultset"; + * ``` * - * @param long $number + * @return int */ - public function dataSeek($number) {} + public function numRows(): int {} /** * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * - * + * ```php * // Return array with integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_NUM + * \Phalcon\Enum::FETCH_NUM * ); * * // Return associative array without integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_ASSOC + * \Phalcon\Enum::FETCH_ASSOC * ); * * // Return associative array together with integer indexes * $result->setFetchMode( - * \Phalcon\Db::FETCH_BOTH + * \Phalcon\Enum::FETCH_BOTH * ); * * // Return an object * $result->setFetchMode( - * \Phalcon\Db::FETCH_OBJ + * \Phalcon\Enum::FETCH_OBJ * ); - * + * ``` * * @param int $fetchMode * @param mixed $colNoOrClassNameOrObject * @param mixed $ctorargs * @return bool */ - public function setFetchMode($fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null) {} - - /** - * Gets the internal PDO result object - * - * @return \PDOStatement - */ - public function getInternalResult() {} + public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool {} } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index a1bc563f..96186819 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -3,68 +3,73 @@ namespace Phalcon\Debug; /** - * Phalcon\Debug\Dump - * * Dumps information about a variable(s) * - * + * ```php * $foo = 123; * * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * + * ``` * - * + * ```php * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * + * ``` */ class Dump { + /** + * @var bool + */ + protected $detailed = false; - protected $_detailed = false; - - - protected $_methods = array(); - - - protected $_styles; + /** + * @var array + */ + protected $methods = array(); + /** + * @var array + */ + protected $styles = array(); - public function getDetailed() {} + /** + * @return bool + */ + public function getDetailed(): bool {} /** - * @param mixed $detailed + * @param bool $detailed */ - public function setDetailed($detailed) {} + public function setDetailed(bool $detailed) {} /** * Phalcon\Debug\Dump constructor * * @param array $styles - * @param boolean $detailed debug object's private and protected properties + * @param bool $detailed */ - public function __construct(array $styles = array(), $detailed = false) {} + public function __construct(array $styles = array(), bool $detailed = false) {} /** * Alias of variables() method * - * @param mixed $variable - * @param ... * @return string */ - public function all() {} + public function all(): string {} /** - * Get style for type + * Alias of variable() method * - * @param string $type + * @param mixed $variable + * @param string $name * @return string */ - protected function getStyle($type) {} + public function one($variable, string $name = null): string {} /** * Set styles for vars type @@ -72,77 +77,74 @@ protected function getStyle($type) {} * @param array $styles * @return array */ - public function setStyles(array $styles = array()) {} + public function setStyles(array $styles = array()): array {} /** - * Alias of variable() method + * Returns an JSON string of information about a single variable. * - * @param mixed $variable - * @param string $name - * @return string - */ - public function one($variable, $name = null) {} - - /** - * Prepare an HTML string of information about a single variable. + * ```php + * $foo = [ + * "key" => "value", + * ]; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * + * $foo = new stdClass(); + * $foo->bar = "buz"; + * + * echo (new \Phalcon\Debug\Dump())->toJson($foo); + * ``` * * @param mixed $variable - * @param string $name - * @param int $tab * @return string */ - protected function output($variable, $name = null, $tab = 1) {} + public function toJson($variable): string {} /** * Returns an HTML string of information about a single variable. * - * + * ```php * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); - * + * ``` * * @param mixed $variable * @param string $name * @return string */ - public function variable($variable, $name = null) {} + public function variable($variable, string $name = null): string {} /** * Returns an HTML string of debugging information about any number of * variables, each wrapped in a "pre" tag. * - * + * ```php * $foo = "string"; * $bar = ["key" => "value"]; * $baz = new stdClass(); * * echo (new \Phalcon\Debug\Dump())->variables($foo, $bar, $baz); - * + * ``` * - * @param mixed $variable - * @param ... * @return string */ - public function variables() {} + public function variables(): string {} /** - * Returns an JSON string of information about a single variable. - * - * - * $foo = [ - * "key" => "value", - * ]; - * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * - * $foo = new stdClass(); - * $foo->bar = "buz"; + * Get style for type * - * echo (new \Phalcon\Debug\Dump())->toJson($foo); - * + * @param string $type + * @return string + */ + protected function getStyle(string $type): string {} + + /** + * Prepare an HTML string of information about a single variable. * * @param mixed $variable + * @param string $name + * @param int $tab * @return string */ - public function toJson($variable) {} + protected function output($variable, string $name = null, int $tab = 1): string {} } diff --git a/src/Phalcon/debug/Exception.php b/src/Phalcon/debug/Exception.php index ea6c9862..9616f511 100644 --- a/src/Phalcon/debug/Exception.php +++ b/src/Phalcon/debug/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Debug; /** - * Phalcon\Debug\Exception - * * Exceptions thrown in Phalcon\Debug will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/DiInterface.php b/src/Phalcon/di/DiInterface.php similarity index 63% rename from src/Phalcon/DiInterface.php rename to src/Phalcon/di/DiInterface.php index a250d834..0e63ebd8 100644 --- a/src/Phalcon/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -1,41 +1,13 @@ + * ```php * $service = new \Phalcon\Di\Service( * "request", - * "Phalcon\\Http\\Request" + * \Phalcon\Http\Request::class * ); * * $request = service->resolve(); - * + * ``` */ class Service implements \Phalcon\Di\ServiceInterface { - protected $_name; - - - protected $_definition; - - - protected $_shared = false; + protected $definition; + /** + * @var bool + */ + protected $resolved = false; - protected $_resolved = false; + /** + * @var bool + */ + protected $shared = false; - protected $_sharedInstance; + protected $sharedInstance; /** * Phalcon\Di\Service * - * @param string $name * @param mixed $definition - * @param boolean $shared + * @param bool $shared */ - public final function __construct($name, $definition, $shared = false) {} + final public function __construct($definition, bool $shared = false) {} /** - * Returns the service's name + * Returns the service definition * - * @return string + * @return mixed */ - public function getName() {} + public function getDefinition() {} /** - * Sets if the service is shared or not + * Returns a parameter in a specific position * - * @param bool $shared + * @param int $position + * @return array */ - public function setShared($shared) {} + public function getParameter(int $position) {} /** - * Check whether the service is shared or not + * Returns true if the service was resolved * * @return bool */ - public function isShared() {} - - /** - * Sets/Resets the shared instance related to the service - * - * @param mixed $sharedInstance - */ - public function setSharedInstance($sharedInstance) {} + public function isResolved(): bool {} /** - * Set the service definition + * Check whether the service is shared or not * - * @param mixed $definition + * @return bool */ - public function setDefinition($definition) {} + public function isShared(): bool {} /** - * Returns the service definition + * Resolves the service * + * @param array $parameters + * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function getDefinition() {} + public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) {} /** - * Resolves the service + * Set the service definition * - * @param array $parameters - * @param \Phalcon\DiInterface $dependencyInjector - * @return mixed + * @param mixed $definition */ - public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null) {} + public function setDefinition($definition) {} /** * Changes a parameter in the definition without resolve the service @@ -101,29 +93,20 @@ public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInje * @param array $parameter * @return \Phalcon\Di\ServiceInterface */ - public function setParameter($position, array $parameter) {} - - /** - * Returns a parameter in a specific position - * - * @param int $position - * @return array - */ - public function getParameter($position) {} + public function setParameter(int $position, array $parameter): ServiceInterface {} /** - * Returns true if the service was resolved + * Sets if the service is shared or not * - * @return bool + * @param bool $shared */ - public function isResolved() {} + public function setShared(bool $shared) {} /** - * Restore the internal state of a service + * Sets/Resets the shared instance related to the service * - * @param array $attributes - * @return \Phalcon\Di\ServiceInterface + * @param mixed $sharedInstance */ - public static function __set_state(array $attributes) {} + public function setSharedInstance($sharedInstance) {} } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index 9277779a..a7447ae8 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -3,56 +3,55 @@ namespace Phalcon\Di; /** - * Phalcon\Di\ServiceInterface - * * Represents a service in the services container */ interface ServiceInterface { /** - * Returns the service's name + * Returns the service definition * - * @param string + * @return mixed */ - public function getName(); + public function getDefinition(); /** - * Sets if the service is shared or not + * Returns a parameter in a specific position * - * @param bool $shared + * @param int $position + * @return array */ - public function setShared($shared); + public function getParameter(int $position); /** - * Check whether the service is shared or not + * Returns true if the service was resolved * * @return bool */ - public function isShared(); + public function isResolved(): bool; /** - * Set the service definition + * Check whether the service is shared or not * - * @param mixed $definition + * @return bool */ - public function setDefinition($definition); + public function isShared(): bool; /** - * Returns the service definition + * Resolves the service * + * @param array $parameters + * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function getDefinition(); + public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null); /** - * Resolves the service + * Set the service definition * - * @param array $parameters - * @param \Phalcon\DiInterface $dependencyInjector - * @return mixed + * @param mixed $definition */ - public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInjector = null); + public function setDefinition($definition); /** * Changes a parameter in the definition without resolve the service @@ -61,14 +60,13 @@ public function resolve($parameters = null, \Phalcon\DiInterface $dependencyInje * @param array $parameter * @return ServiceInterface */ - public function setParameter($position, array $parameter); + public function setParameter(int $position, array $parameter): ServiceInterface; /** - * Restore the internal state of a service + * Sets if the service is shared or not * - * @param array $attributes - * @return ServiceInterface + * @param bool $shared */ - public static function __set_state(array $attributes); + public function setShared(bool $shared); } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index 61c53270..e61eaedb 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -3,27 +3,28 @@ namespace Phalcon\Di; /** - * Phalcon\Di\ServiceProviderInterface + * Should be implemented by service providers, or such components, which + * register a service in the service container. * - * Should be implemented by service providers, or such components, - * which register a service in the service container. - * - * + * ```php * namespace Acme; * - * use Phalcon\DiInterface; + * use Phalcon\Di\DiInterface; * use Phalcon\Di\ServiceProviderInterface; * * class SomeServiceProvider implements ServiceProviderInterface * { * public function register(DiInterface $di) * { - * $di->setShared('service', function () { - * // ... - * }); + * $di->setShared( + * 'service', + * function () { + * // ... + * } + * ); * } * } - * + * ``` */ interface ServiceProviderInterface { @@ -31,8 +32,8 @@ interface ServiceProviderInterface /** * Registers a service provider. * - * @param \Phalcon\DiInterface $di + * @param \Phalcon\Di\DiInterface $di */ - public function register(\Phalcon\DiInterface $di); + public function register(\Phalcon\Di\DiInterface $di); } diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php new file mode 100644 index 00000000..15c7d6b3 --- /dev/null +++ b/src/Phalcon/di/exception/ServiceResolutionException.php @@ -0,0 +1,11 @@ +false if an exception occurred and the operation was + * stopped by returning false in the exception handler. + * + * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. + * @return object|bool + */ + public function dispatch(): bool {} /** - * Sets the dependency injector + * Forwards the execution flow to another controller/action. * - * @param \Phalcon\DiInterface $dependencyInjector + * ```php + * $this->dispatcher->forward( + * [ + * "controller" => "posts", + * "action" => "index", + * ] + * ); + * ``` + * + * @throws \Phalcon\Exception + * @param array $forward */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function forward(array $forward) {} /** - * Returns the internal dependency injector + * Gets the latest dispatched action name * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getActionName(): string {} /** - * Sets the events manager + * Gets the default action suffix * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return string */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function getActionSuffix(): string {} /** - * Returns the internal event manager + * Returns the current method to be/executed in the dispatcher * - * @return \Phalcon\Events\ManagerInterface + * @return string */ - public function getEventsManager() {} + public function getActiveMethod(): string {} /** - * Sets the default action suffix + * Returns bound models from binder instance * - * @param string $actionSuffix + * ```php + * class UserController extends Controller + * { + * public function showAction(User $user) + * { + * // return array with $user + * $boundModels = $this->dispatcher->getBoundModels(); + * } + * } + * ``` + * + * @return array */ - public function setActionSuffix($actionSuffix) {} + public function getBoundModels(): array {} /** - * Gets the default action suffix + * Returns the default namespace * * @return string */ - public function getActionSuffix() {} + public function getDefaultNamespace(): string {} /** - * Sets the module where the controller is (only informative) + * Returns the internal dependency injector * - * @param string $moduleName + * @return \Phalcon\Di\DiInterface */ - public function setModuleName($moduleName) {} + public function getDI(): DiInterface {} /** - * Gets the module where the controller class is + * Returns the internal event manager * - * @return string + * @return \Phalcon\Events\ManagerInterface */ - public function getModuleName() {} + public function getEventsManager(): ManagerInterface {} /** - * Sets the namespace where the controller class is + * Gets the default handler suffix * - * @param string $namespaceName + * @return string */ - public function setNamespaceName($namespaceName) {} + public function getHandlerSuffix(): string {} /** - * Gets a namespace to be prepended to the current handler name + * Gets model binder * - * @return string + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getNamespaceName() {} + public function getModelBinder(): ?BinderInterface {} /** - * Sets the default namespace + * Gets the module where the controller class is * - * @param string $namespaceName + * @return string */ - public function setDefaultNamespace($namespaceName) {} + public function getModuleName(): string {} /** - * Returns the default namespace + * Gets a namespace to be prepended to the current handler name * * @return string */ - public function getDefaultNamespace() {} + public function getNamespaceName(): string {} /** - * Sets the default action name + * Gets a param by its name or numeric index * - * @param string $actionName + * @param mixed $param + * @param string|array $filters + * @param mixed $defaultValue + * @return mixed */ - public function setDefaultAction($actionName) {} + public function getParam($param, $filters = null, $defaultValue = null) {} /** - * Sets the action name to be dispatched + * Gets action params * - * @param string $actionName + * @return array */ - public function setActionName($actionName) {} + public function getParams(): array {} /** - * Gets the latest dispatched action name + * Check if a param exists * - * @return string + * @param mixed $param + * @return bool */ - public function getActionName() {} + public function hasParam($param): bool {} /** - * Sets action params to be dispatched + * Checks if the dispatch loop is finished or has more pendent + * controllers/tasks to dispatch * - * @param array $params + * @return bool */ - public function setParams($params) {} + public function isFinished(): bool {} /** - * Gets action params + * Sets the action name to be dispatched * - * @return array + * @param string $actionName */ - public function getParams() {} + public function setActionName(string $actionName) {} /** - * Set a param by its name or numeric index + * Sets the default action name * - * @param mixed $param - * @param mixed $value + * @param string $actionName */ - public function setParam($param, $value) {} + public function setDefaultAction(string $actionName) {} /** - * Gets a param by its name or numeric index + * Sets the default namespace * - * @param mixed $param - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @param string $namespaceName */ - public function getParam($param, $filters = null, $defaultValue = null) {} + public function setDefaultNamespace(string $namespaceName) {} /** - * Check if a param exists + * Sets the dependency injector * - * @param mixed $param - * @return bool + * @param \Phalcon\Di\DiInterface $container */ - public function hasParam($param) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns the current method to be/executed in the dispatcher + * Possible class name that will be located to dispatch the request * * @return string */ - public function getActiveMethod() {} + public function getHandlerClass(): string {} /** - * Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch + * Set a param by its name or numeric index * - * @return bool + * @param mixed $param + * @param mixed $value + */ + public function setParam($param, $value) {} + + /** + * Sets action params to be dispatched + * + * @param array $params */ - public function isFinished() {} + public function setParams(array $params) {} /** * Sets the latest returned value by an action manually @@ -265,130 +326,88 @@ public function isFinished() {} public function setReturnedValue($value) {} /** - * Returns value returned by the latest dispatched action + * Sets the default action suffix * - * @return mixed + * @param string $actionSuffix */ - public function getReturnedValue() {} + public function setActionSuffix(string $actionSuffix) {} /** - * Enable/Disable model binding during dispatch - * - * - * $di->set('dispatcher', function() { - * $dispatcher = new Dispatcher(); + * Sets the events manager * - * $dispatcher->setModelBinding(true, 'cache'); - * return $dispatcher; - * }); - * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + + /** + * Sets the default suffix for the handler * - * @deprecated 3.1.0 Use setModelBinder method - * @see Phalcon\Dispatcher::setModelBinder() - * @param bool $value - * @param mixed $cache - * @deprecated - * @return Dispatcher + * @param string $handlerSuffix */ - public function setModelBinding($value, $cache = null) {} + public function setHandlerSuffix(string $handlerSuffix) {} /** * Enable model binding during dispatch * - * - * $di->set('dispatcher', function() { - * $dispatcher = new Dispatcher(); + * ```php + * $di->set( + * 'dispatcher', + * function() { + * $dispatcher = new Dispatcher(); * - * $dispatcher->setModelBinder(new Binder(), 'cache'); - * return $dispatcher; - * }); - * + * $dispatcher->setModelBinder( + * new Binder(), + * 'cache' + * ); + * + * return $dispatcher; + * } + * ); + * ``` * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Dispatcher */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher {} /** - * Gets model binder + * Sets the module where the controller is (only informative) * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param string $moduleName */ - public function getModelBinder() {} + public function setModuleName(string $moduleName) {} /** - * Process the results of the router by calling into the appropriate controller action(s) - * including any routing data or injected parameters. - * - * @return object|false Returns the dispatched handler class (the Controller for Mvc dispatching or a Task - * for CLI dispatching) or false if an exception occurred and the operation was - * stopped by returning false in the exception handler. + * Sets the namespace where the controller class is * - * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. + * @param string $namespaceName */ - public function dispatch() {} + public function setNamespaceName(string $namespaceName) {} /** - * Forwards the execution flow to another controller/action. - * - * - * $this->dispatcher->forward( - * [ - * "controller" => "posts", - * "action" => "index", - * ] - * ); - * - * - * @param array forward + * Returns value returned by the latest dispatched action * - * @throws \Phalcon\Exception - * @param mixed $forward + * @return mixed */ - public function forward($forward) {} + public function getReturnedValue() {} /** * Check if the current executed action was forwarded by another one * * @return bool */ - public function wasForwarded() {} - - /** - * Possible class name that will be located to dispatch the request - * - * @return string - */ - public function getHandlerClass() {} - - /** - * @param mixed $handler - * @param string $actionMethod - * @param array $params - */ - public function callActionMethod($handler, $actionMethod, array $params = array()) {} + public function wasForwarded(): bool {} /** - * Returns bound models from binder instance - * - * - * class UserController extends Controller - * { - * public function showAction(User $user) - * { - * $boundModels = $this->dispatcher->getBoundModels(); // return array with $user - * } - * } - * - * - * @return array + * Set empty properties to their defaults (where defaults are available) */ - public function getBoundModels() {} + protected function resolveEmptyProperties() {} /** - * Set empty properties to their defaults (where defaults are available) + * @param string $input + * @return string */ - protected function _resolveEmptyProperties() {} + protected function toCamelCase(string $input): string {} } diff --git a/src/Phalcon/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php similarity index 63% rename from src/Phalcon/DispatcherInterface.php rename to src/Phalcon/dispatcher/DispatcherInterface.php index c7858384..e28b1de8 100644 --- a/src/Phalcon/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -1,136 +1,149 @@ isCancelable()) { + * $event->stop(); + * } + * ``` + * + * @return bool */ - public function setData($data = null) {} + public function isCancelable(): bool {} /** - * Sets event type. + * Check whether the event is currently stopped. * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType($type) {} + public function isStopped(): bool {} /** - * Stops the event preventing propagation. - * - * - * if ($event->isCancelable()) { - * $event->stop(); - * } - * + * Sets event data. * + * @param mixed $data * @return EventInterface */ - public function stop() {} + public function setData($data = null): EventInterface {} /** - * Check whether the event is currently stopped. + * Sets event type. * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped() {} + public function setType(string $type): EventInterface {} /** - * Check whether the event is cancelable. + * Stops the event preventing propagation. * - * + * ```php * if ($event->isCancelable()) { * $event->stop(); * } - * + * ``` * - * @return bool + * @return EventInterface */ - public function isCancelable() {} + public function stop(): EventInterface {} } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index de3427cc..92f60516 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -18,47 +18,47 @@ interface EventInterface public function getData(); /** - * Sets event data + * Gets event type * - * @param mixed $data - * @return EventInterface + * @return mixed */ - public function setData($data = null); + public function getType(); /** - * Gets event type + * Check whether the event is cancelable * - * @return mixed + * @return bool */ - public function getType(); + public function isCancelable(): bool; /** - * Sets event type + * Check whether the event is currently stopped * - * @param string $type - * @return EventInterface + * @return bool */ - public function setType($type); + public function isStopped(): bool; /** - * Stops the event preventing propagation + * Sets event data * + * @param mixed $data * @return EventInterface */ - public function stop(); + public function setData($data = null): EventInterface; /** - * Check whether the event is currently stopped + * Sets event type * - * @return bool + * @param string $type + * @return EventInterface */ - public function isStopped(); + public function setType(string $type): EventInterface; /** - * Check whether the event is cancelable + * Stops the event preventing propagation * - * @return bool + * @return EventInterface */ - public function isCancelable(); + public function stop(): EventInterface; } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index 903a9bb8..a7fcff43 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -5,23 +5,24 @@ /** * Phalcon\Events\EventsAwareInterface * - * This interface must for those classes that accept an EventsManager and dispatch events + * This interface must for those classes that accept an EventsManager and + * dispatch events */ interface EventsAwareInterface { /** - * Sets the events manager + * Returns the internal event manager * - * @param ManagerInterface $eventsManager + * @return ManagerInterface */ - public function setEventsManager(ManagerInterface $eventsManager); + public function getEventsManager(): ManagerInterface; /** - * Returns the internal event manager + * Sets the events manager * - * @return ManagerInterface + * @param ManagerInterface $eventsManager */ - public function getEventsManager(); + public function setEventsManager(ManagerInterface $eventsManager); } diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index d1227745..39b3fb35 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -5,23 +5,31 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, - * the normal flow of operation. With the EventsManager the developer can create hooks or - * plugins that will offer monitoring of data, manipulation, conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if + * needed, the normal flow of operation. With the EventsManager the developer + * can create hooks or plugins that will offer monitoring of data, manipulation, + * conditional execution and much more. */ class Manager implements \Phalcon\Events\ManagerInterface { - protected $_events = null; + const DEFAULT_PRIORITY = 100; + /** + * @var bool + */ + protected $collect = false; - protected $_collect = false; + /** + * @var bool + */ + protected $enablePriorities = false; - protected $_enablePriorities = false; + protected $events = null; - protected $_responses; + protected $responses; /** @@ -31,83 +39,85 @@ class Manager implements \Phalcon\Events\ManagerInterface * @param object|callable $handler * @param int $priority */ - public function attach($eventType, $handler, $priority = 100) {} + public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) {} /** - * Detach the listener from the events manager + * Returns if priorities are enabled * - * @param string $eventType - * @param object $handler + * @return bool */ - public function detach($eventType, $handler) {} + public function arePrioritiesEnabled(): bool {} /** - * Set if priorities are enabled in the EventsManager + * Tells the event manager if it needs to collect all the responses returned + * by every registered listener in a single fire * - * @param bool $enablePriorities + * @param bool $collect */ - public function enablePriorities($enablePriorities) {} + public function collectResponses(bool $collect) {} /** - * Returns if priorities are enabled + * Detach the listener from the events manager * - * @return bool + * @param string $eventType + * @param object $handler */ - public function arePrioritiesEnabled() {} + public function detach(string $eventType, $handler) {} /** - * Tells the event manager if it needs to collect all the responses returned by every - * registered listener in a single fire + * Removes all events from the EventsManager * - * @param bool $collect + * @param string $type */ - public function collectResponses($collect) {} + public function detachAll(string $type = null) {} /** - * Check if the events manager is collecting all all the responses returned by every - * registered listener in a single fire + * Set if priorities are enabled in the EventsManager * - * @return bool + * @param bool $enablePriorities */ - public function isCollecting() {} + public function enablePriorities(bool $enablePriorities) {} /** - * Returns all the responses returned by every handler executed by the last 'fire' executed + * Fires an event in the events manager causing the active listeners to be + * notified about it * - * @return array - */ - public function getResponses() {} - - /** - * Removes all events from the EventsManager + * ```php + * $eventsManager->fire("db", $connection); + * ``` * - * @param string $type + * @param string $eventType + * @param object $source + * @param mixed $data + * @param bool $cancelable + * @return mixed */ - public function detachAll($type = null) {} + public function fire(string $eventType, $source, $data = null, bool $cancelable = true) {} /** * Internal handler to call a queue of events * - * @param \SplPriorityQueue|array $queue - * @param \Phalcon\Events\Event $event + * @param \SplPriorityQueue $queue + * @param EventInterface $event * @return mixed */ - public final function fireQueue($queue, EventInterface $event) {} + final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) {} /** - * Fires an event in the events manager causing the active listeners to be notified about it + * Returns all the attached listeners of a certain type * - * - * $eventsManager->fire("db", $connection); - * + * @param string $type + * @return array + */ + public function getListeners(string $type): array {} + + /** + * Returns all the responses returned by every handler executed by the last + * 'fire' executed * - * @param string $eventType - * @param object $source - * @param mixed $data - * @param boolean $cancelable - * @return mixed + * @return array */ - public function fire($eventType, $source, $data = null, $cancelable = true) {} + public function getResponses(): array {} /** * Check whether certain type of event has listeners @@ -115,14 +125,14 @@ public function fire($eventType, $source, $data = null, $cancelable = true) {} * @param string $type * @return bool */ - public function hasListeners($type) {} + public function hasListeners(string $type): bool {} /** - * Returns all the attached listeners of a certain type + * Check if the events manager is collecting all all the responses returned + * by every registered listener in a single fire * - * @param string $type - * @return array + * @return bool */ - public function getListeners($type) {} + public function isCollecting(): bool {} } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 0598a8c4..048672ab 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -5,9 +5,10 @@ /** * Phalcon\Events\Manager * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if needed, - * the normal flow of operation. With the EventsManager the developer can create hooks or - * plugins that will offer monitoring of data, manipulation, conditional execution and much more. + * Phalcon Events Manager, offers an easy way to intercept and manipulate, if + * needed, the normal flow of operation. With the EventsManager the developer + * can create hooks or plugins that will offer monitoring of data, manipulation, + * conditional execution and much more. */ interface ManagerInterface { @@ -18,7 +19,7 @@ interface ManagerInterface * @param string $eventType * @param object|callable $handler */ - public function attach($eventType, $handler); + public function attach(string $eventType, $handler); /** * Detach the listener from the events manager @@ -26,24 +27,25 @@ public function attach($eventType, $handler); * @param string $eventType * @param object $handler */ - public function detach($eventType, $handler); + public function detach(string $eventType, $handler); /** * Removes all events from the EventsManager * * @param string $type */ - public function detachAll($type = null); + public function detachAll(string $type = null); /** - * Fires an event in the events manager causing the active listeners to be notified about it + * Fires an event in the events manager causing the active listeners to be + * notified about it * * @param string $eventType * @param object $source * @param mixed $data * @return mixed */ - public function fire($eventType, $source, $data = null); + public function fire(string $eventType, $source, $data = null); /** * Returns all the attached listeners of a certain type @@ -51,6 +53,14 @@ public function fire($eventType, $source, $data = null); * @param string $type * @return array */ - public function getListeners($type); + public function getListeners(string $type): array; + + /** + * Check whether certain type of event has listeners + * + * @param string $type + * @return bool + */ + public function hasListeners(string $type): bool; } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php new file mode 100644 index 00000000..b54cb01b --- /dev/null +++ b/src/Phalcon/factory/AbstractFactory.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AbstractFactory +{ + /** + * @var array + */ + protected $mapper = array(); + + /** + * @var array + */ + protected $services = array(); + + + /** + * Checks if a service exists and throws an exception + * + * @param string $name + */ + protected function checkService(string $name) {} + + /** + * Checks the config if it is a valid object + * + * @param mixed $config + * @return array + */ + protected function checkConfig($config): array {} + + /** + * Returns the adapters for the factory + * + * @return array + */ + abstract protected function getAdapters(): array; + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + protected function init(array $services = array()) {} + +} diff --git a/src/Phalcon/factory/Exception.php b/src/Phalcon/factory/Exception.php index 25a41d41..15f9cdc3 100644 --- a/src/Phalcon/factory/Exception.php +++ b/src/Phalcon/factory/Exception.php @@ -3,9 +3,12 @@ namespace Phalcon\Factory; /** - * Phalcon\Factory\Exception + * This file is part of the Phalcon Framework. * - * Exceptions thrown in Phalcon\Factory will use this class + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/filter/Filter.php b/src/Phalcon/filter/Filter.php new file mode 100644 index 00000000..ad2a7516 --- /dev/null +++ b/src/Phalcon/filter/Filter.php @@ -0,0 +1,154 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class FilterFactory +{ + + /** + * Returns a Locator object with all the helpers defined in anonynous + * functions + * + * @return LocatorInterface + */ + public function newInstance(): LocatorInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php new file mode 100644 index 00000000..067ba31c --- /dev/null +++ b/src/Phalcon/filter/FilterInterface.php @@ -0,0 +1,21 @@ + + */ + protected $cache; + + /** + * Default access + * + * @var int + */ + protected $defaultAccess = Enum::DENY; + + /** + * Events manager + * + * @var mixed + */ + protected $eventsManager; + + /** + * Internal cache for caching access during request time + * + * @var mixed + */ + protected $internalCache; + + /** + * Anonymous function for getting user identity - this function must + * return string, array or object implementing Phalcon\Acl\RoleAware + * + * @var mixed + */ + protected $roleCallback; + + + /** + * Storing active identity object implementing Phalcon/Acl/RoleAware + */ + public function getActiveIdentity() {} + + /** + * Storing active user role + */ + public function getActiveRole() {} + + /** + * Should role always be resolved using role callback or just once? + * + * @param bool $alwaysResolvingRole + */ + public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} + + /** + * Default access + * + * @return int + */ + public function getDefaultAccess(): int {} + + /** + * Returns the internal event manager + * + * @return \Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ManagerInterface {} + + /** + * Gets role callback to fetch role name + * + * @return \Closure + */ + public function getRoleCallback(): Closure {} + + /** + * Gets always resolving role option + * + * @return bool + */ + public function isAlwaysResolvingRole(): bool {} + + /** + * Sets the cache adapter + * + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return AdapterInterface + */ + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface {} + + /** + * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) + * + * @param int $defaultAccess + * @return AdapterInterface + */ + public function setDefaultAccess(int $defaultAccess): AdapterInterface {} + + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return AdapterInterface + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AdapterInterface {} + + /** + * Sets role callback to fetch role name + * + * @param mixed $callback + * @return AdapterInterface + */ + public function setRoleCallback($callback): AdapterInterface {} + + /** + * @param \Phalcon\Di\DiInterface $container + */ + protected function callRoleCallback(\Phalcon\Di\DiInterface $container) {} + + /** + * Gets access from cache + * + * @param string $key + * @param array $originalValues + * @param string $roleCacheKey + * @return bool|null + */ + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + + /** + * Handles a user exception + * + * @param \Exception $exception + */ + protected function handleException(\Exception $exception) {} + + /** + * Fires event or throwing exception + * + * @param mixed $role + * @param string $actionName + * @param string $controllerName + * @param bool $access + */ + protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) {} + + /** + * Saves access in cache and internal cache + * + * @param string $key + * @param bool $access + */ + protected function saveAccessInCache(string $key, bool $access) {} + + /** + * Throws an internal exception + * + * @param string $message + * @param int $exceptionCode + * @return bool + */ + protected function throwFirewallException(string $message, int $exceptionCode = 0): bool {} + +} diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php new file mode 100644 index 00000000..7ac99290 --- /dev/null +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -0,0 +1,174 @@ +success("The record was successfully deleted"); + * $flash->error("Cannot open the file"); + * ``` + */ +abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\Di\InjectionAwareInterface +{ + /** + * @var bool + */ + protected $autoescape = true; + + /** + * @var bool + */ + protected $automaticHtml = true; + + /** + * @var array + */ + protected $cssClasses = array(); + + /** + * @var string + */ + protected $customTemplate = ''; + + + protected $container = null; + + + protected $escaperService = null; + + /** + * @var bool + */ + protected $implicitFlush = true; + + + protected $messages = array(); + + + /** + * Phalcon\Flash constructor + * + * @param mixed $cssClasses + */ + public function __construct($cssClasses = null) {} + + /** + * Clears accumulated messages when implicit flush is disabled + */ + public function clear() {} + + /** + * Shows a HTML error message + * + * ```php + * $flash->error("This is an error"); + * ``` + * + * @param string $message + * @return string + */ + public function error(string $message): string {} + + /** + * Returns the autoescape mode in generated html + * + * @return bool + */ + public function getAutoescape(): bool {} + + /** + * Returns the custom template set + * + * @return string + */ + public function getCustomTemplate(): string {} + + /** + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the Escaper Service + * + * @return \Phalcon\Escaper\EscaperInterface + */ + public function getEscaperService(): EscaperInterface {} + + /** + * Shows a HTML notice/information message + * + * ```php + * $flash->notice("This is an information"); + * ``` + * + * @param string $message + * @return string + */ + public function notice(string $message): string {} + + /** + * Set the autoescape mode in generated html + * + * @param bool $autoescape + * @return Flash + */ + public function setAutoescape(bool $autoescape): Flash {} + + /** + * Set if the output must be implicitly formatted with HTML + * + * @param bool $automaticHtml + * @return FlashInterface + */ + public function setAutomaticHtml(bool $automaticHtml): FlashInterface {} + + /** + * Set an array with CSS classes to format the messages + * + * @param array $cssClasses + * @return FlashInterface + */ + public function setCssClasses(array $cssClasses): FlashInterface {} + + /** + * Set an custom template for showing the messages + * + * @param string $customTemplate + * @return FlashInterface + */ + public function setCustomTemplate(string $customTemplate): FlashInterface {} + + /** + * Sets the dependency injector + * + * @param \Phalcon\Di\DiInterface $container + * @return FlashInterface + */ + public function setDI(\Phalcon\Di\DiInterface $container): FlashInterface {} + + /** + * Sets the Escaper Service + * + * @param \Phalcon\Escaper\EscaperInterface $escaperService + * @return FlashInterface + */ + public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface {} + + /** + * Set whether the output must be implicitly flushed to the output or + * returned as string + * + * @param bool $implicitFlush + * @return FlashInterface + */ + public function setImplicitFlush(bool $implicitFlush): FlashInterface {} + + /** + * Shows a HTML success message + * + * ```php + * $flash->success("The process was finished successfully"); + * ``` + * + * @param string $message + * @return string + */ + public function success(string $message): string {} + + /** + * Outputs a message formatting it with HTML + * + * ```php + * $flash->outputMessage("error", $message); + * ``` + * + * @param string $type + * @param string|array $message + * @return string|void + */ + public function outputMessage(string $type, $message) {} + + /** + * Shows a HTML warning message + * + * ```php + * $flash->warning("Hey, this is important"); + * ``` + * + * @param string $message + * @return string + */ + public function warning(string $message): string {} + + /** + * @param string $cssClassses + * @return string + */ + private function getTemplate(string $cssClassses): string {} + + /** + * Returns the message escaped if the autoEscape is true, otherwise the + * original message is returned + * + * @param string $message + * @return string + */ + private function prepareEscapedMessage(string $message): string {} + + /** + * Prepares the HTML output for the message. If automaticHtml is not set + * then the original message is returned + * + * @param string $type + * @param string $message + * @return string + */ + private function prepareHtmlMessage(string $type, string $message): string {} + +} diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index bfe09e23..fda928b6 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -3,11 +3,10 @@ namespace Phalcon\Flash; /** - * Phalcon\Flash\Direct - * - * This is a variant of the Phalcon\Flash that immediately outputs any message passed to it + * This is a variant of the Phalcon\Flash that immediately outputs any message + * passed to it */ -class Direct extends \Phalcon\Flash +class Direct extends \Phalcon\Flash\AbstractFlash { /** @@ -17,13 +16,13 @@ class Direct extends \Phalcon\Flash * @param mixed $message * @return string */ - public function message($type, $message) {} + public function message(string $type, $message): string {} /** * Prints the messages accumulated in the flasher * * @param bool $remove */ - public function output($remove = true) {} + public function output(bool $remove = true) {} } diff --git a/src/Phalcon/flash/Exception.php b/src/Phalcon/flash/Exception.php index fece45ed..6a123e85 100644 --- a/src/Phalcon/flash/Exception.php +++ b/src/Phalcon/flash/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Flash; /** - * Phalcon\Flash\Exception - * * Exceptions thrown in Phalcon\Flash will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php new file mode 100644 index 00000000..8faa3dea --- /dev/null +++ b/src/Phalcon/flash/FlashInterface.php @@ -0,0 +1,53 @@ + + * ```php * if ($form->isValid($_POST) == false) { - * // Get messages separated by the item name - * // $messages is an array of Group object - * $messages = $form->getMessages(true); - * - * foreach ($messages as $message) { - * echo $message, "
"; - * } - * - * // Default behavior. - * // $messages is a Group object * $messages = $form->getMessages(); * * foreach ($messages as $message) { * echo $message, "
"; * } * } - * + * ``` * - * @param bool $byItemName - * @return array|\Phalcon\Validation\Message\Group + * @return array|\Phalcon\Messages\Messages */ - public function getMessages($byItemName = false) {} + public function getMessages() {} /** * Returns the messages generated for a specific element * * @param string $name - * @return \Phalcon\Validation\Message\Group + * @return \Phalcon\Messages\Messages */ - public function getMessagesFor($name) {} + public function getMessagesFor(string $name): Messages {} /** - * Check if messages were generated for a specific element + * Returns the value of an option if present * - * @param string $name - * @return bool + * @param string $option + * @param mixed $defaultValue + * @return mixed */ - public function hasMessagesFor($name) {} + public function getUserOption(string $option, $defaultValue = null) {} /** - * Adds an element to the form + * Returns the options for the element * - * @param \Phalcon\Forms\ElementInterface $element - * @param string $position - * @param bool $type - * @return Form + * @return array */ - public function add(\Phalcon\Forms\ElementInterface $element, $position = null, $type = null) {} + public function getUserOptions(): array {} /** - * Renders a specific item in the form + * Gets a value from the internal related entity or from the default value * * @param string $name - * @param array $attributes - * @return string + * @return mixed|null */ - public function render($name, $attributes = null) {} + public function getValue(string $name): ? {} /** - * Returns an element added to the form by its name + * Check if the form contains an element * * @param string $name - * @return \Phalcon\Forms\ElementInterface + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Generate the label of an element added to the form including HTML + * Check if messages were generated for a specific element * * @param string $name - * @param array $attributes - * @return string + * @return bool */ - public function label($name, array $attributes = null) {} + public function hasMessagesFor(string $name): bool {} /** - * Returns a label for an element + * Validates the form * - * @param string $name - * @return string + * @param array $data + * @param object $entity + * @return bool */ - public function getLabel($name) {} + public function isValid($data = null, $entity = null): bool {} /** - * Gets a value from the internal related entity or from the default value + * Returns the current position/key in the iterator + * + * @return int + */ + public function key(): int {} + + /** + * Generate the label of an element added to the form including HTML * * @param string $name - * @return mixed|null + * @param array $attributes + * @return string */ - public function getValue($name) {} + public function label(string $name, array $attributes = null): string {} /** - * Check if the form contains an element + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Renders a specific item in the form * * @param string $name - * @return bool + * @param array $attributes + * @return string */ - public function has($name) {} + public function render(string $name, array $attributes = array()): string {} /** * Removes an element from the form @@ -252,52 +240,66 @@ public function has($name) {} * @param string $name * @return bool */ - public function remove($name) {} + public function remove(string $name): bool {} /** - * Clears every element in the form to its default value + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Sets the form's action * - * @param array $fields + * @param string $action * @return Form */ - public function clear($fields = null) {} + public function setAction(string $action): Form {} /** - * Returns the number of elements in the form + * Sets the entity related to the model * - * @return int + * @param object $entity + * @return Form */ - public function count() {} + public function setEntity($entity): Form {} /** - * Rewinds the internal iterator + * Sets an option for the form + * + * @param string $option + * @param mixed $value + * @return Form */ - public function rewind() {} + public function setUserOption(string $option, $value): Form {} /** - * Returns the current element in the iterator + * Sets options for the element * - * @return bool|\Phalcon\Forms\ElementInterface + * @param array $options + * @return Form */ - public function current() {} + public function setUserOptions(array $options): Form {} /** - * Returns the current position/key in the iterator + * Check if the current element in the iterator is valid * - * @return int + * @return bool */ - public function key() {} + public function valid(): bool {} /** - * Moves the internal iteration pointer to the next position + * Get Form attributes collection + * + * @return \Phalcon\Html\Attributes */ - public function next() {} + public function getAttributes(): Attributes {} /** - * Check if the current element in the iterator is valid + * Set form attributes collection * - * @return bool + * @param \Phalcon\Html\Attributes $attributes + * @return \Phalcon\Html\Attributes\AttributesInterface */ - public function valid() {} + public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface {} } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index 7a74031c..df4e51a2 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -3,12 +3,12 @@ namespace Phalcon\Forms; /** - * Phalcon\Forms\Manager + * Forms Manager */ class Manager { - protected $_forms; + protected $forms = array(); /** @@ -18,7 +18,7 @@ class Manager * @param object $entity * @return Form */ - public function create($name, $entity = null) {} + public function create(string $name, $entity = null): Form {} /** * Returns a form by its name @@ -26,7 +26,7 @@ public function create($name, $entity = null) {} * @param string $name * @return Form */ - public function get($name) {} + public function get(string $name): Form {} /** * Checks if a form is registered in the forms manager @@ -34,7 +34,7 @@ public function get($name) {} * @param string $name * @return bool */ - public function has($name) {} + public function has(string $name): bool {} /** * Registers a form in the Forms Manager @@ -43,6 +43,6 @@ public function has($name) {} * @param Form $form * @return FormManager */ - public function set($name, Form $form) {} + public function set(string $name, Form $form): FormManager {} } diff --git a/src/Phalcon/forms/Element.php b/src/Phalcon/forms/element/AbstractElement.php similarity index 58% rename from src/Phalcon/forms/Element.php rename to src/Phalcon/forms/element/AbstractElement.php index 6c832bf0..5a9385cd 100644 --- a/src/Phalcon/forms/Element.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -1,226 +1,227 @@ %label%"; + private $template = '
%label%
'; + + + /** + * Crumb separator + * + * @return string + */ + public function getSeparator(): string {} + + /** + * Crumb separator + * + * @param string $separator + */ + public function setSeparator(string $separator) {} /** * Adds a new crumb. * - * + * ```php * // Adding a crumb with a link * $breadcrumbs->add("Home", "/"); * * // Adding a crumb without a link (normally the last one) * $breadcrumbs->add("Users"); - * + * ``` + * + * @param string $label + * @param string $link + * @return Breadcrumbs */ - public function add(string $label, string $link = "") : Breadcrumbs - { - } + public function add(string $label, string $link = ''): Breadcrumbs {} /** - * Clears the crumbx + * Clears the crumbs * - * + * ```php * $breadcrumbs->clear() - * + * ``` */ - public function clear() : void - { - } + public function clear() {} /** * Removes crumb by url. * - * + * ```php * $breadcrumbs->remove("/admin/user/create"); * * // remove a crumb without an url (last link) * $breadcrumbs->remove(); - * + * ``` + * + * @param string $link */ - public function remove(string $link) : void - { - } + public function remove(string $link) {} /** * Renders and outputs breadcrumbs based on previously set template. * - * - * // Php Engine + * ```php * echo $breadcrumbs->render(); - * + * ``` + * + * @return string */ - public function render() : string - { - } + public function render(): string {} /** * Returns the internal breadcrumbs array + * + * @return array */ - public function toArray() : array - { - } + public function toArray(): array {} + } diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php index 1a22c6d9..2a33e680 100644 --- a/src/Phalcon/html/Exception.php +++ b/src/Phalcon/html/Exception.php @@ -6,7 +6,6 @@ * Phalcon\Html\Tag\Exception * * Exceptions thrown in Phalcon\Html\Tag will use this class - * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/html/Tag.php b/src/Phalcon/html/Tag.php index 864cb02b..ee523d93 100644 --- a/src/Phalcon/html/Tag.php +++ b/src/Phalcon/html/Tag.php @@ -2,1063 +2,1181 @@ namespace Phalcon\Html; -use Phalcon\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Escaper; -use Phalcon\EscaperInterface; -use Phalcon\Helper\Arr; -use Phalcon\Html\Exception; -use Phalcon\UrlInterface; - /** * Phalcon\Html\Tag * - * Phalcon\Tag is designed to simplify building of HTML tags. It provides a set - * of helpers to dynamically generate HTML. + * Phalcon\Html\Tag is designed to simplify building of HTML tags. It provides a + * set of helpers to dynamically generate HTML. */ -class Tag implements InjectionAwareInterface +class Tag implements \Phalcon\Di\InjectionAwareInterface { - /** - * @var - */ - protected $container; - - /** - * @var array - */ - private $append = []; - - /** - * @var int - */ - private $docType = 5; // HTML5 - - /** - * @var - */ - private $escaper; - - /** - * @var array - */ - private $prepend = []; - - /** - * @var string - */ - private $separator = ""; - - /** - * @var string - */ - private $title = ""; - - /** - * @var array - */ - private $values = []; - - /** - * @var - */ - private $url; - - /** - * Constants - */ - const HTML32 = 1; - const HTML401_STRICT = 2; - const HTML401_TRANSITIONAL = 3; - const HTML401_FRAMESET = 4; - const HTML5 = 5; - const XHTML10_STRICT = 6; - const XHTML10_TRANSITIONAL = 7; - const XHTML10_FRAMESET = 8; - const XHTML11 = 9; - const XHTML20 = 10; - const XHTML5 = 11; - - /** - * Appends a text to current document title - */ - public function appendTitle(array $title) : Tag - { - } - - /** - * Builds a HTML input[type="button"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->button('Click Me') - * - * - * Volt syntax: - * - * {{ button('Click Me) }} - * - */ - public function button(string $name, array $parameters = []) : string - { - } - - /** - * Resets the request and internal values to avoid those fields will have - * any default value. - */ - public function clear() : void - { - } - - /** - * Builds a HTML tag - * - * Parameters - * `onlyStart` Only process the start of th element - * `selfClose` It is a self close element - * `useEol` Append PHP_EOL at the end - * - */ - public function element(string $tag, array $parameters = []) : string - { - } - - /** - * Builds the closing tag of an html element - * - * Parameters - * `useEol` Append PHP_EOL at the end - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', + /** + * Constants + */ + const HTML32 = 1; + + + const HTML401_STRICT = 2; + + + const HTML401_TRANSITIONAL = 3; + + + const HTML401_FRAMESET = 4; + + + const HTML5 = 5; + + + const XHTML10_STRICT = 6; + + + const XHTML10_TRANSITIONAL = 7; + + + const XHTML10_FRAMESET = 8; + + + const XHTML11 = 9; + + + const XHTML20 = 10; + + + const XHTML5 = 11; + + /** + * @var DiInterface + */ + protected $container; + + /** + * @var array + */ + private $append = array(); + + /** + * @var int + */ + private $docType = 5; + + /** + * @var + */ + private $escaper; + + /** + * @var array + */ + private $prepend = array(); + + /** + * @var string + */ + private $separator = ''; + + /** + * @var string + */ + private $title = ''; + + /** + * @var array + */ + private $values = array(); + + /** + * @var + */ + private $url; + + + /** + * Constructor + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param \Phalcon\Url\UrlInterface $url + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Url\UrlInterface $url = null) {} + + /** + * Appends a text to current document title + * + * @param mixed $title + * @return Tag + */ + public function appendTitle($title): Tag {} + + /** + * Builds a HTML input[type="button"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->button('Click Me'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ button('Click Me') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function button(string $name, array $parameters = array()): string {} + + /** + * Resets the request and internal values to avoid those fields will have + * any default value. + */ + public function clear() {} + + /** + * Builds a HTML tag + * + * Parameters + * `onlyStart` Only process the start of th element + * `selfClose` It is a self close element + * `useEol` Append PHP_EOL at the end + * + * @param string $tag + * @param array $parameters + * @return string + */ + public function element(string $tag, array $parameters = array()): string {} + + /** + * Builds the closing tag of an html element + * + * Parameters + * `useEol` Append PHP_EOL at the end + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', * ] * ); // - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', - * 'useEol' => true, - * ] - * ); // '' . PHP_EOL - * - * - */ - public function elementClose(string $tag, array $parameters = []) : string - { - } - - /** - * Returns the closing tag of a form element - */ - public function endForm(bool $eol = true) : string - { - } - - /** - * Builds a HTML FORM tag - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->form('posts/save'); - * - * echo $tag->form( - * 'posts/save', - * [ - * "method" => "post", - * ] - * ); - * - * - * Volt syntax: - * - * {{ form('posts/save') }} - * {{ form('posts/save', ['method': 'post') }} - * - */ - public function form(string $action, array $parameters = []) : string - { - } - - /** - * Converts text to URL-friendly strings - * - * Parameters - * `text` The text to be processed - * `separator` Separator to use (default '-') - * `lowercase` Convert to lowercase - * `replace` - * - * - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->friendlyTitle( - * [ - * 'text' => 'These are big important news', - * 'separator' => '-', - * ] - * ); - * - * - * Volt Syntax: - * - * {{ friendly_title(['text': 'These are big important news', 'separator': '-']) }} - * - */ - public function friendlyTitle(string $text, array $parameters = []) : string - { - } - - /** - * Returns the internal dependency injector - */ - public function getDI() : DiInterface - { - } - - /** - * Get the document type declaration of content. If the docType has not - * been set properly, XHTML5 is returned - */ - public function getDocType() : string - { - } - - /** - * Gets the current document title. The title will be automatically escaped. - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->getTitle(); // Hello World from Phalcon - * echo $tag->getTitle(false); // World from Phalcon - * echo $tag->getTitle(true, false); // Hello World - * echo $tag->getTitle(false, false); // World - * - * - * Volt syntax: - * - * {{ get_title() }} - * - */ - public function getTitle(bool $prepend = true, bool $append = true) : string - { - } - - /** - * Gets the current document title separator - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->getTitleSeparator(); - * - * - * Volt syntax: - * - * {{ get_title_separator() }} - * - */ - public function getTitleSeparator() : string - { - } - - /** - * Every helper calls this function to check whether a component has a predefined - * value using `setAttribute` or value from $_POST - */ - public function getValue(string $name, array $parameters = []) { - } - - /** - * Check if a helper has a default value set using `setAttribute()` or - * value from $_POST - */ - public function hasValue(string $name) : bool - { - } - - /** - * Builds HTML IMG tags - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->image('img/bg.png'); - * - * echo $tag->image( - * 'img/photo.jpg', - * [ - * 'alt' => 'Some Photo', - * ] - * ); - * - * echo $tag->image( - * 'http://static.mywebsite.com/img/bg.png', - * [ - * 'local' => false, - * ] - * ); - * - * - * Volt Syntax: - * - * {{ image('img/bg.png') }} - * {{ image('img/photo.jpg', ['alt': 'Some Photo') }} - * {{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }} - * - */ - public function image(string $url = "", array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="check"] tag - * - * - * echo $tag->inputCheckbox( - * [ - * 'name' => 'terms, - * 'value' => 'Y', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_checkbox(['name': 'terms, 'value': 'Y']) }} - * - * - * @param array parameters - */ - public function inputCheckbox(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='color'] tag - */ - public function inputColor(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='date'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDate( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDate(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='datetime'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTime( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date_time(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDateTime(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='datetime-local'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTimeLocal( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }} - * - */ - public function inputDateTimeLocal(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='email'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputEmail( - * [ - * 'name' => 'email', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_email(['name': 'email']); - * - */ - public function inputEmail(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='file'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputFile( - * [ - * 'name' => 'file', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_file(['name': 'file']); - * - */ - public function inputFile(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='hidden'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputHidden( - * [ - * 'name' => 'my-field', - * 'value' => 'mike', - * ] - * ); - * - */ - public function inputHidden(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="image"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->inputImage( - * [ - * 'src' => '/img/button.png', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_image(['src': '/img/button.png']) }} - * - */ - public function inputImage(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='month'] tag - */ - public function inputMonth(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='number'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->numericField( - * [ - * 'name' => 'price', - * 'min' => '1', - * 'max' => '5', - * ] - * ); - * - */ - public function inputNumeric(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='password'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->passwordField( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * - */ - public function inputPassword(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="radio"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputRadio( - * [ - * 'name' => 'weather', - * 'value" => 'hot', - * ] - * ); - * - * - * Volt syntax: - * - * {{ input_radio(['name': 'weather', 'value": 'hot']) }} - * - */ - public function inputRadio(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='range'] tag - */ - public function inputRange(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='search'] tag - */ - public function inputSearch(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='tel'] tag - */ - public function inputTel(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='text'] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputText( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * - */ - public function inputText(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='time'] tag - */ - public function inputTime(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='url'] tag - */ - public function inputUrl(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type='week'] tag - */ - public function inputWeek(string $name, array $parameters = []) : string - { - } - - /** - * Builds a script[type="javascript"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->javascript( - * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', - * ['local' => false] - * ); - * echo $tag->javascript('javascript/jquery.js'); - * - * - * Volt syntax: - * - * {{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }} - * {{ javascript('javascript/jquery.js') }} - * - */ - public function javascript(string $url, array $parameters = []) : string - { - } - - /** - * Builds a HTML A tag using framework conventions - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->link('signup/register', 'Register Here!'); - * - * echo $tag->link( - * 'signup/register', - * 'Register Here!', - * [ - * 'class' => 'btn-primary', - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->linkTo( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * 'target' => '_new' - * ] - * ); - * - * - */ - public function link(string $url, string $text = "", array $parameters = []) : string - { - } - - /** - * Prepends a text to current document title - */ - public function prependTitle(array $title) : Tag - { - } - - /** - * Renders the title with title tags. The title is automaticall escaped - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->renderTitle(); // Hello World from Phalcon - * echo $tag->renderTitle(false); // World from Phalcon - * echo $tag->renderTitle(true, false); // Hello World - * echo $tag->renderTitle(false, false); // World - * - * - * - * {{ render_title() }} - * - */ - public function renderTitle(bool $prepend = true, bool $append = true) : string - { - } - - /** - * Builds a HTML input[type="reset"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->reset('Reset') - * - * - * Volt syntax: - * - * {{ reset('Save') }} - * - */ - public function reset(string $name, array $parameters = []) : string - { - } - - /** - * Builds a select element. It accepts an array or a resultset from - * a Phalcon\Mvc\Model - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Status...', - * ], - * [ - * 'A' => 'Active', - * 'I' => 'Inactive', - * ] - * ); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Type...', - * 'using' => [ - * 'id, - * 'name', - * ], - * ], - * Robots::find( - * [ - * 'conditions' => 'type = :type:', - * 'bind' => [ - * 'type' => 'mechanical', - * ] - * ] - * ) - * ); - * - * - * - * @param array parameters - * @param array data - */ - public function select(string $name, array $parameters = [], $data = null) : string - { - } - - /** - * Assigns default values to generated tags by helpers - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute('name', 'peter'); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * - */ - public function setAttribute(string $name, $value) : Tag - { - } - - /** - * Assigns default values to generated tags by helpers - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute( - * [ - * 'name' => 'peter', - * ] - * ); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * - */ - public function setAttributes(array $values, bool $merge = false) : Tag - { - } - - /** - * Sets the dependency injector - */ - public function setDI(DiInterface $container) : void - { - } - - /** - * Set the document type of content - * - * @param int doctype A valid doctype for the content - * - * @return - */ - public function setDocType(int $doctype) : Tag - { - } - - /** - * Set the title separator of view content - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag->setTitle('Phalcon Framework'); - * - */ - public function setTitle(string $title) : Tag - { - } - - /** - * Set the title separator of view content - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->setTitleSeparator('-'); - * - */ - public function setTitleSeparator(string $separator) : Tag - { - } - - /** - * Builds a LINK[rel="stylesheet"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->stylesheet( - * 'http://fonts.googleapis.com/css?family=Rosario', - * ['local' => false] - * ); - * echo $tag->stylesheet('css/style.css'); - * - * - * Volt syntax: - * - * {{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }} - * {{ stylesheet('css/style.css') }} - * - */ - public function stylesheet(string $url, array $parameters = []) : string - { - } - - /** - * Builds a HTML input[type="submit"] tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - *public - * echo $tag->submit('Save') - * - * - * Volt syntax: - * - * {{ submit('Save') }} - * - */ - public function submit(string $name, array $parameters = []) : string - { - } - - /** - * Builds a HTML TEXTAREA tag - * - * - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->textArea( - * 'comments', - * [ - * 'cols' => 10, - * 'rows' => 4, - * ] - * ); - * - * - * Volt syntax: - * - * {{ text_area('comments', ['cols': 10, 'rows': 4]) }} - * - */ - public function textArea(string $name, array $parameters = []) : string - { - } - - /** - * Returns the escaper service from the DI container - */ - private function getService(string $name) - { - } - - /** - * Renders the attributes of an HTML element - */ - private function renderAttributes(string $code, array $attributes) : string - { - } - - /** - * Returns the closing tag depending on the doctype - */ - private function renderCloseTag(bool $addEol = false) : string - { - } - - /** - * Builds `input` elements - */ - private function renderInput(string $type, string $name, array $parameters = []) : string - { - } - /** - * Builds INPUT tags that implements the checked attribute - */ - private function renderInputChecked(string $type, string $name, array $parameters = []) : string - { - } - - /** - * Generates the option values or optgroup from an array - */ - private function renderSelectArray(array $options, $value, string $closeOption) : string - { - } - - /** - * Generates the option values from a resultset - */ - private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption) : string - { - } + * + * echo $tag->elementClose( + * [ + * 'name' => 'aside', + * 'useEol' => true, + * ] + * ); // '' . PHP_EOL + * ``` + * + * @param string $tag + * @param array $parameters + * @return string + */ + public function elementClose(string $tag, array $parameters = array()): string {} + + /** + * Returns the closing tag of a form element + * + * @param bool $eol + * @return string + */ + public function endForm(bool $eol = true): string {} + + /** + * Builds a HTML FORM tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->form('posts/save'); + * + * echo $tag->form( + * 'posts/save', + * [ + * "method" => "post", + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ form('posts/save') }}{% endraw %} + * {% raw %}{{ form('posts/save', ['method': 'post') }}{% endraw %} + * ``` + * + * @param string $action + * @param array $parameters + * @return string + */ + public function form(string $action, array $parameters = array()): string {} + + /** + * Converts text to URL-friendly strings + * + * Parameters + * `text` The text to be processed + * `separator` Separator to use (default '-') + * `lowercase` Convert to lowercase + * `replace` + * + * ```php + * use Phalcon\Html\Tag; + * + * $tab = new Tag(); + * + * echo $tag->friendlyTitle( + * [ + * 'text' => 'These are big important news', + * 'separator' => '-', + * ] + * ); + * ``` + * + * Volt Syntax: + * ```php + * {% raw %}{{ friendly_title(['text': 'These are big important news', 'separator': '-']) }}{% endraw %} + * ``` + * + * @param string $text + * @param array $parameters + * @return string + */ + public function friendlyTitle(string $text, array $parameters = array()): string {} + + /** + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Get the document type declaration of content. If the docType has not + * been set properly, XHTML5 is returned + * + * @return string + */ + public function getDocType(): string {} + + /** + * Gets the current document title. The title will be automatically escaped. + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->getTitle(); // Hello World from Phalcon + * echo $tag->getTitle(false); // World from Phalcon + * echo $tag->getTitle(true, false); // Hello World + * echo $tag->getTitle(false, false); // World + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ get_title() }}{% endraw %} + * ``` + * + * @param bool $prepend + * @param bool $append + * @return string + */ + public function getTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Gets the current document title separator + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->getTitleSeparator(); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ get_title_separator() }}{% endraw %} + * ``` + * + * @return string + */ + public function getTitleSeparator(): string {} + + /** + * Every helper calls this function to check whether a component has a + * predefined value using `setAttribute` or value from $_POST + * + * @param string $name + * @param array $parameters + * @return mixed|null + */ + public function getValue(string $name, array $parameters = array()): ? {} + + /** + * Check if a helper has a default value set using `setAttribute()` or + * value from $_POST + * + * @param string $name + * @return bool + */ + public function hasValue(string $name): bool {} + + /** + * Builds HTML IMG tags + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->image('img/bg.png'); + * + * echo $tag->image( + * 'img/photo.jpg', + * [ + * 'alt' => 'Some Photo', + * ] + * ); + * + * echo $tag->image( + * 'http://static.mywebsite.com/img/bg.png', + * [ + * 'local' => false, + * ] + * ); + * ``` + * + * Volt Syntax: + * ```php + * {% raw %}{{ image('img/bg.png') }}{% endraw %} + * {% raw %}{{ image('img/photo.jpg', ['alt': 'Some Photo') }}{% endraw %} + * {% raw %}{{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function image(string $url = '', array $parameters = array()): string {} + + /** + * Builds a HTML input[type="check"] tag + * + * ```php + * echo $tag->inputCheckbox( + * [ + * 'name' => 'terms, + * 'value' => 'Y', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_checkbox(['name': 'terms, 'value': 'Y']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputCheckbox(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='color'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputColor(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='date'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDate( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDate(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='datetime'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTime( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date_time(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDateTime(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='datetime-local'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputDateTimeLocal( + * [ + * 'name' => 'born', + * 'value' => '14-12-1980', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputDateTimeLocal(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='email'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputEmail( + * [ + * 'name' => 'email', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_email(['name': 'email']);{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputEmail(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='file'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputFile( + * [ + * 'name' => 'file', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_file(['name': 'file']){% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputFile(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='hidden'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputHidden( + * [ + * 'name' => 'my-field', + * 'value' => 'mike', + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputHidden(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="image"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * echo $tag->inputImage( + * [ + * 'src' => '/img/button.png', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_image(['src': '/img/button.png']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputImage(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='month'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputMonth(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='number'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->numericField( + * [ + * 'name' => 'price', + * 'min' => '1', + * 'max' => '5', + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputNumeric(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='password'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->passwordField( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputPassword(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="radio"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputRadio( + * [ + * 'name' => 'weather', + * 'value" => 'hot', + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ input_radio(['name': 'weather', 'value": 'hot']) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputRadio(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='range'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputRange(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='search'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputSearch(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='tel'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputTel(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='text'] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->inputText( + * [ + * 'name' => 'my-field', + * 'size' => 30, + * ] + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputText(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='time'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputTime(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='url'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputUrl(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML input[type='week'] tag + * + * @param string $name + * @param array $parameters + * @return string + */ + public function inputWeek(string $name, array $parameters = array()): string {} + + /** + * Builds a script[type="javascript"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->javascript( + * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->javascript('javascript/jquery.js'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }}{% endraw %} + * {% raw %}{{ javascript('javascript/jquery.js') }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function javascript(string $url, array $parameters = array()): string {} + + /** + * Builds a HTML A tag using framework conventions + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->link('signup/register', 'Register Here!'); + * + * echo $tag->link( + * 'signup/register', + * 'Register Here!', + * [ + * 'class' => 'btn-primary', + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->link( + * 'https://phalconphp.com/', + * 'Phalcon!', + * [ + * 'local' => false, + * 'target' => '_new', + * ] + * ); + * ``` + * + * @param string $url + * @param string $text + * @param array $parameters + * @return string + */ + public function link(string $url, string $text = '', array $parameters = array()): string {} + + /** + * Prepends a text to current document title + * + * @param mixed $title + * @return Tag + */ + public function prependTitle($title): Tag {} + + /** + * Renders the title with title tags. The title is automaticall escaped + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag + * ->setTitleSeparator(' ') + * ->prependTitle(['Hello']) + * ->setTitle('World') + * ->appendTitle(['from Phalcon']); + * + * echo $tag->renderTitle(); // Hello World from Phalcon + * echo $tag->renderTitle(false); // World from Phalcon + * echo $tag->renderTitle(true, false); // Hello World + * echo $tag->renderTitle(false, false); // World + * ``` + * + * ```php + * {% raw %}{{ render_title() }}{% endraw %} + * ``` + * + * @param bool $prepend + * @param bool $append + * @return string + */ + public function renderTitle(bool $prepend = true, bool $append = true): string {} + + /** + * Builds a HTML input[type="reset"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->reset('Reset') + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ reset('Save') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function reset(string $name, array $parameters = array()): string {} + + /** + * Builds a select element. It accepts an array or a resultset from + * a Phalcon\Mvc\Model + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Status...', + * ], + * [ + * 'A' => 'Active', + * 'I' => 'Inactive', + * ] + * ); + * + * echo $tag->select( + * 'status', + * [ + * 'id' => 'status-id', + * 'useEmpty' => true, + * 'emptyValue => '', + * 'emptyText' => 'Choose Type...', + * 'using' => [ + * 'id, + * 'name', + * ], + * ], + * Robots::find( + * [ + * 'conditions' => 'type = :type:', + * 'bind' => [ + * 'type' => 'mechanical', + * ] + * ] + * ) + * ); + * ``` + * + * @param string $name + * @param array $parameters + * @param mixed $data + * @return string + */ + public function select(string $name, array $parameters = array(), $data = null): string {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute('name', 'peter'); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * ``` + * + * @param string $name + * @param mixed $value + * @return Tag + */ + public function setAttribute(string $name, $value): Tag {} + + /** + * Assigns default values to generated tags by helpers + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * // Assigning 'peter' to 'name' component + * $tag->setAttribute( + * [ + * 'name' => 'peter', + * ] + * ); + * + * // Later in the view + * echo $tag->inputText('name'); // Will have the value 'peter' by default + * ``` + * + * @param array $values + * @param bool $merge + * @return Tag + */ + public function setAttributes(array $values, bool $merge = false): Tag {} + + /** + * Sets the dependency injector + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the document type of content + * + * @param int $doctype + * @return Tag + */ + public function setDocType(int $doctype): Tag {} + + /** + * Set the title separator of view content + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * $tag->setTitle('Phalcon Framework'); + * ``` + * + * @param string $title + * @return Tag + */ + public function setTitle(string $title): Tag {} + + /** + * Set the title separator of view content + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->setTitleSeparator('-'); + * ``` + * + * @param string $separator + * @return Tag + */ + public function setTitleSeparator(string $separator): Tag {} + + /** + * Builds a LINK[rel="stylesheet"] tag + * + * Parameters + * `local` Local resource or not (default `true`) + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->stylesheet( + * 'http://fonts.googleapis.com/css?family=Rosario', + * [ + * 'local' => false, + * ] + * ); + * + * echo $tag->stylesheet('css/style.css'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }}{% endraw %} + * {% raw %}{{ stylesheet('css/style.css') }}{% endraw %} + * ``` + * + * @param string $url + * @param array $parameters + * @return string + */ + public function stylesheet(string $url, array $parameters = array()): string {} + + /** + * Builds a HTML input[type="submit"] tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->submit('Save'); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ submit('Save') }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function submit(string $name, array $parameters = array()): string {} + + /** + * Builds a HTML TEXTAREA tag + * + * ```php + * use Phalcon\Html\Tag; + * + * $tag = new Tag(); + * + * echo $tag->textArea( + * 'comments', + * [ + * 'cols' => 10, + * 'rows' => 4, + * ] + * ); + * ``` + * + * Volt syntax: + * ```php + * {% raw %}{{ text_area('comments', ['cols': 10, 'rows': 4]) }}{% endraw %} + * ``` + * + * @param string $name + * @param array $parameters + * @return string + */ + public function textArea(string $name, array $parameters = array()): string {} + + /** + * Returns the escaper service from the DI container + * + * @param string $name + */ + private function getService(string $name) {} + + /** + * Renders the attributes of an HTML element + * + * @param string $code + * @param array $attributes + * @return string + */ + private function renderAttributes(string $code, array $attributes): string {} + + /** + * Returns the closing tag depending on the doctype + * + * @param bool $addEol + * @return string + */ + private function renderCloseTag(bool $addEol = false): string {} + + /** + * Builds `input` elements + * + * @param string $type + * @param string $name + * @param array $parameters + * @return string + */ + private function renderInput(string $type, string $name, array $parameters = array()): string {} + + /** + * Builds INPUT tags that implements the checked attribute + * + * @param string $type + * @param string $name + * @param array $parameters + * @return string + */ + private function renderInputChecked(string $type, string $name, array $parameters = array()): string {} + + /** + * Generates the option values or optgroup from an array + * + * @param array $options + * @param mixed $value + * @param string $closeOption + * @return string + */ + private function renderSelectArray(array $options, $value, string $closeOption): string {} + + /** + * Generates the option values from a resultset + * + * @param ResulsetInterface $resultset + * @param mixed $using + * @param mixed $value + * @param string $closeOption + * @return string + */ + private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption): string {} + } diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php new file mode 100644 index 00000000..3621c52c --- /dev/null +++ b/src/Phalcon/html/TagFactory.php @@ -0,0 +1,38 @@ + + */ + private $escaper; + + + /** + * TagFactory constructor. + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param array $services + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) {} + + /** + * @param string name + * + * @throws Exception + * @param string $name + * @return mixed + */ + public function newInstance(string $name) {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/html/Taglocator.php b/src/Phalcon/html/Taglocator.php deleted file mode 100644 index 2cebb261..00000000 --- a/src/Phalcon/html/Taglocator.php +++ /dev/null @@ -1,14 +0,0 @@ - + */ + protected $escaper; + + + /** + * Constructor + * + * @param \Phalcon\Escaper\EscaperInterface $escaper + */ + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) {} + + /** + * Renders an element + * + * @param string $tag + * @param string $text + * @param array $attributes + * @param bool $raw + * @return string + */ + protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string {} + + /** + * Renders an element + * + * @param string $tag + * @param array $attributes + * @return string + */ + protected function renderElement(string $tag, array $attributes = array()): string {} + + /** + * Keeps all the attributes sorted - same order all the tome + * + * @param array attributes + * + * @param array $overrides + * @param array $attributes + * @return array + */ + protected function orderAttributes(array $overrides, array $attributes): array {} + + /** + * Renders all the attributes + * + * @param array $attributes + * @return string + */ + protected function renderAttributes(array $attributes): string {} + + /** + * Produces a self close tag i.e. + * + * @param string $tag + * @param array $attributes + * @return string + */ + protected function selfClose(string $tag, array $attributes = array()): string {} + +} diff --git a/src/Phalcon/html/helper/Abstracthelper.php b/src/Phalcon/html/helper/Abstracthelper.php deleted file mode 100644 index cf39440c..00000000 --- a/src/Phalcon/html/helper/Abstracthelper.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ - protected $escaper; - - /** - * Constructor - */ - public function __construct(EscaperInterface $escaper) - { - } - - /** - * Keeps all the attributes sorted - same order all the tome - */ - protected function orderAttributes(array $overrides, array $attributes) : array - { - } - - /** - * Renders all the attributes - */ - protected function renderAttributes(array $attributes) : string - { - } - - /** - * Renders an element - */ - protected function renderElement(string $tag, string $text, array $attributes = []) - { - } - - /** - * Produces a self close tag i.e. - */ - protected function selfClose(string $tag, array $attributes = []) - { - } -} diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index b4ecb01d..5e8646d1 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -2,21 +2,20 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Anchor * * Creates an anchor */ -class Anchor extends AbstractHelper +class Anchor extends \Phalcon\Html\Helper\AbstractHelper { - /** - * @var string href The href tag - * @var string text The text for the anchor - * @var array attributes Any additional attributes - */ - public function __invoke(string $href, string $text, array $attributes = []) : string - { - } + + /** + * @param string $href + * @param string $text + * @param array $attributes + * @return string + */ + public function __invoke(string $href, string $text, array $attributes = array()): string {} + } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php new file mode 100644 index 00000000..1bdb84b7 --- /dev/null +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -0,0 +1,21 @@ + + * ```php * use Phalcon\Http\Request; * * $request = new Request(); @@ -19,65 +18,67 @@ * echo "Request was made using POST and AJAX"; * } * - * $request->getServer("HTTP_HOST"); // Retrieve SERVER variables - * $request->getMethod(); // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT - * $request->getLanguages(); // An array of languages the client accepts - * + * // Retrieve SERVER variables + * $request->getServer("HTTP_HOST"); + * + * // GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, PURGE, TRACE, CONNECT + * $request->getMethod(); + * + * // An array of languages the client accepts + * $request->getLanguages(); + * ``` */ class Request implements \Phalcon\Http\RequestInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - - - protected $_rawBody; - - - protected $_filter; + private $container; - protected $_putCache; + private $filterService; + /** + * @var bool + */ + private $httpMethodParameterOverride = false; - protected $_httpMethodParameterOverride = false; - + /** + * @var array + */ + private $queryFilters = array(); - protected $_strictHostCheck = false; + private $putCache; - public function getHttpMethodParameterOverride() {} + private $rawBody; /** - * @param mixed $httpMethodParameterOverride + * @var bool */ - public function setHttpMethodParameterOverride($httpMethodParameterOverride) {} + private $strictHostCheck = false; + /** - * Sets the dependency injector - * - * @param \Phalcon\DiInterface $dependencyInjector + * @return bool */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function getHttpMethodParameterOverride(): bool {} /** - * Returns the internal dependency injector - * - * @return \Phalcon\DiInterface + * @param bool $httpMethodParameterOverride */ - public function getDI() {} + public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride) {} /** - * Gets a variable from the $_REQUEST superglobal applying filters if needed. - * If no parameters are given the $_REQUEST superglobal is returned + * Gets a variable from the $_REQUEST superglobal applying filters if + * needed. If no parameters are given the $_REQUEST superglobal is returned * - * + * ```php * // Returns value from $_REQUEST["user_email"] without sanitizing * $userEmail = $request->get("user_email"); * * // Returns value from $_REQUEST["user_email"] with sanitizing * $userEmail = $request->get("user_email", "email"); - * + * ``` * * @param string $name * @param mixed $filters @@ -86,142 +87,120 @@ public function getDI() {} * @param bool $noRecursive * @return mixed */ - public function get($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Gets a variable from the $_POST superglobal applying filters if needed - * If no parameters are given the $_POST superglobal is returned + * Gets an array with mime/types and their quality accepted by the + * browser/client from _SERVER["HTTP_ACCEPT"] * - * - * // Returns value from $_POST["user_email"] without sanitizing - * $userEmail = $request->getPost("user_email"); - * - * // Returns value from $_POST["user_email"] with sanitizing - * $userEmail = $request->getPost("user_email", "email"); - * - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return array */ - public function getPost($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getAcceptableContent(): array {} /** - * Gets a variable from put request - * - * - * // Returns value from $_PUT["user_email"] without sanitizing - * $userEmail = $request->getPut("user_email"); + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_USER"] * - * // Returns value from $_PUT["user_email"] with sanitizing - * $userEmail = $request->getPut("user_email", "email"); - * - * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return array|null */ - public function getPut($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getBasicAuth(): ?array {} /** - * Gets variable from $_GET superglobal applying filters if needed - * If no parameters are given the $_GET superglobal is returned + * Gets best mime/type accepted by the browser/client from + * _SERVER["HTTP_ACCEPT"] * - * - * // Returns value from $_GET["id"] without sanitizing - * $id = $request->getQuery("id"); - * - * // Returns value from $_GET["id"] with sanitizing - * $id = $request->getQuery("id", "int"); + * @return string + */ + public function getBestAccept(): string {} + + /** + * Gets best charset accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_CHARSET"] * - * // Returns value from $_GET["id"] with a default value - * $id = $request->getQuery("id", null, 150); - * + * @return string + */ + public function getBestCharset(): string {} + + /** + * Gets best language accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @return string */ - public function getQuery($name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getBestLanguage(): string {} /** - * Helper to get data from superglobals, applying filters if needed. - * If no parameters are given the superglobal is returned. + * Gets most possible client IPv4 Address. This method searches in + * `$_SERVER["REMOTE_ADDR"]` and optionally in + * `$_SERVER["HTTP_X_FORWARDED_FOR"]` * - * @param array $source - * @param string $name - * @param mixed $filters - * @param mixed $defaultValue - * @param bool $notAllowEmpty - * @param bool $noRecursive - * @return mixed + * @param bool $trustForwardedHeader + * @return string|bool */ - protected final function getHelper(array $source, $name = null, $filters = null, $defaultValue = null, $notAllowEmpty = false, $noRecursive = false) {} + public function getClientAddress(bool $trustForwardedHeader = false) {} /** - * Gets variable from $_SERVER superglobal + * Gets a charsets array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return string|null + * @return array */ - public function getServer($name) {} + public function getClientCharsets(): array {} /** - * Checks whether $_REQUEST superglobal has certain index + * Gets content type which request has been made * - * @param string $name - * @return bool + * @return string|null */ - public function has($name) {} + public function getContentType(): ?string {} /** - * Checks whether $_POST superglobal has certain index + * Returns the internal dependency injector * - * @param string $name - * @return bool + * @return \Phalcon\Di\DiInterface */ - public function hasPost($name) {} + public function getDI(): DiInterface {} /** - * Checks whether the PUT data has certain index + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_DIGEST"] * - * @param string $name - * @return bool + * @return array */ - public function hasPut($name) {} + public function getDigestAuth(): array {} /** - * Checks whether $_GET superglobal has certain index + * Retrieves a query/get value always sanitized with the preset filters * * @param string $name - * @return bool + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function hasQuery($name) {} + public function getFilteredQuery(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Checks whether $_SERVER superglobal has certain index + * Retrieves a post value always sanitized with the preset filters * * @param string $name - * @return bool + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public final function hasServer($name) {} + public function getFilteredPost(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Checks whether headers has certain index + * Retrieves a put value always sanitized with the preset filters * - * @param string $header - * @return bool + * @param string $name + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public final function hasHeader($header) {} + public function getFilteredPut(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** * Gets HTTP header from request data @@ -229,58 +208,70 @@ public final function hasHeader($header) {} * @param string $header * @return string */ - public final function getHeader($header) {} + final public function getHeader(string $header): string {} /** - * Gets HTTP schema (http/https) + * Returns the available headers in the request * - * @return string - */ - public function getScheme() {} - - /** - * Checks whether request has been made using ajax + * + * $_SERVER = [ + * "PHP_AUTH_USER" => "phalcon", + * "PHP_AUTH_PW" => "secret", + * ]; * - * @return bool - */ - public function isAjax() {} - - /** - * Checks whether request has been made using SOAP + * $headers = $request->getHeaders(); * - * @return bool - */ - public function isSoap() {} - - /** - * Alias of isSoap(). It will be deprecated in future versions + * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= + * * - * @deprecated - * @return bool + * @return array */ - public function isSoapRequested() {} + public function getHeaders(): array {} /** - * Checks whether request has been made using any secure layer + * Gets host name used by the request. * - * @return bool - */ - public function isSecure() {} - - /** - * Alias of isSecure(). It will be deprecated in future versions + * `Request::getHttpHost` trying to find host name in following order: * - * @deprecated - * @return bool + * - `$_SERVER["HTTP_HOST"]` + * - `$_SERVER["SERVER_NAME"]` + * - `$_SERVER["SERVER_ADDR"]` + * + * Optionally `Request::getHttpHost` validates and clean host name. + * The `Request::$strictHostCheck` can be used to validate host name. + * + * Note: validation and cleaning have a negative performance impact because + * they use regular expressions. + * + * ```php + * use Phalcon\Http\Request; + * + * $request = new Request; + * + * $_SERVER["HTTP_HOST"] = "example.com"; + * $request->getHttpHost(); // example.com + * + * $_SERVER["HTTP_HOST"] = "example.com:8080"; + * $request->getHttpHost(); // example.com:8080 + * + * $request->setStrictHostCheck(true); + * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; + * $request->getHttpHost(); // UnexpectedValueException + * + * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; + * $request->getHttpHost(); // example.com + * ``` + * + * @return string */ - public function isSecureRequest() {} + public function getHttpHost(): string {} /** - * Gets HTTP raw request body + * Gets web page that refers active request. ie: http://www.google.com * * @return string */ - public function getRawBody() {} + public function getHTTPReferer(): string {} /** * Gets decoded JSON HTTP raw request body @@ -288,357 +279,445 @@ public function getRawBody() {} * @param bool $associative * @return array|bool|\stdClass */ - public function getJsonRawBody($associative = false) {} + public function getJsonRawBody(bool $associative = false) {} /** - * Gets active server address IP + * Gets languages array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return string + * @return array */ - public function getServerAddress() {} + public function getLanguages(): array {} /** - * Gets active server name + * Gets HTTP method which request has been made + * + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP + * method, but only if setHttpMethodParameterOverride(true) has been called. + * + * The method is always an uppercased string. * * @return string */ - public function getServerName() {} + final public function getMethod(): string {} /** - * Gets host name used by the request. + * Gets information about the port on which the request is made. * - * `Request::getHttpHost` trying to find host name in following order: + * @return int + */ + public function getPort(): int {} + + /** + * Gets a variable from the $_POST superglobal applying filters if needed + * If no parameters are given the $_POST superglobal is returned * - * - `$_SERVER["HTTP_HOST"]` - * - `$_SERVER["SERVER_NAME"]` - * - `$_SERVER["SERVER_ADDR"]` + * ```php + * // Returns value from $_POST["user_email"] without sanitizing + * $userEmail = $request->getPost("user_email"); * - * Optionally `Request::getHttpHost` validates and clean host name. - * The `Request::$_strictHostCheck` can be used to validate host name. + * // Returns value from $_POST["user_email"] with sanitizing + * $userEmail = $request->getPost("user_email", "email"); + * ``` * - * Note: validation and cleaning have a negative performance impact because - * they use regular expressions. + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + + /** + * Gets a variable from put request * - * - * use Phalcon\Http\Request; + * ```php + * // Returns value from $_PUT["user_email"] without sanitizing + * $userEmail = $request->getPut("user_email"); * - * $request = new Request; + * // Returns value from $_PUT["user_email"] with sanitizing + * $userEmail = $request->getPut("user_email", "email"); + * ``` * - * $_SERVER["HTTP_HOST"] = "example.com"; - * $request->getHttpHost(); // example.com + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + + /** + * Gets variable from $_GET superglobal applying filters if needed + * If no parameters are given the $_GET superglobal is returned * - * $_SERVER["HTTP_HOST"] = "example.com:8080"; - * $request->getHttpHost(); // example.com:8080 + * ```php + * // Returns value from $_GET["id"] without sanitizing + * $id = $request->getQuery("id"); * - * $request->setStrictHostCheck(true); - * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; - * $request->getHttpHost(); // UnexpectedValueException + * // Returns value from $_GET["id"] with sanitizing + * $id = $request->getQuery("id", "int"); * - * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; - * $request->getHttpHost(); // example.com - * + * // Returns value from $_GET["id"] with a default value + * $id = $request->getQuery("id", null, 150); + * ``` * - * @return string + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getHttpHost() {} + public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Sets if the `Request::getHttpHost` method must be use strict validation of host name or not + * Gets HTTP raw request body * - * @param bool $flag - * @return Request + * @return string */ - public function setStrictHostCheck($flag = true) {} + public function getRawBody(): string {} /** - * Checks if the `Request::getHttpHost` method will be use strict validation of host name or not + * Gets HTTP schema (http/https) * - * @return bool + * @return string */ - public function isStrictHostCheck() {} + public function getScheme(): string {} /** - * Gets information about the port on which the request is made. + * Gets variable from $_SERVER superglobal * - * @return int + * @param string $name + * @return string|null */ - public function getPort() {} + public function getServer(string $name): ?string {} /** - * Gets HTTP URI which request has been made + * Gets active server address IP * * @return string */ - public final function getURI() {} + public function getServerAddress(): string {} /** - * Gets most possible client IPv4 Address. This method searches in - * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] + * Gets active server name * - * @param bool $trustForwardedHeader - * @return string|bool + * @return string */ - public function getClientAddress($trustForwardedHeader = false) {} + public function getServerName(): string {} /** - * Gets HTTP method which request has been made - * - * If the X-HTTP-Method-Override header is set, and if the method is a POST, - * then it is used to determine the "real" intended HTTP method. - * - * The _method request parameter can also be used to determine the HTTP method, - * but only if setHttpMethodParameterOverride(true) has been called. + * Gets attached files as Phalcon\Http\Request\File instances * - * The method is always an uppercased string. + * @param bool $onlySuccessful + * @param bool $namedKeys + * @return array|\Phalcon\Http\Request\FileInterface[] + */ + public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array {} + + /** + * Gets HTTP URI which request has been made * * @return string */ - public final function getMethod() {} + final public function getURI(): string {} /** * Gets HTTP user agent used to made the request * * @return string */ - public function getUserAgent() {} + public function getUserAgent(): string {} /** - * Checks if a method is a valid HTTP method + * Checks whether $_REQUEST superglobal has certain index * - * @param string $method + * @param string $name * @return bool */ - public function isValidHttpMethod($method) {} + public function has(string $name): bool {} /** - * Check if HTTP method match any of the passed methods - * When strict is true it checks if validated methods are real HTTP methods + * Returns the number of files available * - * @param mixed $methods - * @param bool $strict + * TODO: Check this + * + * @param bool $onlySuccessful + * @return long + */ + public function hasFiles(bool $onlySuccessful = false): int {} + + /** + * Checks whether headers has certain index + * + * @param string $header * @return bool */ - public function isMethod($methods, $strict = false) {} + final public function hasHeader(string $header): bool {} /** - * Checks whether HTTP method is POST. if _SERVER["REQUEST_METHOD"]==="POST" + * Checks whether $_POST superglobal has certain index * + * @param string $name * @return bool */ - public function isPost() {} + public function hasPost(string $name): bool {} /** - * Checks whether HTTP method is GET. if _SERVER["REQUEST_METHOD"]==="GET" + * Checks whether the PUT data has certain index * + * @param string $name * @return bool */ - public function isGet() {} + public function hasPut(string $name): bool {} /** - * Checks whether HTTP method is PUT. if _SERVER["REQUEST_METHOD"]==="PUT" + * Checks whether $_GET superglobal has certain index * + * @param string $name * @return bool */ - public function isPut() {} + public function hasQuery(string $name): bool {} /** - * Checks whether HTTP method is PATCH. if _SERVER["REQUEST_METHOD"]==="PATCH" + * Checks whether $_SERVER superglobal has certain index * + * @param string $name * @return bool */ - public function isPatch() {} + final public function hasServer(string $name): bool {} /** - * Checks whether HTTP method is HEAD. if _SERVER["REQUEST_METHOD"]==="HEAD" + * Checks whether request has been made using ajax * * @return bool */ - public function isHead() {} + public function isAjax(): bool {} /** - * Checks whether HTTP method is DELETE. if _SERVER["REQUEST_METHOD"]==="DELETE" + * Checks whether HTTP method is CONNECT. + * if _SERVER["REQUEST_METHOD"]==="CONNECT" * * @return bool */ - public function isDelete() {} + public function isConnect(): bool {} /** - * Checks whether HTTP method is OPTIONS. if _SERVER["REQUEST_METHOD"]==="OPTIONS" + * Checks whether HTTP method is DELETE. + * if _SERVER["REQUEST_METHOD"]==="DELETE" * * @return bool */ - public function isOptions() {} + public function isDelete(): bool {} /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). if _SERVER["REQUEST_METHOD"]==="PURGE" + * Checks whether HTTP method is GET. + * if _SERVER["REQUEST_METHOD"]==="GET" * * @return bool */ - public function isPurge() {} + public function isGet(): bool {} /** - * Checks whether HTTP method is TRACE. if _SERVER["REQUEST_METHOD"]==="TRACE" + * Checks whether HTTP method is HEAD. + * if _SERVER["REQUEST_METHOD"]==="HEAD" * * @return bool */ - public function isTrace() {} + public function isHead(): bool {} /** - * Checks whether HTTP method is CONNECT. if _SERVER["REQUEST_METHOD"]==="CONNECT" + * Check if HTTP method match any of the passed methods + * When strict is true it checks if validated methods are real HTTP methods * + * @param mixed $methods + * @param bool $strict * @return bool */ - public function isConnect() {} + public function isMethod($methods, bool $strict = false): bool {} /** - * Checks whether request include attached files + * Checks whether HTTP method is OPTIONS. + * if _SERVER["REQUEST_METHOD"]==="OPTIONS" * - * @param bool $onlySuccessful - * @return long + * @return bool */ - public function hasFiles($onlySuccessful = false) {} + public function isOptions(): bool {} /** - * Recursively counts file in an array of files + * Checks whether HTTP method is PATCH. + * if _SERVER["REQUEST_METHOD"]==="PATCH" * - * @param mixed $data - * @param bool $onlySuccessful - * @return long + * @return bool */ - protected final function hasFileHelper($data, $onlySuccessful) {} + public function isPatch(): bool {} /** - * Gets attached files as Phalcon\Http\Request\File instances + * Checks whether HTTP method is POST. + * if _SERVER["REQUEST_METHOD"]==="POST" * - * @param bool $onlySuccessful - * @return \Phalcon\Http\Request\FileInterface[] + * @return bool */ - public function getUploadedFiles($onlySuccessful = false) {} + public function isPost(): bool {} /** - * Smooth out $_FILES to have plain array with all files uploaded + * Checks whether HTTP method is PUT. + * if _SERVER["REQUEST_METHOD"]==="PUT" * - * @param array $names - * @param array $types - * @param array $tmp_names - * @param array $sizes - * @param array $errors - * @param string $prefix - * @return array + * @return bool */ - protected final function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, $prefix) {} + public function isPut(): bool {} /** - * Returns the available headers in the request + * Checks whether HTTP method is PURGE (Squid and Varnish support). + * if _SERVER["REQUEST_METHOD"]==="PURGE" * - * - * $_SERVER = [ - * "PHP_AUTH_USER" => "phalcon", - * "PHP_AUTH_PW" => "secret", - * ]; + * @return bool + */ + public function isPurge(): bool {} + + /** + * Checks whether request has been made using any secure layer * - * $headers = $request->getHeaders(); + * @return bool + */ + public function isSecure(): bool {} + + /** + * Checks if the `Request::getHttpHost` method will be use strict validation + * of host name or not * - * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= - * + * @return bool + */ + public function isStrictHostCheck(): bool {} + + /** + * Checks whether request has been made using SOAP * - * @return array + * @return bool */ - public function getHeaders() {} + public function isSoap(): bool {} /** - * Resolve authorization headers. + * Checks whether HTTP method is TRACE. + * if _SERVER["REQUEST_METHOD"]==="TRACE" * - * @return array + * @return bool */ - protected function resolveAuthorizationHeaders() {} + public function isTrace(): bool {} /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks if a method is a valid HTTP method * - * @return string + * @param string $method + * @return bool */ - public function getHTTPReferer() {} + public function isValidHttpMethod(string $method): bool {} /** - * Process a request header and return the one with best quality + * Sets the dependency injector * - * @param array $qualityParts - * @param string $name - * @return string + * @param \Phalcon\Di\DiInterface $container */ - protected final function _getBestQuality(array $qualityParts, $name) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Gets content type which request has been made + * Sets automatic sanitizers/filters for a particular field and for + * particular methods * - * @return string|null + * @param string $name + * @param array $filters + * @param array $scope + * @return RequestInterface */ - public function getContentType() {} + public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface {} /** - * Gets an array with mime/types and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT"] + * Sets if the `Request::getHttpHost` method must be use strict validation + * of host name or not * - * @return array + * @param bool $flag + * @return RequestInterface */ - public function getAcceptableContent() {} + public function setStrictHostCheck(bool $flag = true): RequestInterface {} /** - * Gets best mime/type accepted by the browser/client from _SERVER["HTTP_ACCEPT"] + * Process a request header and return the one with best quality * + * @param array $qualityParts + * @param string $name * @return string */ - public function getBestAccept() {} + final protected function getBestQuality(array $qualityParts, string $name): string {} /** - * Gets a charsets array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] + * Helper to get data from superglobals, applying filters if needed. + * If no parameters are given the superglobal is returned. * - * @return array + * @param array $source + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed */ - public function getClientCharsets() {} + final protected function getHelper(array $source, string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} /** - * Gets best charset accepted by the browser/client from _SERVER["HTTP_ACCEPT_CHARSET"] + * Recursively counts file in an array of files * - * @return string + * @param mixed $data + * @param bool $onlySuccessful + * @return long */ - public function getBestCharset() {} + final protected function hasFileHelper($data, bool $onlySuccessful): int {} /** - * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Process a request header and return an array of values with their qualities * + * @param string $serverIndex + * @param string $name * @return array */ - public function getLanguages() {} + final protected function getQualityHeader(string $serverIndex, string $name): array {} /** - * Gets best language accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Resolve authorization headers. * - * @return string + * @return array */ - public function getBestLanguage() {} + protected function resolveAuthorizationHeaders(): array {} /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] + * Smooth out $_FILES to have plain array with all files uploaded * - * @return array|null + * @param array $names + * @param array $types + * @param array $tmp_names + * @param array $sizes + * @param array $errors + * @param string $prefix + * @return array */ - public function getBasicAuth() {} + final protected function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, string $prefix): array {} /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] + * Checks the filter service and assigns it to the class parameter * - * @return array + * @return \Phalcon\Filter\FilterInterface */ - public function getDigestAuth() {} + private function getFilterService(): FilterInterface {} /** - * Process a request header and return an array of values with their qualities - * - * @param string $serverIndex - * @param string $name * @return array */ - protected final function _getQualityHeader($serverIndex, $name) {} + private function getServerArray(): array {} } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 493883ff..853091b0 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -3,90 +3,104 @@ namespace Phalcon\Http; /** - * Phalcon\Http\RequestInterface - * * Interface for Phalcon\Http\Request */ interface RequestInterface { /** - * Gets a variable from the $_REQUEST superglobal applying filters if needed + * Gets a variable from the $_REQUEST superglobal applying filters if + * needed. If no parameters are given the $_REQUEST superglobal is returned + * + * ```php + * // Returns value from $_REQUEST["user_email"] without sanitizing + * $userEmail = $request->get("user_email"); + * + * // Returns value from $_REQUEST["user_email"] with sanitizing + * $userEmail = $request->get("user_email", "email"); + * ``` * * @param string $name - * @param string|array $filters + * @param mixed $filters * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive * @return mixed */ - public function get($name = null, $filters = null, $defaultValue = null); + public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); /** - * Gets a variable from the $_POST superglobal applying filters if needed + * Gets an array with mime/types and their quality accepted by the + * browser/client from _SERVER["HTTP_ACCEPT"] * - * @param string $name - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @return array */ - public function getPost($name = null, $filters = null, $defaultValue = null); + public function getAcceptableContent(): array; /** - * Gets variable from $_GET superglobal applying filters if needed + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_USER"] * - * @param string $name - * @param string|array $filters - * @param mixed $defaultValue - * @return mixed + * @return array|null */ - public function getQuery($name = null, $filters = null, $defaultValue = null); + public function getBasicAuth(): ?array; /** - * Gets variable from $_SERVER superglobal + * Gets best mime/type accepted by the browser/client from + * _SERVER["HTTP_ACCEPT"] * - * @param string $name - * @return mixed + * @return string */ - public function getServer($name); + public function getBestAccept(): string; /** - * Checks whether $_REQUEST superglobal has certain index + * Gets best charset accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return bool + * @return string */ - public function has($name); + public function getBestCharset(): string; /** - * Checks whether $_POST superglobal has certain index + * Gets best language accepted by the browser/client from + * _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @param string $name - * @return bool + * @return string */ - public function hasPost($name); + public function getBestLanguage(): string; /** - * Checks whether the PUT data has certain index + * Gets most possible client IPv4 Address. This method searches in + * $_SERVER["REMOTE_ADDR"] and optionally in + * $_SERVER["HTTP_X_FORWARDED_FOR"] * - * @param string $name - * @return bool + * @param bool $trustForwardedHeader + * @return string|bool */ - public function hasPut($name); + public function getClientAddress(bool $trustForwardedHeader = false); /** - * Checks whether $_GET superglobal has certain index + * Gets a charsets array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_CHARSET"] * - * @param string $name - * @return bool + * @return array */ - public function hasQuery($name); + public function getClientCharsets(): array; /** - * Checks whether $_SERVER superglobal has certain index + * Gets content type which request has been made * - * @param string $name - * @return bool + * @return string|null + */ + public function getContentType(): ?string; + + /** + * Gets auth info accepted by the browser/client from + * $_SERVER["PHP_AUTH_DIGEST"] + * + * @return array */ - public function hasServer($name); + public function getDigestAuth(): array; /** * Gets HTTP header from request data @@ -94,243 +108,383 @@ public function hasServer($name); * @param string $header * @return string */ - public function getHeader($header); + public function getHeader(string $header): string; /** - * Gets HTTP schema (http/https) + * Returns the available headers in the request + * + * ```php + * $_SERVER = [ + * "PHP_AUTH_USER" => "phalcon", + * "PHP_AUTH_PW" => "secret", + * ]; + * + * $headers = $request->getHeaders(); + * + * echo $headers["Authorization"]; // Basic cGhhbGNvbjpzZWNyZXQ= + * ``` + * + * @return array + */ + public function getHeaders(): array; + + /** + * Gets host name used by the request. + * + * `Request::getHttpHost` trying to find host name in following order: + * + * - `$_SERVER["HTTP_HOST"]` + * - `$_SERVER["SERVER_NAME"]` + * - `$_SERVER["SERVER_ADDR"]` + * + * Optionally `Request::getHttpHost` validates and clean host name. + * The `Request::$_strictHostCheck` can be used to validate host name. + * + * Note: validation and cleaning have a negative performance impact because + * they use regular expressions. + * + * ```php + * use Phalcon\Http\Request; + * + * $request = new Request; + * + * $_SERVER["HTTP_HOST"] = "example.com"; + * $request->getHttpHost(); // example.com + * + * $_SERVER["HTTP_HOST"] = "example.com:8080"; + * $request->getHttpHost(); // example.com:8080 + * + * $request->setStrictHostCheck(true); + * $_SERVER["HTTP_HOST"] = "ex=am~ple.com"; + * $request->getHttpHost(); // UnexpectedValueException + * + * $_SERVER["HTTP_HOST"] = "ExAmPlE.com"; + * $request->getHttpHost(); // example.com + * ``` * * @return string */ - public function getScheme(); + public function getHttpHost(): string; /** - * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" + * Gets web page that refers active request. ie: http://www.google.com * - * @return bool + * @return string */ - public function isAjax(); + public function getHTTPReferer(): string; /** - * Checks whether request has been made using SOAP + * Gets decoded JSON HTTP raw request body * - * @return bool + * @param bool $associative + * @return array|bool|\stdClass */ - public function isSoapRequested(); + public function getJsonRawBody(bool $associative = false); /** - * Checks whether request has been made using any secure layer + * Gets languages array and their quality accepted by the browser/client + * from _SERVER["HTTP_ACCEPT_LANGUAGE"] * - * @return bool + * @return array */ - public function isSecureRequest(); + public function getLanguages(): array; /** - * Gets HTTP raw request body + * Gets HTTP method which request has been made + * + * If the X-HTTP-Method-Override header is set, and if the method is a POST, + * then it is used to determine the "real" intended HTTP method. + * + * The _method request parameter can also be used to determine the HTTP + * method, but only if setHttpMethodParameterOverride(true) has been called. + * + * The method is always an uppercased string. * * @return string */ - public function getRawBody(); + public function getMethod(): string; /** - * Gets active server address IP + * Gets information about the port on which the request is made * - * @return string + * @return int */ - public function getServerAddress(); + public function getPort(): int; /** - * Gets active server name + * Gets HTTP URI which request has been made * * @return string */ - public function getServerName(); + final public function getURI(): string; + + /** + * Gets a variable from the $_POST superglobal applying filters if needed + * If no parameters are given the $_POST superglobal is returned + * + * ```php + * // Returns value from $_POST["user_email"] without sanitizing + * $userEmail = $request->getPost("user_email"); + * + * // Returns value from $_POST["user_email"] with sanitizing + * $userEmail = $request->getPost("user_email", "email"); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); + + /** + * Gets a variable from put request + * + * ```php + * // Returns value from $_PUT["user_email"] without sanitizing + * $userEmail = $request->getPut("user_email"); + * + * // Returns value from $_PUT["user_email"] with sanitizing + * $userEmail = $request->getPut("user_email", "email"); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); + + /** + * Gets variable from $_GET superglobal applying filters if needed + * If no parameters are given the $_GET superglobal is returned + * + * ```php + * // Returns value from $_GET["id"] without sanitizing + * $id = $request->getQuery("id"); + * + * // Returns value from $_GET["id"] with sanitizing + * $id = $request->getQuery("id", "int"); + * + * // Returns value from $_GET["id"] with a default value + * $id = $request->getQuery("id", null, 150); + * ``` + * + * @param string $name + * @param mixed $filters + * @param mixed $defaultValue + * @param bool $notAllowEmpty + * @param bool $noRecursive + * @return mixed + */ + public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false); /** - * Gets host name used by the request + * Gets HTTP raw request body * * @return string */ - public function getHttpHost(); + public function getRawBody(): string; /** - * Gets information about the port on which the request is made + * Gets HTTP schema (http/https) * - * @return int + * @return string */ - public function getPort(); + public function getScheme(): string; /** - * Gets most possibly client IPv4 Address. This methods searches in - * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"] + * Gets variable from $_SERVER superglobal * - * @param bool $trustForwardedHeader - * @return string|bool + * @param string $name + * @return string|null */ - public function getClientAddress($trustForwardedHeader = false); + public function getServer(string $name): ?string; /** - * Gets HTTP method which request has been made + * Gets active server address IP * * @return string */ - public function getMethod(); + public function getServerAddress(): string; /** - * Gets HTTP user agent used to made the request + * Gets active server name * * @return string */ - public function getUserAgent(); + public function getServerName(): string; /** - * Check if HTTP method match any of the passed methods + * Gets attached files as Phalcon\Http\Request\FileInterface compatible + * instances * - * @param string|array $methods - * @param bool $strict - * @return bool + * @param bool $onlySuccessful + * @param bool $namedKeys + * @return array|\Phalcon\Http\Request\FileInterface[] */ - public function isMethod($methods, $strict = false); + public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; /** - * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" + * Gets HTTP user agent used to made the request * - * @return bool + * @return string */ - public function isPost(); + public function getUserAgent(): string; /** - * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" + * Checks whether $_REQUEST superglobal has certain index * + * @param string $name * @return bool */ - public function isGet(); + public function has(string $name): bool; /** - * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" + * Checks whether request include attached files + * TODO: We need to check the name. Not very intuitive + * + * @param bool $onlySuccessful + * @return long + */ + public function hasFiles(bool $onlySuccessful = false): int; + + /** + * Checks whether headers has certain index * + * @param string $header * @return bool */ - public function isPut(); + public function hasHeader(string $header): bool; /** - * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" + * Checks whether $_GET superglobal has certain index * + * @param string $name * @return bool */ - public function isHead(); + public function hasQuery(string $name): bool; /** - * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" + * Checks whether $_POST superglobal has certain index * + * @param string $name * @return bool */ - public function isDelete(); + public function hasPost(string $name): bool; /** - * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" + * Checks whether the PUT data has certain index * + * @param string $name * @return bool */ - public function isOptions(); + public function hasPut(string $name): bool; /** - * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" + * Checks whether $_SERVER superglobal has certain index * + * @param string $name * @return bool */ - public function isPurge(); + public function hasServer(string $name): bool; /** - * Checks whether HTTP method is TRACE. if $_SERVER["REQUEST_METHOD"] === "TRACE" + * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest" * * @return bool */ - public function isTrace(); + public function isAjax(): bool; /** * Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT" * * @return bool */ - public function isConnect(); + public function isConnect(): bool; /** - * Checks whether request include attached files + * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE" * - * @param boolean $onlySuccessful - * @return int + * @return bool */ - public function hasFiles($onlySuccessful = false); + public function isDelete(): bool; /** - * Gets attached files as Phalcon\Http\Request\FileInterface compatible instances + * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET" * - * @param bool $onlySuccessful - * @return \Phalcon\Http\Request\FileInterface[] + * @return bool */ - public function getUploadedFiles($onlySuccessful = false); + public function isGet(): bool; /** - * Gets web page that refers active request. ie: http://www.google.com + * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD" * - * @return string + * @return bool */ - public function getHTTPReferer(); + public function isHead(): bool; /** - * Gets array with mime/types and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] + * Check if HTTP method match any of the passed methods * - * @return array + * @param string|array $methods + * @param bool $strict + * @return bool */ - public function getAcceptableContent(); + public function isMethod($methods, bool $strict = false): bool; /** - * Gets best mime/type accepted by the browser/client from $_SERVER["HTTP_ACCEPT"] + * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS" * - * @return string + * @return bool */ - public function getBestAccept(); + public function isOptions(): bool; /** - * Gets charsets array and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] + * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST" * - * @return array + * @return bool */ - public function getClientCharsets(); + public function isPost(): bool; /** - * Gets best charset accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"] + * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE" * - * @return string + * @return bool */ - public function getBestCharset(); + public function isPurge(): bool; /** - * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT" * - * @return array + * @return bool */ - public function getLanguages(); + public function isPut(): bool; /** - * Gets best language accepted by the browser/client from $_SERVER["HTTP_ACCEPT_LANGUAGE"] + * Checks whether request has been made using any secure layer * - * @return string + * @return bool */ - public function getBestLanguage(); + public function isSecure(): bool; /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"] + * Checks whether request has been made using SOAP * - * @return array + * @return bool */ - public function getBasicAuth(); + public function isSoap(): bool; /** - * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"] + * Checks whether HTTP method is TRACE. + * if $_SERVER["REQUEST_METHOD"] === "TRACE" * - * @return array + * @return bool */ - public function getDigestAuth(); + public function isTrace(): bool; } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 31dd3efe..31051ef3 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -3,40 +3,46 @@ namespace Phalcon\Http; /** - * Phalcon\Http\Response - * * Part of the HTTP cycle is return responses to the clients. * Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. * HTTP responses are usually composed by headers and body. * - * + * ```php * $response = new \Phalcon\Http\Response(); * * $response->setStatusCode(200, "OK"); * $response->setContent("Hello"); * * $response->send(); - * + * ``` */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface +class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_sent = false; + protected $container; + + protected $content; - protected $_content; + protected $cookies; - protected $_headers; + protected $eventsManager; - protected $_cookies; + protected $file; - protected $_file; + protected $headers; - protected $_dependencyInjector; + /** + * @var bool + */ + protected $sent = false; + + + protected $statusCodes; /** @@ -49,321 +55,351 @@ class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\Injection public function __construct($content = null, $code = null, $status = null) {} /** - * Sets the dependency injector + * Appends a string to the HTTP response body * - * @param \Phalcon\DiInterface $dependencyInjector + * @param mixed $content + * @return ResponseInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function appendContent($content): ResponseInterface {} /** - * Returns the internal dependency injector + * Gets the HTTP response body * - * @return \Phalcon\DiInterface + * @return string */ - public function getDI() {} + public function getContent(): string {} /** - * Sets the HTTP response code + * Returns cookies set by the user * - * - * $response->setStatusCode(404, "Not Found"); - * + * @return \Phalcon\Http\Response\CookiesInterface + */ + public function getCookies(): CookiesInterface {} + + /** + * Returns the internal dependency injector * - * @param int $code - * @param string $message - * @return ResponseInterface + * @return \Phalcon\Di\DiInterface */ - public function setStatusCode($code, $message = null) {} + public function getDI(): DiInterface {} /** - * Returns the status code + * Returns the internal event manager * - * - * echo $response->getStatusCode(); - * + * @return \Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ManagerInterface {} + + /** + * Returns headers set by the user * - * @return int|null + * @return \Phalcon\Http\Response\HeadersInterface */ - public function getStatusCode() {} + public function getHeaders(): HeadersInterface {} /** * Returns the reason phrase * - * + * ```php * echo $response->getReasonPhrase(); - * + * ``` * * @return string|null */ - public function getReasonPhrase() {} + public function getReasonPhrase(): ?string {} /** - * Sets a headers bag for the response externally + * Returns the status code * - * @param \Phalcon\Http\Response\HeadersInterface $headers - * @return ResponseInterface + * ```php + * echo $response->getStatusCode(); + * ``` + * + * @return int|null */ - public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers) {} + public function getStatusCode(): ?int {} /** - * Returns headers set by the user + * Checks if a header exists * - * @return \Phalcon\Http\Response\HeadersInterface + * ```php + * $response->hasHeader("Content-Type"); + * ``` + * + * @param string $name + * @return bool */ - public function getHeaders() {} + public function hasHeader(string $name): bool {} /** - * Sets a cookies bag for the response externally + * Check if the response is already sent * - * @param \Phalcon\Http\Response\CookiesInterface $cookies - * @return Response + * @return bool */ - public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies) {} + public function isSent(): bool {} /** - * Returns cookies set by the user + * Redirect by HTTP to another action or URL * - * @return \Phalcon\Http\Response\CookiesInterface + * ```php + * // Using a string redirect (internal/external) + * $response->redirect("posts/index"); + * $response->redirect("http://en.wikipedia.org", true); + * $response->redirect("http://www.example.com/new-location", true, 301); + * + * // Making a redirection based on a named route + * $response->redirect( + * [ + * "for" => "index-lang", + * "lang" => "jp", + * "controller" => "index", + * ] + * ); + * ``` + * + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode + * @return ResponseInterface */ - public function getCookies() {} + public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface {} /** - * Overwrites a header in the response + * Remove a header in the response * - * - * $response->setHeader("Content-Type", "text/plain"); - * + * ```php + * $response->removeHeader("Expires"); + * ``` * * @param string $name - * @param mixed $value * @return ResponseInterface */ - public function setHeader($name, $value) {} + public function removeHeader(string $name): ResponseInterface {} /** - * Send a raw header to the response - * - * - * $response->setRawHeader("HTTP/1.1 404 Not Found"); - * + * Resets all the established headers * - * @param string $header * @return ResponseInterface */ - public function setRawHeader($header) {} + public function resetHeaders(): ResponseInterface {} /** - * Resets all the established headers + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function resetHeaders() {} + public function send(): ResponseInterface {} /** - * Sets an Expires header in the response that allows to use the HTTP cache - * - * - * $this->response->setExpires( - * new DateTime() - * ); - * + * Sends cookies to the client * - * @param \DateTime $datetime * @return ResponseInterface */ - public function setExpires(\DateTime $datetime) {} + public function sendCookies(): ResponseInterface {} /** - * Sets Last-Modified header - * - * - * $this->response->setLastModified( - * new DateTime() - * ); - * + * Sends headers to the client * - * @param \DateTime $datetime - * @return Response + * @return bool|ResponseInterface */ - public function setLastModified(\DateTime $datetime) {} + public function sendHeaders() {} /** * Sets Cache headers to use HTTP cache * - * + * ```php * $this->response->setCache(60); - * + * ``` * * @param int $minutes - * @return Response + * @return ResponseInterface */ - public function setCache($minutes) {} + public function setCache(int $minutes): ResponseInterface {} /** - * Sends a Not-Modified response + * Sets HTTP response body + * + * ```php + * $response->setContent("

Hello!

"); + * ``` + * + * @param string $content + * @return ResponseInterface + */ + public function setContent(string $content): ResponseInterface {} + + /** + * Sets the response content-length * + * ```php + * $response->setContentLength(2048); + * ``` + * + * @param int $contentLength * @return ResponseInterface */ - public function setNotModified() {} + public function setContentLength(int $contentLength): ResponseInterface {} /** * Sets the response content-type mime, optionally the charset * - * + * ```php * $response->setContentType("application/pdf"); * $response->setContentType("text/plain", "UTF-8"); - * + * ``` * * @param string $contentType * @param mixed $charset * @return ResponseInterface */ - public function setContentType($contentType, $charset = null) {} + public function setContentType(string $contentType, $charset = null): ResponseInterface {} /** - * Sets the response content-length - * - * - * $response->setContentLength(2048); - * + * Sets a cookies bag for the response externally * - * @param int $contentLength + * @param \Phalcon\Http\Response\CookiesInterface $cookies * @return ResponseInterface */ - public function setContentLength($contentLength) {} + public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface {} /** - * Set a custom ETag - * - * - * $response->setEtag(md5(time())); - * + * Sets the dependency injector * - * @param string $etag - * @return Response + * @param \Phalcon\Di\DiInterface $container */ - public function setEtag($etag) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Redirect by HTTP to another action or URL - * - * - * // Using a string redirect (internal/external) - * $response->redirect("posts/index"); - * $response->redirect("http://en.wikipedia.org", true); - * $response->redirect("http://www.example.com/new-location", true, 301); + * Set a custom ETag * - * // Making a redirection based on a named route - * $response->redirect( - * [ - * "for" => "index-lang", - * "lang" => "jp", - * "controller" => "index", - * ] + * ```php + * $response->setEtag( + * md5( + * time() + * ) * ); - * + * ``` * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode + * @param string $etag * @return ResponseInterface */ - public function redirect($location = null, $externalRedirect = false, $statusCode = 302) {} + public function setEtag(string $etag): ResponseInterface {} /** - * Sets HTTP response body + * Sets an Expires header in the response that allows to use the HTTP cache * - * - * $response->setContent("

Hello!

"); - *
+ * ```php + * $this->response->setExpires( + * new DateTime() + * ); + * ``` * - * @param string $content + * @param \DateTime $datetime * @return ResponseInterface */ - public function setContent($content) {} + public function setExpires(\DateTime $datetime): ResponseInterface {} /** - * Sets HTTP response body. The parameter is automatically converted to JSON - * and also sets default header: Content-Type: "application/json; charset=UTF-8" + * Sets the events manager * - * - * $response->setJsonContent( - * [ - * "status" => "OK", - * ] - * ); - * - * - * @param mixed $content - * @param int $jsonOptions - * @param int $depth - * @return ResponseInterface + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setJsonContent($content, $jsonOptions = 0, $depth = 512) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Appends a string to the HTTP response body + * Sets an attached file to be sent at the end of the request * - * @param mixed $content + * @param string $filePath + * @param mixed $attachmentName + * @param mixed $attachment * @return ResponseInterface */ - public function appendContent($content) {} + public function setFileToSend(string $filePath, $attachmentName = null, $attachment = true): ResponseInterface {} /** - * Gets the HTTP response body + * Overwrites a header in the response * - * @return string + * ```php + * $response->setHeader("Content-Type", "text/plain"); + * ``` + * + * @param string $name + * @param mixed $value + * @return ResponseInterface */ - public function getContent() {} + public function setHeader(string $name, $value): ResponseInterface {} /** - * Check if the response is already sent + * Sets a headers bag for the response externally * - * @return bool + * @param \Phalcon\Http\Response\HeadersInterface $headers + * @return ResponseInterface */ - public function isSent() {} + public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface {} /** - * Sends headers to the client + * Sets HTTP response body. The parameter is automatically converted to JSON + * and also sets default header: Content-Type: "application/json; charset=UTF-8" * + * ```php + * $response->setJsonContent( + * [ + * "status" => "OK", + * ] + * ); + * ``` + * + * @param mixed $content + * @param int $jsonOptions + * @param int $depth * @return ResponseInterface */ - public function sendHeaders() {} + public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512): ResponseInterface {} /** - * Sends cookies to the client + * Sets Last-Modified header + * + * ```php + * $this->response->setLastModified( + * new DateTime() + * ); + * ``` * + * @param \DateTime $datetime * @return ResponseInterface */ - public function sendCookies() {} + public function setLastModified(\DateTime $datetime): ResponseInterface {} /** - * Prints out HTTP response to the client + * Sends a Not-Modified response * * @return ResponseInterface */ - public function send() {} + public function setNotModified(): ResponseInterface {} /** - * Sets an attached file to be sent at the end of the request + * Sets the HTTP response code * - * @param string $filePath - * @param mixed $attachmentName - * @param mixed $attachment + * ```php + * $response->setStatusCode(404, "Not Found"); + * ``` + * + * @param int $code + * @param string $message * @return ResponseInterface */ - public function setFileToSend($filePath, $attachmentName = null, $attachment = true) {} + public function setStatusCode(int $code, string $message = null): ResponseInterface {} /** - * Remove a header in the response + * Send a raw header to the response * - * - * $response->removeHeader("Expires"); - * + * ```php + * $response->setRawHeader("HTTP/1.1 404 Not Found"); + * ``` * - * @param string $name - * @return Response + * @param string $header + * @return ResponseInterface */ - public function removeHeader($name) {} + public function setRawHeader(string $header): ResponseInterface {} } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index 17f684bc..d3176976 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -11,59 +11,81 @@ interface ResponseInterface { /** - * Sets the HTTP response code + * Appends a string to the HTTP response body * - * @param int $code - * @param string $message + * @param mixed $content * @return ResponseInterface */ - public function setStatusCode($code, $message = null); + public function appendContent($content): ResponseInterface; + + /** + * Gets the HTTP response body + * + * @return string + */ + public function getContent(): string; + + /** + * Returns the status code + * + * @return int|null + */ + public function getStatusCode(): ?int; /** * Returns headers set by the user * * @return \Phalcon\Http\Response\HeadersInterface */ - public function getHeaders(); + public function getHeaders(): HeadersInterface; /** - * Overwrites a header in the response + * Checks if a header exists * * @param string $name - * @param mixed $value - * @return ResponseInterface + * @return bool */ - public function setHeader($name, $value); + public function hasHeader(string $name): bool; /** - * Send a raw header to the response + * Checks if the response was already sent * - * @param string $header + * @return bool + */ + public function isSent(): bool; + + /** + * Redirect by HTTP to another action or URL + * + * @param mixed $location + * @param bool $externalRedirect + * @param int $statusCode * @return ResponseInterface */ - public function setRawHeader($header); + public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface; /** * Resets all the established headers * * @return ResponseInterface */ - public function resetHeaders(); + public function resetHeaders(): ResponseInterface; /** - * Sets output expire time header + * Sets HTTP response body * - * @param \DateTime $datetime + * @param string $content * @return ResponseInterface */ - public function setExpires(\DateTime $datetime); + public function setContent(string $content): ResponseInterface; /** - * Sends a Not-Modified response + * Sets the response content-length * + * @param int $contentLength * @return ResponseInterface */ - public function setNotModified(); + public function setContentLength(int $contentLength): ResponseInterface; /** * Sets the response content-type mime, optionally the charset @@ -72,93 +94,93 @@ public function setNotModified(); * @param string $charset * @return ResponseInterface */ - public function setContentType($contentType, $charset = null); + public function setContentType(string $contentType, $charset = null): ResponseInterface; /** - * Sets the response content-length + * Sets output expire time header * - * @param int $contentLength + * @param \DateTime $datetime * @return ResponseInterface */ - public function setContentLength($contentLength); + public function setExpires(\DateTime $datetime): ResponseInterface; /** - * Redirect by HTTP to another action or URL + * Sets an attached file to be sent at the end of the request * - * @param mixed $location - * @param bool $externalRedirect - * @param int $statusCode + * @param string $filePath + * @param mixed $attachmentName * @return ResponseInterface */ - public function redirect($location = null, $externalRedirect = false, $statusCode = 302); + public function setFileToSend(string $filePath, $attachmentName = null): ResponseInterface; /** - * Sets HTTP response body + * Overwrites a header in the response * - * @param string $content + * @param string $name + * @param mixed $value * @return ResponseInterface */ - public function setContent($content); + public function setHeader(string $name, $value): ResponseInterface; /** * Sets HTTP response body. The parameter is automatically converted to JSON * - * + * ```php * $response->setJsonContent( * [ * "status" => "OK", * ] * ); - * + * ``` * * @param mixed $content * @return ResponseInterface */ - public function setJsonContent($content); + public function setJsonContent($content): ResponseInterface; /** - * Appends a string to the HTTP response body + * Sends a Not-Modified response * - * @param mixed $content * @return ResponseInterface */ - public function appendContent($content); + public function setNotModified(): ResponseInterface; /** - * Gets the HTTP response body + * Send a raw header to the response * - * @return string + * @param string $header + * @return ResponseInterface */ - public function getContent(); + public function setRawHeader(string $header): ResponseInterface; /** - * Sends headers to the client + * Sets the HTTP response code * + * @param int $code + * @param string $message * @return ResponseInterface */ - public function sendHeaders(); + public function setStatusCode(int $code, string $message = null): ResponseInterface; /** - * Sends cookies to the client + * Prints out HTTP response to the client * * @return ResponseInterface */ - public function sendCookies(); + public function send(): ResponseInterface; /** - * Prints out HTTP response to the client + * Sends cookies to the client * * @return ResponseInterface */ - public function send(); + public function sendCookies(): ResponseInterface; /** - * Sets an attached file to be sent at the end of the request + * Sends headers to the client * - * @param string $filePath - * @param mixed $attachmentName - * @return ResponseInterface + * @return bool|ResponseInterface */ - public function setFileToSend($filePath, $attachmentName = null); + public function sendHeaders(); } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php new file mode 100644 index 00000000..99f4f9c7 --- /dev/null +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -0,0 +1,41 @@ + + */ + protected $body; + + /** + * @var + */ + protected $headers; + + /** + * Retrieves the HTTP protocol version as a string. + * + * The string MUST contain only the HTTP version number (e.g., '1.1', + * '1.0'). + * + * @return string HTTP protocol version. + * + * @var string + */ + protected $protocolVersion = '1.1'; + + /** + * Retrieves the URI instance. + * + * This method MUST return a UriInterface instance. + * + * @see http://tools.ietf.org/html/rfc3986#section-4.3 + * + * @var UriInterface + */ + protected $uri; + + + /** + * Gets the body of the message. + * + * @return + */ + public function getBody() {} + + /** + * Retrieves the HTTP protocol version as a string. + * + * The string MUST contain only the HTTP version number (e.g., '1.1', + * '1.0'). + * + * @return string + */ + public function getProtocolVersion(): string {} + + /** + * Retrieves the URI instance. + * + * This method MUST return a UriInterface instance. + * + * @return UriInterface + */ + public function getUri() {} + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name + * + * @param mixed $name + * @return array + */ + public function getHeader($name): array {} + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name + * + * @param mixed $name + * @return string + */ + public function getHeaderLine($name): string {} + + /** + * Retrieves all message header values. + * + * The keys represent the header name as it will be sent over the wire, and + * each value is an array of strings associated with the header. + * + * // Represent the headers as a string + * foreach ($message->getHeaders() as $name => $values) { + * echo $name . ': ' . implode(', ', $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return array + */ + public function getHeaders(): array {} + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name + * + * @param mixed $name + * @return bool + */ + public function hasHeader($name): bool {} + + /** + * Return an instance with the specified header appended with the given + * value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string|string[] $value + * + * @param string $name + * @param mixed $value + * @return object + */ + public function withAddedHeader($name, $value) {} + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body + * + * @throws InvalidArgumentException When the body is not valid. + * + * @param \Psr\Http\Message\StreamInterface $body + * @return object + */ + public function withBody(\Psr\Http\Message\StreamInterface $body) {} + + /** + * Return an instance with the provided value replacing the specified + * header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string|string[] $value + * + * @throws InvalidArgumentException for invalid header names or values. + * + * @param string $name + * @param mixed $value + * @return object + */ + public function withHeader($name, $value) {} + + /** + * Return an instance with the specified HTTP protocol version. + * + * The version string MUST contain only the HTTP version number (e.g., + * '1.1', '1.0'). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new protocol version. + * + * @param string $version + * + * @param mixed $version + * @return object + */ + public function withProtocolVersion($version) {} + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name + * + * @param mixed $name + * @return object + */ + public function withoutHeader($name) {} + + /** + * Ensure Host is the first header. + * + * @see: http://tools.ietf.org/html/rfc7230#section-5.4 + * + * @param Collection $collection + * + * @param \Phalcon\Collection $collection + * @return \Phalcon\Collection + */ + final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection {} + + /** + * Check the name of the header. Throw exception if not valid + * + * @see http://tools.ietf.org/html/rfc7230#section-3.2 + * + * @param mixed $name + * @param $name + */ + final protected function checkHeaderName($name) {} + + /** + * Validates a header value + * + * Most HTTP header field values are defined using common syntax + * components (token, quoted-string, and comment) separated by + * whitespace or specific delimiting characters. Delimiters are chosen + * from the set of US-ASCII visual characters not allowed in a token + * (DQUOTE and '(),/:;<=>?@[\]{}'). + * + * token = 1tchar + * + * tchar = '!' / '#' / '$' / '%' / '&' / ''' / '' + * / '+' / '-' / '.' / '^' / '_' / '`' / '|' / '~' + * / DIGIT / ALPHA + * ; any VCHAR, except delimiters + * + * A string of text is parsed as a single value if it is quoted using + * double-quote marks. + * + * quoted-string = DQUOTE( qdtext / quoted-pair ) DQUOTE + * qdtext = HTAB / SP /%x21 / %x23-5B / %x5D-7E / obs-text + * obs-text = %x80-FF + * + * Comments can be included in some HTTP header fields by surrounding + * the comment text with parentheses. Comments are only allowed in + * fields containing 'comment' as part of their field value definition. + * + * comment = '('( ctext / quoted-pair / comment ) ')' + * ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text + * + * The backslash octet ('\') can be used as a single-octet quoting + * mechanism within quoted-string and comment constructs. Recipients + * that process the value of a quoted-string MUST handle a quoted-pair + * as if it were replaced by the octet following the backslash. + * + * quoted-pair = '\' ( HTAB / SP / VCHAR / obs-text ) + * + * A sender SHOULD NOT generate a quoted-pair in a quoted-string except + * where necessary to quote DQUOTE and backslash octets occurring within + * that string. A sender SHOULD NOT generate a quoted-pair in a comment + * except where necessary to quote parentheses ['(' and ')'] and + * backslash octets occurring within that comment. + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 + * + * @param mixed $value + * @param $value + */ + final protected function checkHeaderValue($value) {} + + /** + * Returns the header values checked for validity + * + * @param $values + * + * @param mixed $values + * @return array + */ + final protected function getHeaderValue($values): array {} + + /** + * Return the host and if applicable the port + * + * @param UriInterface $uri + * + * @param \Psr\Http\Message\UriInterface $uri + * @return string + */ + final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string {} + + /** + * Populates the header collection + * + * @param array $headers + * + * @param array $headers + * @return \Phalcon\Collection + */ + final protected function populateHeaderCollection(array $headers): Collection {} + + /** + * Set a valid stream + * + * @param string $mode + * + * @param StreamInterface|resource|string $body + * @param string $mode + * @return \Psr\Http\Message\StreamInterface + */ + final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface {} + + /** + * Sets the headers + * + * @param $headers + * + * @param mixed $headers + * @return \Phalcon\Collection + */ + final protected function processHeaders($headers): Collection {} + + /** + * Checks the protocol + * + * @param string $protocol + * + * @param mixed $protocol + * @return string + */ + final protected function processProtocol($protocol = ''): string {} + +} diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php new file mode 100644 index 00000000..3fdf32fd --- /dev/null +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -0,0 +1,165 @@ +getQuery()` or from the `QUERY_STRING` server param. + * + * @var array + */ + private $queryParams = array(); + + /** + * Retrieve server parameters. + * + * Retrieves data related to the incoming request environment, + * typically derived from PHP's $_SERVER superglobal. The data IS NOT + * REQUIRED to originate from $_SERVER. + * + * @var array + */ + private $serverParams = array(); + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @var array + */ + private $uploadedFiles = array(); + + + /** + * Retrieve cookies. + * + * Retrieves cookies sent by the client to the server. + * + * The data MUST be compatible with the structure of the $_COOKIE + * superglobal. + * + * @return array + */ + public function getCookieParams(): array {} + + /** + * Retrieve any parameters provided in the request body. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, this method MUST + * return the contents of $_POST. + * + * Otherwise, this method may return any results of deserializing + * the request body content; as parsing returns structured content, the + * potential types MUST be arrays or objects only. A null value indicates + * the absence of body content. + * + * @return mixed + */ + public function getParsedBody() {} + + /** + * Retrieve query string arguments. + * + * Retrieves the deserialized query string arguments, if any. + * + * Note: the query params might not be in sync with the URI or server + * params. If you need to ensure you are only getting the original + * values, you may need to parse the query string from + * `getUri()->getQuery()` or from the `QUERY_STRING` server param. + * + * @return array + */ + public function getQueryParams(): array {} + + /** + * Retrieve server parameters. + * + * Retrieves data related to the incoming request environment, + * typically derived from PHP's $_SERVER superglobal. The data IS NOT + * REQUIRED to originate from $_SERVER. + * + * @return array + */ + public function getServerParams(): array {} + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @return array + */ + public function getUploadedFiles(): array {} + + /** + * ServerRequest constructor. + * + * @param string $method + * @param UriInterface|string|null $uri + * @param array $serverParams + * @param StreamInterface|string $body + * @param array $headers + * @param array $cookies + * @param array $queryParams + * @param array $uploadFiles + * @param null|array|object $parsedBody + * @param string $protocol + */ + public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') {} + + /** + * Retrieve a single derived request attribute. + * + * Retrieves a single derived request attribute as described in + * getAttributes(). If the attribute has not been previously set, returns + * the default value as provided. + * + * This method obviates the need for a hasAttribute() method, as it allows + * specifying a default value to return if the attribute is not found. + * + * @param mixed|null $defaultValue + * + * @param string $name + * @param mixed $defaultValue + * @return mixed + */ + public function getAttribute($name, $defaultValue = null) {} + + /** + * Retrieve attributes derived from the request. + * + * The request 'attributes' may be used to allow injection of any + * parameters derived from the request: e.g., the results of path + * match operations; the results of decrypting cookies; the results of + * deserializing non-form-encoded message bodies; etc. Attributes + * will be application and request specific, and CAN be mutable. + * + * @return array + */ + public function getAttributes(): array {} + + /** + * Return an instance with the specified derived request attribute. + * + * This method allows setting a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated attribute. + * + * @param mixed $value + * + * @param string $name + * @param mixed $value + * @return ServerRequest + */ + public function withAttribute($name, $value): ServerRequest {} + + /** + * Return an instance with the specified cookies. + * + * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST + * be compatible with the structure of $_COOKIE. Typically, this data will + * be injected at instantiation. + * + * This method MUST NOT update the related Cookie header of the request + * instance, nor related values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated cookie values. + * + * @param array $cookies + * + * @param array $cookies + * @return ServerRequest + */ + public function withCookieParams(array $cookies): ServerRequest {} + + /** + * Return an instance with the specified body parameters. + * + * These MAY be injected during instantiation. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, use this method + * ONLY to inject the contents of $_POST. + * + * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of + * deserializing the request body content. Deserialization/parsing returns + * structured data, and, as such, this method ONLY accepts arrays or + * objects, or a null value if nothing was available to parse. + * + * As an example, if content negotiation determines that the request data + * is a JSON payload, this method could be used to create a request + * instance with the deserialized parameters. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array|object|null $data + * + * @throws InvalidArgumentException if an unsupported argument type is + * provided. + * + * @param mixed $data + * @return ServerRequest + */ + public function withParsedBody($data): ServerRequest {} + + /** + * Return an instance with the specified query string arguments. + * + * These values SHOULD remain immutable over the course of the incoming + * request. They MAY be injected during instantiation, such as from PHP's + * $_GET superglobal, or MAY be derived from some other value such as the + * URI. In cases where the arguments are parsed from the URI, the data + * MUST be compatible with what PHP's parse_str() would return for + * purposes of how duplicate query parameters are handled, and how nested + * sets are handled. + * + * Setting query string arguments MUST NOT change the URI stored by the + * request, nor the values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated query string arguments. + * + * @param array $query + * + * @param array $query + * @return ServerRequest + */ + public function withQueryParams(array $query): ServerRequest {} + + /** + * Create a new instance with the specified uploaded files. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array $uploadedFiles + * + * @throws InvalidArgumentException if an invalid structure is provided. + * + * @param array $uploadedFiles + * @return ServerRequest + */ + public function withUploadedFiles(array $uploadedFiles): ServerRequest {} + + /** + * Return an instance that removes the specified derived request attribute. + * + * This method allows removing a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the attribute. + * + * @param string $name + * + * @param mixed $name + * @return ServerRequest + */ + public function withoutAttribute($name): ServerRequest {} + + /** + * Checks the uploaded files + * + * @param array $files + */ + private function checkUploadedFiles(array $files) {} + +} diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php new file mode 100644 index 00000000..2821ea96 --- /dev/null +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class InvalidArgumentException extends InvalidArgumentException implements \Throwable +{ + +} diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php new file mode 100644 index 00000000..40b7b316 --- /dev/null +++ b/src/Phalcon/http/message/stream/Input.php @@ -0,0 +1,76 @@ + + * ```php * use Phalcon\Mvc\Controller; * * class PostsController extends Controller @@ -20,58 +20,58 @@ * foreach ($this->request->getUploadedFiles() as $file) { * echo $file->getName(), " ", $file->getSize(), "\n"; * } - * } + * } * } * } - * + * ``` */ class File implements \Phalcon\Http\Request\FileInterface { + /** + * @var string|null + */ + protected $error; - protected $_name; + /** + * @var string + */ + protected $extension; + /** + * @var string|null + */ + protected $key; - protected $_tmp; + protected $name; - protected $_size; + protected $realType; - protected $_type; + protected $size; - protected $_realType; - /** - * @var string|null - */ - protected $_error; + protected $tmp; - /** - * @var string|null - */ - protected $_key; - /** - * @var string - */ - protected $_extension; + protected $type; /** * @return string|null */ - public function getError() {} + public function getError(): ?string {} /** - * @return string|null + * @return string */ - public function getKey() {} + public function getExtension(): string {} /** - * @return string + * @return string|null */ - public function getExtension() {} + public function getKey(): ?string {} /** * Phalcon\Http\Request\File constructor @@ -82,47 +82,47 @@ public function getExtension() {} public function __construct(array $file, $key = null) {} /** - * Returns the file size of the uploaded file + * Returns the real name of the uploaded file * - * @return int + * @return string */ - public function getSize() {} + public function getName(): string {} /** - * Returns the real name of the uploaded file + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getName() {} + public function getRealType(): string {} /** - * Returns the temporary name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getTempName() {} + public function getSize(): int {} /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Returns the temporary name of the uploaded file * * @return string */ - public function getType() {} + public function getTempName(): string {} /** - * Gets the real mime type of the upload file using finfo + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getRealType() {} + public function getType(): string {} /** * Checks whether the file has been uploaded via Post. * * @return bool */ - public function isUploadedFile() {} + public function isUploadedFile(): bool {} /** * Moves the temporary file to a destination within the application @@ -130,6 +130,6 @@ public function isUploadedFile() {} * @param string $destination * @return bool */ - public function moveTo($destination) {} + public function moveTo(string $destination): bool {} } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 913d759b..69f37a10 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -11,40 +11,40 @@ interface FileInterface { /** - * Returns the file size of the uploaded file + * Returns the real name of the uploaded file * - * @return int + * @return string */ - public function getSize(); + public function getName(): string; /** - * Returns the real name of the uploaded file + * Gets the real mime type of the upload file using finfo * * @return string */ - public function getName(); + public function getRealType(): string; /** - * Returns the temporal name of the uploaded file + * Returns the file size of the uploaded file * - * @return string + * @return int */ - public function getTempName(); + public function getSize(): int; /** - * Returns the mime type reported by the browser - * This mime type is not completely secure, use getRealType() instead + * Returns the temporal name of the uploaded file * * @return string */ - public function getType(); + public function getTempName(): string; /** - * Gets the real mime type of the upload file using finfo + * Returns the mime type reported by the browser + * This mime type is not completely secure, use getRealType() instead * * @return string */ - public function getRealType(); + public function getType(): string; /** * Move the temporary file to a destination @@ -52,6 +52,6 @@ public function getRealType(); * @param string $destination * @return bool */ - public function moveTo($destination); + public function moveTo(string $destination): bool; } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 8f7c5f7a..8e63b483 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -7,12 +7,13 @@ * * This class is a bag to manage the cookies. * - * A cookies bag is automatically registered as part of the 'response' service in the DI. - * By default, cookies are automatically encrypted before being sent to the client and are - * decrypted when retrieved from the user. To set sign key used to generate a message - * authentication code use `Phalcon\Http\Response\Cookies::setSignKey`. + * A cookies bag is automatically registered as part of the 'response' service + * in the DI. By default, cookies are automatically encrypted before being sent + * to the client and are decrypted when retrieved from the user. To set sign key + * used to generate a message authentication code use + * `Phalcon\Http\Response\Cookies::setSignKey()`. * - * + * ```php * use Phalcon\Di; * use Phalcon\Crypt; * use Phalcon\Http\Response\Cookies; @@ -26,6 +27,7 @@ * * // The `$key' should have been previously generated in a cryptographically safe way. * $key = "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3"; + * * $crypt->setKey($key); * * return $crypt; @@ -40,26 +42,24 @@ * // The `$key' MUST be at least 32 characters long and generated using a * // cryptographically secure pseudo random generator. * $key = "#1dj8$=dp?.ak//j1V$~%0XaK\xb1\x8d\xa9\x98\x054t7w!z%CF-Jk\x98\x05\\\x5c"; + * * $cookies->setSignKey($key); * * return $cookies; * } * ); - * + * ``` */ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $container; - protected $_registered = false; + protected $cookies = array(); - protected $_useEncryption = true; - - protected $_cookies; + protected $registered = false; /** * The cookie's sign key. @@ -69,63 +69,85 @@ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\In protected $signKey = null; + protected $useEncryption = true; + + /** * Phalcon\Http\Response\Cookies constructor * * @param bool $useEncryption * @param string $signKey */ - public function __construct($useEncryption = true, $signKey = null) {} + public function __construct(bool $useEncryption = true, string $signKey = null) {} /** - * Sets the cookie's sign key. - * - * The `$signKey' MUST be at least 32 characters long - * and generated using a cryptographically secure pseudo random generator. + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * - * Use NULL to disable cookie signing. + * @param string $name + * @return bool + */ + public function delete(string $name): bool {} + + /** + * Gets a cookie from the bag * - * @see \Phalcon\Security\Random - * @param string $signKey + * @param string $name * @return \Phalcon\Http\CookieInterface */ - public function setSignKey($signKey = null) {} + public function get(string $name): CookieInterface {} /** - * Sets the dependency injector + * Gets all cookies from the bag * - * @param \Phalcon\DiInterface $dependencyInjector + * @return array */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function getCookies(): array {} /** * Returns the internal dependency injector * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** - * Set if cookies in the bag must be automatically encrypted/decrypted + * Check if a cookie is defined in the bag or exists in the _COOKIE + * superglobal * - * @param bool $useEncryption - * @return \Phalcon\Http\Response\CookiesInterface + * @param string $name + * @return bool */ - public function useEncryption($useEncryption) {} + public function has(string $name): bool {} /** * Returns if the bag is automatically encrypting/decrypting cookies * * @return bool */ - public function isUsingEncryption() {} + public function isUsingEncryption(): bool {} + + /** + * Reset set cookies + * + * @return \Phalcon\Http\Response\CookiesInterface + */ + public function reset(): CookiesInterface {} + + /** + * Sends the cookies to the client + * Cookies aren't sent if headers are sent in the current request + * + * @return bool + */ + public function send(): bool {} /** * Sets a cookie to be sent at the end of the request. * * This method overrides any cookie set before with the same name. * - * + * ```php * use Phalcon\Http\Response\Cookies; * * $now = new DateTimeImmutable(); @@ -137,7 +159,7 @@ public function isUsingEncryption() {} * json_encode(['user_id' => 1]), * (int) $tomorrow->format('U'), * ); - * + * ``` * * @param string $name * @param mixed $value @@ -148,46 +170,35 @@ public function isUsingEncryption() {} * @param bool $httpOnly * @return \Phalcon\Http\Response\CookiesInterface */ - public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null) {} + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface {} /** - * Gets a cookie from the bag + * Sets the dependency injector * - * @param string $name - * @return \Phalcon\Http\Response\CookiesInterface + * @param \Phalcon\Di\DiInterface $container */ - public function get($name) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal + * Sets the cookie's sign key. * - * @param string $name - * @return bool - */ - public function has($name) {} - - /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * The `$signKey' MUST be at least 32 characters long + * and generated using a cryptographically secure pseudo random generator. * - * @param string $name - * @return bool - */ - public function delete($name) {} - - /** - * Sends the cookies to the client - * Cookies aren't sent if headers are sent in the current request + * Use NULL to disable cookie signing. * - * @return bool + * @see \Phalcon\Security\Random + * @param string $signKey + * @return \Phalcon\Http\CookieInterface */ - public function send() {} + public function setSignKey(string $signKey = null): CookieInterface {} /** - * Reset set cookies + * Set if cookies in the bag must be automatically encrypted/decrypted * + * @param bool $useEncryption * @return \Phalcon\Http\Response\CookiesInterface */ - public function reset() {} + public function useEncryption(bool $useEncryption): CookiesInterface {} } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index cd1c100e..abe18b6f 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -11,71 +11,71 @@ interface CookiesInterface { /** - * Set if cookies in the bag must be automatically encrypted/decrypted - * - * @param bool $useEncryption - * @return CookiesInterface - */ - public function useEncryption($useEncryption); - - /** - * Returns if the bag is automatically encrypting/decrypting cookies + * Deletes a cookie by its name + * This method does not removes cookies from the _COOKIE superglobal * + * @param string $name * @return bool */ - public function isUsingEncryption(); + public function delete(string $name): bool; /** - * Sets a cookie to be sent at the end of the request + * Gets a cookie from the bag * * @param string $name - * @param mixed $value - * @param int $expire - * @param string $path - * @param bool $secure - * @param string $domain - * @param bool $httpOnly - * @return CookiesInterface + * @return \Phalcon\Http\CookieInterface */ - public function set($name, $value = null, $expire = 0, $path = '/', $secure = null, $domain = null, $httpOnly = null); + public function get(string $name): CookieInterface; /** - * Gets a cookie from the bag + * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal * * @param string $name - * @return CookiesInterface + * @return bool */ - public function get($name); + public function has(string $name): bool; /** - * Check if a cookie is defined in the bag or exists in the _COOKIE superglobal + * Returns if the bag is automatically encrypting/decrypting cookies * - * @param string $name * @return bool */ - public function has($name); + public function isUsingEncryption(): bool; /** - * Deletes a cookie by its name - * This method does not removes cookies from the _COOKIE superglobal + * Reset set cookies * - * @param string $name - * @return bool + * @return CookiesInterface */ - public function delete($name); + public function reset(): CookiesInterface; /** * Sends the cookies to the client * * @return bool */ - public function send(); + public function send(): bool; /** - * Reset set cookies + * Sets a cookie to be sent at the end of the request + * + * @param string $name + * @param mixed $value + * @param int $expire + * @param string $path + * @param bool $secure + * @param string $domain + * @param bool $httpOnly + * @return CookiesInterface + */ + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface; + + /** + * Set if cookies in the bag must be automatically encrypted/decrypted * + * @param bool $useEncryption * @return CookiesInterface */ - public function reset(); + public function useEncryption(bool $useEncryption): CookiesInterface; } diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 7ccc1a96..31f52cbd 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -10,64 +10,64 @@ class Headers implements \Phalcon\Http\Response\HeadersInterface { - protected $_headers = array(); + protected $headers = array(); /** - * Sets a header to be sent at the end of the request + * Gets a header value from the internal bag * * @param string $name - * @param string $value + * @return string|bool */ - public function set($name, $value) {} + public function get(string $name) {} /** - * Gets a header value from the internal bag + * Sets a header to be sent at the end of the request * * @param string $name - * @return string|bool + * @return bool */ - public function get($name) {} + public function has(string $name): bool {} /** - * Sets a raw header to be sent at the end of the request + * Removes a header to be sent at the end of the request * * @param string $header */ - public function setRaw($header) {} + public function remove(string $header) {} /** - * Removes a header to be sent at the end of the request - * - * @param string $header + * Reset set headers */ - public function remove($header) {} + public function reset() {} /** * Sends the headers to the client * * @return bool */ - public function send() {} + public function send(): bool {} /** - * Reset set headers + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value */ - public function reset() {} + public function set(string $name, string $value) {} /** - * Returns the current headers as an array + * Sets a raw header to be sent at the end of the request * - * @return array + * @param string $header */ - public function toArray() {} + public function setRaw(string $header) {} /** - * Restore a \Phalcon\Http\Response\Headers object + * Returns the current headers as an array * - * @param array $data - * @return \Phalcon\Http\Response\HeadersInterface + * @return array */ - public static function __set_state(array $data) {} + public function toArray(): array {} } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index 9d7349ea..a2b439a8 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -11,46 +11,46 @@ interface HeadersInterface { /** - * Sets a header to be sent at the end of the request + * Gets a header value from the internal bag * * @param string $name - * @param string $value + * @return string|bool */ - public function set($name, $value); + public function get(string $name); /** - * Gets a header value from the internal bag + * Returns true if the header is set, false otherwise * * @param string $name - * @return string|bool + * @return bool */ - public function get($name); + public function has(string $name): bool; /** - * Sets a raw header to be sent at the end of the request - * - * @param string $header + * Reset set headers */ - public function setRaw($header); + public function reset(); /** * Sends the headers to the client * * @return bool */ - public function send(); + public function send(): bool; /** - * Reset set headers + * Sets a header to be sent at the end of the request + * + * @param string $name + * @param string $value */ - public function reset(); + public function set(string $name, string $value); /** - * Restore a \Phalcon\Http\Response\Headers object + * Sets a raw header to be sent at the end of the request * - * @param array $data - * @return HeadersInterface + * @param string $header */ - public static function __set_state(array $data); + public function setRaw(string $header); } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php new file mode 100644 index 00000000..8f3353b7 --- /dev/null +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Enum +{ + + const AUTO = 4; + + + const HEIGHT = 3; + + + const INVERSE = 5; + + + const NONE = 1; + + + const PRECISE = 6; + + + const TENSILE = 7; + + + const WIDTH = 2; + + + const HORIZONTAL = 11; + + + const VERTICAL = 12; + + +} diff --git a/src/Phalcon/image/Exception.php b/src/Phalcon/image/Exception.php index 7e881cbe..d590f857 100644 --- a/src/Phalcon/image/Exception.php +++ b/src/Phalcon/image/Exception.php @@ -2,7 +2,14 @@ namespace Phalcon\Image; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/image/Factory.php b/src/Phalcon/image/Factory.php deleted file mode 100644 index 36ef8eb9..00000000 --- a/src/Phalcon/image/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ - - * use Phalcon\Image\Factory; - * - * $options = [ - * "width" => 200, - * "height" => 200, - * "file" => "upload/test.jpg", - * "adapter" => "imagick", - * ]; - * $image = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php new file mode 100644 index 00000000..234d2713 --- /dev/null +++ b/src/Phalcon/image/ImageFactory.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +interface AdapterInterface +{ + + /** + * @param string $color + * @param int $opacity + */ + public function background(string $color, int $opacity = 100); + + /** + * @param int $radius + */ + public function blur(int $radius); + + /** + * @param int $width + * @param int $height + * @param int $offsetX + * @param int $offsetY + */ + public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null); + + /** + * @param int $direction + */ + public function flip(int $direction); + + /** + * @param AdapterInterface $watermark + */ + public function mask(AdapterInterface $watermark); + + /** + * @param int $amount + */ + public function pixelate(int $amount); + + /** + * @param int $height + * @param int $opacity + * @param bool $fadeIn + */ + public function reflection(int $height, int $opacity = 100, bool $fadeIn = false); + + /** + * @param string $ext + * @param int $quality + */ + public function render(string $ext = null, int $quality = 100); + + /** + * @param int $width + * @param int $height + * @param int $master + */ + public function resize(int $width = null, int $height = null, int $master = Image::AUTO); + + /** + * @param int $degrees + */ + public function rotate(int $degrees); + + /** + * @param string $file + * @param int $quality + */ + public function save(string $file = null, int $quality = 100); + + /** + * @param int $amount + */ + public function sharpen(int $amount); + + /** + * @param string $text + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + * @param string $color + * @param int $size + * @param string $fontfile + */ + public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null); + + /** + * @param AdapterInterface $watermark + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + */ + public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100); + +} diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index c162e8a3..e8769205 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -2,30 +2,58 @@ namespace Phalcon\Image\Adapter; - -class Gd extends \Phalcon\Image\Adapter +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $_checked = false; + static protected $checked = false; + + + /** + * @param string $file + * @param int $width + * @param int $height + */ + public function __construct(string $file, int $width = null, int $height = null) {} + + public function __destruct() {} /** * @return bool */ - public static function check() {} + public static function check(): bool {} /** - * @param string $file - * @param int $width - * @param int $height + * @return string + */ + public static function getVersion(): string {} + + /** + * @param int $r + * @param int $g + * @param int $b + * @param int $opacity */ - public function __construct($file, $width = null, $height = null) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) {} + + /** + * @param int $radius + */ + protected function processBlur(int $radius) {} /** * @param int $width * @param int $height */ - protected function _resize($width, $height) {} + protected function processCreate(int $width, int $height) {} /** * @param int $width @@ -33,93 +61,77 @@ protected function _resize($width, $height) {} * @param int $offsetX * @param int $offsetY */ - protected function _crop($width, $height, $offsetX, $offsetY) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} /** - * @param int $degrees + * @param int $direction */ - protected function _rotate($degrees) {} + protected function processFlip(int $direction) {} /** - * @param int $direction + * @param AdapterInterface $mask */ - protected function _flip($direction) {} + protected function processMask(AdapterInterface $mask) {} /** * @param int $amount */ - protected function _sharpen($amount) {} + protected function processPixelate(int $amount) {} /** * @param int $height * @param int $opacity * @param bool $fadeIn */ - protected function _reflection($height, $opacity, $fadeIn) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) {} /** - * @param \Phalcon\Image\Adapter $watermark - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - */ - protected function _watermark(\Phalcon\Image\Adapter $watermark, $offsetX, $offsetY, $opacity) {} - - /** - * @param string $text - * @param int $offsetX - * @param int $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @param string $ext + * @param int $quality */ - protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} + protected function processRender(string $ext, int $quality) {} /** - * @param \Phalcon\Image\Adapter $mask + * @param int $width + * @param int $height */ - protected function _mask(\Phalcon\Image\Adapter $mask) {} + protected function processResize(int $width, int $height) {} /** - * @param int $r - * @param int $g - * @param int $b - * @param int $opacity + * @param int $degrees */ - protected function _background($r, $g, $b, $opacity) {} + protected function processRotate(int $degrees) {} /** - * @param int $radius + * @param string $file + * @param int $quality */ - protected function _blur($radius) {} + protected function processSave(string $file, int $quality) {} /** * @param int $amount */ - protected function _pixelate($amount) {} - - /** - * @param string $file - * @param int $quality - */ - protected function _save($file, $quality) {} + protected function processSharpen(int $amount) {} /** - * @param string $ext - * @param int $quality + * @param string $text + * @param int $offsetX + * @param int $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - protected function _render($ext, $quality) {} + protected function processText(string $text, int $offsetX, int $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} /** - * @param int $width - * @param int $height + * @param AdapterInterface $watermark + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - protected function _create($width, $height) {} - - - public function __destruct() {} + protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) {} } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 2164b7f7..6164a769 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -7,7 +7,7 @@ * * Image manipulation support. Allows images to be resized, cropped, etc. * - * + * ```php * $image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg"); * * $image->resize(200, 200)->rotate(90)->crop(100, 100); @@ -15,24 +15,17 @@ * if ($image->save()) { * echo "success"; * } - * + * ``` */ -class Imagick extends \Phalcon\Image\Adapter +class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $_version = 0; + static protected $checked = false; - static protected $_checked = false; + static protected $version = 0; - /** - * Checks if Imagick is enabled - * - * @return bool - */ - public static function check() {} - /** * \Phalcon\Image\Adapter\Imagick constructor * @@ -40,158 +33,166 @@ public static function check() {} * @param int $width * @param int $height */ - public function __construct($file, $width = null, $height = null) {} + public function __construct(string $file, int $width = null, int $height = null) {} /** - * Execute a resize. - * - * @param int $width - * @param int $height + * Destroys the loaded image to free up resources. */ - protected function _resize($width, $height) {} + public function __destruct() {} /** - * This method scales the images using liquid rescaling method. Only support Imagick + * Checks if Imagick is enabled * - * @param int $width new width - * @param int $height new height - * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. - * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. + * @return bool */ - protected function _liquidRescale($width, $height, $deltaX, $rigidity) {} + public static function check(): bool {} /** - * Execute a crop. + * Get instance * - * @param int $width - * @param int $height - * @param int $offsetX - * @param int $offsetY + * @return \Imagick */ - protected function _crop($width, $height, $offsetX, $offsetY) {} + public function getInternalImInstance(): \Imagick {} /** - * Execute a rotation. + * Sets the limit for a particular resource in megabytes * - * @param int $degrees + * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes + * @param int $type + * @param int $limit */ - protected function _rotate($degrees) {} + public function setResourceLimit(int $type, int $limit) {} /** - * Execute a flip. + * Execute a background. * - * @param int $direction + * @param int $r + * @param int $g + * @param int $b + * @param int $opacity */ - protected function _flip($direction) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) {} /** - * Execute a sharpen. + * Blur image * - * @param int $amount + * @param int $radius Blur radius */ - protected function _sharpen($amount) {} + protected function processBlur(int $radius) {} /** - * Execute a reflection. + * Execute a crop. * + * @param int $width * @param int $height - * @param int $opacity - * @param bool $fadeIn + * @param int $offsetX + * @param int $offsetY */ - protected function _reflection($height, $opacity, $fadeIn) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} /** - * Execute a watermarking. + * Execute a flip. * - * @param \Phalcon\Image\Adapter $image - * @param int $offsetX - * @param int $offsetY - * @param int $opacity + * @param int $direction */ - protected function _watermark(\Phalcon\Image\Adapter $image, $offsetX, $offsetY, $opacity) {} + protected function processFlip(int $direction) {} /** - * Execute a text + * This method scales the images using liquid rescaling method. Only support + * Imagick * - * @param string $text - * @param mixed $offsetX - * @param mixed $offsetY - * @param int $opacity - * @param int $r - * @param int $g - * @param int $b - * @param int $size - * @param string $fontfile + * @param int $width new width + * @param int $height new height + * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. + * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ - protected function _text($text, $offsetX, $offsetY, $opacity, $r, $g, $b, $size, $fontfile) {} + protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) {} /** * Composite one image onto another * - * @param \Phalcon\Image\Adapter $image + * @param AdapterInterface $image */ - protected function _mask(\Phalcon\Image\Adapter $image) {} + protected function processMask(AdapterInterface $image) {} /** - * Execute a background. + * Pixelate image * - * @param int $r - * @param int $g - * @param int $b + * @param int $amount amount to pixelate + */ + protected function processPixelate(int $amount) {} + + /** + * Execute a reflection. + * + * @param int $height * @param int $opacity + * @param bool $fadeIn */ - protected function _background($r, $g, $b, $opacity) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) {} /** - * Blur image + * Execute a render. * - * @param int $radius Blur radius + * @param string $extension + * @param int $quality + * @return string */ - protected function _blur($radius) {} + protected function processRender(string $extension, int $quality): string {} /** - * Pixelate image + * Execute a resize. * - * @param int $amount amount to pixelate + * @param int $width + * @param int $height */ - protected function _pixelate($amount) {} + protected function processResize(int $width, int $height) {} /** - * Execute a save. + * Execute a rotation. * - * @param string $file - * @param int $quality + * @param int $degrees */ - protected function _save($file, $quality) {} + protected function processRotate(int $degrees) {} /** - * Execute a render. + * Execute a save. * - * @param string $extension + * @param string $file * @param int $quality - * @return string */ - protected function _render($extension, $quality) {} + protected function processSave(string $file, int $quality) {} /** - * Destroys the loaded image to free up resources. + * Execute a sharpen. + * + * @param int $amount */ - public function __destruct() {} + protected function processSharpen(int $amount) {} /** - * Get instance + * Execute a text * - * @return \Imagick + * @param string $text + * @param mixed $offsetX + * @param mixed $offsetY + * @param int $opacity + * @param int $r + * @param int $g + * @param int $b + * @param int $size + * @param string $fontfile */ - public function getInternalImInstance() {} + protected function processText(string $text, $offsetX, $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} /** - * Sets the limit for a particular resource in megabytes + * Execute a watermarking. * - * @link http://php.net/manual/ru/imagick.constants.php#imagick.constants.resourcetypes - * @param int $type - * @param int $limit + * @param AdapterInterface $image + * @param int $offsetX + * @param int $offsetY + * @param int $opacity */ - public function setResourceLimit($type, $limit) {} + protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) {} } diff --git a/src/Phalcon/logger/Adapter.php b/src/Phalcon/logger/Adapter.php deleted file mode 100644 index 6332108c..00000000 --- a/src/Phalcon/logger/Adapter.php +++ /dev/null @@ -1,174 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AdapterFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param string $fileName + * @param array $options + * @return AdapterInterface + */ + public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/logger/AdapterInterface.php b/src/Phalcon/logger/AdapterInterface.php deleted file mode 100644 index a6ed7ba9..00000000 --- a/src/Phalcon/logger/AdapterInterface.php +++ /dev/null @@ -1,144 +0,0 @@ - - * use Phalcon\Logger\Factory; - * - * $options = [ - * "name" => "log.txt", - * "adapter" => "file", - * ]; - * $logger = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - - /** - * @param string $namespace - * @param mixed $config - */ - protected static function loadClass($namespace, $config) {} - -} diff --git a/src/Phalcon/logger/Formatter.php b/src/Phalcon/logger/Formatter.php deleted file mode 100644 index 24868d1c..00000000 --- a/src/Phalcon/logger/Formatter.php +++ /dev/null @@ -1,30 +0,0 @@ - $adapter1, + * 'remote' => $adapter2, + * 'manager' => $adapter3, + * ] + * ); + * + * // Log to all adapters + * $logger->error('Something went wrong'); + * + * // Log to specific adapters + * $logger + * ->excludeAdapters(['manager']) + * ->info('This does not go to the "manager" logger); + * ``` + */ +class Logger implements \Psr\Log\LoggerInterface +{ + + const ALERT = 2; + + + const CRITICAL = 1; + + + const CUSTOM = 8; + + + const DEBUG = 7; + + + const EMERGENCY = 0; + + + const ERROR = 3; + + + const INFO = 6; + + + const NOTICE = 5; + + + const WARNING = 4; + + /** + * The adapter stack + * + * @var AdapterInterface[] + */ + protected $adapters = array(); + + /** + * @var string + */ + protected $name = ''; + + /** + * The excluded adapters for this log process + * + * @var AdapterInterface[] + */ + protected $excluded = array(); + + + /** + * Constructor. + * + * @param string $name The name of the logger + * @param array $adapters The collection of adapters to be used for logging (default []) + */ + public function __construct(string $name, array $adapters = array()) {} + + /** + * Add an adapter to the stack. For processing we use FIFO + * + * @param string $name The name of the adapter + * @param $adapter The adapter to add to the stack + * @return Logger + */ + public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger {} + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + */ + public function alert($message, array $context = array()) {} + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + */ + public function critical($message, array $context = array()) {} + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + */ + public function debug($message, array $context = array()) {} + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + */ + public function error($message, array $context = array()) {} + + /** + * System is unusable. + * + * @param string $message + * @param array $context + */ + public function emergency($message, array $context = array()) {} + + /** + * Exclude certain adapters. + * + * @param array $adapters + * @return Logger + */ + public function excludeAdapters(array $adapters = array()): Logger {} + + /** + * Returns an adapter from the stack + * + * @param string name The name of the adapter + * + * @throws + * @param string $name + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function getAdapter(string $name): AdapterInterface {} + + /** + * Returns the adapter stack array + * + * @return array + */ + public function getAdapters(): array {} + + /** + * Returns the name of the logger + * + * @return string + */ + public function getName(): string {} + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + */ + public function info($message, array $context = array()) {} + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + */ + public function log($level, $message, array $context = array()) {} + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + */ + public function notice($message, array $context = array()) {} + + /** + * Removes an adapter from the stack + * + * @param string name The name of the adapter + * + * @throws + * @param string $name + * @return Logger + */ + public function removeAdapter(string $name): Logger {} + + /** + * Sets the adapters stack overriding what is already there + * + * @param array $adapters An array of adapters + * @return Logger + */ + public function setAdapters(array $adapters): Logger {} + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + */ + public function warning($message, array $context = array()) {} + + /** + * Adds a message to each handler for processing + * + * @param string message + * + * @throws + * @param int $level + * @param string $message + * @param array $context + * @return bool + */ + protected function addMessage(int $level, string $message, array $context = array()): bool {} + + /** + * Returns an array of log levels with integer to string conversion + * + * @return array + */ + protected function getLevels(): array {} + + /** + * Converts the level from string/word to an integer + * + * @param string|int $level + * @return int + */ + private function getLevelNumber($level): int {} + +} diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php new file mode 100644 index 00000000..a53c608b --- /dev/null +++ b/src/Phalcon/logger/LoggerFactory.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface +{ + /** + * Name of the default formatter class + * + * @var string + */ + protected $defaultFormatter = 'Line'; + + /** + * Formatter + * + * @var + */ + protected $formatter; + + /** + * Tells if there is an active transaction or not + * + * @var bool + */ + protected $inTransaction = false; + + /** + * Array with messages queued in the transaction + * + * @var array + */ + protected $queue = array(); + + + /** + * Destructor cleanup + */ + public function __destruct() {} + + /** + * Adds a message to the queue + * + * @param \Phalcon\Logger\Item $item + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function add(\Phalcon\Logger\Item $item): AdapterInterface {} + + /** + * Starts a transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function begin(): AdapterInterface {} + + /** + * Commits the internal transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function commit(): AdapterInterface {} + + /** + * @return \Phalcon\Logger\Formatter\FormatterInterface + */ + public function getFormatter(): FormatterInterface {} + + /** + * Returns the whether the logger is currently in an active transaction or not + * + * @return bool + */ + public function inTransaction(): bool {} + + /** + * Processes the message in the adapter + * + * @param \Phalcon\Logger\Item $item + */ + abstract public function process(\Phalcon\Logger\Item $item); + + /** + * Rollbacks the internal transaction + * + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function rollback(): AdapterInterface {} + + /** + * Sets the message formatter + * + * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter + * @return \Phalcon\Logger\Adapter\AdapterInterface + */ + public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface {} + +} diff --git a/src/Phalcon/logger/adapter/Abstractadapter.php b/src/Phalcon/logger/adapter/Abstractadapter.php deleted file mode 100644 index 6abb00ee..00000000 --- a/src/Phalcon/logger/adapter/Abstractadapter.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ - protected $formatter; - - /** - * Tells if there is an active transaction or not - * - * @var bool - */ - protected $inTransaction = false; - - /** - * Array with messages queued in the transaction - * - * @var array - */ - protected $queue = []; - - /** - * Destructor cleanup - */ - public function __destruct() - { - } - - /** - * Adds a message to the queue - */ - public function add(Item $item) : void - { - } - - /** - * Starts a transaction - */ - public function begin() : AdapterInterface - { - } - - /** - * Commits the internal transaction - */ - public function commit() : AdapterInterface - { - } - - public function getFormatter() : FormatterInterface - { - } - - /** - * Returns the whether the logger is currently in an active transaction or not - */ - public function inTransaction() : bool - { - } - - /** - * Processes the message in the adapter - */ - public function process(Item $item) : void - { - } - - /** - * Rollbacks the internal transaction - */ - public function rollback() : AdapterInterface - { - } - - /** - * Sets the message formatter - */ - public function setFormatter(FormatterInterface $formatter) : AdapterInterface - { - } -} diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php new file mode 100644 index 00000000..b9317e56 --- /dev/null +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -0,0 +1,70 @@ + - * $logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log"); - * - * $logger->log("This is a message"); - * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - * $logger->close(); - * - */ -class File extends \Phalcon\Logger\Adapter -{ - /** - * File handler resource - * - * @var resource - */ - protected $_fileHandler; - - /** - * File Path - */ - protected $_path; - - /** - * Path options - */ - protected $_options; - - - /** - * File Path - */ - public function getPath() {} - - /** - * Phalcon\Logger\Adapter\File constructor - * - * @param string $name - * @param array $options - */ - public function __construct($name, $options = null) {} - - /** - * Returns the internal formatter - * - * @return \Phalcon\Logger\FormatterInterface - */ - public function getFormatter() {} - - /** - * Writes the log to the file itself - * - * @param string $message - * @param int $type - * @param int $time - * @param array $context - */ - public function logInternal($message, $type, $time, array $context) {} - - /** - * Closes the logger - * - * @return bool - */ - public function close() {} - - /** - * Opens the internal file handler after unserialization - */ - public function __wakeup() {} - -} diff --git a/src/Phalcon/logger/adapter/Firephp.php b/src/Phalcon/logger/adapter/Firephp.php deleted file mode 100644 index c509e369..00000000 --- a/src/Phalcon/logger/adapter/Firephp.php +++ /dev/null @@ -1,55 +0,0 @@ - - * use Phalcon\Logger\Adapter\Firephp; - * use Phalcon\Logger; - * - * $logger = new Firephp(); - * - * $logger->log(Logger::ERROR, "This is an error"); - * $logger->error("This is another error"); - * - * - * @deprecated Will be removed in 4.0.0 - */ -class Firephp extends \Phalcon\Logger\Adapter -{ - - private $_initialized = false; - - - private $_index = 1; - - - /** - * Returns the internal formatter - * - * @return \Phalcon\Logger\FormatterInterface - */ - public function getFormatter() {} - - /** - * Writes the log to the stream itself - * - * @param string $message - * @param int $type - * @param int $time - * @param array $context - */ - public function logInternal($message, $type, $time, array $context) {} - - /** - * Closes the logger - * - * @return bool - */ - public function close() {} - -} diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 76f9e1a9..9f2e6578 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -2,35 +2,35 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Noop * * Adapter to store logs in plain text files * - * + * ```php * $logger = new \Phalcon\Logger\Adapter\Noop(); * * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); * * $logger->close(); - * + * ``` */ -class Noop extends AbstractAdapter +class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter { - /** - * Closes the stream - */ - public function close() : bool - { - } - /** - * Processes the message i.e. writes it to the file - */ - public function process(Item $item) : void - { - } + /** + * Closes the stream + * + * @return bool + */ + public function close(): bool {} + + /** + * Processes the message i.e. writes it to the file + * + * @param \Phalcon\Logger\Item $item + */ + public function process(\Phalcon\Logger\Item $item) {} + } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 33279124..94b479a3 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -5,59 +5,76 @@ /** * Phalcon\Logger\Adapter\Stream * - * Sends logs to a valid PHP stream + * Adapter to store logs in plain text files * - * - * use Phalcon\Logger; - * use Phalcon\Logger\Adapter\Stream; - * - * $logger = new Stream("php://stderr"); + * ```php + * $logger = new \Phalcon\Logger\Adapter\Stream("app/logs/test.log"); * * $logger->log("This is a message"); - * $logger->log(Logger::ERROR, "This is an error"); + * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * + * + * $logger->close(); + * ``` */ -class Stream extends \Phalcon\Logger\Adapter +class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter { /** - * File handler resource + * Stream handler resource * - * @var resource + * @var resource|null */ - protected $_stream; + protected $handler = null; + /** + * The file open mode. Defaults to "ab" + * + * @var string + */ + protected $mode = 'ab'; /** - * Phalcon\Logger\Adapter\Stream constructor + * Stream name * - * @param string $name - * @param array $options + * @var string + */ + protected $name; + + /** + * Path options + * + * @var array */ - public function __construct($name, $options = null) {} + protected $options; + /** - * Returns the internal formatter + * Stream name * - * @return \Phalcon\Logger\FormatterInterface + * @return string */ - public function getFormatter() {} + public function getName(): string {} /** - * Writes the log to the stream itself + * Constructor. Accepts the name and some options * - * @param string $message - * @param int $type - * @param int $time - * @param array $context + * @param string $name + * @param array $options */ - public function logInternal($message, $type, $time, array $context) {} + public function __construct(string $name, array $options = array()) {} /** - * Closes the logger + * Closes the stream * * @return bool */ - public function close() {} + public function close(): bool {} + + /** + * Processes the message i.e. writes it to the file + * + * @param \Phalcon\Logger\Item $item + */ + public function process(\Phalcon\Logger\Item $item) {} } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index bf684c7c..14c95796 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -7,7 +7,7 @@ * * Sends logs to the system logger * - * + * ```php * use Phalcon\Logger; * use Phalcon\Logger\Adapter\Syslog; * @@ -23,12 +23,36 @@ * $logger->log("This is a message"); * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * + * ``` */ -class Syslog extends \Phalcon\Logger\Adapter +class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter { + /** + * Name of the default formatter class + * + * @var string + */ + protected $defaultFormatter = 'Syslog'; + + /** + * @var int + */ + protected $facility = 0; + + /** + * @var string + */ + protected $name = ''; - protected $_opened = false; + /** + * @var bool + */ + protected $opened = false; + + /** + * @var int + */ + protected $option = 0; /** @@ -37,30 +61,28 @@ class Syslog extends \Phalcon\Logger\Adapter * @param string $name * @param array $options */ - public function __construct($name, $options = null) {} + public function __construct(string $name, array $options = array()) {} /** - * Returns the internal formatter + * Closes the logger * - * @return \Phalcon\Logger\FormatterInterface + * @return bool */ - public function getFormatter() {} + public function close(): bool {} /** - * Writes the log to the stream itself + * Processes the message i.e. writes it to the syslog * - * @param string $message - * @param int $type - * @param int $time - * @param array $context + * @param \Phalcon\Logger\Item $item */ - public function logInternal($message, $type, $time, array $context) {} + public function process(\Phalcon\Logger\Item $item) {} /** - * Closes the logger + * Translates a Logger level to a Syslog level * - * @return bool + * @param string $level + * @return int */ - public function close() {} + private function logLevelToSyslog(string $level): int {} } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php new file mode 100644 index 00000000..9049eb11 --- /dev/null +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface +{ + + /** + * Interpolates context values into the message placeholders + * + * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message + * @param string $message + * @param array $context + */ + public function interpolate(string $message, $context = null) {} + +} diff --git a/src/Phalcon/logger/formatter/Abstractformatter.php b/src/Phalcon/logger/formatter/Abstractformatter.php deleted file mode 100644 index 1079548e..00000000 --- a/src/Phalcon/logger/formatter/Abstractformatter.php +++ /dev/null @@ -1,19 +0,0 @@ - item - * - * @return string|array - */ - public function format(Item $item); -} + /** + * Applies a format to an item + * + * @param \Phalcon\Logger\Item $item + * @return string|array + */ + public function format(\Phalcon\Logger\Item $item); + +} diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index 127cb1bd..a1552d6a 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -7,18 +7,43 @@ * * Formats messages using JSON encoding */ -class Json extends \Phalcon\Logger\Formatter +class Json extends \Phalcon\Logger\Formatter\AbstractFormatter { + /** + * Default date format + * + * @var string + */ + protected $dateFormat; + + + /** + * Default date format + * + * @return string + */ + public function getDateFormat(): string {} + + /** + * Default date format + * + * @param string $dateFormat + */ + public function setDateFormat(string $dateFormat) {} + + /** + * Phalcon\Logger\Formatter\Json construct + * + * @param string $dateFormat + */ + public function __construct(string $dateFormat = 'D, d M y H:i:s O') {} /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return string */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): string {} } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index 0387d9ed..b575d37d 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -7,21 +7,21 @@ * * Formats messages using an one-line string */ -class Line extends \Phalcon\Logger\Formatter +class Line extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Default date format * * @var string */ - protected $_dateFormat = 'D, d M y H:i:s O'; + protected $dateFormat; /** * Format applied to each message * * @var string */ - protected $_format = '[%date%][%type%] %message%'; + protected $format; /** @@ -29,28 +29,28 @@ class Line extends \Phalcon\Logger\Formatter * * @return string */ - public function getDateFormat() {} + public function getDateFormat(): string {} /** * Default date format * * @param string $dateFormat */ - public function setDateFormat($dateFormat) {} + public function setDateFormat(string $dateFormat) {} /** * Format applied to each message * * @return string */ - public function getFormat() {} + public function getFormat(): string {} /** * Format applied to each message * * @param string $format */ - public function setFormat($format) {} + public function setFormat(string $format) {} /** * Phalcon\Logger\Formatter\Line construct @@ -58,17 +58,14 @@ public function setFormat($format) {} * @param string $format * @param string $dateFormat */ - public function __construct($format = null, $dateFormat = null) {} + public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') {} /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return string */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): string {} } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index c37da150..6f886239 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -7,18 +7,15 @@ * * Prepares a message to be used in a Syslog backend */ -class Syslog extends \Phalcon\Logger\Formatter +class Syslog extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Applies a format to a message before sent it to the internal log * - * @param string $message - * @param int $type - * @param int $timestamp - * @param array $context + * @param \Phalcon\Logger\Item $item * @return array */ - public function format($message, $type, $timestamp, $context = null) {} + public function format(\Phalcon\Logger\Item $item): array {} } diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php index b1978f3b..bca86886 100644 --- a/src/Phalcon/messages/Exception.php +++ b/src/Phalcon/messages/Exception.php @@ -5,8 +5,7 @@ /** * Phalcon\Validation\Exception * - * Exceptions thrown in Phalcon\Messages\* classes will use this class - * + * Exceptions thrown in Phalcon\Messages\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index 3cfe5cfe..e1d94052 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -2,137 +2,127 @@ namespace Phalcon\Messages; -use Phalcon\Messages\MessageInterface; - /** * Phalcon\Messages\Message * * Stores a message from various components */ -class Message implements MessageInterface, \JsonSerializable +class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable { - /** - * @var int - */ - protected $code; - - /** - * @var string - */ - protected $field; - - /** - * @var string - */ - protected $message; - - /** - * @var string - */ - protected $type; - - /** - * @var array - */ - protected $metaData = []; - - /** - * Phalcon\Messages\Message constructor - */ - public function __construct(string $message, $field = "", string $type = "", int $code = 0, array $metaData = []) - { - } - - /** - * Returns the message code - */ - public function getCode() : int - { - } - - /** - * Returns field name related to message - * - * @return mixed - */ - public function getField() - { - } - - /** - * Returns verbose message - */ - public function getMessage() : string - { - } - - /** - * Returns message type - */ - public function getType() : string - { - } - - /** - * Returns message metadata - */ - public function getMetaData() : array - { - } - - /** - * Serializes the object for json_encode - */ - public function jsonSerialize() : array - { - } - - /** - * Sets code for the message - */ - public function setCode(int $code) : MessageInterface - { - } - - /** - * Sets field name related to message - */ - public function setField($field) : MessageInterface - { - } - - /** - * Sets verbose message - */ - public function setMessage(string $message) : MessageInterface - { - } - - /** - * Sets message type - */ - public function setType(string $type) : MessageInterface - { - } - - /** - * Sets message metadata - */ - public function setMetaData(array $metaData) : MessageInterface - { - } - - /** - * Magic __toString method returns verbose message - */ - public function __toString() : string - { - } - - /** - * Magic __set_state helps to re-build messages variable exporting - */ - public static function __set_state(array $message) : MessageInterface - { - } + /** + * @var int + */ + protected $code; + + /** + * @var string + */ + protected $field; + + /** + * @var string + */ + protected $message; + + /** + * @var string + */ + protected $type; + + /** + * @var array + */ + protected $metaData = array(); + + + /** + * @return int + */ + public function getCode(): int {} + + /** + * @return string + */ + public function getField(): string {} + + /** + * @return string + */ + public function getMessage(): string {} + + /** + * @return string + */ + public function getType(): string {} + + /** + * @return array + */ + public function getMetaData(): array {} + + /** + * Phalcon\Messages\Message constructor + * + * @param string $message + * @param mixed $field + * @param string $type + * @param int $code + * @param array $metaData + */ + public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) {} + + /** + * Magic __toString method returns verbose message + * + * @return string + */ + public function __toString(): string {} + + /** + * Serializes the object for json_encode + * + * @return array + */ + public function jsonSerialize(): array {} + + /** + * Sets code for the message + * + * @param int $code + * @return \Phalcon\Messages\MessageInterface + */ + public function setCode(int $code): MessageInterface {} + + /** + * Sets field name related to message + * + * @param mixed $field + * @return \Phalcon\Messages\MessageInterface + */ + public function setField($field): MessageInterface {} + + /** + * Sets verbose message + * + * @param string $message + * @return \Phalcon\Messages\MessageInterface + */ + public function setMessage(string $message): MessageInterface {} + + /** + * Sets message metadata + * + * @param array $metaData + * @return \Phalcon\Messages\MessageInterface + */ + public function setMetaData(array $metaData): MessageInterface {} + + /** + * Sets message type + * + * @param string $type + * @return \Phalcon\Messages\MessageInterface + */ + public function setType(string $type): MessageInterface {} + } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php new file mode 100644 index 00000000..550abcfa --- /dev/null +++ b/src/Phalcon/messages/MessageInterface.php @@ -0,0 +1,95 @@ + - * $messages->appendMessage( - * new \Phalcon\Messages\Message("This is a message") - * ); - * - */ - public function appendMessage(MessageInterface $message) - { - } - - /** - * Appends an array of messages to the collection - * - * - * $messages->appendMessages($messagesArray); - * - * - * @param \Phalcon\Messages\MessageInterface[] messages - */ - public function appendMessages($messages) - { - } - - /** - * Returns the number of messages in the list - */ - public function count() : int - { - } - - /** - * Returns the current message in the iterator - */ - public function current() : MessageInterface - { - } - - /** - * Filters the message collection by field name - */ - public function filter(string $fieldName) : array - { - } + /** + * @var int + */ + protected $position = 0; + + /** + * @var array + */ + protected $messages; + + + /** + * Phalcon\Messages\Messages constructor + * + * @param array $messages + */ + public function __construct(array $messages = array()) {} + + /** + * Appends a message to the collection + * + * ```php + * $messages->appendMessage( + * new \Phalcon\Messages\Message("This is a message") + * ); + * ``` + * + * @param \Phalcon\Messages\MessageInterface $message + */ + public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} + + /** + * Appends an array of messages to the collection + * + * ```php + * $messages->appendMessages($messagesArray); + * ``` + * + * @param \Phalcon\Messages\MessageInterface[] $messages + */ + public function appendMessages($messages) {} + + /** + * Returns the number of messages in the list + * + * @return int + */ + public function count(): int {} + + /** + * Returns the current message in the iterator + * + * @return \Phalcon\Messages\MessageInterface + */ + public function current(): MessageInterface {} + + /** + * Filters the message collection by field name + * + * @param string $fieldName + * @return array + */ + public function filter(string $fieldName): array {} /** * Returns serialised message objects as array for json_encode. Calls * jsonSerialize on each object if present * - * + * ```php * $data = $messages->jsonSerialize(); * echo json_encode($data); - * - */ - public function jsonSerialize() : array - { - } - - /** - * Returns the current position/key in the iterator - */ - public function key() : int - { - } - - /** - * Moves the internal iteration pointer to the next position - */ - public function next() : void - { - } - - /** - * Checks if an index exists - * - * - * var_dump( - * isset($message["database"]) - * ); - * - * - * @param int index - */ - public function offsetExists($index) : boolean - { - } - - /** - * Gets an attribute a message using the array syntax - * - * - * print_r( - * $messages[0] - * ); - * - */ - public function offsetGet($index) { - } - - /** - * Sets an attribute using the array-syntax - * - * - * $messages[0] = new \Phalcon\Messages\Message("This is a message"); - * - * - * @param \Phalcon\Messages\Message message - */ - public function offsetSet($index, $message) : void - { - } - - /** - * Removes a message from the list - * - * - * unset($message["database"]); - * - */ - public function offsetUnset($index) : void - { - } - - /** - * Rewinds the internal iterator - */ - public function rewind() : void - { - } - - /** - * Check if the current message in the iterator is valid - */ - public function valid() : boolean - { - } + * ``` + * + * @return array + */ + public function jsonSerialize(): array {} + + /** + * Returns the current position/key in the iterator + * + * @return int + */ + public function key(): int {} + + /** + * Moves the internal iteration pointer to the next position + */ + public function next() {} + + /** + * Checks if an index exists + * + * ```php + * var_dump( + * isset($message["database"]) + * ); + * ``` + * + * @param int $index + * @return bool + */ + public function offsetExists($index): bool {} + + /** + * Gets an attribute a message using the array syntax + * + * ```php + * print_r( + * $messages[0] + * ); + * ``` + * + * @param mixed $index + * @return mixed + */ + public function offsetGet($index) {} + + /** + * Sets an attribute using the array-syntax + * + * ```php + * $messages[0] = new \Phalcon\Messages\Message("This is a message"); + * ``` + * + * @param mixed $index + * @param \Phalcon\Messages\Message $message + */ + public function offsetSet($index, $message) {} + + /** + * Removes a message from the list + * + * ```php + * unset($message["database"]); + * ``` + * + * @param mixed $index + */ + public function offsetUnset($index) {} + + /** + * Rewinds the internal iterator + */ + public function rewind() {} + + /** + * Check if the current message in the iterator is valid + * + * @return bool + */ + public function valid(): bool {} + } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 293a9d9d..9faf4966 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -5,10 +5,11 @@ /** * Phalcon\Mvc\Application * - * This component encapsulates all the complex operations behind instantiating every component - * needed and integrating it with the rest to allow the MVC pattern to operate as desired. + * This component encapsulates all the complex operations behind instantiating + * every component needed and integrating it with the rest to allow the MVC + * pattern to operate as desired. * - * + * ```php * use Phalcon\Mvc\Application; * * class MyApp extends Application @@ -45,27 +46,27 @@ * $application = new MyApp(); * * $application->main(); - * + * ``` */ -class Application extends \Phalcon\Application +class Application extends \Phalcon\Application\AbstractApplication { - protected $_implicitView = true; + protected $implicitView = true; - protected $_sendHeaders = true; + protected $sendCookies = true; - protected $_sendCookies = true; + protected $sendHeaders = true; /** - * Enables or disables sending headers by each request handling + * Handles a MVC request * - * @param bool $sendHeaders - * @return Application + * @param string $uri + * @return bool|\Phalcon\Http\ResponseInterface */ - public function sendHeadersOnHandleRequest($sendHeaders) {} + public function handle(string $uri) {} /** * Enables or disables sending cookies by each request handling @@ -73,23 +74,23 @@ public function sendHeadersOnHandleRequest($sendHeaders) {} * @param bool $sendCookies * @return Application */ - public function sendCookiesOnHandleRequest($sendCookies) {} + public function sendCookiesOnHandleRequest(bool $sendCookies): Application {} /** - * By default. The view is implicitly buffering all the output - * You can full disable the view component using this method + * Enables or disables sending headers by each request handling * - * @param bool $implicitView + * @param bool $sendHeaders * @return Application */ - public function useImplicitView($implicitView) {} + public function sendHeadersOnHandleRequest(bool $sendHeaders): Application {} /** - * Handles a MVC request + * By default. The view is implicitly buffering all the output + * You can full disable the view component using this method * - * @param string $uri - * @return bool|\Phalcon\Http\ResponseInterface + * @param bool $implicitView + * @return Application */ - public function handle($uri = null) {} + public function useImplicitView(bool $implicitView): Application {} } diff --git a/src/Phalcon/mvc/Collection.php b/src/Phalcon/mvc/Collection.php index 14296c3d..a5dbf4ae 100644 --- a/src/Phalcon/mvc/Collection.php +++ b/src/Phalcon/mvc/Collection.php @@ -11,160 +11,336 @@ abstract class Collection implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\CollectionInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable { - const OP_NONE = 0; + const DIRTY_STATE_DETACHED = 2; - const OP_CREATE = 1; + const DIRTY_STATE_PERSISTENT = 0; - const OP_UPDATE = 2; + const DIRTY_STATE_TRANSIENT = 1; - const OP_DELETE = 3; + const OP_CREATE = 1; - const DIRTY_STATE_PERSISTENT = 0; + const OP_DELETE = 3; - const DIRTY_STATE_TRANSIENT = 1; + const OP_NONE = 0; - const DIRTY_STATE_DETACHED = 2; + const OP_UPDATE = 2; public $_id; - protected $_dependencyInjector; + protected $connection; - protected $_modelsManager; + protected $container; - protected $_source; + protected $dirtyState = 1; - protected $_operationMade = 0; + static protected $disableEvents; - protected $_dirtyState = 1; + protected $errorMessages = array(); - protected $_connection; + protected $modelsManager; - protected $_errorMessages = array(); + protected $operationMade = 0; - static protected $_reserved; + static protected $reserved; - static protected $_disableEvents; + protected $skipped = false; - protected $_skipped = false; + protected $source; /** * Phalcon\Mvc\Collection constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param \Phalcon\Mvc\Collection\ManagerInterface $modelsManager */ - public final function __construct(\Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} + final public function __construct(\Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {} /** - * Sets a value for the _id property, creates a MongoId object if needed + * Sets up a behavior in a collection * - * @param mixed $id + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setId($id) {} + protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} /** - * Returns the value of the _id property + * Perform an aggregation using the Mongo aggregation framework * - * @return \MongoId + * @param array $parameters + * @param array $options + * @return array */ - public function getId() {} + public static function aggregate(array $parameters = null, array $options = null): array {} /** - * Sets the dependency injection container + * Appends a customized message on the validation process + * + * ```php + * use \Phalcon\Messages\Message as Message; + * + * class Robots extends \Phalcon\Mvc\Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); + * + * $this->appendMessage(message); + * } + * } + * } + * ``` * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Messages\MessageInterface $message */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} /** - * Returns the dependency injection container + * Returns a cloned collection * - * @return \Phalcon\DiInterface + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function getDI() {} + public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface {} /** - * Sets a custom events manager + * Creates a collection based on the values in the attributes * - * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager + * @return bool */ - protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} + public function create(): bool {} /** - * Returns the custom events manager + * Creates a document based on the values in the attributes, if not found by + * criteria. Preferred way to avoid duplication is to create index o + * attribute * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * ```php + * $robot = new Robot(); + * + * $robot->name = "MyRobot"; + * $robot->type = "Droid"; + * + * // Create only if robot with same name and type does not exist + * $robot->createIfNotExist( + * [ + * "name", + * "type", + * ] + * ); + * ``` + * + * @param array $criteria + * @return bool */ - protected function getEventsManager() {} + public function createIfNotExist(array $criteria): bool {} /** - * Returns the models manager related to the entity instance + * Perform a count over a collection * - * @return \Phalcon\Mvc\Collection\ManagerInterface + * ```php + * echo "There are ", Robots::count(), " robots"; + * ``` + * + * @param array $parameters + * @return int + */ + public static function count(array $parameters = null): int {} + + /** + * Deletes a model instance. Returning true on success or false otherwise. + * + * ```php + * $robot = Robots::findFirst(); + * + * $robot->delete(); + * + * $robots = Robots::find(); + * + * foreach ($robots as $robot) { + * $robot->delete(); + * } + * ``` + * + * @return bool */ - public function getCollectionManager() {} + public function delete(): bool {} /** - * Returns an array with reserved properties that cannot be part of the insert/update + * Allows to query a set of records that match the specified conditions + * + * ```php + * // How many robots are there? + * $robots = Robots::find(); + * + * echo "There are ", count($robots), "\n"; + * + * // How many mechanical robots are there? + * $robots = Robots::find( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "There are ", count(robots), "\n"; + * + * // Get and print virtual robots ordered by name + * $robots = Robots::findFirst( + * [ + * [ + * "type" => "virtual" + * ], + * "order" => [ + * "name" => 1, + * ] + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * + * // Get first 100 virtual robots ordered by name + * $robots = Robots::find( + * [ + * [ + * "type" => "virtual", + * ], + * "order" => [ + * "name" => 1, + * ], + * "limit" => 100, + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; + * } + * ``` * + * @param array $parameters * @return array */ - public function getReservedAttributes() {} + public static function find(array $parameters = null): array {} /** - * Sets if a model must use implicit objects ids + * Find a document by its id (_id) * - * @param bool $useImplicitObjectIds + * ```php + * // Find user by using \MongoId object + * $user = Users::findById( + * new \MongoId("545eb081631d16153a293a66") + * ); + * + * // Find user by using id as sting + * $user = Users::findById("45cbc4a0e4123f6920000002"); + * + * // Validate input + * if ($user = Users::findById($_POST["id"])) { + * // ... + * } + * ``` + * + * @param mixed $id + * @return null|CollectionInterface */ - protected function useImplicitObjectIds($useImplicitObjectIds) {} + public static function findById($id): ?CollectionInterface {} /** - * Sets collection name which model should be mapped + * Allows to query the first record that match the specified conditions * - * @param string $source - * @return Collection + * ```php + * // What's the first robot in the robots table? + * $robot = Robots::findFirst(); + * + * echo "The robot name is ", $robot->name, "\n"; + * + * // What's the first mechanical robot in robots table? + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ] + * ] + * ); + * + * echo "The first mechanical robot name is ", $robot->name, "\n"; + * + * // Get first virtual robot ordered by name + * $robot = Robots::findFirst( + * [ + * [ + * "type" => "mechanical", + * ], + * "order" => [ + * "name" => 1, + * ], + * ] + * ); + * + * echo "The first virtual robot name is ", $robot->name, "\n"; + * + * // Get first robot by id (_id) + * $robot = Robots::findFirst( + * [ + * [ + * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), + * ] + * ] + * ); + * + * echo "The robot id is ", $robot->_id, "\n"; + * ``` + * + * @param array $parameters + * @return array */ - protected function setSource($source) {} + public static function findFirst(array $parameters = null): array {} /** - * Returns collection name mapped in the model + * Fires an internal event * - * @return string + * @param string $eventName + * @return bool */ - public function getSource() {} + public function fireEvent(string $eventName): bool {} /** - * Sets the DependencyInjection connection service name + * Fires an internal event that cancels the operation * - * @param string $connectionService - * @return Collection + * @param string $eventName + * @return bool */ - public function setConnectionService($connectionService) {} + public function fireEventCancel(string $eventName): bool {} /** - * Returns DependencyInjection connection service + * Returns the models manager related to the entity instance * - * @return string + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - public function getConnectionService() {} + public function getCollectionManager(): ManagerInterface {} /** * Retrieves a database connection @@ -174,534 +350,315 @@ public function getConnectionService() {} public function getConnection() {} /** - * Reads an attribute value by its name - * - * - * echo $robot->readAttribute("name"); - * + * Returns DependencyInjection connection service * - * @param string $attribute - * @return mixed + * @return string */ - public function readAttribute($attribute) {} + public function getConnectionService(): string {} /** - * Writes an attribute value by its name - * - * - * $robot->writeAttribute("name", "Rosey"); - * + * Returns the dependency injection container * - * @param string $attribute - * @param mixed $value + * @return \Phalcon\Di\DiInterface */ - public function writeAttribute($attribute, $value) {} + public function getDI(): DiInterface {} /** - * Returns a cloned collection + * Returns one of the DIRTY_STATE_ constants telling if the document exists + * in the collection or not * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @return int */ - public static function cloneResult(CollectionInterface $collection, array $document) {} + public function getDirtyState(): int {} /** - * Returns a collection resultset + * Returns the custom events manager * - * @param array $params - * @param \Phalcon\Mvc\Collection $collection - * @param \MongoDb $connection - * @param boolean $unique - * @return array + * @return \Phalcon\Mvc\Collection\ManagerInterface */ - protected static function _getResultset($params, CollectionInterface $collection, $connection, $unique) {} + protected function getEventsManager(): ManagerInterface {} /** - * Perform a count over a resultset + * Returns the value of the _id property * - * @param array $params - * @param \Phalcon\Mvc\Collection $collection - * @param \MongoDb $connection - * @return int + * @return \MongoId */ - protected static function _getGroupResultset($params, Collection $collection, $connection) {} + public function getId() {} /** - * Executes internal hooks before save a document + * Returns all the validation messages * - * @param \Phalcon\DiInterface $dependencyInjector - * @param boolean $disableEvents - * @param boolean $exists - * @return bool - */ - protected final function _preSave($dependencyInjector, $disableEvents, $exists) {} - - /** - * Executes internal events after save a document - * - * @param bool $disableEvents - * @param bool $success - * @param bool $exists - * @return bool - */ - protected final function _postSave($disableEvents, $success, $exists) {} - - /** - * Executes validators on every validation call - * - * - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * // Old, deprecated syntax, use new one below - * $this->validate( - * new ExclusionIn( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); + * ```php + * $robot = new Robots(); * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; * - * - * use Phalcon\Validation\Validator\ExclusionIn as ExclusionIn; - * use Phalcon\Validation; + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $validator = new Validation(); - * $validator->add("status", - * new ExclusionIn( - * [ - * "domain" => ["A", "I"] - * ] - * ) - * ); + * $messages = $robot->getMessages(); * - * return $this->validate($validator); + * foreach ($messages as $message) { + * echo $message; * } + * } else { + * echo "Great, a new robot was saved successfully!"; * } - * + * ``` * - * @param mixed $validator + * @return array|\Phalcon\Messages\MessageInterface[] */ - protected function validate($validator) {} + public function getMessages(): array {} /** - * Check whether validation process has generated any messages + * Returns an array with reserved properties that cannot be part of the + * insert/update * - * - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new ExclusionIn( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * - * - * @return bool + * @return array */ - public function validationHasFailed() {} + public function getReservedAttributes(): array {} /** - * Fires an internal event + * Returns collection name mapped in the model * - * @param string $eventName - * @return bool + * @return string */ - public function fireEvent($eventName) {} + public function getSource(): string {} /** - * Fires an internal event that cancels the operation + * Reads an attribute value by its name * - * @param string $eventName - * @return bool - */ - public function fireEventCancel($eventName) {} - - /** - * Cancel the current operation + * ```php + * echo $robot->readAttribute("name"); + * ``` * - * @param bool $disableEvents - * @return bool + * @param string $attribute + * @return mixed|null */ - protected function _cancelOperation($disableEvents) {} + public function readAttribute(string $attribute): ? {} /** - * Checks if the document exists in the collection + * Creates/Updates a collection based on the values in the attributes * - * @param \MongoCollection $collection * @return bool */ - protected function _exists($collection) {} + public function save(): bool {} /** - * Returns all the validation messages - * - * - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); - * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * + * Serializes the object ignoring connections or protected properties * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return string */ - public function getMessages() {} + public function serialize(): string {} /** - * Appends a customized message on the validation process - * - * - * use \Phalcon\Mvc\Model\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - * + * Sets the DependencyInjection connection service name * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @param string $connectionService + * @return Collection */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} + public function setConnectionService(string $connectionService): Collection {} /** - * Shared Code for CU Operations - * Prepares Collection + * Sets the dependency injection container + * + * @param \Phalcon\Di\DiInterface $container */ - protected function prepareCU() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Creates/Updates a collection based on the values in the attributes + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @return bool + * @param int $dirtyState + * @return CollectionInterface */ - public function save() {} + public function setDirtyState(int $dirtyState): CollectionInterface {} /** - * Creates a collection based on the values in the attributes + * Sets a custom events manager * - * @return bool + * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager */ - public function create() {} + protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} /** - * Creates a document based on the values in the attributes, if not found by criteria - * Preferred way to avoid duplication is to create index on attribute - * - * - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * + * Sets a value for the _id property, creates a MongoId object if needed * - * @param array $criteria - * @return bool + * @param mixed $id */ - public function createIfNotExist(array $criteria) {} + public function setId($id) {} /** - * Creates/Updates a collection based on the values in the attributes + * Sets collection name which model should be mapped * - * @return bool + * @param string $source + * @return Collection */ - public function update() {} + protected function setSource(string $source): Collection {} /** - * Find a document by its id (_id) - * - * - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * + * Skips the current operation forcing a success state * - * @param mixed $id - * @return null|CollectionInterface + * @param bool $skip */ - public static function findById($id) {} + public function skipOperation(bool $skip) {} /** - * Allows to query the first record that match the specified conditions - * - * - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * + * Allows to perform a summatory group for a column in the collection * - * @param array $parameters + * @param string $field + * @param mixed $conditions + * @param mixed $finalize * @return array */ - public static function findFirst(array $parameters = null) {} + public static function summatory(string $field, $conditions = null, $finalize = null): array {} /** - * Allows to query a set of records that match the specified conditions - * - * - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } + * Returns the instance as an array representation * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] + * ```php + * print_r( + * $robot->toArray() * ); + * ``` * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * - * @param array $parameters * @return array */ - public static function find(array $parameters = null) {} - - /** - * Perform a count over a collection - * - * - * echo "There are ", Robots::count(), " robots"; - * - * - * @param array $parameters - * @return int - */ - public static function count(array $parameters = null) {} + public function toArray(): array {} /** - * Perform an aggregation using the Mongo aggregation framework + * Unserializes the object from a serialized string * - * @param array $parameters - * @param array $options - * @return array + * @param mixed $data */ - public static function aggregate(array $parameters = null, array $options = null) {} + public function unserialize($data) {} /** - * Allows to perform a summatory group for a column in the collection + * Creates/Updates a collection based on the values in the attributes * - * @param string $field - * @param mixed $conditions - * @param mixed $finalize - * @return array + * @return bool */ - public static function summatory($field, $conditions = null, $finalize = null) {} + public function update(): bool {} /** - * Deletes a model instance. Returning true on success or false otherwise. + * Executes validators on every validation call * - * - * $robot = Robots::findFirst(); + * ```php + * use Phalcon\Mvc\Collection; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; * - * $robot->delete(); + * class Subscriptors extends Collection + * { + * public function validation() + * { + * $validator = new Validation(); * - * $robots = Robots::find(); + * $validator->add( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); * - * foreach ($robots as $robot) { - * $robot->delete(); + * return $this->validate($validator); + * } * } - * + * ``` * + * @param \Phalcon\Validation\ValidationInterface $validator * @return bool */ - public function delete() {} + protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Sets if a model must use implicit objects ids * - * @param int $dirtyState - * @return CollectionInterface + * @param bool $useImplicitObjectIds */ - public function setDirtyState($dirtyState) {} + protected function useImplicitObjectIds(bool $useImplicitObjectIds) {} /** - * Returns one of the DIRTY_STATE_ constants telling if the document exists in the collection or not + * Writes an attribute value by its name * - * @return int + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` + * + * @param string $attribute + * @param mixed $value */ - public function getDirtyState() {} + public function writeAttribute(string $attribute, $value) {} /** - * Sets up a behavior in a collection + * Cancel the current operation * - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param bool $disableEvents + * @return bool */ - protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + protected function cancelOperation(bool $disableEvents): bool {} /** - * Skips the current operation forcing a success state + * Checks if the document exists in the collection * - * @param bool $skip + * @param MongoCollection $collection + * @return bool */ - public function skipOperation($skip) {} + protected function exists($collection): bool {} /** - * Returns the instance as an array representation + * Perform a count over a resultset * - * - * print_r( - * $robot->toArray() - * ); - * + * @param array $params + * @param Collection $collection + * @param \MongoDb $connection + * @return int + */ + protected static function getGroupResultset($params, Collection $collection, $connection): int {} + + /** + * Returns a collection resultset * + * @param array $params + * @param CollectionInterface $collection + * @param \MongoDb $connection + * @param bool $unique * @return array */ - public function toArray() {} + protected static function getResultset($params, CollectionInterface $collection, $connection, bool $unique) {} /** - * Serializes the object ignoring connections or protected properties + * Executes internal hooks before save a document * - * @return string + * @param \Phalcon\Di\DiInterface $container + * @param bool $disableEvents + * @param bool $exists + * @return bool */ - public function serialize() {} + final protected function preSave(\Phalcon\Di\DiInterface $container, bool $disableEvents, bool $exists): bool {} /** - * Unserializes the object from a serialized string + * Executes internal events after save a document * - * @param mixed $data + * @param bool $disableEvents + * @param bool $success + * @param bool $exists + * @return bool */ - public function unserialize($data) {} + final protected function postSave(bool $disableEvents, bool $success, bool $exists): bool {} + + /** + * Shared Code for CU Operations + * Prepares Collection + */ + protected function prepareCU() {} } diff --git a/src/Phalcon/mvc/CollectionInterface.php b/src/Phalcon/mvc/CollectionInterface.php index ab22a531..ead5cdd5 100644 --- a/src/Phalcon/mvc/CollectionInterface.php +++ b/src/Phalcon/mvc/CollectionInterface.php @@ -3,162 +3,163 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\CollectionInterface - * * Interface for Phalcon\Mvc\Collection */ interface CollectionInterface { /** - * Sets a value for the _id property, creates a MongoId object if needed + * Appends a customized message on the validation process * - * @param mixed $id + * @param \Phalcon\Messages\MessageInterface $message */ - public function setId($id); + public function appendMessage(\Phalcon\Messages\MessageInterface $message); /** - * Returns the value of the _id property + * Returns a cloned collection * - * @return MongoId + * @param CollectionInterface $collection + * @param array $document + * @return CollectionInterface */ - public function getId(); + public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface; /** - * Returns an array with reserved properties that cannot be part of the insert/update + * Perform a count over a collection * - * @return array + * @param array $parameters + * @return int */ - public function getReservedAttributes(); + public static function count(array $parameters = null): int; /** - * Returns collection name mapped in the model + * Deletes a model instance. Returning true on success or false otherwise * - * @return string + * @return bool */ - public function getSource(); + public function delete(): bool; /** - * Sets a service in the services container that returns the Mongo database + * Allows to query a set of records that match the specified conditions * - * @param string $connectionService + * @param array $parameters + * @return array */ - public function setConnectionService($connectionService); + public static function find(array $parameters = null): array; /** - * Retrieves a database connection + * Find a document by its id * - * @return MongoDb + * @param string $id + * @return null|CollectionInterface */ - public function getConnection(); + public static function findById($id): ?CollectionInterface; /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Allows to query the first record that match the specified conditions * - * @param int $dirtyState - * @return \Phalcon\Mvc\CollectionInterface + * @param array $parameters + * @return array */ - public function setDirtyState($dirtyState); + public static function findFirst(array $parameters = null): array; /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @return int + * @param string $eventName + * @return bool */ - public function getDirtyState(); + public function fireEvent(string $eventName): bool; /** - * Returns a cloned collection + * Fires an event, implicitly listeners in the events manager are notified + * This method stops if one of the callbacks/listeners returns bool false * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface + * @param string $eventName + * @return bool */ - public static function cloneResult(CollectionInterface $collection, array $document); + public function fireEventCancel(string $eventName): bool; /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Retrieves a database connection * - * @param string $eventName - * @return bool + * @return MongoDb */ - public function fireEvent($eventName); + public function getConnection(); /** - * Fires an event, implicitly listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param string $eventName - * @return bool + * @return int */ - public function fireEventCancel($eventName); + public function getDirtyState(): int; /** - * Check whether validation process has generated any messages + * Returns the value of the _id property * - * @return bool + * @return MongoId */ - public function validationHasFailed(); + public function getId(); /** * Returns all the validation messages * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getMessages(); + public function getMessages(): array; /** - * Appends a customized message on the validation process + * Returns an array with reserved properties that cannot be part of the + * insert/update * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @return array */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); + public function getReservedAttributes(): array; /** - * Creates/Updates a collection based on the values in the attributes + * Returns collection name mapped in the model * - * @return bool + * @return string */ - public function save(); + public function getSource(): string; /** - * Find a document by its id + * Creates/Updates a collection based on the values in the attributes * - * @param string $id - * @return null|CollectionInterface + * @return bool */ - public static function findById($id); + public function save(): bool; /** - * Allows to query the first record that match the specified conditions + * Sets a service in the services container that returns the Mongo database * - * @param array $parameters - * @return array + * @param string $connectionService */ - public static function findFirst(array $parameters = null); + public function setConnectionService(string $connectionService); /** - * Allows to query a set of records that match the specified conditions + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @param array $parameters - * @param $array parameters - * @return array + * @param int $dirtyState + * @return CollectionInterface */ - public static function find(array $parameters = null); + public function setDirtyState(int $dirtyState): CollectionInterface; /** - * Perform a count over a collection + * Sets a value for the _id property, creates a MongoId object if needed * - * @param array $parameters - * @return array + * @param mixed $id */ - public static function count(array $parameters = null); + public function setId($id); /** - * Deletes a model instance. Returning true on success or false otherwise + * Check whether validation process has generated any messages * * @return bool */ - public function delete(); + public function validationHasFailed(): bool; } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index f4089c53..e7f03779 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -5,13 +5,15 @@ /** * Phalcon\Mvc\Controller * - * Every application controller should extend this class that encapsulates all the controller functionality + * Every application controller should extend this class that encapsulates all + * the controller functionality * - * The controllers provide the “flow” between models and views. Controllers are responsible - * for processing the incoming requests from the web browser, interrogating the models for data, - * and passing that data on to the views for presentation. + * The controllers provide the “flow” between models and views. Controllers are + * responsible for processing the incoming requests from the web browser, + * interrogating the models for data, and passing that data on to the views for + * presentation. * - * + * ```php * + * ``` */ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ControllerInterface { @@ -46,6 +48,6 @@ abstract class Controller extends \Phalcon\Di\Injectable implements \Phalcon\Mvc /** * Phalcon\Mvc\Controller constructor */ - public final function __construct() {} + final public function __construct() {} } diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index f48fc6ad..50644e36 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -3,13 +3,12 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\Dispatcher + * Dispatching is the process of taking the request object, extracting the + * module name, controller name, action name, and optional parameters contained + * in it, and then instantiating a controller and calling an action of that + * controller. * - * Dispatching is the process of taking the request object, extracting the module name, - * controller name, action name, and optional parameters contained in it, and then - * instantiating a controller and calling an action of that controller. - * - * + * ```php * $di = new \Phalcon\Di(); * * $dispatcher = new \Phalcon\Mvc\Dispatcher(); @@ -21,88 +20,24 @@ * $dispatcher->setParams([]); * * $controller = $dispatcher->dispatch(); - * + * ``` */ -class Dispatcher extends \Phalcon\Dispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface { - protected $_handlerSuffix = 'Controller'; - - - protected $_defaultHandler = 'index'; - - - protected $_defaultAction = 'index'; - - - /** - * Sets the default controller suffix - * - * @param string $controllerSuffix - */ - public function setControllerSuffix($controllerSuffix) {} - - /** - * Sets the default controller name - * - * @param string $controllerName - */ - public function setDefaultController($controllerName) {} - - /** - * Sets the controller name to be dispatched - * - * @param string $controllerName - */ - public function setControllerName($controllerName) {} - - /** - * Gets last dispatched controller name - * - * @return string - */ - public function getControllerName() {} + protected $defaultAction = 'index'; - /** - * Gets previous dispatched namespace name - * - * @return string - */ - public function getPreviousNamespaceName() {} - /** - * Gets previous dispatched controller name - * - * @return string - */ - public function getPreviousControllerName() {} + protected $defaultHandler = 'index'; - /** - * Gets previous dispatched action name - * - * @return string - */ - public function getPreviousActionName() {} - /** - * Throws an internal exception - * - * @param string $message - * @param int $exceptionCode - */ - protected function _throwDispatchException($message, $exceptionCode = 0) {} + protected $handlerSuffix = 'Controller'; - /** - * Handles a user exception - * - * @param \Exception $exception - */ - protected function _handleException(\Exception $exception) {} /** * Forwards the execution flow to another controller/action. * - * + * ```php * use Phalcon\Events\Event; * use Phalcon\Mvc\Dispatcher; * use App\Backend\Bootstrap as Backend; @@ -136,8 +71,13 @@ protected function _handleException(\Exception $exception) {} * function(Event $event, Dispatcher $dispatcher, array $forward) use ($modules) { * $metadata = $modules[$forward["module"]]["metadata"]; * - * $dispatcher->setModuleName($forward["module"]); - * $dispatcher->setNamespaceName($metadata["controllersNamespace"]); + * $dispatcher->setModuleName( + * $forward["module"] + * ); + * + * $dispatcher->setNamespaceName( + * $metadata["controllersNamespace"] + * ); * } * ); * @@ -149,31 +89,96 @@ protected function _handleException(\Exception $exception) {} * "action" => "index", * ] * ); - * + * ``` * * @param array $forward */ public function forward($forward) {} /** - * Possible controller class name that will be located to dispatch the request + * Returns the active controller in the dispatcher + * + * @return \Phalcon\Mvc\ControllerInterface + */ + public function getActiveController(): ControllerInterface {} + + /** + * Possible controller class name that will be located to dispatch the + * request * * @return string */ - public function getControllerClass() {} + public function getControllerClass(): string {} + + /** + * Gets last dispatched controller name + * + * @return string + */ + public function getControllerName(): string {} /** * Returns the latest dispatched controller * * @return \Phalcon\Mvc\ControllerInterface */ - public function getLastController() {} + public function getLastController(): ControllerInterface {} /** - * Returns the active controller in the dispatcher + * Gets previous dispatched action name * - * @return \Phalcon\Mvc\ControllerInterface + * @return string + */ + public function getPreviousActionName(): string {} + + /** + * Gets previous dispatched controller name + * + * @return string + */ + public function getPreviousControllerName(): string {} + + /** + * Gets previous dispatched namespace name + * + * @return string + */ + public function getPreviousNamespaceName(): string {} + + /** + * Sets the controller name to be dispatched + * + * @param string $controllerName + */ + public function setControllerName(string $controllerName) {} + + /** + * Sets the default controller suffix + * + * @param string $controllerSuffix + */ + public function setControllerSuffix(string $controllerSuffix) {} + + /** + * Sets the default controller name + * + * @param string $controllerName + */ + public function setDefaultController(string $controllerName) {} + + /** + * Handles a user exception + * + * @param \Exception $exception + */ + protected function handleException(\Exception $exception) {} + + /** + * Throws an internal exception + * + * @param string $message + * @param int $exceptionCode */ - public function getActiveController() {} + protected function throwDispatchException(string $message, int $exceptionCode = 0) {} } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index d0625078..3019e142 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -7,49 +7,49 @@ * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends \Phalcon\DispatcherInterface +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** - * Sets the default controller suffix + * Returns the active controller in the dispatcher * - * @param string $controllerSuffix + * @return \Phalcon\Mvc\ControllerInterface */ - public function setControllerSuffix($controllerSuffix); + public function getActiveController(): ControllerInterface; /** - * Sets the default controller name + * Gets last dispatched controller name * - * @param string $controllerName + * @return string */ - public function setDefaultController($controllerName); + public function getControllerName(): string; /** - * Sets the controller name to be dispatched + * Returns the latest dispatched controller * - * @param string $controllerName + * @return \Phalcon\Mvc\ControllerInterface */ - public function setControllerName($controllerName); + public function getLastController(): ControllerInterface; /** - * Gets last dispatched controller name + * Sets the default controller suffix * - * @return string + * @param string $controllerSuffix */ - public function getControllerName(); + public function setControllerSuffix(string $controllerSuffix); /** - * Returns the latest dispatched controller + * Sets the controller name to be dispatched * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerName */ - public function getLastController(); + public function setControllerName(string $controllerName); /** - * Returns the active controller in the dispatcher + * Sets the default controller name * - * @return \Phalcon\Mvc\ControllerInterface + * @param string $controllerName */ - public function getActiveController(); + public function setDefaultController(string $controllerName); } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index 196e0b86..ccff1790 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -14,9 +14,9 @@ interface EntityInterface * Reads an attribute value by its name * * @param string $attribute - * @return mixed + * @return mixed|null */ - public function readAttribute($attribute); + public function readAttribute(string $attribute): ?; /** * Writes an attribute value by its name @@ -24,6 +24,6 @@ public function readAttribute($attribute); * @param string $attribute * @param mixed $value */ - public function writeAttribute($attribute, $value); + public function writeAttribute(string $attribute, $value); } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index 7f8ca591..b1fba1ac 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\Micro * - * With Phalcon you can create "Micro-Framework like" applications. By doing this, you only need to - * write a minimal amount of code to create a PHP application. Micro applications are suitable - * to small applications, APIs and prototypes in a practical way. + * With Phalcon you can create "Micro-Framework like" applications. By doing + * this, you only need to write a minimal amount of code to create a PHP + * application. Micro applications are suitable to small applications, APIs and + * prototypes in a practical way. * - * + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $app->get( @@ -19,185 +20,161 @@ * } * ); * - * $app->handle(); - * + * $app->handle("/say/welcome/Phalcon"); + * ``` */ class Micro extends \Phalcon\Di\Injectable implements \ArrayAccess { - protected $_dependencyInjector; + protected $activeHandler; - protected $_handlers = array(); + protected $afterBindingHandlers = array(); - protected $_router; + protected $afterHandlers = array(); - protected $_stopped; + protected $beforeHandlers = array(); - protected $_notFoundHandler; + protected $container; - protected $_errorHandler; + protected $errorHandler; - protected $_activeHandler; + protected $finishHandlers = array(); - protected $_beforeHandlers; + protected $handlers = array(); - protected $_afterHandlers; + protected $modelBinder; - protected $_finishHandlers; + protected $notFoundHandler; - protected $_returnedValue; + protected $responseHandler; - protected $_modelBinder; + protected $returnedValue; - protected $_afterBindingHandlers; + protected $router; - /** - * Phalcon\Mvc\Micro constructor - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} + protected $stopped; - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} /** - * Maps a route to a handler without any HTTP method constraint + * Phalcon\Mvc\Micro constructor * - * @param string $routePattern - * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function map($routePattern, $handler) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) {} /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Appends an 'after' middleware to be called after execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function get($routePattern, $handler) {} + public function after($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Appends a afterBinding middleware to be called after model binding * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function post($routePattern, $handler) {} + public function afterBinding($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Appends a before middleware to be called before execute the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function put($routePattern, $handler) {} + public function before($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Maps a route to a handler that only matches if the HTTP method is DELETE * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function patch($routePattern, $handler) {} + public function delete(string $routePattern, $handler): RouteInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets a handler that will be called when an exception is thrown handling + * the route * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function head($routePattern, $handler) {} + public function error($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Appends a 'finish' middleware to be called when the request is finished * - * @param string $routePattern * @param callable $handler - * @return \Phalcon\Mvc\Router\RouteInterface + * @return Micro */ - public function delete($routePattern, $handler) {} + public function finish($handler): Micro {} /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Maps a route to a handler that only matches if the HTTP method is GET * * @param string $routePattern * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function options($routePattern, $handler) {} + public function get(string $routePattern, $handler): RouteInterface {} /** - * Mounts a collection of handlers + * Return the handler that will be called for the matched route * - * @param \Phalcon\Mvc\Micro\CollectionInterface $collection - * @return Micro + * @return callable */ - public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection) {} + public function getActiveHandler() {} /** - * Sets a handler that will be called when the router doesn't match any of the defined routes + * Returns bound models from binder instance * - * @param callable $handler - * @return Micro + * @return array */ - public function notFound($handler) {} + public function getBoundModels(): array {} /** - * Sets a handler that will be called when an exception is thrown handling the route + * Returns the internal handlers attached to the application * - * @param callable $handler - * @return Micro + * @return array */ - public function error($handler) {} + public function getHandlers(): array {} /** - * Returns the internal router used by the application + * Gets model binder * - * @return RouterInterface + * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getRouter() {} + public function getModelBinder(): ?BinderInterface {} /** - * Sets a service from the DI + * Returns the value returned by the executed handler * - * @param string $serviceName - * @param mixed $definition - * @param boolean $shared - * @return \Phalcon\Di\ServiceInterface + * @return mixed */ - public function setService($serviceName, $definition, $shared = false) {} + public function getReturnedValue() {} /** - * Checks if a service is registered in the DI + * Returns the internal router used by the application * - * @param string $serviceName - * @return bool + * @return RouterInterface */ - public function hasService($serviceName) {} + public function getRouter(): RouterInterface {} /** * Obtains a service from the DI @@ -205,7 +182,7 @@ public function hasService($serviceName) {} * @param string $serviceName * @return object */ - public function getService($serviceName) {} + public function getService(string $serviceName) {} /** * Obtains a shared service from the DI @@ -213,7 +190,7 @@ public function getService($serviceName) {} * @param string $serviceName * @return mixed */ - public function getSharedService($serviceName) {} + public function getSharedService(string $serviceName) {} /** * Handle the whole request @@ -221,140 +198,187 @@ public function getSharedService($serviceName) {} * @param string $uri * @return mixed */ - public function handle($uri = null) {} + public function handle(string $uri) {} /** - * Stops the middleware execution avoiding than other middlewares be executed + * Checks if a service is registered in the DI + * + * @param string $serviceName + * @return bool */ - public function stop() {} + public function hasService(string $serviceName): bool {} /** - * Sets externally the handler that must be called by the matched route + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param callable $activeHandler + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setActiveHandler($activeHandler) {} + public function head(string $routePattern, $handler): RouteInterface {} /** - * Return the handler that will be called for the matched route + * Maps a route to a handler without any HTTP method constraint * - * @return callable + * @param string $routePattern + * @param callable $handler + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getActiveHandler() {} + public function map(string $routePattern, $handler): RouteInterface {} /** - * Returns the value returned by the executed handler + * Mounts a collection of handlers * - * @return mixed + * @param \Phalcon\Mvc\Micro\CollectionInterface $collection + * @return Micro */ - public function getReturnedValue() {} + public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro {} /** - * Check if a service is registered in the internal services container using the array syntax + * Sets a handler that will be called when the router doesn't match any of + * the defined routes * - * @param string $alias - * @return bool + * @param callable $handler + * @return Micro */ - public function offsetExists($alias) {} + public function notFound($handler): Micro {} /** - * Allows to register a shared service in the internal services container using the array syntax - * - * - * $app["request"] = new \Phalcon\Http\Request(); - * + * Check if a service is registered in the internal services container using + * the array syntax * - * @param string $alias - * @param mixed $definition + * @param mixed $alias + * @return bool */ - public function offsetSet($alias, $definition) {} + public function offsetExists($alias): bool {} /** - * Allows to obtain a shared service in the internal services container using the array syntax + * Allows to obtain a shared service in the internal services container + * using the array syntax * - * + * ```php * var_dump( * $app["request"] * ); - * + * ``` * - * @param string $alias + * @param mixed $alias * @return mixed */ public function offsetGet($alias) {} /** - * Removes a service from the internal services container using the array syntax + * Allows to register a shared service in the internal services container + * using the array syntax * - * @param string $alias + * ```php + * $app["request"] = new \Phalcon\Http\Request(); + * ``` + * + * @param mixed $alias + * @param mixed $definition + */ + public function offsetSet($alias, $definition) {} + + /** + * Removes a service from the internal services container using the array + * syntax + * + * @param mixed $alias */ public function offsetUnset($alias) {} /** - * Appends a before middleware to be called before execute the route + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function before($handler) {} + public function options(string $routePattern, $handler): RouteInterface {} /** - * Appends a afterBinding middleware to be called after model binding + * Maps a route to a handler that only matches if the HTTP method is PATCH * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function afterBinding($handler) {} + public function patch(string $routePattern, $handler): RouteInterface {} /** - * Appends an 'after' middleware to be called after execute the route + * Maps a route to a handler that only matches if the HTTP method is POST * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function after($handler) {} + public function post(string $routePattern, $handler): RouteInterface {} /** - * Appends a 'finish' middleware to be called when the request is finished + * Maps a route to a handler that only matches if the HTTP method is PUT * + * @param string $routePattern * @param callable $handler - * @return Micro + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function finish($handler) {} + public function put(string $routePattern, $handler): RouteInterface {} /** - * Returns the internal handlers attached to the application + * Sets externally the handler that must be called by the matched route * - * @return array + * @param callable $activeHandler */ - public function getHandlers() {} + public function setActiveHandler($activeHandler) {} /** - * Gets model binder + * Sets the DependencyInjector container * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getModelBinder() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Sets model binder * - * + * ```php * $micro = new Micro($di); - * $micro->setModelBinder(new Binder(), 'cache'); - * + * + * $micro->setModelBinder( + * new Binder(), + * 'cache' + * ); + * ``` * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache * @return Micro */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null) {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro {} /** - * Returns bound models from binder instance + * Appends a custom 'reponse' handler to be called insted of the default + * response handler * - * @return array + * @param callable $handler + * @return Micro */ - public function getBoundModels() {} + public function setResponseHandler($handler): Micro {} + + /** + * Sets a service from the DI + * + * @param string $serviceName + * @param mixed $definition + * @param bool $shared + * @return \Phalcon\Di\ServiceInterface + */ + public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface {} + + /** + * Stops the middleware execution avoiding than other middlewares be + * executed + */ + public function stop() {} } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 85fada49..4778080b 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -5,19 +5,21 @@ /** * Phalcon\Mvc\Model * - * Phalcon\Mvc\Model connects business objects and database tables to create - * a persistable domain model where logic and data are presented in one wrapping. + * Phalcon\Mvc\Model connects business objects and database tables to create a + * persistable domain model where logic and data are presented in one wrapping. * It‘s an implementation of the object-relational mapping (ORM). * - * A model represents the information (data) of the application and the rules to manipulate that data. - * Models are primarily used for managing the rules of interaction with a corresponding database table. - * In most cases, each table in your database will correspond to one model in your application. - * The bulk of your application's business logic will be concentrated in the models. + * A model represents the information (data) of the application and the rules to + * manipulate that data. Models are primarily used for managing the rules of + * interaction with a corresponding database table. In most cases, each table in + * your database will correspond to one model in your application. The bulk of + * your application's business logic will be concentrated in the models. * - * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, giving to developers high performance - * when interacting with databases while is also easy to use. + * Phalcon\Mvc\Model is the first ORM written in Zephir/C languages for PHP, + * giving to developers high performance when interacting with databases while + * is also easy to use. * - * + * ```php * $robot = new Robots(); * * $robot->type = "mechanical"; @@ -35,75 +37,78 @@ * } else { * echo "Great, a new robot was saved successfully!"; * } - * + * ``` */ abstract class Model implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable, \JsonSerializable { - const TRANSACTION_INDEX = 'transaction'; + const DIRTY_STATE_DETACHED = 2; - const OP_NONE = 0; + const DIRTY_STATE_PERSISTENT = 0; - const OP_CREATE = 1; + const DIRTY_STATE_TRANSIENT = 1; - const OP_UPDATE = 2; + const OP_CREATE = 1; const OP_DELETE = 3; - const DIRTY_STATE_PERSISTENT = 0; + const OP_NONE = 0; - const DIRTY_STATE_TRANSIENT = 1; + const OP_UPDATE = 2; - const DIRTY_STATE_DETACHED = 2; + const TRANSACTION_INDEX = 'transaction'; + + + protected $container; - protected $_dependencyInjector; + protected $dirtyState = 1; - protected $_modelsManager; + protected $dirtyRelated = array(); - protected $_modelsMetaData; + protected $errorMessages = array(); - protected $_errorMessages; + protected $modelsManager; - protected $_operationMade = 0; + protected $modelsMetaData; - protected $_dirtyState = 1; + protected $related = array(); - protected $_transaction; + protected $operationMade = 0; - protected $_uniqueKey; + protected $oldSnapshot = array(); - protected $_uniqueParams; + protected $skipped; - protected $_uniqueTypes; + protected $snapshot; - protected $_skipped; + protected $transaction; - protected $_related; + protected $uniqueKey; - protected $_snapshot; + protected $uniqueParams; - protected $_oldSnapshot; + protected $uniqueTypes; @@ -113,198 +118,114 @@ public function getTransaction() {} * Phalcon\Mvc\Model constructor * * @param mixed $data - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager */ - public final function __construct($data = null, \Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} + final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} /** - * Sets the dependency injection container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the dependency injection container + * Handles method calls when a method is not implemented * - * @return \Phalcon\DiInterface + * @param string $method + * @param array $arguments + * @return mixed */ - public function getDI() {} + public function __call(string $method, array $arguments) {} /** - * Sets a custom events manager + * Handles method calls when a static method is not implemented * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param string $method + * @param array $arguments + * @return mixed */ - protected function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public static function __callStatic(string $method, array $arguments) {} /** - * Returns the custom events manager + * Magic method to get related records using the relation alias as a + * property * - * @return \Phalcon\Events\ManagerInterface + * @param string $property + * @return mixed */ - protected function getEventsManager() {} + public function __get(string $property) {} /** - * Returns the models meta-data service related to the entity instance + * Magic method to check if a property is a valid relation * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @param string $property + * @return bool */ - public function getModelsMetaData() {} + public function __isset(string $property): bool {} /** - * Returns the models manager related to the entity instance + * Magic method to assign values to the the model * - * @return \Phalcon\Mvc\Model\ManagerInterface + * @param string $property + * @param mixed $value */ - public function getModelsManager() {} + public function __set(string $property, $value) {} /** - * Sets a transaction related to the Model instance - * - * - * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; - * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; - * - * try { - * $txManager = new TxManager(); - * - * $transaction = $txManager->get(); - * - * $robot = new Robots(); - * - * $robot->setTransaction($transaction); - * - * $robot->name = "WALL·E"; - * $robot->created_at = date("Y-m-d"); - * - * if ($robot->save() === false) { - * $transaction->rollback("Can't save robot"); - * } - * - * $robotPart = new RobotParts(); - * - * $robotPart->setTransaction($transaction); + * Setups a behavior in a model * - * $robotPart->type = "head"; + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Mvc\Model\Behavior\Timestampable; * - * if ($robotPart->save() === false) { - * $transaction->rollback("Robot part cannot be saved"); + * class Robots extends Model + * { + * public function initialize() + * { + * $this->addBehavior( + * new Timestampable( + * [ + * "onCreate" => [ + * "field" => "created_at", + * "format" => "Y-m-d", + * ], + * ] + * ) + * ); * } - * - * $transaction->commit(); - * } catch (TxFailed $e) { - * echo "Failed, reason: ", $e->getMessage(); * } - * - * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return ModelInterface - */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} - - /** - * Sets the table name to which model should be mapped - * - * @param string $source - * @return Model - */ - protected function setSource($source) {} - - /** - * Returns the table name mapped in the model - * - * @return string - */ - public function getSource() {} - - /** - * Sets schema name where the mapped table is located - * - * @param string $schema - * @return Model - */ - protected function setSchema($schema) {} - - /** - * Returns schema name where the mapped table is located - * - * @return string - */ - public function getSchema() {} - - /** - * Sets the DependencyInjection connection service name - * - * @param string $connectionService - * @return Model - */ - public function setConnectionService($connectionService) {} - - /** - * Sets the DependencyInjection connection service name used to read data + * ``` * - * @param string $connectionService - * @return Model - */ - public function setReadConnectionService($connectionService) {} - - /** - * Sets the DependencyInjection connection service name used to write data - * - * @param string $connectionService - * @return Model - */ - public function setWriteConnectionService($connectionService) {} - - /** - * Returns the DependencyInjection connection service name used to read data related the model - * - * @return string - */ - public function getReadConnectionService() {} - - /** - * Returns the DependencyInjection connection service name used to write data related to the model - * - * @return string + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function getWriteConnectionService() {} + public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Appends a customized message on the validation process * - * @param int $dirtyState - * @return ModelInterface - */ - public function setDirtyState($dirtyState) {} - - /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Messages\Message as Message; * - * @return int - */ - public function getDirtyState() {} - - /** - * Gets the connection used to read data for the model + * class Robots extends Model + * { + * public function beforeSave() + * { + * if ($this->name === "Peter") { + * $message = new Message( + * "Sorry, but a robot cannot be named Peter" + * ); * - * @return \Phalcon\Db\AdapterInterface - */ - public function getReadConnection() {} - - /** - * Gets the connection used to write data to the model + * $this->appendMessage($message); + * } + * } + * } + * ``` * - * @return \Phalcon\Db\AdapterInterface + * @param \Phalcon\Messages\MessageInterface $message + * @return \Phalcon\Mvc\ModelInterface */ - public function getWriteConnection() {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface {} /** * Assigns values to a model from an array * - * + * ```php * $robot->assign( * [ * "type" => "mechanical", @@ -345,20 +266,50 @@ public function getWriteConnection() {} * "year", * ] * ); - * + * ``` * * @param array $data * @param array $dataColumnMap array to transform keys of data to another * @param array $whiteList - * @return Model + * @return \Phalcon\Mvc\ModelInterface */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null) {} + public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface {} /** - * Assigns values to a model from an array, returning a new model. + * Returns the average value on a column for a result-set of rows matching + * the specified conditions * - * - * $robot = \Phalcon\Mvc\Model::cloneResultMap( + * ```php + * // What's the average price of robots? + * $average = Robots::average( + * [ + * "column" => "price", + * ] + * ); + * + * echo "The average price is ", $average, "\n"; + * + * // What's the average price of mechanical robots? + * $average = Robots::average( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); + * + * echo "The average price of mechanical robots is ", $average, "\n"; + * ``` + * + * @param array $parameters + * @return double + */ + public static function average($parameters = null): float {} + + /** + * Assigns values to a model from an array returning a new model + * + * ```php + * $robot = Phalcon\Mvc\Model::cloneResult( * new Robots(), * [ * "type" => "mechanical", @@ -366,32 +317,20 @@ public function assign(array $data, $dataColumnMap = null, $whiteList = null) {} * "year" => 1952, * ] * ); - * + * ``` * - * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface $base * @param array $data - * @param array $columnMap * @param int $dirtyState - * @param boolean $keepSnapshots - * @return Model - */ - public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null) {} - - /** - * Returns an hydrated result based on the data and the column map - * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode - * @return mixed + * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode) {} + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface {} /** - * Assigns values to a model from an array returning a new model + * Assigns values to a model from an array, returning a new model. * - * - * $robot = Phalcon\Mvc\Model::cloneResult( + * ```php + * $robot = \Phalcon\Mvc\Model::cloneResultMap( * new Robots(), * [ * "type" => "mechanical", @@ -399,41 +338,139 @@ public static function cloneResultMapHydrate(array $data, $columnMap, $hydration * "year" => 1952, * ] * ); - * + * ``` * - * @param \Phalcon\Mvc\ModelInterface $base + * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base * @param array $data + * @param array $columnMap * @param int $dirtyState + * @param bool $keepSnapshots * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResult(ModelInterface $base, array $data, $dirtyState = 0) {} + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface {} /** - * Query for a set of records that match the specified conditions + * Returns an hydrated result based on the data and the column map + * + * @param array $data + * @param array $columnMap + * @param int $hydrationMode + * @return mixed + */ + public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) {} + + /** + * Counts how many records match the specified conditions * - * + * ```php * // How many robots are there? - * $robots = Robots::find(); + * $number = Robots::count(); * - * echo "There are ", count($robots), "\n"; + * echo "There are ", $number, "\n"; * * // How many mechanical robots are there? - * $robots = Robots::find( - * "type = 'mechanical'" - * ); - * - * echo "There are ", count($robots), "\n"; + * $number = Robots::count("type = 'mechanical'"); * - * // Get and print virtual robots ordered by name - * $robots = Robots::find( - * [ - * "type = 'virtual'", - * "order" => "name", - * ] - * ); + * echo "There are ", $number, " mechanical robots\n"; + * ``` * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * @param array $parameters + * @return int + */ + public static function count($parameters = null): int {} + + /** + * Inserts a model instance. If the instance already exists in the + * persistence it will throw an exception + * Returning true on success or false otherwise. + * + * ```php + * // Creating a new robot + * $robot = new Robots(); + * + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; + * + * $robot->create(); + * + * // Passing an array to create + * $robot = new Robots(); + * + * $robot->assign( + * [ + * "type" => "mechanical", + * "name" => "Astro Boy", + * "year" => 1952, + * ] + * ); + * + * $robot->create(); + * ``` + * + * @return bool + */ + public function create(): bool {} + + /** + * Deletes a model instance. Returning true on success or false otherwise. + * + * ```php + * $robot = Robots::findFirst("id=100"); + * + * $robot->delete(); + * + * $robots = Robots::find("type = 'mechanical'"); + * + * foreach ($robots as $robot) { + * $robot->delete(); + * } + * ``` + * + * @return bool + */ + public function delete(): bool {} + + /** + * Returns a simple representation of the object that can be used with + * `var_dump()` + * + * ```php + * var_dump( + * $robot->dump() + * ); + * ``` + * + * @return array + */ + public function dump(): array {} + + /** + * Query for a set of records that match the specified conditions + * + * ```php + * // How many robots are there? + * $robots = Robots::find(); + * + * echo "There are ", count($robots), "\n"; + * + * // How many mechanical robots are there? + * $robots = Robots::find( + * "type = 'mechanical'" + * ); + * + * echo "There are ", count($robots), "\n"; + * + * // Get and print virtual robots ordered by name + * $robots = Robots::find( + * [ + * "type = 'virtual'", + * "order" => "name", + * ] + * ); + * + * foreach ($robots as $robot) { + * echo $robot->name, "\n"; * } * * // Get first 100 virtual robots ordered by name @@ -446,7 +483,7 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * ); * * foreach ($robots as $robot) { - * echo $robot->name, "\n"; + * echo $robot->name, "\n"; * } * * // encapsulate find it into an running transaction esp. useful for application unit-tests @@ -454,11 +491,27 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); + * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); - * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); * - * $resultInsideTransaction = Robot::find(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); + * $newRobot->assign( + * [ + * 'name' => 'test', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * + * $newRobot->save(); + * + * $resultInsideTransaction = Robot::find( + * [ + * 'name' => 'test', + * Model::TRANSACTION_INDEX => $myTransaction, + * ] + * ); + * * $resultOutsideTransaction = Robot::find(['name' => 'test']); * * foreach ($setInsideTransaction as $robot) { @@ -481,39 +534,85 @@ public static function cloneResult(ModelInterface $base, array $data, $dirtyStat * // add a new robots * $firstNewRobot = new Robot(); * $firstNewRobot->setTransaction($myTransaction1); - * $firstNewRobot->save(['name' => 'first-transaction-robot', 'type' => 'mechanical', 'year' => 1944]); + * $firstNewRobot->assign( + * [ + * 'name' => 'first-transaction-robot', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * $firstNewRobot->save(); * * $secondNewRobot = new Robot(); * $secondNewRobot->setTransaction($myTransaction2); - * $secondNewRobot->save(['name' => 'second-transaction-robot', 'type' => 'fictional', 'year' => 1984]); + * $secondNewRobot->assign( + * [ + * 'name' => 'second-transaction-robot', + * 'type' => 'fictional', + * 'year' => 1984, + * ] + * ); + * $secondNewRobot->save(); * * // this transaction will find the robot. - * $resultInFirstTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); + * $resultInFirstTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction1, + * ] + * ); + * * // this transaction won't find the robot. - * $resultInSecondTransaction = Robot::find(['name' => 'first-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); + * $resultInSecondTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction2, + * ] + * ); + * * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'first-transaction-robot']); + * $resultOutsideAnyExplicitTransaction = Robot::find( + * [ + * 'name' => 'first-transaction-robot', + * ] + * ); * * // this transaction won't find the robot. - * $resultInFirstTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction2]); + * $resultInFirstTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction2, + * ] + * ); + * * // this transaction will find the robot. - * $resultInSecondTransaction = Robot::find(['name' => 'second-transaction-robot', Model::TRANSACTION_INDEX => $myTransaction1]); + * $resultInSecondTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * Model::TRANSACTION_INDEX => $myTransaction1, + * ] + * ); + * * // this transaction won't find the robot. - * $resultOutsideAnyExplicitTransaction = Robot::find(['name' => 'second-transaction-robot']); + * $resultOutsideAnyExplicitTransaction = Robot::find( + * [ + * 'name' => 'second-transaction-robot', + * ] + * ); * * $transaction1->rollback(); * $transaction2->rollback(); - * + * ``` * * @param mixed $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public static function find($parameters = null) {} + public static function find($parameters = null): ResultsetInterface {} /** * Query the first record that matches the specified conditions * - * + * ```php * // What's the first robot in robots table? * $robot = Robots::findFirst(); * @@ -521,7 +620,7 @@ public static function find($parameters = null) {} * * // What's the first mechanical robot in robots table? * $robot = Robots::findFirst( - * "type = 'mechanical'" + * "type = 'mechanical'" * ); * * echo "The first mechanical robot name is ", $robot->name; @@ -539,431 +638,414 @@ public static function find($parameters = null) {} * // behaviour with transaction * $myTransaction = new Transaction(\Phalcon\Di::getDefault()); * $myTransaction->begin(); + * * $newRobot = new Robot(); * $newRobot->setTransaction($myTransaction); - * $newRobot->save(['name' => 'test', 'type' => 'mechanical', 'year' => 1944]); + * $newRobot->assign( + * [ + * 'name' => 'test', + * 'type' => 'mechanical', + * 'year' => 1944, + * ] + * ); + * $newRobot->save(); + * + * $findsARobot = Robot::findFirst( + * [ + * 'name' => 'test', + * Model::TRANSACTION_INDEX => $myTransaction, + * ] + * ); * - * $findsARobot = Robot::findFirst(['name' => 'test', Model::TRANSACTION_INDEX => $myTransaction]); - * $doesNotFindARobot = Robot::findFirst(['name' => 'test']); + * $doesNotFindARobot = Robot::findFirst( + * [ + * 'name' => 'test', + * ] + * ); * * var_dump($findARobot); * var_dump($doesNotFindARobot); * * $transaction->commit(); - * $doesFindTheRobotNow = Robot::findFirst(['name' => 'test']); - * * - * @param mixed $parameters - * @return Model + * $doesFindTheRobotNow = Robot::findFirst( + * [ + * 'name' => 'test', + * ] + * ); + * ``` + * + * @param string|array $parameters + * @return bool|\Phalcon\Mvc\ModelInterface */ public static function findFirst($parameters = null) {} /** - * shared prepare query logic for find and findFirst method + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @param mixed $params - * @param mixed $limit - * @return \Phalcon\Mvc\Model\Query + * @param string $eventName + * @return bool */ - private static function getPreparedQuery($params, $limit = null) {} + public function fireEvent(string $eventName): bool {} /** - * Create a criteria for a specific model + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified + * This method stops if one of the callbacks/listeners returns bool false * - * @param \Phalcon\DiInterface $dependencyInjector - * @return \Phalcon\Mvc\Model\Criteria + * @param string $eventName + * @return bool */ - public static function query(\Phalcon\DiInterface $dependencyInjector = null) {} + public function fireEventCancel(string $eventName): bool {} /** - * Checks whether the current record already exists + * Returns a list of changed values. * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @return bool + * ```php + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] + * + * $robots->deleted = 'Y'; + * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * ``` + * + * @return array */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table = null) {} + public function getChangedFields(): array {} /** - * Generate a PHQL SELECT statement for an aggregate + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param string $functionName - * @param string $alias - * @param array $parameters - * @param string $function - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return int */ - protected static function _groupResult($functionName, $alias, $parameters) {} + public function getDirtyState(): int {} /** - * Counts how many records match the specified conditions - * - * - * // How many robots are there? - * $number = Robots::count(); - * - * echo "There are ", $number, "\n"; - * - * // How many mechanical robots are there? - * $number = Robots::count("type = 'mechanical'"); + * Returns the dependency injection container * - * echo "There are ", $number, " mechanical robots\n"; - * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the custom events manager * - * @param array $parameters - * @return mixed + * @return \Phalcon\Events\ManagerInterface */ - public static function count($parameters = null) {} + public function getEventsManager(): EventsManagerInterface {} /** - * Calculates the sum on a column for a result-set of rows that match the specified conditions + * Returns array of validation messages * - * - * // How much are all robots? - * $sum = Robots::sum( - * [ - * "column" => "price", - * ] - * ); + * ```php + * $robot = new Robots(); * - * echo "The total price of robots is ", $sum, "\n"; + * $robot->type = "mechanical"; + * $robot->name = "Astro Boy"; + * $robot->year = 1952; * - * // How much are mechanical robots? - * $sum = Robots::sum( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); + * if ($robot->save() === false) { + * echo "Umh, We can't store robots right now "; * - * echo "The total price of mechanical robots is ", $sum, "\n"; - * + * $messages = $robot->getMessages(); * - * @param array $parameters - * @return mixed + * foreach ($messages as $message) { + * echo $message; + * } + * } else { + * echo "Great, a new robot was saved successfully!"; + * } + * ``` + * + * @param mixed $filter + * @return array|\Phalcon\Messages\MessageInterface[] */ - public static function sum($parameters = null) {} + public function getMessages($filter = null): array {} /** - * Returns the maximum value of a column for a result-set of rows that match the specified conditions - * - * - * // What is the maximum robot id? - * $id = Robots::maximum( - * [ - * "column" => "id", - * ] - * ); + * Returns the models manager related to the entity instance * - * echo "The maximum robot id is: ", $id, "\n"; + * @return \Phalcon\Mvc\Model\ManagerInterface + */ + public function getModelsManager(): ManagerInterface {} + + /** + * {@inheritdoc} * - * // What is the maximum id of mechanical robots? - * $sum = Robots::maximum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); + * @return \Phalcon\Mvc\Model\MetaDataInterface + */ + public function getModelsMetaData(): MetaDataInterface {} + + /** + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * echo "The maximum robot id of mechanical robots is ", $id, "\n"; - * + * @return int + */ + public function getOperationMade(): int {} + + /** + * Returns the internal old snapshot data * - * @param array $parameters - * @return mixed + * @return array */ - public static function maximum($parameters = null) {} + public function getOldSnapshotData(): array {} /** - * Returns the minimum value of a column for a result-set of rows that match the specified conditions + * Gets the connection used to read data for the model * - * - * // What is the minimum robot id? - * $id = Robots::minimum( - * [ - * "column" => "id", - * ] - * ); - * - * echo "The minimum robot id is: ", $id; - * - * // What is the minimum id of mechanical robots? - * $sum = Robots::minimum( - * [ - * "type = 'mechanical'", - * "column" => "id", - * ] - * ); + * @return \Phalcon\Db\Adapter\AdapterInterface + */ + final public function getReadConnection(): AdapterInterface {} + + /** + * Returns the DependencyInjection connection service name used to read data + * related the model * - * echo "The minimum robot id of mechanical robots is ", $id; - * + * @return string + */ + final public function getReadConnectionService(): string {} + + /** + * Returns related records based on defined relations * - * @param array $parameters - * @return mixed + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ - public static function minimum($parameters = null) {} + public function getRelated(string $alias, $arguments = null) {} /** - * Returns the average value on a column for a result-set of rows matching the specified conditions + * Checks if saved related records have already been loaded. * - * - * // What's the average price of robots? - * $average = Robots::average( - * [ - * "column" => "price", - * ] - * ); + * Only returns true if the records were previously fetched + * through the model without any additional parameters. * - * echo "The average price is ", $average, "\n"; + * ```php + * $robot = Robots::findFirst(); + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false * - * // What's the average price of mechanical robots? - * $average = Robots::average( - * [ - * "type = 'mechanical'", - * "column" => "price", - * ] - * ); + * $robotsParts = $robot->getRobotsParts(['id > 0']); + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false * - * echo "The average price of mechanical robots is ", $average, "\n"; - * + * $robotsParts = $robot->getRobotsParts(); // or $robot->robotsParts + * var_dump($robot->isRelationshipLoaded('robotsParts')); // true * - * @param array $parameters - * @return double + * $robot->robotsParts = [new RobotsParts()]; + * var_dump($robot->isRelationshipLoaded('robotsParts')); // false + * ``` + * + * @param string $relationshipAlias + * @return bool */ - public static function average($parameters = null) {} + public function isRelationshipLoaded(string $relationshipAlias): bool {} /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Returns schema name where the mapped table is located * - * @param string $eventName - * @return bool + * @return string */ - public function fireEvent($eventName) {} + final public function getSchema(): string {} /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Returns the internal snapshot data * - * @param string $eventName - * @return bool + * @return array */ - public function fireEventCancel($eventName) {} + public function getSnapshotData(): array {} /** - * Cancel the current operation + * Returns the table name mapped in the model + * + * @return string */ - protected function _cancelOperation() {} + final public function getSource(): string {} /** - * Appends a customized message on the validation process + * Returns a list of updated values. * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Mvc\Model\Message as Message; + * ```php + * $robots = Robots::findFirst(); + * print_r($robots->getChangedFields()); // [] * - * class Robots extends Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); + * $robots->deleted = 'Y'; * - * $this->appendMessage($message); - * } - * } - * } - * + * $robots->getChangedFields(); + * print_r($robots->getChangedFields()); // ["deleted"] + * $robots->save(); + * print_r($robots->getChangedFields()); // [] + * print_r($robots->getUpdatedFields()); // ["deleted"] + * ``` * - * @param \Phalcon\Mvc\Model\MessageInterface $message - * @return Model + * @return array */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {} + public function getUpdatedFields(): array {} /** - * Executes validators on every validation call - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * + * Gets the connection used to write data to the model * - * @param \Phalcon\ValidationInterface $validator - * @return bool + * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function validate(\Phalcon\ValidationInterface $validator) {} + final public function getWriteConnection(): AdapterInterface {} /** - * Check whether validation process has generated any messages - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Model - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->validate( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * + * Returns the DependencyInjection connection service name used to write + * data related to the model * - * @return bool + * @return string */ - public function validationHasFailed() {} + final public function getWriteConnectionService(): string {} /** - * Returns array of validation messages + * Check if a specific attribute has changed + * This only works if the model is keeping data snapshots * - * + * ```php * $robot = new Robots(); * * $robot->type = "mechanical"; * $robot->name = "Astro Boy"; * $robot->year = 1952; * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); + * $robot->create(); * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * + * $robot->type = "hydraulic"; * - * @param mixed $filter - * @return \Phalcon\Mvc\Model\MessageInterface[] - */ - public function getMessages($filter = null) {} - - /** - * Reads "belongs to" relations and check the virtual foreign keys when inserting or updating records - * to verify that inserted/updated values are present in the related entity + * $hasChanged = $robot->hasChanged("type"); // returns true + * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true + * $hasChanged = $robot->hasChanged(["type", "name"], true); // returns false + * ``` * + * @param string|array $fieldName + * @param boolean $allFields * @return bool */ - protected final function _checkForeignKeysRestrict() {} + public function hasChanged($fieldName = null, bool $allFields = false): bool {} /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (cascade) when deleting records + * Checks if the object has internal snapshot data * * @return bool */ - protected final function _checkForeignKeysReverseCascade() {} + public function hasSnapshotData(): bool {} /** - * Reads both "hasMany" and "hasOne" relations and checks the virtual foreign keys (restrict) when deleting records + * Check if a specific attribute was updated + * This only works if the model is keeping data snapshots * + * @param string|array $fieldName + * @param bool $allFields * @return bool */ - protected final function _checkForeignKeysReverseRestrict() {} + public function hasUpdated($fieldName = null, bool $allFields = false): bool {} /** - * Executes internal hooks before save a record + * Serializes the object for json_encode * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param bool $exists - * @param mixed $identityField - * @return bool + * ```php + * echo json_encode($robot); + * ``` + * + * @return array */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, $exists, $identityField) {} + public function jsonSerialize(): array {} /** - * Executes internal events after save a record + * Returns the maximum value of a column for a result-set of rows that match + * the specified conditions * - * @param bool $success - * @param bool $exists - * @return bool + * ```php + * // What is the maximum robot id? + * $id = Robots::maximum( + * [ + * "column" => "id", + * ] + * ); + * + * echo "The maximum robot id is: ", $id, "\n"; + * + * // What is the maximum id of mechanical robots? + * $sum = Robots::maximum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); + * + * echo "The maximum robot id of mechanical robots is ", $id, "\n"; + * ``` + * + * @param array $parameters + * @return mixed */ - protected function _postSave($success, $exists) {} + public static function maximum($parameters = null) {} /** - * Sends a pre-build INSERT SQL statement to the relational database system + * Returns the minimum value of a column for a result-set of rows that match + * the specified conditions * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @param boolean|string $identityField - * @return bool + * ```php + * // What is the minimum robot id? + * $id = Robots::minimum( + * [ + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id is: ", $id; + * + * // What is the minimum id of mechanical robots? + * $sum = Robots::minimum( + * [ + * "type = 'mechanical'", + * "column" => "id", + * ] + * ); + * + * echo "The minimum robot id of mechanical robots is ", $id; + * ``` + * + * @param array $parameters + * @return mixed */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table, $identityField) {} + public static function minimum($parameters = null) {} /** - * Sends a pre-build UPDATE SQL statement to the relational database system + * Create a criteria for a specific model * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\AdapterInterface $connection - * @param string|array $table - * @return bool + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\AdapterInterface $connection, $table) {} + public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface {} /** - * Saves related records that must be stored prior to save the master record + * Reads an attribute value by its name * - * @param \Phalcon\Db\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related - * @return bool + * ```php + * echo $robot->readAttribute("name"); + * ``` + * + * @param string $attribute + * @return mixed|null */ - protected function _preSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} + public function readAttribute(string $attribute): ? {} /** - * Save the related records assigned in the has-one/has-many relations + * Refreshes the model attributes re-querying the record from the database * - * @param \Phalcon\Db\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related - * @return bool + * @return \Phalcon\Mvc\ModelInterface */ - protected function _postSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connection, $related) {} + public function refresh(): ModelInterface {} /** - * Inserts or updates a model instance. Returning true on success or false otherwise. + * Inserts or updates a model instance. Returning true on success or false + * otherwise. * - * + * ```php * // Creating a new robot * $robot = new Robots(); * @@ -979,648 +1061,697 @@ protected function _postSaveRelatedRecords(\Phalcon\Db\AdapterInterface $connect * $robot->name = "Biomass"; * * $robot->save(); - * + * ``` * - * @param array $data - * @param array $whiteList * @return bool */ - public function save($data = null, $whiteList = null) {} + public function save(): bool {} /** - * Inserts a model instance. If the instance already exists in the persistence it will throw an exception - * Returning true on success or false otherwise. - * - * - * // Creating a new robot - * $robot = new Robots(); + * Serializes the object ignoring connections, services, related objects or + * static properties * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * $robot->create(); - * - * // Passing an array to create - * $robot = new Robots(); - * - * $robot->create( - * [ - * "type" => "mechanical", - * "name" => "Astro Boy", - * "year" => 1952, - * ] - * ); - * - * - * @param mixed $data - * @param mixed $whiteList - * @return bool + * @return string */ - public function create($data = null, $whiteList = null) {} + public function serialize(): string {} /** - * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception - * Returning true on success or false otherwise. - * - * - * // Updating a robot name - * $robot = Robots::findFirst("id = 100"); - * - * $robot->name = "Biomass"; - * - * $robot->update(); - * + * Unserializes the object from a serialized string * * @param mixed $data - * @param mixed $whiteList - * @return bool */ - public function update($data = null, $whiteList = null) {} + public function unserialize($data) {} /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * - * $robot = Robots::findFirst("id=100"); - * - * $robot->delete(); - * - * $robots = Robots::find("type = 'mechanical'"); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * + * Sets the DependencyInjection connection service name * - * @return bool + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface */ - public function delete() {} + final public function setConnectionService(string $connectionService): ModelInterface {} /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * - * @return int + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getOperationMade() {} + public function setDirtyState(int $dirtyState) {} /** - * Refreshes the model attributes re-querying the record from the database + * Sets the dependency injection container * - * @return Model + * @param \Phalcon\Di\DiInterface $container */ - public function refresh() {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Skips the current operation forcing a success state + * Sets a custom events manager * - * @param bool $skip + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function skipOperation($skip) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Reads an attribute value by its name - * - * - * echo $robot->readAttribute("name"); - * + * Sets the DependencyInjection connection service name used to read data * - * @param string $attribute + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface */ - public function readAttribute($attribute) {} + final public function setReadConnectionService(string $connectionService): ModelInterface {} /** - * Writes an attribute value by its name + * Sets the record's old snapshot data. + * This method is used internally to set old snapshot data when the model + * was set up to keep snapshot data * - * - * $robot->writeAttribute("name", "Rosey"); - * + * @param array $data + * @param array $columnMap + */ + public function setOldSnapshotData(array $data, $columnMap = null) {} + + /** + * Sets the record's snapshot data. + * This method is used internally to set snapshot data when the model was + * set up to keep snapshot data * - * @param string $attribute - * @param mixed $value + * @param array $data + * @param array $columnMap */ - public function writeAttribute($attribute, $value) {} + public function setSnapshotData(array $data, $columnMap = null) {} /** - * Sets a list of attributes that must be skipped from the - * generated INSERT/UPDATE statement + * Sets a transaction related to the Model instance * - * + * ```php + * use Phalcon\Mvc\Model\Transaction\Manager as TxManager; + * use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributes( - * [ - * "price", - * ] - * ); + * try { + * $txManager = new TxManager(); + * + * $transaction = $txManager->get(); + * + * $robot = new Robots(); + * + * $robot->setTransaction($transaction); + * + * $robot->name = "WALL·E"; + * $robot->created_at = date("Y-m-d"); + * + * if ($robot->save() === false) { + * $transaction->rollback("Can't save robot"); * } - * } - * * - * @param array $attributes - */ - protected function skipAttributes(array $attributes) {} - - /** - * Sets a list of attributes that must be skipped from the - * generated INSERT statement + * $robotPart = new RobotParts(); * - * + * $robotPart->setTransaction($transaction); * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnCreate( - * [ - * "created_at", - * ] - * ); + * $robotPart->type = "head"; + * + * if ($robotPart->save() === false) { + * $transaction->rollback("Robot part cannot be saved"); * } + * + * $transaction->commit(); + * } catch (TxFailed $e) { + * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` * - * @param array $attributes + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return \Phalcon\Mvc\ModelInterface */ - protected function skipAttributesOnCreate(array $attributes) {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Enables/disables options in the ORM * - * + * @param array $options + */ + public static function setup(array $options) {} + + /** + * Sets the DependencyInjection connection service name used to write data * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->skipAttributesOnUpdate( - * [ - * "modified_in", - * ] - * ); - * } - * } - * + * @param string $connectionService + * @return \Phalcon\Mvc\ModelInterface + */ + final public function setWriteConnectionService(string $connectionService): ModelInterface {} + + /** + * Skips the current operation forcing a success state * - * @param array $attributes + * @param bool $skip */ - protected function skipAttributesOnUpdate(array $attributes) {} + public function skipOperation(bool $skip) {} /** - * Sets a list of attributes that must be skipped from the - * generated UPDATE statement + * Calculates the sum on a column for a result-set of rows that match the + * specified conditions * - * + * ```php + * // How much are all robots? + * $sum = Robots::sum( + * [ + * "column" => "price", + * ] + * ); * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->allowEmptyStringValues( - * [ - * "name", - * ] - * ); - * } - * } - * + * echo "The total price of robots is ", $sum, "\n"; * - * @param array $attributes + * // How much are mechanical robots? + * $sum = Robots::sum( + * [ + * "type = 'mechanical'", + * "column" => "price", + * ] + * ); + * + * echo "The total price of mechanical robots is ", $sum, "\n"; + * ``` + * + * @param array $parameters + * @return double */ - protected function allowEmptyStringValues(array $attributes) {} + public static function sum($parameters = null): float {} /** - * Setup a 1-1 relation between two models - * - * + * Returns the instance as an array representation * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasOne("id", "RobotsDescription", "robots_id"); - * } - * } - * + * ```php + * print_r( + * $robot->toArray() + * ); + * ``` * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $columns + * @return array */ - protected function hasOne($fields, $referenceModel, $referencedFields, $options = null) {} + public function toArray($columns = null): array {} /** - * Setup a reverse 1-1 or n-1 relation between two models + * Updates a model instance. If the instance doesn't exist in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. * - * + * ```php + * // Updating a robot name + * $robot = Robots::findFirst("id = 100"); * - * class RobotsParts extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->belongsTo("robots_id", "Robots", "id"); - * } - * } - * + * $robot->name = "Biomass"; * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * $robot->update(); + * ``` + * + * @return bool */ - protected function belongsTo($fields, $referenceModel, $referencedFields, $options = null) {} + public function update(): bool {} /** - * Setup a 1-n relation between two models - * - * + * Writes an attribute value by its name * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * $this->hasMany("id", "RobotsParts", "robots_id"); - * } - * } - * + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` * - * @param mixed $fields - * @param string $referenceModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param string $attribute + * @param mixed $value */ - protected function hasMany($fields, $referenceModel, $referencedFields, $options = null) {} + public function writeAttribute(string $attribute, $value) {} /** - * Setup an n-n relation between two models, through an intermediate relation + * Reads "belongs to" relations and check the virtual foreign keys when + * inserting or updating records to verify that inserted/updated values are + * present in the related entity * - * - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function initialize() - * { - * // Setup a many-to-many relation to Parts through RobotsParts - * $this->hasManyToMany( - * "id", - * "RobotsParts", - * "robots_id", - * "parts_id", - * "Parts", - * "id", - * ); - * } - * } - * - * - * @param string|array fields - * @param string intermediateModel - * @param string|array intermediateFields - * @param string|array intermediateReferencedFields - * @param string referencedModel - * @param mixed $fields - * @param string $intermediateModel - * @param mixed $intermediateFields - * @param mixed $intermediateReferencedFields - * @param string $referenceModel - * @param string|array $referencedFields - * @param array $options - * @return \Phalcon\Mvc\Model\Relation + * @return bool */ - protected function hasManyToMany($fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referenceModel, $referencedFields, $options = null) {} + final protected function _checkForeignKeysRestrict(): bool {} /** - * Setups a behavior in a model + * Reads both "hasMany" and "hasOne" relations and checks the virtual + * foreign keys (cascade) when deleting records * - * - * - * use Phalcon\Mvc\Model; - * use Phalcon\Mvc\Model\Behavior\Timestampable; - * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->addBehavior( - * new Timestampable( - * [ - * "onCreate" => [ - * "field" => "created_at", - * "format" => "Y-m-d", - * ], - * ] - * ) - * ); - * } - * } - * - * - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @return bool */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} + final protected function _checkForeignKeysReverseCascade(): bool {} /** - * Sets if the model must keep the original record snapshot in memory - * - * - * - * use Phalcon\Mvc\Model; - * - * class Robots extends Model - * { - * public function initialize() - * { - * $this->keepSnapshots(true); - * } - * } - * + * Reads both "hasMany" and "hasOne" relations and checks the virtual + * foreign keys (restrict) when deleting records * - * @param bool $keepSnapshot + * @return bool */ - protected function keepSnapshots($keepSnapshot) {} + final protected function _checkForeignKeysReverseRestrict(): bool {} /** - * Sets the record's snapshot data. - * This method is used internally to set snapshot data when the model was set up to keep snapshot data + * Sends a pre-build INSERT SQL statement to the relational database system * - * @param array $data - * @param array $columnMap + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param string|array $table + * @param bool|string $identityField + * @return bool */ - public function setSnapshotData(array $data, $columnMap = null) {} + protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool {} /** - * Sets the record's old snapshot data. - * This method is used internally to set old snapshot data when the model was set up to keep snapshot data + * Sends a pre-build UPDATE SQL statement to the relational database system * - * @param array $data - * @param array $columnMap + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param string|array $table + * @return bool */ - public function setOldSnapshotData(array $data, $columnMap = null) {} + protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool {} /** - * Checks if the object has internal snapshot data + * Checks whether the current record already exists * + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @return bool */ - public function hasSnapshotData() {} + protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool {} /** - * Returns the internal snapshot data + * Returns related records defined relations depending on the method name * - * @return array + * @param string $modelName + * @param string $method + * @param array $arguments + * @return mixed */ - public function getSnapshotData() {} + protected function _getRelatedRecords(string $modelName, string $method, $arguments) {} /** - * Returns the internal old snapshot data + * Generate a PHQL SELECT statement for an aggregate * - * @return array + * @param string $functionName + * @param string $alias + * @param array $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getOldSnapshotData() {} + protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface {} /** - * Check if a specific attribute has changed - * This only works if the model is keeping data snapshots - * - * - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; + * Try to check if the query must invoke a finder * - * $robot->create(); - * $robot->type = "hydraulic"; - * $hasChanged = $robot->hasChanged("type"); // returns true - * $hasChanged = $robot->hasChanged(["type", "name"]); // returns true - * $hasChanged = $robot->hasChanged(["type", "name", true]); // returns false - * + * @param string $method + * @param array $arguments + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool + */ + protected final static function _invokeFinder(string $method, array $arguments) {} + + /** + * Check for, and attempt to use, possible setter. * - * @param string|array $fieldName - * @param boolean $allFields + * @param string $property + * @param mixed $value * @return bool */ - public function hasChanged($fieldName = null, $allFields = false) {} + final protected function _possibleSetter(string $property, $value): bool {} /** - * Check if a specific attribute was updated - * This only works if the model is keeping data snapshots + * Executes internal hooks before save a record * - * @param string|array $fieldName - * @param bool $allFields + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param bool $exists + * @param mixed $identityField * @return bool */ - public function hasUpdated($fieldName = null, $allFields = false) {} + protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool {} /** - * Returns a list of changed values. - * - * - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] - * - * $robots->deleted = 'Y'; - * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * + * Saves related records that must be stored prior to save the master record * - * @return array + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool */ - public function getChangedFields() {} + protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} /** - * Returns a list of updated values. - * - * - * $robots = Robots::findFirst(); - * print_r($robots->getChangedFields()); // [] - * - * $robots->deleted = 'Y'; + * Executes internal events after save a record * - * $robots->getChangedFields(); - * print_r($robots->getChangedFields()); // ["deleted"] - * $robots->save(); - * print_r($robots->getChangedFields()); // [] - * print_r($robots->getUpdatedFields()); // ["deleted"] - * + * @param bool $success + * @param bool $exists + * @return bool */ - public function getUpdatedFields() {} + protected function _postSave(bool $success, bool $exists): bool {} /** - * Sets if a model must use dynamic update instead of the all-field update - * - * + * Save the related records assigned in the has-one/has-many relations * - * use Phalcon\Mvc\Model; + * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param \Phalcon\Mvc\ModelInterface[] $related + * @return bool + */ + protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + + /** + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * class Robots extends Model + * ```php + * class Robots extends \Phalcon\Mvc\Model * { * public function initialize() * { - * $this->useDynamicUpdate(true); + * $this->allowEmptyStringValues( + * [ + * "name", + * ] + * ); * } * } - * + * ``` * - * @param bool $dynamicUpdate + * @param array $attributes */ - protected function useDynamicUpdate($dynamicUpdate) {} + protected function allowEmptyStringValues(array $attributes) {} /** - * Returns related records based on defined relations - * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\ResultsetInterface + * Cancel the current operation */ - public function getRelated($alias, $arguments = null) {} + protected function _cancelOperation() {} /** - * Returns related records defined relations depending on the method name + * Setup a reverse 1-1 or n-1 relation between two models * - * @param string $modelName - * @param string $method - * @param array $arguments - * @return mixed + * ```php + * class RobotsParts extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->belongsTo( + * "robots_id", + * Robots::class, + * "id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - protected function _getRelatedRecords($modelName, $method, $arguments) {} + protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Try to check if the query must invoke a finder + * shared prepare query logic for find and findFirst method * - * @param string $method - * @param array $arguments - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|boolean + * @param mixed $params + * @param mixed $limit + * @return \Phalcon\Mvc\Model\Query */ - protected final static function _invokeFinder($method, $arguments) {} + private static function getPreparedQuery($params, $limit = null): Query {} /** - * Handles method calls when a method is not implemented + * Setup a 1-n relation between two models * - * @param string method - * @param array arguments - * @return mixed - * @param string $method - * @param mixed $arguments + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasMany( + * "id", + * RobotsParts::class, + * "robots_id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function __call($method, $arguments) {} + protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Handles method calls when a static method is not implemented + * Setup an n-n relation between two models, through an intermediate + * relation * - * @param string method - * @param array arguments - * @return mixed - * @param string $method - * @param mixed $arguments + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * // Setup a many-to-many relation to Parts through RobotsParts + * $this->hasManyToMany( + * "id", + * RobotsParts::class, + * "robots_id", + * "parts_id", + * Parts::class, + * "id", + * ); + * } + * } + * ``` + * + * @param string|array $fields + * @param string $intermediateModel + * @param string|array $intermediateFields + * @param string|array $intermediateReferencedFields + * @param string $referenceModel + * @param string|array $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\Relation */ - public static function __callStatic($method, $arguments) {} + protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Magic method to assign values to the the model + * Setup a 1-1 relation between two models * - * @param string $property - * @param mixed $value + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->hasOne( + * "id", + * RobotsDescription::class, + * "robots_id" + * ); + * } + * } + * ``` + * + * @param mixed $fields + * @param string $referenceModel + * @param mixed $referencedFields + * @param mixed $options + * @return \Phalcon\Mvc\Model\Relation */ - public function __set($property, $value) {} + protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation {} /** - * Check for, and attempt to use, possible setter. + * Sets if the model must keep the original record snapshot in memory * - * @param string $property - * @param mixed $value - * @return string + * ```php + * use Phalcon\Mvc\Model; + * + * class Robots extends Model + * { + * public function initialize() + * { + * $this->keepSnapshots(true); + * } + * } + * ``` + * + * @param bool $keepSnapshot */ - protected final function _possibleSetter($property, $value) {} + protected function keepSnapshots(bool $keepSnapshot) {} /** - * Magic method to get related records using the relation alias as a property + * Sets schema name where the mapped table is located * - * @param string $property - * @return \Phalcon\Mvc\Model\Resultset|Phalcon\Mvc\Model + * @param string $schema + * @return \Phalcon\Mvc\ModelInterface */ - public function __get($property) {} + final protected function setSchema(string $schema): ModelInterface {} /** - * Magic method to check if a property is a valid relation + * Sets the table name to which model should be mapped * - * @param string $property - * @return bool + * @param string $source + * @return \Phalcon\Mvc\ModelInterface */ - public function __isset($property) {} + final protected function setSource(string $source): ModelInterface {} /** - * Serializes the object ignoring connections, services, related objects or static properties + * Sets a list of attributes that must be skipped from the + * generated INSERT/UPDATE statement * - * @return string + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributes( + * [ + * "price", + * ] + * ); + * } + * } + * ``` + * + * @param array $attributes */ - public function serialize() {} + protected function skipAttributes(array $attributes) {} /** - * Unserializes the object from a serialized string + * Sets a list of attributes that must be skipped from the + * generated INSERT statement * - * @param mixed $data + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnCreate( + * [ + * "created_at", + * ] + * ); + * } + * } + * ``` + * + * @param array $attributes */ - public function unserialize($data) {} + protected function skipAttributesOnCreate(array $attributes) {} /** - * Returns a simple representation of the object that can be used with var_dump + * Sets a list of attributes that must be skipped from the + * generated UPDATE statement * - * - * var_dump( - * $robot->dump() - * ); - * + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * $this->skipAttributesOnUpdate( + * [ + * "modified_in", + * ] + * ); + * } + * } + * ``` * - * @return array + * @param array $attributes */ - public function dump() {} + protected function skipAttributesOnUpdate(array $attributes) {} /** - * Returns the instance as an array representation + * Sets if a model must use dynamic update instead of the all-field update * - * - * print_r( - * $robot->toArray() - * ); - * + * ```php + * use Phalcon\Mvc\Model; * - * @param array $columns - * @return array + * class Robots extends Model + * { + * public function initialize() + * { + * $this->useDynamicUpdate(true); + * } + * } + * ``` + * + * @param bool $dynamicUpdate */ - public function toArray($columns = null) {} + protected function useDynamicUpdate(bool $dynamicUpdate) {} /** - * Serializes the object for json_encode + * Executes validators on every validation call * - * - * echo json_encode($robot); - * + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; * - * @return array + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->add( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * ``` + * + * @param \Phalcon\Validation\ValidationInterface $validator + * @return bool */ - public function jsonSerialize() {} + protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} /** - * Enables/disables options in the ORM + * Check whether validation process has generated any messages * - * @param array $options + * ```php + * use Phalcon\Mvc\Model; + * use Phalcon\Validation; + * use Phalcon\Validation\Validator\ExclusionIn; + * + * class Subscriptors extends Model + * { + * public function validation() + * { + * $validator = new Validation(); + * + * $validator->validate( + * "status", + * new ExclusionIn( + * [ + * "domain" => [ + * "A", + * "I", + * ], + * ] + * ) + * ); + * + * return $this->validate($validator); + * } + * } + * ``` + * + * @return bool */ - public static function setup(array $options) {} + public function validationHasFailed(): bool {} /** - * Reset a model instance data + * Attempts to find key case-insensitively + * + * @param mixed $columnMap + * @param mixed $key + * @return string */ - public function reset() {} + private static function caseInsensitiveColumnMap($columnMap, $key): string {} } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index 5ded0692..b65f6f6d 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -11,313 +11,321 @@ interface ModelInterface { /** - * Sets a transaction related to the Model instance + * Appends a customized message on the validation process * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param \Phalcon\Messages\MessageInterface $message * @return \Phalcon\Mvc\ModelInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface; /** - * Returns table name mapped in the model + * Assigns values to a model from an array * - * @return string + * @param array $data + * @param mixed $dataColumnMap + * @param mixed $whiteList + * @param array $columnMap + * @return \Phalcon\Mvc\ModelInterface */ - public function getSource(); + public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface; /** - * Returns schema name where table mapped is located + * Allows to calculate the average value on a column matching the specified + * conditions * - * @return string + * @param array $parameters + * @return double */ - public function getSchema(); + public static function average($parameters = null): float; /** - * Sets both read/write connection services + * Assigns values to a model from an array returning a new model * - * @param string $connectionService + * @param \Phalcon\Mvc\ModelInterface $base + * @param array $data + * @param int $dirtyState + * @return \Phalcon\Mvc\ModelInterface */ - public function setConnectionService($connectionService); + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface; /** - * Sets the DependencyInjection connection service used to write data + * Assigns values to a model from an array returning a new model * - * @param string $connectionService + * @param \Phalcon\Mvc\Model $base + * @param array $data + * @param array $columnMap + * @param int $dirtyState + * @param bool $keepSnapshots + * @return \Phalcon\Mvc\ModelInterface */ - public function setWriteConnectionService($connectionService); + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; /** - * Sets the DependencyInjection connection service used to read data + * Returns an hydrated result based on the data and the column map * - * @param string $connectionService + * @param array $data + * @param array $columnMap + * @param int $hydrationMode */ - public function setReadConnectionService($connectionService); + public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode); /** - * Returns DependencyInjection connection service used to read data + * Allows to count how many records match the specified conditions * - * @return string + * @param array $parameters + * @return int */ - public function getReadConnectionService(); + public static function count($parameters = null): int; /** - * Returns DependencyInjection connection service used to write data + * Inserts a model instance. If the instance already exists in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. * - * @return string + * @return bool */ - public function getWriteConnectionService(); + public function create(): bool; /** - * Gets internal database connection + * Deletes a model instance. Returning true on success or false otherwise. * - * @return \Phalcon\Db\AdapterInterface + * @return bool */ - public function getReadConnection(); + public function delete(): bool; /** - * Gets internal database connection + * Allows to query a set of records that match the specified conditions * - * @return \Phalcon\Db\AdapterInterface + * @param mixed $parameters + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function getWriteConnection(); + public static function find($parameters = null): ResultsetInterface; /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ constants + * Allows to query the first record that match the specified conditions * - * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @param array $parameters + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState($dirtyState); + public static function findFirst($parameters = null); /** - * Returns one of the DIRTY_STATE_ constants telling if the record exists in the database or not + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified * - * @return int + * @param string $eventName + * @return bool */ - public function getDirtyState(); + public function fireEvent(string $eventName): bool; /** - * Assigns values to a model from an array + * Fires an event, implicitly calls behaviors and listeners in the events + * manager are notified. This method stops if one of the callbacks/listeners + * returns bool false * - * @param array $data - * @param mixed $dataColumnMap - * @param mixed $whiteList - * @param \Phalcon\Mvc\Model $object - * @param array $columnMap - * @return \Phalcon\Mvc\Model + * @param string $eventName + * @return bool */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null); + public function fireEventCancel(string $eventName): bool; /** - * Assigns values to a model from an array returning a new model + * Returns one of the DIRTY_STATE_ constants telling if the record exists + * in the database or not * - * @param \Phalcon\Mvc\Model $base - * @param array $data - * @param array $columnMap - * @param int $dirtyState - * @param boolean $keepSnapshots - * @return \Phalcon\Mvc\Model + * @return int */ - public static function cloneResultMap($base, array $data, $columnMap, $dirtyState = 0, $keepSnapshots = null); + public function getDirtyState(): int; /** - * Assigns values to a model from an array returning a new model + * Returns array of validation messages * - * @param \Phalcon\Mvc\ModelInterface $base - * @param array $data - * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, $dirtyState = 0); + public function getMessages(): array; /** - * Returns an hydrated result based on the data and the column map + * Returns the models meta-data service related to the entity instance. * - * @param array $data - * @param array $columnMap - * @param int $hydrationMode + * @return \Phalcon\Mvc\Model\MetaDataInterface */ - public static function cloneResultMapHydrate(array $data, $columnMap, $hydrationMode); + public function getModelsMetaData(): MetaDataInterface; /** - * Allows to query a set of records that match the specified conditions + * Returns the type of the latest operation performed by the ORM + * Returns one of the OP_ class constants * - * @param mixed $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return int */ - public static function find($parameters = null); + public function getOperationMade(): int; /** - * Allows to query the first record that match the specified conditions + * Gets internal database connection * - * @param array $parameters - * @return static + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public static function findFirst($parameters = null); + public function getReadConnection(): AdapterInterface; /** - * Create a criteria for a specific model + * Returns DependencyInjection connection service used to read data * - * @param \Phalcon\DiInterface $dependencyInjector - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return string */ - public static function query(\Phalcon\DiInterface $dependencyInjector = null); + public function getReadConnectionService(): string; /** - * Allows to count how many records match the specified conditions + * Returns related records based on defined relations * - * @param array $parameters - * @return int + * @param string $alias + * @param array $arguments + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ - public static function count($parameters = null); + public function getRelated(string $alias, $arguments = null); /** - * Allows to calculate a sum on a column that match the specified conditions + * Returns schema name where table mapped is located * - * @param array $parameters - * @return double + * @return string */ - public static function sum($parameters = null); + public function getSchema(): string; /** - * Allows to get the maximum value of a column that match the specified conditions + * Returns table name mapped in the model * - * @param array $parameters - * @return mixed + * @return string */ - public static function maximum($parameters = null); + public function getSource(): string; /** - * Allows to get the minimum value of a column that match the specified conditions + * Gets internal database connection * - * @param array $parameters - * @return mixed + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public static function minimum($parameters = null); + public function getWriteConnection(): AdapterInterface; /** - * Allows to calculate the average value on a column matching the specified conditions + * Returns DependencyInjection connection service used to write data * - * @param array $parameters - * @return double + * @return string */ - public static function average($parameters = null); + public function getWriteConnectionService(): string; /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified + * Allows to get the maximum value of a column that match the specified + * conditions * - * @param string $eventName - * @return boolean + * @param array $parameters + * @return mixed */ - public function fireEvent($eventName); + public static function maximum($parameters = null); /** - * Fires an event, implicitly calls behaviors and listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns boolean false + * Allows to get the minimum value of a column that match the specified + * conditions * - * @param string $eventName - * @return boolean + * @param array $parameters + * @return mixed */ - public function fireEventCancel($eventName); + public static function minimum($parameters = null); /** - * Appends a customized message on the validation process + * Create a criteria for a specific model * - * @param \Phalcon\Mvc\Model\MessageInterface $message + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message); + public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface; /** - * Check whether validation process has generated any messages + * Refreshes the model attributes re-querying the record from the database * - * @return boolean + * @return \Phalcon\Mvc\ModelInterface */ - public function validationHasFailed(); + public function refresh(): ModelInterface; /** - * Returns array of validation messages + * Inserts or updates a model instance. Returning true on success or false + * otherwise. * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return bool */ - public function getMessages(); + public function save(): bool; /** - * Inserts or updates a model instance. Returning true on success or false otherwise. + * Sets both read/write connection services * - * @param array $data - * @param array $whiteList - * @return boolean + * @param string $connectionService */ - public function save($data = null, $whiteList = null); + public function setConnectionService(string $connectionService); /** - * Inserts a model instance. If the instance already exists in the persistence it will throw an exception - * Returning true on success or false otherwise. + * Sets the dirty state of the object using one of the DIRTY_STATE_ + * constants * - * @param array $data - * @param array $whiteList - * @return boolean + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function create($data = null, $whiteList = null); + public function setDirtyState(int $dirtyState); /** - * Updates a model instance. If the instance doesn't exist in the persistence it will throw an exception - * Returning true on success or false otherwise. + * Sets the DependencyInjection connection service used to read data * - * @param array $data - * @param array $whiteList - * @return boolean + * @param string $connectionService */ - public function update($data = null, $whiteList = null); + public function setReadConnectionService(string $connectionService); /** - * Deletes a model instance. Returning true on success or false otherwise. + * Sets the record's snapshot data. This method is used internally to set + * snapshot data when the model was set up to keep snapshot data * - * @return boolean + * @param array $data + * @param array $columnMap */ - public function delete(); + public function setSnapshotData(array $data, $columnMap = null); /** - * Returns the type of the latest operation performed by the ORM - * Returns one of the OP_ class constants + * Sets a transaction related to the Model instance * - * @return int + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return \Phalcon\Mvc\ModelInterface */ - public function getOperationMade(); + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface; /** - * Refreshes the model attributes re-querying the record from the database + * Sets the DependencyInjection connection service used to write data + * + * @param string $connectionService */ - public function refresh(); + public function setWriteConnectionService(string $connectionService); /** * Skips the current operation forcing a success state * * @param bool $skip */ - public function skipOperation($skip); + public function skipOperation(bool $skip); /** - * Returns related records based on defined relations + * Allows to calculate a sum on a column that match the specified conditions * - * @param string $alias - * @param array $arguments - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param array $parameters + * @return double */ - public function getRelated($alias, $arguments = null); + public static function sum($parameters = null): float; /** - * Sets the record's snapshot data. - * This method is used internally to set snapshot data when the model was set up to keep snapshot data + * Check whether validation process has generated any messages * - * @param array $data - * @param array $columnMap + * @return bool */ - public function setSnapshotData(array $data, $columnMap = null); + public function validationHasFailed(): bool; /** - * Reset a model instance data + * Updates a model instance. If the instance doesn't exist in the + * persistence it will throw an exception. Returning true on success or + * false otherwise. + * + * @return bool */ - public function reset(); + public function update(): bool; } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index a1336e4e..fe59a300 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -13,15 +13,15 @@ interface ModuleDefinitionInterface /** * Registers an autoloader related to the module * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function registerAutoloaders(\Phalcon\DiInterface $dependencyInjector = null); + public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); /** * Registers services related to the module * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function registerServices(\Phalcon\DiInterface $dependencyInjector); + public function registerServices(\Phalcon\Di\DiInterface $container); } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index 69a4e1af..852feabd 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -6,11 +6,11 @@ * Phalcon\Mvc\Router * * Phalcon\Mvc\Router is the standard framework router. Routing is the - * process of taking a URI endpoint (that part of the URI which comes after the base URL) and - * decomposing it into parameters to determine which module, controller, and - * action of that controller should receive the request + * process of taking a URI endpoint (that part of the URI which comes after the + * base URL) and decomposing it into parameters to determine which module, + * controller, and action of that controller should receive the request * - * + * ```php * use Phalcon\Mvc\Router; * * $router = new Router(); @@ -23,87 +23,83 @@ * ] * ); * - * $router->handle(); + * $router->handle( + * "/documentation/1/examples.html" + * ); * * echo $router->getControllerName(); - * + * ``` */ class Router implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { - const URI_SOURCE_GET_URL = 0; - - - const URI_SOURCE_SERVER_REQUEST_URI = 1; - - const POSITION_FIRST = 0; const POSITION_LAST = 1; - protected $_dependencyInjector; + protected $action = null; - protected $_eventsManager; + protected $container; - protected $_uriSource; + protected $controller = null; - protected $_namespace = null; + protected $defaultAction; - protected $_module = null; + protected $defaultController; - protected $_controller = null; + protected $defaultModule; - protected $_action = null; + protected $defaultNamespace; - protected $_params = array(); + protected $defaultParams = array(); - protected $_routes; + protected $eventsManager; - protected $_matchedRoute; + protected $keyRouteNames = array(); - protected $_matches; + protected $keyRouteIds = array(); - protected $_wasMatched = false; + protected $matchedRoute; - protected $_defaultNamespace; + protected $matches; - protected $_defaultModule; + protected $module = null; - protected $_defaultController; + protected $namespaceName = null; - protected $_defaultAction; + protected $notFoundPaths; - protected $_defaultParams = array(); + protected $params = array(); - protected $_removeExtraSlashes; + protected $removeExtraSlashes; - protected $_notFoundPaths; + protected $routes; - protected $_keyRouteNames = array(); + protected $uriSource; - protected $_keyRouteIds = array(); + protected $wasMatched = false; @@ -127,141 +123,143 @@ public function setKeyRouteIds($keyRouteIds) {} * * @param bool $defaultRoutes */ - public function __construct($defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) {} /** - * Sets the dependency injector + * Adds a route to the router without any HTTP constraint * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector + * ```php + * use Phalcon\Mvc\Router; * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Sets the events manager + * $router->add("/about", "About::index"); * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Returns the internal event manager + * $router->add( + * "/about", + * "About::index", + * ["GET", "POST"] + * ); * - * @return \Phalcon\Events\ManagerInterface + * $router->add( + * "/about", + * "About::index", + * ["GET", "POST"], + * Router::POSITION_FIRST + * ); + * ``` + * + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getEventsManager() {} + public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Get rewrite info. This info is read from $_GET["_url"]. This returns '/' if the rewrite information cannot be read + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRewriteUri() {} + public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the URI source. One of the URI_SOURCE_ constants - * - * - * $router->setUriSource( - * Router::URI_SOURCE_SERVER_REQUEST_URI - * ); - * + * Adds a route to the router that only match if the HTTP method is DELETE * - * @param mixed $uriSource - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setUriSource($uriSource) {} + public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Set whether router must remove the extra slashes in the handled routes + * Adds a route to the router that only match if the HTTP method is GET * - * @param bool $remove - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function removeExtraSlashes($remove) {} + public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the name of the default namespace + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param string $namespaceName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultNamespace($namespaceName) {} + public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the name of the default module + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string $moduleName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultModule($moduleName) {} + public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the default controller name + * Adds a route to the router that only match if the HTTP method is PATCH * - * @param string $controllerName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultController($controllerName) {} + public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets the default action name + * Adds a route to the router that only match if the HTTP method is POST * - * @param string $actionName - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultAction($actionName) {} + public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Sets an array of default paths. If a route is missing a path the router will use the defined here - * This method must not be used to set a 404 route + * Adds a route to the router that only match if the HTTP method is PURGE + * (Squid and Varnish support) * - * - * $router->setDefaults( - * [ - * "module" => "common", - * "action" => "index", - * ] - * ); - * - * - * @param array $defaults - * @return RouterInterface + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaults(array $defaults) {} + public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Returns an array of default parameters + * Adds a route to the router that only match if the HTTP method is PUT * - * @return array + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getDefaults() {} + public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** - * Handles routing information received from the rewrite engine - * - * - * // Read the info from the rewrite engine - * $router->handle(); - * - * // Manually passing an URL - * $router->handle("/posts/edit/1"); - * + * Adds a route to the router that only match if the HTTP method is TRACE * - * @param string $uri + * @param string $pattern + * @param mixed $paths + * @param mixed $position + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function handle($uri = null) {} + public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} /** * Attach Route object to the routes stack. * - * + * ```php * use Phalcon\Mvc\Router; * use Phalcon\Mvc\Router\Route; * @@ -275,239 +273,226 @@ public function handle($uri = null) {} * new CustomRoute("/about", "About::index", ["GET", "HEAD"]), * Router::POSITION_FIRST * ); - * + * ``` * - * @todo Add to the interface for 4.0.0 * @param \Phalcon\Mvc\Router\RouteInterface $route * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST) {} + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface {} /** - * Adds a route to the router without any HTTP constraint - * - * - * use Phalcon\Mvc\Router; - * - * $router->add("/about", "About::index"); - * $router->add("/about", "About::index", ["GET", "POST"]); - * $router->add("/about", "About::index", ["GET", "POST"], Router::POSITION_FIRST); - * + * Removes all the pre-defined routes + */ + public function clear() {} + + /** + * Returns the internal dependency injector * - * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Di\DiInterface */ - public function add($pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST) {} + public function getDI(): DiInterface {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Returns the internal event manager * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return \Phalcon\Events\ManagerInterface */ - public function addGet($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getEventsManager(): ManagerInterface {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Returns the processed action name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addPost($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getActionName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Returns the processed controller name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addPut($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getControllerName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Returns the route that matches the handled URI * - * @param string $pattern - * @param mixed $paths - * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getMatchedRoute(): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the sub expressions in the regular expression matched * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array */ - public function addDelete($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getMatches(): array {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the processed module name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addOptions($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getModuleName(): string {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the processed namespace name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addHead($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getNamespaceName(): string {} /** - * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) + * Returns the processed parameters * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array */ - public function addPurge($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getParams(): array {} /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Returns a route object by its id * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function addTrace($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getRouteById($id) {} /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns a route object by its name * - * @param string $pattern - * @param mixed $paths - * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function addConnect($pattern, $paths = null, $position = Router::POSITION_LAST) {} + public function getRouteByName(string $name) {} /** - * Mounts a group of routes in the router + * Returns all the routes defined in the router * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group) {} + public function getRoutes(): array {} /** - * Set a group of paths to be returned when none of the defined routes are matched + * Handles routing information received from the rewrite engine * - * @param mixed $paths - * @return RouterInterface + * ```php + * // Passing a URL + * $router->handle("/posts/edit/1"); + * ``` + * + * @param string $uri */ - public function notFound($paths) {} + public function handle(string $uri) {} /** - * Removes all the pre-defined routes + * Returns whether controller name should not be mangled + * + * @return bool */ - public function clear() {} + public function isExactControllerName(): bool {} /** - * Returns the processed namespace name + * Mounts a group of routes in the router * - * @return string + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function getNamespaceName() {} + public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface {} /** - * Returns the processed module name + * Set a group of paths to be returned when none of the defined routes are + * matched * - * @return string + * @param mixed $paths + * @return RouterInterface */ - public function getModuleName() {} + public function notFound($paths): RouterInterface {} /** - * Returns the processed controller name + * Set whether router must remove the extra slashes in the handled routes * - * @return string + * @param bool $remove + * @return RouterInterface */ - public function getControllerName() {} + public function removeExtraSlashes(bool $remove): RouterInterface {} /** - * Returns the processed action name + * Sets the default action name * - * @return string + * @param string $actionName + * @return RouterInterface */ - public function getActionName() {} + public function setDefaultAction(string $actionName): RouterInterface {} /** - * Returns the processed parameters + * Sets the default controller name * - * @return array + * @param string $controllerName + * @return RouterInterface */ - public function getParams() {} + public function setDefaultController(string $controllerName): RouterInterface {} /** - * Returns the route that matches the handled URI + * Sets the name of the default module * - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName + * @return RouterInterface */ - public function getMatchedRoute() {} + public function setDefaultModule(string $moduleName): RouterInterface {} /** - * Returns the sub expressions in the regular expression matched + * Sets the name of the default namespace * - * @return array + * @param string $namespaceName + * @return RouterInterface */ - public function getMatches() {} + public function setDefaultNamespace(string $namespaceName): RouterInterface {} /** - * Checks if the router matches any of the defined routes + * Sets an array of default paths. If a route is missing a path the router + * will use the defined here. This method must not be used to set a 404 + * route * - * @return bool + * ```php + * $router->setDefaults( + * [ + * "module" => "common", + * "action" => "index", + * ] + * ); + * ``` + * + * @param array $defaults + * @return RouterInterface */ - public function wasMatched() {} + public function setDefaults(array $defaults): RouterInterface {} /** - * Returns all the routes defined in the router + * Returns an array of default parameters * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @return array */ - public function getRoutes() {} + public function getDefaults(): array {} /** - * Returns a route object by its id + * Sets the dependency injector * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Di\DiInterface $container */ - public function getRouteById($id) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns a route object by its name + * Sets the events manager * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function getRouteByName($name) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns whether controller name should not be mangled + * Checks if the router matches any of the defined routes * * @return bool */ - public function isExactControllerName() {} + public function wasMatched(): bool {} } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index 6f7adef2..f78d3286 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -3,84 +3,74 @@ namespace Phalcon\Mvc; /** - * Phalcon\Mvc\RouterInterface - * * Interface for Phalcon\Mvc\Router */ interface RouterInterface { /** - * Sets the name of the default module - * - * @param string $moduleName - */ - public function setDefaultModule($moduleName); - - /** - * Sets the default controller name - * - * @param string $controllerName - */ - public function setDefaultController($controllerName); - - /** - * Sets the default action name + * Adds a route to the router on any HTTP method * - * @param string $actionName + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setDefaultAction($actionName); + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; /** - * Sets an array of default paths + * Attach Route object to the routes stack. * - * @param array $defaults + * @param \Phalcon\Mvc\Router\RouteInterface $route + * @param mixed $position + * @return RouterInterface */ - public function setDefaults(array $defaults); + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; /** - * Handles routing information received from the rewrite engine + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $uri + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function handle($uri = null); + public function addConnect(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router on any HTTP method + * Adds a route to the router that only match if the HTTP method is DELETE * * @param string $pattern * @param mixed $paths - * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null); + public function addDelete(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is HEAD * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet($pattern, $paths = null); + public function addHead(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is POST + * Adds a route to the router that only match if the HTTP method is GET * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost($pattern, $paths = null); + public function addGet(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PUT + * Add a route to the router that only match if the HTTP method is OPTIONS * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPut($pattern, $paths = null); + public function addOptions(string $pattern, $paths = null): RouteInterface; /** * Adds a route to the router that only match if the HTTP method is PATCH @@ -89,152 +79,170 @@ public function addPut($pattern, $paths = null); * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch($pattern, $paths = null); + public function addPatch(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Adds a route to the router that only match if the HTTP method is POST * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addDelete($pattern, $paths = null); + public function addPost(string $pattern, $paths = null): RouteInterface; /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Adds a route to the router that only match if the HTTP method is PURGE + * (Squid and Varnish support) * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addOptions($pattern, $paths = null); + public function addPurge(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addHead($pattern, $paths = null); + public function addPut(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support) + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPurge($pattern, $paths = null); + public function addTrace(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is TRACE + * Removes all the defined routes + */ + public function clear(); + + /** + * Returns processed action name * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addTrace($pattern, $paths = null); + public function getActionName(): string; /** - * Adds a route to the router that only match if the HTTP method is CONNECT + * Returns processed controller name * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addConnect($pattern, $paths = null); + public function getControllerName(): string; /** - * Mounts a group of routes in the router + * Returns the route that matches the handled URI * - * @param \Phalcon\Mvc\Router\GroupInterface $group - * @return RouterInterface + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group); + public function getMatchedRoute(): RouteInterface; /** - * Removes all the defined routes + * Return the sub expressions in the regular expression matched + * + * @return array */ - public function clear(); + public function getMatches(): array; /** * Returns processed module name * * @return string */ - public function getModuleName(); + public function getModuleName(): string; /** * Returns processed namespace name * * @return string */ - public function getNamespaceName(); + public function getNamespaceName(): string; /** - * Returns processed controller name + * Returns processed extra params * - * @return string + * @return array */ - public function getControllerName(); + public function getParams(): array; /** - * Returns processed action name + * Return all the routes defined in the router * - * @return string + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function getActionName(); + public function getRoutes(): array; /** - * Returns processed extra params + * Returns a route object by its id * - * @return array + * @param mixed $id + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getParams(); + public function getRouteById($id); /** - * Returns the route that matches the handled URI + * Returns a route object by its name * - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $name + * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getMatchedRoute(); + public function getRouteByName(string $name); /** - * Return the sub expressions in the regular expression matched + * Handles routing information received from the rewrite engine * - * @return array + * @param string $uri */ - public function getMatches(); + public function handle(string $uri); /** - * Check if the router matches any of the defined routes + * Mounts a group of routes in the router * - * @return bool + * @param \Phalcon\Mvc\Router\GroupInterface $group + * @return RouterInterface */ - public function wasMatched(); + public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface; /** - * Return all the routes defined in the router + * Sets the default action name * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @param string $actionName */ - public function getRoutes(); + public function setDefaultAction(string $actionName); /** - * Returns a route object by its id + * Sets the default controller name * - * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $controllerName */ - public function getRouteById($id); + public function setDefaultController(string $controllerName); /** - * Returns a route object by its name + * Sets the name of the default module * - * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @param string $moduleName + */ + public function setDefaultModule(string $moduleName); + + /** + * Sets an array of default paths + * + * @param array $defaults + */ + public function setDefaults(array $defaults); + + /** + * Check if the router matches any of the defined routes + * + * @return bool */ - public function getRouteByName($name); + public function wasMatched(): bool; } diff --git a/src/Phalcon/mvc/Url.php b/src/Phalcon/mvc/Url.php deleted file mode 100644 index 92b6e69a..00000000 --- a/src/Phalcon/mvc/Url.php +++ /dev/null @@ -1,184 +0,0 @@ - - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2012", - * ] - * ); - * - */ -class Url implements \Phalcon\Mvc\UrlInterface, \Phalcon\Di\InjectionAwareInterface -{ - - protected $_dependencyInjector; - - - protected $_baseUri = null; - - - protected $_staticBaseUri = null; - - - protected $_basePath = null; - - - protected $_router; - - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Sets a prefix for all the URIs to be generated - * - * - * $url->setBaseUri("/invo/"); - * - * $url->setBaseUri("/invo/index.php/"); - * - * - * @param string $baseUri - * @return Url - */ - public function setBaseUri($baseUri) {} - - /** - * Sets a prefix for all static URLs generated - * - * - * $url->setStaticBaseUri("/invo/"); - * - * - * @param string $staticBaseUri - * @return Url - */ - public function setStaticBaseUri($staticBaseUri) {} - - /** - * Returns the prefix for all the generated urls. By default / - * - * @return string - */ - public function getBaseUri() {} - - /** - * Returns the prefix for all the generated static urls. By default / - * - * @return string - */ - public function getStaticBaseUri() {} - - /** - * Sets a base path for all the generated paths - * - * - * $url->setBasePath("/var/www/htdocs/"); - * - * - * @param string $basePath - * @return Url - */ - public function setBasePath($basePath) {} - - /** - * Returns the base path - * - * @return string - */ - public function getBasePath() {} - - /** - * Generates a URL - * - * - * // Generate a URL appending the URI to the base URI - * echo $url->get("products/edit/1"); - * - * // Generate a URL for a predefined route - * echo $url->get( - * [ - * "for" => "blog-post", - * "title" => "some-cool-stuff", - * "year" => "2015", - * ] - * ); - * - * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) - * echo $url->get( - * "show/products", - * [ - * "id" => 1, - * "name" => "Carrots", - * ] - * ); - * - * // Generate an absolute URL by setting the third parameter as false. - * echo $url->get( - * "https://phalconphp.com/", - * null, - * false - * ); - * - * - * @param mixed $uri - * @param mixed $args - * @param mixed $local - * @param mixed $baseUri - * @return string - */ - public function get($uri = null, $args = null, $local = null, $baseUri = null) {} - - /** - * Generates a URL for a static resource - * - * - * // Generate a URL for a static resource - * echo $url->getStatic("img/logo.png"); - * - * // Generate a URL for a static predefined route - * echo $url->getStatic( - * [ - * "for" => "logo-cdn", - * ] - * ); - * - * - * @param mixed $uri - * @return string - */ - public function getStatic($uri = null) {} - - /** - * Generates a local path - * - * @param string $path - * @return string - */ - public function path($path = null) {} - -} diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index f55dcfd4..e8270a85 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\View * - * Phalcon\Mvc\View is a class for working with the "view" portion of the model-view-controller pattern. - * That is, it exists to help keep the view script separate from the model and controller scripts. - * It provides a system of helpers, output filters, and variable escaping. + * Phalcon\Mvc\View is a class for working with the "view" portion of the + * model-view-controller pattern. That is, it exists to help keep the view + * script separate from the model and controller scripts. It provides a system + * of helpers, output filters, and variable escaping. * - * + * ```php * use Phalcon\Mvc\View; * * $view = new View(); @@ -25,19 +26,19 @@ * * // Printing views output * echo $view->getContent(); - * + * ``` */ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface { /** - * Render Level: To the main layout + * Render Level: To the action view */ - const LEVEL_MAIN_LAYOUT = 5; + const LEVEL_ACTION_VIEW = 1; /** - * Render Level: Render to the templates "after" + * Render Level: To the templates "before" */ - const LEVEL_AFTER_TEMPLATE = 4; + const LEVEL_BEFORE_TEMPLATE = 2; /** * Render Level: To the controller layout @@ -45,14 +46,9 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_LAYOUT = 3; /** - * Render Level: To the templates "before" - */ - const LEVEL_BEFORE_TEMPLATE = 2; - - /** - * Render Level: To the action view + * Render Level: To the main layout */ - const LEVEL_ACTION_VIEW = 1; + const LEVEL_MAIN_LAYOUT = 5; /** * Render Level: No render any view @@ -60,99 +56,86 @@ class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface const LEVEL_NO_RENDER = 0; /** - * Cache Mode + * Render Level: Render to the templates "after" */ - const CACHE_MODE_NONE = 0; - + const LEVEL_AFTER_TEMPLATE = 4; - const CACHE_MODE_INVERSE = 1; + protected $actionName; - protected $_options; + protected $activeRenderPaths; - protected $_basePath = ''; + protected $basePath = ''; - protected $_content = ''; + protected $content = ''; - protected $_renderLevel = 5; + protected $controllerName; - protected $_currentRenderLevel = 0; + protected $currentRenderLevel = 0; - protected $_disabledLevels; + protected $disabled = false; - protected $_viewParams = array(); + protected $disabledLevels; - protected $_layout; + protected $engines = false; - protected $_layoutsDir = ''; + protected $layout; - protected $_partialsDir = ''; + protected $layoutsDir = ''; - protected $_viewsDirs = array(); + protected $mainView = 'index'; - protected $_templatesBefore = array(); + protected $options = array(); - protected $_templatesAfter = array(); + protected $params; - protected $_engines = false; - /** - * @var array - */ - protected $_registeredEngines; + protected $pickView; - protected $_mainView = 'index'; + protected $partialsDir = ''; - protected $_controllerName; + protected $registeredEngines = array(); - protected $_actionName; + protected $renderLevel = 5; - protected $_params; + protected $templatesAfter = array(); - protected $_pickView; + protected $templatesBefore = array(); - protected $_cache; + protected $viewsDirs = array(); - protected $_cacheLevel = 0; + protected $viewParams = array(); - protected $_activeRenderPaths; + public function getCurrentRenderLevel() {} - protected $_disabled = false; + public function getRegisteredEngines() {} public function getRenderLevel() {} - - public function getCurrentRenderLevel() {} - - /** - * @return array - */ - public function getRegisteredEngines() {} - /** * Phalcon\Mvc\View constructor * @@ -161,563 +144,542 @@ public function getRegisteredEngines() {} public function __construct(array $options = array()) {} /** - * Checks if a path is absolute or not + * Magic method to retrieve a variable passed to the view * - * @param string $path + * ```php + * echo $this->view->products; + * ``` + * + * @param string $key + * @return mixed|null */ - protected final function _isAbsolutePath($path) {} + public function __get(string $key): ? {} /** - * Sets the views directory. Depending of your platform, - * always add a trailing slash or backslash + * Magic method to retrieve if a variable is set in the view * - * @param mixed $viewsDir - * @return View + * ```php + * echo isset($this->view->products); + * ``` + * + * @param string $key + * @return bool */ - public function setViewsDir($viewsDir) {} + public function __isset(string $key): bool {} /** - * Gets views directory + * Magic method to pass variables to the views * - * @return string|array + * ```php + * $this->view->products = $products; + * ``` + * + * @param string $key + * @param mixed $value */ - public function getViewsDir() {} + public function __set(string $key, $value) {} /** - * Sets the layouts sub-directory. Must be a directory under the views directory. - * Depending of your platform, always add a trailing slash or backslash - * - * - * $view->setLayoutsDir("../common/layouts/"); - * + * Resets any template before layouts * - * @param string $layoutsDir * @return View */ - public function setLayoutsDir($layoutsDir) {} + public function cleanTemplateAfter(): View {} /** - * Gets the current layouts sub-directory + * Resets any "template before" layouts * - * @return string + * @return View */ - public function getLayoutsDir() {} + public function cleanTemplateBefore(): View {} /** - * Sets a partials sub-directory. Must be a directory under the views directory. - * Depending of your platform, always add a trailing slash or backslash + * Disables a specific level of rendering * - * - * $view->setPartialsDir("../common/partials/"); - * + * ```php + * // Render all levels except ACTION level + * $this->view->disableLevel( + * View::LEVEL_ACTION_VIEW + * ); + * ``` * - * @param string $partialsDir - * @return View + * @param mixed $level + * @return \Phalcon\Mvc\ViewInterface */ - public function setPartialsDir($partialsDir) {} + public function disableLevel($level): ViewInterface {} /** - * Gets the current partials sub-directory + * Disables the auto-rendering process * - * @return string + * @return View */ - public function getPartialsDir() {} + public function disable(): View {} /** - * Sets base path. Depending of your platform, always add a trailing slash or backslash - * - * - * $view->setBasePath(__DIR__ . "/"); - * + * Enables the auto-rendering process * - * @param string $basePath * @return View */ - public function setBasePath($basePath) {} + public function enable(): View {} /** - * Gets base path + * Checks whether view exists * - * @return string + * @param string $view + * @return bool */ - public function getBasePath() {} + public function exists(string $view): bool {} /** - * Sets the render level for the view - * - * - * // Render the view related to the controller only - * $this->view->setRenderLevel( - * View::LEVEL_LAYOUT - * ); - * + * Finishes the render process by stopping the output buffering * - * @param int $level * @return View */ - public function setRenderLevel($level) {} + public function finish(): View {} /** - * Disables a specific level of rendering - * - * - * // Render all levels except ACTION level - * $this->view->disableLevel( - * View::LEVEL_ACTION_VIEW - * ); - * + * Gets the name of the action rendered * - * @param mixed $level - * @return View + * @return string */ - public function disableLevel($level) {} + public function getActionName(): string {} /** - * Sets default view name. Must be a file without extension in the views directory - * - * - * // Renders as main view views-dir/base.phtml - * $this->view->setMainView("base"); - * + * Returns the path (or paths) of the views that are currently rendered * - * @param string $viewPath - * @return View + * @return string|array */ - public function setMainView($viewPath) {} + public function getActiveRenderPath() {} /** - * Returns the name of the main view + * Gets base path * * @return string */ - public function getMainView() {} + public function getBasePath(): string {} /** - * Change the layout to be used instead of using the name of the latest controller name + * Returns output from another view stage * - * - * $this->view->setLayout("main"); - * + * @return string + */ + public function getContent(): string {} + + /** + * Gets the name of the controller rendered * - * @param string $layout - * @return View + * @return string */ - public function setLayout($layout) {} + public function getControllerName(): string {} /** * Returns the name of the main view * * @return string */ - public function getLayout() {} + public function getLayout(): string {} /** - * Sets a template before the controller layout + * Gets the current layouts sub-directory * - * @param mixed $templateBefore - * @return View + * @return string */ - public function setTemplateBefore($templateBefore) {} + public function getLayoutsDir(): string {} /** - * Resets any "template before" layouts + * Returns the name of the main view * - * @return View + * @return string */ - public function cleanTemplateBefore() {} + public function getMainView(): string {} /** - * Sets a "template after" controller layout + * Returns parameters to views * - * @param mixed $templateAfter - * @return View + * @return array */ - public function setTemplateAfter($templateAfter) {} + public function getParamsToView(): array {} /** - * Resets any template before layouts + * Renders a partial view * - * @return View + * ```php + * // Retrieve the contents of a partial + * echo $this->getPartial("shared/footer"); + * ``` + * + * ```php + * // Retrieve the contents of a partial with arguments + * echo $this->getPartial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * ``` + * + * @param string $partialPath + * @param mixed $params + * @return string */ - public function cleanTemplateAfter() {} + public function getPartial(string $partialPath, $params = null): string {} /** - * Adds parameters to views (alias of setVar) - * - * - * $this->view->setParamToView("products", $products); - * + * Gets the current partials sub-directory * - * @param string $key - * @param mixed $value - * @return View + * @return string */ - public function setParamToView($key, $value) {} + public function getPartialsDir(): string {} /** - * Set all the render params + * Perform the automatic rendering returning the output as a string * - * - * $this->view->setVars( + * ```php + * $template = $this->view->getRender( + * "products", + * "show", * [ * "products" => $products, * ] * ); - * + * ``` * + * @param string $controllerName + * @param string $actionName * @param array $params - * @param bool $merge - * @return View + * @param mixed $configCallback + * @return string */ - public function setVars(array $params, $merge = true) {} + public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string {} /** - * Set a single view parameter - * - * - * $this->view->setVar("products", $products); - * + * Returns a parameter previously set in the view * * @param string $key - * @param mixed $value - * @return View */ - public function setVar($key, $value) {} + public function getVar(string $key) {} /** - * Returns a parameter previously set in the view + * Gets views directory * - * @param string $key + * @return string|array */ - public function getVar($key) {} + public function getViewsDir() {} /** - * Returns parameters to views + * Gets views directories * * @return array */ - public function getParamsToView() {} + protected function getViewsDirs(): array {} /** - * Gets the name of the controller rendered + * Whether automatic rendering is enabled * - * @return string + * @return bool */ - public function getControllerName() {} + public function isDisabled(): bool {} /** - * Gets the name of the action rendered + * Renders a partial view * - * @return string - */ - public function getActionName() {} - - /** - * Gets extra parameters of the action rendered + * ```php + * // Show a partial inside another view + * $this->partial("shared/footer"); + * ``` * - * @deprecated Will be removed in 4.0.0 - * @deprecated - * @return array - */ - public function getParams() {} - - /** - * Starts rendering process enabling the output buffering + * ```php + * // Show a partial inside another view with parameters + * $this->partial( + * "shared/footer", + * [ + * "content" => $html, + * ] + * ); + * ``` * - * @return View + * @param string $partialPath + * @param mixed $params */ - public function start() {} + public function partial(string $partialPath, $params = null) {} /** - * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php + * Choose a different view to render instead of last-controller/last-action * - * @return array - */ - protected function _loadTemplateEngines() {} - - /** - * Checks whether view exists on registered extensions and render it + * ```php + * use Phalcon\Mvc\Controller; * - * @param array $engines - * @param string $viewPath - * @param boolean $silence - * @param boolean $mustClean - * @param \Phalcon\Cache\BackendInterface $cache + * class ProductsController extends Controller + * { + * public function saveAction() + * { + * // Do some save stuff... + * + * // Then show the list view + * $this->view->pick("products/list"); + * } + * } + * ``` + * + * @param mixed $renderView + * @return View */ - protected function _engineRender($engines, $viewPath, $silence, $mustClean, \Phalcon\Cache\BackendInterface $cache = null) {} + public function pick($renderView): View {} /** * Register templating engines * - * + * ```php * $this->view->registerEngines( * [ - * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", - * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", - * ".mhtml" => "MyCustomEngine", + * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, + * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, + * ".mhtml" => \MyCustomEngine::class, * ] * ); - * + * ``` * * @param array $engines * @return View */ - public function registerEngines(array $engines) {} - - /** - * Checks whether view exists - * - * @param string $view - * @return bool - */ - public function exists($view) {} + public function registerEngines(array $engines): View {} /** * Executes render process from dispatching data * - * + * ```php * // Shows recent posts view (app/views/posts/recent.phtml) * $view->start()->render("posts", "recent")->finish(); - * + * ``` * * @param string $controllerName * @param string $actionName * @param array $params * @return bool|View */ - public function render($controllerName, $actionName, $params = null) {} + public function render(string $controllerName, string $actionName, array $params = array()) {} /** - * Choose a different view to render instead of last-controller/last-action - * - * - * use Phalcon\Mvc\Controller; - * - * class ProductsController extends Controller - * { - * public function saveAction() - * { - * // Do some save stuff... - * - * // Then show the list view - * $this->view->pick("products/list"); - * } - * } - * + * Resets the view component to its factory default values * - * @param mixed $renderView * @return View */ - public function pick($renderView) {} + public function reset(): View {} /** - * Renders a partial view + * Sets base path. Depending of your platform, always add a trailing slash + * or backslash * - * - * // Retrieve the contents of a partial - * echo $this->getPartial("shared/footer"); - * + * ```php + * $view->setBasePath(__DIR__ . "/"); + * ``` * - * - * // Retrieve the contents of a partial with arguments - * echo $this->getPartial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * - * - * @param string $partialPath - * @param mixed $params - * @return string + * @param string $basePath + * @return View */ - public function getPartial($partialPath, $params = null) {} + public function setBasePath(string $basePath): View {} /** - * Renders a partial view - * - * - * // Show a partial inside another view - * $this->partial("shared/footer"); - * + * Externally sets the view content * - * - * // Show a partial inside another view with parameters - * $this->partial( - * "shared/footer", - * [ - * "content" => $html, - * ] - * ); - * + * ```php + * $this->view->setContent("

hello

"); + * ``` * - * @param string $partialPath - * @param mixed $params + * @param string $content + * @return View */ - public function partial($partialPath, $params = null) {} + public function setContent(string $content): View {} /** - * Perform the automatic rendering returning the output as a string + * Change the layout to be used instead of using the name of the latest + * controller name * - * - * $template = $this->view->getRender( - * "products", - * "show", - * [ - * "products" => $products, - * ] - * ); - * + * ```php + * $this->view->setLayout("main"); + * ``` * - * @param string $controllerName - * @param string $actionName - * @param array $params - * @param mixed $configCallback - * @return string + * @param string $layout + * @return View */ - public function getRender($controllerName, $actionName, $params = null, $configCallback = null) {} + public function setLayout(string $layout): View {} /** - * Finishes the render process by stopping the output buffering + * Sets the layouts sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * + * ```php + * $view->setLayoutsDir("../common/layouts/"); + * ``` + * + * @param string $layoutsDir * @return View */ - public function finish() {} + public function setLayoutsDir(string $layoutsDir): View {} /** - * Create a Phalcon\Cache based on the internal cache options + * Sets default view name. Must be a file without extension in the views + * directory * - * @return \Phalcon\Cache\BackendInterface + * ```php + * // Renders as main view views-dir/base.phtml + * $this->view->setMainView("base"); + * ``` + * + * @param string $viewPath + * @return View */ - protected function _createCache() {} + public function setMainView(string $viewPath): View {} /** - * Check if the component is currently caching the output content + * Sets a partials sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * - * @return bool + * ```php + * $view->setPartialsDir("../common/partials/"); + * ``` + * + * @param string $partialsDir + * @return View */ - public function isCaching() {} + public function setPartialsDir(string $partialsDir): View {} /** - * Returns the cache instance used to cache + * Adds parameters to views (alias of setVar) + * + * ```php + * $this->view->setParamToView("products", $products); + * ``` * - * @return \Phalcon\Cache\BackendInterface + * @param string $key + * @param mixed $value + * @return View */ - public function getCache() {} + public function setParamToView(string $key, $value): View {} /** - * Cache the actual view render to certain level + * Sets the render level for the view * - * - * $this->view->cache( - * [ - * "key" => "my-key", - * "lifetime" => 86400, - * ] + * ```php + * // Render the view related to the controller only + * $this->view->setRenderLevel( + * View::LEVEL_LAYOUT * ); - * + * ``` * - * @param mixed $options - * @return View + * @param int $level + * @return \Phalcon\Mvc\ViewInterface */ - public function cache($options = true) {} + public function setRenderLevel(int $level): ViewInterface {} /** - * Externally sets the view content - * - * - * $this->view->setContent("

hello

"); - *
+ * Sets a "template after" controller layout * - * @param string $content + * @param mixed $templateAfter * @return View */ - public function setContent($content) {} + public function setTemplateAfter($templateAfter): View {} /** - * Returns cached output from another view stage + * Sets a template before the controller layout * - * @return string + * @param mixed $templateBefore + * @return View */ - public function getContent() {} + public function setTemplateBefore($templateBefore): View {} /** - * Returns the path (or paths) of the views that are currently rendered + * Set a single view parameter * - * @return string|array + * ```php + * $this->view->setVar("products", $products); + * ``` + * + * @param string $key + * @param mixed $value + * @return View */ - public function getActiveRenderPath() {} + public function setVar(string $key, $value): View {} /** - * Disables the auto-rendering process + * Set all the render params * + * ```php + * $this->view->setVars( + * [ + * "products" => $products, + * ] + * ); + * ``` + * + * @param array $params + * @param bool $merge * @return View */ - public function disable() {} + public function setVars(array $params, bool $merge = true): View {} /** - * Enables the auto-rendering process + * Sets the views directory. Depending of your platform, + * always add a trailing slash or backslash * + * @param mixed $viewsDir * @return View */ - public function enable() {} + public function setViewsDir($viewsDir): View {} /** - * Resets the view component to its factory default values + * Starts rendering process enabling the output buffering * * @return View */ - public function reset() {} + public function start(): View {} /** - * Magic method to pass variables to the views - * - * - * $this->view->products = $products; - * + * Renders the view and returns it as a string * - * @param string $key - * @param mixed $value + * @param string $controllerName + * @param string $actionName + * @param array $params + * @return string */ - public function __set($key, $value) {} + public function toString(string $controllerName, string $actionName, array $params = array()): string {} /** - * Magic method to retrieve a variable passed to the view - * - * - * echo $this->view->products; - * + * Checks whether view exists on registered extensions and render it * - * @param string $key - * @return mixed|null + * @param array $engines + * @param string $viewPath + * @param bool $silence + * @param bool $mustClean */ - public function __get($key) {} + protected function engineRender(array $engines, string $viewPath, bool $silence, bool $mustClean = true) {} /** - * Whether automatic rendering is enabled + * Checks if a path is absolute or not * - * @return bool + * @param string $path */ - public function isDisabled() {} + final protected function isAbsolutePath(string $path) {} /** - * Magic method to retrieve if a variable is set in the view - * - * - * echo isset($this->view->products); - * + * Loads registered template engines, if none is registered it will use + * Phalcon\Mvc\View\Engine\Php * - * @param string $key - * @return bool + * @return array */ - public function __isset($key) {} + protected function loadTemplateEngines(): array {} /** - * Gets views directories + * Processes the view and templates; Fires events if needed * - * @return array + * @param string $controllerName + * @param string $actionName + * @param array $params + * @param bool $fireEvents + * @return bool */ - protected function getViewsDirs() {} + public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool {} } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index d0821d61..a88fca68 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -11,76 +11,63 @@ interface ViewBaseInterface { /** - * Sets views directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $viewsDir - */ - public function setViewsDir($viewsDir); - - /** - * Gets views directory - * - * @return string|array - */ - public function getViewsDir(); - - /** - * Adds parameters to views (alias of setVar) - * - * @param string $key - * @param mixed $value - */ - public function setParamToView($key, $value); - - /** - * Adds parameters to views + * Returns cached output from another view stage * - * @param string $key - * @param mixed $value + * @return string */ - public function setVar($key, $value); + public function getContent(): string; /** * Returns parameters to views * * @return array */ - public function getParamsToView(); + public function getParamsToView(): array; /** - * Returns the cache instance used to cache + * Gets views directory * - * @return \Phalcon\Cache\BackendInterface + * @return string|array */ - public function getCache(); + public function getViewsDir(); /** - * Cache the actual view render to certain level + * Renders a partial view * - * @param mixed $options + * @param string $partialPath + * @param mixed $params */ - public function cache($options = true); + public function partial(string $partialPath, $params = null); /** * Externally sets the view content * * @param string $content */ - public function setContent($content); + public function setContent(string $content); /** - * Returns cached output from another view stage + * Adds parameters to views (alias of setVar) * - * @return string + * @param string $key + * @param mixed $value */ - public function getContent(); + public function setParamToView(string $key, $value); /** - * Renders a partial view + * Adds parameters to views * - * @param string $partialPath - * @param mixed $params + * @param string $key + * @param mixed $value + */ + public function setVar(string $key, $value); + + /** + * Sets views directory. Depending of your platform, always add a trailing + * slash or backslash + * + * @param string $viewsDir */ - public function partial($partialPath, $params = null); + public function setViewsDir(string $viewsDir); } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index fb0b5082..c27c5ca3 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -11,135 +11,99 @@ interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface { /** - * Sets the layouts sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $layoutsDir + * Resets any template before layouts */ - public function setLayoutsDir($layoutsDir); + public function cleanTemplateAfter(); /** - * Gets the current layouts sub-directory - * - * @return string + * Resets any template before layouts */ - public function getLayoutsDir(); + public function cleanTemplateBefore(); /** - * Sets a partials sub-directory. Must be a directory under the views - * directory. Depending of your platform, always add a trailing slash or backslash - * - * @param string $partialsDir + * Disables the auto-rendering process */ - public function setPartialsDir($partialsDir); + public function disable(); /** - * Gets the current partials sub-directory - * - * @return string + * Enables the auto-rendering process */ - public function getPartialsDir(); + public function enable(); /** - * Sets base path. Depending of your platform, always add a trailing slash or backslash - * - * @param string $basePath + * Finishes the render process by stopping the output buffering */ - public function setBasePath($basePath); + public function finish(); /** - * Gets base path + * Gets the name of the action rendered * * @return string */ - public function getBasePath(); + public function getActionName(): string; /** - * Sets the render level for the view - * - * @param int $level - */ - public function setRenderLevel($level); - - /** - * Sets default view name. Must be a file without extension in the views directory + * Returns the path of the view that is currently rendered * - * @param string $viewPath + * @return string|array */ - public function setMainView($viewPath); + public function getActiveRenderPath(); /** - * Returns the name of the main view + * Gets base path * * @return string */ - public function getMainView(); + public function getBasePath(): string; /** - * Change the layout to be used instead of using the name of the latest controller name + * Gets the name of the controller rendered * - * @param string $layout + * @return string */ - public function setLayout($layout); + public function getControllerName(): string; /** * Returns the name of the main view * * @return string */ - public function getLayout(); - - /** - * Appends template before controller layout - * - * @param string|array $templateBefore - */ - public function setTemplateBefore($templateBefore); - - /** - * Resets any template before layouts - */ - public function cleanTemplateBefore(); + public function getLayout(): string; /** - * Appends template after controller layout + * Gets the current layouts sub-directory * - * @param string|array $templateAfter - */ - public function setTemplateAfter($templateAfter); - - /** - * Resets any template before layouts + * @return string */ - public function cleanTemplateAfter(); + public function getLayoutsDir(): string; /** - * Gets the name of the controller rendered + * Returns the name of the main view * * @return string */ - public function getControllerName(); + public function getMainView(): string; /** - * Gets the name of the action rendered + * Gets the current partials sub-directory * * @return string */ - public function getActionName(); + public function getPartialsDir(): string; /** - * Gets extra parameters of the action rendered + * Whether the automatic rendering is disabled * - * @deprecated Will be removed in 4.0.0 - * @deprecated - * @return array + * @return bool */ - public function getParams(); + public function isDisabled(): bool; /** - * Starts rendering process enabling the output buffering + * Choose a view different to render than last-controller/last-action + * + * @param string $renderView */ - public function start(); + public function pick(string $renderView); /** * Register templating engines @@ -154,48 +118,82 @@ public function registerEngines(array $engines); * @param string $controllerName * @param string $actionName * @param array $params + * @return bool|ViewInterface */ - public function render($controllerName, $actionName, $params = null); + public function render(string $controllerName, string $actionName, array $params = array()); /** - * Choose a view different to render than last-controller/last-action + * Resets the view component to its factory default values + */ + public function reset(); + + /** + * Sets base path. Depending of your platform, always add a trailing slash + * or backslash * - * @param string $renderView + * @param string $basePath */ - public function pick($renderView); + public function setBasePath(string $basePath); /** - * Finishes the render process by stopping the output buffering + * Change the layout to be used instead of using the name of the latest + * controller name + * + * @param string $layout */ - public function finish(); + public function setLayout(string $layout); /** - * Returns the path of the view that is currently rendered + * Sets the layouts sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash * - * @return string|array + * @param string $layoutsDir */ - public function getActiveRenderPath(); + public function setLayoutsDir(string $layoutsDir); /** - * Disables the auto-rendering process + * Sets default view name. Must be a file without extension in the views + * directory + * + * @param string $viewPath */ - public function disable(); + public function setMainView(string $viewPath); /** - * Enables the auto-rendering process + * Sets a partials sub-directory. Must be a directory under the views + * directory. Depending of your platform, always add a trailing slash or + * backslash + * + * @param string $partialsDir */ - public function enable(); + public function setPartialsDir(string $partialsDir); /** - * Resets the view component to its factory default values + * Sets the render level for the view + * + * @param int $level + * @return ViewInterface */ - public function reset(); + public function setRenderLevel(int $level): ViewInterface; /** - * Whether the automatic rendering is disabled + * Appends template after controller layout * - * @return bool + * @param string|array $templateAfter */ - public function isDisabled(); + public function setTemplateAfter($templateAfter); + + /** + * Appends template before controller layout + * + * @param string|array $templateBefore + */ + public function setTemplateBefore($templateBefore); + + /** + * Starts rendering process enabling the output buffering + */ + public function start(); } diff --git a/src/Phalcon/mvc/collection/Behavior.php b/src/Phalcon/mvc/collection/Behavior.php index 7ad66958..b0683096 100644 --- a/src/Phalcon/mvc/collection/Behavior.php +++ b/src/Phalcon/mvc/collection/Behavior.php @@ -10,7 +10,7 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface { - protected $_options; + protected $options; /** @@ -18,39 +18,39 @@ abstract class Behavior implements \Phalcon\Mvc\Collection\BehaviorInterface * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Checks whether the behavior must take action on certain event + * Returns the behavior options related to an event * * @param string $eventName - * @return bool + * @return array */ - protected function mustTakeAction($eventName) {} + protected function getOptions(string $eventName = null) {} /** - * Returns the behavior options related to an event + * Acts as fallbacks when a missing method is called on the collection * - * @param string $eventName - * @return array + * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $method + * @param array $arguments */ - protected function getOptions($eventName = null) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $method, array $arguments = array()) {} /** - * This method receives the notifications from the EventsManager + * Checks whether the behavior must take action on certain event * - * @param string $type - * @param \Phalcon\Mvc\CollectionInterface $model + * @param string $eventName + * @return bool */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + protected function mustTakeAction(string $eventName): bool {} /** - * Acts as fallbacks when a missing method is called on the collection + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $method - * @param mixed $arguments */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $method, $arguments = null) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/collection/BehaviorInterface.php b/src/Phalcon/mvc/collection/BehaviorInterface.php index a3d877ba..0a5b1437 100644 --- a/src/Phalcon/mvc/collection/BehaviorInterface.php +++ b/src/Phalcon/mvc/collection/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the collection * - * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection + * @param string $method + * @param array $arguments */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $collection); + public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, string $method, array $arguments = array()); /** - * Calls a method when it's missing in the collection + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\CollectionInterface $collection - * @param string $method - * @param mixed $arguments */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $collection, $method, $arguments = null); + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $collection); } diff --git a/src/Phalcon/mvc/collection/Document.php b/src/Phalcon/mvc/collection/Document.php index bbc95b98..94efc018 100644 --- a/src/Phalcon/mvc/collection/Document.php +++ b/src/Phalcon/mvc/collection/Document.php @@ -12,19 +12,20 @@ class Document implements \Phalcon\Mvc\EntityInterface, \ArrayAccess { /** - * Checks whether an offset exists in the document + * Returns the value of a field using the ArrayAccess interfase * - * @param int $index - * @return bool + * @param mixed $index + * @return mixed */ - public function offsetExists($index) {} + public function offsetGet($index) {} /** - * Returns the value of a field using the ArrayAccess interfase + * Checks whether an offset exists in the document * * @param mixed $index + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index): bool {} /** * Change a value using the ArrayAccess interface @@ -37,39 +38,39 @@ public function offsetSet($index, $value) {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @param string $offset + * @param mixed $index */ - public function offsetUnset($offset) {} + public function offsetUnset($index) {} /** * Reads an attribute value by its name * - * + * ```php * echo $robot->readAttribute("name"); - * + * ``` * * @param string $attribute - * @return mixed + * @return mixed|null */ - public function readAttribute($attribute) {} + public function readAttribute(string $attribute): ? {} + + /** + * Returns the instance as an array representation + * + * @return array + */ + public function toArray(): array {} /** * Writes an attribute value by its name * - * + * ```php * $robot->writeAttribute("name", "Rosey"); - * + * ``` * * @param string $attribute * @param mixed $value */ - public function writeAttribute($attribute, $value) {} - - /** - * Returns the instance as an array representation - * - * @return array - */ - public function toArray() {} + public function writeAttribute(string $attribute, $value) {} } diff --git a/src/Phalcon/mvc/collection/Manager.php b/src/Phalcon/mvc/collection/Manager.php index dc635c26..8be4af53 100644 --- a/src/Phalcon/mvc/collection/Manager.php +++ b/src/Phalcon/mvc/collection/Manager.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * + * ```php * $di = new \Phalcon\Di(); * * $di->set( @@ -21,36 +21,36 @@ * ); * * $robot = new Robots($di); - * + * ``` */ class Manager implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_dependencyInjector; + protected $behaviors; - protected $_initialized; + protected $connectionServices; - protected $_lastInitialized; + protected $container; - protected $_eventsManager; + protected $customEventsManager; - protected $_customEventsManager; + protected $eventsManager; - protected $_connectionServices; + protected $implicitObjectsIds; - protected $_implicitObjectsIds; + protected $initialized; - protected $_behaviors; + protected $lastInitialized; - protected $_serviceName = 'mongo'; + protected $serviceName = 'mongo'; @@ -62,138 +62,138 @@ public function getServiceName() {} public function setServiceName($serviceName) {} /** - * Sets the DependencyInjector container + * Binds a behavior to a model * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} /** - * Returns the DependencyInjector container + * Returns a custom events manager related to a model * - * @return \Phalcon\DiInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @return mixed|null */ - public function getDI() {} + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): ? {} /** - * Sets the event manager + * Returns the connection related to a model * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Mongo */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Returns the internal event manager + * Gets a connection service for a specific model * - * @return \Phalcon\Events\ManagerInterface + * @param \Phalcon\Mvc\CollectionInterface $model + * @return string */ - public function getEventsManager() {} + public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model): string {} /** - * Sets a custom events manager for a specific model + * Returns the DependencyInjector container * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return \Phalcon\Di\DiInterface */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} + public function getDI(): DiInterface {} /** - * Returns a custom events manager related to a model + * Returns the internal event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return mixed|null + * @return \Phalcon\Events\ManagerInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model) {} + public function getEventsManager(): ManagerInterface {} /** - * Initializes a model in the models manager + * Get the latest initialized model * - * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Phalcon\Mvc\CollectionInterface */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} + public function getLastInitialized(): CollectionInterface {} /** - * Check whether a model is already initialized + * Checks if a model is using implicit object ids * - * @param string $modelName + * @param \Phalcon\Mvc\CollectionInterface $model * @return bool */ - public function isInitialized($modelName) {} + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool {} /** - * Get the latest initialized model + * Check whether a model is already initialized * - * @return \Phalcon\Mvc\CollectionInterface + * @param string $className + * @return bool */ - public function getLastInitialized() {} + public function isInitialized(string $className): bool {} /** - * Sets a connection service for a specific model + * Initializes a model in the models manager * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService) {} + public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} /** - * Gets a connection service for a specific model + * Dispatch an event to the listeners and behaviors + * This method expects that the endpoint listeners/behaviors returns true + * meaning that at least one was implemented * * @param \Phalcon\Mvc\CollectionInterface $model - * @return string + * @param string $eventName + * @param mixed $data + * @return bool */ - public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model) {} + public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $eventName, $data): bool {} /** - * Sets whether a model must use implicit objects ids + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds) {} + public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model) {} /** - * Checks if a model is using implicit object ids + * Sets a custom events manager for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model) {} + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Returns the connection related to a model + * Sets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Mongo + * @param string $connectionService */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService) {} /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets the DependencyInjector container * - * @param string $eventName - * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Di\DiInterface $container */ - public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented + * Sets the event manager * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $eventName - * @param mixed $data - * @return bool + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, $eventName, $data) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** - * Binds a behavior to a model + * Sets whether a model must use implicit objects ids * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param bool $useImplicitObjectIds */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds) {} } diff --git a/src/Phalcon/mvc/collection/ManagerInterface.php b/src/Phalcon/mvc/collection/ManagerInterface.php index da8edc32..1d575f79 100644 --- a/src/Phalcon/mvc/collection/ManagerInterface.php +++ b/src/Phalcon/mvc/collection/ManagerInterface.php @@ -10,7 +10,7 @@ * * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. * - * + * ```php * $di = new \Phalcon\Di(); * * $di->set( @@ -21,64 +21,56 @@ * ); * * $robot = new Robots(di); - * + * ``` */ interface ManagerInterface { /** - * Sets a custom events manager for a specific model + * Binds a behavior to a collection * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); + public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); /** - * Returns a custom events manager related to a model + * Returns the connection related to a model * * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Events\ManagerInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model); + public function getConnection(\Phalcon\Mvc\CollectionInterface $model): AdapterInterface; /** - * Initializes a model in the models manager + * Returns a custom events manager related to a model * * @param \Phalcon\Mvc\CollectionInterface $model + * @return \Phalcon\Events\ManagerInterface */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model); - - /** - * Check whether a model is already initialized - * - * @param string $modelName - * @return bool - */ - public function isInitialized($modelName); + public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): EventsManagerInterface; /** * Get the latest initialized model * * @return \Phalcon\Mvc\CollectionInterface */ - public function getLastInitialized(); + public function getLastInitialized(): CollectionInterface; /** - * Sets a connection service for a specific model + * Initializes a model in the models manager * * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, $connectionService); + public function initialize(\Phalcon\Mvc\CollectionInterface $model); /** - * Sets if a model must use implicit objects ids + * Check whether a model is already initialized * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds + * @param string $className + * @return bool */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $useImplicitObjectIds); + public function isInitialized(string $className): bool; /** * Checks if a model is using implicit object ids @@ -86,31 +78,39 @@ public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, $u * @param \Phalcon\Mvc\CollectionInterface $model * @return bool */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model); + public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool; /** - * Returns the connection related to a model + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * + * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Db\AdapterInterface */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model); + public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model); /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets a custom events manager for a specific model * - * @param string $eventName * @param \Phalcon\Mvc\CollectionInterface $model + * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function notifyEvent($eventName, \Phalcon\Mvc\CollectionInterface $model); + public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); /** - * Binds a behavior to a collection + * Sets a connection service for a specific model * * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior + * @param string $connectionService */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); + public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService); + + /** + * Sets if a model must use implicit objects ids + * + * @param \Phalcon\Mvc\CollectionInterface $model + * @param bool $useImplicitObjectIds + */ + public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds); } diff --git a/src/Phalcon/mvc/collection/behavior/SoftDelete.php b/src/Phalcon/mvc/collection/behavior/SoftDelete.php index 59621249..18c2959f 100644 --- a/src/Phalcon/mvc/collection/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/collection/behavior/SoftDelete.php @@ -17,6 +17,6 @@ class SoftDelete extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/collection/behavior/Timestampable.php b/src/Phalcon/mvc/collection/behavior/Timestampable.php index d9803981..09ebb023 100644 --- a/src/Phalcon/mvc/collection/behavior/Timestampable.php +++ b/src/Phalcon/mvc/collection/behavior/Timestampable.php @@ -17,6 +17,6 @@ class Timestampable extends \Phalcon\Mvc\Collection\Behavior * @param string $type * @param \Phalcon\Mvc\CollectionInterface $model */ - public function notify($type, \Phalcon\Mvc\CollectionInterface $model) {} + public function notify(string $type, \Phalcon\Mvc\CollectionInterface $model) {} } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 1bffa5d2..84e98de1 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -15,6 +15,6 @@ interface BindModelInterface * * @return string */ - public static function getModelName(); + public static function getModelName(): string; } diff --git a/src/Phalcon/mvc/dispatcher/Exception.php b/src/Phalcon/mvc/dispatcher/Exception.php index 685af95f..b7f06862 100644 --- a/src/Phalcon/mvc/dispatcher/Exception.php +++ b/src/Phalcon/mvc/dispatcher/Exception.php @@ -7,7 +7,7 @@ * * Exceptions thrown in Phalcon\Mvc\Dispatcher will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Phalcon\Dispatcher\Exception { } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 8b312466..5c1ba381 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -7,7 +7,7 @@ * * Groups Micro-Mvc handlers as controllers * - * + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $collection = new Collection(); @@ -19,175 +19,185 @@ * $collection->get("/posts/edit/{id}", "edit"); * * $app->mount($collection); - * + * ``` */ class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { - protected $_prefix; + protected $handler; - protected $_lazy; + protected $handlers = array(); - protected $_handler; + protected $lazy; - protected $_handlers; + protected $prefix; /** - * Internal function to add a handler to the group + * Maps a route to a handler that only matches if the HTTP method is DELETE. * - * @param string|array $method * @param string $routePattern - * @param mixed $handler + * @param callable|string $handler * @param string $name + * @return CollectionInterface */ - protected function _addMap($method, $routePattern, $handler, $name) {} + public function delete(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is GET. * - * @param string $prefix + * @param string $routePattern + * @param callable|string $handler + * @param string $name * @return CollectionInterface */ - public function setPrefix($prefix) {} + public function get(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Returns the collection prefix if any + * Returns the main handler * - * @return string + * @return mixed */ - public function getPrefix() {} + public function getHandler() {} /** * Returns the registered handlers * * @return array */ - public function getHandlers() {} + public function getHandlers(): array {} /** - * Sets the main handler + * Returns the collection prefix if any * - * @param mixed $handler - * @param boolean $lazy - * @return Collection + * @return string */ - public function setHandler($handler, $lazy = false) {} + public function getPrefix(): string {} /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is HEAD. * - * @param bool $lazy + * @param string $routePattern + * @param callable|string $handler + * @param string $name * @return CollectionInterface */ - public function setLazy($lazy) {} + public function head(string $routePattern, $handler, string $name = null): CollectionInterface {} /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy() {} + public function isLazy(): bool {} /** - * Returns the main handler + * Maps a route to a handler. * - * @return mixed + * @param string $routePattern + * @param callable|string $handler + * @param string $name + * @return CollectionInterface */ - public function getHandler() {} + public function map(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler + * Maps a route to a handler via methods. + * + * ```php + * $collection->mapVia( + * "/test", + * "indexAction", + * ["POST", "GET"], + * "test" + * ); + * ``` * * @param string $routePattern * @param callable $handler + * @param string|array $method * @param string $name - * @return Collection + * @return CollectionInterface */ - public function map($routePattern, $handler, $name = null) {} + public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface {} /** - * Maps a route to a handler via methods + * Maps a route to a handler that only matches if the HTTP method is + * OPTIONS. * * @param string $routePattern - * @param callable $handler - * @param string|array $method + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function mapVia($routePattern, $handler, $method, $name = null) {} + public function options(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Maps a route to a handler that only matches if the HTTP method is PATCH. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function get($routePattern, $handler, $name = null) {} + public function patch(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Maps a route to a handler that only matches if the HTTP method is POST. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function post($routePattern, $handler, $name = null) {} + public function post(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Maps a route to a handler that only matches if the HTTP method is PUT. * * @param string $routePattern - * @param callable $handler + * @param callable|string $handler * @param string $name - * @return Collection + * @return CollectionInterface */ - public function put($routePattern, $handler, $name = null) {} + public function put(string $routePattern, $handler, string $name = null): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Sets the main handler. * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param callable|string $handler + * @param bool $lazy + * @return CollectionInterface */ - public function patch($routePattern, $handler, $name = null) {} + public function setHandler($handler, bool $lazy = false): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param bool $lazy + * @return CollectionInterface */ - public function head($routePattern, $handler, $name = null) {} + public function setLazy(bool $lazy): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return Collection + * @param string $prefix + * @return CollectionInterface */ - public function delete($routePattern, $handler, $name = null) {} + public function setPrefix(string $prefix): CollectionInterface {} /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Internal function to add a handler to the group. * + * @param string|array $method * @param string $routePattern - * @param callable $handler - * @param mixed $name - * @return Collection + * @param callable|string $handler + * @param string $name */ - public function options($routePattern, $handler, $name = null) {} + protected function addMap($method, string $routePattern, $handler, string $name) {} } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index ad71ea2e..8254ccc9 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -11,57 +11,62 @@ interface CollectionInterface { /** - * Sets a prefix for all routes added to the collection + * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @param string $prefix + * @param string $routePattern + * @param callable $handler + * @param string $name * @return CollectionInterface */ - public function setPrefix($prefix); + public function delete(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Returns the collection prefix if any + * Maps a route to a handler that only matches if the HTTP method is GET * - * @return string + * @param string $routePattern + * @param callable $handler + * @param string $name + * @return CollectionInterface + */ + public function get(string $routePattern, $handler, string $name = null): CollectionInterface; + + /** + * Returns the main handler + * + * @return mixed */ - public function getPrefix(); + public function getHandler(); /** * Returns the registered handlers * * @return array */ - public function getHandlers(); + public function getHandlers(): array; /** - * Sets the main handler + * Returns the collection prefix if any * - * @param mixed $handler - * @param boolean $lazy - * @return \Phalcon\Mvc\Micro\Collection + * @return string */ - public function setHandler($handler, $lazy = false); + public function getPrefix(): string; /** - * Sets if the main handler must be lazy loaded + * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param bool $lazy + * @param string $routePattern + * @param callable $handler + * @param string $name * @return CollectionInterface */ - public function setLazy($lazy); + public function head(string $routePattern, $handler, string $name = null): CollectionInterface; /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy(); - - /** - * Returns the main handler - * - * @return mixed - */ - public function getHandler(); + public function isLazy(): bool; /** * Maps a route to a handler @@ -69,78 +74,73 @@ public function getHandler(); * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function map($routePattern, $handler, $name = null); + public function map(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is GET + * Maps a route to a handler that only matches if the HTTP method is OPTIONS * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function get($routePattern, $handler, $name = null); + public function options(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is POST + * Maps a route to a handler that only matches if the HTTP method is PATCH * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function post($routePattern, $handler, $name = null); + public function patch(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is PUT + * Maps a route to a handler that only matches if the HTTP method is POST * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function put($routePattern, $handler, $name = null); + public function post(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is PATCH + * Maps a route to a handler that only matches if the HTTP method is PUT * * @param string $routePattern * @param callable $handler * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @return CollectionInterface */ - public function patch($routePattern, $handler, $name = null); + public function put(string $routePattern, $handler, string $name = null): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is HEAD + * Sets the main handler * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param mixed $handler + * @param bool $lazy + * @return CollectionInterface */ - public function head($routePattern, $handler, $name = null); + public function setHandler($handler, bool $lazy = false): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is DELETE + * Sets if the main handler must be lazy loaded * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param bool $lazy + * @return CollectionInterface */ - public function delete($routePattern, $handler, $name = null); + public function setLazy(bool $lazy): CollectionInterface; /** - * Maps a route to a handler that only matches if the HTTP method is OPTIONS + * Sets a prefix for all routes added to the collection * - * @param string $routePattern - * @param callable $handler - * @param string $name - * @return \Phalcon\Mvc\Router\RouteInterface + * @param string $prefix + * @return CollectionInterface */ - public function options($routePattern, $handler, $name = null); + public function setPrefix(string $prefix): CollectionInterface; } diff --git a/src/Phalcon/mvc/micro/Exception.php b/src/Phalcon/mvc/micro/Exception.php index 1c22e5f4..cd352fc1 100644 --- a/src/Phalcon/mvc/micro/Exception.php +++ b/src/Phalcon/mvc/micro/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\Micro; /** - * Phalcon\Mvc\Micro\Exception - * * Exceptions thrown in Phalcon\Mvc\Micro will use this class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index e083b411..d7cb0a66 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -10,13 +10,10 @@ class LazyLoader { - protected $_handler; + protected $handler; - protected $_modelBinder; - - - protected $_definition; + protected $definition; @@ -27,16 +24,7 @@ public function getDefinition() {} * * @param string $definition */ - public function __construct($definition) {} - - /** - * Initializes the internal handler, calling functions on it - * - * @param string $method - * @param array $arguments - * @return mixed - */ - public function __call($method, $arguments) {} + public function __construct(string $definition) {} /** * Calling __call method @@ -46,6 +34,6 @@ public function __call($method, $arguments) {} * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @return mixed */ - public function callMethod($method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} + public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index ee19ff86..daa73549 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\Micro; /** - * Phalcon\Mvc\Micro\MiddlewareInterface - * * Allows to implement Phalcon\Mvc\Micro middleware in classes */ interface MiddlewareInterface diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 4c5bc910..e3366fdd 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -9,8 +9,10 @@ */ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface { - - protected $_options; + /** + * @var array + */ + protected $options; /** @@ -18,39 +20,39 @@ abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface * * @param array $options */ - public function __construct($options = null) {} + public function __construct(array $options = array()) {} /** - * Checks whether the behavior must take action on certain event + * Returns the behavior options related to an event * * @param string $eventName - * @return bool + * @return array */ - protected function mustTakeAction($eventName) {} + protected function getOptions(string $eventName = null) {} /** - * Returns the behavior options related to an event + * Acts as fallbacks when a missing method is called on the model * - * @param string $eventName - * @return array + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - protected function getOptions($eventName = null) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) {} /** - * This method receives the notifications from the EventsManager + * Checks whether the behavior must take action on certain event * - * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param string $eventName + * @return bool */ - public function notify($type, \Phalcon\Mvc\ModelInterface $model) {} + protected function mustTakeAction(string $eventName): bool {} /** - * Acts as fallbacks when a missing method is called on the model + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null) {} + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 084b49fd..77ed3cc6 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -11,20 +11,20 @@ interface BehaviorInterface { /** - * This method receives the notifications from the EventsManager + * Calls a method when it's missing in the model * - * @param string $type * @param \Phalcon\Mvc\ModelInterface $model + * @param string $method + * @param array $arguments */ - public function notify($type, \Phalcon\Mvc\ModelInterface $model); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()); /** - * Calls a method when it's missing in the model + * This method receives the notifications from the EventsManager * + * @param string $type * @param \Phalcon\Mvc\ModelInterface $model - * @param string $method - * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $method, $arguments = null); + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index dbe0bf78..086ca316 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -37,7 +37,7 @@ class Binder implements \Phalcon\Mvc\Model\BinderInterface * * @return array */ - public function getBoundModels() {} + public function getBoundModels(): array {} /** * Array for original values @@ -47,24 +47,9 @@ public function getOriginalValues() {} /** * Phalcon\Mvc\Model\Binder constructor * - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct(\Phalcon\Cache\BackendInterface $cache = null) {} - - /** - * Gets cache instance - * - * @param \Phalcon\Cache\BackendInterface $cache - * @return BinderInterface - */ - public function setCache(\Phalcon\Cache\BackendInterface $cache) {} - - /** - * Sets cache instance - * - * @return \Phalcon\Cache\BackendInterface - */ - public function getCache() {} + public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** * Bind models into params in proper handler @@ -72,10 +57,10 @@ public function getCache() {} * @param object $handler * @param array $params * @param string $cacheKey - * @param mixed $methodName + * @param string $methodName * @return array */ - public function bindToHandler($handler, array $params, $cacheKey, $methodName = null) {} + public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array {} /** * Find the model by param value. @@ -84,7 +69,14 @@ public function bindToHandler($handler, array $params, $cacheKey, $methodName = * @param string $className * @return object|bool */ - protected function findBoundModel($paramValue, $className) {} + protected function findBoundModel($paramValue, string $className): bool {} + + /** + * Sets cache instance + * + * @return \Phalcon\Cache\Adapter\AdapterInterface + */ + public function getCache(): AdapterInterface {} /** * Get params classes from cache by key @@ -92,7 +84,7 @@ protected function findBoundModel($paramValue, $className) {} * @param string $cacheKey * @return array|null */ - protected function getParamsFromCache($cacheKey) {} + protected function getParamsFromCache(string $cacheKey): ?array {} /** * Get modified params for handler using reflection @@ -100,9 +92,17 @@ protected function getParamsFromCache($cacheKey) {} * @param object $handler * @param array $params * @param string $cacheKey - * @param mixed $methodName + * @param string $methodName * @return array */ - protected function getParamsFromReflection($handler, array $params, $cacheKey, $methodName) {} + protected function getParamsFromReflection($handler, array $params, string $cacheKey, string $methodName): array {} + + /** + * Gets cache instance + * + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return BinderInterface + */ + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface {} } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index ddd77ec2..811f792e 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -11,36 +11,36 @@ interface BinderInterface { /** - * Gets active bound models + * Bind models into params in proper handler * + * @param object $handler + * @param array $params + * @param string $cacheKey + * @param string $methodName * @return array */ - public function getBoundModels(); + public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array; /** - * Gets cache instance + * Gets active bound models * - * @return \Phalcon\Cache\BackendInterface + * @return array */ - public function getCache(); + public function getBoundModels(): array; /** - * Sets cache instance + * Gets cache instance * - * @param \Phalcon\Cache\BackendInterface $cache - * @return BinderInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function setCache(\Phalcon\Cache\BackendInterface $cache); + public function getCache(): AdapterInterface; /** - * Bind models into params in proper handler + * Sets cache instance * - * @param object $handler - * @param array $params - * @param string $cacheKey - * @param mixed $methodName - * @return array + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @return BinderInterface */ - public function bindToHandler($handler, array $params, $cacheKey, $methodName = null); + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index e39987a0..99b5a18f 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -6,10 +6,10 @@ * Phalcon\Mvc\Model\Criteria * * This class is used to build the array parameter required by - * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() - * using an object-oriented interface. + * Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() using an + * object-oriented interface. * - * + * ```php * $robots = Robots::query() * ->where("type = :type:") * ->andWhere("year < 2000") @@ -17,39 +17,39 @@ * ->limit(5, 10) * ->orderBy("name") * ->execute(); - * + * ``` */ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_model; + protected $bindParams; - protected $_params; + protected $bindTypes; - protected $_bindParams; + protected $hiddenParamNumber = 0; - protected $_bindTypes; + protected $model; - protected $_hiddenParamNumber = 0; + protected $params = array(); /** * Sets the DependencyInjector container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the DependencyInjector container * - * @return null|\Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** * Set a model on which the query will be executed @@ -57,14 +57,14 @@ public function getDI() {} * @param string $modelName * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function setModelName($modelName) {} + public function setModelName(string $modelName): CriteriaInterface {} /** * Returns an internal model name on which the criteria will be applied * * @return string */ - public function getModelName() {} + public function getModelName(): string {} /** * Sets the bound parameters in the criteria @@ -74,7 +74,7 @@ public function getModelName() {} * @param bool $merge * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bind(array $bindParams, $merge = false) {} + public function bind(array $bindParams, bool $merge = false): CriteriaInterface {} /** * Sets the bind types in the criteria @@ -83,94 +83,130 @@ public function bind(array $bindParams, $merge = false) {} * @param array $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bindTypes(array $bindTypes) {} + public function bindTypes(array $bindTypes): CriteriaInterface {} /** * Sets SELECT DISTINCT / SELECT ALL flag * * @param mixed $distinct - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function distinct($distinct) {} + public function distinct($distinct): CriteriaInterface {} /** * Sets the columns to be queried * - * + * ```php * $criteria->columns( * [ * "id", * "name", * ] * ); - * + * ``` * * @param string|array $columns - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function columns($columns) {} + public function columns($columns): CriteriaInterface {} /** * Adds an INNER join to the query * - * - * $criteria->join("Robots"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r"); - * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); - * + * ```php + * $criteria->join( + * Robots::class + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * + * $criteria->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r", + * "LEFT" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias * @param mixed $type - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function join($model, $conditions = null, $alias = null, $type = null) {} + public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface {} /** * Adds an INNER join to the query * - * - * $criteria->innerJoin("Robots"); - * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id"); - * $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->innerJoin( + * Robots::class + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function innerJoin($model, $conditions = null, $alias = null) {} + public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Adds a LEFT join to the query * - * - * $criteria->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function leftJoin($model, $conditions = null, $alias = null) {} + public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Adds a RIGHT join to the query * - * - * $criteria->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * ```php + * $criteria->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * * @param string $model * @param mixed $conditions * @param mixed $alias - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function rightJoin($model, $conditions = null, $alias = null) {} + public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} /** * Sets the conditions parameter in the criteria @@ -180,20 +216,7 @@ public function rightJoin($model, $conditions = null, $alias = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null) {} - - /** - * Appends a condition to the current conditions using an AND operator (deprecated) - * - * @deprecated 1.0.0 - * @see \Phalcon\Mvc\Model\Criteria::andWhere() - * @param string $conditions - * @param mixed $bindParams - * @param mixed $bindTypes - * @deprecated - * @return Criteria - */ - public function addWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a condition to the current conditions using an AND operator @@ -203,7 +226,7 @@ public function addWhere($conditions, $bindParams = null, $bindTypes = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a condition to the current conditions using an OR operator @@ -213,61 +236,61 @@ public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} /** * Appends a BETWEEN condition to the current conditions * - * + * ```php * $criteria->betweenWhere("price", 100.25, 200.50); - * + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function betweenWhere($expr, $minimum, $maximum) {} + public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} /** * Appends a NOT BETWEEN condition to the current conditions * - * + * ```php * $criteria->notBetweenWhere("price", 100.25, 200.50); - * + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notBetweenWhere($expr, $minimum, $maximum) {} + public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} /** * Appends an IN condition to the current conditions * - * + * ```php * $criteria->inWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function inWhere($expr, array $values) {} + public function inWhere(string $expr, array $values): CriteriaInterface {} /** * Appends a NOT IN condition to the current conditions * - * + * ```php * $criteria->notInWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notInWhere($expr, array $values) {} + public function notInWhere(string $expr, array $values): CriteriaInterface {} /** * Adds the conditions parameter to the criteria @@ -275,17 +298,7 @@ public function notInWhere($expr, array $values) {} * @param string $conditions * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function conditions($conditions) {} - - /** - * Adds the order-by parameter to the criteria (deprecated) - * - * @see \Phalcon\Mvc\Model\Criteria::orderBy() - * @param string $orderColumns - * @deprecated - * @return Criteria - */ - public function order($orderColumns) {} + public function conditions(string $conditions): CriteriaInterface {} /** * Adds the order-by clause to the criteria @@ -293,38 +306,38 @@ public function order($orderColumns) {} * @param string $orderColumns * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orderBy($orderColumns) {} + public function orderBy(string $orderColumns): CriteriaInterface {} /** * Adds the group-by clause to the criteria * * @param mixed $group - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function groupBy($group) {} + public function groupBy($group): CriteriaInterface {} /** * Adds the having clause to the criteria * * @param mixed $having - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function having($having) {} + public function having($having): CriteriaInterface {} /** * Adds the limit parameter to the criteria. * - * + * ```php * $criteria->limit(100); * $criteria->limit(100, 200); * $criteria->limit("100", "200"); - * + * ``` * * @param int $limit - * @param mixed $offset + * @param int $offset * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function limit($limit, $offset = null) {} + public function limit(int $limit, int $offset = 0): CriteriaInterface {} /** * Adds the "for_update" parameter to the criteria @@ -332,7 +345,7 @@ public function limit($limit, $offset = null) {} * @param bool $forUpdate * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function forUpdate($forUpdate = true) {} + public function forUpdate(bool $forUpdate = true): CriteriaInterface {} /** * Adds the "shared_lock" parameter to the criteria @@ -340,54 +353,53 @@ public function forUpdate($forUpdate = true) {} * @param bool $sharedLock * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function sharedLock($sharedLock = true) {} + public function sharedLock(bool $sharedLock = true): CriteriaInterface {} /** * Sets the cache options in the criteria * This method replaces all previously set cache options * * @param array $cache - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function cache(array $cache) {} + public function cache(array $cache): CriteriaInterface {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getWhere() {} + public function getWhere(): ?string {} /** * Returns the columns to be queried * * @return string|null */ - public function getColumns() {} + public function getColumns(): ?string {} /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getConditions() {} + public function getConditions(): ?string {} /** - * Returns the limit parameter in the criteria, which will be - * an integer if limit was set without an offset, - * an array with 'number' and 'offset' keys if an offset was set with the limit, - * or null if limit has not been set. + * Returns the limit parameter in the criteria, which will be an integer if + * limit was set without an offset, an array with 'number' and 'offset' keys + * if an offset was set with the limit, or null if limit has not been set. * * @return string|null */ - public function getLimit() {} + public function getLimit(): ?string {} /** * Returns the order clause in the criteria * * @return string|null */ - public function getOrderBy() {} + public function getOrderBy(): ?string {} /** * Returns the group clause in the criteria @@ -404,38 +416,38 @@ public function getHaving() {} * * @return array */ - public function getParams() {} + public function getParams(): array {} /** * Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param string $modelName * @param array $data * @param string $operator - * @return Criteria + * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public static function fromInput(\Phalcon\DiInterface $dependencyInjector, $modelName, array $data, $operator = 'AND') {} + public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface {} /** * Creates a query builder from criteria. * - * + * ```php * $builder = Robots::query() * ->where("type = :type:") * ->bind(["type" => "mechanical"]) * ->createBuilder(); - * + * ``` * * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder() {} + public function createBuilder(): BuilderInterface {} /** * Executes a find using the parameters built with the criteria * * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function execute() {} + public function execute(): ResultsetInterface {} } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index cd77f6dc..923f16b8 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -11,29 +11,37 @@ interface CriteriaInterface { /** - * Set a model on which the query will be executed + * Appends a condition to the current conditions using an AND operator * - * @param string $modelName + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes * @return CriteriaInterface */ - public function setModelName($modelName); + public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; /** - * Returns an internal model name on which the criteria will be applied + * Appends a BETWEEN condition to the current conditions * - * @return string + * ```php + * $criteria->betweenWhere("price", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @return CriteriaInterface */ - public function getModelName(); + public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; /** * Sets the bound parameters in the criteria * This method replaces all previously set bound parameters * * @param array $bindParams - * @param bool $merge * @return CriteriaInterface */ - public function bind(array $bindParams, $merge = false); + public function bind(array $bindParams): CriteriaInterface; /** * Sets the bind types in the criteria @@ -42,17 +50,16 @@ public function bind(array $bindParams, $merge = false); * @param array $bindTypes * @return CriteriaInterface */ - public function bindTypes(array $bindTypes); + public function bindTypes(array $bindTypes): CriteriaInterface; /** - * Sets the conditions parameter in the criteria + * Sets the cache options in the criteria + * This method replaces all previously set cache options * - * @param string $conditions - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $cache * @return CriteriaInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null); + public function cache(array $cache): CriteriaInterface; /** * Adds the conditions parameter to the criteria @@ -60,24 +67,22 @@ public function where($conditions, $bindParams = null, $bindTypes = null); * @param string $conditions * @return CriteriaInterface */ - public function conditions($conditions); + public function conditions(string $conditions): CriteriaInterface; /** - * Adds the order-by parameter to the criteria + * Sets SELECT DISTINCT / SELECT ALL flag * - * @param string $orderColumns + * @param mixed $distinct * @return CriteriaInterface */ - public function orderBy($orderColumns); + public function distinct($distinct): CriteriaInterface; /** - * Sets the limit parameter to the criteria + * Executes a find using the parameters built with the criteria * - * @param int $limit - * @param int $offset - * @return CriteriaInterface + * @return ResultsetInterface */ - public function limit($limit, $offset = null); + public function execute(): ResultsetInterface; /** * Sets the "for_update" parameter to the criteria @@ -85,133 +90,237 @@ public function limit($limit, $offset = null); * @param bool $forUpdate * @return CriteriaInterface */ - public function forUpdate($forUpdate = true); + public function forUpdate(bool $forUpdate = true): CriteriaInterface; /** - * Sets the "shared_lock" parameter to the criteria + * Returns the columns to be queried * - * @param bool $sharedLock + * @return string|null + */ + public function getColumns(): ?string; + + /** + * Returns the conditions parameter in the criteria + * + * @return string|null + */ + public function getConditions(): ?string; + + /** + * Returns the group clause in the criteria + */ + public function getGroupBy(); + + /** + * Returns the having clause in the criteria + */ + public function getHaving(); + + /** + * Returns the limit parameter in the criteria, which will be an integer if + * limit was set without an offset, an array with 'number' and 'offset' keys + * if an offset was set with the limit, or null if limit has not been set. + * + * @return string|null + */ + public function getLimit(): ?string; + + /** + * Returns an internal model name on which the criteria will be applied + * + * @return string + */ + public function getModelName(): string; + + /** + * Returns the order parameter in the criteria + * + * @return string|null + */ + public function getOrderBy(): ?string; + + /** + * Returns all the parameters defined in the criteria + * + * @return array + */ + public function getParams(): array; + + /** + * Returns the conditions parameter in the criteria + * + * @return string|null + */ + public function getWhere(): ?string; + + /** + * Adds the group-by clause to the criteria + * + * @param mixed $group * @return CriteriaInterface */ - public function sharedLock($sharedLock = true); + public function groupBy($group): CriteriaInterface; /** - * Appends a condition to the current conditions using an AND operator + * Adds the having clause to the criteria * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes + * @param mixed $having * @return CriteriaInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null); + public function having($having): CriteriaInterface; /** - * Appends a condition to the current conditions using an OR operator + * Adds an INNER join to the query * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes + * ```php + * $criteria->innerJoin( + * Robots::class + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id" + * ); + * + * $criteria->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` + * + * @param string $model + * @param mixed $conditions + * @param mixed $alias * @return CriteriaInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null); + public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Appends a BETWEEN condition to the current conditions + * Appends an IN condition to the current conditions * - * - * $criteria->betweenWhere("price", 100.25, 200.50); - * + * ```php + * $criteria->inWhere("id", [1, 2, 3]); + * ``` * * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param array $values * @return CriteriaInterface */ - public function betweenWhere($expr, $minimum, $maximum); + public function inWhere(string $expr, array $values): CriteriaInterface; /** - * Appends a NOT BETWEEN condition to the current conditions + * Adds a LEFT join to the query * - * - * $criteria->notBetweenWhere("price", 100.25, 200.50); - * + * ```php + * $criteria->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param string $model + * @param mixed $conditions + * @param mixed $alias * @return CriteriaInterface */ - public function notBetweenWhere($expr, $minimum, $maximum); + public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Appends an IN condition to the current conditions + * Sets the limit parameter to the criteria * - * - * $criteria->inWhere("id", [1, 2, 3]); - * + * @param int $limit + * @param int $offset + * @return CriteriaInterface + */ + public function limit(int $limit, int $offset = 0): CriteriaInterface; + + /** + * Appends a NOT BETWEEN condition to the current conditions + * + * ```php + * $criteria->notBetweenWhere("price", 100.25, 200.50); + * ``` * * @param string $expr - * @param array $values + * @param mixed $minimum + * @param mixed $maximum * @return CriteriaInterface */ - public function inWhere($expr, array $values); + public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; /** * Appends a NOT IN condition to the current conditions * - * + * ```php * $criteria->notInWhere("id", [1, 2, 3]); - * + * ``` * * @param string $expr * @param array $values * @return CriteriaInterface */ - public function notInWhere($expr, array $values); + public function notInWhere(string $expr, array $values): CriteriaInterface; /** - * Returns the conditions parameter in the criteria + * Adds the order-by parameter to the criteria * - * @return string|null + * @param string $orderColumns + * @return CriteriaInterface */ - public function getWhere(); + public function orderBy(string $orderColumns): CriteriaInterface; /** - * Returns the conditions parameter in the criteria + * Appends a condition to the current conditions using an OR operator * - * @return string|null + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return CriteriaInterface */ - public function getConditions(); + public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; /** - * Returns the limit parameter in the criteria, which will be - * an integer if limit was set without an offset, - * an array with 'number' and 'offset' keys if an offset was set with the limit, - * or null if limit has not been set. + * Adds a RIGHT join to the query * - * @return int|array|null + * ```php + * $criteria->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` + * + * @param string $model + * @param mixed $conditions + * @param mixed $alias + * @return CriteriaInterface */ - public function getLimit(); + public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface; /** - * Returns the order parameter in the criteria + * Set a model on which the query will be executed * - * @return string|null + * @param string $modelName + * @return CriteriaInterface */ - public function getOrderBy(); + public function setModelName(string $modelName): CriteriaInterface; /** - * Returns all the parameters defined in the criteria + * Sets the "shared_lock" parameter to the criteria * - * @return array + * @param bool $sharedLock + * @return CriteriaInterface */ - public function getParams(); + public function sharedLock(bool $sharedLock = true): CriteriaInterface; /** - * Executes a find using the parameters built with the criteria + * Sets the conditions parameter in the criteria * - * @return ResultsetInterface + * @param string $conditions + * @return CriteriaInterface */ - public function execute(); + public function where(string $conditions): CriteriaInterface; } diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index f83fe1c8..a398bec4 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -5,12 +5,13 @@ /** * Phalcon\Mvc\Model\Manager * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. + * This components controls the initialization of models, keeping record of + * relations between the different models of the application. * - * A ModelsManager is injected to a model via a Dependency Injector/Services Container such as Phalcon\Di. + * A ModelsManager is injected to a model via a Dependency Injector/Services + * Container such as Phalcon\Di. * - * + * ```php * use Phalcon\Di; * use Phalcon\Mvc\Model\Manager as ModelsManager; * @@ -24,145 +25,142 @@ * ); * * $robot = new Robots($di); - * + * ``` */ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { - protected $_dependencyInjector; - - - protected $_eventsManager; + protected $aliases = array(); + /** + * Models' behaviors + */ + protected $behaviors = array(); - protected $_customEventsManager; + /** + * Belongs to relations + */ + protected $belongsTo = array(); + /** + * All the relationships by model + */ + protected $belongsToSingle = array(); - protected $_readConnectionServices; + protected $container; - protected $_writeConnectionServices; + protected $customEventsManager = array(); - protected $_aliases; + /** + * Does the model use dynamic update, instead of updating all rows? + */ + protected $dynamicUpdate = array(); - protected $_modelVisibility = array(); + protected $eventsManager; /** * Has many relations */ - protected $_hasMany; + protected $hasMany = array(); /** * Has many relations by model */ - protected $_hasManySingle; + protected $hasManySingle = array(); /** - * Has one relations + * Has many-Through relations */ - protected $_hasOne; + protected $hasManyToMany = array(); /** - * Has one relations by model + * Has many-Through relations by model */ - protected $_hasOneSingle; + protected $hasManyToManySingle = array(); /** - * Belongs to relations + * Has one relations */ - protected $_belongsTo; + protected $hasOne = array(); /** - * All the relationships by model + * Has one relations by model */ - protected $_belongsToSingle; + protected $hasOneSingle = array(); /** - * Has many-Through relations + * Mark initialized models */ - protected $_hasManyToMany; + protected $initialized = array(); + + + protected $keepSnapshots = array(); /** - * Has many-Through relations by model + * Last model initialized */ - protected $_hasManyToManySingle; + protected $lastInitialized; /** - * Mark initialized models + * Last query created/executed */ - protected $_initialized; + protected $lastQuery; - protected $_prefix = ''; + protected $modelVisibility = array(); - protected $_sources; + protected $prefix = ''; - protected $_schemas; + protected $readConnectionServices = array(); - /** - * Models' behaviors - */ - protected $_behaviors; - /** - * Last model initialized - */ - protected $_lastInitialized; + protected $sources = array(); - /** - * Last query created/executed - */ - protected $_lastQuery; - /** - * Stores a list of reusable instances - */ - protected $_reusable; + protected $schemas = array(); - protected $_keepSnapshots; + protected $writeConnectionServices = array(); /** - * Does the model use dynamic update, instead of updating all rows? + * Stores a list of reusable instances */ - protected $_dynamicUpdate; - - - protected $_namespaceAliases; + protected $reusable = array(); /** * Sets the DependencyInjector container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the DependencyInjector container * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return Manager + * @return \Phalcon\Mvc\Model\ManagerInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): ManagerInterface {} /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager() {} + public function getEventsManager(): EventsManagerInterface {} /** * Sets a custom events manager for a specific model @@ -186,73 +184,63 @@ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function initialize(\Phalcon\Mvc\ModelInterface $model) {} + public function initialize(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Check whether a model is already initialized * - * @param string $modelName + * @param string $className * @return bool */ - public function isInitialized($modelName) {} + public function isInitialized(string $className): bool {} /** * Get last initialized model * * @return \Phalcon\Mvc\ModelInterface */ - public function getLastInitialized() {} + public function getLastInitialized(): ModelInterface {} /** * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @param bool $newInstance * @return \Phalcon\Mvc\ModelInterface */ - public function load($modelName, $newInstance = false) {} + public function load(string $modelName): ModelInterface {} /** * Sets the prefix for all model sources. * - * + * ```php * use Phalcon\Mvc\Model\Manager; * - * $di->set("modelsManager", function () { - * $modelsManager = new Manager(); - * $modelsManager->setModelPrefix("wp_"); + * $di->set( + * "modelsManager", + * function () { + * $modelsManager = new Manager(); * - * return $modelsManager; - * }); + * $modelsManager->setModelPrefix("wp_"); + * + * return $modelsManager; + * } + * ); * * $robots = new Robots(); + * * echo $robots->getSource(); // wp_robots - * + * ``` * * @param string $prefix */ - public function setModelPrefix($prefix) {} + public function setModelPrefix(string $prefix) {} /** * Returns the prefix for all model sources. * - * - * use Phalcon\Mvc\Model\Manager; - * - * $di->set("modelsManager", function () { - * $modelsManager = new Manager(); - * $modelsManager->setModelPrefix("wp_"); - * - * return $modelsManager; - * }); - * - * $robots = new Robots(); - * echo $robots->getSource(); // wp_robots - * - * * @return string */ - public function getModelPrefix() {} + public function getModelPrefix(): string {} /** * Sets the mapped source for a model @@ -260,23 +248,23 @@ public function getModelPrefix() {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $source */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source) {} + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) {} /** * Check whether a model property is declared as public. * - * + * ```php * $isPublic = $manager->isVisibleModelProperty( * new Robots(), * "name" * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param string $property * @return bool */ - public final function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, $property) {} + final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool {} /** * Returns the mapped source for a model @@ -284,7 +272,7 @@ public final function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model) {} + public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} /** * Sets the mapped schema for a model @@ -292,7 +280,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema) {} + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) {} /** * Returns the mapped schema for a model @@ -300,7 +288,7 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema) {} * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model) {} + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} /** * Sets both write and read connection service for a model @@ -308,7 +296,7 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Sets write connection service for a model @@ -316,7 +304,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connec * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Sets read connection service for a model @@ -324,32 +312,32 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $c * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService) {} + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} /** * Returns the connection to read data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model) {} + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} /** * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model) {} + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} /** * Returns the connection to read or write data related to a model depending on the connection services. * * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $connectionServices - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} + protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface {} /** * Returns the connection service name used to read data related to a model @@ -357,7 +345,7 @@ protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectio * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model) {} + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns the connection service name used to write data related to a model @@ -365,7 +353,7 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model) {} + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns the connection service name used to read or write data related to @@ -375,16 +363,17 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model) {} * @param mixed $connectionServices * @return string */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices) {} + public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string {} /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Receives events generated in the models and dispatches them to an + * events-manager if available. Notify the behaviors that are listening in + * the model * * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model */ - public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model) {} + public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) {} /** * Dispatch an event to the listeners and behaviors @@ -395,7 +384,7 @@ public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model) {} * @param string $eventName * @param mixed $data */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) {} /** * Binds a behavior to a model @@ -411,7 +400,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, $keepSnapshots) {} + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) {} /** * Checks if a model is keeping snapshots for the queried records @@ -419,7 +408,7 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, $keepSnapshots * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model) {} + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Sets if a model must use dynamic update instead of the all-field update @@ -427,7 +416,7 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, $dynamicUpdate) {} + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) {} /** * Checks if a model is using dynamic update instead of all-field update @@ -435,78 +424,58 @@ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, $dynamicUpd * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model) {} + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool {} /** * Setup a 1-1 relation between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options - * @param \Phalcon\Mvc\Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setup a relation reverse many to one between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options - * @param \Phalcon\Mvc\Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setup a relation 1-n between two models * - * @param mixed fields - * @param string referencedModel - * @param mixed referencedFields - * @param array options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param mixed $options - * @param $Phalcon\Mvc\ModelInterface model - * @return \Phalcon\Mvc\Model\Relation + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null) {} + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Setups a relation n-m between two models * - * @param string fields - * @param string intermediateModel - * @param string intermediateFields - * @param string intermediateReferencedFields - * @param string referencedModel - * @param string referencedFields * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields + * @param string $fields * @param string $intermediateModel - * @param mixed $intermediateFields - * @param mixed $intermediateReferencedFields + * @param string $intermediateFields + * @param string $intermediateReferencedFields * @param string $referencedModel - * @param mixed $referencedFields + * @param string $referencedFields * @param array $options - * @param $Phalcon\Mvc\ModelInterface model - * @return \Phalcon\Mvc\Model\Relation + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, $intermediateModel, $intermediateFields, $intermediateReferencedFields, $referencedModel, $referencedFields, $options = null) {} + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} /** * Checks whether a model has a belongsTo relation with another model @@ -515,7 +484,7 @@ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, $i * @param string $modelRelation * @return bool */ - public function existsBelongsTo($modelName, $modelRelation) {} + public function existsBelongsTo(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasMany relation with another model @@ -524,7 +493,7 @@ public function existsBelongsTo($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasMany($modelName, $modelRelation) {} + public function existsHasMany(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasOne relation with another model @@ -533,7 +502,7 @@ public function existsHasMany($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasOne($modelName, $modelRelation) {} + public function existsHasOne(string $modelName, string $modelRelation): bool {} /** * Checks whether a model has a hasManyToMany relation with another model @@ -542,16 +511,16 @@ public function existsHasOne($modelName, $modelRelation) {} * @param string $modelRelation * @return bool */ - public function existsHasManyToMany($modelName, $modelRelation) {} + public function existsHasManyToMany(string $modelName, string $modelRelation): bool {} /** * Returns a relation by its alias * * @param string $modelName * @param string $alias - * @return bool|\Phalcon\Mvc\Model\Relation + * @return bool|\Phalcon\Mvc\Model\RelationInterface */ - public function getRelationByAlias($modelName, $alias) {} + public function getRelationByAlias(string $modelName, string $alias) {} /** * Merge two arrays of find parameters @@ -560,18 +529,18 @@ public function getRelationByAlias($modelName, $alias) {} * @param mixed $findParamsTwo * @return array */ - protected final function _mergeFindParameters($findParamsOne, $findParamsTwo) {} + final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): array {} /** * Helper method to query records based on a relation definition * * @param \Phalcon\Mvc\Model\RelationInterface $relation - * @param string $method * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, $method, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Returns a reusable object from the internal list @@ -579,7 +548,7 @@ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relatio * @param string $modelName * @param string $key */ - public function getReusableRecords($modelName, $key) {} + public function getReusableRecords(string $modelName, string $key) {} /** * Stores a reusable record in the internal list @@ -588,7 +557,7 @@ public function getReusableRecords($modelName, $key) {} * @param string $key * @param mixed $records */ - public function setReusableRecords($modelName, $key, $records) {} + public function setReusableRecords(string $modelName, string $key, $records) {} /** * Clears the internal reusable list @@ -598,52 +567,52 @@ public function clearReusableObjects() {} /** * Gets belongsTo related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets hasMany related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets belongsTo related records from a model * - * @param string $method * @param string $modelName - * @param mixed $modelRelation + * @param string $modelRelation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters + * @param string $method * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null) {} + public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} /** * Gets all the belongsTo relations defined in a model * - * + * ```php * $relations = $modelsManager->getBelongsTo( * new Robots() * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model) {} + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasMany relations defined on a model @@ -651,7 +620,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasOne relations defined on a model @@ -659,7 +628,7 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasManyToMany relations defined on a model @@ -667,32 +636,32 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model) {} + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array {} /** * Query all the relationships defined on a model * * @param string $modelName - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelations($modelName) {} + public function getRelations(string $modelName): array {} /** * Query the first relationship defined between two models * * @param string $first * @param string $second - * @return bool|\Phalcon\Mvc\Model\RelationInterface[] + * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelationsBetween($first, $second) {} + public function getRelationsBetween(string $first, string $second) {} /** * Creates a Phalcon\Mvc\Model\Query without execute it @@ -700,7 +669,7 @@ public function getRelationsBetween($first, $second) {} * @param string $phql * @return \Phalcon\Mvc\Model\QueryInterface */ - public function createQuery($phql) {} + public function createQuery(string $phql): QueryInterface {} /** * Creates a Phalcon\Mvc\Model\Query and execute it @@ -710,7 +679,7 @@ public function createQuery($phql) {} * @param mixed $types * @return \Phalcon\Mvc\Model\QueryInterface */ - public function executeQuery($phql, $placeholders = null, $types = null) {} + public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface {} /** * Creates a Phalcon\Mvc\Model\Query\Builder @@ -718,37 +687,14 @@ public function executeQuery($phql, $placeholders = null, $types = null) {} * @param mixed $params * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder($params = null) {} + public function createBuilder($params = null): BuilderInterface {} /** * Returns the last query created or executed in the models manager * * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getLastQuery() {} - - /** - * Registers shorter aliases for namespaces in PHQL statements - * - * @param string $alias - * @param string $namespaceName - */ - public function registerNamespaceAlias($alias, $namespaceName) {} - - /** - * Returns a real namespace from its alias - * - * @param string $alias - * @return string - */ - public function getNamespaceAlias($alias) {} - - /** - * Returns all the registered namespace aliases - * - * @return array - */ - public function getNamespaceAliases() {} + public function getLastQuery(): QueryInterface {} /** * Destroys the current PHQL cache diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 27bc4070..9cd12efc 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -11,331 +11,362 @@ interface ManagerInterface { /** - * Initializes a model in the model manager + * Binds a behavior to a model * * @param \Phalcon\Mvc\ModelInterface $model + * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function initialize(\Phalcon\Mvc\ModelInterface $model); + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); /** - * Sets the mapped source for a model + * Setup a relation reverse 1-1 between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $source + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, $source); + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Returns the mapped source for a model + * Setup a relation 1-n between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model); + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Sets the mapped schema for a model + * Setup a 1-1 relation between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $schema + * @param mixed $fields + * @param string $referencedModel + * @param mixed $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, $schema); + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Returns the mapped schema for a model + * Setups a relation n-m between two models * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $fields + * @param string $intermediateModel + * @param string $intermediateFields + * @param string $intermediateReferencedFields + * @param string $referencedModel + * @param string $referencedFields + * @param array $options + * @return \Phalcon\Mvc\Model\RelationInterface */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model); + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** - * Sets both write and read connection service for a model + * Creates a Phalcon\Mvc\Model\Query\Builder * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $params + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function createBuilder($params = null): BuilderInterface; /** - * Sets read connection service for a model + * Creates a Phalcon\Mvc\Model\Query without execute it * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $phql + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function createQuery(string $phql): QueryInterface; /** - * Returns the connection service name used to read data related to a model + * Creates a Phalcon\Mvc\Model\Query and execute it * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $phql + * @param array $placeholders + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model); + public function executeQuery(string $phql, $placeholders = null): QueryInterface; /** - * Sets write connection service for a model + * Checks whether a model has a belongsTo relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $connectionService + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionService); + public function existsBelongsTo(string $modelName, string $modelRelation): bool; /** - * Returns the connection service name used to write data related to a model + * Checks whether a model has a hasMany relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model); + public function existsHasMany(string $modelName, string $modelRelation): bool; /** - * Returns the connection to read data related to a model + * Checks whether a model has a hasOne relation with another model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @param string $modelName + * @param string $modelRelation + * @return bool */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model); + public function existsHasOne(string $modelName, string $modelRelation): bool; /** - * Returns the connection to write data related to a model + * Checks whether a model has a hasManyToMany relation with another model + * + * @param string $modelName + * @param string $modelRelation + * @return bool + */ + public function existsHasManyToMany(string $modelName, string $modelRelation): bool; + + /** + * Gets belongsTo relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\AdapterInterface + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model); + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; /** - * Check of a model is already initialized + * Gets belongsTo related records from a model * * @param string $modelName - * @return bool + * @param string $modelRelation + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|ResultsetInterface */ - public function isInitialized($modelName); + public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Get last initialized model + * Gets hasMany relations defined on a model * - * @return \Phalcon\Mvc\ModelInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getLastInitialized(); + public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Loads a model throwing an exception if it doesn't exist + * Gets hasMany related records from a model * * @param string $modelName - * @param bool $newInstance - * @return \Phalcon\Mvc\ModelInterface + * @param string $modelRelation + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|ResultsetInterface */ - public function load($modelName, $newInstance = false); + public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Setup a 1-1 relation between two models + * Gets hasManyToMany relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @return \Phalcon\Mvc\Model\RelationInterface + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Setup a relation reverse 1-1 between two models + * Gets hasOne relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @param $\Phalcon\Mvc\ModelInterface $model - * @return + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; /** - * Setup a relation 1-n between two models + * Gets hasOne relations defined on a model * - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $fields - * @param string $referencedModel - * @param mixed $referencedFields - * @param mixed $options - * @param $\Phalcon\Mvc\ModelInterface $model - * @return + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, $referencedModel, $referencedFields, $options = null); + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Checks whether a model has a belongsTo relation with another model + * Gets belongsTo related records from a model * * @param string $modelName * @param string $modelRelation - * @param $string $modelRelation - * @return + * @param ModelInterface $record + * @param array|string|null $parameters + * @param string|null $method + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function existsBelongsTo($modelName, $modelRelation); + public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Checks whether a model has a hasMany relation with another model + * Get last initialized model * - * @param string $modelName - * @param string $modelRelation - * @param $string $modelRelation - * @return + * @return \Phalcon\Mvc\ModelInterface */ - public function existsHasMany($modelName, $modelRelation); + public function getLastInitialized(): ModelInterface; /** - * Checks whether a model has a hasOne relation with another model + * Returns the last query created or executed in the models manager * - * @param string $modelName - * @param string $modelRelation - * @param $string $modelRelation - * @return + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function existsHasOne($modelName, $modelRelation); + public function getLastQuery(): QueryInterface; /** - * Gets belongsTo related records from a model + * Returns the mapped schema for a model * - * @param string $method - * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return string */ - public function getBelongsToRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string; /** - * Gets hasMany related records from a model + * Returns the mapped source for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return string + */ + public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string; + + /** + * Returns the connection to read data related to a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return \Phalcon\Db\Adapter\AdapterInterface + */ + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + + /** + * Returns the connection service name used to read data related to a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return string + */ + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + + /** + * Returns a relation by its alias * - * @param string $method * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @param string $alias + * @return bool|Relation */ - public function getHasManyRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getRelationByAlias(string $modelName, string $alias); /** - * Gets belongsTo related records from a model + * Helper method to query records based on a relation definition * + * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @param \Phalcon\Mvc\ModelInterface $record + * @param mixed $parameters * @param string $method - * @param string $modelName - * @param string $modelRelation - * @param \Phalcon\Mvc\Model $record - * @param array $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getHasOneRecords($method, $modelName, $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null); + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** - * Gets belongsTo relations defined on a model + * Query all the relationships defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $modelName + * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model); + public function getRelations(string $modelName): array; /** - * Gets hasMany relations defined on a model + * Query the relations between two models * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $first + * @param string $second + * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model); + public function getRelationsBetween(string $first, string $second); /** - * Gets hasOne relations defined on a model + * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model); + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; /** - * Gets hasOne relations defined on a model + * Returns the connection service name used to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model); + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string; /** - * Query all the relationships defined on a model + * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @return \Phalcon\Mvc\Model\RelationInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getRelations($modelName); + public function load(string $modelName): ModelInterface; /** - * Query the relations between two models + * Initializes a model in the model manager * - * @param string $first - * @param string $second - * @return array + * @param \Phalcon\Mvc\ModelInterface $model */ - public function getRelationsBetween($first, $second); + public function initialize(\Phalcon\Mvc\ModelInterface $model); /** - * Creates a Phalcon\Mvc\Model\Query without execute it + * Check of a model is already initialized * - * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @param string $className + * @return bool */ - public function createQuery($phql); + public function isInitialized(string $className): bool; /** - * Creates a Phalcon\Mvc\Model\Query and execute it + * Checks if a model is keeping snapshots for the queried records * - * @param string $phql - * @param array $placeholders - * @param array $types - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return bool */ - public function executeQuery($phql, $placeholders = null, $types = null); + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool; /** - * Creates a Phalcon\Mvc\Model\Query\Builder + * Checks if a model is using dynamic update instead of all-field update * - * @param string $params - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return bool */ - public function createBuilder($params = null); + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; /** - * Binds a behavior to a model + * Check whether a model property is declared as public. + * + * ```php + * $isPublic = $manager->isVisibleModelProperty( + * new Robots(), + * "name" + * ); + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @param string $property + * @return bool */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); + final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model + * Sets if a model must keep snapshots * - * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model + * @param bool $keepSnapshots */ - public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model); + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); /** * Dispatch an event to the listeners and behaviors @@ -345,24 +376,65 @@ public function notifyEvent($eventName, \Phalcon\Mvc\ModelInterface $model); * @param \Phalcon\Mvc\ModelInterface $model * @param string $eventName * @param array $data - * @return boolean + * @return bool */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, $eventName, $data); + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); /** - * Returns the last query created or executed in the models manager + * Receives events generated in the models and dispatches them to an events-manager if available + * Notify the behaviors that are listening in the model * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param string $eventName + * @param \Phalcon\Mvc\ModelInterface $model */ - public function getLastQuery(); + public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model); /** - * Returns a relation by its alias + * Sets both write and read connection service for a model * - * @param string $modelName - * @param string $alias - * @return \Phalcon\Mvc\Model\Relation + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets read connection service for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets the mapped schema for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $schema + */ + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); + + /** + * Sets the mapped source for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $source + */ + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); + + /** + * Sets write connection service for a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $connectionService + */ + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + + /** + * Sets if a model must use dynamic update instead of the all-field update + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param bool $dynamicUpdate */ - public function getRelationByAlias($modelName, $alias); + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); } diff --git a/src/Phalcon/mvc/model/Message.php b/src/Phalcon/mvc/model/Message.php deleted file mode 100644 index 971efcd9..00000000 --- a/src/Phalcon/mvc/model/Message.php +++ /dev/null @@ -1,147 +0,0 @@ - - * use Phalcon\Mvc\Model\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $text = "A robot cannot be named Peter"; - * $field = "name"; - * $type = "InvalidValue"; - * - * $message = new Message($text, $field, $type); - * - * $this->appendMessage($message); - * } - * } - * } - * - */ -class Message implements \Phalcon\Mvc\Model\MessageInterface -{ - /** - * @var string - */ - protected $_type; - - /** - * @var string - */ - protected $_message; - - - protected $_field; - - - protected $_model; - - - protected $_code; - - - /** - * @return string - */ - public function getType() {} - - /** - * @return string - */ - public function getMessage() {} - - /** - * Phalcon\Mvc\Model\Message constructor - * - * @param string $message - * @param string|array $field - * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model - * @param int|null $code - */ - public function __construct($message, $field = null, $type = null, $model = null, $code = null) {} - - /** - * Sets message type - * - * @param string $type - * @return Message - */ - public function setType($type) {} - - /** - * Sets verbose message - * - * @param string $message - * @return Message - */ - public function setMessage($message) {} - - /** - * Sets field name related to message - * - * @param mixed $field - * @return Message - */ - public function setField($field) {} - - /** - * Returns field name related to message - */ - public function getField() {} - - /** - * Set the model who generates the message - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return Message - */ - public function setModel(\Phalcon\Mvc\ModelInterface $model) {} - - /** - * Sets code for the message - * - * @param int $code - * @return Message - */ - public function setCode($code) {} - - /** - * Returns the model that produced the message - * - * @return \Phalcon\Mvc\ModelInterface - */ - public function getModel() {} - - /** - * Returns the message code - * - * @return int - */ - public function getCode() {} - - /** - * Magic __toString method returns verbose message - * - * @return string - */ - public function __toString() {} - - /** - * Magic __set_state helps to re-build messages variable exporting - * - * @param array $message - * @return \Phalcon\Mvc\Model\MessageInterface - */ - public static function __set_state(array $message) {} - -} diff --git a/src/Phalcon/mvc/model/MessageInterface.php b/src/Phalcon/mvc/model/MessageInterface.php deleted file mode 100644 index ffdb410e..00000000 --- a/src/Phalcon/mvc/model/MessageInterface.php +++ /dev/null @@ -1,70 +0,0 @@ -Because Phalcon\Mvc\Model requires meta-data like field names, data types, primary keys, etc. - * this component collect them and store for further querying by Phalcon\Mvc\Model. - * Phalcon\Mvc\Model\MetaData can also use adapters to store temporarily or permanently the meta-data.

+ * Because Phalcon\Mvc\Model requires meta-data like field names, data types, + * primary keys, etc. This component collect them and store for further + * querying by Phalcon\Mvc\Model. Phalcon\Mvc\Model\MetaData can also use + * adapters to store temporarily or permanently the meta-data. * - *

A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes:

+ * A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes: * - * + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Memory(); * * $attributes = $metaData->getAttributes( @@ -19,7 +20,7 @@ * ); * * print_r($attributes); - * + * ``` */ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface { @@ -27,357 +28,431 @@ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon const MODELS_ATTRIBUTES = 0; - const MODELS_PRIMARY_KEY = 1; + const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; - const MODELS_NON_PRIMARY_KEY = 2; + const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; - const MODELS_NOT_NULL = 3; + const MODELS_COLUMN_MAP = 0; - const MODELS_DATA_TYPES = 4; + const MODELS_DATE_AT = 6; - const MODELS_DATA_TYPES_NUMERIC = 5; + const MODELS_DATE_IN = 7; - const MODELS_DATE_AT = 6; + const MODELS_DATA_TYPES = 4; - const MODELS_DATE_IN = 7; + const MODELS_DATA_TYPES_BIND = 9; - const MODELS_IDENTITY_COLUMN = 8; + const MODELS_DATA_TYPES_NUMERIC = 5; - const MODELS_DATA_TYPES_BIND = 9; + const MODELS_DEFAULT_VALUES = 12; - const MODELS_AUTOMATIC_DEFAULT_INSERT = 10; + const MODELS_EMPTY_STRING_VALUES = 13; - const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11; + const MODELS_IDENTITY_COLUMN = 8; - const MODELS_DEFAULT_VALUES = 12; + const MODELS_NON_PRIMARY_KEY = 2; - const MODELS_EMPTY_STRING_VALUES = 13; + const MODELS_NOT_NULL = 3; - const MODELS_COLUMN_MAP = 0; + const MODELS_PRIMARY_KEY = 1; const MODELS_REVERSE_COLUMN_MAP = 1; + /** + * @var CacheAdapterInterface + */ + protected $adapter; + - protected $_dependencyInjector; + protected $columnMap; - protected $_strategy; + protected $container; - protected $_metaData; + protected $metaData = array(); - protected $_columnMap; + protected $strategy; /** - * Initialize the metadata for certain table + * Returns table attributes names (fields) + * + * ```php + * print_r( + * $metaData->getAttributes( + * new Robots() + * ) + * ); + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param mixed $key - * @param mixed $table - * @param mixed $schema + * @return array */ - protected final function _initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} + public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Sets the DependencyInjector container + * Returns attributes that must be ignored from the INSERT SQL generation * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container + * ```php + * print_r( + * $metaData->getAutomaticCreateAttributes( + * new Robots() + * ) + * ); + * ``` * - * @return \Phalcon\DiInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getDI() {} + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Set the meta-data extraction strategy + * Returns attributes that must be ignored from the UPDATE SQL generation * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy - */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} - - /** - * Return the strategy to obtain the meta-data + * ```php + * print_r( + * $metaData->getAutomaticUpdateAttributes( + * new Robots() + * ) + * ); + * ``` * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getStrategy() {} + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads the complete meta-data for certain model + * Returns attributes and their bind data types * - * + * ```php * print_r( - * $metaData->readMetaData( + * $metaData->getBindTypes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public final function readMetaData(\Phalcon\Mvc\ModelInterface $model) {} + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads meta-data for certain model + * Returns the column map if any * - * + * ```php * print_r( - * $metaData->readMetaDataIndex( - * new Robots(), - * 0 + * $metaData->getColumnMap( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public final function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Writes meta-data for certain model using a MODEL_ constant + * Returns attributes (which have default values) and their default values * - * + * ```php * print_r( - * $metaData->writeColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP, - * [ - * "leName" => "name", - * ] + * $metaData->getDefaultValues( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * @return array */ - public final function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data) {} + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads the ordered/reversed column map for certain model + * Returns attributes and their data types * - * + * ```php * print_r( - * $metaData->readColumnMap( + * $metaData->getDataTypes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public final function readColumnMap(\Phalcon\Mvc\ModelInterface $model) {} + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Reads column-map information for certain model using a MODEL_ constant + * Returns attributes which types are numerical * - * + * ```php * print_r( - * $metaData->readColumnMapIndex( - * new Robots(), - * MetaData::MODELS_REVERSE_COLUMN_MAP + * $metaData->getDataTypesNumeric( + * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public final function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index) {} + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns table attributes names (fields) + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns attributes allow empty strings * - * + * ```php * print_r( - * $metaData->getAttributes( + * $metaData->getEmptyStringAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns an array of fields which are part of the primary key + * Returns the name of identity field (if one is present) * - * + * ```php * print_r( - * $metaData->getPrimaryKeyAttributes( + * $metaData->getIdentityField( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string {} /** * Returns an array of fields which are not part of the primary key * - * + * ```php * print_r( * $metaData->getNonPrimaryKeyAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** * Returns an array of not null attributes * - * + * ```php * print_r( * $metaData->getNotNullAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes and their data types + * Returns an array of fields which are part of the primary key * - * + * ```php * print_r( - * $metaData->getDataTypes( + * $metaData->getPrimaryKeyAttributes( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model) {} + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes which types are numerical + * Returns the reverse column map if any * - * + * ```php * print_r( - * $metaData->getDataTypesNumeric( + * $metaData->getReverseColumnMap( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model) {} + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns the name of identity field (if one is present) + * Return the strategy to obtain the meta-data * - * + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + */ + public function getStrategy(): StrategyInterface {} + + /** + * Check if a model has certain attribute + * + * ```php + * var_dump( + * $metaData->hasAttribute( + * new Robots(), + * "name" + * ) + * ); + * ``` + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $attribute + * @return bool + */ + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool {} + + /** + * Checks if the internal meta-data container is empty + * + * ```php + * var_dump( + * $metaData->isEmpty() + * ); + * ``` + * + * @return bool + */ + public function isEmpty(): bool {} + + /** + * Reads metadata from the adapter + * + * @param string $key + * @return array|null + */ + public function read(string $key): ?array {} + + /** + * Reads the ordered/reversed column map for certain model + * + * ```php * print_r( - * $metaData->getIdentityField( + * $metaData->readColumnMap( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model) {} + final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array {} /** - * Returns attributes and their bind data types + * Reads column-map information for certain model using a MODEL_ constant * - * + * ```php * print_r( - * $metaData->getBindTypes( - * new Robots() + * $metaData->readColumnMapIndex( + * new Robots(), + * MetaData::MODELS_REVERSE_COLUMN_MAP * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Reads the complete meta-data for certain model * - * + * ```php * print_r( - * $metaData->getAutomaticCreateAttributes( + * $metaData->readMetaData( * new Robots() * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array {} /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Reads meta-data for certain model * - * + * ```php * print_r( - * $metaData->getAutomaticUpdateAttributes( - * new Robots() + * $metaData->readMetaDataIndex( + * new Robots(), + * 0 * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model) {} + final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} + + /** + * Resets internal meta-data in order to regenerate it + * + * ```php + * $metaData->reset(); + * ``` + */ + public function reset() {} /** * Set the attributes that must be ignored from the INSERT SQL generation * - * + * ```php * $metaData->setAutomaticCreateAttributes( * new Robots(), * [ * "created_at" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -387,14 +462,14 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that must be ignored from the UPDATE SQL generation * - * + * ```php * $metaData->setAutomaticUpdateAttributes( * new Robots(), * [ * "modified_at" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -404,14 +479,14 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, /** * Set the attributes that allow empty string values * - * + * ```php * $metaData->setEmptyStringAttributes( * new Robots(), * [ * "name" => true, * ] * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes @@ -419,107 +494,63 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} /** - * Returns attributes allow empty strings - * - * - * print_r( - * $metaData->getEmptyStringAttributes( - * new Robots() - * ) - * ); - * + * Sets the DependencyInjector container * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param \Phalcon\Di\DiInterface $container */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Returns attributes (which have default values) and their default values - * - * - * print_r( - * $metaData->getDefaultValues( - * new Robots() - * ) - * ); - * + * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model) {} + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} /** - * Returns the column map if any - * - * - * print_r( - * $metaData->getColumnMap( - * new Robots() - * ) - * ); - * + * Writes the metadata to adapter * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $key + * @param array $data */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model) {} + public function write(string $key, array $data) {} /** - * Returns the reverse column map if any + * Writes meta-data for certain model using a MODEL_ constant * - * + * ```php * print_r( - * $metaData->getReverseColumnMap( - * new Robots() - * ) - * ); - * - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array - */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model) {} - - /** - * Check if a model has certain attribute - * - * - * var_dump( - * $metaData->hasAttribute( + * $metaData->writeColumnMapIndex( * new Robots(), - * "name" + * MetaData::MODELS_REVERSE_COLUMN_MAP, + * [ + * "leName" => "name", + * ] * ) * ); - * + * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool + * @param int $index + * @param mixed $data */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute) {} + final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) {} /** - * Checks if the internal meta-data container is empty - * - * - * var_dump( - * $metaData->isEmpty() - * ); - * + * Initialize the metadata for certain table * - * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @param mixed $key + * @param mixed $table + * @param mixed $schema */ - public function isEmpty() {} + final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} /** - * Resets internal meta-data in order to regenerate it + * Throws an exception when the metadata cannot be written * - * - * $metaData->reset(); - * + * @param mixed $option */ - public function reset() {} + private function throwWriteException($option) {} } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index 502ec310..bea647c2 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -11,225 +11,225 @@ interface MetaDataInterface { /** - * Set the meta-data extraction strategy + * Returns table attributes names (fields) * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); + public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Return the strategy to obtain the meta-data + * Returns attributes that must be ignored from the INSERT SQL generation * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @param \Phalcon\Mvc\ModelInterface $model + * @return array */ - public function getStrategy(); + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads meta-data for certain model + * Returns attributes that must be ignored from the UPDATE SQL generation * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function readMetaData(\Phalcon\Mvc\ModelInterface $model); + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads meta-data for certain model using a MODEL_ constant + * Returns attributes and their bind data types * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @return mixed + * @return array */ - public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index); + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Writes meta-data for certain model using a MODEL_ constant + * Returns the column map if any * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index - * @param mixed $data + * @return array */ - public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, $index, $data); + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads the ordered/reversed column map for certain model + * Returns attributes (which have default values) and their default values * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function readColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array; /** - * Reads column-map information for certain model using a MODEL_ constant + * Returns attributes and their data types * * @param \Phalcon\Mvc\ModelInterface $model - * @param int $index + * @return array */ - public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, $index); + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns table attributes names (fields) + * Returns attributes which types are numerical * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns an array of fields which are part of the primary key + * Returns attributes allow empty strings * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns an array of fields which are not part of the primary key + * Returns the name of identity field (if one is present) * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return string */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string; /** - * Returns an array of not null attributes + * Returns an array of fields which are not part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model); + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes and their data types + * Returns an array of not null attributes * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model); + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes which types are numerical + * Returns an array of fields which are part of the primary key * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model); + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns the name of identity field (if one is present) + * Returns the reverse column map if any * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return array */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model); + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes and their bind data types + * Return the strategy to obtain the meta-data * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model); + public function getStrategy(): StrategyInterface; /** - * Returns attributes that must be ignored from the INSERT SQL generation + * Check if a model has certain attribute * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param string $attribute + * @return bool */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model); + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool; /** - * Returns attributes that must be ignored from the UPDATE SQL generation + * Checks if the internal meta-data container is empty * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return bool */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model); + public function isEmpty(): bool; /** - * Set the attributes that must be ignored from the INSERT SQL generation + * Reads meta-data from the adapter * - * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @param string $key + * @return array|null */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function read(string $key): ?array; /** - * Set the attributes that must be ignored from the UPDATE SQL generation + * Reads the ordered/reversed column map for certain model * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @return array|null */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array; /** - * Set the attributes that allow empty string values + * Reads column-map information for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @param array $attributes + * @param int $index */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index); /** - * Returns attributes allow empty strings + * Reads meta-data for certain model * * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model); + public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array; /** - * Returns attributes (which have default values) and their default values + * Reads meta-data for certain model using a MODEL_ constant * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param int $index + * @return mixed */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model); + public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index); /** - * Returns the column map if any - * - * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * Resets internal meta-data in order to regenerate it */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function reset(); /** - * Returns the reverse column map if any + * Set the attributes that must be ignored from the INSERT SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @param array $attributes */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model); + public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Check if a model has certain attribute + * Set the attributes that must be ignored from the UPDATE SQL generation * * @param \Phalcon\Mvc\ModelInterface $model - * @param string $attribute - * @return bool + * @param array $attributes */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, $attribute); + public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Checks if the internal meta-data container is empty + * Set the attributes that allow empty string values * - * @return boolean + * @param \Phalcon\Mvc\ModelInterface $model + * @param array $attributes */ - public function isEmpty(); + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); /** - * Resets internal meta-data in order to regenerate it + * Writes meta-data for certain model using a MODEL_ constant + * + * @param \Phalcon\Mvc\ModelInterface $model + * @param int $index + * @param mixed $data */ - public function reset(); + public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data); /** - * Reads meta-data from the adapter + * Set the meta-data extraction strategy * - * @param string $key - * @return array + * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function read($key); + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); /** * Writes meta-data to the adapter @@ -237,6 +237,6 @@ public function read($key); * @param string $key * @param array $data */ - public function write($key, $data); + public function write(string $key, array $data); } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index dd7594e6..5d33d3c1 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -7,7 +7,7 @@ * * This class takes a PHQL intermediate representation and executes it. * - * + * ```php * $phql = "SELECT c.price0.16 AS taxes, c. FROM Cars AS c JOIN Brands AS b * WHERE b.name = :name: ORDER BY c.name"; * @@ -49,103 +49,107 @@ * $resultWithEntries = $queryWithTransaction->execute(); * * $queryWithOutTransaction = new Query($phql, $di); - * $resultWithOutEntries = $queryWithTransaction->execute() - * - * + * $resultWithOutEntries = $queryWithTransaction->execute(); + * ``` */ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { - const TYPE_SELECT = 309; + const TYPE_DELETE = 303; const TYPE_INSERT = 306; + const TYPE_SELECT = 309; + + const TYPE_UPDATE = 300; - const TYPE_DELETE = 303; + protected $ast; + + protected $bindParams; - protected $_dependencyInjector; + protected $bindTypes; - protected $_manager; + protected $cache; - protected $_metaData; + protected $cacheOptions; - protected $_type; + protected $container; - protected $_phql; + protected $enableImplicitJoins; - protected $_ast; + protected $intermediate; - protected $_intermediate; + protected $manager; - protected $_models; + protected $metaData; - protected $_sqlAliases; + protected $models; - protected $_sqlAliasesModels; + protected $modelsInstances; - protected $_sqlModelsAliases; + protected $nestingLevel = -1; - protected $_sqlAliasesModelsInstances; + protected $phql; - protected $_sqlColumnAliases; + protected $sharedLock; - protected $_modelsInstances; + protected $sqlAliases; - protected $_cache; + protected $sqlAliasesModels; - protected $_cacheOptions; + protected $sqlAliasesModelsInstances; - protected $_uniqueRow; + protected $sqlColumnAliases = array(); - protected $_bindParams; + protected $sqlModelsAliases; - protected $_bindTypes; + protected $type; - protected $_enableImplicitJoins; + protected $uniqueRow; - protected $_sharedLock; + + static protected $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local transaction instead of this one + * however if a model got a transaction set inside it will use the local + * transaction instead of this one */ protected $_transaction; - static protected $_irPhqlCache; - - /** * TransactionInterface so that the query can wrap a transaction * * around batch updates and intermediate selects within the transaction. - * however if a model got a transaction set inside it will use the local transaction instead of this one + * however if a model got a transaction set inside it will use the local + * transaction instead of this one */ public function getTransaction() {} @@ -153,47 +157,50 @@ public function getTransaction() {} * Phalcon\Mvc\Model\Query constructor * * @param string $phql - * @param \Phalcon\DiInterface $dependencyInjector - * @param mixed $options + * @param \Phalcon\Di\DiInterface $container + * @param array $options */ - public function __construct($phql = null, \Phalcon\DiInterface $dependencyInjector = null, $options = null) {} + public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) {} /** * Sets the dependency injection container * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Returns the dependency injection container * - * @return \Phalcon\DiInterface + * @return \Phalcon\Di\DiInterface */ - public function getDI() {} + public function getDI(): DiInterface {} /** - * Tells to the query if only the first row in the resultset must be returned + * Tells to the query if only the first row in the resultset must be + * returned * * @param bool $uniqueRow - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setUniqueRow($uniqueRow) {} + public function setUniqueRow(bool $uniqueRow): QueryInterface {} /** - * Check if the query is programmed to get only the first row in the resultset + * Check if the query is programmed to get only the first row in the + * resultset * * @return bool */ - public function getUniqueRow() {} + public function getUniqueRow(): bool {} /** - * Replaces the model's name to its source name in a qualified-name expression + * Replaces the model's name to its source name in a qualified-name + * expression * * @param array $expr * @return array */ - protected final function _getQualified(array $expr) {} + final protected function _getQualified(array $expr): array {} /** * Resolves an expression in a single call argument @@ -201,7 +208,7 @@ protected final function _getQualified(array $expr) {} * @param array $argument * @return array */ - protected final function _getCallArgument(array $argument) {} + final protected function _getCallArgument(array $argument): array {} /** * Resolves an expression in a single call argument @@ -209,7 +216,7 @@ protected final function _getCallArgument(array $argument) {} * @param array $expr * @return array */ - protected final function _getCaseExpression(array $expr) {} + final protected function _getCaseExpression(array $expr): array {} /** * Resolves an expression in a single call argument @@ -217,25 +224,25 @@ protected final function _getCaseExpression(array $expr) {} * @param array $expr * @return array */ - protected final function _getFunctionCall(array $expr) {} + final protected function _getFunctionCall(array $expr): array {} /** * Resolves an expression from its intermediate code into a string * * @param array $expr - * @param boolean $quoting + * @param bool $quoting * @return string */ - protected final function _getExpression($expr, $quoting = true) {} + final protected function _getExpression(array $expr, bool $quoting = true): string {} /** - * Resolves a column from its intermediate representation into an array used to determine - * if the resultset produced is simple or complex + * Resolves a column from its intermediate representation into an array + * used to determine if the resultset produced is simple or complex * * @param array $column * @return array */ - protected final function _getSelectColumn(array $column) {} + final protected function _getSelectColumn(array $column): array {} /** * Resolves a table in a SELECT statement checking if the model exists @@ -244,16 +251,16 @@ protected final function _getSelectColumn(array $column) {} * @param array $qualifiedName * @return string */ - protected final function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, $qualifiedName) {} + final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) {} /** * Resolves a JOIN clause checking if the associated models exist * * @param \Phalcon\Mvc\Model\ManagerInterface $manager - * @param mixed $join + * @param array $join * @return array */ - protected final function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, $join) {} + final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array {} /** * Resolves a JOIN type @@ -261,7 +268,7 @@ protected final function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, * @param array $join * @return string */ - protected final function _getJoinType($join) {} + final protected function _getJoinType(array $join): string {} /** * Resolves joins involving has-one/belongs-to/has-many relations @@ -273,7 +280,7 @@ protected final function _getJoinType($join) {} * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - protected final function _getSingleJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} + final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} /** * Resolves joins involving many-to-many relations @@ -285,15 +292,16 @@ protected final function _getSingleJoin($joinType, $joinSource, $modelAlias, $jo * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - protected final function _getMultiJoin($joinType, $joinSource, $modelAlias, $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation) {} + final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} /** - * Processes the JOINs in the query returning an internal representation for the database dialect + * Processes the JOINs in the query returning an internal representation for + * the database dialect * * @param array $select * @return array */ - protected final function _getJoins($select) {} + final protected function _getJoins(array $select): array {} /** * Returns a processed order clause for a SELECT statement @@ -301,7 +309,7 @@ protected final function _getJoins($select) {} * @param array|string $order * @return array */ - protected final function _getOrderClause($order) {} + final protected function _getOrderClause($order): array {} /** * Returns a processed group clause for a SELECT statement @@ -309,7 +317,7 @@ protected final function _getOrderClause($order) {} * @param array $group * @return array */ - protected final function _getGroupClause(array $group) {} + final protected function _getGroupClause(array $group): array {} /** * Returns a processed limit clause for a SELECT statement @@ -317,96 +325,104 @@ protected final function _getGroupClause(array $group) {} * @param array $limitClause * @return array */ - protected final function _getLimitClause(array $limitClause) {} + final protected function _getLimitClause(array $limitClause): array {} /** * Analyzes a SELECT intermediate code and produces an array to be executed later * * @param mixed $ast - * @param mixed $merge + * @param bool $merge * @return array */ - protected final function _prepareSelect($ast = null, $merge = null) {} + final protected function _prepareSelect($ast = null, bool $merge = false): array {} /** - * Analyzes an INSERT intermediate code and produces an array to be executed later + * Analyzes an INSERT intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareInsert() {} + final protected function _prepareInsert(): array {} /** - * Analyzes an UPDATE intermediate code and produces an array to be executed later + * Analyzes an UPDATE intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareUpdate() {} + final protected function _prepareUpdate(): array {} /** - * Analyzes a DELETE intermediate code and produces an array to be executed later + * Analyzes a DELETE intermediate code and produces an array to be executed + * later * * @return array */ - protected final function _prepareDelete() {} + final protected function _prepareDelete(): array {} /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another - * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang + * generating another intermediate representation that could be executed by + * Phalcon\Mvc\Model\Query * * @return array */ - public function parse() {} + public function parse(): array {} /** * Returns the current cache backend instance * - * @return \Phalcon\Cache\BackendInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function getCache() {} + public function getCache(): AdapterInterface {} /** - * Executes the SELECT intermediate representation producing a Phalcon\Mvc\Model\Resultset + * Executes the SELECT intermediate representation producing a + * Phalcon\Mvc\Model\Resultset * - * @param mixed $intermediate - * @param mixed $bindParams - * @param mixed $bindTypes + * @param array $intermediate + * @param array $bindParams + * @param array $bindTypes * @param bool $simulate * @return array|\Phalcon\Mvc\Model\ResultsetInterface */ - protected final function _executeSelect($intermediate, $bindParams, $bindTypes, $simulate = false) {} + final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) {} /** - * Executes the INSERT intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the INSERT intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeInsert($intermediate, $bindParams, $bindTypes) {} + final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Executes the UPDATE intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the UPDATE intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeUpdate($intermediate, $bindParams, $bindTypes) {} + final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Executes the DELETE intermediate representation producing a Phalcon\Mvc\Model\Query\Status + * Executes the DELETE intermediate representation producing a + * Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - protected final function _executeDelete($intermediate, $bindParams, $bindTypes) {} + final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} /** - * Query the records on which the UPDATE/DELETE operation well be done + * Query the records on which the UPDATE/DELETE operation will be done * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate @@ -414,7 +430,7 @@ protected final function _executeDelete($intermediate, $bindParams, $bindTypes) * @param array $bindTypes * @return \Phalcon\Mvc\Model\ResultsetInterface */ - protected final function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, $intermediate, $bindParams, $bindTypes) {} + final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface {} /** * Executes a parsed PHQL statement @@ -423,7 +439,7 @@ protected final function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, * @param array $bindTypes * @return mixed */ - public function execute($bindParams = null, $bindTypes = null) {} + public function execute(array $bindParams = array(), array $bindTypes = array()) {} /** * Executes the query returning the first result @@ -432,99 +448,100 @@ public function execute($bindParams = null, $bindTypes = null) {} * @param array $bindTypes * @return \Phalcon\Mvc\ModelInterface */ - public function getSingleResult($bindParams = null, $bindTypes = null) {} + public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface {} /** * Sets the type of PHQL statement to be executed * * @param int $type - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setType($type) {} + public function setType(int $type): QueryInterface {} /** * Gets the type of PHQL statement executed * * @return int */ - public function getType() {} + public function getType(): int {} /** * Set default bind parameters * * @param array $bindParams * @param bool $merge - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindParams(array $bindParams, $merge = false) {} + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface {} /** * Returns default bind params * * @return array */ - public function getBindParams() {} + public function getBindParams(): array {} /** * Set default bind parameters * * @param array $bindTypes * @param bool $merge - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindTypes(array $bindTypes, $merge = false) {} + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface {} /** * Set SHARED LOCK clause * * @param bool $sharedLock - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setSharedLock($sharedLock = false) {} + public function setSharedLock(bool $sharedLock = false): QueryInterface {} /** * Returns default bind types * * @return array */ - public function getBindTypes() {} + public function getBindTypes(): array {} /** * Allows to set the IR to be executed * * @param array $intermediate - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setIntermediate(array $intermediate) {} + public function setIntermediate(array $intermediate): QueryInterface {} /** * Returns the intermediate representation of the PHQL statement * * @return array */ - public function getIntermediate() {} + public function getIntermediate(): array {} /** * Sets the cache parameters of the query * - * @param mixed $cacheOptions - * @return Query + * @param array $cacheOptions + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function cache($cacheOptions) {} + public function cache(array $cacheOptions): QueryInterface {} /** * Returns the current cache options * - * @param array + * @return array */ - public function getCacheOptions() {} + public function getCacheOptions(): array {} /** - * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) + * Returns the SQL to be generated by the internal PHQL (only works in + * SELECT statements) * * @return array */ - public function getSql() {} + public function getSql(): array {} /** * Destroys the internal PHQL cache @@ -532,33 +549,35 @@ public function getSql() {} public static function clean() {} /** - * Gets the read connection from the model if there is no transaction set inside the query object + * Gets the read connection from the model if there is no transaction set + * inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} + protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} /** - * Gets the write connection from the model if there is no transaction inside the query object + * Gets the write connection from the model if there is no transaction + * inside the query object * * @param \Phalcon\Mvc\ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\AdapterInterface + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = null, array $bindTypes = null) {} + protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} /** * allows to wrap a transaction around all queries * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return Query + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface {} } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 197dbcd6..80c28f29 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -11,50 +11,106 @@ interface QueryInterface { /** - * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another - * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * Sets the cache parameters of the query * - * @return array + * @param array $cacheOptions + * @return QueryInterface */ - public function parse(); + public function cache(array $cacheOptions): QueryInterface; /** - * Sets the cache parameters of the query + * Executes a parsed PHQL statement * - * @param array $cacheOptions - * @return \Phalcon\Mvc\Model\Query + * @param array $bindParams + * @param array $bindTypes + * @return mixed + */ + public function execute(array $bindParams = array(), array $bindTypes = array()); + + /** + * Returns default bind params + * + * @return array */ - public function cache($cacheOptions); + public function getBindParams(): array; /** * Returns the current cache options * - * @param array + * @return array */ - public function getCacheOptions(); + public function getCacheOptions(): array; /** - * Tells to the query if only the first row in the resultset must be returned + * Returns default bind types + * + * @return array + */ + public function getBindTypes(): array; + + /** + * Returns the SQL to be generated by the internal PHQL (only works in SELECT statements) + * + * @return array + */ + public function getSql(): array; + + /** + * Executes the query returning the first result * - * @param boolean $uniqueRow - * @return \Phalcon\Mvc\Model\Query + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\ModelInterface */ - public function setUniqueRow($uniqueRow); + public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface; /** * Check if the query is programmed to get only the first row in the resultset * - * @return boolean + * @return bool */ - public function getUniqueRow(); + public function getUniqueRow(): bool; /** - * Executes a parsed PHQL statement + * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another + * intermediate representation that could be executed by Phalcon\Mvc\Model\Query + * + * @return array + */ + public function parse(): array; + + /** + * Set default bind parameters * * @param array $bindParams + * @param bool $merge + * @return QueryInterface + */ + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface; + + /** + * Set default bind parameters + * * @param array $bindTypes - * @return mixed + * @param bool $merge + * @return QueryInterface + */ + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface; + + /** + * Set SHARED LOCK clause + * + * @param bool $sharedLock + * @return QueryInterface + */ + public function setSharedLock(bool $sharedLock = false): QueryInterface; + + /** + * Tells to the query if only the first row in the resultset must be returned + * + * @param bool $uniqueRow + * @return QueryInterface */ - public function execute($bindParams = null, $bindTypes = null); + public function setUniqueRow(bool $uniqueRow): QueryInterface; } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index 362d73ff..4284bf95 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -10,52 +10,52 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface { - const BELONGS_TO = 0; + const ACTION_CASCADE = 2; - const HAS_ONE = 1; + const ACTION_RESTRICT = 1; - const HAS_MANY = 2; + const BELONGS_TO = 0; - const HAS_ONE_THROUGH = 3; + const HAS_MANY = 2; const HAS_MANY_THROUGH = 4; - const NO_ACTION = 0; + const HAS_ONE = 1; - const ACTION_RESTRICT = 1; + const HAS_ONE_THROUGH = 3; - const ACTION_CASCADE = 2; + const NO_ACTION = 0; - protected $_type; + protected $fields; - protected $_referencedModel; + protected $intermediateFields; - protected $_fields; + protected $intermediateModel; - protected $_referencedFields; + protected $intermediateReferencedFields; - protected $_intermediateModel; + protected $options; - protected $_intermediateFields; + protected $referencedFields; - protected $_intermediateReferencedFields; + protected $referencedModel; - protected $_options; + protected $type; /** @@ -67,51 +67,42 @@ class Relation implements \Phalcon\Mvc\Model\RelationInterface * @param string|array $referencedFields * @param array $options */ - public function __construct($type, $referencedModel, $fields, $referencedFields, $options = null) {} - - /** - * Sets the intermediate model data for has--through relations - * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string $intermediateReferencedFields - */ - public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields) {} + public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) {} /** - * Returns the relation type + * Returns the fields * - * @return int + * @return string|array */ - public function getType() {} + public function getFields() {} /** - * Returns the referenced model + * Returns the foreign key configuration * - * @return string + * @return string|array */ - public function getReferencedModel() {} + public function getForeignKey() {} /** - * Returns the fields + * Gets the intermediate fields for has--through relations * * @return string|array */ - public function getFields() {} + public function getIntermediateFields() {} /** - * Returns the referenced fields + * Gets the intermediate model for has--through relations * - * @return string|array + * @return string */ - public function getReferencedFields() {} + public function getIntermediateModel(): string {} /** - * Returns the options + * Gets the intermediate referenced fields for has--through relations * * @return string|array */ - public function getOptions() {} + public function getIntermediateReferencedFields() {} /** * Returns an option by the specified name @@ -119,62 +110,71 @@ public function getOptions() {} * * @param string $name */ - public function getOption($name) {} + public function getOption(string $name) {} /** - * Check whether the relation act as a foreign key + * Returns the options * - * @return bool + * @return array */ - public function isForeignKey() {} + public function getOptions(): array {} /** - * Returns the foreign key configuration + * Returns parameters that must be always used when the related records are obtained * - * @return string|array + * @return array */ - public function getForeignKey() {} + public function getParams() {} /** - * Returns parameters that must be always used when the related records are obtained + * Returns the relation type * - * @return array + * @return int */ - public function getParams() {} + public function getType(): int {} /** - * Check whether the relation is a 'many-to-many' relation or not + * Returns the referenced fields * - * @return bool + * @return string|array */ - public function isThrough() {} + public function getReferencedFields() {} /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Returns the referenced model + * + * @return string + */ + public function getReferencedModel(): string {} + + /** + * Check whether the relation act as a foreign key * * @return bool */ - public function isReusable() {} + public function isForeignKey(): bool {} /** - * Gets the intermediate fields for has--through relations + * Check whether the relation is a 'many-to-many' relation or not * - * @return string|array + * @return bool */ - public function getIntermediateFields() {} + public function isThrough(): bool {} /** - * Gets the intermediate model for has--through relations + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * - * @return string + * @return bool */ - public function getIntermediateModel() {} + public function isReusable(): bool {} /** - * Gets the intermediate referenced fields for has--through relations + * Sets the intermediate model data for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string $intermediateReferencedFields */ - public function getIntermediateReferencedFields() {} + public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) {} } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index 992893d1..4f018af5 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -11,104 +11,111 @@ interface RelationInterface { /** - * Sets the intermediate model dat for has--through relations + * Returns the fields * - * @param string|array $intermediateFields - * @param string $intermediateModel - * @param string|array $intermediateReferencedFields + * @return string|array */ - public function setIntermediateRelation($intermediateFields, $intermediateModel, $intermediateReferencedFields); + public function getFields(); /** - * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request + * Returns the foreign key configuration * - * @return bool + * @return string|array */ - public function isReusable(); + public function getForeignKey(); /** - * Returns the relations type + * Gets the intermediate fields for has--through relations * - * @return int + * @return string|array */ - public function getType(); + public function getIntermediateFields(); /** - * Returns the referenced model + * Gets the intermediate model for has--through relations * * @return string */ - public function getReferencedModel(); + public function getIntermediateModel(): string; /** - * Returns the fields + * Gets the intermediate referenced fields for has--through relations * * @return string|array */ - public function getFields(); + public function getIntermediateReferencedFields(); /** - * Returns the referenced fields + * Returns an option by the specified name + * If the option doesn't exist null is returned * - * @return string|array + * @param string $name */ - public function getReferencedFields(); + public function getOption(string $name); /** * Returns the options * - * @return string|array + * @return array */ - public function getOptions(); + public function getOptions(): array; /** - * Returns an option by the specified name - * If the option doesn't exist null is returned + * Returns parameters that must be always used when the related records are obtained * - * @param string $name + * @return array */ - public function getOption($name); + public function getParams(); /** - * Check whether the relation act as a foreign key + * Returns the referenced fields * - * @return bool + * @return string|array */ - public function isForeignKey(); + public function getReferencedFields(); /** - * Returns the foreign key configuration + * Returns the referenced model * - * @return string|array + * @return string */ - public function getForeignKey(); + public function getReferencedModel(): string; /** - * Check whether the relation is a 'many-to-many' relation or not + * Returns the relations type + * + * @return int + */ + public function getType(): int; + + /** + * Check whether the relation act as a foreign key * * @return bool */ - public function isThrough(); + public function isForeignKey(): bool; /** - * Gets the intermediate fields for has--through relations + * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * - * @return string|array + * @return bool */ - public function getIntermediateFields(); + public function isReusable(): bool; /** - * Gets the intermediate model for has--through relations + * Check whether the relation is a 'many-to-many' relation or not * - * @return string + * @return bool */ - public function getIntermediateModel(); + public function isThrough(): bool; /** - * Gets the intermediate referenced fields for has--through relations + * Sets the intermediate model dat for has--through relations * - * @return string|array + * @param string|array $intermediateFields + * @param string $intermediateModel + * @param string|array $intermediateReferencedFields */ - public function getIntermediateReferencedFields(); + public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 12423705..9ba8f10b 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -13,8 +13,9 @@ interface ResultInterface /** * Sets the object's state * - * @param integer $dirtyState + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState($dirtyState); + public function setDirtyState(int $dirtyState); } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index 5e2e1bb8..4064c4a7 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -10,7 +10,7 @@ * it will dump all the rows into a big array. Then unserialize will retrieve the rows as they were before * serializing. * - * + * ```php * * // Using a standard foreach * $robots = Robots::find( @@ -41,247 +41,248 @@ * * $robots->next(); * } - * + * ``` */ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { - const TYPE_RESULT_FULL = 0; + const HYDRATE_ARRAYS = 1; - const TYPE_RESULT_PARTIAL = 1; + const HYDRATE_OBJECTS = 2; const HYDRATE_RECORDS = 0; - const HYDRATE_OBJECTS = 2; + const TYPE_RESULT_FULL = 0; - const HYDRATE_ARRAYS = 1; + const TYPE_RESULT_PARTIAL = 1; - /** - * Phalcon\Db\ResultInterface or false for empty resultset - */ - protected $_result = false; + protected $activeRow = null; - protected $_cache; + protected $cache; - protected $_isFresh = true; + protected $count; - protected $_pointer = 0; + protected $errorMessages; - protected $_count; + protected $hydrateMode = 0; - protected $_activeRow = null; + protected $isFresh = true; - protected $_rows = null; + protected $pointer = 0; - protected $_row = null; + protected $row = null; - protected $_errorMessages; + protected $rows = null; - protected $_hydrateMode = 0; + /** + * Phalcon\Db\ResultInterface or false for empty resultset + */ + protected $result; /** * Phalcon\Mvc\Model\Resultset constructor * * @param \Phalcon\Db\ResultInterface|false $result - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($result, \Phalcon\Cache\BackendInterface $cache = null) {} + public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** - * Moves cursor to next row in the resultset + * Counts how many rows are in the resultset + * + * @return int */ - public function next() {} + final public function count(): int {} /** - * Check whether internal resource has rows to fetch + * Deletes every record in the resultset * + * @param \Closure $conditionCallback * @return bool */ - public function valid() {} + public function delete(\Closure $conditionCallback = null): bool {} /** - * Gets pointer number of active row in the resultset + * Filters a resultset returning only those the developer requires * - * @return int|null + * ```php + * $filtered = $robots->filter( + * function ($robot) { + * if ($robot->id < 3) { + * return $robot; + * } + * } + * ); + * ``` + * + * @param callable $filter + * @return array|\Phalcon\Mvc\ModelInterface[] */ - public function key() {} + public function filter($filter): array {} /** - * Rewinds resultset to its beginning + * Returns the associated cache for the resultset + * + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public final function rewind() {} + public function getCache(): AdapterInterface {} /** - * Changes the internal pointer to a specific position in the resultset. - * Set the new position if required, and then set this->_row + * Get first row in the resultset * - * @param mixed $position + * @return null|\Phalcon\Mvc\ModelInterface */ - public final function seek($position) {} + public function getFirst(): ?ModelInterface {} /** - * Counts how many rows are in the resultset + * Returns the current hydration mode * * @return int */ - public final function count() {} + public function getHydrateMode(): int {} /** - * Checks whether offset exists in the resultset + * Get last row in the resultset * - * @param mixed $index - * @return bool + * @return null|\Phalcon\Mvc\ModelInterface */ - public function offsetExists($index) {} + public function getLast(): ?ModelInterface {} /** - * Gets row in a specific position of the resultset + * Returns the error messages produced by a batch operation * - * @param mixed $index - * @return bool|\Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function offsetGet($index) {} + public function getMessages(): array {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Returns the internal type of data retrieval that the resultset is using * - * @param int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @return int */ - public function offsetSet($index, $value) {} + public function getType(): int {} /** - * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface + * Tell if the resultset if fresh or an old one cached * - * @param mixed $offset + * @return bool */ - public function offsetUnset($offset) {} + public function isFresh(): bool {} /** - * Returns the internal type of data retrieval that the resultset is using + * Returns serialised model objects as array for json_encode. + * Calls jsonSerialize on each object if present * - * @return int + * ```php + * $robots = Robots::find(); + * + * echo json_encode($robots); + * ``` + * + * @return array */ - public function getType() {} + public function jsonSerialize(): array {} /** - * Get first row in the resultset + * Gets pointer number of active row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return int|null */ - public function getFirst() {} + public function key(): ?int {} /** - * Get last row in the resultset - * - * @return bool|\Phalcon\Mvc\ModelInterface + * Moves cursor to next row in the resultset */ - public function getLast() {} + public function next() {} /** - * Set if the resultset is fresh or an old one cached + * Gets row in a specific position of the resultset * - * @param bool $isFresh - * @return Resultset + * @param mixed $index + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setIsFresh($isFresh) {} + public function offsetGet($index) {} /** - * Tell if the resultset if fresh or an old one cached + * Checks whether offset exists in the resultset * + * @param mixed $index * @return bool */ - public function isFresh() {} + public function offsetExists($index): bool {} /** - * Sets the hydration mode in the resultset + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @param int $hydrateMode - * @return Resultset + * @param int $index + * @param \Phalcon\Mvc\ModelInterface $value */ - public function setHydrateMode($hydrateMode) {} + public function offsetSet($index, $value) {} /** - * Returns the current hydration mode + * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * - * @return int + * @param mixed $offset */ - public function getHydrateMode() {} + public function offsetUnset($offset) {} /** - * Returns the associated cache for the resultset - * - * @return \Phalcon\Cache\BackendInterface + * Rewinds resultset to its beginning */ - public function getCache() {} + final public function rewind() {} /** - * Returns the error messages produced by a batch operation + * Changes the internal pointer to a specific position in the resultset. + * Set the new position if required, and then set this->row * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @param mixed $position */ - public function getMessages() {} + final public function seek($position) {} /** - * Updates every record in the resultset + * Sets the hydration mode in the resultset * - * @param array $data - * @param \Closure $conditionCallback - * @return bool + * @param int $hydrateMode + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function update($data, \Closure $conditionCallback = null) {} + public function setHydrateMode(int $hydrateMode): ResultsetInterface {} /** - * Deletes every record in the resultset + * Set if the resultset is fresh or an old one cached * - * @param \Closure $conditionCallback - * @return bool + * @param bool $isFresh + * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function delete(\Closure $conditionCallback = null) {} + public function setIsFresh(bool $isFresh): ResultsetInterface {} /** - * Filters a resultset returning only those the developer requires - * - * - * $filtered = $robots->filter( - * function ($robot) { - * if ($robot->id < 3) { - * return $robot; - * } - * } - * ); - * + * Updates every record in the resultset * - * @param callback $filter - * @return array + * @param array $data + * @param \Closure $conditionCallback + * @return bool */ - public function filter($filter) {} + public function update($data, \Closure $conditionCallback = null): bool {} /** - * Returns serialised model objects as array for json_encode. - * Calls jsonSerialize on each object if present - * - * - * $robots = Robots::find(); - * echo json_encode($robots); - * + * Check whether internal resource has rows to fetch * - * @return array + * @return bool */ - public function jsonSerialize() {} + public function valid(): bool {} } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index f1252a35..b36b34d7 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -11,46 +11,95 @@ interface ResultsetInterface { /** - * Returns the internal type of data retrieval that the resultset is using + * Deletes every record in the resultset * - * @return int + * @param \Closure $conditionCallback + * @return bool + */ + public function delete(\Closure $conditionCallback = null): bool; + + /** + * Filters a resultset returning only those the developer requires + * + * ```php + * $filtered = $robots->filter( + * function ($robot) { + * if ($robot->id < 3) { + * return $robot; + * } + * } + * ); + * ``` + * + * @param callable $filter + * @return array|\Phalcon\Mvc\ModelInterface[] */ - public function getType(); + public function filter($filter): array; + + /** + * Returns the associated cache for the resultset + * + * @return \Phalcon\Cache\Adapter\AdapterInterface + */ + public function getCache(): AdapterInterface; /** * Get first row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return null|\Phalcon\Mvc\ModelInterface */ - public function getFirst(); + public function getFirst(): ?ModelInterface; + + /** + * Returns the current hydration mode + * + * @return int + */ + public function getHydrateMode(): int; /** * Get last row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return null|\Phalcon\Mvc\ModelInterface */ - public function getLast(); + public function getLast(): ?ModelInterface; /** - * Set if the resultset is fresh or an old one cached + * Returns the error messages produced by a batch operation * - * @param bool $isFresh + * @return array|\Phalcon\Messages\MessageInterface[] + */ + public function getMessages(): array; + + /** + * Returns the internal type of data retrieval that the resultset is using + * + * @return int */ - public function setIsFresh($isFresh); + public function getType(): int; /** * Tell if the resultset if fresh or an old one cached * * @return bool */ - public function isFresh(); + public function isFresh(): bool; /** - * Returns the associated cache for the resultset + * Sets the hydration mode in the resultset * - * @return \Phalcon\Cache\BackendInterface + * @param int $hydrateMode + * @return ResultsetInterface */ - public function getCache(); + public function setHydrateMode(int $hydrateMode): ResultsetInterface; + + /** + * Set if the resultset is fresh or an old one cached + * + * @param bool $isFresh + * @return ResultsetInterface + */ + public function setIsFresh(bool $isFresh): ResultsetInterface; /** * Returns a complete resultset as an array, if the resultset has a big number of rows @@ -58,6 +107,15 @@ public function getCache(); * * @return array */ - public function toArray(); + public function toArray(): array; + + /** + * Updates every record in the resultset + * + * @param array $data + * @param \Closure $conditionCallback + * @return bool + */ + public function update($data, \Closure $conditionCallback = null): bool; } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 4d910b69..9d9200e2 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -12,28 +12,29 @@ class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInte { /** - * Set the current object's state + * Serializes the object for json_encode * - * @param int $dirtyState - * @return bool + * @return array */ - public function setDirtyState($dirtyState) {} + public function jsonSerialize(): array {} /** - * Checks whether offset exists in the row + * Gets a record in a specific position of the row * - * @param string|int $index - * @return bool + * @param string|int index + * + * @param mixed $index + * @return mixed */ - public function offsetExists($index) {} + public function offsetGet($index) {} /** - * Gets a record in a specific position of the row + * Checks whether offset exists in the row * * @param string|int $index - * @return string|Phalcon\Mvc\ModelInterface + * @return bool */ - public function offsetGet($index) {} + public function offsetExists($index): bool {} /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface @@ -53,39 +54,40 @@ public function offsetUnset($offset) {} /** * Reads an attribute value by its name * - * + * ```php * echo $robot->readAttribute("name"); - * + * ``` * * @param string $attribute * @return mixed */ - public function readAttribute($attribute) {} + public function readAttribute(string $attribute) {} /** - * Writes an attribute value by its name - * - * - * $robot->writeAttribute("name", "Rosey"); - * + * Set the current object's state * - * @param string $attribute - * @param mixed $value + * @param int $dirtyState + * @return bool|\Phalcon\Mvc\ModelInterface */ - public function writeAttribute($attribute, $value) {} + public function setDirtyState(int $dirtyState) {} /** * Returns the instance as an array representation * * @return array */ - public function toArray() {} + public function toArray(): array {} /** - * Serializes the object for json_encode + * Writes an attribute value by its name * - * @return array + * ```php + * $robot->writeAttribute("name", "Rosey"); + * ``` + * + * @param string $attribute + * @param mixed $value */ - public function jsonSerialize() {} + public function writeAttribute(string $attribute, $value) {} } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index 072d0f35..6559b68e 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -5,11 +5,12 @@ /** * Phalcon\Mvc\Model\Transaction * - * Transactions are protective blocks where SQL statements are only permanent if they can - * all succeed as one atomic action. Phalcon\Transaction is intended to be used with Phalcon_Model_Base. - * Phalcon Transactions should be created using Phalcon\Transaction\Manager. + * Transactions are protective blocks where SQL statements are only permanent if + * they can all succeed as one atomic action. Phalcon\Transaction is intended to + * be used with Phalcon_Model_Base. Phalcon Transactions should be created using + * Phalcon\Transaction\Manager. * - * + * ```php * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -43,112 +44,108 @@ * } catch(Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` */ class Transaction implements \Phalcon\Mvc\Model\TransactionInterface { - protected $_connection; + protected $activeTransaction = false; - protected $_activeTransaction = false; + protected $connection; - protected $_isNewTransaction = true; + protected $isNewTransaction = true; - protected $_rollbackOnAbort = false; + protected $manager; - protected $_manager; + protected $messages; - protected $_messages; + protected $rollbackRecord; - protected $_rollbackRecord; + protected $rollbackOnAbort = false; + + + protected $rollbackThrowException = false; /** * Phalcon\Mvc\Model\Transaction constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @param bool $autoBegin * @param string $service */ - public function __construct(\Phalcon\DiInterface $dependencyInjector, $autoBegin = false, $service = null) {} - - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} + public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') {} /** * Starts the transaction * * @return bool */ - public function begin() {} + public function begin(): bool {} /** * Commits the transaction * * @return bool */ - public function commit() {} + public function commit(): bool {} /** - * Rollbacks the transaction + * Returns the connection related to transaction * - * @param mixed $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord - * @return bool + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null) {} + public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface {} /** - * Returns the connection related to transaction + * Returns validations messages from last save try * - * @return \Phalcon\Db\AdapterInterface + * @return array */ - public function getConnection() {} + public function getMessages(): array {} /** - * Sets if is a reused transaction or new once + * Checks whether transaction is managed by a transaction manager * - * @param bool $isNew + * @return bool */ - public function setIsNewTransaction($isNew) {} + public function isManaged(): bool {} /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort($rollbackOnAbort) {} + public function isValid(): bool {} /** - * Checks whether transaction is managed by a transaction manager + * Rollbacks the transaction * + * @param string $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function isManaged() {} + public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool {} /** - * Returns validations messages from last save try + * Sets if is a reused transaction or new once * - * @return array + * @param bool $isNew */ - public function getMessages() {} + public function setIsNewTransaction(bool $isNew) {} /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid() {} + public function setRollbackOnAbort(bool $rollbackOnAbort) {} /** * Sets object which generates rollback action @@ -157,4 +154,19 @@ public function isValid() {} */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) {} + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} + + /** + * Enables throwing exception + * + * @param bool $status + * @return \Phalcon\Mvc\Model\TransactionInterface + */ + public function throwRollbackException(bool $status): TransactionInterface {} + } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index d1715dee..da437029 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -10,76 +10,70 @@ interface TransactionInterface { - /** - * Sets transaction manager related to the transaction - * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager - */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); - /** * Starts the transaction * * @return bool */ - public function begin(); + public function begin(): bool; /** * Commits the transaction * * @return bool */ - public function commit(); + public function commit(): bool; /** - * Rollbacks the transaction + * Returns connection related to transaction * - * @param mixed $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord + * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function rollback($rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null); + public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface; /** - * Returns connection related to transaction + * Returns validations messages from last save try * - * @return \Phalcon\Db\AdapterInterface + * @return array */ - public function getConnection(); + public function getMessages(): array; /** - * Sets if is a reused transaction or new once + * Checks whether transaction is managed by a transaction manager * - * @param bool $isNew + * @return bool */ - public function setIsNewTransaction($isNew); + public function isManaged(): bool; /** - * Sets flag to rollback on abort the HTTP connection + * Checks whether internal connection is under an active transaction * - * @param bool $rollbackOnAbort + * @return bool */ - public function setRollbackOnAbort($rollbackOnAbort); + public function isValid(): bool; /** - * Checks whether transaction is managed by a transaction manager + * Rollbacks the transaction * + * @param string $rollbackMessage + * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function isManaged(); + public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool; /** - * Returns validations messages from last save try + * Sets if is a reused transaction or new once * - * @return array + * @param bool $isNew */ - public function getMessages(); + public function setIsNewTransaction(bool $isNew); /** - * Checks whether internal connection is under an active transaction + * Sets flag to rollback on abort the HTTP connection * - * @return bool + * @param bool $rollbackOnAbort */ - public function isValid(); + public function setRollbackOnAbort(bool $rollbackOnAbort); /** * Sets object which generates rollback action @@ -88,4 +82,19 @@ public function isValid(); */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); + /** + * Sets transaction manager related to the transaction + * + * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + */ + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); + + /** + * Enables throwing exception + * + * @param bool $status + * @return TransactionInterface + */ + public function throwRollbackException(bool $status): TransactionInterface; + } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index f491a341..e64943b7 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -11,32 +11,32 @@ class ValidationFailed extends \Phalcon\Mvc\Model\Exception { - protected $_model; + protected $messages; - protected $_messages; + protected $model; /** * Phalcon\Mvc\Model\ValidationFailed constructor * - * @param Model $model + * @param \Phalcon\Mvc\ModelInterface $model * @param Message[] $validationMessages */ - public function __construct(\Phalcon\Mvc\Model $model, array $validationMessages) {} + public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) {} /** - * Returns the model that generated the messages + * Returns the complete group of messages produced in the validation * - * @return \Phalcon\Mvc\Model + * @return array|Message[] */ - public function getModel() {} + public function getMessages(): array {} /** - * Returns the complete group of messages produced in the validation + * Returns the model that generated the messages * - * @return Message[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages() {} + public function getModel(): ModelInterface {} } diff --git a/src/Phalcon/mvc/model/Validator.php b/src/Phalcon/mvc/model/Validator.php deleted file mode 100644 index a5b17579..00000000 --- a/src/Phalcon/mvc/model/Validator.php +++ /dev/null @@ -1,73 +0,0 @@ - - * $metaData = new \Phalcon\Mvc\Model\Metadata\Apc( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * ] - * ); - * - * - * @deprecated Deprecated since 3.3.0, will be removed in 4.0.0 - * @see Phalcon\Mvc\Model\Metadata\Apcu - */ -class Apc extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Apc constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads meta-data from APC - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the meta-data to APC - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index d27a7af2..b676700d 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -11,48 +11,24 @@ * * You can query the meta-data by printing apcu_fetch('$PMM$') or apcu_fetch('$PMM$my-app-id') * - * - * $metaData = new \Phalcon\Mvc\Model\Metadata\Apcu( + * ```php + * $metaData = new \Phalcon\Mvc\Model\MetaData\Apcu( * [ * "prefix" => "my-app-id", * "lifetime" => 86400, * ] * ); - * + * ``` */ class Apcu extends \Phalcon\Mvc\Model\MetaData { - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Apcu constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads meta-data from APCu - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the meta-data to APCu - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) {} } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index ef4640b7..fad94fe0 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -8,61 +8,17 @@ * Stores model meta-data in the Memcache. * * By default meta-data is stored for 48 hours (172800 seconds) - * - * - * $metaData = new Phalcon\Mvc\Model\Metadata\Libmemcached( - * [ - * "servers" => [ - * [ - * "host" => "localhost", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * Memcached::OPT_HASH => Memcached::HASH_MD5, - * Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * */ class Libmemcached extends \Phalcon\Mvc\Model\MetaData { - protected $_ttl = 172800; - - - protected $_memcache = null; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Libmemcached constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads metadata from Memcache - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Memcache - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} /** * Flush Memcache data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Memcache.php b/src/Phalcon/mvc/model/metadata/Memcache.php deleted file mode 100644 index b846ab98..00000000 --- a/src/Phalcon/mvc/model/metadata/Memcache.php +++ /dev/null @@ -1,64 +0,0 @@ - - * $metaData = new Phalcon\Mvc\Model\Metadata\Memcache( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * "host" => "localhost", - * "port" => 11211, - * "persistent" => false, - * ] - * ); - * - */ -class Memcache extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_ttl = 172800; - - - protected $_memcache = null; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Memcache constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads metadata from Memcache - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Memcache - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} - - /** - * Flush Memcache data and resets internal meta-data in order to regenerate it - */ - public function reset() {} - -} diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index 57966816..c647040f 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -10,9 +10,6 @@ class Memory extends \Phalcon\Mvc\Model\MetaData { - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Memory constructor * @@ -24,9 +21,9 @@ public function __construct($options = null) {} * Reads the meta-data from temporal memory * * @param string $key - * @return array + * @return array|null */ - public function read($key) {} + public function read(string $key): ?array {} /** * Writes the meta-data to temporal memory @@ -34,6 +31,6 @@ public function read($key) {} * @param string $key * @param array $data */ - public function write($key, $data) {} + public function write(string $key, array $data) {} } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index 6b357aec..c32c0bca 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -9,55 +9,30 @@ * * By default meta-data is stored for 48 hours (172800 seconds) * - * - * use Phalcon\Mvc\Model\Metadata\Redis; + * ```php + * use Phalcon\Mvc\Model\MetaData\Redis; * * $metaData = new Redis( * [ * "host" => "127.0.0.1", * "port" => 6379, * "persistent" => 0, - * "statsKey" => "_PHCM_MM", * "lifetime" => 172800, * "index" => 2, * ] * ); - * + * ``` */ class Redis extends \Phalcon\Mvc\Model\MetaData { - protected $_ttl = 172800; - - - protected $_redis = null; - - - protected $_metaData = array(); - - /** * Phalcon\Mvc\Model\MetaData\Redis constructor * + * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct($options = null) {} - - /** - * Reads metadata from Redis - * - * @param string $key - * @return array|null - */ - public function read($key) {} - - /** - * Writes the metadata to Redis - * - * @param string $key - * @param mixed $data - */ - public function write($key, $data) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} /** * Flush Redis data and resets internal meta-data in order to regenerate it diff --git a/src/Phalcon/mvc/model/metadata/Session.php b/src/Phalcon/mvc/model/metadata/Session.php deleted file mode 100644 index 048388de..00000000 --- a/src/Phalcon/mvc/model/metadata/Session.php +++ /dev/null @@ -1,50 +0,0 @@ - - * $metaData = new \Phalcon\Mvc\Model\Metadata\Session( - * [ - * "prefix" => "my-app-id", - * ] - * ); - * - */ -class Session extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - /** - * Phalcon\Mvc\Model\MetaData\Session constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads meta-data from $_SESSION - * - * @param string $key - * @return array - */ - public function read($key) {} - - /** - * Writes the meta-data to $_SESSION - * - * @param string $key - * @param array $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/StrategyInterface.php index 82b2a4d6..9ba73ec4 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/StrategyInterface.php @@ -2,27 +2,34 @@ namespace Phalcon\Mvc\Model\MetaData; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ interface StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * + * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); + public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * - * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector); + public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; } diff --git a/src/Phalcon/mvc/model/metadata/Files.php b/src/Phalcon/mvc/model/metadata/Stream.php similarity index 57% rename from src/Phalcon/mvc/model/metadata/Files.php rename to src/Phalcon/mvc/model/metadata/Stream.php index 419c3016..c14155d6 100644 --- a/src/Phalcon/mvc/model/metadata/Files.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -3,25 +3,22 @@ namespace Phalcon\Mvc\Model\MetaData; /** - * Phalcon\Mvc\Model\MetaData\Files + * Phalcon\Mvc\Model\MetaData\Stream * * Stores model meta-data in PHP files. * - * + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Files( * [ * "metaDataDir" => "app/cache/metadata/", * ] * ); - * + * ``` */ -class Files extends \Phalcon\Mvc\Model\MetaData +class Stream extends \Phalcon\Mvc\Model\MetaData { - protected $_metaDataDir = './'; - - - protected $_metaData = array(); + protected $metaDataDir = './'; /** @@ -35,9 +32,9 @@ public function __construct($options = null) {} * Reads meta-data from files * * @param string $key - * @return mixed + * @return array|null */ - public function read($key) {} + public function read(string $key): ?array {} /** * Writes the meta-data to files @@ -45,6 +42,13 @@ public function read($key) {} * @param string $key * @param array $data */ - public function write($key, $data) {} + public function write(string $key, array $data) {} + + /** + * Throws an exception when the metadata cannot be written + * + * @param mixed $option + */ + private function throwWriteException($option) {} } diff --git a/src/Phalcon/mvc/model/metadata/Xcache.php b/src/Phalcon/mvc/model/metadata/Xcache.php deleted file mode 100644 index bffa8d74..00000000 --- a/src/Phalcon/mvc/model/metadata/Xcache.php +++ /dev/null @@ -1,58 +0,0 @@ - - * $metaData = new Phalcon\Mvc\Model\Metadata\Xcache( - * [ - * "prefix" => "my-app-id", - * "lifetime" => 86400, - * ] - * ); - * - */ -class Xcache extends \Phalcon\Mvc\Model\MetaData -{ - - protected $_prefix = ''; - - - protected $_ttl = 172800; - - - protected $_metaData = array(); - - - /** - * Phalcon\Mvc\Model\MetaData\Xcache constructor - * - * @param array $options - */ - public function __construct($options = null) {} - - /** - * Reads metadata from XCache - * - * @param string $key - * @return array - */ - public function read($key) {} - - /** - * Writes the metadata to XCache - * - * @param string $key - * @param array $data - */ - public function write($key, $data) {} - -} diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index af7790fa..86f0806f 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -2,26 +2,33 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; - +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ class Annotations implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index 3f61fd1a..361aa28e 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -11,21 +11,21 @@ class Introspection implements \Phalcon\Mvc\Model\MetaData\StrategyInterface { /** - * The meta-data is obtained by reading the column descriptions from the database information schema + * Read the model's column map, this can't be inferred * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} /** - * Read the model's column map, this can't be inferred + * The meta-data is obtained by reading the column descriptions from the database information schema * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container * @return array */ - public final function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\DiInterface $dependencyInjector) {} + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index df6ecfc3..73447ad5 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -7,9 +7,11 @@ * * Helps to create PHQL queries using an OO interface * - * + * ```php * $params = [ - * "models" => ["Users"], + * "models" => [ + * Users::class, + * ], * "columns" => ["id", "name", "status"], * "conditions" => [ * [ @@ -34,111 +36,176 @@ * ]; * * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); - * + * ``` */ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - + protected $bindParams; - protected $_columns; + protected $bindTypes; - protected $_models; + protected $columns; - protected $_joins; - - /** - * @deprecated Will be removed in version 4.0.0 - */ - protected $_with; + protected $conditions; - protected $_conditions; + protected $container; - protected $_group; + protected $distinct; - protected $_having; + protected $forUpdate; - protected $_order; + /** + * @var array + */ + protected $group; - protected $_limit; + protected $having; - protected $_offset; + protected $hiddenParamNumber = 0; - protected $_forUpdate; + protected $joins; - protected $_sharedLock; + protected $limit; - protected $_bindParams; + protected $models; - protected $_bindTypes; + protected $offset; - protected $_distinct; + protected $order; - protected $_hiddenParamNumber = 0; + protected $sharedLock; /** * Phalcon\Mvc\Model\Query\Builder constructor * * @param mixed $params - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function __construct($params = null, \Phalcon\DiInterface $dependencyInjector = null) {} + public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) {} /** - * Sets the DependencyInjector container + * Add a model to take part of the query + * + * ```php + * // Load data from models Robots + * $builder->addFrom( + * Robots::class + * ); * - * @param \Phalcon\DiInterface $dependencyInjector - * @return Builder + * // Load data from model 'Robots' using 'r' as alias in PHQL + * $builder->addFrom( + * Robots::class, + * "r" + * ); + * ``` + * + * @param string $model + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function addFrom(string $model, string $alias = null): BuilderInterface {} /** - * Returns the DependencyInjector container + * Appends a condition to the current HAVING conditions clause using a AND operator * - * @return \Phalcon\DiInterface + * ```php + * $builder->andHaving("SUM(Robots.price) > 0"); + * + * $builder->andHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getDI() {} + public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets SELECT DISTINCT / SELECT ALL flag + * Appends a condition to the current WHERE conditions using a AND operator * - * - * $builder->distinct("status"); - * $builder->distinct(null); - * + * ```php + * $builder->andWhere("name = 'Peter'"); * - * @param mixed $distinct - * @return Builder + * $builder->andWhere( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function distinct($distinct) {} + public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Returns SELECT DISTINCT / SELECT ALL flag + * Automatically escapes identifiers but only if they need to be escaped. * - * @return bool + * @param string $identifier + * @return string + */ + final public function autoescape(string $identifier): string {} + + /** + * Appends a BETWEEN condition to the current HAVING conditions clause + * + * ```php + * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getDistinct() {} + public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + + /** + * Appends a BETWEEN condition to the current WHERE conditions + * + * ```php + * $builder->betweenWhere("price", 100.25, 200.50); + * ``` + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return \Phalcon\Mvc\Model\Query\BuilderInterface + */ + public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** * Sets the columns to be queried * - * + * ```php * $builder->columns("id, name"); * * $builder->columns( @@ -154,65 +221,100 @@ public function getDistinct() {} * "number" => "COUNT()", * ] * ); - * + * ``` * * @param mixed $columns - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function columns($columns) {} + public function columns($columns): BuilderInterface {} /** - * Return the columns to be queried + * Sets SELECT DISTINCT / SELECT ALL flag * - * @return string|array + * ```php + * $builder->distinct("status"); + * $builder->distinct(null); + * ``` + * + * @param mixed $distinct + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getColumns() {} + public function distinct($distinct): BuilderInterface {} + + /** + * Sets a FOR UPDATE clause + * + * ```php + * $builder->forUpdate(true); + * ``` + * + * @param bool $forUpdate + * @return \Phalcon\Mvc\Model\Query\BuilderInterface + */ + public function forUpdate(bool $forUpdate): BuilderInterface {} /** * Sets the models who makes part of the query * - * - * $builder->from("Robots"); + * ```php + * $builder->from( + * Robots::class + * ); * * $builder->from( * [ - * "Robots", - * "RobotsParts", + * Robots::class, + * RobotsParts::class, * ] * ); * * $builder->from( * [ - * "r" => "Robots", - * "rp" => "RobotsParts", + * "r" => Robots::class, + * "rp" => RobotsParts::class, * ] * ); - * + * ``` * * @param mixed $models - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function from($models) {} + public function from($models): BuilderInterface {} /** - * Add a model to take part of the query + * Returns default bind params * - * NOTE: The third parameter $with is deprecated and will be removed in future releases. + * @return array + */ + public function getBindParams(): array {} + + /** + * Returns default bind types * - * - * // Load data from models Robots - * $builder->addFrom("Robots"); + * @return array + */ + public function getBindTypes(): array {} + + /** + * Return the columns to be queried * - * // Load data from model 'Robots' using 'r' as alias in PHQL - * $builder->addFrom("Robots", "r"); - * + * @return string|array + */ + public function getColumns() {} + + /** + * Returns the DependencyInjector container * - * @param mixed $model - * @param mixed $alias - * @param mixed $with - * @return Builder + * @return \Phalcon\Di\DiInterface */ - public function addFrom($model, $alias = null, $with = null) {} + public function getDI(): DiInterface {} + + /** + * Returns SELECT DISTINCT / SELECT ALL flag + * + * @return bool + */ + public function getDistinct(): bool {} /** * Return the models who makes part of the query @@ -222,466 +324,439 @@ public function addFrom($model, $alias = null, $with = null) {} public function getFrom() {} /** - * Adds an :type: join (by default type - INNER) to the query - * - * - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->join("Robots"); - * - * // Inner Join model 'Robots' specifying conditions - * $builder->join("Robots", "Robots.id = RobotsParts.robots_id"); - * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r"); - * - * // Left Join model 'Robots' specifying conditions, alias and type of join - * $builder->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); - * + * Returns the GROUP BY clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return Builder + * @return array */ - public function join($model, $conditions = null, $alias = null, $type = null) {} + public function getGroupBy(): array {} /** - * Adds an INNER join to the query - * - * - * // Inner Join model 'Robots' with automatic conditions and alias - * $builder->innerJoin("Robots"); - * - * // Inner Join model 'Robots' specifying conditions - * $builder->innerJoin("Robots", "Robots.id = RobotsParts.robots_id"); - * - * // Inner Join model 'Robots' specifying conditions and alias - * $builder->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Return the current having clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return Builder + * @return string */ - public function innerJoin($model, $conditions = null, $alias = null) {} + public function getHaving(): string {} /** - * Adds a LEFT join to the query - * - * - * $builder->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Return join parts of the query * - * @param string $model - * @param string $conditions - * @param string $alias - * @return Builder + * @return array */ - public function leftJoin($model, $conditions = null, $alias = null) {} + public function getJoins(): array {} /** - * Adds a RIGHT join to the query - * - * - * $builder->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r"); - * + * Returns the current LIMIT clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return Builder + * @return string|array */ - public function rightJoin($model, $conditions = null, $alias = null) {} + public function getLimit() {} /** - * Return join parts of the query + * Returns the models involved in the query * - * @return array + * @return string|array|null */ - public function getJoins() {} + public function getModels() {} /** - * Sets the query WHERE conditions + * Returns the current OFFSET clause * - * - * $builder->where(100); + * @return int + */ + public function getOffset(): int {} + + /** + * Returns the set ORDER BY clause * - * $builder->where("name = 'Peter'"); + * @return string|array + */ + public function getOrderBy() {} + + /** + * Returns a PHQL statement built based on the builder parameters * - * $builder->where( - * "name = :name: AND id > :id:", - * [ - * "name" => "Peter", - * "id" => 100, - * ] - * ); - * + * @return string + */ + final public function getPhql(): string {} + + /** + * Returns the query built * - * @param mixed $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @return \Phalcon\Mvc\Model\QueryInterface */ - public function where($conditions, $bindParams = null, $bindTypes = null) {} + public function getQuery(): QueryInterface {} /** - * Appends a condition to the current WHERE conditions using a AND operator + * Return the conditions for the query * - * - * $builder->andWhere("name = 'Peter'"); + * @return string|array + */ + public function getWhere() {} + + /** + * Sets a GROUP BY clause * - * $builder->andWhere( - * "name = :name: AND id > :id:", + * ```php + * $builder->groupBy( * [ - * "name" => "Peter", - * "id" => 100, + * "Robots.name", * ] * ); - * + * ``` * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string|array $group + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function groupBy($group): BuilderInterface {} /** - * Appends a condition to the current conditions using an OR operator + * Sets the HAVING condition clause * - * - * $builder->orWhere("name = 'Peter'"); + * ```php + * $builder->having("SUM(Robots.price) > 0"); * - * $builder->orWhere( - * "name = :name: AND id > :id:", + * $builder->having( + * "SUM(Robots.price) > :sum:", * [ - * "name" => "Peter", - * "id" => 100, + * "sum" => 100, * ] * ); - * + * ``` * - * @param string $conditions + * @param mixed $conditions * @param array $bindParams * @param array $bindTypes - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null) {} + public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Appends a BETWEEN condition to the current WHERE conditions + * Appends an IN condition to the current HAVING conditions clause * - * - * $builder->betweenWhere("price", 100.25, 200.50); - * + * ```php + * $builder->inHaving("SUM(Robots.price)", [100, 200]); + * ``` * * @param string $expr - * @param mixed $minimum - * @param mixed $maximum + * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT BETWEEN condition to the current WHERE conditions + * Adds an INNER join to the query * - * - * $builder->notBetweenWhere("price", 100.25, 200.50); - * + * ```php + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->innerJoin( + * Robots::class + * ); * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return Builder - */ - public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} - - /** - * Appends an IN condition to the current WHERE conditions + * // Inner Join model 'Robots' specifying conditions + * $builder->innerJoin( + * Robots::class, + * "Robots.id = RobotsParts.robots_id" + * ); * - * - * $builder->inWhere("id", [1, 2, 3]); - * + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->innerJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); + * ``` * - * @param string $expr - * @param array $values - * @param string $operator + * @param string $model + * @param string $conditions + * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Appends a NOT IN condition to the current WHERE conditions + * Appends an IN condition to the current WHERE conditions * - * - * $builder->notInWhere("id", [1, 2, 3]); - * + * ```php + * $builder->inWhere( + * "id", + * [1, 2, 3] + * ); + * ``` * * @param string $expr * @param array $values * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Return the conditions for the query - * - * @return string|array - */ - public function getWhere() {} - - /** - * Sets an ORDER BY condition clause - * - * - * $builder->orderBy("Robots.name"); - * $builder->orderBy(["1", "Robots.name"]); - * $builder->orderBy(["Robots.name DESC"]); - * + * Adds an :type: join (by default type - INNER) to the query * - * @param string|array $orderBy - * @return Builder - */ - public function orderBy($orderBy) {} - - /** - * Returns the set ORDER BY clause + * ```php + * // Inner Join model 'Robots' with automatic conditions and alias + * $builder->join( + * Robots::class + * ); * - * @return string|array - */ - public function getOrderBy() {} - - /** - * Sets the HAVING condition clause + * // Inner Join model 'Robots' specifying conditions + * $builder->join( + * Robots::class, + * "Robots.id = RobotsParts.robots_id" + * ); * - * - * $builder->having("SUM(Robots.price) > 0"); + * // Inner Join model 'Robots' specifying conditions and alias + * $builder->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" + * ); * - * $builder->having( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] + * // Left Join model 'Robots' specifying conditions, alias and type of join + * $builder->join( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r", + * "LEFT" * ); - * + * ``` * - * @param mixed $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function having($conditions, $bindParams = null, $bindTypes = null) {} + public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface {} /** - * Appends a condition to the current HAVING conditions clause using a AND operator - * - * - * $builder->andHaving("SUM(Robots.price) > 0"); + * Adds a LEFT join to the query * - * $builder->andHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] + * ```php + * $builder->leftJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" * ); - * + * ``` * + * @param string $model * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andHaving($conditions, $bindParams = null, $bindTypes = null) {} + public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Appends a condition to the current HAVING conditions clause using an OR operator - * - * - * $builder->orHaving("SUM(Robots.price) > 0"); + * Sets a LIMIT clause, optionally an offset clause * - * $builder->orHaving( - * "SUM(Robots.price) > :sum:", - * [ - * "sum" => 100, - * ] - * ); - * + * ```php + * $builder->limit(100); + * $builder->limit(100, 20); + * $builder->limit("100", "20"); + * ``` * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return Builder + * @param int $limit + * @param mixed $offset + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orHaving($conditions, $bindParams = null, $bindTypes = null) {} + public function limit(int $limit, $offset = null): BuilderInterface {} /** - * Appends a BETWEEN condition to the current HAVING conditions clause + * Appends a NOT BETWEEN condition to the current HAVING conditions clause * - * - * $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50); - * + * ```php + * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT BETWEEN condition to the current HAVING conditions clause + * Appends a NOT BETWEEN condition to the current WHERE conditions * - * - * $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50); - * + * ```php + * $builder->notBetweenWhere("price", 100.25, 200.50); + * ``` * * @param string $expr * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notBetweenHaving($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND) {} + public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends an IN condition to the current HAVING conditions clause + * Appends a NOT IN condition to the current HAVING conditions clause * - * - * $builder->inHaving("SUM(Robots.price)", [100, 200]); - * + * ```php + * $builder->notInHaving("SUM(Robots.price)", [100, 200]); + * ``` * * @param string $expr * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Appends a NOT IN condition to the current HAVING conditions clause + * Appends a NOT IN condition to the current WHERE conditions * - * - * $builder->notInHaving("SUM(Robots.price)", [100, 200]); - * + * ```php + * $builder->notInWhere("id", [1, 2, 3]); + * ``` * * @param string $expr * @param array $values * @param string $operator - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInHaving($expr, array $values, $operator = BuilderInterface::OPERATOR_AND) {} + public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} /** - * Return the current having clause + * Sets an OFFSET clause * - * @return string + * ```php + * $builder->offset(30); + * ``` + * + * @param int $offset + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getHaving() {} + public function offset(int $offset): BuilderInterface {} /** - * Sets a FOR UPDATE clause + * Sets an ORDER BY condition clause * - * - * $builder->forUpdate(true); - * + * ```php + * $builder->orderBy("Robots.name"); + * $builder->orderBy(["1", "Robots.name"]); + * $builder->orderBy(["Robots.name DESC"]); + * ``` * - * @param bool $forUpdate - * @return Builder + * @param string|array $orderBy + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function forUpdate($forUpdate) {} + public function orderBy($orderBy): BuilderInterface {} /** - * Sets a LIMIT clause, optionally an offset clause + * Appends a condition to the current HAVING conditions clause using an OR operator * - * - * $builder->limit(100); - * $builder->limit(100, 20); - * $builder->limit("100", "20"); - * + * ```php + * $builder->orHaving("SUM(Robots.price) > 0"); * - * @param int $limit - * @param mixed $offset - * @return Builder - */ - public function limit($limit, $offset = null) {} - - /** - * Returns the current LIMIT clause + * $builder->orHaving( + * "SUM(Robots.price) > :sum:", + * [ + * "sum" => 100, + * ] + * ); + * ``` * - * @return string|array + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getLimit() {} + public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets an OFFSET clause + * Appends a condition to the current conditions using an OR operator * - * - * $builder->offset(30); - * + * ```php + * $builder->orWhere("name = 'Peter'"); * - * @param int $offset - * @return Builder - */ - public function offset($offset) {} - - /** - * Returns the current OFFSET clause + * $builder->orWhere( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` * - * @return string|array + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getOffset() {} + public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** - * Sets a GROUP BY clause + * Adds a RIGHT join to the query * - * - * $builder->groupBy( - * [ - * "Robots.name", - * ] + * ```php + * $builder->rightJoin( + * Robots::class, + * "r.id = RobotsParts.robots_id", + * "r" * ); - * + * ``` * - * @param string|array $group - * @return Builder + * @param string $model + * @param string $conditions + * @param string $alias + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function groupBy($group) {} + public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} /** - * Returns the GROUP BY clause + * Set default bind parameters * - * @return string + * @param array $bindParams + * @param bool $merge + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getGroupBy() {} + public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface {} /** - * Returns a PHQL statement built based on the builder parameters + * Set default bind types * - * @return string + * @param array $bindTypes + * @param bool $merge + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public final function getPhql() {} + public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface {} /** - * Returns the query built + * Sets the DependencyInjector container * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param \Phalcon\Di\DiInterface $container + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function getQuery() {} + public function setDI(\Phalcon\Di\DiInterface $container): BuilderInterface {} /** - * Automatically escapes identifiers but only if they need to be escaped. + * Sets the query WHERE conditions * - * @param string $identifier - * @return string + * ```php + * $builder->where(100); + * + * $builder->where("name = 'Peter'"); + * + * $builder->where( + * "name = :name: AND id > :id:", + * [ + * "name" => "Peter", + * "id" => 100, + * ] + * ); + * ``` + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - final public function autoescape($identifier) {} + public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} /** * Appends a BETWEEN condition @@ -691,32 +766,32 @@ final public function autoescape($identifier) {} * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionBetween($clause, $operator, $expr, $minimum, $maximum) {} + protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} /** - * Appends a NOT BETWEEN condition + * Appends an IN condition * * @param string $clause * @param string $operator * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @return Builder + * @param array $values + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionNotBetween($clause, $operator, $expr, $minimum, $maximum) {} + protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} /** - * Appends an IN condition + * Appends a NOT BETWEEN condition * * @param string $clause * @param string $operator * @param string $expr - * @param array $values - * @return Builder + * @param mixed $minimum + * @param mixed $maximum + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionIn($clause, $operator, $expr, array $values) {} + protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} /** * Appends a NOT IN condition @@ -725,8 +800,8 @@ protected function _conditionIn($clause, $operator, $expr, array $values) {} * @param string $operator * @param string $expr * @param array $values - * @return Builder + * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function _conditionNotIn($clause, $operator, $expr, array $values) {} + protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index ced90250..636c17c6 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -10,151 +10,206 @@ interface BuilderInterface { + const OPERATOR_AND = 'and'; + + const OPERATOR_OR = 'or'; - const OPERATOR_AND = 'and'; + /** + * Add a model to take part of the query + * + * @param string $model + * @param string $alias + * @return BuilderInterface + */ + public function addFrom(string $model, string $alias = null): BuilderInterface; + + /** + * Appends a condition to the current conditions using a AND operator + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface + */ + public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + /** + * Appends a BETWEEN condition to the current conditions + * + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return BuilderInterface + */ + public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** * Sets the columns to be queried * * @param string|array $columns - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function columns($columns); + public function columns($columns): BuilderInterface; /** - * Return the columns to be queried + * Sets SELECT DISTINCT / SELECT ALL flag * - * @return string|array + * ```php + * $builder->distinct("status"); + * $builder->distinct(null); + * ``` + * + * @param mixed $distinct + * @return BuilderInterface */ - public function getColumns(); + public function distinct($distinct): BuilderInterface; + + /** + * Sets a FOR UPDATE clause + * + * ```php + * $builder->forUpdate(true); + * ``` + * + * @param bool $forUpdate + * @return BuilderInterface + */ + public function forUpdate(bool $forUpdate): BuilderInterface; /** * Sets the models who makes part of the query * * @param string|array $models - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function from($models); + public function from($models): BuilderInterface; /** - * Add a model to take part of the query + * Returns default bind params * - * @param string $model - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return array */ - public function addFrom($model, $alias = null); + public function getBindParams(): array; /** - * Return the models who makes part of the query + * Returns default bind types + * + * @return array + */ + public function getBindTypes(): array; + + /** + * Return the columns to be queried * * @return string|array */ - public function getFrom(); + public function getColumns(); /** - * Adds an :type: join (by default type - INNER) to the query + * Returns SELECT DISTINCT / SELECT ALL flag * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return bool */ - public function join($model, $conditions = null, $alias = null, $type = null); + public function getDistinct(): bool; /** - * Adds an INNER join to the query + * Return the models who makes part of the query * - * @param string $model - * @param string $conditions - * @param string $alias - * @param string $type - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string|array */ - public function innerJoin($model, $conditions = null, $alias = null); + public function getFrom(); /** - * Adds a LEFT join to the query + * Returns the GROUP BY clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\Builder + * @return array */ - public function leftJoin($model, $conditions = null, $alias = null); + public function getGroupBy(): array; /** - * Adds a RIGHT join to the query + * Returns the HAVING condition clause * - * @param string $model - * @param string $conditions - * @param string $alias - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string */ - public function rightJoin($model, $conditions = null, $alias = null); + public function getHaving(): string; /** * Return join parts of the query * * @return array */ - public function getJoins(); + public function getJoins(): array; /** - * Sets conditions for the query + * Returns the current LIMIT clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return string|array */ - public function where($conditions, $bindParams = null, $bindTypes = null); + public function getLimit(); /** - * Appends a condition to the current conditions using a AND operator + * Returns the current OFFSET clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\Builder + * @return int */ - public function andWhere($conditions, $bindParams = null, $bindTypes = null); + public function getOffset(): int; /** - * Appends a condition to the current conditions using an OR operator + * Return the set ORDER BY clause * - * @param string $conditions - * @param array $bindParams - * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string|array */ - public function orWhere($conditions, $bindParams = null, $bindTypes = null); + public function getOrderBy(); /** - * Appends a BETWEEN condition to the current conditions + * Returns a PHQL statement built based on the builder parameters * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\Builder + * @return string */ - public function betweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); + public function getPhql(): string; /** - * Appends a NOT BETWEEN condition to the current conditions + * Returns the query built * - * @param string $expr - * @param mixed $minimum - * @param mixed $maximum - * @param string $operator - * @return \Phalcon\Mvc\Model\Query\Builder + * @return \Phalcon\Mvc\Model\QueryInterface + */ + public function getQuery(): QueryInterface; + + /** + * Return the conditions for the query + * + * @return string|array + */ + public function getWhere(); + + /** + * Sets a GROUP BY clause + * + * @param string|array $group + * @return BuilderInterface + */ + public function groupBy($group): BuilderInterface; + + /** + * Sets a HAVING condition clause + * + * @param string $having + * @return BuilderInterface + */ + public function having(string $having): BuilderInterface; + + /** + * Adds an INNER join to the query + * + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderInterface::OPERATOR_AND); + public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** * Appends an IN condition to the current conditions @@ -164,98 +219,128 @@ public function notBetweenWhere($expr, $minimum, $maximum, $operator = BuilderIn * @param string $operator * @return BuilderInterface */ - public function inWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); + public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Appends a NOT IN condition to the current conditions + * Adds an :type: join (by default type - INNER) to the query * - * @param string $expr - * @param array $values - * @param string $operator + * @param string $model + * @param string $conditions + * @param string $alias + * @param string $type * @return BuilderInterface */ - public function notInWhere($expr, array $values, $operator = BuilderInterface::OPERATOR_AND); + public function join(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Return the conditions for the query + * Adds a LEFT join to the query * - * @return string|array + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function getWhere(); + public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Sets an ORDER BY condition clause + * Sets a LIMIT clause * - * @param string $orderBy - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param int $limit + * @param int $offset + * @return BuilderInterface */ - public function orderBy($orderBy); + public function limit(int $limit, $offset = null): BuilderInterface; /** - * Return the set ORDER BY clause + * Returns the models involved in the query * - * @return string|array + * @return string|array|null */ - public function getOrderBy(); + public function getModels(); /** - * Sets a HAVING condition clause + * Appends a NOT BETWEEN condition to the current conditions * - * @param string $having - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $expr + * @param mixed $minimum + * @param mixed $maximum + * @param string $operator + * @return BuilderInterface */ - public function having($having); + public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Returns the HAVING condition clause + * Appends a NOT IN condition to the current conditions * - * @return string|array + * @param string $expr + * @param array $values + * @param string $operator + * @return BuilderInterface */ - public function getHaving(); + public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface; /** - * Sets a LIMIT clause + * Sets an OFFSET clause * - * @param int $limit * @param int $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ - public function limit($limit, $offset = null); + public function offset(int $offset): BuilderInterface; /** - * Returns the current LIMIT clause + * Sets an ORDER BY condition clause * - * @return string|array + * @param string $orderBy + * @return BuilderInterface */ - public function getLimit(); + public function orderBy(string $orderBy): BuilderInterface; /** - * Sets a LIMIT clause + * Appends a condition to the current conditions using an OR operator * - * @param string|array $group - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface */ - public function groupBy($group); + public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; /** - * Returns the GROUP BY clause + * Adds a RIGHT join to the query * - * @return string + * @param string $model + * @param string $conditions + * @param string $alias + * @return BuilderInterface */ - public function getGroupBy(); + public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface; /** - * Returns a PHQL statement built based on the builder parameters + * Set default bind parameters * - * @return string + * @param array $bindParams + * @param bool $merge + * @return BuilderInterface */ - public function getPhql(); + public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface; /** - * Returns the query built + * Set default bind types * - * @return \Phalcon\Mvc\Model\QueryInterface + * @param array $bindTypes + * @param bool $merge + * @return BuilderInterface + */ + public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface; + + /** + * Sets conditions for the query + * + * @param string $conditions + * @param array $bindParams + * @param array $bindTypes + * @return BuilderInterface */ - public function getQuery(); + public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 5f453526..28727de1 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -15,9 +15,11 @@ * the same technology as SQLite. This technology provides a small in-memory * parser with a very low memory footprint that is also thread-safe. * - * - * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL("SELECT r. FROM Robots r LIMIT 10"); - * + * ```php + * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL( + * "SELECT r. FROM Robots r LIMIT 10" + * ); + * ``` */ abstract class Lang { @@ -28,6 +30,6 @@ abstract class Lang * @param string $phql * @return string */ - public static function parsePHQL($phql) {} + public static function parsePHQL(string $phql): string {} } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index ba75ee6d..f902467d 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -10,7 +10,7 @@ * information and the related messages produced by the * model which finally executes the operations when it fails * - * + * ```php * $phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:"; * * $status = $app->modelsManager->executeQuery( @@ -24,18 +24,18 @@ * ); * * // Check if the update was successful - * if ($status->success() === true) { + * if ($status->success()) { * echo "OK"; * } - * + * ``` */ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { - protected $_success; + protected $model; - protected $_model; + protected $success; /** @@ -44,27 +44,27 @@ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface * @param bool $success * @param \Phalcon\Mvc\ModelInterface $model */ - public function __construct($success, \Phalcon\Mvc\ModelInterface $model = null) {} + public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) {} /** - * Returns the model that executed the action + * Returns the messages produced because of a failed operation * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getModel() {} + public function getMessages(): array {} /** - * Returns the messages produced because of a failed operation + * Returns the model that executed the action * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages() {} + public function getModel(): ModelInterface {} /** * Allows to check if the executed operation was successful * * @return bool */ - public function success() {} + public function success(): bool {} } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index b2980bec..1f16632c 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -11,24 +11,24 @@ interface StatusInterface { /** - * Returns the model which executed the action + * Returns the messages produced by an operation failed * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getModel(); + public function getMessages(): array; /** - * Returns the messages produced by an operation failed + * Returns the model which executed the action * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getMessages(); + public function getModel(): ModelInterface; /** * Allows to check if the executed operation was successful * * @return bool */ - public function success(); + public function success(): bool; } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 793e38d0..7f057733 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -11,12 +11,13 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model\ResultsetInterface { - protected $_columnTypes; + protected $columnTypes; /** - * Unserialised result-set hydrated all rows already. unserialise() sets _disableHydration to true + * Unserialised result-set hydrated all rows already. unserialise() sets + * disableHydration to true */ - protected $_disableHydration = false; + protected $disableHydration = false; /** @@ -24,31 +25,31 @@ class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model * * @param array $columnTypes * @param \Phalcon\Db\ResultInterface $result - * @param \Phalcon\Cache\BackendInterface $cache + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\BackendInterface $cache = null) {} + public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} /** * Returns current row in the resultset * * @return bool|ModelInterface */ - public final function current() {} + final public function current() {} /** - * Returns a complete resultset as an array, if the resultset has a big number of rows - * it could consume more memory than currently it does. + * Returns a complete resultset as an array, if the resultset has a big + * number of rows it could consume more memory than currently it does. * * @return array */ - public function toArray() {} + public function toArray(): array {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize() {} + public function serialize(): string {} /** * Unserializing a resultset will allow to only works on the rows present in the saved state diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 8d377287..1209af8a 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -11,13 +11,15 @@ class Simple extends \Phalcon\Mvc\Model\Resultset { - protected $_model; + protected $columnMap; - protected $_columnMap; + protected $model; - - protected $_keepSnapshots = false; + /** + * @var bool + */ + protected $keepSnapshots = false; /** @@ -25,38 +27,40 @@ class Simple extends \Phalcon\Mvc\Model\Resultset * * @param array $columnMap * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $model - * @param \Phalcon\Db\Result\Pdo|null $result - * @param \Phalcon\Cache\BackendInterface $cache - * @param boolean $keepSnapshots + * @param mixed $result + * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param bool $keepSnapshots */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\BackendInterface $cache = null, $keepSnapshots = null) {} + public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) {} /** * Returns current row in the resultset * - * @return bool|ModelInterface + * @return null|ModelInterface */ - public final function current() {} + final public function current(): ?ModelInterface {} /** - * Returns a complete resultset as an array, if the resultset has a big number of rows - * it could consume more memory than currently it does. Export the resultset to an array - * couldn't be faster with a large number of records + * Returns a complete resultset as an array, if the resultset has a big + * number of rows it could consume more memory than currently it does. + * Export the resultset to an array couldn't be faster with a large number + * of records * * @param bool $renameColumns * @return array */ - public function toArray($renameColumns = true) {} + public function toArray(bool $renameColumns = true): array {} /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize() {} + public function serialize(): string {} /** - * Unserializing a resultset will allow to only works on the rows present in the saved state + * Unserializing a resultset will allow to only works on the rows present in + * the saved state * * @param mixed $data */ diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 725b413e..08fa28f4 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -10,7 +10,7 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception { - protected $_record = null; + protected $record = null; /** @@ -19,20 +19,20 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception * @param string $message * @param \Phalcon\Mvc\ModelInterface $record */ - public function __construct($message, \Phalcon\Mvc\ModelInterface $record = null) {} + public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) {} /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\Model\MessageInterface[] + * @return \Phalcon\Mvc\ModelInterface */ - public function getRecordMessages() {} + public function getRecord(): ModelInterface {} /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\ModelInterface + * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getRecord() {} + public function getRecordMessages(): array {} } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index faf1aa4a..31af4afd 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -5,14 +5,15 @@ /** * Phalcon\Mvc\Model\Transaction\Manager * - * A transaction acts on a single database connection. If you have multiple class-specific - * databases, the transaction will not protect interaction among them. + * A transaction acts on a single database connection. If you have multiple + * class-specific databases, the transaction will not protect interaction among + * them. * * This class manages the objects that compose a transaction. - * A transaction produces a unique connection that is passed to every - * object part of the transaction. + * A transaction produces a unique connection that is passed to every object + * part of the transaction. * - * + * ```php * use Phalcon\Mvc\Model\Transaction\Failed; * use Phalcon\Mvc\Model\Transaction\Manager; * @@ -28,7 +29,7 @@ * $robot->name = "WALL·E"; * $robot->created_at = date("Y-m-d"); * - * if ($robot->save() === false){ + * if ($robot->save() === false) { * $transaction->rollback("Can't save robot"); * } * @@ -46,146 +47,150 @@ * } catch (Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * + * ``` */ class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; + protected $container; - protected $_initialized = false; + protected $initialized = false; - protected $_rollbackPendent = true; + protected $number = 0; - protected $_number = 0; + protected $rollbackPendent = true; - protected $_service = 'db'; + protected $service = 'db'; - - protected $_transactions; + /** + * @var array + */ + protected $transactions = array(); /** * Phalcon\Mvc\Model\Transaction\Manager constructor * - * @param \Phalcon\DiInterface $dependencyInjector + * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\DiInterface $dependencyInjector = null) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) {} /** - * Sets the dependency injection container - * - * @param \Phalcon\DiInterface $dependencyInjector + * Remove all the transactions from the manager */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} + public function collectTransactions() {} /** - * Returns the dependency injection container - * - * @return \Phalcon\DiInterface + * Commits active transactions within the manager */ - public function getDI() {} + public function commit() {} /** - * Sets the database service used to run the isolated transactions + * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once + * This method registers a shutdown function to rollback active connections * - * @param string $service - * @return Manager + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function setDbService($service) {} + public function get(bool $autoBegin = true): TransactionInterface {} /** * Returns the database service used to isolate the transaction * * @return string */ - public function getDbService() {} + public function getDbService(): string {} /** - * Set if the transaction manager must register a shutdown function to clean up pendent transactions + * Returns the dependency injection container * - * @param bool $rollbackPendent - * @return Manager + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Create/Returns a new transaction or an existing one + * + * @param bool $autoBegin + * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function setRollbackPendent($rollbackPendent) {} + public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface {} /** - * Check if the transaction manager is registering a shutdown function to clean up pendent transactions + * Check if the transaction manager is registering a shutdown function to + * clean up pendent transactions * * @return bool */ - public function getRollbackPendent() {} + public function getRollbackPendent(): bool {} /** * Checks whether the manager has an active transaction * * @return bool */ - public function has() {} + public function has(): bool {} /** - * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once - * This method registers a shutdown function to rollback active connections + * Notifies the manager about a committed transaction * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function get($autoBegin = true) {} + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** - * Create/Returns a new transaction or an existing one + * Notifies the manager about a rollbacked transaction * - * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function getOrCreateTransaction($autoBegin = true) {} + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} /** * Rollbacks active transactions within the manager + * Collect will remove the transaction from the manager + * + * @param bool $collect */ - public function rollbackPendent() {} + public function rollback(bool $collect = true) {} /** - * Commits active transactions within the manager + * Rollbacks active transactions within the manager */ - public function commit() {} + public function rollbackPendent() {} /** - * Rollbacks active transactions within the manager - * Collect will remove the transaction from the manager + * Sets the database service used to run the isolated transactions * - * @param boolean $collect + * @param string $service + * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function rollback($collect = true) {} + public function setDbService(string $service): ManagerInterface {} /** - * Notifies the manager about a rollbacked transaction + * Sets the dependency injection container * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param \Phalcon\Di\DiInterface $container */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** - * Notifies the manager about a committed transaction + * Set if the transaction manager must register a shutdown function to clean + * up pendent transactions * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $rollbackPendent + * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function setRollbackPendent(bool $rollbackPendent): ManagerInterface {} /** * Removes transactions from the TransactionManager * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - protected function _collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} - - /** - * Remove all the transactions from the manager - */ - public function collectTransactions() {} + protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index d2c1b841..21fa668d 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -11,11 +11,14 @@ interface ManagerInterface { /** - * Checks whether manager has an active transaction - * - * @return bool + * Remove all the transactions from the manager + */ + public function collectTransactions(); + + /** + * Commits active transactions within the manager */ - public function has(); + public function commit(); /** * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once @@ -23,25 +26,35 @@ public function has(); * @param bool $autoBegin * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function get($autoBegin = true); + public function get(bool $autoBegin = true): TransactionInterface; /** - * Rollbacks active transactions within the manager + * Returns the database service used to isolate the transaction + * + * @return string */ - public function rollbackPendent(); + public function getDbService(): string; /** - * Commits active transactions within the manager + * Check if the transaction manager is registering a shutdown function to clean up pendent transactions + * + * @return bool */ - public function commit(); + public function getRollbackPendent(): bool; /** - * Rollbacks active transactions within the manager - * Collect will remove transaction from the manager + * Checks whether manager has an active transaction * - * @param boolean $collect + * @return bool */ - public function rollback($collect = false); + public function has(): bool; + + /** + * Notifies the manager about a committed transaction + * + * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + */ + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** * Notifies the manager about a rollbacked transaction @@ -51,15 +64,32 @@ public function rollback($collect = false); public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); /** - * Notifies the manager about a committed transaction + * Rollbacks active transactions within the manager + * Collect will remove transaction from the manager * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param bool $collect */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function rollback(bool $collect = false); /** - * Remove all the transactions from the manager + * Rollbacks active transactions within the manager */ - public function collectTransactions(); + public function rollbackPendent(); + + /** + * Sets the database service used to run the isolated transactions + * + * @param string $service + * @return ManagerInterface + */ + public function setDbService(string $service): ManagerInterface; + + /** + * Set if the transaction manager must register a shutdown function to clean up pendent transactions + * + * @param bool $rollbackPendent + * @return ManagerInterface + */ + public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; } diff --git a/src/Phalcon/mvc/model/validator/Email.php b/src/Phalcon/mvc/model/validator/Email.php deleted file mode 100644 index 62825bce..00000000 --- a/src/Phalcon/mvc/model/validator/Email.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Email as EmailValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new EmailValidator( - * [ - * "field" => "electronic_mail", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Email - */ -class Email extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Exclusionin.php b/src/Phalcon/mvc/model/validator/Exclusionin.php deleted file mode 100644 index cd444ce3..00000000 --- a/src/Phalcon/mvc/model/validator/Exclusionin.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionInValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new ExclusionInValidator( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\EclusionIn - */ -class Exclusionin extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Inclusionin.php b/src/Phalcon/mvc/model/validator/Inclusionin.php deleted file mode 100644 index d506ab45..00000000 --- a/src/Phalcon/mvc/model/validator/Inclusionin.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\InclusionIn as InclusionInValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new InclusionInValidator( - * [ - * "field" => "status", - * "domain" => ["A", "I"], - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\InclusionIn - */ -class Inclusionin extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Ip.php b/src/Phalcon/mvc/model/validator/Ip.php deleted file mode 100644 index f6ca5e5d..00000000 --- a/src/Phalcon/mvc/model/validator/Ip.php +++ /dev/null @@ -1,82 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Ip; - * - * class Data extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * // Any pubic IP - * $this->validate( - * new IP( - * [ - * "field" => "server_ip", - * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified - * "allowReserved" => false, // False if not specified. Ignored for v6 - * "allowPrivate" => false, // False if not specified - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * // Any public v4 address - * $this->validate( - * new IP( - * [ - * "field" => "ip_4", - * "version" => IP::VERSION_4, - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * // Any v6 address - * $this->validate( - * new IP( - * [ - * "field" => "ip6", - * "version" => IP::VERSION_6, - * "allowPrivate" => true, - * "message" => "IP address has to be correct", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - */ -class Ip extends \Phalcon\Mvc\Model\Validator -{ - - const VERSION_4 = 1048576; - - - const VERSION_6 = 2097152; - - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Numericality.php b/src/Phalcon/mvc/model/validator/Numericality.php deleted file mode 100644 index 9878eac2..00000000 --- a/src/Phalcon/mvc/model/validator/Numericality.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Numericality as NumericalityValidator; - * - * class Products extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new NumericalityValidator( - * [ - * "field" => "price", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Numericality - */ -class Numericality extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/PresenceOf.php b/src/Phalcon/mvc/model/validator/PresenceOf.php deleted file mode 100644 index 229e417c..00000000 --- a/src/Phalcon/mvc/model/validator/PresenceOf.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\PresenceOf; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new PresenceOf( - * [ - * "field" => "name", - * "message" => "The name is required", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\PresenceOf - */ -class PresenceOf extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Regex.php b/src/Phalcon/mvc/model/validator/Regex.php deleted file mode 100644 index 64b6ee12..00000000 --- a/src/Phalcon/mvc/model/validator/Regex.php +++ /dev/null @@ -1,50 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Regex as RegexValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new RegexValidator( - * [ - * "field" => "created_at", - * "pattern" => "/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])/", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() == true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Regex - */ -class Regex extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/StringLength.php b/src/Phalcon/mvc/model/validator/StringLength.php deleted file mode 100644 index 91a7701f..00000000 --- a/src/Phalcon/mvc/model/validator/StringLength.php +++ /dev/null @@ -1,53 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\StringLength as StringLengthValidator; - * - * class Subscriptors extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new StringLengthValidator( - * [ - * "field" => "name_last", - * "max" => 50, - * "min" => 2, - * "messageMaximum" => "We don't like really long names", - * "messageMinimum" => "We want more than just their initials", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\StringLength - */ -class StringLength extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Uniqueness.php b/src/Phalcon/mvc/model/validator/Uniqueness.php deleted file mode 100644 index c9cb687b..00000000 --- a/src/Phalcon/mvc/model/validator/Uniqueness.php +++ /dev/null @@ -1,52 +0,0 @@ - - * use Phalcon\Mvc\Collection; - * use Phalcon\Mvc\Model\Validator\Uniqueness; - * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $this->validate( - * new Uniqueness( - * [ - * "field" => "email", - * "message" => "Value of field 'email' is already present in another record", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Uniqueness - */ -class Uniqueness extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/model/validator/Url.php b/src/Phalcon/mvc/model/validator/Url.php deleted file mode 100644 index 28ee074f..00000000 --- a/src/Phalcon/mvc/model/validator/Url.php +++ /dev/null @@ -1,49 +0,0 @@ - - * use Phalcon\Mvc\Model\Validator\Url as UrlValidator; - * - * class Posts extends \Phalcon\Mvc\Collection - * { - * public function validation() - * { - * $this->validate( - * new UrlValidator( - * [ - * "field" => "source_url", - * ] - * ) - * ); - * - * if ($this->validationHasFailed() === true) { - * return false; - * } - * } - * } - * - * - * @deprecated 3.1.0 - * @see Phalcon\Validation\Validator\Url - */ -class Url extends \Phalcon\Mvc\Model\Validator -{ - - /** - * Executes the validator - * - * @param \Phalcon\Mvc\EntityInterface $record - * @return bool - */ - public function validate(\Phalcon\Mvc\EntityInterface $record) {} - -} diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 18c4db8c..b8adad00 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -7,7 +7,7 @@ * * A router that reads routes annotations from classes/resources * - * + * ```php * use Phalcon\Mvc\Router\Annotations; * * $di->setShared( @@ -22,59 +22,58 @@ * return $router; * } * ); - * + * ``` */ class Annotations extends \Phalcon\Mvc\Router { - protected $_handlers = array(); + protected $actionSuffix = 'Action'; - protected $_controllerSuffix = 'Controller'; + protected $controllerSuffix = 'Controller'; - protected $_actionSuffix = 'Action'; + protected $handlers = array(); - protected $_routePrefix; + protected $routePrefix; /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations + * The class is located in a module * + * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addResource($handler, $prefix = null) {} + public function addModuleResource(string $module, string $handler, string $prefix = null): Annotations {} /** * Adds a resource to the annotations handler * A resource is a class that contains routing annotations - * The class is located in a module * - * @param string $module * @param string $handler * @param string $prefix * @return Annotations */ - public function addModuleResource($module, $handler, $prefix = null) {} + public function addResource(string $handler, string $prefix = null): Annotations {} /** - * Produce the routing parameters from the rewrite information + * Return the registered resources * - * @param string $uri + * @return array */ - public function handle($uri = null) {} + public function getResources(): array {} /** - * Checks for annotations in the controller docblock + * Produce the routing parameters from the rewrite information * - * @param string $handler - * @param \Phalcon\Annotations\Annotation $annotation + * @param string $uri */ - public function processControllerAnnotation($handler, \Phalcon\Annotations\Annotation $annotation) {} + public function handle(string $uri) {} /** * Checks for annotations in the public methods of the controller @@ -85,27 +84,28 @@ public function processControllerAnnotation($handler, \Phalcon\Annotations\Annot * @param string $action * @param \Phalcon\Annotations\Annotation $annotation */ - public function processActionAnnotation($module, $namespaceName, $controller, $action, \Phalcon\Annotations\Annotation $annotation) {} + public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) {} /** - * Changes the controller class suffix + * Checks for annotations in the controller docblock * - * @param string $controllerSuffix + * @param string $handler + * @param \Phalcon\Annotations\Annotation $annotation */ - public function setControllerSuffix($controllerSuffix) {} + public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) {} /** * Changes the action method suffix * * @param string $actionSuffix */ - public function setActionSuffix($actionSuffix) {} + public function setActionSuffix(string $actionSuffix) {} /** - * Return the registered resources + * Changes the controller class suffix * - * @return array + * @param string $controllerSuffix */ - public function getResources() {} + public function setControllerSuffix(string $controllerSuffix) {} } diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index e89389c2..864e7821 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -7,7 +7,7 @@ * * Helper class to create a group of routes with common attributes * - * + * ```php * $router = new \Phalcon\Mvc\Router(); * * //Create a group with a common module and controller @@ -48,24 +48,24 @@ * * //Add the group to the router * $router->mount($blog); - * + * ``` */ class Group implements \Phalcon\Mvc\Router\GroupInterface { - protected $_prefix; + protected $beforeMatch; - protected $_hostname; + protected $hostname; - protected $_paths; + protected $paths; - protected $_routes; + protected $prefix; - protected $_beforeMatch; + protected $routes; /** @@ -76,155 +76,182 @@ class Group implements \Phalcon\Mvc\Router\GroupInterface public function __construct($paths = null) {} /** - * Set a hostname restriction for all the routes in the group + * Adds a route to the router on any HTTP method * - * @param string $hostname - * @return GroupInterface + * ```php + * $router->add("/about", "About::index"); + * ``` + * + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return RouteInterface */ - public function setHostname($hostname) {} + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} /** - * Returns the hostname restriction + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @return string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getHostname() {} + public function addConnect(string $pattern, $paths = null): RouteInterface {} /** - * Set a common uri prefix for all the routes in this group + * Adds a route to the router that only match if the HTTP method is DELETE * - * @param string $prefix - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setPrefix($prefix) {} + public function addDelete(string $pattern, $paths = null): RouteInterface {} /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is GET * - * @return string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getPrefix() {} + public function addGet(string $pattern, $paths = null): RouteInterface {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Adds a route to the router that only match if the HTTP method is HEAD * - * @param callable $beforeMatch - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function beforeMatch($beforeMatch) {} + public function addHead(string $pattern, $paths = null): RouteInterface {} /** - * Returns the 'before match' callback if any + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @return callable + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getBeforeMatch() {} + public function addOptions(string $pattern, $paths = null): RouteInterface {} /** - * Set common paths for all the routes in the group + * Adds a route to the router that only match if the HTTP method is PATCH * - * @param mixed $paths - * @return GroupInterface + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function setPaths($paths) {} + public function addPatch(string $pattern, $paths = null): RouteInterface {} /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is POST * - * @return array|string + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getPaths() {} + public function addPost(string $pattern, $paths = null): RouteInterface {} /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is PURGE * - * @return RouteInterface[] + * @param string $pattern + * @param string|array $paths + * @return RouteInterface */ - public function getRoutes() {} + public function addPurge(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router on any HTTP method - * - * - * $router->add("/about", "About::index"); - * + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern - * @param mixed $paths - * @param mixed $httpMethods + * @param string|array $paths * @return RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null) {} + public function addPut(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern - * @param string/array $paths + * @param string|array $paths * @return RouteInterface */ - public function addGet($pattern, $paths = null) {} + public function addTrace(string $pattern, $paths = null): RouteInterface {} /** - * Adds a route to the router that only match if the HTTP method is POST + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addPost($pattern, $paths = null) {} + public function beforeMatch($beforeMatch): GroupInterface {} /** - * Adds a route to the router that only match if the HTTP method is PUT + * Removes all the pre-defined routes + */ + public function clear() {} + + /** + * Returns the 'before match' callback if any * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return callable */ - public function addPut($pattern, $paths = null) {} + public function getBeforeMatch() {} /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Returns the hostname restriction * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return string */ - public function addPatch($pattern, $paths = null) {} + public function getHostname(): string {} /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the common paths defined for this group * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return array|string */ - public function addDelete($pattern, $paths = null) {} + public function getPaths() {} /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the common prefix for all the routes * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return string */ - public function addOptions($pattern, $paths = null) {} + public function getPrefix(): string {} /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the routes added to the group * - * @param string $pattern - * @param string/array $paths - * @return RouteInterface + * @return array|RouteInterface[] */ - public function addHead($pattern, $paths = null) {} + public function getRoutes(): array {} /** - * Removes all the pre-defined routes + * Set a hostname restriction for all the routes in the group + * + * @param string $hostname + * @return GroupInterface */ - public function clear() {} + public function setHostname(string $hostname): GroupInterface {} + + /** + * Set common paths for all the routes in the group + * + * @param mixed $paths + * @return GroupInterface + */ + public function setPaths($paths): GroupInterface {} + + /** + * Set a common uri prefix for all the routes in this group + * + * @param string $prefix + * @return GroupInterface + */ + public function setPrefix(string $prefix): GroupInterface {} /** * Adds a route applying the common attributes @@ -234,6 +261,6 @@ public function clear() {} * @param mixed $httpMethods * @return RouteInterface */ - protected function _addRoute($pattern, $paths = null, $httpMethods = null) {} + protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index dd9a10b1..33d59115 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -5,7 +5,7 @@ /** * Phalcon\Mvc\Router\GroupInterface * - * + * ```php * $router = new \Phalcon\Mvc\Router(); * * // Create a group with a common module and controller @@ -46,160 +46,187 @@ * * // Add the group to the router * $router->mount($blog); - * + * ``` */ interface GroupInterface { /** - * Set a hostname restriction for all the routes in the group + * Adds a route to the router on any HTTP method * - * @param string $hostname - * @return GroupInterface - */ - public function setHostname($hostname); - - /** - * Returns the hostname restriction + * ```php + * router->add("/about", "About::index"); + * ``` * - * @return string + * @param string $pattern + * @param mixed $paths + * @param mixed $httpMethods + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getHostname(); + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; /** - * Set a common uri prefix for all the routes in this group + * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $prefix - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPrefix($prefix); + public function addConnect(string $pattern, $paths = null): RouteInterface; /** - * Returns the common prefix for all the routes + * Adds a route to the router that only match if the HTTP method is DELETE * - * @return string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPrefix(); + public function addDelete(string $pattern, $paths = null): RouteInterface; /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched + * Adds a route to the router that only match if the HTTP method is GET * - * @param callable $beforeMatch - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function beforeMatch($beforeMatch); + public function addGet(string $pattern, $paths = null): RouteInterface; /** - * Returns the 'before match' callback if any + * Adds a route to the router that only match if the HTTP method is HEAD * - * @return callable + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getBeforeMatch(); + public function addHead(string $pattern, $paths = null): RouteInterface; /** - * Set common paths for all the routes in the group + * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param array $paths - * @return GroupInterface + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function setPaths($paths); + public function addOptions(string $pattern, $paths = null): RouteInterface; /** - * Returns the common paths defined for this group + * Adds a route to the router that only match if the HTTP method is PATCH * - * @return array|string + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getPaths(); + public function addPatch(string $pattern, $paths = null): RouteInterface; /** - * Returns the routes added to the group + * Adds a route to the router that only match if the HTTP method is POST * - * @return \Phalcon\Mvc\Router\RouteInterface[] + * @param string $pattern + * @param mixed $paths + * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getRoutes(); + public function addPost(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router on any HTTP method - * - * - * router->add("/about", "About::index"); - * + * Adds a route to the router that only match if the HTTP method is PURGE * * @param string $pattern * @param mixed $paths - * @param mixed $httpMethods * @return \Phalcon\Mvc\Router\RouteInterface */ - public function add($pattern, $paths = null, $httpMethods = null); + public function addPurge(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is GET + * Adds a route to the router that only match if the HTTP method is PUT * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet($pattern, $paths = null); + public function addPut(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is POST + * Adds a route to the router that only match if the HTTP method is TRACE * * @param string $pattern * @param mixed $paths * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost($pattern, $paths = null); + public function addTrace(string $pattern, $paths = null): RouteInterface; /** - * Adds a route to the router that only match if the HTTP method is PUT + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @param callable $beforeMatch + * @return GroupInterface */ - public function addPut($pattern, $paths = null); + public function beforeMatch($beforeMatch): GroupInterface; /** - * Adds a route to the router that only match if the HTTP method is PATCH + * Removes all the pre-defined routes + */ + public function clear(); + + /** + * Returns the 'before match' callback if any * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return callable */ - public function addPatch($pattern, $paths = null); + public function getBeforeMatch(); /** - * Adds a route to the router that only match if the HTTP method is DELETE + * Returns the hostname restriction * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addDelete($pattern, $paths = null); + public function getHostname(): string; /** - * Add a route to the router that only match if the HTTP method is OPTIONS + * Returns the common paths defined for this group * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return array|string */ - public function addOptions($pattern, $paths = null); + public function getPaths(); /** - * Adds a route to the router that only match if the HTTP method is HEAD + * Returns the common prefix for all the routes * - * @param string $pattern - * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return string */ - public function addHead($pattern, $paths = null); + public function getPrefix(): string; /** - * Removes all the pre-defined routes + * Returns the routes added to the group + * + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function clear(); + public function getRoutes(): array; + + /** + * Set a hostname restriction for all the routes in the group + * + * @param string $hostname + * @return GroupInterface + */ + public function setHostname(string $hostname): GroupInterface; + + /** + * Set common paths for all the routes in the group + * + * @param array $paths + * @return GroupInterface + */ + public function setPaths($paths): GroupInterface; + + /** + * Set a common uri prefix for all the routes in this group + * + * @param string $prefix + * @return GroupInterface + */ + public function setPrefix(string $prefix): GroupInterface; } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 8397b84f..5f86e634 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -10,40 +10,40 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface { - protected $_pattern; + protected $beforeMatch; - protected $_compiledPattern; + protected $compiledPattern; - protected $_paths; + protected $converters; - protected $_methods; + protected $group; - protected $_hostname; + protected $hostname; - protected $_converters; + protected $id; - protected $_id; + protected $methods; - protected $_name; + protected $match; - protected $_beforeMatch; + protected $name; - protected $_match; + protected $paths; - protected $_group; + protected $pattern; - static protected $_uniqueId; + static protected $uniqueId = 0; @@ -56,137 +56,103 @@ public function getId() {} * @param mixed $paths * @param mixed $httpMethods */ - public function __construct($pattern, $paths = null, $httpMethods = null) {} + public function __construct(string $pattern, $paths = null, $httpMethods = null) {} /** - * Replaces placeholders from pattern returning a valid PCRE regular expression - * - * @param string $pattern - * @return string - */ - public function compilePattern($pattern) {} - - /** - * Set one or more HTTP methods that constraint the matching of the route - * - * - * $route->via("GET"); + * Sets a callback that is called if the route is matched. + * The developer can implement any arbitrary conditions here + * If the callback returns false the route is treated as not matched * - * $route->via( + * ```php + * $router->add( + * "/login", * [ - * "GET", - * "POST", + * "module" => "admin", + * "controller" => "session", * ] + * )->beforeMatch( + * function ($uri, $route) { + * // Check if the request was made with Ajax + * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { + * return false; + * } + * + * return true; + * } * ); - * + * ``` * - * @param mixed $httpMethods - * @return Route + * @param mixed $callback + * @return RouteInterface */ - public function via($httpMethods) {} + public function beforeMatch($callback): RouteInterface {} /** - * Extracts parameters from a string + * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string $pattern - * @return array|bool + * @return string */ - public function extractNamedParams($pattern) {} + public function compilePattern(string $pattern): string {} /** - * Reconfigure the route adding a new pattern and a set of paths + * {@inheritdoc} + * + * @param string $name + * @param mixed $converter + * @return RouteInterface + */ + public function convert(string $name, $converter): RouteInterface {} + + /** + * Extracts parameters from a string * * @param string $pattern - * @param mixed $paths + * @return array|bool */ - public function reConfigure($pattern, $paths = null) {} + public function extractNamedParams(string $pattern) {} /** - * Returns routePaths + * Returns the 'before match' callback if any * - * @param mixed $paths - * @return array + * @return callable */ - public static function getRoutePaths($paths = null) {} + public function getBeforeMatch() {} /** - * Returns the route's name + * Returns the route's compiled pattern * * @return string */ - public function getName() {} + public function getCompiledPattern(): string {} /** - * Sets the route's name - * - * - * $router->add( - * "/about", - * [ - * "controller" => "about", - * ] - * )->setName("about"); - * + * Returns the router converter * - * @param string $name - * @return Route + * @return array */ - public function setName($name) {} + public function getConverters(): array {} /** - * Sets a callback that is called if the route is matched. - * The developer can implement any arbitrary conditions here - * If the callback returns false the route is treated as not matched - * - * - * $router->add( - * "/login", - * [ - * "module" => "admin", - * "controller" => "session", - * ] - * )->beforeMatch( - * function ($uri, $route) { - * // Check if the request was made with Ajax - * if ($_SERVER["HTTP_X_REQUESTED_WITH"] === "xmlhttprequest") { - * return false; - * } - * - * return true; - * } - * ); - * + * Returns the group associated with the route * - * @param mixed $callback - * @return Route + * @return null|GroupInterface */ - public function beforeMatch($callback) {} + public function getGroup(): ?GroupInterface {} /** - * Returns the 'before match' callback if any + * Returns the HTTP methods that constraint matching the route * - * @return callable + * @return array|string */ - public function getBeforeMatch() {} + public function getHttpMethods() {} /** - * Allows to set a callback to handle the request directly in the route - * - * - * $router->add( - * "/help", - * [] - * )->match( - * function () { - * return $this->getResponse()->redirect("https://support.google.com/", true); - * } - * ); - * + * Returns the hostname restriction if any * - * @param mixed $callback - * @return Route + * @return string */ - public function match($callback) {} + public function getHostname(): string {} /** * Returns the 'match' callback if any @@ -196,137 +162,153 @@ public function match($callback) {} public function getMatch() {} /** - * Returns the route's id + * Returns the route's name * * @return string */ - public function getRouteId() {} + public function getName(): string {} /** - * Returns the route's pattern + * Returns the paths * - * @return string + * @return array */ - public function getPattern() {} + public function getPaths(): array {} /** - * Returns the route's compiled pattern + * Returns the route's pattern * * @return string */ - public function getCompiledPattern() {} - - /** - * Returns the paths - * - * @return array - */ - public function getPaths() {} + public function getPattern(): string {} /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths() {} + public function getReversedPaths(): array {} /** - * Sets a set of HTTP methods that constraint the matching of the route (alias of via) - * - * - * $route->setHttpMethods("GET"); - * $route->setHttpMethods(["GET", "POST"]); - * + * Returns the route's id * - * @param mixed $httpMethods - * @return RouteInterface + * @return string */ - public function setHttpMethods($httpMethods) {} + public function getRouteId(): string {} /** - * Returns the HTTP methods that constraint matching the route + * Returns routePaths * - * @return array|string + * @param mixed $paths + * @return array */ - public function getHttpMethods() {} + public static function getRoutePaths($paths = null): array {} /** - * Sets a hostname restriction to the route + * Allows to set a callback to handle the request directly in the route * - * - * $route->setHostname("localhost"); - * + * ```php + * $router->add( + * "/help", + * [] + * )->match( + * function () { + * return $this->getResponse()->redirect("https://support.google.com/", true); + * } + * ); + * ``` * - * @param string $hostname + * @param mixed $callback * @return RouteInterface */ - public function setHostname($hostname) {} + public function match($callback): RouteInterface {} /** - * Returns the hostname restriction if any + * Reconfigure the route adding a new pattern and a set of paths * - * @return string + * @param string $pattern + * @param mixed $paths */ - public function getHostname() {} + public function reConfigure(string $pattern, $paths = null) {} + + /** + * Resets the internal route id generator + */ + public static function reset() {} /** * Sets the group associated with the route * * @param GroupInterface $group - * @return Route + * @return RouteInterface */ - public function setGroup(GroupInterface $group) {} + public function setGroup(GroupInterface $group): RouteInterface {} /** - * Returns the group associated with the route + * Sets a set of HTTP methods that constraint the matching of the route (alias of via) * - * @return null|GroupInterface + * ```php + * $route->setHttpMethods("GET"); + * + * $route->setHttpMethods( + * [ + * "GET", + * "POST", + * ] + * ); + * ``` + * + * @param mixed $httpMethods + * @return RouteInterface */ - public function getGroup() {} + public function setHttpMethods($httpMethods): RouteInterface {} /** - * Adds a converter to perform an additional transformation for certain parameter - * - * - * $router = new Phalcon\Mvc\Router(false); //create Router without default routes - * $route = $router->add("/catalog/([a-zA-Z0-9\_\-]+)/([^\?]+)", [ - * "controller" => "catalog", - * "action" => "show", - * "name" => 1, - * "params_" => 2, - * ]); - * - * //additional parsing - * $route->convert( - * 'params_', - * function ($string) { - * $array = explode('/', $string); - * array_walk($array, function (&$string) { - * $string = explode('-', $string); - * }); - * - * return $array; - * }); - * $router->handle("https://site.com/controller_name/param1-val1-val2/param2-val3"); - * //result is: `["params_"] = [["param1","val1","val2"], ["param2","val3"]]` - * + * Sets a hostname restriction to the route * - * @param string $name - * @param mixed $converter - * @return Route + * ```php + * $route->setHostname("localhost"); + * ``` + * + * @param string $hostname + * @return RouteInterface */ - public function convert($name, $converter) {} + public function setHostname(string $hostname): RouteInterface {} /** - * Returns the router converter + * Sets the route's name * - * @return array + * ```php + * $router->add( + * "/about", + * [ + * "controller" => "about", + * ] + * )->setName("about"); + * ``` + * + * @param string $name + * @return RouteInterface */ - public function getConverters() {} + public function setName(string $name): RouteInterface {} /** - * Resets the internal route id generator + * Set one or more HTTP methods that constraint the matching of the route + * + * ```php + * $route->via("GET"); + * + * $route->via( + * [ + * "GET", + * "POST", + * ] + * ); + * ``` + * + * @param mixed $httpMethods + * @return RouteInterface */ - public static function reset() {} + public function via($httpMethods): RouteInterface {} } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index f6f1f632..77877799 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -11,110 +11,119 @@ interface RouteInterface { /** - * Sets a hostname restriction to the route + * Replaces placeholders from pattern returning a valid PCRE regular expression * - * @param string $hostname - * @return RouteInterface + * @param string $pattern + * @return string */ - public function setHostname($hostname); + public function compilePattern(string $pattern): string; /** - * Returns the hostname restriction if any + * Adds a converter to perform an additional transformation for certain parameter. * - * @return string + * @param string $name + * @param mixed $converter + * @return RouteInterface */ - public function getHostname(); + public function convert(string $name, $converter): RouteInterface; /** - * Replaces placeholders from pattern returning a valid PCRE regular expression + * Returns the route's pattern * - * @param string $pattern * @return string */ - public function compilePattern($pattern); + public function getCompiledPattern(): string; /** - * Set one or more HTTP methods that constraint the matching of the route + * Returns the hostname restriction if any * - * @param mixed $httpMethods + * @return string */ - public function via($httpMethods); + public function getHostname(): string; /** - * Reconfigure the route adding a new pattern and a set of paths + * Returns the HTTP methods that constraint matching the route * - * @param string $pattern - * @param mixed $paths + * @return string|array */ - public function reConfigure($pattern, $paths = null); + public function getHttpMethods(); /** * Returns the route's name * * @return string */ - public function getName(); + public function getName(): string; /** - * Sets the route's name + * Returns the paths * - * @param string $name + * @return array */ - public function setName($name); + public function getPaths(): array; /** - * Sets a set of HTTP methods that constraint the matching of the route + * Returns the route's pattern * - * @param mixed $httpMethods - * @return RouteInterface + * @return string */ - public function setHttpMethods($httpMethods); + public function getPattern(): string; /** - * Returns the route's id + * Returns the paths using positions as keys and names as values * - * @return string + * @return array */ - public function getRouteId(); + public function getReversedPaths(): array; /** - * Returns the route's pattern + * Returns the route's id * * @return string */ - public function getPattern(); + public function getRouteId(): string; /** - * Returns the route's pattern + * Sets a hostname restriction to the route * - * @return string + * @param string $hostname + * @return RouteInterface */ - public function getCompiledPattern(); + public function setHostname(string $hostname): RouteInterface; /** - * Returns the paths + * Sets a set of HTTP methods that constraint the matching of the route * - * @return array + * @param mixed $httpMethods + * @return RouteInterface */ - public function getPaths(); + public function setHttpMethods($httpMethods): RouteInterface; /** - * Returns the paths using positions as keys and names as values + * Sets the route's name * - * @return array + * @param string $name */ - public function getReversedPaths(); + public function setName(string $name); /** - * Returns the HTTP methods that constraint matching the route + * Reconfigure the route adding a new pattern and a set of paths * - * @return string|array + * @param string $pattern + * @param mixed $paths */ - public function getHttpMethods(); + public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator */ public static function reset(); + /** + * Set one or more HTTP methods that constraint the matching of the route + * + * @param mixed $httpMethods + */ + public function via($httpMethods); + } diff --git a/src/Phalcon/mvc/url/Exception.php b/src/Phalcon/mvc/url/Exception.php deleted file mode 100644 index f10048ee..00000000 --- a/src/Phalcon/mvc/url/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - + * ```php * use Phalcon\Mvc\View\Simple as View; * * $view = new View(); @@ -27,49 +27,43 @@ * "parameter" => $here, * ] * ); - * + * ``` */ class Simple extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewBaseInterface { - protected $_options; + protected $activeRenderPath; - protected $_viewsDir; - - - protected $_partialsDir; - - - protected $_viewParams; + protected $content; /** * @var \Phalcon\Mvc\View\EngineInterface[]|false */ - protected $_engines = false; + protected $engines = false; - /** - * @var array|null - */ - protected $_registeredEngines; + protected $options; - protected $_activeRenderPath; + protected $partialsDir; - protected $_content; + /** + * @var array|null + */ + protected $registeredEngines; - protected $_cache = false; + protected $viewsDir; - protected $_cacheOptions; + protected $viewParams = array(); /** * @return array|null */ - public function getRegisteredEngines() {} + public function getRegisteredEngines(): ?array {} /** * Phalcon\Mvc\View\Simple constructor @@ -79,69 +73,74 @@ public function getRegisteredEngines() {} public function __construct(array $options = array()) {} /** - * Sets views directory. Depending of your platform, always add a trailing slash or backslash + * Magic method to retrieve a variable passed to the view * - * @param string $viewsDir + * ```php + * echo $this->view->products; + * ``` + * + * @param string $key + * @return mixed|null */ - public function setViewsDir($viewsDir) {} + public function __get(string $key): ? {} /** - * Gets views directory + * Magic method to pass variables to the views * - * @return string + * ```php + * $this->view->products = $products; + * ``` + * + * @param string $key + * @param mixed $value */ - public function getViewsDir() {} + public function __set(string $key, $value) {} /** - * Register templating engines + * Returns the path of the view that is currently rendered * - * - * $this->view->registerEngines( - * [ - * ".phtml" => "Phalcon\\Mvc\\View\\Engine\\Php", - * ".volt" => "Phalcon\\Mvc\\View\\Engine\\Volt", - * ".mhtml" => "MyCustomEngine", - * ] - * ); - * + * @return string + */ + public function getActiveRenderPath(): string {} + + /** + * Returns output from another view stage * - * @param array $engines + * @return string */ - public function registerEngines(array $engines) {} + public function getContent(): string {} /** - * Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php + * Returns parameters to views * * @return array */ - protected function _loadTemplateEngines() {} + public function getParamsToView(): array {} /** - * Tries to render the view with every engine registered in the component + * Returns a parameter previously set in the view * - * @param string $path - * @param array $params + * @param string $key + * @return mixed|null */ - protected final function _internalRender($path, $params) {} + public function getVar(string $key): ? {} /** - * Renders a view + * Gets views directory * - * @param string $path - * @param array $params * @return string */ - public function render($path, $params = null) {} + public function getViewsDir(): string {} /** * Renders a partial view * - * + * ```php * // Show a partial inside another view * $this->partial("shared/footer"); - * + * ``` * - * + * ```php * // Show a partial inside another view with parameters * $this->partial( * "shared/footer", @@ -149,165 +148,115 @@ public function render($path, $params = null) {} * "content" => $html, * ] * ); - * + * ``` * * @param string $partialPath * @param mixed $params */ - public function partial($partialPath, $params = null) {} + public function partial(string $partialPath, $params = null) {} /** - * Sets the cache options + * Register templating engines * - * @param array $options - * @return Simple - */ - public function setCacheOptions(array $options) {} - - /** - * Returns the cache options + * ```php + * $this->view->registerEngines( + * [ + * ".phtml" => \Phalcon\Mvc\View\Engine\Php::class, + * ".volt" => \Phalcon\Mvc\View\Engine\Volt::class, + * ".mhtml" => \MyCustomEngine::class, + * ] + * ); + * ``` * - * @return array + * @param array $engines */ - public function getCacheOptions() {} + public function registerEngines(array $engines) {} /** - * Create a Phalcon\Cache based on the internal cache options + * Renders a view * - * @return \Phalcon\Cache\BackendInterface + * @param string $path + * @param array $params + * @return string */ - protected function _createCache() {} + public function render(string $path, array $params = array()): string {} /** - * Returns the cache instance used to cache + * Externally sets the view content + * + * ```php + * $this->view->setContent("

hello

"); + * ``` * - * @return \Phalcon\Cache\BackendInterface + * @param string $content + * @return Simple */ - public function getCache() {} + public function setContent(string $content): Simple {} /** - * Cache the actual view render to certain level + * Adds parameters to views (alias of setVar) * - * - * $this->view->cache( - * [ - * "key" => "my-key", - * "lifetime" => 86400, - * ] - * ); - * + * ```php + * $this->view->setParamToView("products", $products); + * ``` * - * @param mixed $options + * @param string $key + * @param mixed $value * @return Simple */ - public function cache($options = true) {} + public function setParamToView(string $key, $value): Simple {} /** - * Adds parameters to views (alias of setVar) + * Set a single view parameter * - * - * $this->view->setParamToView("products", $products); - * + * ```php + * $this->view->setVar("products", $products); + * ``` * * @param string $key * @param mixed $value * @return Simple */ - public function setParamToView($key, $value) {} + public function setVar(string $key, $value): Simple {} /** * Set all the render params * - * + * ```php * $this->view->setVars( * [ * "products" => $products, * ] * ); - * + * ``` * * @param array $params * @param bool $merge * @return Simple */ - public function setVars(array $params, $merge = true) {} + public function setVars(array $params, bool $merge = true): Simple {} /** - * Set a single view parameter - * - * - * $this->view->setVar("products", $products); - * + * Sets views directory * - * @param string $key - * @param mixed $value - * @return Simple - */ - public function setVar($key, $value) {} - - /** - * Returns a parameter previously set in the view - * - * @param string $key - * @return mixed|null + * @param string $viewsDir */ - public function getVar($key) {} + public function setViewsDir(string $viewsDir) {} /** - * Returns parameters to views + * Loads registered template engines, if none are registered it will use + * Phalcon\Mvc\View\Engine\Php * * @return array */ - public function getParamsToView() {} - - /** - * Externally sets the view content - * - * - * $this->view->setContent("

hello

"); - *
- * - * @param string $content - * @return Simple - */ - public function setContent($content) {} + protected function loadTemplateEngines(): array {} /** - * Returns cached output from another view stage - * - * @return string - */ - public function getContent() {} - - /** - * Returns the path of the view that is currently rendered - * - * @return string - */ - public function getActiveRenderPath() {} - - /** - * Magic method to pass variables to the views - * - * - * $this->view->products = $products; - * - * - * @param string $key - * @param mixed $value - */ - public function __set($key, $value) {} - - /** - * Magic method to retrieve a variable passed to the view - * - * - * echo $this->view->products; - * + * Tries to render the view with every engine registered in the component * - * @param string $key - * @return mixed|null + * @param string $path + * @param array $params */ - public function __get($key) {} + final protected function internalRender(string $path, $params) {} } diff --git a/src/Phalcon/mvc/view/Engine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php similarity index 62% rename from src/Phalcon/mvc/view/Engine.php rename to src/Phalcon/mvc/view/engine/AbstractEngine.php index 9ccfadcb..786bf49e 100644 --- a/src/Phalcon/mvc/view/Engine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -1,48 +1,46 @@ + * ```php * $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); * * $compiler->compile("views/partials/header.volt"); * * require $compiler->getCompiledTemplatePath(); - * + * ``` */ class Compiler implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; - - - protected $_view; + protected $autoescape = false; - protected $_options; + protected $blockLevel = 0; - protected $_arrayHelpers; + protected $blocks; - protected $_level = 0; + protected $container; - protected $_foreachLevel = 0; + protected $compiledTemplatePath; - protected $_blockLevel = 0; + protected $currentBlock; - protected $_exprLevel = 0; + protected $currentPath; - protected $_extended = false; + protected $exprLevel = 0; - protected $_autoescape = false; + protected $extended = false; - protected $_extendedBlocks; + protected $extensions; - protected $_currentBlock; + protected $extendedBlocks; - protected $_blocks; + protected $filters; - protected $_forElsePointers; + protected $foreachLevel = 0; - protected $_loopPointers; + protected $forElsePointers; - protected $_extensions; + protected $functions; - protected $_functions; + protected $level = 0; - protected $_filters; + protected $loopPointers; - protected $_macros; + protected $macros; - protected $_prefix; + protected $options; - protected $_currentPath; + protected $prefix; - protected $_compiledTemplatePath; + protected $view; /** @@ -92,194 +87,200 @@ class Compiler implements \Phalcon\Di\InjectionAwareInterface public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) {} /** - * Sets the dependency injector - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the internal dependency injector + * Registers a Volt's extension * - * @return \Phalcon\DiInterface + * @param mixed $extension + * @return Compiler */ - public function getDI() {} + public function addExtension($extension): Compiler {} /** - * Sets the compiler options + * Register a new filter in the compiler * - * @param array $options + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function setOptions(array $options) {} + public function addFilter(string $name, $definition): Compiler {} /** - * Sets a single compiler option + * Register a new function in the compiler * - * @param string $option - * @param mixed $value + * @param string $name + * @param mixed $definition + * @return Compiler */ - public function setOption($option, $value) {} + public function addFunction(string $name, $definition): Compiler {} /** - * Returns a compiler's option + * Resolves attribute reading * - * @param string $option + * @param array $expr * @return string */ - public function getOption($option) {} + public function attributeReader(array $expr): string {} /** - * Returns the compiler options + * Compiles a template into a file applying the compiler options + * This method does not return the compiled path if the template was not compiled * - * @return array - */ - public function getOptions() {} - - /** - * Fires an event to registered extensions + * ```php + * $compiler->compile("views/layouts/main.volt"); * - * @param string $name - * @param array $arguments - * @return mixed - */ - public final function fireExtensionEvent($name, $arguments = null) {} - - /** - * Registers a Volt's extension + * require $compiler->getCompiledTemplatePath(); + * ``` * - * @param mixed $extension - * @return Compiler + * @param string $templatePath + * @param bool $extendsMode */ - public function addExtension($extension) {} + public function compile(string $templatePath, bool $extendsMode = false) {} /** - * Returns the list of extensions registered in Volt + * Compiles a "autoescape" statement returning PHP code * - * @return array + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function getExtensions() {} + public function compileAutoEscape(array $statement, bool $extendsMode): string {} /** - * Register a new function in the compiler + * Compiles a "cache" statement returning PHP code * - * @param string $name - * @param mixed $definition - * @return Compiler + * @param array $statement + * @param bool $extendsMode + * @return string */ - public function addFunction($name, $definition) {} + public function compileCache(array $statement, bool $extendsMode = false): string {} /** - * Register the user registered functions + * Compiles calls to macros * - * @return array + * @param array $statement + * @param bool $extendsMode */ - public function getFunctions() {} + public function compileCall(array $statement, bool $extendsMode) {} /** - * Register a new filter in the compiler + * Compiles a "case"/"default" clause returning PHP code * - * @param string $name - * @param mixed $definition - * @return Compiler + * @param array $statement + * @param bool $caseClause + * @return string */ - public function addFilter($name, $definition) {} + public function compileCase(array $statement, bool $caseClause = true): string {} /** - * Register the user registered filters + * Compiles a "do" statement returning PHP code * - * @return array + * @param array $statement + * @return string */ - public function getFilters() {} + public function compileDo(array $statement): string {} /** - * Set a unique prefix to be used as prefix for compiled variables + * Compiles a {% raw %}`{{` `}}`{% endraw %} statement returning PHP code * - * @param string $prefix - * @return Compiler + * @param array $statement + * @return string */ - public function setUniquePrefix($prefix) {} + public function compileEcho(array $statement): string {} /** - * Return a unique prefix to be used as prefix for compiled variables and contexts + * Compiles a "elseif" statement returning PHP code * + * @param array $statement * @return string */ - public function getUniquePrefix() {} + public function compileElseIf(array $statement): string {} /** - * Resolves attribute reading + * Compiles a template into a file forcing the destination path * - * @param array $expr - * @return string + * ```php + * $compiler->compileFile( + * "views/layouts/main.volt", + * "views/layouts/main.volt.php" + * ); + * ``` + * + * @param string $path + * @param string $compiledPath + * @param bool $extendsMode + * @return string|array */ - public function attributeReader(array $expr) {} + public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) {} /** - * Resolves function intermediate code into PHP function calls + * Compiles a "foreach" intermediate code representation into plain PHP code * - * @param array $expr + * @param array $statement + * @param bool $extendsMode * @return string */ - public function functionCall(array $expr) {} + public function compileForeach(array $statement, bool $extendsMode = false): string {} /** - * Resolves filter intermediate code into a valid PHP expression + * Generates a 'forelse' PHP code * - * @param array $test - * @param string $left * @return string */ - public function resolveTest(array $test, $left) {} + public function compileForElse(): string {} /** - * Resolves filter intermediate code into PHP function calls + * Compiles a 'if' statement returning PHP code * - * @param array $filter - * @param string $left + * @param array $statement + * @param bool $extendsMode * @return string */ - final protected function resolveFilter(array $filter, $left) {} + public function compileIf(array $statement, bool $extendsMode = false): string {} /** - * Resolves an expression node in an AST volt tree + * Compiles a 'include' statement returning PHP code * - * @param array $expr + * @param array $statement * @return string */ - final public function expression(array $expr) {} + public function compileInclude(array $statement): string {} /** - * Compiles a block of statements + * Compiles macros * - * @param array $statements - * @return string|array + * @param array $statement + * @param bool $extendsMode + * @return string */ - final protected function _statementListOrExtends($statements) {} + public function compileMacro(array $statement, bool $extendsMode): string {} /** - * Compiles a "foreach" intermediate code representation into plain PHP code + * Compiles a "return" statement returning PHP code * * @param array $statement - * @param bool $extendsMode * @return string */ - public function compileForeach(array $statement, $extendsMode = false) {} + public function compileReturn(array $statement): string {} /** - * Generates a 'forelse' PHP code + * Compiles a "set" statement returning PHP code * + * @param array $statement * @return string */ - public function compileForElse() {} + public function compileSet(array $statement): string {} /** - * Compiles a 'if' statement returning PHP code + * Compiles a template into a string * - * @param array $statement + * ```php + * echo $compiler->compileString({% raw %}'{{ "hello world" }}'{% endraw %}); + * ``` + * + * @param string $viewCode * @param bool $extendsMode * @return string */ - public function compileIf(array $statement, $extendsMode = false) {} + public function compileString(string $viewCode, bool $extendsMode = false): string {} /** * Compiles a 'switch' statement returning PHP code @@ -288,195 +289,191 @@ public function compileIf(array $statement, $extendsMode = false) {} * @param bool $extendsMode * @return string */ - public function compileSwitch(array $statement, $extendsMode = false) {} + public function compileSwitch(array $statement, bool $extendsMode = false): string {} /** - * Compiles a "case"/"default" clause returning PHP code + * Resolves an expression node in an AST volt tree * - * @param array $statement - * @param bool $caseClause + * @param array $expr * @return string */ - public function compileCase(array $statement, $caseClause = true) {} + final public function expression(array $expr): string {} /** - * Compiles a "elseif" statement returning PHP code + * Fires an event to registered extensions * - * @param array $statement - * @return string + * @param string $name + * @param array $arguments + * @return mixed */ - public function compileElseIf(array $statement) {} + final public function fireExtensionEvent(string $name, $arguments = null) {} /** - * Compiles a "cache" statement returning PHP code + * Resolves function intermediate code into PHP function calls * - * @param array $statement - * @param bool $extendsMode + * @param array $expr * @return string */ - public function compileCache(array $statement, $extendsMode = false) {} + public function functionCall(array $expr): string {} /** - * Compiles a "set" statement returning PHP code + * Returns the path to the last compiled template * - * @param array $statement * @return string */ - public function compileSet(array $statement) {} + public function getCompiledTemplatePath(): string {} /** - * Compiles a "do" statement returning PHP code + * Returns the internal dependency injector * - * @param array $statement - * @return string + * @return \Phalcon\Di\DiInterface */ - public function compileDo(array $statement) {} + public function getDI(): DiInterface {} /** - * Compiles a "return" statement returning PHP code + * Returns the list of extensions registered in Volt * - * @param array $statement - * @return string + * @return array */ - public function compileReturn(array $statement) {} + public function getExtensions(): array {} /** - * Compiles a "autoescape" statement returning PHP code + * Register the user registered filters * - * @param array $statement - * @param bool $extendsMode - * @return string + * @return array */ - public function compileAutoEscape(array $statement, $extendsMode) {} + public function getFilters(): array {} /** - * Compiles a '{{' '}}' statement returning PHP code + * Register the user registered functions * - * @param array $statement - * @param boolean $extendsMode - * @return string + * @return array */ - public function compileEcho(array $statement) {} + public function getFunctions(): array {} /** - * Compiles a 'include' statement returning PHP code + * Returns a compiler's option * - * @param array $statement + * @param string $option * @return string */ - public function compileInclude(array $statement) {} + public function getOption(string $option) {} /** - * Compiles macros + * Returns the compiler options * - * @param array $statement - * @param bool $extendsMode - * @return string + * @return array */ - public function compileMacro(array $statement, $extendsMode) {} + public function getOptions(): array {} /** - * Compiles calls to macros + * Returns the path that is currently being compiled * - * @param array $statement - * @param boolean $extendsMode * @return string */ - public function compileCall(array $statement, $extendsMode) {} + public function getTemplatePath(): string {} /** - * Traverses a statement list compiling each of its nodes + * Return a unique prefix to be used as prefix for compiled variables and + * contexts * - * @param array $statements - * @param bool $extendsMode * @return string */ - final protected function _statementList(array $statements, $extendsMode = false) {} + public function getUniquePrefix(): string {} /** - * Compiles a Volt source code returning a PHP plain version + * Parses a Volt template returning its intermediate representation + * + * ```php + * print_r( + * $compiler->parse("{% raw %}{{ 3 + 2 }}{% endraw %}") + * ); + * ``` * * @param string $viewCode - * @param bool $extendsMode - * @return string + * @return array */ - protected function _compileSource($viewCode, $extendsMode = false) {} + public function parse(string $viewCode) {} /** - * Compiles a template into a string - * - * - * echo $compiler->compileString('{{ "hello world" }}'); - * + * Resolves filter intermediate code into a valid PHP expression * - * @param string $viewCode - * @param bool $extendsMode + * @param array $test + * @param string $left * @return string */ - public function compileString($viewCode, $extendsMode = false) {} + public function resolveTest(array $test, string $left): string {} /** - * Compiles a template into a file forcing the destination path + * Sets the dependency injector * - * - * $compiler->compileFile("views/layouts/main.volt", "views/layouts/main.volt.php"); - * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Sets a single compiler option * - * @param string $path - * @param string $compiledPath - * @param boolean $extendsMode - * @return string|array + * @param string $option + * @param mixed $value */ - public function compileFile($path, $compiledPath, $extendsMode = false) {} + public function setOption(string $option, $value) {} /** - * Compiles a template into a file applying the compiler options - * This method does not return the compiled path if the template was not compiled + * Sets the compiler options * - * - * $compiler->compile("views/layouts/main.volt"); + * @param array $options + */ + public function setOptions(array $options) {} + + /** + * Set a unique prefix to be used as prefix for compiled variables * - * require $compiler->getCompiledTemplatePath(); - * + * @param string $prefix + * @return Compiler + */ + public function setUniquePrefix(string $prefix): Compiler {} + + /** + * Compiles a Volt source code returning a PHP plain version * - * @param string $templatePath + * @param string $viewCode * @param bool $extendsMode + * @return string */ - public function compile($templatePath, $extendsMode = false) {} + protected function compileSource(string $viewCode, bool $extendsMode = false): string {} /** - * Returns the path that is currently being compiled + * Gets the final path with VIEW * - * @return string + * @param string $path */ - public function getTemplatePath() {} + protected function getFinalPath(string $path) {} /** - * Returns the path to the last compiled template + * Resolves filter intermediate code into PHP function calls * + * @param array $filter + * @param string $left * @return string */ - public function getCompiledTemplatePath() {} + final protected function resolveFilter(array $filter, string $left): string {} /** - * Parses a Volt template returning its intermediate representation - * - * - * print_r( - * $compiler->parse("{{ 3 + 2 }}") - * ); - * + * Traverses a statement list compiling each of its nodes * - * @param string $viewCode - * @return array + * @param array $statements + * @param bool $extendsMode + * @return string */ - public function parse($viewCode) {} + final protected function statementList(array $statements, bool $extendsMode = false): string {} /** - * Gets the final path with VIEW + * Compiles a block of statements * - * @param string $path + * @param array $statements + * @return string|array */ - protected function getFinalPath($path) {} + final protected function statementListOrExtends($statements) {} } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 0c9ec29b..8f230a7c 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\View\Engine\Volt; /** - * Phalcon\Mvc\View\Exception - * * Class for exceptions thrown by Phalcon\Mvc\View */ class Exception extends \Phalcon\Mvc\View\Exception @@ -19,13 +17,13 @@ class Exception extends \Phalcon\Mvc\View\Exception * @param int $code * @param \Exception $previous */ - public function __construct($message = '', array $statement = array(), $code = 0, \Exception $previous = null) {} + public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) {} /** * Gets currently parsed statement (if any). * * @return array */ - public function getStatement() {} + public function getStatement(): array {} } diff --git a/src/Phalcon/paginator/Adapter.php b/src/Phalcon/paginator/Adapter.php deleted file mode 100644 index 20238657..00000000 --- a/src/Phalcon/paginator/Adapter.php +++ /dev/null @@ -1,44 +0,0 @@ - - * use Phalcon\Paginator\Factory; - * $builder = $this->modelsManager->createBuilder() - * ->columns("id, name") - * ->from("Robots") - * ->orderBy("name"); - * - * $options = [ - * "builder" => $builder, - * "limit" => 20, - * "page" => 1, - * "adapter" => "queryBuilder", - * ]; - * $paginator = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php new file mode 100644 index 00000000..1b6a8f76 --- /dev/null +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class PaginatorFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * ```php + * use Phalcon\Paginator\PaginatorFactory; + * + * $builder = $this + * ->modelsManager + * ->createBuilder() + * ->columns("id, name") + * ->from(Robots::class) + * ->orderBy("name"); + * + * $options = [ + * "builder" => $builder, + * "limit" => 20, + * "page" => 1, + * "adapter" => "queryBuilder", + * ]; + * + * $paginator = (new PaginatorFactory())->load($options); + * ``` + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Paginator\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index 03fc7b1c..1d5fe849 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -5,106 +5,123 @@ /** * Phalcon\Paginator\Repository * - * Repository of current state Phalcon\Paginator\AdapterInterface::getPaginate() + * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements RepositoryInterface +class Repository implements \Phalcon\Paginator\RepositoryInterface { - protected $_properties = []; - protected $_aliases = []; - - /** - * {@inheritdoc} - */ - public function setProperties(array $properties) : RepositoryInterface - { - } - - /** - * {@inheritdoc} - */ - public function setAliases(array $aliases) : RepositoryInterface - { - } - - /** - * {@inheritdoc} - */ - public function getAliases() : array - { - } - - /** - * {@inheritdoc} - */ - public function getItems() { - } - - /** - * {@inheritdoc} - */ - public function getTotalItems() : int - { - } - - /** - * {@inheritdoc} - */ - public function getLimit() : int - { - } - - /** - * {@inheritdoc} - */ - public function getFirst() : int - { - } - - /** - * {@inheritdoc} - */ - public function getPrevious() : int - { - } - - /** - * {@inheritdoc} - */ - public function getCurrent() : int - { - } - - /** - * {@inheritdoc} - */ - public function getNext() : int - { - } - - /** - * {@inheritdoc} - */ - public function getLast() : int - { - } - - /** - * {@inheritdoc} - */ - public function __get(string $property) - { - } - - /** - * Gets value of property by name - */ - protected function getProperty(string $property, $defaultValue = null) { - } - - /** - * Resolve legacy alias for compatibility with version 2.0.x - */ - protected function getRealNameProperty(string $property) : string - { - } + /** + * @var array + */ + protected $aliases = array(); + + /** + * @var array + */ + protected $properties = array(); + + + /** + * {@inheritdoc} + * + * @param string $property + * @return mixed|null + */ + public function __get(string $property): ? {} + + /** + * {@inheritdoc} + * + * @return array + */ + public function getAliases(): array {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getCurrent(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getFirst(): int {} + + /** + * {@inheritdoc} + * + * @return mixed + */ + public function getItems() {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getLast(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getLimit(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getNext(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getPrevious(): int {} + + /** + * {@inheritdoc} + * + * @return int + */ + public function getTotalItems(): int {} + + /** + * {@inheritdoc} + * + * @param array $aliases + * @return RepositoryInterface + */ + public function setAliases(array $aliases): RepositoryInterface {} + + /** + * {@inheritdoc} + * + * @param array $properties + * @return RepositoryInterface + */ + public function setProperties(array $properties): RepositoryInterface {} + + /** + * Gets value of property by name + * + * @param string $property + * @param mixed $defaultValue + * @return mixed + */ + protected function getProperty(string $property, $defaultValue = null) {} + + /** + * Resolve alias property name + * + * @param string $property + * @return string + */ + protected function getRealNameProperty(string $property): string {} + } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php new file mode 100644 index 00000000..94b41503 --- /dev/null +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -0,0 +1,117 @@ + + * ```php * use Phalcon\Paginator\Adapter\Model; * * $paginator = new Model( @@ -18,37 +19,17 @@ * ] * ); * - * $paginate = $paginator->getPaginate(); - * + * $paginate = $paginator->paginate(); + * ``` */ -class Model extends \Phalcon\Paginator\Adapter +class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of paginator by model - */ - protected $_config = null; - - - /** - * Phalcon\Paginator\Adapter\Model constructor - * - * @param array $config - */ - public function __construct(array $config) {} - - /** - * Returns a slice of the resultset to show in the pagination - * - * @deprecated will be removed after 4.0 - * @return \stdClass - */ - public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate() {} + public function paginate(): RepositoryInterface {} } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 39fee906..36547901 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -7,7 +7,7 @@ * * Pagination using a PHP array as source of data * - * + * ```php * use Phalcon\Paginator\Adapter\NativeArray; * * $paginator = new NativeArray( @@ -23,36 +23,16 @@ * "page" => $currentPage, * ] * ); - * + * ``` */ -class NativeArray extends \Phalcon\Paginator\Adapter +class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of the paginator - */ - protected $_config = null; - - - /** - * Phalcon\Paginator\Adapter\NativeArray constructor - * - * @param array $config - */ - public function __construct(array $config) {} - - /** - * Returns a slice of the resultset to show in the pagination - * - * @deprecated will be removed after 4.0 - * @return \stdClass - */ - public function getPaginate() {} /** * Returns a slice of the resultset to show in the pagination * - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate() {} + public function paginate(): RepositoryInterface {} } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index ed229f0a..7e810c18 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -7,12 +7,12 @@ * * Pagination using a PHQL query builder as source of data * - * + * ```php * use Phalcon\Paginator\Adapter\QueryBuilder; * * $builder = $this->modelsManager->createBuilder() * ->columns("id, name") - * ->from("Robots") + * ->from(Robots::class) * ->orderBy("name"); * * $paginator = new QueryBuilder( @@ -22,24 +22,19 @@ * "page" => 1, * ] * ); - * + * ``` */ -class QueryBuilder extends \Phalcon\Paginator\Adapter +class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter { - /** - * Configuration of paginator by model - */ - protected $_config; - /** * Paginator's data */ - protected $_builder; + protected $builder; /** * Columns for count query if builder has having */ - protected $_columns; + protected $columns; /** @@ -54,36 +49,28 @@ public function __construct(array $config) {} * * @return int */ - public function getCurrentPage() {} - - /** - * Set query builder object - * - * @param \Phalcon\Mvc\Model\Query\Builder $builder - * @return QueryBuilder - */ - public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder) {} + public function getCurrentPage(): int {} /** * Get query builder object * * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getQueryBuilder() {} + public function getQueryBuilder(): Builder {} /** * Returns a slice of the resultset to show in the pagination * - * @deprecated `will be removed after 4.0 - * @return \stdClass + * @return \Phalcon\Paginator\RepositoryInterface */ - public function getPaginate() {} + public function paginate(): RepositoryInterface {} /** - * Returns a slice of the resultset to show in the pagination + * Set query builder object * - * @return \stdClass + * @param \Phalcon\Mvc\Model\Query\Builder $builder + * @return QueryBuilder */ - public function paginate() {} + public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder {} } diff --git a/src/Phalcon/queue/Beanstalk.php b/src/Phalcon/queue/Beanstalk.php deleted file mode 100644 index fb1308ce..00000000 --- a/src/Phalcon/queue/Beanstalk.php +++ /dev/null @@ -1,269 +0,0 @@ - - * use Phalcon\Queue\Beanstalk; - * - * $queue = new Beanstalk( - * [ - * "host" => "127.0.0.1", - * "port" => 11300, - * "persistent" => true, - * ] - * ); - * - * - * @link http://www.igvita.com/2010/05/20/scalable-work-queues-with-beanstalk/ - */ -class Beanstalk -{ - /** - * Seconds to wait before putting the job in the ready queue. - * The job will be in the "delayed" state during this time. - * - * @const integer - */ - const DEFAULT_DELAY = 0; - - /** - * Jobs with smaller priority values will be scheduled before jobs with larger priorities. - * The most urgent priority is 0, the least urgent priority is 4294967295. - * - * @const integer - */ - const DEFAULT_PRIORITY = 100; - - /** - * Time to run - number of seconds to allow a worker to run this job. - * The minimum ttr is 1. - * - * @const integer - */ - const DEFAULT_TTR = 86400; - - /** - * Default tube name - * - * @const string - */ - const DEFAULT_TUBE = 'default'; - - /** - * Default connected host - * - * @const string - */ - const DEFAULT_HOST = '127.0.0.1'; - - /** - * Default connected port - * - * @const integer - */ - const DEFAULT_PORT = 11300; - - /** - * Connection resource - * - * @var resource - */ - protected $_connection; - - /** - * Connection options - * - * @var array - */ - protected $_parameters; - - - /** - * Phalcon\Queue\Beanstalk - * - * @param array $parameters - */ - public function __construct(array $parameters = array()) {} - - /** - * Makes a connection to the Beanstalkd server - * - * @return resource - */ - public function connect() {} - - /** - * Puts a job on the queue using specified tube. - * - * @param mixed $data - * @param array $options - * @return int|bool - */ - public function put($data, array $options = null) {} - - /** - * Reserves/locks a ready job from the specified tube. - * - * @param mixed $timeout - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function reserve($timeout = null) {} - - /** - * Change the active tube. By default the tube is "default". - * - * @param string $tube - * @return bool|string - */ - public function choose($tube) {} - - /** - * The watch command adds the named tube to the watch list for the current connection. - * - * @param string $tube - * @return bool|int - */ - public function watch($tube) {} - - /** - * It removes the named tube from the watch list for the current connection. - * - * @param string $tube - * @return bool|int - */ - public function ignore($tube) {} - - /** - * Can delay any new job being reserved for a given time. - * - * @param string $tube - * @param int $delay - * @return bool - */ - public function pauseTube($tube, $delay) {} - - /** - * The kick command applies only to the currently used tube. - * - * @param int $bound - * @return bool|int - */ - public function kick($bound) {} - - /** - * Gives statistical information about the system as a whole. - * - * @return bool|array - */ - public function stats() {} - - /** - * Gives statistical information about the specified tube if it exists. - * - * @param string $tube - * @return bool|array - */ - public function statsTube($tube) {} - - /** - * Returns a list of all existing tubes. - * - * @return bool|array - */ - public function listTubes() {} - - /** - * Returns the tube currently being used by the client. - * - * @return bool|string - */ - public function listTubeUsed() {} - - /** - * Returns a list tubes currently being watched by the client. - * - * @return bool|array - */ - public function listTubesWatched() {} - - /** - * Inspect the next ready job. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekReady() {} - - /** - * Return the next job in the list of buried jobs. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekBuried() {} - - /** - * Return the next job in the list of buried jobs. - * - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function peekDelayed() {} - - /** - * The peek commands let the client inspect a job in the system. - * - * @param int $id - * @return bool|\Phalcon\Queue\Beanstalk\Job - */ - public function jobPeek($id) {} - - /** - * Reads the latest status from the Beanstalkd server - * - * @return array - */ - final public function readStatus() {} - - /** - * Fetch a YAML payload from the Beanstalkd server - * - * @return array - */ - final public function readYaml() {} - - /** - * Reads a packet from the socket. Prior to reading from the socket will - * check for availability of the connection. - * - * @param int $length - * @return bool|string - */ - public function read($length = 0) {} - - /** - * Writes data to the socket. Performs a connection if none is available - * - * @param string $data - * @return bool|int - */ - public function write($data) {} - - /** - * Closes the connection to the beanstalk server. - * - * @return bool - */ - public function disconnect() {} - - /** - * Simply closes the connection. - * - * @return bool - */ - public function quit() {} - -} diff --git a/src/Phalcon/queue/beanstalk/Exception.php b/src/Phalcon/queue/beanstalk/Exception.php deleted file mode 100644 index e2bb63bc..00000000 --- a/src/Phalcon/queue/beanstalk/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - + * ```php * $random = new \Phalcon\Security\Random(); * * // Random binary string @@ -68,7 +68,7 @@ * echo $random->base58(); // Umjxqf7ZPwh765yR * echo $random->base58(24); // qoXcgmw4A9dys26HaNEdCRj9 * echo $random->base58(7); // 774SJD3vgP - * + * ``` * * This class partially borrows SecureRandom library from Ruby * @@ -77,61 +77,21 @@ class Random { - /** - * Generates a random binary string - * - * The `Random::bytes` method returns a string and accepts as input an int - * representing the length in bytes to be returned. - * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The result may contain any byte: "x00" - "xFF". - * - * - * $random = new \Phalcon\Security\Random(); - * - * $bytes = $random->bytes(); - * var_dump(bin2hex($bytes)); - * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" - * - * - * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len - * @return string - */ - public function bytes($len = 16) {} - - /** - * Generates a random hex string - * - * If $len is not specified, 16 is assumed. It may be larger in future. - * The length of the result string is usually greater of $len. - * - * - * $random = new \Phalcon\Security\Random(); - * - * echo $random->hex(10); // a29f470508d5ccb8e289 - * - * - * @throws Exception If secure random number generator is not available or unexpected partial read - * @param int $len - * @return string - */ - public function hex($len = null) {} - /** * Generates a random base58 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The result may contain alphanumeric characters except 0, O, I and l. * - * It is similar to `Phalcon\Security\Random:base64` but has been modified to avoid both non-alphanumeric - * characters and letters which might look ambiguous when printed. + * It is similar to `Phalcon\Security\Random::base64()` but has been + * modified to avoid both non-alphanumeric characters and letters which + * might look ambiguous when printed. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base58(); // 4kUgL2pdQMSCQtjE - * + * ``` * * @see \Phalcon\Security\Random:base64 * @link https://en.wikipedia.org/wiki/Base58 @@ -139,47 +99,49 @@ public function hex($len = null) {} * @param int $len * @return string */ - public function base58($len = null) {} + public function base58(int $len = null): string {} /** * Generates a random base62 string * * If $len is not specified, 16 is assumed. It may be larger in future. * - * It is similar to `Phalcon\Security\Random:base58` but has been modified to provide the largest value that can - * safely be used in URLs without needing to take extra characters into consideration because it is [A-Za-z0-9]. + * It is similar to `Phalcon\Security\Random::base58()` but has been + * modified to provide the largest value that can safely be used in URLs + * without needing to take extra characters into consideration because it is + * [A-Za-z0-9]. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base62(); // z0RkwHfh8ErDM1xw - * + * ``` * * @see \Phalcon\Security\Random:base58 * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base62($len = null) {} + public function base62(int $len = null): string {} /** * Generates a random base64 string * * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. - * Size formula: 4 ($len / 3) and this need to be rounded up to a multiple of 4. + * Size formula: 4 ($len / 3) rounded up to a multiple of 4. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base64(12); // 3rcq39QzGK9fUqh8 - * + * ``` * * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string */ - public function base64($len = null) {} + public function base64(int $len = null): string {} /** * Generates a random URL-safe base64 string @@ -187,15 +149,16 @@ public function base64($len = null) {} * If $len is not specified, 16 is assumed. It may be larger in future. * The length of the result string is usually greater of $len. * - * By default, padding is not generated because "=" may be used as a URL delimiter. - * The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if $padding is true. - * See RFC 3548 for the definition of URL-safe base64. + * By default, padding is not generated because "=" may be used as a URL + * delimiter. The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also + * used if $padding is true. See RFC 3548 for the definition of URL-safe + * base64. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->base64Safe(); // GD8JojhzSTrqX7Q8J6uug - * + * ``` * * @link https://www.ietf.org/rfc/rfc3548.txt * @throws Exception If secure random number generator is not available or unexpected partial read @@ -203,50 +166,94 @@ public function base64($len = null) {} * @param bool $padding * @return string */ - public function base64Safe($len = null, $padding = false) {} + public function base64Safe(int $len = null, bool $padding = false): string {} /** - * Generates a v4 random UUID (Universally Unique IDentifier) + * Generates a random binary string + * + * The `Random::bytes` method returns a string and accepts as input an int + * representing the length in bytes to be returned. + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The result may contain any byte: "x00" - "xFF". * - * The version 4 UUID is purely random (except the version). It doesn't contain meaningful - * information such as MAC address, time, etc. See RFC 4122 for details of UUID. + * ```php + * $random = new \Phalcon\Security\Random(); + * + * $bytes = $random->bytes(); + * var_dump(bin2hex($bytes)); + * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" + * ``` * - * This algorithm sets the version number (4 bits) as well as two reserved bits. - * All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. - * Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal - * digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). + * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len + * @return string + */ + public function bytes(int $len = 16): string {} + + /** + * Generates a random hex string + * + * If $len is not specified, 16 is assumed. It may be larger in future. + * The length of the result string is usually greater of $len. * - * + * ```php * $random = new \Phalcon\Security\Random(); * - * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 - * + * echo $random->hex(10); // a29f470508d5ccb8e289 + * ``` * - * @link https://www.ietf.org/rfc/rfc4122.txt * @throws Exception If secure random number generator is not available or unexpected partial read + * @param int $len * @return string */ - public function uuid() {} + public function hex(int $len = null): string {} /** * Generates a random number between 0 and $len * * Returns an integer: 0 <= result <= $len. * - * + * ```php * $random = new \Phalcon\Security\Random(); * * echo $random->number(16); // 8 - * + * ``` * * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 * @param int $len * @return int */ - public function number($len) {} + public function number(int $len): int {} + + /** + * Generates a v4 random UUID (Universally Unique IDentifier) + * + * The version 4 UUID is purely random (except the version). It doesn't + * contain meaningful information such as MAC address, time, etc. See RFC + * 4122 for details of UUID. + * + * This algorithm sets the version number (4 bits) as well as two reserved + * bits. All other bits (the remaining 122 bits) are set using a random or + * pseudorandom data source. Version 4 UUIDs have the form + * xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and + * y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). + * + * ```php + * $random = new \Phalcon\Security\Random(); + * + * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 + * ``` + * + * @link https://www.ietf.org/rfc/rfc4122.txt + * @throws Exception If secure random number generator is not available or unexpected partial read + * @return string + */ + public function uuid(): string {} /** - * Generates a random string based on the number ($base) of characters ($alphabet). + * Generates a random string based on the number ($base) of characters + * ($alphabet). * * If $n is not specified, 16 is assumed. It may be larger in future. * @@ -256,6 +263,6 @@ public function number($len) {} * @param mixed $n * @return string */ - protected function base($alphabet, $base, $n = null) {} + protected function base(string $alphabet, int $base, $n = null): string {} } diff --git a/src/Phalcon/service/Exception.php b/src/Phalcon/service/Exception.php deleted file mode 100644 index 22ac2332..00000000 --- a/src/Phalcon/service/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ - - * $session->setOptions( - * [ - * "uniqueId" => "my-private-app", - * ] - * ); - * - * - * @param array $options - */ - public function setOptions(array $options) {} - - /** - * Get internal options - * - * @return array - */ - public function getOptions() {} - - /** - * Set session name - * - * @param string $name - */ - public function setName($name) {} - - /** - * Get session name - * - * @return string - */ - public function getName() {} - - /** - * {@inheritdoc} - * - * @param bool $deleteOldSession - * @return AdapterInterface - */ - public function regenerateId($deleteOldSession = true) {} - - /** - * Gets a session variable from an application context - * - * - * $session->get("auth", "yes"); - * - * - * @param string $index - * @param mixed $defaultValue - * @param bool $remove - * @return mixed - */ - public function get($index, $defaultValue = null, $remove = false) {} - - /** - * Sets a session variable in an application context - * - * - * $session->set("auth", "yes"); - * - * - * @param string $index - * @param mixed $value - */ - public function set($index, $value) {} - - /** - * Check whether a session variable is set in an application context - * - * - * var_dump( - * $session->has("auth") - * ); - * - * - * @param string $index - * @return bool - */ - public function has($index) {} - - /** - * Removes a session variable from an application context - * - * - * $session->remove("auth"); - * - * - * @param string $index - */ - public function remove($index) {} - - /** - * Returns active session id - * - * - * echo $session->getId(); - * - * - * @return string - */ - public function getId() {} - - /** - * Set the current session id - * - * - * $session->setId($id); - * - * - * @param string $id - */ - public function setId($id) {} - - /** - * Check whether the session has been started - * - * - * var_dump( - * $session->isStarted() - * ); - * - * - * @return bool - */ - public function isStarted() {} - - /** - * Destroys the active session - * - * - * var_dump( - * $session->destroy() - * ); - * - * var_dump( - * $session->destroy(true) - * ); - * - * - * @param mixed $removeData - * @return bool - */ - public function destroy($removeData = null) {} - - /** - * Returns the status of the current session. - * - * - * var_dump( - * $session->status() - * ); - * - * if ($session->status() !== $session::SESSION_ACTIVE) { - * $session->start(); - * } - * - * - * @return int - */ - public function status() {} - - /** - * Alias: Gets a session variable from an application context - * - * @param string $index - * @return mixed - */ - public function __get($index) {} - - /** - * Alias: Sets a session variable in an application context - * - * @param string $index - * @param mixed $value - */ - public function __set($index, $value) {} - - /** - * Alias: Check whether a session variable is set in an application context - * - * @param string $index - * @return bool - */ - public function __isset($index) {} - - /** - * Alias: Removes a session variable from an application context - * - * - * unset($session->auth); - * - * - * @param string $index - */ - public function __unset($index) {} - - - public function __destruct() {} - - - protected function removeSessionData() {} - -} diff --git a/src/Phalcon/session/AdapterInterface.php b/src/Phalcon/session/AdapterInterface.php deleted file mode 100644 index aba0f232..00000000 --- a/src/Phalcon/session/AdapterInterface.php +++ /dev/null @@ -1,108 +0,0 @@ - + * ```php * $user = new \Phalcon\Session\Bag("user"); * * $user->name = "Kimbra Johnson"; * $user->age = 22; - * + * ``` */ -class Bag implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Session\BagInterface, \IteratorAggregate, \ArrayAccess, \Countable +class Bag extends \Phalcon\Collection implements \Phalcon\Di\InjectionAwareInterface { - protected $_dependencyInjector; + private $container; - protected $_name = null; + private $name = null; - protected $_data; - - - protected $_initialized = false; - - - protected $_session; + private $session; /** @@ -38,176 +33,47 @@ class Bag implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Session\BagIn * * @param string $name */ - public function __construct($name) {} - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\DiInterface $dependencyInjector - */ - public function setDI(\Phalcon\DiInterface $dependencyInjector) {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\DiInterface - */ - public function getDI() {} - - /** - * Initializes the session bag. This method must not be called directly, the - * class calls it when its internal data is accessed - */ - public function initialize() {} + public function __construct(string $name) {} /** * Destroys the session bag - * - * - * $user->destroy(); - * - */ - public function destroy() {} - - /** - * Sets a value in the session bag - * - * - * $user->set("name", "Kimbra"); - * - * - * @param string $property - * @param mixed $value - */ - public function set($property, $value) {} - - /** - * Magic setter to assign values to the session bag - * - * - * $user->name = "Kimbra"; - * - * - * @param string $property - * @param mixed $value - */ - public function __set($property, $value) {} - - /** - * Obtains a value from the session bag optionally setting a default value - * - * - * echo $user->get("name", "Kimbra"); - * - * - * @param string $property - * @param mixed $defaultValue */ - public function get($property, $defaultValue = null) {} + public function clear() {} /** - * Magic getter to obtain values from the session bag - * - * - * echo $user->name; - * - * - * @param string $property - * @return mixed - */ - public function __get($property) {} - - /** - * Check whether a property is defined in the internal bag - * - * - * var_dump( - * $user->has("name") - * ); - * - * - * @param string $property - * @return bool - */ - public function has($property) {} - - /** - * Magic isset to check whether a property is defined in the bag - * - * - * var_dump( - * isset($user["name"]) - * ); - * + * Returns the DependencyInjector container * - * @param string $property - * @return bool + * @return \Phalcon\Di\DiInterface */ - public function __isset($property) {} + public function getDI(): DiInterface {} /** * Removes a property from the internal bag * - * - * $user->remove("name"); - * - * - * @param string $property - * @return bool - */ - public function remove($property) {} - - /** - * Magic unset to remove items using the array syntax - * - * - * unset($user["name"]); - * - * - * @param string $property - * @return bool + * @param array $data */ - public function __unset($property) {} + public function init(array $data = array()) {} /** - * Return length of bag - * - * - * echo $user->count(); - * + * Removes a property from the internal bag * - * @return int + * @param string $element */ - public final function count() {} + public function remove(string $element) {} /** - *  Returns the bag iterator + * Sets a value in the session bag * - * @return \ArrayIterator - */ - public final function getIterator() {} - - /** - * @param mixed $property + * @param string $element * @param mixed $value */ - public final function offsetSet($property, $value) {} + public function set(string $element, $value) {} /** - * @param mixed $property - * @return bool - */ - public final function offsetExists($property) {} - - /** - * @param mixed $property - */ - public final function offsetUnset($property) {} - - /** - * @param mixed $property - * @return mixed + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container */ - public final function offsetGet($property) {} + public function setDI(\Phalcon\Di\DiInterface $container) {} } diff --git a/src/Phalcon/session/BagInterface.php b/src/Phalcon/session/BagInterface.php deleted file mode 100644 index ed3afba4..00000000 --- a/src/Phalcon/session/BagInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - * use Phalcon\Session\Factory; - * - * $options = [ - * "uniqueId" => "my-private-app", - * "host" => "127.0.0.1", - * "port" => 11211, - * "persistent" => true, - * "lifetime" => 3600, - * "prefix" => "my_", - * "adapter" => "memcache", - * ]; - * $session = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 19b0c3b4..1ce22d22 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -2,238 +2,237 @@ namespace Phalcon\Session; -use InvalidArgumentException; -use RuntimeException; -use SessionHandlerInterface; -use Phalcon\DiInterface; -use Phalcon\DI\InjectionAwareInterface; -use Phalcon\Helper\Arr; -use Phalcon\Session\ManagerInterface; - /** * Phalcon\Session\Manager * * Session manager class */ -class Manager implements ManagerInterface, InjectionAwareInterface +class Manager implements \Phalcon\Session\ManagerInterface, \Phalcon\DI\InjectionAwareInterface { /** * @var */ private $container; - /** - * @var |null - */ - private $handler = null; - - /** - * @var string - */ - private $name = ""; - - /** - * @var array - */ - private $options = []; - - /** - * @var string - */ - private $uniqueId = ""; - - /** - * Manager constructor. - * - * @param array options - */ - public function __construct(array $options = []) - { - } - - - /** - * Alias: Gets a session variable from an application context - */ - public function __get(string $key) { - } - - /** - * Alias: Check whether a session variable is set in an application context - */ - public function __isset(string $key) : bool - { - } - - /** - * Alias: Sets a session variable in an application context - */ - public function __set(string $key, $value) : void - { - } - - /** - * Alias: Removes a session variable from an application context - */ - public function __unset(string $key) - { - } - - /** - * Destroy/end a session - */ - public function destroy() : void - { - } - - /** - * Check whether the session has been started - */ - public function exists() : bool - { - } - - /** - * Gets a session variable from an application context - */ - public function get(string $key, $defaultValue = null, bool $remove = false) { - } - - /** - * Returns the DependencyInjector container - */ - public function getDI() : DiInterface - { - } - - /** - * Returns the stored session handler - */ - public function getHandler() : SessionHandlerInterface - { - } - - /** - * Returns the session id - */ - public function getId() : string - { - } - - /** - * Returns the name of the session - */ - public function getName() : string - { - } - - /** - * Check whether a session variable is set in an application context - */ - public function has(string $key) : bool - { - } - - /** - * Get internal options - */ - public function getOptions() : array - { - } - - /** - * Regenerates the session id using the handler. - */ - public function regenerateId($deleteOldSession = true) : ManagerInterface - { - } - - /** - * Registers a handler with the session - */ - public function registerHandler(SessionHandlerInterface $handler) : bool - { - } - - /** - * Removes a session variable from an application context - */ - public function remove(string $key) - { - } - - /** - * Sets a session variable in an application context - */ - public function set(string $key, $value) : void - { - } - - /** - * Sets the DependencyInjector container - */ - public function setDI(DiInterface $container) - { - } - - /** - * Set the handler for the session - */ - public function setHandler(SessionHandlerInterface $handler) : ManagerInterface - { - } - - /** - * Set session Id - */ - public function setId(string $id) : ManagerInterface - { - } - - /** - * Set the session name. Throw exception if the session has started - * and do not allow poop names - * - * @param string name - * - * @throws InvalidArgumentException - * - * @return Manager - */ - public function setName(string $name) : ManagerInterface - { - } - - /** - * Sets session's options - * - * @param array options - */ - public function setOptions(array $options) : void - { - } - - /** - * Starts the session (if headers are already sent the session will not be - * started) - */ - public function start() : bool - { - } - - /** - * Returns the status of the current session. - * - * @return int - */ - public function status() : int - { - } - - /** - * Returns the key prefixed - */ - private function getUniqueKey(string $key) : string - { - } + /** + * @var |null + */ + private $handler = null; + + /** + * @var string + */ + private $name = ''; + + /** + * @var array + */ + private $options = array(); + + /** + * @var string + */ + private $uniqueId = ''; + + + /** + * Manager constructor. + * + * @param array $options + */ + public function __construct(array $options = array()) {} + + /** + * Alias: Gets a session variable from an application context + * + * @param string $key + * @return mixed + */ + public function __get(string $key) {} + + /** + * Alias: Check whether a session variable is set in an application context + * + * @param string $key + * @return bool + */ + public function __isset(string $key): bool {} + + /** + * Alias: Sets a session variable in an application context + * + * @param string $key + * @param mixed $value + */ + public function __set(string $key, $value) {} + + /** + * Alias: Removes a session variable from an application context + * + * @param string $key + */ + public function __unset(string $key) {} + + /** + * Destroy/end a session + */ + public function destroy() {} + + /** + * Check whether the session has been started + * + * @return bool + */ + public function exists(): bool {} + + /** + * Gets a session variable from an application context + * + * @param string $key + * @param mixed $defaultValue + * @param bool $remove + * @return mixed + */ + public function get(string $key, $defaultValue = null, bool $remove = false) {} + + /** + * Returns the DependencyInjector container + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Returns the stored session handler + * + * @return \SessionHandlerInterface + */ + public function getHandler(): SessionHandlerInterface {} + + /** + * Returns the session id + * + * @return string + */ + public function getId(): string {} + + /** + * Returns the name of the session + * + * @return string + */ + public function getName(): string {} + + /** + * Check whether a session variable is set in an application context + * + * @param string $key + * @return bool + */ + public function has(string $key): bool {} + + /** + * Get internal options + * + * @return array + */ + public function getOptions(): array {} + + /** + * Regenerates the session id using the handler. + * + * @param mixed $deleteOldSession + * @return \Phalcon\Session\ManagerInterface + */ + public function regenerateId($deleteOldSession = true): ManagerInterface {} + + /** + * Registers a handler with the session + * + * @param \SessionHandlerInterface $handler + * @return bool + */ + public function registerHandler(\SessionHandlerInterface $handler): bool {} + + /** + * Removes a session variable from an application context + * + * @param string $key + */ + public function remove(string $key) {} + + /** + * Sets a session variable in an application context + * + * @param string $key + * @param mixed $value + */ + public function set(string $key, $value) {} + + /** + * Sets the DependencyInjector container + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + + /** + * Set the handler for the session + * + * @param \SessionHandlerInterface $handler + * @return \Phalcon\Session\ManagerInterface + */ + public function setHandler(\SessionHandlerInterface $handler): ManagerInterface {} + + /** + * Set session Id + * + * @param string $id + * @return \Phalcon\Session\ManagerInterface + */ + public function setId(string $id): ManagerInterface {} + + /** + * Set the session name. Throw exception if the session has started + * and do not allow poop names + * + * @param string name + * + * @throws InvalidArgumentException + * + * @param string $name + * @return \Phalcon\Session\ManagerInterface + */ + public function setName(string $name): ManagerInterface {} + + /** + * Sets session's options + * + * @param array $options + */ + public function setOptions(array $options) {} + + /** + * Starts the session (if headers are already sent the session will not be + * started) + * + * @return bool + */ + public function start(): bool {} + + /** + * Returns the status of the current session. + * + * @return int + */ + public function status(): int {} + + /** + * Returns the key prefixed + * + * @param string $key + * @return string + */ + private function getUniqueKey(string $key): string {} + } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php new file mode 100644 index 00000000..0bdb4024 --- /dev/null +++ b/src/Phalcon/session/ManagerInterface.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \SessionHandlerInterface +{ + /** + * @var + */ + protected $adapter; + + + /** + * Close + * + * @return bool + */ + public function close(): bool {} + + /** + * Destroy + * + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} + + /** + * Garbage Collector + * + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * Read + * + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * Open + * + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} + + /** + * Write + * + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} + +} diff --git a/src/Phalcon/session/adapter/Files.php b/src/Phalcon/session/adapter/Files.php deleted file mode 100644 index ffe3b7f0..00000000 --- a/src/Phalcon/session/adapter/Files.php +++ /dev/null @@ -1,29 +0,0 @@ - - * use Phalcon\Session\Adapter\Files; - * - * $session = new Files( - * [ - * "uniqueId" => "my-private-app", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * - */ -class Files extends \Phalcon\Session\Adapter -{ - -} diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index c1d60223..83668e14 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -4,100 +4,16 @@ /** * Phalcon\Session\Adapter\Libmemcached - * - * This adapter store sessions in libmemcached - * - * - * use Phalcon\Session\Adapter\Libmemcached; - * - * $session = new Libmemcached( - * [ - * "servers" => [ - * [ - * "host" => "localhost", - * "port" => 11211, - * "weight" => 1, - * ], - * ], - * "client" => [ - * \Memcached::OPT_HASH => \Memcached::HASH_MD5, - * \Memcached::OPT_PREFIX_KEY => "prefix.", - * ], - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * */ -class Libmemcached extends \Phalcon\Session\Adapter +class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter { - protected $_libmemcached = null; - - - protected $_lifetime = 8600; - - - - public function getLibmemcached() {} - - - public function getLifetime() {} - /** - * Phalcon\Session\Adapter\Libmemcached constructor + * Constructor * - * @throws \Phalcon\Session\Exception + * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(array $options) {} - - /** - * @return bool - */ - public function open() {} - - /** - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} } diff --git a/src/Phalcon/session/adapter/Memcache.php b/src/Phalcon/session/adapter/Memcache.php deleted file mode 100644 index c5cac728..00000000 --- a/src/Phalcon/session/adapter/Memcache.php +++ /dev/null @@ -1,95 +0,0 @@ - - * use Phalcon\Session\Adapter\Memcache; - * - * $session = new Memcache( - * [ - * "uniqueId" => "my-private-app", - * "host" => "127.0.0.1", - * "port" => 11211, - * "persistent" => true, - * "lifetime" => 3600, - * "prefix" => "my_", - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * - */ -class Memcache extends \Phalcon\Session\Adapter -{ - - protected $_memcache = null; - - - protected $_lifetime = 8600; - - - - public function getMemcache() {} - - - public function getLifetime() {} - - /** - * Phalcon\Session\Adapter\Memcache constructor - * - * @param array $options - */ - public function __construct(array $options = array()) {} - - /** - * @return bool - */ - public function open() {} - - /** - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} - -} diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index ed866229..02a62873 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -2,15 +2,13 @@ namespace Phalcon\Session\Adapter; -use SessionHandlerInterface; - /** * Phalcon\Session\Adapter\Noop * * This is an "empty" or null adapter. It can be used for testing or any * other purpose that no session needs to be invoked * - * + * ```php * setHandler(new Noop()); - * + * ``` */ -class Noop implements SessionHandlerInterface +class Noop implements \SessionHandlerInterface { /** * The connection of some adapters */ - protected $connection; + protected $connection; - /** - * Session options - * - * @var array - */ - protected $options = []; + /** + * Session options + * + * @var array + */ + protected $options = array(); - /** - * Session prefix - * - * @var string - */ - protected $prefix = ""; + /** + * Session prefix + * + * @var string + */ + protected $prefix = ''; - /** - * Time To Live - * - * @var int - */ - protected $ttl = 8600; + /** + * Time To Live + * + * @var int + */ + protected $ttl = 8600; - /** - * Constructor - */ - public function __construct(array $options = []) - { - } - /** - * Close - */ - public function close() : bool - { - } + /** + * Constructor + * + * @param array $options + */ + public function __construct(array $options = array()) {} - /** - * Destroy - */ - public function destroy($id) : bool - { - } + /** + * Close + * + * @return bool + */ + public function close(): bool {} - /** - * Garbage Collector - */ - public function gc($maxlifetime) : bool - { - } + /** + * Destroy + * + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} - /** - * Read - */ - public function read($id) : string - { - } + /** + * Garbage Collector + * + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * Read + * + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * Open + * + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} - /** - * Open - */ - public function open($savePath, $sessionName) : bool - { - } + /** + * Write + * + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} - /** - * Write - */ - public function write($id, $data) : bool - { - } + /** + * Helper method to get the name prefixed + * + * @param mixed $name + * @return string + */ + protected function getPrefixedName($name): string {} - /** - * Helper method to get the name prefixed - */ - protected function getPrefixedName($name) : string - { - } } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 179e2d47..9df67fd7 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -4,98 +4,16 @@ /** * Phalcon\Session\Adapter\Redis - * - * This adapter store sessions in Redis - * - * - * use Phalcon\Session\Adapter\Redis; - * - * $session = new Redis( - * [ - * "uniqueId" => "my-private-app", - * "host" => "localhost", - * "port" => 6379, - * "auth" => "foobared", - * "persistent" => false, - * "lifetime" => 3600, - * "prefix" => "my", - * "index" => 1, - * ] - * ); - * - * $session->start(); - * - * $session->set("var", "some-value"); - * - * echo $session->get("var"); - * */ -class Redis extends \Phalcon\Session\Adapter +class Redis extends \Phalcon\Session\Adapter\AbstractAdapter { - protected $_redis = null; - - - protected $_lifetime = 8600; - - - - public function getRedis() {} - - - public function getLifetime() {} - /** - * Phalcon\Session\Adapter\Redis constructor + * Constructor * + * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(array $options = array()) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function open() {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function close() {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return string - */ - public function read($sessionId) {} - - /** - * {@inheritdoc} - * - * @param string $sessionId - * @param string $data - * @return bool - */ - public function write($sessionId, $data) {} - - /** - * {@inheritdoc} - * - * @param mixed $sessionId - * @return bool - */ - public function destroy($sessionId = null) {} - - /** - * {@inheritdoc} - * - * @return bool - */ - public function gc() {} + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php new file mode 100644 index 00000000..50f4da55 --- /dev/null +++ b/src/Phalcon/session/adapter/Stream.php @@ -0,0 +1,70 @@ + '/tmp', + * ] + * ); + * $session->setHandler($files); + * ``` + */ +class Stream extends \Phalcon\Session\Adapter\Noop +{ + /** + * @var string + */ + private $path = ''; + + + /** + * @param array $options + */ + public function __construct(array $options = array()) {} + + /** + * @param mixed $id + * @return bool + */ + public function destroy($id): bool {} + + /** + * @param mixed $maxlifetime + * @return bool + */ + public function gc($maxlifetime): bool {} + + /** + * @param mixed $savePath + * @param mixed $sessionName + * @return bool + */ + public function open($savePath, $sessionName): bool {} + + /** + * @param mixed $id + * @return string + */ + public function read($id): string {} + + /** + * @param mixed $id + * @param mixed $data + * @return bool + */ + public function write($id, $data): bool {} + +} diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php new file mode 100644 index 00000000..22477029 --- /dev/null +++ b/src/Phalcon/storage/AdapterFactory.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AdapterFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var + */ + private $serializerFactory; + + + /** + * AdapterFactory constructor. + * + * @param \Phalcon\Storage\SerializerFactory $factory + * @param array $services + */ + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return \Phalcon\Storage\Adapter\AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/storage/Exception.php b/src/Phalcon/storage/Exception.php new file mode 100644 index 00000000..e699f6fa --- /dev/null +++ b/src/Phalcon/storage/Exception.php @@ -0,0 +1,13 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class SerializerFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * SerializerFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * @param string name + * + * @throws Exception + * @param string $name + * @return \Phalcon\Storage\Serializer\SerializerInterface + */ + public function newInstance(string $name): SerializerInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php new file mode 100644 index 00000000..ec177404 --- /dev/null +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -0,0 +1,195 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface +{ + /** + * @var mixed + */ + protected $adapter; + + /** + * Name of the default serializer class + * + * @var string + */ + protected $defaultSerializer = 'Php'; + + /** + * Name of the default TTL (time to live) + * + * @var int + */ + protected $lifetime = 3600; + + /** + * @var string + */ + protected $prefix = ''; + + /** + * Serializer + * + * @var + */ + protected $serializer; + + /** + * Serializer Factory + * + * @var + */ + protected $serializerFactory; + + + /** + * Name of the default serializer class + * + * @return string + */ + public function getDefaultSerializer(): string {} + + /** + * Name of the default serializer class + * + * @param string $defaultSerializer + */ + public function setDefaultSerializer(string $defaultSerializer) {} + + /** + * @return string + */ + public function getPrefix(): string {} + + /** + * Sets parameters based on options + * + * @param \Phalcon\Storage\SerializerFactory $factory + * @param array $options + */ + protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) {} + + /** + * Flushes/clears the cache + * + * @return bool + */ + abstract public function clear(): bool; + + /** + * Decrements a stored number + * + * @param string $key + * @param int $value + * @return int|bool + */ + abstract public function decrement(string $key, int $value = 1); + + /** + * Deletes data from the adapter + * + * @param string $key + * @return bool + */ + abstract public function delete(string $key): bool; + + /** + * Reads data from the adapter + * + * @param string $key + * @return mixed + */ + abstract public function get(string $key); + + /** + * Returns the adapter - connects to the storage if not connected + * + * @return mixed + */ + abstract public function getAdapter(); + + /** + * Returns all the keys stored + * + * @return array + */ + abstract public function getKeys(): array; + + /** + * Checks if an element exists in the cache + * + * @param string $key + * @return bool + */ + abstract public function has(string $key): bool; + + /** + * Increments a stored number + * + * @param string $key + * @param int $value + * @return int|bool + */ + abstract public function increment(string $key, int $value = 1); + + /** + * Stores data in the adapter + * + * @param string $key + * @param mixed $value + * @param mixed $ttl + * @return bool + */ + abstract public function set(string $key, $value, $ttl = null): bool; + + /** + * Returns the key requested, prefixed + * + * @param mixed $key + * @return string + */ + protected function getPrefixedKey($key): string {} + + /** + * Returns serialized data + * + * @param mixed $content + * @return mixed + */ + protected function getSerializedData($content) {} + + /** + * Calculates the TTL for a cache item + * + * @param DateInterval|int|null $ttl + * + * @throws Exception + * @param mixed $ttl + * @return int + */ + protected function getTtl($ttl): int {} + + /** + * Returns unserialized data + * + * @param mixed $content + * @param mixed $defaultValue + * @return mixed + */ + protected function getUnserializedData($content, $defaultValue = null) {} + + /** + * Initializes the serializer + */ + protected function initSerializer() {} + +} diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php new file mode 100644 index 00000000..a7f35523 --- /dev/null +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface +{ + /** + * @var mixed + */ + protected $data = null; + + + /** + * @return mixed + */ + public function getData() {} + + /** + * @param mixed $data + */ + public function setData($data) {} + + /** + * Constructor + * + * @param mixed $data + */ + public function __construct($data = null) {} + + /** + * If this returns true, then the data returns back as is + * + * @param mixed $data + * @return bool + */ + protected function isSerializable($data): bool {} + +} diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php new file mode 100644 index 00000000..6dfbad46 --- /dev/null +++ b/src/Phalcon/storage/serializer/Base64.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php new file mode 100644 index 00000000..5047c4bc --- /dev/null +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php new file mode 100644 index 00000000..ef79de7a --- /dev/null +++ b/src/Phalcon/storage/serializer/Json.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Json extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php new file mode 100644 index 00000000..8b8a3e80 --- /dev/null +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string|null + */ + public function serialize(): ?string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php new file mode 100644 index 00000000..bba29154 --- /dev/null +++ b/src/Phalcon/storage/serializer/None.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class None extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php new file mode 100644 index 00000000..ea6e0ef6 --- /dev/null +++ b/src/Phalcon/storage/serializer/Php.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Php extends \Phalcon\Storage\Serializer\AbstractSerializer +{ + + /** + * Serializes data + * + * @return string + */ + public function serialize(): string {} + + /** + * Unserializes data + * + * @param mixed $data + */ + public function unserialize($data) {} + +} diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php new file mode 100644 index 00000000..b13acdd3 --- /dev/null +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +interface SerializerInterface extends \Serializable +{ + + /** + * @return mixed + */ + public function getData(); + + /** + * @param mixed $data + * @param $data + */ + public function setData($data); + +} diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 551efc84..5f1f29fe 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -5,7 +5,8 @@ /** * Phalcon\Tag\Select * - * Generates a SELECT html tag using a static array of values or a Phalcon\Mvc\Model resultset + * Generates a SELECT html tag using a static array of values or a + * Phalcon\Mvc\Model resultset */ abstract class Select { @@ -15,26 +16,29 @@ abstract class Select * * @param array $parameters * @param array $data + * @return string */ - public static function selectField($parameters, $data = null) {} + public static function selectField($parameters, $data = null): string {} /** - * Generate the OPTION tags based on a resultset + * Generate the OPTION tags based on an array * - * @param \Phalcon\Mvc\Model\Resultset $resultset - * @param array $using + * @param array $data * @param mixed $value * @param string $closeOption + * @return string */ - private static function _optionsFromResultset($resultset, $using, $value, $closeOption) {} + private static function optionsFromArray(array $data, $value, string $closeOption): string {} /** - * Generate the OPTION tags based on an array + * Generate the OPTION tags based on a resultset * - * @param array $data + * @param \Phalcon\Mvc\Model\ResulsetInterface $resultset + * @param array $using * @param mixed $value * @param string $closeOption + * @return string */ - private static function _optionsFromArray($data, $value, $closeOption) {} + private static function optionsFromResultset(\Phalcon\Mvc\Model\ResulsetInterface $resultset, $using, $value, string $closeOption): string {} } diff --git a/src/Phalcon/translate/Factory.php b/src/Phalcon/translate/Factory.php deleted file mode 100644 index a33f5973..00000000 --- a/src/Phalcon/translate/Factory.php +++ /dev/null @@ -1,30 +0,0 @@ - - * use Phalcon\Translate\Factory; - * - * $options = [ - * "locale" => "de_DE.UTF-8", - * "defaultDomain" => "translations", - * "directory" => "/path/to/application/locales", - * "category" => LC_MESSAGES, - * "adapter" => "gettext", - * ]; - * $translate = Factory::load($options); - * - */ -class Factory extends \Phalcon\Factory -{ - - /** - * @param \Phalcon\Config|array $config - * @return AdapterInterface - */ - public static function load($config) {} - -} diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php new file mode 100644 index 00000000..5907eda6 --- /dev/null +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class InterpolatorFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var array + */ + private $mapper = array(); + + /** + * @var array + */ + private $services = array(); + + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @return \Phalcon\Translate\Adapter\AdapterInterface + */ + public function newInstance(string $name): AdapterInterface {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/translate/InterpolatorInterface.php b/src/Phalcon/translate/InterpolatorInterface.php deleted file mode 100644 index ebd37966..00000000 --- a/src/Phalcon/translate/InterpolatorInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class TranslateFactory extends \Phalcon\Factory\AbstractFactory +{ + /** + * @var InterpolatorFactory + */ + private $interpolator; + + + /** + * AdapterFactory constructor. + * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param array $services + */ + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) {} + + /** + * Factory to create an instace from a Config object + * + * @param mixed $config + * @return mixed + */ + public function load($config) {} + + /** + * Create a new instance of the adapter + * + * @param string $name + * @param array $options + * @return AbstractAdapter + */ + public function newInstance(string $name, array $options = array()): AbstractAdapter {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/translate/Adapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php similarity index 58% rename from src/Phalcon/translate/Adapter.php rename to src/Phalcon/translate/adapter/AbstractAdapter.php index 42b3d83b..8d221db3 100644 --- a/src/Phalcon/translate/Adapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -1,79 +1,79 @@ + * ```php * use Phalcon\Translate\Adapter\Gettext; * * $adapter = new Gettext( @@ -16,72 +16,60 @@ * "category" => LC_MESSAGES, * ] * ); - * + * ``` * * Allows translate using gettext */ -class Gettext extends \Phalcon\Translate\Adapter implements \ArrayAccess +class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { /** - * @var string|array + * @var int */ - protected $_directory; + protected $category; /** * @var string */ - protected $_defaultDomain; + protected $defaultDomain; /** - * @var string + * @var string|array */ - protected $_locale; + protected $directory; /** - * @var int + * @var string */ - protected $_category; + protected $locale; /** - * @return string|array + * @return int */ - public function getDirectory() {} + public function getCategory(): int {} /** * @return string */ - public function getDefaultDomain() {} + public function getDefaultDomain(): string {} /** - * @return string + * @return string|array */ - public function getLocale() {} + public function getDirectory() {} /** - * @return int + * @return string */ - public function getCategory() {} + public function getLocale(): string {} /** * Phalcon\Translate\Adapter\Gettext constructor * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(array $options) {} - - /** - * Returns the translation related to the given key. - * - * - * $translator->query("你好 %name%!", ["name" => "Phalcon"]); - * - * - * @param string $index - * @param mixed $placeholders - * @return string - */ - public function query($index, $placeholders = null) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} /** * Check whether is defined a translation key in the internal array @@ -89,11 +77,12 @@ public function query($index, $placeholders = null) {} * @param string $index * @return bool */ - public function exists($index) {} + public function exists(string $index): bool {} /** * The plural version of gettext(). - * Some languages have more than one form for plural messages dependent on the count. + * Some languages have more than one form for plural messages dependent on + * the count. * * @param string $msgid1 * @param string $msgid2 @@ -102,34 +91,39 @@ public function exists($index) {} * @param string $domain * @return string */ - public function nquery($msgid1, $msgid2, $count, $placeholders = null, $domain = null) {} + public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string {} /** - * Changes the current domain (i.e. the translation file) + * Returns the translation related to the given key. * - * @param mixed $domain + * ```php + * $translator->query("你好 %name%!", ["name" => "Phalcon"]); + * ``` + * + * @param string $index + * @param array $placeholders * @return string */ - public function setDomain($domain) {} + public function query(string $index, $placeholders = null): string {} /** * Sets the default domain * * @return string */ - public function resetDomain() {} + public function resetDomain(): string {} /** * Sets the domain default to search within when calls are made to gettext() * * @param string $domain */ - public function setDefaultDomain($domain) {} + public function setDefaultDomain(string $domain) {} /** * Sets the path for a domain * - * + * ```php * // Set the directory path * $gettext->setDirectory("/path/to/the/messages"); * @@ -140,41 +134,49 @@ public function setDefaultDomain($domain) {} * "another" => "/path/to/the/another", * ] * ); - * + * ``` * * @param string|array $directory The directory path or an array of directories and domains */ public function setDirectory($directory) {} + /** + * Changes the current domain (i.e. the translation file) + * + * @param mixed $domain + * @return string + */ + public function setDomain($domain): string {} + /** * Sets locale information * - * + * ```php * // Set locale to Dutch * $gettext->setLocale(LC_ALL, "nl_NL"); * * // Try different possible locale names for german * $gettext->setLocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge"); - * + * ``` * * @param int $category * @param string $locale * @return string|bool */ - public function setLocale($category, $locale) {} + public function setLocale(int $category, string $locale) {} /** - * Validator for constructor + * Gets default options * - * @param array $options + * @return array */ - protected function prepareOptions(array $options) {} + protected function getOptionsDefault(): array {} /** - * Gets default options + * Validator for constructor * - * @return array + * @param array $options */ - protected function getOptionsDefault() {} + protected function prepareOptions(array $options) {} } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index bd5f98c6..710d5661 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -7,34 +7,50 @@ * * Allows to define translation lists using PHP arrays */ -class NativeArray extends \Phalcon\Translate\Adapter implements \ArrayAccess +class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { + /** + * @var array + */ + private $translate; - protected $_translate; + /** + * @var bool + */ + private $triggerError = false; /** * Phalcon\Translate\Adapter\NativeArray constructor * + * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} /** - * Returns the translation related to the given key + * Check whether is defined a translation key in the internal array + * + * @param string $index + * @return bool + */ + public function exists(string $index): bool {} + + /** + * Whenever a key is not found this medhod will be called * * @param string $index - * @param mixed $placeholders * @return string */ - public function query($index, $placeholders = null) {} + public function notFound(string $index): string {} /** - * Check whether is defined a translation key in the internal array + * Returns the translation related to the given key * * @param string $index - * @return bool + * @param mixed $placeholders + * @return string */ - public function exists($index) {} + public function query(string $index, $placeholders = null): string {} } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index cfb6f050..55bc4363 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -2,17 +2,24 @@ namespace Phalcon\Translate\Interpolator; - -class AssociativeArray implements \Phalcon\Translate\InterpolatorInterface +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function replacePlaceholders($translation, $placeholders = null) {} + public function replacePlaceholders(string $translation, array $placeholders = array()): string {} } diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index f668236e..af57aa6f 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -2,17 +2,24 @@ namespace Phalcon\Translate\Interpolator; - -class IndexedArray implements \Phalcon\Translate\InterpolatorInterface +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** * Replaces placeholders by the values passed * * @param string $translation - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function replacePlaceholders($translation, $placeholders = null) {} + public function replacePlaceholders(string $translation, array $placeholders = array()): string {} } diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php new file mode 100644 index 00000000..4adb6a41 --- /dev/null +++ b/src/Phalcon/translate/interpolator/InterpolatorInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class ValidatorFactory extends \Phalcon\Factory\AbstractFactory +{ + + /** + * TagFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = array()) {} + + /** + * Creates a new instance + * + * @param string $name + * @return mixed + */ + public function newInstance(string $name) {} + + /** + * @return array + */ + protected function getAdapters(): array {} + +} diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 5cf7d765..307747be 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -3,38 +3,68 @@ namespace Phalcon\Validation; /** - * Phalcon\Validation\ValidatorInterface - * - * Interface for Phalcon\Validation\Validator + * Interface for Phalcon\Validation\AbstractValidator */ interface ValidatorInterface { /** - * Checks if an option is defined + * Returns an option in the validator's options + * Returns null if the option hasn't set * * @param string $key - * @return bool + * @param mixed $defaultValue + * @return mixed */ - public function hasOption($key); + public function getOption(string $key, $defaultValue = null); /** - * Returns an option in the validator's options - * Returns null if the option hasn't set + * Checks if an option is defined * * @param string $key - * @param mixed $defaultValue - * @return mixed + * @return bool */ - public function getOption($key, $defaultValue = null); + public function hasOption(string $key): bool; /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $attribute + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $attribute); + public function validate(\Phalcon\Validation $validation, $field): bool; + + /** + * Get the template message + * + * @throw InvalidArgumentException When the field does not exists + * @param string $field + * @return string + */ + public function getTemplate(string $field): string; + + /** + * Get message templates + * + * @return array + */ + public function getTemplates(): array; + + /** + * Clear current template and set new from an array, + * + * @param array $templates + * @return ValidatorInterface + */ + public function setTemplates(array $templates): ValidatorInterface; + + /** + * Set a new temlate message + * + * @param string $template + * @return ValidatorInterface + */ + public function setTemplate(string $template): ValidatorInterface; } diff --git a/src/Phalcon/validation/message/Group.php b/src/Phalcon/validation/message/Group.php deleted file mode 100644 index 34a8301c..00000000 --- a/src/Phalcon/validation/message/Group.php +++ /dev/null @@ -1,155 +0,0 @@ - - * print_r( - * $messages[0] - * ); - * - * - * @param int $index - * @return bool|\Phalcon\Validation\Message - */ - public function offsetGet($index) {} - - /** - * Sets an attribute using the array-syntax - * - * - * $messages[0] = new \Phalcon\Validation\Message("This is a message"); - * - * - * @param int $index - * @param \Phalcon\Validation\Message $message - */ - public function offsetSet($index, $message) {} - - /** - * Checks if an index exists - * - * - * var_dump( - * isset($message["database"]) - * ); - * - * - * @param int $index - * @return bool - */ - public function offsetExists($index) {} - - /** - * Removes a message from the list - * - * - * unset($message["database"]); - * - * - * @param mixed $index - */ - public function offsetUnset($index) {} - - /** - * Appends a message to the group - * - * - * $messages->appendMessage( - * new \Phalcon\Validation\Message("This is a message") - * ); - * - * - * @param \Phalcon\Validation\MessageInterface $message - */ - public function appendMessage(\Phalcon\Validation\MessageInterface $message) {} - - /** - * Appends an array of messages to the group - * - * - * $messages->appendMessages($messagesArray); - * - * - * @param \Phalcon\Validation\MessageInterface[] $messages - */ - public function appendMessages($messages) {} - - /** - * Filters the message group by field name - * - * @param string $fieldName - * @return array - */ - public function filter($fieldName) {} - - /** - * Returns the number of messages in the list - * - * @return int - */ - public function count() {} - - /** - * Rewinds the internal iterator - */ - public function rewind() {} - - /** - * Returns the current message in the iterator - * - * @return \Phalcon\Validation\Message - */ - public function current() {} - - /** - * Returns the current position/key in the iterator - * - * @return int - */ - public function key() {} - - /** - * Moves the internal iteration pointer to the next position - */ - public function next() {} - - /** - * Check if the current message in the iterator is valid - * - * @return bool - */ - public function valid() {} - - /** - * Magic __set_state helps to re-build messages variable when exporting - * - * @param array $group - * @return \Phalcon\Validation\Message\Group - */ - public static function __set_state($group) {} - -} diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index c73c1ad4..e44a4154 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Alnum - * * Check for alphanumeric character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alnum as AlnumValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Alnum extends \Phalcon\Validation\Validator +class Alnum extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must contain only letters and numbers'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 87c1dd50..c4a0ef8c 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Alpha - * * Check for alphabetic character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alpha as AlphaValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Alpha extends \Phalcon\Validation\Validator +class Alpha extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must contain only letters'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index a6ec67a6..62ae2db7 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -3,12 +3,10 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Between - * * Validates that a value is between an inclusive range of two values. * For a value x, the test is passed if minimum<=x<=maximum. * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Between; * @@ -47,18 +45,21 @@ * ] * ) * ); - * + * ``` */ -class Between extends \Phalcon\Validation\Validator +class Between extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be within the range of :min to :max'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 6915f1e6..61c7a9fa 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Callback - * * Calls user function for validation * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Callback as CallbackValidator; * use Phalcon\Validation\Validator\Numericality as NumericalityValidator; @@ -46,18 +44,21 @@ * ] * ) * ); - * + * ``` */ -class Callback extends \Phalcon\Validation\Validator +class Callback extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must match the callback function'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 2c235c3d..9adbf563 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Confirmation - * * Checks that two values have the same value * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Confirmation; * @@ -41,19 +39,22 @@ * ] * ) * ); - * + * ``` */ -class Confirmation extends \Phalcon\Validation\Validator +class Confirmation extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be the same as :with'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * Compare strings @@ -62,6 +63,6 @@ public function validate(\Phalcon\Validation $validation, $field) {} * @param string $b * @return bool */ - protected final function compare($a, $b) {} + final protected function compare(string $a, string $b): bool {} } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index fcef5b6f..659e1445 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\CreditCard - * * Checks if a value has a valid credit card number * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\CreditCard as CreditCardValidator; * @@ -36,26 +34,30 @@ * ] * ) * ); - * + * ``` */ -class CreditCard extends \Phalcon\Validation\Validator +class CreditCard extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is not valid for a credit card number'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** - * is a simple checksum formula used to validate a variety of identification numbers + * is a simple checksum formula used to validate a variety of identification + * numbers * * @param string $number * @return bool */ - private function verifyByLuhnAlgorithm($number) {} + private function verifyByLuhnAlgorithm(string $number): bool {} } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index f5a354ed..47ce72e1 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Date - * * Checks if a value is a valid date * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Date as DateValidator; * @@ -41,25 +39,28 @@ * ] * ) * ); - * + * ``` */ -class Date extends \Phalcon\Validation\Validator +class Date extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is not a valid date'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * @param mixed $value * @param mixed $format * @return bool */ - private function checkDate($value, $format) {} + private function checkDate($value, $format): bool {} } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 4bcc361b..038cb5d8 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Digit - * * Check for numeric character(s) * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Digit as DigitValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Digit extends \Phalcon\Validation\Validator +class Digit extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be numeric'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 804d42f2..93b774b3 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Email - * * Checks if a value has a correct e-mail format * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Email as EmailValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Email extends \Phalcon\Validation\Validator +class Email extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be an email address'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Exception.php b/src/Phalcon/validation/validator/Exception.php index 6e0f3fbf..240b1809 100644 --- a/src/Phalcon/validation/validator/Exception.php +++ b/src/Phalcon/validation/validator/Exception.php @@ -3,9 +3,8 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Exception - * - * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this class + * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this + * class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index f4eac992..aa870b04 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\ExclusionIn - * * Check if a value is not included into a list of values * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\ExclusionIn; * @@ -47,18 +45,21 @@ * ] * ) * ); - * + * ``` */ -class ExclusionIn extends \Phalcon\Validation\Validator +class ExclusionIn extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must not be a part of list: :domain'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index aef472d0..3ab08575 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\File - * * Checks if a value has a correct file * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\File as FileValidator; * @@ -18,14 +16,14 @@ * new FileValidator( * [ * "maxSize" => "2M", - * "messageSize" => ":field exceeds the max filesize (:max)", + * "messageSize" => ":field exceeds the max filesize (:size)", * "allowedTypes" => [ * "image/jpeg", * "image/png", * ], * "messageType" => "Allowed file types are :types", * "maxResolution" => "800x600", - * "messageMaxResolution" => "Max resolution of :field is :max", + * "messageMaxResolution" => "Max resolution of :field is :resolution", * ] * ) * ); @@ -69,27 +67,16 @@ * ] * ) * ); - * + * ``` */ -class File extends \Phalcon\Validation\Validator +class File extends \Phalcon\Validation\AbstractValidatorComposite { /** - * Executes the validation - * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool - */ - public function validate(\Phalcon\Validation $validation, $field) {} - - /** - * Check on empty + * Constructor * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool + * @param array $options */ - public function isAllowEmpty(\Phalcon\Validation $validation, $field) {} + public function __construct(array $options = array()) {} } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 9a28f586..152a25ab 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Identical - * * Checks if a value is identical to other * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Identical; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class Identical extends \Phalcon\Validation\Validator +class Identical extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not have the expected value'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index b55343d3..2b69130e 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\InclusionIn - * * Check if a value is included into a list of values * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\InclusionIn; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class InclusionIn extends \Phalcon\Validation\Validator +class InclusionIn extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be a part of list: :domain'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 7193c835..485fdb5b 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -2,27 +2,21 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Validation; -use Phalcon\Validation\Validator; -use Phalcon\Messages\Message; - /** - * Phalcon\Validation\Validator\ip - * - * Check for ip addresses + * Check for IP addresses * - * + * ```php * use Phalcon\Validation\Validator\Ip as IpValidator; * * $validator->add( * "ip_address", * new IpValidator( * [ - * "message" => ":field must contain only ip addresses", - * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified + * "message" => ":field must contain only ip addresses", + * "version" => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified * "allowReserved" => false, // False if not specified. Ignored for v6 - * "allowPrivate" => false, // False if not specified - * "allowEmpty" => false, + * "allowPrivate" => false, // False if not specified + * "allowEmpty" => false, * ] * ) * ); @@ -35,39 +29,49 @@ * new IpValidator( * [ * "message" => [ - * "source_address" => "source_address must contain only ip addresses", - * "destination_address" => "destination_address must contain only ip addresses", + * "source_address" => "source_address must be a valid IP address", + * "destination_address" => "destination_address must be a valid IP address", * ], * "version" => [ - * "source_address" => Ip::VERSION_4 | IP::VERSION_6, + * "source_address" => Ip::VERSION_4 | IP::VERSION_6, * "destination_address" => Ip::VERSION_4, * ], * "allowReserved" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowPrivate" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * "allowEmpty" => [ - * "source_address" => false, + * "source_address" => false, * "destination_address" => true, * ], * ] * ) * ); - * + * ``` */ -class Ip extends Validator +class Ip extends \Phalcon\Validation\AbstractValidator { - const VERSION_4 = FILTER_FLAG_IPV4; - const VERSION_6 = FILTER_FLAG_IPV6; - /** - * Executes the validation - */ - public function validate(Validation $validation, $field) : bool - { - } + const VERSION_4 = 1048576; + + + const VERSION_6 = 2097152; + + + protected $template = 'Field :field must be a valid IP address'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index baf05fe8..4a55030b 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Numericality - * * Check for a valid numeric value * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Numericality; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Numericality extends \Phalcon\Validation\Validator +class Numericality extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not have a valid numeric format'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index 046f395b..f7e1a631 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\PresenceOf - * * Validates that a value is not null or empty string * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\PresenceOf; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class PresenceOf extends \Phalcon\Validation\Validator +class PresenceOf extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field is required'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index f3f431b9..23aa7ec5 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Regex - * * Allows validate if the value of a field matches a regular expression * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Regex as RegexValidator; * @@ -41,18 +39,21 @@ * ] * ) * ); - * + * ``` */ -class Regex extends \Phalcon\Validation\Validator +class Regex extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field does not match the required format'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index b95904f7..7cded7d9 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -3,13 +3,12 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\StringLength - * * Validates that a string has the specified maximum and minimum constraints * The test is passed if for a string's length L, min<=L<=max, i.e. L must * be at least min, and at most max. + * Since Phalcon v4.0 this valitor works like a container * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\StringLength as StringLength; * @@ -19,10 +18,12 @@ * "name_last", * new StringLength( * [ - * "max" => 50, - * "min" => 2, - * "messageMaximum" => "We don't like really long names", - * "messageMinimum" => "We want more than just their initials", + * "max" => 50, + * "min" => 2, + * "messageMaximum" => "We don't like really long names", + * "messageMinimum" => "We want more than just their initials", + * "includedMaximum" => true, + * "includedMinimum" => false, * ] * ) * ); @@ -49,22 +50,28 @@ * "messageMinimum" => [ * "name_last" => "We don't like too short last names", * "name_first" => "We don't like too short first names", + * ], + * "includedMaximum" => [ + * "name_last" => false, + * "name_first" => true, + * ], + * "includedMinimum" => [ + * "name_last" => false, + * "name_first" => true, * ] * ] * ) * ); - * + * ``` */ -class StringLength extends \Phalcon\Validation\Validator +class StringLength extends \Phalcon\Validation\AbstractValidatorComposite { /** - * Executes the validation + * Constructor * - * @param \Phalcon\Validation $validation - * @param string $field - * @return bool + * @param array $options */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function __construct(array $options = array()) {} } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index 26b77fb4..fa70ed86 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Uniqueness - * * Check that a field is unique in the related table * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; * @@ -22,10 +20,10 @@ * ] * ) * ); - * + * ``` * * Different attribute from the field: - * + * ```php * $validator->add( * "username", * new UniquenessValidator( @@ -35,18 +33,18 @@ * ] * ) * ); - * + * ``` * * In model: - * + * ```php * $validator->add( * "username", * new UniquenessValidator() * ); - * + * ``` * * Combination of fields in model: - * + * ```php * $validator->add( * [ * "firstName", @@ -54,12 +52,12 @@ * ], * new UniquenessValidator() * ); - * + * ``` * * It is possible to convert values before validation. This is useful in * situations where values need to be converted to do the database lookup: * - * + * ```php * $validator->add( * "username", * new UniquenessValidator( @@ -72,11 +70,14 @@ * ] * ) * ); - * + * ``` */ -class Uniqueness extends \Phalcon\Validation\CombinedFieldsValidator +class Uniqueness extends \Phalcon\Validation\AbstractCombinedFieldsValidator { + protected $template = 'Field :field must be unique'; + + private $columnMap = null; @@ -87,14 +88,7 @@ class Uniqueness extends \Phalcon\Validation\CombinedFieldsValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} - - /** - * @param \Phalcon\Validation $validation - * @param mixed $field - * @return bool - */ - protected function isUniqueness(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} /** * The column map is used in the case to get real column name @@ -103,24 +97,31 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field) {} * @param string $field * @return string */ - protected function getColumnNameReal($record, $field) {} + protected function getColumnNameReal($record, string $field): string {} /** - * Uniqueness method used for model + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + protected function isUniqueness(\Phalcon\Validation $validation, $field): bool {} + + /** + * Uniqueness method used for collection * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessModel($record, array $field, array $values) {} + protected function isUniquenessCollection($record, array $field, array $values) {} /** - * Uniqueness method used for collection + * Uniqueness method used for model * * @param mixed $record * @param array $field * @param array $values */ - protected function isUniquenessCollection($record, array $field, array $values) {} + protected function isUniquenessModel($record, array $field, array $values) {} } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index b3e86bd5..0c85f1f0 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -3,11 +3,9 @@ namespace Phalcon\Validation\Validator; /** - * Phalcon\Validation\Validator\Url - * * Checks if a value has a url format * - * + * ```php * use Phalcon\Validation; * use Phalcon\Validation\Validator\Url as UrlValidator; * @@ -36,18 +34,21 @@ * ] * ) * ); - * + * ``` */ -class Url extends \Phalcon\Validation\Validator +class Url extends \Phalcon\Validation\AbstractValidator { + protected $template = 'Field :field must be a url'; + + /** * Executes the validation * * @param \Phalcon\Validation $validation - * @param string $field + * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field) {} + public function validate(\Phalcon\Validation $validation, $field): bool {} } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php new file mode 100644 index 00000000..2a2c15cd --- /dev/null +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -0,0 +1,151 @@ +add( + * "file", + * new Size( + * [ + * "maxSize" => "2M", + * "messageSize" => ":field exceeds the max filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new FileValidator( + * [ + * "maxSize" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "messageSize" => [ + * "file" => "file exceeds the max filesize 2M", + * "anotherFile" => "anotherFile exceeds the max filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +abstract class AbstractFile extends \Phalcon\Validation\AbstractValidator +{ + /** + * Empty is empty + */ + protected $messageFileEmpty = 'Field :field must not be empty'; + + /** + * File exceeed the file size setted in PHP configuration + */ + protected $messageIniSize = 'File :field exceeds the maximum file size'; + + /** + * File is not valid + */ + protected $messageValid = 'Field :field is not valid'; + + + /** + * Empty is empty + */ + public function getMessageFileEmpty() {} + + /** + * Empty is empty + * + * @param mixed $messageFileEmpty + */ + public function setMessageFileEmpty($messageFileEmpty) {} + + /** + * File exceeed the file size setted in PHP configuration + */ + public function getMessageIniSize() {} + + /** + * File exceeed the file size setted in PHP configuration + * + * @param mixed $messageIniSize + */ + public function setMessageIniSize($messageIniSize) {} + + /** + * File is not valid + */ + public function getMessageValid() {} + + /** + * File is not valid + * + * @param mixed $messageValid + */ + public function setMessageValid($messageValid) {} + + /** + * Check on empty + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool {} + + /** + * Check upload + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUpload(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if uploaded file is larger than PHP allowed size + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if upload is empty + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool {} + + /** + * Check if upload is valid + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool {} + + /** + * Convert a string like "2.5MB" in bytes + * + * @param string $size + * @return double + */ + public function getFileSizeInBytes(string $size): float {} + +} diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php new file mode 100644 index 00000000..b642b371 --- /dev/null +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -0,0 +1,68 @@ +add( + * "file", + * new MimeType( + * [ + * "types" => [ + * "image/jpeg", + * "image/png", + * ], + * "message" => "Allowed file types are :types" + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new MimeType( + * [ + * "types" => [ + * "file" => [ + * "image/jpeg", + * "image/png", + * ], + * "anotherFile" => [ + * "image/gif", + * "image/bmp", + * ], + * ], + * "message" => [ + * "file" => "Allowed file types are image/jpeg and image/png", + * "anotherFile" => "Allowed file types are image/gif and image/bmp", + * ] + * ] + * ) + * ); + * ``` + */ +class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field must be of type: :types'; + + + /** + * Executes the validation + * + * @param Valiation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php new file mode 100644 index 00000000..cc59fdd6 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -0,0 +1,59 @@ +add( + * "file", + * new Equal( + * [ + * "resolution" => "800x600", + * "message" => "The resolution of the field :field has to be equal :resolution", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Equal( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "message" => [ + * "file" => "Equal resolution of file has to be 800x600", + * "anotherFile" => "Equal resolution of file has to be 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'The resolution of the field :field has to be equal :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php new file mode 100644 index 00000000..32ca0ec1 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Max( + * [ + * "resolution" => "800x600", + * "message" => "Max resolution of :field is :resolution", + * "included" => true, + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Max( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "Max resolution of file is 800x600", + * "anotherFile" => "Max resolution of file is 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field exceeds the maximum resolution of :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php new file mode 100644 index 00000000..db1e4db0 --- /dev/null +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Min( + * [ + * "resolution" => "800x600", + * "message" => "Min resolution of :field is :resolution", + * "included" => true, + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Min( + * [ + * "resolution" => [ + * "file" => "800x600", + * "anotherFile" => "1024x768", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "Min resolution of file is 800x600", + * "anotherFile" => "Min resolution of file is 1024x768", + * ], + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field can not have the minimum resolution of :resolution'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php new file mode 100644 index 00000000..2e7de623 --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Equal( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the equal filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Equal( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file does not have the rigth filesize", + * "anotherFile" => "anotherFile wrong filesize (4MB)", + * ], + * ] + * ) + * ); + * ``` + */ +class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field does not have the exact :size filesize'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php new file mode 100644 index 00000000..1e634676 --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Max( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the max filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Max( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file exceeds the max filesize 2M", + * "anotherFile" => "anotherFile exceeds the max filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field exceeds the size of :size'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php new file mode 100644 index 00000000..92d65f3f --- /dev/null +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -0,0 +1,64 @@ +add( + * "file", + * new Min( + * [ + * "size" => "2M", + * "included" => true, + * "message" => ":field exceeds the min filesize (:size)", + * ] + * ) + * ); + * + * $validator->add( + * [ + * "file", + * "anotherFile", + * ], + * new Min( + * [ + * "size" => [ + * "file" => "2M", + * "anotherFile" => "4M", + * ], + * "included" => [ + * "file" => false, + * "anotherFile" => true, + * ], + * "message" => [ + * "file" => "file exceeds the min filesize 2M", + * "anotherFile" => "anotherFile exceeds the min filesize 4M", + * ], + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\Validator\File\AbstractFile +{ + + protected $template = 'File :field can not have the minimum size of :size'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php new file mode 100644 index 00000000..fe294b5f --- /dev/null +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -0,0 +1,66 @@ +add( + * "name_last", + * new Max( + * [ + * "max" => 50, + * "message" => "We don't like really long names", + * "included" => true + * ] + * ) + * ); + * + * $validation->add( + * [ + * "name_last", + * "name_first", + * ], + * new Max( + * [ + * "max" => [ + * "name_last" => 50, + * "name_first" => 40, + * ], + * "message" => [ + * "name_last" => "We don't like really long last names", + * "name_first" => "We don't like really long first names", + * ], + * "included" => [ + * "name_last" => false, + * "name_first" => true, + * ] + * ] + * ) + * ); + * ``` + */ +class Max extends \Phalcon\Validation\AbstractValidator +{ + + protected $template = 'Field :field must not exceed :max characters long'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php new file mode 100644 index 00000000..606924c0 --- /dev/null +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -0,0 +1,66 @@ +add( + * "name_last", + * new Min( + * [ + * "min" => 2, + * "message" => "We want more than just their initials", + * "included" => true + * ] + * ) + * ); + * + * $validation->add( + * [ + * "name_last", + * "name_first", + * ], + * new Min( + * [ + * "min" => [ + * "name_last" => 2, + * "name_first" => 4, + * ], + * "message" => [ + * "name_last" => "We don't like too short last names", + * "name_first" => "We don't like too short first names", + * ], + * "included" => [ + * "name_last" => false, + * "name_first" => true, + * ] + * ] + * ) + * ); + * ``` + */ +class Min extends \Phalcon\Validation\AbstractValidator +{ + + protected $template = 'Field :field must be at least :min characters long'; + + + /** + * Executes the validation + * + * @param \Phalcon\Validation $validation + * @param mixed $field + * @return bool + */ + public function validate(\Phalcon\Validation $validation, $field): bool {} + +} From 0830ac310e21fe70f6d92c98f4941c056b98d7d0 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sun, 18 Aug 2019 22:37:18 +0200 Subject: [PATCH 10/25] Updated stubs to beta.2 --- src/Phalcon/Collection.php | 3 +-- src/Phalcon/application/AbstractApplication.php | 12 ++++++------ src/Phalcon/db/adapter/AbstractAdapter.php | 6 +++--- src/Phalcon/db/adapter/AdapterInterface.php | 4 ++-- src/Phalcon/db/result/Pdo.php | 4 ++-- src/Phalcon/forms/element/Select.php | 2 +- src/Phalcon/html/Tag.php | 4 ++-- src/Phalcon/security/Random.php | 7 ------- src/Phalcon/tag/Select.php | 4 ++-- 9 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index ecde5727..eb8b0927 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -137,9 +137,8 @@ public function offsetGet($element) {} /** * Offset to set - * See [offsetSet]( + * See [offsetSet](https://php.net/manual/en/arrayaccess.offsetset.php) * - * @link )https://php.net/manual/en/arrayaccess.offsetset.php) * @param mixed $element * @param mixed $value */ diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index b0376906..9c441209 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -89,24 +89,24 @@ abstract public function handle(); * * @param array $modules * @param bool $merge - * @return Application + * @return AbstractApplication */ - public function registerModules(array $modules, bool $merge = false): Application {} + public function registerModules(array $modules, bool $merge = false): AbstractApplication {} /** * Sets the module name to be used if the router doesn't return a valid module * * @param string $defaultModule - * @return Application + * @return AbstractApplication */ - public function setDefaultModule(string $defaultModule): Application {} + public function setDefaultModule(string $defaultModule): AbstractApplication {} /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return Application + * @return AbstractApplication */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): Application {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AbstractApplication {} } diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index e6cbc176..d5a4c210 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -480,7 +480,7 @@ public function getDescriptor(): array {} /** * Returns internal dialect instance * - * @return DialectInterface + * @return \Phalcon\Db\DialectInterface */ public function getDialect(): DialectInterface {} @@ -651,9 +651,9 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager /** * Sets the dialect used to produce the SQL * - * @param DialectInterface $dialect + * @param \Phalcon\Db\DialectInterface $dialect */ - public function setDialect(DialectInterface $dialect) {} + public function setDialect(\Phalcon\Db\DialectInterface $dialect) {} /** * Set if nested transactions should use savepoints diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index e136e02f..97744ae5 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -326,7 +326,7 @@ public function getDescriptor(): array; /** * Returns internal dialect instance * - * @return DialectInterface + * @return \Phalcon\Db\DialectInterface */ public function getDialect(): DialectInterface; @@ -494,7 +494,7 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlStatement * @param mixed $placeholders * @param mixed $dataTypes - * @return bool|ResultInterface + * @return bool|\Phalcon\Db\ResultInterface */ public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 42675919..98a954a3 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -53,13 +53,13 @@ class Pdo implements \Phalcon\Db\ResultInterface /** * Phalcon\Db\Result\Pdo constructor * - * @param Db\AdapterInterface $connection + * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @param \PDOStatement $result * @param mixed $sqlStatement * @param mixed $bindParams * @param mixed $bindTypes */ - public function __construct(Db\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} + public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} /** * Moves internal resultset cursor to another position letting us to fetch a diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index 16c0fc24..9fcbf112 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -25,7 +25,7 @@ public function __construct(string $name, $options = null, $attributes = null) { /** * Adds an option to the current options * - * @param array $option + * @param array|string $option * @return Element */ public function addOption($option): Element {} diff --git a/src/Phalcon/html/Tag.php b/src/Phalcon/html/Tag.php index ee523d93..f825b280 100644 --- a/src/Phalcon/html/Tag.php +++ b/src/Phalcon/html/Tag.php @@ -1171,12 +1171,12 @@ private function renderSelectArray(array $options, $value, string $closeOption): /** * Generates the option values from a resultset * - * @param ResulsetInterface $resultset + * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset * @param mixed $using * @param mixed $value * @param string $closeOption * @return string */ - private function renderSelectResultset(ResulsetInterface $resultset, $using, $value, string $closeOption): string {} + private function renderSelectResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string {} } diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/security/Random.php index 06baa385..3ff0e433 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/security/Random.php @@ -10,13 +10,6 @@ * Provides secure random number generator which is suitable for generating * session key in HTTP cookies, etc. * - * It supports following secure random number generators: - * - * - random_bytes (PHP 7) - * - libsodium - * - openssl, libressl - * - /dev/urandom - * * `Phalcon\Security\Random` could be mainly useful for: * * - Key generation (e.g. generation of complicated keys) diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 5f1f29fe..7b670532 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -33,12 +33,12 @@ private static function optionsFromArray(array $data, $value, string $closeOptio /** * Generate the OPTION tags based on a resultset * - * @param \Phalcon\Mvc\Model\ResulsetInterface $resultset + * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset * @param array $using * @param mixed $value * @param string $closeOption * @return string */ - private static function optionsFromResultset(\Phalcon\Mvc\Model\ResulsetInterface $resultset, $using, $value, string $closeOption): string {} + private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string {} } From 98d121b8fbe403ab1e989c8e175868df140384bc Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Thu, 22 Aug 2019 14:04:17 +0200 Subject: [PATCH 11/25] Fixed missing \ in extended Exception. Workaround untill https://github.com/phalcon/zephir/issues/1907 is fixed. --- src/Phalcon/Exception.php | 2 +- src/Phalcon/cache/exception/Exception.php | 2 +- src/Phalcon/cache/exception/InvalidArgumentException.php | 2 +- src/Phalcon/collection/Exception.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 1cbf0b74..88b0636f 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -7,7 +7,7 @@ * * All framework exceptions should use or extend this exception */ -class Exception extends Exception implements \Throwable +class Exception extends \Exception implements \Throwable { /** diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php index cd483e0a..b97a13d8 100644 --- a/src/Phalcon/cache/exception/Exception.php +++ b/src/Phalcon/cache/exception/Exception.php @@ -5,7 +5,7 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class Exception extends Exception implements \Psr\SimpleCache\CacheException +class Exception extends \Exception implements \Psr\SimpleCache\CacheException { } diff --git a/src/Phalcon/cache/exception/InvalidArgumentException.php b/src/Phalcon/cache/exception/InvalidArgumentException.php index 82839f82..6d1c6a22 100644 --- a/src/Phalcon/cache/exception/InvalidArgumentException.php +++ b/src/Phalcon/cache/exception/InvalidArgumentException.php @@ -5,7 +5,7 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class InvalidArgumentException extends Exception implements \Psr\SimpleCache\InvalidArgumentException +class InvalidArgumentException extends \Exception implements \Psr\SimpleCache\InvalidArgumentException { } diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php index 58194464..95493ef5 100644 --- a/src/Phalcon/collection/Exception.php +++ b/src/Phalcon/collection/Exception.php @@ -5,7 +5,7 @@ /** * Exceptions for the Collection object */ -class Exception extends Exception implements \Throwable +class Exception extends \Exception implements \Throwable { } From f0f03b1e9fd728b080213ff16a9560bc3d32d05d Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Mon, 23 Sep 2019 16:35:13 +0200 Subject: [PATCH 12/25] Bumped ide-stubs to 4.0.0-rc.1 --- src/Phalcon/Cache.php | 38 +- src/Phalcon/Collection.php | 23 +- src/Phalcon/Config.php | 15 +- src/Phalcon/Container.php | 14 +- src/Phalcon/Crypt.php | 13 +- src/Phalcon/Debug.php | 11 +- src/Phalcon/Di.php | 26 +- src/Phalcon/Escaper.php | 17 +- src/Phalcon/Exception.php | 13 +- src/Phalcon/{filter => }/Filter.php | 15 +- src/Phalcon/Kernel.php | 9 + src/Phalcon/Loader.php | 18 +- src/Phalcon/{logger => }/Logger.php | 22 +- src/Phalcon/Plugin.php | 12 - src/Phalcon/Registry.php | 17 +- src/Phalcon/Security.php | 66 +- src/Phalcon/Tag.php | 430 +----- src/Phalcon/Text.php | 9 + src/Phalcon/Url.php | 47 +- src/Phalcon/Validation.php | 19 +- src/Phalcon/Version.php | 9 + src/Phalcon/acl/Component.php | 11 +- src/Phalcon/acl/ComponentAware.php | 9 + src/Phalcon/acl/ComponentInterface.php | 9 + src/Phalcon/acl/Enum.php | 9 + src/Phalcon/acl/Exception.php | 9 + src/Phalcon/acl/Role.php | 11 +- src/Phalcon/acl/RoleAware.php | 9 + src/Phalcon/acl/RoleInterface.php | 9 + src/Phalcon/acl/adapter/AbstractAdapter.php | 14 +- src/Phalcon/acl/adapter/AdapterInterface.php | 9 + src/Phalcon/acl/adapter/Memory.php | 19 +- src/Phalcon/annotations/Annotation.php | 9 + .../annotations/AnnotationsFactory.php | 14 +- src/Phalcon/annotations/Collection.php | 18 +- src/Phalcon/annotations/Exception.php | 9 + src/Phalcon/annotations/Reader.php | 11 +- src/Phalcon/annotations/ReaderInterface.php | 9 + src/Phalcon/annotations/Reflection.php | 13 +- .../annotations/adapter/AbstractAdapter.php | 16 +- .../annotations/adapter/AdapterInterface.php | 13 + src/Phalcon/annotations/adapter/Apcu.php | 15 +- src/Phalcon/annotations/adapter/Memory.php | 11 +- src/Phalcon/annotations/adapter/Stream.php | 15 +- .../application/AbstractApplication.php | 24 +- src/Phalcon/application/Exception.php | 9 + src/Phalcon/assets/Asset.php | 15 +- src/Phalcon/assets/AssetInterface.php | 9 + src/Phalcon/assets/Collection.php | 14 +- src/Phalcon/assets/Exception.php | 9 + src/Phalcon/assets/FilterInterface.php | 9 + src/Phalcon/assets/Inline.php | 15 +- src/Phalcon/assets/Manager.php | 32 +- src/Phalcon/assets/asset/Css.php | 13 +- src/Phalcon/assets/asset/Js.php | 13 +- src/Phalcon/assets/filters/Cssmin.php | 13 +- src/Phalcon/assets/filters/Jsmin.php | 13 +- src/Phalcon/assets/filters/None.php | 13 +- src/Phalcon/assets/inline/Css.php | 13 +- src/Phalcon/assets/inline/Js.php | 13 +- src/Phalcon/cache/AdapterFactory.php | 15 +- src/Phalcon/cache/CacheFactory.php | 11 + .../cache/adapter/AdapterInterface.php | 13 +- src/Phalcon/cache/adapter/Apcu.php | 14 +- src/Phalcon/cache/adapter/Libmemcached.php | 14 +- src/Phalcon/cache/adapter/Memory.php | 14 +- src/Phalcon/cache/adapter/Redis.php | 14 +- src/Phalcon/cache/adapter/Stream.php | 14 +- src/Phalcon/cache/exception/Exception.php | 11 +- .../exception/InvalidArgumentException.php | 11 +- src/Phalcon/cli/Console.php | 18 +- src/Phalcon/cli/Dispatcher.php | 13 +- src/Phalcon/cli/DispatcherInterface.php | 13 +- src/Phalcon/cli/Router.php | 34 +- src/Phalcon/cli/RouterInterface.php | 11 + src/Phalcon/cli/Task.php | 17 +- src/Phalcon/cli/TaskInterface.php | 9 + src/Phalcon/cli/console/Exception.php | 9 + src/Phalcon/cli/dispatcher/Exception.php | 9 + src/Phalcon/cli/router/Exception.php | 9 + src/Phalcon/cli/router/Route.php | 9 + src/Phalcon/cli/router/RouteInterface.php | 9 + src/Phalcon/collection/Exception.php | 13 +- src/Phalcon/collection/ReadOnly.php | 13 +- src/Phalcon/config/ConfigFactory.php | 17 +- src/Phalcon/config/Exception.php | 9 + src/Phalcon/config/adapter/Grouped.php | 13 +- src/Phalcon/config/adapter/Ini.php | 19 +- src/Phalcon/config/adapter/Json.php | 21 +- src/Phalcon/config/adapter/Php.php | 21 +- src/Phalcon/config/adapter/Yaml.php | 21 +- src/Phalcon/crypt/CryptInterface.php | 9 + src/Phalcon/crypt/Exception.php | 9 + src/Phalcon/crypt/Mismatch.php | 11 +- src/Phalcon/db/AbstractDb.php | 13 +- src/Phalcon/db/Column.php | 15 +- src/Phalcon/db/ColumnInterface.php | 9 + src/Phalcon/db/Dialect.php | 11 +- src/Phalcon/db/DialectInterface.php | 9 + src/Phalcon/db/Enum.php | 9 + src/Phalcon/db/Exception.php | 9 + src/Phalcon/db/Index.php | 15 +- src/Phalcon/db/IndexInterface.php | 9 + src/Phalcon/db/Profiler.php | 12 + src/Phalcon/db/RawValue.php | 15 +- src/Phalcon/db/Reference.php | 15 +- src/Phalcon/db/ReferenceInterface.php | 9 + src/Phalcon/db/ResultInterface.php | 9 + src/Phalcon/db/adapter/AbstractAdapter.php | 17 +- src/Phalcon/db/adapter/AdapterInterface.php | 12 + src/Phalcon/db/adapter/PdoFactory.php | 13 +- src/Phalcon/db/adapter/pdo/AbstractPdo.php | 15 +- src/Phalcon/db/adapter/pdo/Mysql.php | 17 +- src/Phalcon/db/adapter/pdo/Postgresql.php | 14 +- src/Phalcon/db/adapter/pdo/Sqlite.php | 14 +- src/Phalcon/db/dialect/Mysql.php | 13 +- src/Phalcon/db/dialect/Postgresql.php | 13 +- src/Phalcon/db/dialect/Sqlite.php | 13 +- src/Phalcon/db/profiler/Item.php | 9 + src/Phalcon/db/result/Pdo.php | 16 +- src/Phalcon/debug/Dump.php | 9 + src/Phalcon/debug/Exception.php | 9 + src/Phalcon/di/AbstractInjectionAware.php | 41 + src/Phalcon/di/DiInterface.php | 13 +- src/Phalcon/di/Exception.php | 9 + src/Phalcon/di/FactoryDefault.php | 9 + src/Phalcon/di/Injectable.php | 23 +- src/Phalcon/di/InjectionAwareInterface.php | 9 + src/Phalcon/di/Service.php | 17 +- src/Phalcon/di/ServiceInterface.php | 9 + src/Phalcon/di/ServiceProviderInterface.php | 9 + .../exception/ServiceResolutionException.php | 6 - src/Phalcon/di/factorydefault/Cli.php | 13 +- src/Phalcon/di/service/Builder.php | 9 + src/Phalcon/dispatcher/AbstractDispatcher.php | 33 +- .../dispatcher/DispatcherInterface.php | 9 + src/Phalcon/dispatcher/Exception.php | 11 +- src/Phalcon/domain/payload/Payload.php | 19 +- src/Phalcon/domain/payload/PayloadFactory.php | 17 + .../domain/payload/PayloadInterface.php | 19 +- .../domain/payload/ReadableInterface.php | 17 + src/Phalcon/domain/payload/Status.php | 17 + .../domain/payload/WriteableInterface.php | 17 + src/Phalcon/escaper/EscaperInterface.php | 9 + src/Phalcon/escaper/Exception.php | 9 + src/Phalcon/events/Event.php | 11 +- src/Phalcon/events/EventInterface.php | 9 + src/Phalcon/events/EventsAwareInterface.php | 13 +- src/Phalcon/events/Exception.php | 9 + src/Phalcon/events/Manager.php | 11 +- src/Phalcon/events/ManagerInterface.php | 9 + src/Phalcon/factory/AbstractFactory.php | 9 +- src/Phalcon/factory/Exception.php | 7 +- src/Phalcon/filter/Exception.php | 9 + src/Phalcon/filter/FilterFactory.php | 7 +- src/Phalcon/filter/FilterInterface.php | 9 + src/Phalcon/filter/sanitize/AbsInt.php | 9 + src/Phalcon/filter/sanitize/Alnum.php | 9 + src/Phalcon/filter/sanitize/Alpha.php | 9 + src/Phalcon/filter/sanitize/BoolVal.php | 9 + src/Phalcon/filter/sanitize/Email.php | 9 + src/Phalcon/filter/sanitize/FloatVal.php | 9 + src/Phalcon/filter/sanitize/IntVal.php | 9 + src/Phalcon/filter/sanitize/Lower.php | 9 + src/Phalcon/filter/sanitize/LowerFirst.php | 9 + src/Phalcon/filter/sanitize/Regex.php | 9 + src/Phalcon/filter/sanitize/Remove.php | 9 + src/Phalcon/filter/sanitize/Replace.php | 9 + src/Phalcon/filter/sanitize/Special.php | 9 + src/Phalcon/filter/sanitize/SpecialFull.php | 9 + src/Phalcon/filter/sanitize/StringVal.php | 9 + src/Phalcon/filter/sanitize/Striptags.php | 9 + src/Phalcon/filter/sanitize/Trim.php | 9 + src/Phalcon/filter/sanitize/Upper.php | 9 + src/Phalcon/filter/sanitize/UpperFirst.php | 9 + src/Phalcon/filter/sanitize/UpperWords.php | 9 + src/Phalcon/filter/sanitize/Url.php | 9 + src/Phalcon/firewall/Exception.php | 9 + .../firewall/adapter/AbstractAdapter.php | 34 +- src/Phalcon/firewall/adapter/Acl.php | 11 +- .../firewall/adapter/AdapterInterface.php | 9 + src/Phalcon/firewall/adapter/Annotations.php | 11 +- src/Phalcon/firewall/adapter/micro/Acl.php | 14 +- src/Phalcon/flash/AbstractFlash.php | 88 +- src/Phalcon/flash/Direct.php | 15 +- src/Phalcon/flash/Exception.php | 9 + src/Phalcon/flash/FlashInterface.php | 12 +- src/Phalcon/flash/Session.php | 23 +- src/Phalcon/forms/Exception.php | 9 + src/Phalcon/forms/Form.php | 21 +- src/Phalcon/forms/Manager.php | 9 + src/Phalcon/forms/element/AbstractElement.php | 14 +- src/Phalcon/forms/element/Check.php | 11 +- src/Phalcon/forms/element/Date.php | 11 +- .../forms/element/ElementInterface.php | 12 + src/Phalcon/forms/element/Email.php | 11 +- src/Phalcon/forms/element/File.php | 11 +- src/Phalcon/forms/element/Hidden.php | 11 +- src/Phalcon/forms/element/Numeric.php | 11 +- src/Phalcon/forms/element/Password.php | 11 +- src/Phalcon/forms/element/Radio.php | 11 +- src/Phalcon/forms/element/Select.php | 11 +- src/Phalcon/forms/element/Submit.php | 11 +- src/Phalcon/forms/element/Text.php | 11 +- src/Phalcon/forms/element/TextArea.php | 11 +- src/Phalcon/helper/Arr.php | 21 +- src/Phalcon/helper/Exception.php | 9 + src/Phalcon/helper/Fs.php | 33 + src/Phalcon/helper/Number.php | 9 + src/Phalcon/helper/Str.php | 9 + src/Phalcon/html/Attributes.php | 14 +- src/Phalcon/html/Breadcrumbs.php | 9 + src/Phalcon/html/Exception.php | 9 + src/Phalcon/html/Tag.php | 1182 ----------------- src/Phalcon/html/TagFactory.php | 14 +- .../html/attributes/AttributesInterface.php | 18 +- .../html/attributes/RenderInterface.php | 16 +- src/Phalcon/html/helper/AbstractHelper.php | 11 + src/Phalcon/html/helper/Anchor.php | 11 +- src/Phalcon/html/helper/AnchorRaw.php | 11 +- src/Phalcon/html/helper/Body.php | 11 +- src/Phalcon/html/helper/Button.php | 11 +- src/Phalcon/html/helper/Close.php | 11 +- src/Phalcon/html/helper/Element.php | 11 +- src/Phalcon/html/helper/ElementRaw.php | 13 +- src/Phalcon/html/helper/Form.php | 11 +- src/Phalcon/html/helper/Img.php | 13 +- src/Phalcon/html/helper/Label.php | 13 +- src/Phalcon/html/helper/TextArea.php | 11 +- src/Phalcon/http/Cookie.php | 30 +- src/Phalcon/http/CookieInterface.php | 9 + src/Phalcon/http/Request.php | 48 +- src/Phalcon/http/RequestInterface.php | 22 +- src/Phalcon/http/Response.php | 22 +- src/Phalcon/http/ResponseInterface.php | 11 + src/Phalcon/http/cookie/Exception.php | 9 + src/Phalcon/http/message/AbstractCommon.php | 13 + src/Phalcon/http/message/AbstractMessage.php | 20 +- src/Phalcon/http/message/AbstractRequest.php | 18 +- src/Phalcon/http/message/Request.php | 19 +- src/Phalcon/http/message/RequestFactory.php | 19 +- src/Phalcon/http/message/Response.php | 17 +- src/Phalcon/http/message/ResponseFactory.php | 18 +- src/Phalcon/http/message/ServerRequest.php | 25 +- .../http/message/ServerRequestFactory.php | 22 +- src/Phalcon/http/message/Stream.php | 19 +- src/Phalcon/http/message/StreamFactory.php | 18 +- src/Phalcon/http/message/UploadedFile.php | 23 +- .../http/message/UploadedFileFactory.php | 19 +- src/Phalcon/http/message/Uri.php | 18 +- src/Phalcon/http/message/UriFactory.php | 18 +- .../exception/InvalidArgumentException.php | 12 +- src/Phalcon/http/message/stream/Input.php | 17 +- src/Phalcon/http/message/stream/Memory.php | 17 +- src/Phalcon/http/message/stream/Temp.php | 17 +- src/Phalcon/http/request/Exception.php | 9 + src/Phalcon/http/request/File.php | 15 +- src/Phalcon/http/request/FileInterface.php | 10 + src/Phalcon/http/response/Cookies.php | 33 +- .../http/response/CookiesInterface.php | 11 + src/Phalcon/http/response/Exception.php | 9 + src/Phalcon/http/response/Headers.php | 20 +- .../http/response/HeadersInterface.php | 9 + .../http/server/AbstractMiddleware.php | 16 +- .../http/server/AbstractRequestHandler.php | 15 +- src/Phalcon/image/Enum.php | 7 +- src/Phalcon/image/Exception.php | 7 +- src/Phalcon/image/ImageFactory.php | 14 +- src/Phalcon/image/adapter/AbstractAdapter.php | 69 +- .../image/adapter/AdapterInterface.php | 51 +- src/Phalcon/image/adapter/Gd.php | 9 +- src/Phalcon/image/adapter/Imagick.php | 19 +- src/Phalcon/loader/Exception.php | 9 + src/Phalcon/logger/AdapterFactory.php | 11 +- src/Phalcon/logger/Exception.php | 9 + src/Phalcon/logger/Item.php | 10 + src/Phalcon/logger/LoggerFactory.php | 13 +- .../logger/adapter/AbstractAdapter.php | 11 +- .../logger/adapter/AdapterInterface.php | 14 +- src/Phalcon/logger/adapter/Noop.php | 15 +- src/Phalcon/logger/adapter/Stream.php | 15 +- src/Phalcon/logger/adapter/Syslog.php | 13 +- .../logger/formatter/AbstractFormatter.php | 9 +- .../logger/formatter/FormatterInterface.php | 9 + src/Phalcon/logger/formatter/Json.php | 11 +- src/Phalcon/logger/formatter/Line.php | 13 +- src/Phalcon/logger/formatter/Syslog.php | 11 +- src/Phalcon/messages/Exception.php | 11 +- src/Phalcon/messages/Message.php | 13 +- src/Phalcon/messages/MessageInterface.php | 9 + src/Phalcon/messages/Messages.php | 16 +- src/Phalcon/mvc/Application.php | 31 +- src/Phalcon/mvc/Collection.php | 664 --------- src/Phalcon/mvc/CollectionInterface.php | 165 --- src/Phalcon/mvc/Controller.php | 17 +- src/Phalcon/mvc/ControllerInterface.php | 9 + src/Phalcon/mvc/Dispatcher.php | 17 +- src/Phalcon/mvc/DispatcherInterface.php | 13 +- src/Phalcon/mvc/EntityInterface.php | 11 +- src/Phalcon/mvc/Micro.php | 21 +- src/Phalcon/mvc/Model.php | 57 +- src/Phalcon/mvc/ModelInterface.php | 37 +- src/Phalcon/mvc/ModuleDefinitionInterface.php | 9 + src/Phalcon/mvc/Router.php | 33 +- src/Phalcon/mvc/RouterInterface.php | 23 +- src/Phalcon/mvc/View.php | 15 +- src/Phalcon/mvc/ViewBaseInterface.php | 9 + src/Phalcon/mvc/ViewInterface.php | 11 +- src/Phalcon/mvc/application/Exception.php | 9 + src/Phalcon/mvc/collection/Behavior.php | 56 - .../mvc/collection/BehaviorInterface.php | 30 - src/Phalcon/mvc/collection/Document.php | 76 -- src/Phalcon/mvc/collection/Exception.php | 13 - src/Phalcon/mvc/collection/Manager.php | 199 --- .../mvc/collection/ManagerInterface.php | 116 -- .../mvc/collection/behavior/SoftDelete.php | 22 - .../mvc/collection/behavior/Timestampable.php | 22 - .../mvc/controller/BindModelInterface.php | 9 + src/Phalcon/mvc/dispatcher/Exception.php | 9 + src/Phalcon/mvc/micro/Collection.php | 15 +- src/Phalcon/mvc/micro/CollectionInterface.php | 9 + src/Phalcon/mvc/micro/Exception.php | 9 + src/Phalcon/mvc/micro/LazyLoader.php | 9 + src/Phalcon/mvc/micro/MiddlewareInterface.php | 9 + src/Phalcon/mvc/model/Behavior.php | 11 +- src/Phalcon/mvc/model/BehaviorInterface.php | 9 + src/Phalcon/mvc/model/Binder.php | 13 +- src/Phalcon/mvc/model/BinderInterface.php | 11 + src/Phalcon/mvc/model/Criteria.php | 15 +- src/Phalcon/mvc/model/CriteriaInterface.php | 9 + src/Phalcon/mvc/model/Exception.php | 11 +- src/Phalcon/mvc/model/Manager.php | 22 +- src/Phalcon/mvc/model/ManagerInterface.php | 15 +- src/Phalcon/mvc/model/MetaData.php | 16 +- src/Phalcon/mvc/model/MetaDataInterface.php | 11 + src/Phalcon/mvc/model/Query.php | 31 +- src/Phalcon/mvc/model/QueryInterface.php | 11 + src/Phalcon/mvc/model/Relation.php | 11 +- src/Phalcon/mvc/model/RelationInterface.php | 9 + src/Phalcon/mvc/model/ResultInterface.php | 9 + src/Phalcon/mvc/model/Resultset.php | 21 +- src/Phalcon/mvc/model/ResultsetInterface.php | 12 + src/Phalcon/mvc/model/Row.php | 15 +- src/Phalcon/mvc/model/Transaction.php | 11 +- .../mvc/model/TransactionInterface.php | 9 + src/Phalcon/mvc/model/ValidationFailed.php | 13 +- src/Phalcon/mvc/model/behavior/SoftDelete.php | 13 +- .../mvc/model/behavior/Timestampable.php | 13 +- .../mvc/model/binder/BindableInterface.php | 9 + src/Phalcon/mvc/model/metadata/Apcu.php | 17 +- .../mvc/model/metadata/Libmemcached.php | 13 +- src/Phalcon/mvc/model/metadata/Memory.php | 14 +- src/Phalcon/mvc/model/metadata/Redis.php | 17 +- .../mvc/model/metadata/StrategyInterface.php | 7 +- src/Phalcon/mvc/model/metadata/Stream.php | 17 +- .../model/metadata/strategy/Annotations.php | 11 +- .../model/metadata/strategy/Introspection.php | 13 +- src/Phalcon/mvc/model/query/Builder.php | 22 +- .../mvc/model/query/BuilderInterface.php | 11 + src/Phalcon/mvc/model/query/Lang.php | 11 +- src/Phalcon/mvc/model/query/Status.php | 17 +- .../mvc/model/query/StatusInterface.php | 11 + src/Phalcon/mvc/model/resultset/Complex.php | 14 +- src/Phalcon/mvc/model/resultset/Simple.php | 13 +- .../mvc/model/transaction/Exception.php | 9 + src/Phalcon/mvc/model/transaction/Failed.php | 13 +- src/Phalcon/mvc/model/transaction/Manager.php | 17 +- .../model/transaction/ManagerInterface.php | 11 + src/Phalcon/mvc/router/Annotations.php | 13 +- src/Phalcon/mvc/router/Exception.php | 9 + src/Phalcon/mvc/router/Group.php | 17 +- src/Phalcon/mvc/router/GroupInterface.php | 13 +- src/Phalcon/mvc/router/Route.php | 11 +- src/Phalcon/mvc/router/RouteInterface.php | 15 +- src/Phalcon/mvc/view/Exception.php | 9 + src/Phalcon/mvc/view/Simple.php | 22 +- .../mvc/view/engine/AbstractEngine.php | 14 +- .../mvc/view/engine/EngineInterface.php | 9 + src/Phalcon/mvc/view/engine/Php.php | 11 +- src/Phalcon/mvc/view/engine/Volt.php | 13 +- src/Phalcon/mvc/view/engine/volt/Compiler.php | 18 +- .../mvc/view/engine/volt/Exception.php | 13 +- src/Phalcon/paginator/Exception.php | 9 + src/Phalcon/paginator/PaginatorFactory.php | 12 +- src/Phalcon/paginator/Repository.php | 13 +- src/Phalcon/paginator/RepositoryInterface.php | 9 + .../paginator/adapter/AbstractAdapter.php | 13 +- .../paginator/adapter/AdapterInterface.php | 11 + src/Phalcon/paginator/adapter/Model.php | 15 +- src/Phalcon/paginator/adapter/NativeArray.php | 15 +- .../paginator/adapter/QueryBuilder.php | 16 +- src/Phalcon/security/Exception.php | 9 + src/Phalcon/security/Random.php | 13 +- src/Phalcon/session/Bag.php | 14 +- src/Phalcon/session/Exception.php | 9 + src/Phalcon/session/Manager.php | 56 +- src/Phalcon/session/ManagerInterface.php | 33 +- .../session/adapter/AbstractAdapter.php | 10 +- src/Phalcon/session/adapter/Libmemcached.php | 11 +- src/Phalcon/session/adapter/Noop.php | 15 +- src/Phalcon/session/adapter/Redis.php | 11 +- src/Phalcon/session/adapter/Stream.php | 15 +- src/Phalcon/storage/AdapterFactory.php | 12 +- src/Phalcon/storage/Exception.php | 10 + src/Phalcon/storage/SerializerFactory.php | 12 +- .../storage/adapter/AbstractAdapter.php | 14 +- .../storage/adapter/AdapterInterface.php | 9 + src/Phalcon/storage/adapter/Apcu.php | 11 +- src/Phalcon/storage/adapter/Libmemcached.php | 13 +- src/Phalcon/storage/adapter/Memory.php | 13 +- src/Phalcon/storage/adapter/Redis.php | 13 +- src/Phalcon/storage/adapter/Stream.php | 14 +- .../storage/serializer/AbstractSerializer.php | 29 +- src/Phalcon/storage/serializer/Base64.php | 9 +- src/Phalcon/storage/serializer/Igbinary.php | 9 +- src/Phalcon/storage/serializer/Json.php | 9 +- src/Phalcon/storage/serializer/Msgpack.php | 9 +- src/Phalcon/storage/serializer/None.php | 9 +- src/Phalcon/storage/serializer/Php.php | 9 +- .../serializer/SerializerInterface.php | 12 +- src/Phalcon/tag/Exception.php | 9 + src/Phalcon/tag/Select.php | 9 + src/Phalcon/translate/Exception.php | 9 + src/Phalcon/translate/InterpolatorFactory.php | 12 +- src/Phalcon/translate/TranslateFactory.php | 11 +- .../translate/adapter/AbstractAdapter.php | 13 +- .../translate/adapter/AdapterInterface.php | 9 + src/Phalcon/translate/adapter/Csv.php | 13 +- src/Phalcon/translate/adapter/Gettext.php | 13 +- src/Phalcon/translate/adapter/NativeArray.php | 13 +- .../interpolator/AssociativeArray.php | 9 +- .../translate/interpolator/IndexedArray.php | 9 +- .../interpolator/InterpolatorInterface.php | 9 + src/Phalcon/url/Exception.php | 9 + src/Phalcon/url/UrlInterface.php | 9 + .../AbstractCombinedFieldsValidator.php | 11 +- src/Phalcon/validation/AbstractValidator.php | 13 +- .../validation/AbstractValidatorComposite.php | 11 +- src/Phalcon/validation/Exception.php | 11 +- .../validation/ValidationInterface.php | 15 +- .../ValidatorCompositeInterface.php | 9 + src/Phalcon/validation/ValidatorFactory.php | 11 +- src/Phalcon/validation/ValidatorInterface.php | 9 + src/Phalcon/validation/validator/Alnum.php | 13 +- src/Phalcon/validation/validator/Alpha.php | 13 +- src/Phalcon/validation/validator/Between.php | 13 +- src/Phalcon/validation/validator/Callback.php | 13 +- .../validation/validator/Confirmation.php | 13 +- .../validation/validator/CreditCard.php | 13 +- src/Phalcon/validation/validator/Date.php | 13 +- src/Phalcon/validation/validator/Digit.php | 13 +- src/Phalcon/validation/validator/Email.php | 13 +- .../validation/validator/Exception.php | 11 +- .../validation/validator/ExclusionIn.php | 13 +- src/Phalcon/validation/validator/File.php | 13 +- .../validation/validator/Identical.php | 13 +- .../validation/validator/InclusionIn.php | 13 +- src/Phalcon/validation/validator/Ip.php | 13 +- .../validation/validator/Numericality.php | 13 +- .../validation/validator/PresenceOf.php | 13 +- src/Phalcon/validation/validator/Regex.php | 13 +- .../validation/validator/StringLength.php | 13 +- .../validation/validator/Uniqueness.php | 25 +- src/Phalcon/validation/validator/Url.php | 13 +- .../validator/file/AbstractFile.php | 13 +- .../validation/validator/file/MimeType.php | 11 +- .../validator/file/resolution/Equal.php | 13 +- .../validator/file/resolution/Max.php | 13 +- .../validator/file/resolution/Min.php | 13 +- .../validation/validator/file/size/Equal.php | 13 +- .../validation/validator/file/size/Max.php | 13 +- .../validation/validator/file/size/Min.php | 13 +- .../validation/validator/stringlength/Max.php | 13 +- .../validation/validator/stringlength/Min.php | 13 +- 474 files changed, 5555 insertions(+), 3901 deletions(-) rename src/Phalcon/{filter => }/Filter.php (89%) rename src/Phalcon/{logger => }/Logger.php (93%) delete mode 100644 src/Phalcon/Plugin.php create mode 100644 src/Phalcon/di/AbstractInjectionAware.php create mode 100644 src/Phalcon/helper/Fs.php delete mode 100644 src/Phalcon/html/Tag.php delete mode 100644 src/Phalcon/mvc/Collection.php delete mode 100644 src/Phalcon/mvc/CollectionInterface.php delete mode 100644 src/Phalcon/mvc/collection/Behavior.php delete mode 100644 src/Phalcon/mvc/collection/BehaviorInterface.php delete mode 100644 src/Phalcon/mvc/collection/Document.php delete mode 100644 src/Phalcon/mvc/collection/Exception.php delete mode 100644 src/Phalcon/mvc/collection/Manager.php delete mode 100644 src/Phalcon/mvc/collection/ManagerInterface.php delete mode 100644 src/Phalcon/mvc/collection/behavior/SoftDelete.php delete mode 100644 src/Phalcon/mvc/collection/behavior/Timestampable.php diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index 444fa3d7..4c844d1f 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -1,12 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Cache\Adapter\AdapterInterface; +use Psr\SimpleCache\CacheInterface; + /** * This component offers caching capabilities for your application. * Phalcon\Cache implements PSR-16. */ -class Cache implements \Psr\SimpleCache\CacheInterface +class Cache implements CacheInterface { /** * The adapter @@ -44,8 +56,7 @@ public function clear(): bool {} * * @return bool True if the item was successfully removed. False if there was an error. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. * @param mixed $key * @return bool */ @@ -58,9 +69,7 @@ public function delete($key): bool {} * * @return bool True if the items were successfully removed. False if there was an error. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if $keys is neither an array nor a Traversable, - * or if any of the $keys are not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. * @param mixed $keys * @return bool */ @@ -73,8 +82,7 @@ public function deleteMultiple($keys): bool {} * * @return mixed The value of the item from the cache, or $default in case of cache miss. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. * @param string $key The unique key of this item in the cache. * @param mixed $defaultValue * @return mixed @@ -88,9 +96,7 @@ public function get($key, $defaultValue = null) {} * * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if $keys is neither an array nor a Traversable, - * or if any of the $keys are not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. * @param iterable $keys A list of keys that can obtained in a single operation. * @param mixed $defaultValue * @return mixed @@ -104,8 +110,7 @@ public function getMultiple($keys, $defaultValue = null) {} * * @return bool * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. * @param mixed $key * @return bool */ @@ -120,8 +125,7 @@ public function has($key): bool {} * * @return bool True on success and false on failure. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if the $key string is not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. * @param string $key The key of the item to store. * @param mixed $value The value of the item to store. Must be serializable. * @param mixed $ttl @@ -138,9 +142,7 @@ public function set($key, $value, $ttl = null): bool {} * * @return bool True on success and false on failure. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException - * MUST be thrown if $values is neither an array nor a Traversable, - * or if any of the $values are not a legal value. + * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value. * @param iterable $values A list of key => value pairs for a multiple-set operation. * @param mixed $ttl * @return bool diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index eb8b0927..34d86fb3 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -1,7 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use ArrayAccess; +use Countable; +use IteratorAggregate; +use JsonSerializable; +use Serializable; +use Traversable; + /** * `Phalcon\Collection` is a supercharged object oriented array. It implements [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php), [Countable](https://www.php.net/manual/en/class.countable.php), [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate.php), [JsonSerializable](https://www.php.net/manual/en/class.jsonserializable.php), [Serializable](https://www.php.net/manual/en/class.serializable.php) * @@ -9,7 +25,12 @@ * Such implementations are for instance accessing globals `$_GET`, `$_POST` * etc. */ -class Collection implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSerializable, \Serializable +class Collection implements + ArrayAccess, + Countable, + IteratorAggregate, + JsonSerializable, + Serializable { /** * @var array diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index c813fce2..e21f8410 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; /** @@ -8,7 +17,7 @@ * based user interface for accessing this configuration data within application * code. * - * ```php + *```php * $config = new \Phalcon\Config( * [ * "database" => [ @@ -25,9 +34,9 @@ * ], * ] * ); - * ``` + *``` */ -class Config extends \Phalcon\Collection +class Config extends Collection { const DEFAULT_PATH_DELIMITER = '.'; diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 22b70ee1..c734da9b 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\DiInterface; +use Psr\Container\ContainerInterface; + /** * PSR-11 Wrapper for `Phalcon\Di` */ -class Container implements \Psr\Container\ContainerInterface +class Container implements ContainerInterface { /** * @var diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 9a547569..4f4aebaf 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Crypt\CryptInterface; + /** * Provides encryption capabilities to Phalcon applications. * @@ -20,7 +31,7 @@ * echo $crypt->decrypt($encrypted, $key); * ``` */ -class Crypt implements \Phalcon\Crypt\CryptInterface +class Crypt implements CryptInterface { const PADDING_ANSI_X_923 = 1; diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 291d4d30..11e08ed9 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; /** @@ -43,7 +52,7 @@ class Debug /** * @var string */ - protected $uri = 'https://assets.phalconphp.com/debug/4.0.x/'; + protected $uri = 'https://assets.phalcon.io/debug/4.0.x/'; /** diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 4f4d7bb0..59d5b5a6 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -1,7 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception\ServiceResolutionException; +use Phalcon\Di\ServiceInterface; +use Phalcon\Events\ManagerInterface; + /** * Phalcon\Di is a component that implements Dependency Injection/Service * Location of services and it's itself a container for them. @@ -20,7 +34,7 @@ * Additionally, this pattern increases testability in the code, thus making it * less prone to errors. * - * ```php + *```php * use Phalcon\Di; * use Phalcon\Http\Request; * @@ -38,9 +52,9 @@ * ); * * $request = $di->getRequest(); - * ``` + *``` */ -class Di implements \Phalcon\Di\DiInterface +class Di implements DiInterface { /** * List of registered services @@ -77,7 +91,7 @@ public function __construct() {} * @param array $arguments * @return mixed|null */ - public function __call(string $method, array $arguments = array()): ? {} + public function __call(string $method, array $arguments = array()) {} /** * Attempts to register a service in the services container @@ -184,7 +198,7 @@ protected function loadFromConfig(\Phalcon\Config $config) {} * ]; * ``` * - * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @link https://docs.phalcon.io/en/latest/reference/di.html * @param string $filePath */ public function loadFromPhp(string $filePath) {} @@ -220,7 +234,7 @@ public function loadFromPhp(string $filePath) {} * className: \Acme\User * ``` * - * @link https://docs.phalconphp.com/en/latest/reference/di.html + * @link https://docs.phalcon.io/en/latest/reference/di.html * @param string $filePath * @param array $callbacks */ diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index ea0b9e58..f6c9a990 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Escaper\EscaperInterface; + /** * Phalcon\Escaper * @@ -11,15 +22,15 @@ * This component only works with UTF-8. The PREG extension needs to be compiled * with UTF-8 support. * - * ```php + *```php * $escaper = new \Phalcon\Escaper(); * * $escaped = $escaper->escapeCss("font-family: "); * * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E - * ``` + *``` */ -class Escaper implements \Phalcon\Escaper\EscaperInterface +class Escaper implements EscaperInterface { /** * @var bool diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 88b0636f..916eb89f 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Throwable; + /** * Phalcon\Exception * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception implements \Throwable +class Exception extends \Exception implements Throwable { /** diff --git a/src/Phalcon/filter/Filter.php b/src/Phalcon/Filter.php similarity index 89% rename from src/Phalcon/filter/Filter.php rename to src/Phalcon/Filter.php index ad2a7516..d9c45215 100644 --- a/src/Phalcon/filter/Filter.php +++ b/src/Phalcon/Filter.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +namespace Phalcon; + +use Phalcon\Filter\FilterInterface; /** * Lazy loads, stores and exposes sanitizer objects */ -class Filter implements \Phalcon\Filter\FilterInterface +class Filter implements FilterInterface { const FILTER_ABSINT = 'absint'; diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index 925c16e0..ba6ba1ea 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; /** diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 390a53fa..20f5168f 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -1,12 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * This component helps to load your project classes automatically based on some * conventions * - * ```php + *```php * use Phalcon\Loader; * * // Creates the autoloader @@ -26,9 +38,9 @@ * * // Requiring this class will automatically include file vendor/example/adapter/Some.php * $adapter = new \Example\Adapter\Some(); - * ``` + *``` */ -class Loader implements \Phalcon\Events\EventsAwareInterface +class Loader implements EventsAwareInterface { protected $checkedPath = null; diff --git a/src/Phalcon/logger/Logger.php b/src/Phalcon/Logger.php similarity index 93% rename from src/Phalcon/logger/Logger.php rename to src/Phalcon/Logger.php index 00a70150..11b07316 100644 --- a/src/Phalcon/logger/Logger.php +++ b/src/Phalcon/Logger.php @@ -1,6 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +namespace Phalcon; + +use Phalcon\Logger\Adapter\AdapterInterface; +use Phalcon\Logger\Exception; +use Psr\Log\InvalidArgumentException; +use Psr\Log\LoggerInterface; /** * Phalcon\Logger @@ -9,7 +23,7 @@ * component accepts multiple adapters, working also as a multiple logger. * Phalcon\Logger implements PSR-3. * - * ```php + *```php * use Phalcon\Logger; * use Phalcon\Logger\Adapter\Stream; * @@ -33,9 +47,9 @@ * $logger * ->excludeAdapters(['manager']) * ->info('This does not go to the "manager" logger); - * ``` + *``` */ -class Logger implements \Psr\Log\LoggerInterface +class Logger implements LoggerInterface { const ALERT = 2; diff --git a/src/Phalcon/Plugin.php b/src/Phalcon/Plugin.php deleted file mode 100644 index ddc7559e..00000000 --- a/src/Phalcon/Plugin.php +++ /dev/null @@ -1,12 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Traversable; + /** * Phalcon\Registry * @@ -9,7 +20,7 @@ * space. By storing the value in a registry, the same object is always * available throughout your application. * - * ```php + *```php * $registry = new \Phalcon\Registry(); * * // Set value @@ -31,7 +42,7 @@ * unset($registry->something); * // or * unset($registry["something"]); - * ``` + *``` * * In addition to ArrayAccess, Phalcon\Registry also implements Countable * (count($registry) will return the number of elements in the registry), @@ -52,7 +63,7 @@ * are implemented using object handlers or similar techniques: this allows to * bypass relatively slow method calls. */ -final class Registry extends \Phalcon\Collection +final class Registry extends Collection { /** diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 8a79b6be..32359ac7 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -1,12 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Http\RequestInterface; +use Phalcon\Security\Random; +use Phalcon\Session\ManagerInterface as SessionInterface; + /** * This component provides a set of functions to improve the security in Phalcon * applications * - * ```php + *```php * $login = $this->request->getPost("login"); * $password = $this->request->getPost("password"); * @@ -17,9 +31,9 @@ * // The password is valid * } * } - * ``` + *``` */ -class Security implements \Phalcon\Di\InjectionAwareInterface +class Security extends AbstractInjectionAware { const CRYPT_DEFAULT = 0; @@ -52,9 +66,6 @@ class Security implements \Phalcon\Di\InjectionAwareInterface const CRYPT_STD_DES = 1; - protected $container; - - protected $defaultHash; @@ -82,6 +93,12 @@ class Security implements \Phalcon\Di\InjectionAwareInterface protected $workFactor = 8; + private $localSession = null; + + + private $localRequest = null; + + /** * @param mixed $workFactor */ @@ -92,8 +109,11 @@ public function getWorkFactor() {} /** * Phalcon\Security constructor + * + * @param \Phalcon\Session\ManagerInterface $session + * @param \Phalcon\Http\RequestInterface $request */ - public function __construct() {} + public function __construct(\Phalcon\Session\ManagerInterface $session = null, \Phalcon\Http\RequestInterface $request = null) {} /** * Checks a plain text password and its hash version to check if the @@ -142,13 +162,6 @@ public function destroyToken(): Security {} */ public function getDefaultHash(): ?int {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns a secure random number generator instance * @@ -167,16 +180,16 @@ public function getRandomBytes(): string {} /** * Returns the value of the CSRF token for the current request. * - * @return string + * @return string|null */ - public function getRequestToken(): string {} + public function getRequestToken(): ?string {} /** * Returns the value of the CSRF token in session * - * @return string + * @return string|null */ - public function getSessionToken(): string {} + public function getSessionToken(): ?string {} /** * Generate a >22-length pseudo random string to be used as salt for @@ -228,13 +241,6 @@ public function isLegacyHash(string $passwordHash): bool {} */ public function setDefaultHash(int $defaultHash): Security {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets a number of bytes to be generated by the openssl pseudo random * generator @@ -244,4 +250,14 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} */ public function setRandomBytes(int $randomBytes): Security {} + /** + * @return null|\Phalcon\Http\RequestInterface + */ + private function getLocalRequest(): ?RequestInterface {} + + /** + * @return null|\Phalcon\Session\ManagerInterface + */ + private function getLocalSession(): ?SessionInterface {} + } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 75c84096..6afc26e8 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\DiInterface; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Url\UrlInterface; + /** * Phalcon\Tag is designed to simplify building of HTML tags. * It provides a set of helpers to generate HTML in a dynamic way. @@ -46,7 +59,7 @@ class Tag static protected $autoEscape = true; /** - * Framework Dispatcher + * DI Container */ static protected $container; @@ -56,9 +69,6 @@ class Tag static protected $displayValues; - static protected $dispatcherService = null; - - static protected $documentAppendTitle = null; @@ -92,21 +102,7 @@ public static function appendTitle($title) {} /** * Builds a HTML input[type="check"] tag * - * ```php - * echo Phalcon\Tag::checkField( - * [ - * "terms", - * "value" => "Y", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ check_field("terms") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function checkField($parameters): string {} @@ -114,7 +110,7 @@ public static function checkField($parameters): string {} /** * Builds a HTML input[type="color"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function colorField($parameters): string {} @@ -122,16 +118,7 @@ public static function colorField($parameters): string {} /** * Builds a HTML input[type="date"] tag * - * ```php - * echo Phalcon\Tag::dateField( - * [ - * "born", - * "value" => "14-12-1980", - * ] - * ); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function dateField($parameters): string {} @@ -139,7 +126,7 @@ public static function dateField($parameters): string {} /** * Builds a HTML input[type="datetime"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function dateTimeField($parameters): string {} @@ -147,7 +134,7 @@ public static function dateTimeField($parameters): string {} /** * Builds a HTML input[type="datetime-local"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function dateTimeLocalField($parameters): string {} @@ -156,18 +143,14 @@ public static function dateTimeLocalField($parameters): string {} * Alias of Phalcon\Tag::setDefault() * * @param string $id - * @param string $value + * @param mixed $value */ public static function displayTo(string $id, $value) {} /** * Builds a HTML input[type="email"] tag * - * ```php - * echo Phalcon\Tag::emailField("email"); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function emailField($parameters): string {} @@ -182,11 +165,7 @@ public static function endForm(): string {} /** * Builds a HTML input[type="file"] tag * - * ```php - * echo Phalcon\Tag::fileField("file"); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function fileField($parameters): string {} @@ -194,24 +173,7 @@ public static function fileField($parameters): string {} /** * Builds a HTML FORM tag * - * ```php - * echo Phalcon\Tag::form("posts/save"); - * - * echo Phalcon\Tag::form( - * [ - * "posts/save", - * "method" => "post", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ form("posts/save") }} - * {{ form("posts/save", "method": "post") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function form($parameters): string {} @@ -219,10 +181,6 @@ public static function form($parameters): string {} /** * Converts texts into URL-friendly titles * - * ```php - * echo Phalcon\Tag::friendlyTitle("These are big important news", "-") - * ``` - * * @param string $text * @param string $separator * @param bool $lowercase @@ -261,23 +219,7 @@ public static function getDI(): DiInterface {} public static function getEscaperService(): EscaperInterface {} /** - * Gets the current document title. - * The title will be automatically escaped. - * - * ```php - * Tag::prependTitle('Hello'); - * Tag::setTitle('World'); - * Tag::appendTitle('from Phalcon'); - * - * echo Tag::getTitle(); // Hello World from Phalcon - * echo Tag::getTitle(false); // World from Phalcon - * echo Tag::getTitle(true, false); // Hello World - * echo Tag::getTitle(false, false); // World - * ``` - * - * ```php - * {{ get_title() }} - * ``` + * Gets the current document title. The title will be automatically escaped. * * @param bool $prepend * @param bool $append @@ -288,14 +230,6 @@ public static function getTitle(bool $prepend = true, bool $append = true): stri /** * Gets the current document title separator * - * ```php - * echo Phalcon\Tag::getTitleSeparator(); - * ``` - * - * ```php - * {{ get_title_separator() }} - * ``` - * * @return string */ public static function getTitleSeparator(): string {} @@ -311,9 +245,8 @@ public static function getUrlService(): UrlInterface {} * Every helper calls this function to check whether a component has a * predefined value using Phalcon\Tag::setDefault() or value from $_POST * - * @param string $name + * @param mixed $name * @param array $params - * @return mixed */ public static function getValue($name, array $params = array()) {} @@ -321,7 +254,7 @@ public static function getValue($name, array $params = array()) {} * Check if a helper has a default value set using Phalcon\Tag::setDefault() * or value from $_POST * - * @param string $name + * @param mixed $name * @return bool */ public static function hasValue($name): bool {} @@ -329,16 +262,7 @@ public static function hasValue($name): bool {} /** * Builds a HTML input[type="hidden"] tag * - * ```php - * echo Phalcon\Tag::hiddenField( - * [ - * "name", - * "value" => "mike", - * ] - * ); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function hiddenField($parameters): string {} @@ -346,25 +270,7 @@ public static function hiddenField($parameters): string {} /** * Builds HTML IMG tags * - * ```php - * echo Phalcon\Tag::image("img/bg.png"); - * - * echo Phalcon\Tag::image( - * [ - * "img/photo.jpg", - * "alt" => "Some Photo", - * ] - * ); - * ``` - * - * Volt Syntax: - * ```php - * {{ image("img/bg.png") }} - * {{ image("img/photo.jpg", "alt": "Some Photo") }} - * {{ image("http://static.mywebsite.com/img/bg.png", false) }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @param bool $local * @return string */ @@ -373,20 +279,7 @@ public static function image($parameters = null, bool $local = true): string {} /** * Builds a HTML input[type="image"] tag * - * ```php - * echo Phalcon\Tag::imageInput( - * [ - * "src" => "/img/button.png", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ image_input("src": "/img/button.png") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function imageInput($parameters): string {} @@ -394,22 +287,7 @@ public static function imageInput($parameters): string {} /** * Builds a SCRIPT[type="javascript"] tag * - * ```php - * echo Phalcon\Tag::javascriptInclude( - * "http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", - * false - * ); - * - * echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); - * ``` - * - * Volt syntax: - * ```php - * {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js", false) }} - * {{ javascript_include("javascript/jquery.js") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @param bool $local * @return string */ @@ -418,56 +296,9 @@ public static function javascriptInclude($parameters = null, bool $local = true) /** * Builds a HTML A tag using framework conventions * - * ```php - * echo Phalcon\Tag::linkTo("signup/register", "Register Here!"); - * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!" - * ] - * ); - * - * echo Phalcon\Tag::linkTo( - * [ - * "signup/register", - * "Register Here!", - * "class" => "btn-primary", - * ] - * ); - * - * echo Phalcon\Tag::linkTo("http://phalconphp.com/", "Phalcon", false); - * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * false, - * ] - * ); - * - * echo Phalcon\Tag::linkTo( - * [ - * "http://phalconphp.com/", - * "Phalcon Home", - * "local" => false, - * ] - * ); - * - * echo Phalcon\Tag::linkTo( - * [ - * "action" => "http://phalconphp.com/", - * "text" => "Phalcon Home", - * "local" => false, - * "target" => "_new" - * ] - * ); - * - * ``` - * - * @param array|string $parameters - * @param string $text - * @param bool $local + * @param mixed $parameters + * @param mixed $text + * @param mixed $local * @return string */ public static function linkTo($parameters, $text = null, $local = true): string {} @@ -475,7 +306,7 @@ public static function linkTo($parameters, $text = null, $local = true): string /** * Builds a HTML input[type="month"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function monthField($parameters): string {} @@ -483,17 +314,7 @@ public static function monthField($parameters): string {} /** * Builds a HTML input[type="number"] tag * - * ```php - * echo Phalcon\Tag::numericField( - * [ - * "price", - * "min" => "1", - * "max" => "5", - * ] - * ); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function numericField($parameters): string {} @@ -501,16 +322,7 @@ public static function numericField($parameters): string {} /** * Builds a HTML input[type="password"] tag * - * ```php - * echo Phalcon\Tag::passwordField( - * [ - * "name", - * "size" => 30, - * ] - * ); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function passwordField($parameters): string {} @@ -525,21 +337,7 @@ public static function prependTitle($title) {} /** * Builds a HTML input[type="radio"] tag * - * ```php - * echo Phalcon\Tag::radioField( - * [ - * "weather", - * "value" => "hot", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ radio_field("Save") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function radioField($parameters): string {} @@ -547,7 +345,7 @@ public static function radioField($parameters): string {} /** * Builds a HTML input[type="range"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function rangeField($parameters): string {} @@ -564,21 +362,6 @@ public static function renderAttributes(string $code, array $attributes): string /** * Renders the title with title tags. The title is automaticall escaped * - * ```php - * Tag::prependTitle('Hello'); - * Tag::setTitle('World'); - * Tag::appendTitle('from Phalcon'); - * - * echo Tag::renderTitle(); // Hello World from Phalcon - * echo Tag::renderTitle(false); // World from Phalcon - * echo Tag::renderTitle(true, false); // Hello World - * echo Tag::renderTitle(false, false); // World - * ``` - * - * ```php - * {{ render_title() }} - * ``` - * * @param bool $prepend * @param bool $append * @return string @@ -597,7 +380,7 @@ public static function resetInput() {} /** * Builds a HTML input[type="search"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function searchField($parameters): string {} @@ -605,23 +388,8 @@ public static function searchField($parameters): string {} /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * - * ```php - * echo Phalcon\Tag::select( - * [ - * "robotId", - * Robots::find("type = "mechanical""), - * "using" => ["id", "name"], - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ select("robotId", robots, "using": ["id", "name"]) }} - * ``` - * - * @param array $parameters - * @param array $data + * @param mixed $parameters + * @param mixed $data * @return string */ public static function select($parameters, $data = null): string {} @@ -629,18 +397,8 @@ public static function select($parameters, $data = null): string {} /** * Builds a HTML SELECT tag using a PHP array for options * - * ```php - * echo Phalcon\Tag::selectStatic( - * "status", - * [ - * "A" => "Active", - * "I" => "Inactive", - * ] - * ); - * ``` - * - * @param array $parameters - * @param array $data + * @param mixed $parameters + * @param mixed $data * @return string */ public static function selectStatic($parameters, $data = null): string {} @@ -655,34 +413,14 @@ public static function setAutoescape(bool $autoescape) {} /** * Assigns default values to generated tags by helpers * - * ```php - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefault("name", "peter"); - * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * ``` - * * @param string $id - * @param string $value + * @param mixed $value */ public static function setDefault(string $id, $value) {} /** * Assigns default values to generated tags by helpers * - * ```php - * // Assigning "peter" to "name" component - * Phalcon\Tag::setDefaults( - * [ - * "name" => "peter", - * ] - * ); - * - * // Later in the view - * echo Phalcon\Tag::textField("name"); // Will have the value "peter" by default - * ``` - * * @param array $values * @param bool $merge */ @@ -705,10 +443,6 @@ public static function setDocType(int $doctype) {} /** * Set the title of view content * - * ```php - * Phalcon\Tag::setTitle("Welcome to my Page"); - * ``` - * * @param string $title */ public static function setTitle(string $title) {} @@ -716,10 +450,6 @@ public static function setTitle(string $title) {} /** * Set the title separator of view content * - * ```php - * Phalcon\Tag::setTitleSeparator("-"); - * ``` - * * @param string $titleSeparator */ public static function setTitleSeparator(string $titleSeparator) {} @@ -727,22 +457,7 @@ public static function setTitleSeparator(string $titleSeparator) {} /** * Builds a LINK[rel="stylesheet"] tag * - * ```php - * echo Phalcon\Tag::stylesheetLink( - * "http://fonts.googleapis.com/css?family=Rosario", - * false - * ); - * - * echo Phalcon\Tag::stylesheetLink("css/style.css"); - * ``` - * - * Volt Syntax: - * ```php - * {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }} - * {{ stylesheet_link("css/style.css") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @param bool $local * @return string */ @@ -751,16 +466,7 @@ public static function stylesheetLink($parameters = null, bool $local = true): s /** * Builds a HTML input[type="submit"] tag * - * ```php - * echo Phalcon\Tag::submitButton("Save") - * ``` - * - * Volt syntax: - * ```php - * {{ submit_button("Save") }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function submitButton($parameters): string {} @@ -780,10 +486,6 @@ public static function tagHtml(string $tagName, $parameters = null, bool $selfCl /** * Builds a HTML tag closing tag * - * ```php - * echo Phalcon\Tag::tagHtmlClose("script", true); - * ``` - * * @param string $tagName * @param bool $useEol * @return string @@ -793,7 +495,7 @@ public static function tagHtmlClose(string $tagName, bool $useEol = false): stri /** * Builds a HTML input[type="tel"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function telField($parameters): string {} @@ -801,22 +503,7 @@ public static function telField($parameters): string {} /** * Builds a HTML TEXTAREA tag * - * ```php - * echo Phalcon\Tag::textArea( - * [ - * "comments", - * "cols" => 10, - * "rows" => 4, - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {{ text_area("comments", "cols": 10, "rows": 4) }} - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function textArea($parameters): string {} @@ -824,16 +511,7 @@ public static function textArea($parameters): string {} /** * Builds a HTML input[type="text"] tag * - * ```php - * echo Phalcon\Tag::textField( - * [ - * "name", - * "size" => 30, - * ] - * ); - * ``` - * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function textField($parameters): string {} @@ -841,7 +519,7 @@ public static function textField($parameters): string {} /** * Builds a HTML input[type="time"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function timeField($parameters): string {} @@ -849,7 +527,7 @@ public static function timeField($parameters): string {} /** * Builds a HTML input[type="url"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function urlField($parameters): string {} @@ -857,7 +535,7 @@ public static function urlField($parameters): string {} /** * Builds a HTML input[type="week"] tag * - * @param array $parameters + * @param mixed $parameters * @return string */ public static function weekField($parameters): string {} @@ -866,7 +544,7 @@ public static function weekField($parameters): string {} * Builds generic INPUT tags * * @param string $type - * @param array $parameters + * @param mixed $parameters * @param bool $asValue * @return string */ @@ -876,7 +554,7 @@ static final protected function inputField(string $type, $parameters, bool $asVa * Builds INPUT tags that implements the checked attribute * * @param string $type - * @param array $parameters + * @param mixed $parameters * @return string */ static final protected function inputFieldChecked(string $type, $parameters): string {} diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 14589c93..0d58385c 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; /** diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index de030017..d760b5a6 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -1,11 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Mvc\RouterInterface; +use Phalcon\Url\UrlInterface; + /** * This components helps in the generation of: URIs, URLs and Paths * - * ```php + *```php * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * @@ -17,9 +30,9 @@ * "year" => "2012", * ] * ); - * ``` + *``` */ -class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterface +class Url extends AbstractInjectionAware implements UrlInterface { /** * @var null | string @@ -32,12 +45,9 @@ class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterf protected $basePath = null; /** - * @var + * @var | null */ - protected $container; - - - protected $router; + protected $router = null; /** * @var null | string @@ -45,6 +55,11 @@ class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterf protected $staticBaseUri = null; + /** + * @param \Phalcon\Mvc\RouterInterface $router + */ + public function __construct(\Phalcon\Mvc\RouterInterface $router = null) {} + /** * Generates a URL * @@ -72,7 +87,7 @@ class Url implements \Phalcon\Url\UrlInterface, \Phalcon\Di\InjectionAwareInterf * * // Generate an absolute URL by setting the third parameter as false. * echo $url->get( - * "https://phalconphp.com/", + * "https://phalcon.io/", * null, * false * ); @@ -100,13 +115,6 @@ public function getBasePath(): string {} */ public function getBaseUri(): string {} - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Generates a URL for a static resource * @@ -160,13 +168,6 @@ public function setBasePath(string $basePath): UrlInterface {} */ public function setBaseUri(string $baseUri): UrlInterface {} - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets a prefix for all static URLs generated * diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index 776e83b7..f5cc53ec 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -1,11 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; +use Phalcon\Di\Injectable; +use Phalcon\Messages\Messages; +use Phalcon\Validation\ValidationInterface; + /** * Allows to validate data using custom or built-in validators */ -class Validation extends \Phalcon\Di\Injectable implements \Phalcon\Validation\ValidationInterface +class Validation extends Injectable implements ValidationInterface { protected $combinedFieldsValidators; @@ -87,7 +100,7 @@ public function getEntity() {} * @param string $field * @return mixed|null */ - public function getFilters(string $field = null): ? {} + public function getFilters(string $field = null) {} /** * Get label for field @@ -117,7 +130,7 @@ public function getValidators(): array {} * @param string $field * @return mixed|null */ - public function getValue(string $field): ? {} + public function getValue(string $field) {} /** * Alias of `add` method diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 3cded390..2094ca57 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon; /** diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 4928abdd..dd062ed4 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** * This class defines component entity and its description */ -class Component implements \Phalcon\Acl\ComponentInterface +class Component implements ComponentInterface { /** * Component description diff --git a/src/Phalcon/acl/ComponentAware.php b/src/Phalcon/acl/ComponentAware.php index 3539eb59..894576a3 100644 --- a/src/Phalcon/acl/ComponentAware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php index b1e0960c..de39056f 100644 --- a/src/Phalcon/acl/ComponentInterface.php +++ b/src/Phalcon/acl/ComponentInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/Enum.php b/src/Phalcon/acl/Enum.php index bce07c38..849ad26d 100644 --- a/src/Phalcon/acl/Enum.php +++ b/src/Phalcon/acl/Enum.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/Exception.php b/src/Phalcon/acl/Exception.php index f65dd278..38139709 100644 --- a/src/Phalcon/acl/Exception.php +++ b/src/Phalcon/acl/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/acl/Role.php index 7cee9dd9..bc6c0193 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/acl/Role.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** * This class defines role entity and its description */ -class Role implements \Phalcon\Acl\RoleInterface +class Role implements RoleInterface { /** * Role name diff --git a/src/Phalcon/acl/RoleAware.php b/src/Phalcon/acl/RoleAware.php index 8a22a4b6..9ebd5166 100644 --- a/src/Phalcon/acl/RoleAware.php +++ b/src/Phalcon/acl/RoleAware.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/RoleInterface.php b/src/Phalcon/acl/RoleInterface.php index 7ba84c4a..d8dab9cb 100644 --- a/src/Phalcon/acl/RoleInterface.php +++ b/src/Phalcon/acl/RoleInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/adapter/AbstractAdapter.php index 70df5795..ac4780e4 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/adapter/AbstractAdapter.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl\Adapter; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Active access which the list is checking if some role can access it diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/acl/adapter/AdapterInterface.php index 15041916..a90688a0 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/acl/adapter/AdapterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl\Adapter; /** diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/acl/adapter/Memory.php index 7b125edc..4610366d 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/acl/adapter/Memory.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Acl\Adapter; +use Phalcon\Acl\Enum; + /** * Manages ACL lists in memory * - * ```php + *```php * $acl = new \Phalcon\Acl\Adapter\Memory(); * * $acl->setDefaultAction( @@ -53,7 +64,7 @@ * // Grant access to public areas to both users and guests * foreach ($roles as $role) { * foreach ($publicComponents as $component => $actions) { - * $acl->allow($role->getName(), $component, ""); + * $acl->allow($role->getName(), $component, "*"); * } * } * @@ -63,9 +74,9 @@ * $acl->allow("Users", $component, $action); * } * } - * ``` + *``` */ -class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * Access diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index 09c42994..fc75870b 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; /** diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php index 474b8c63..51fdb14c 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; +use Phalcon\Annotations\Adapter\AbstractAdapter; +use Phalcon\Factory\AbstractFactory; + /** * Factory to create annotations components */ -class AnnotationsFactory extends \Phalcon\Factory\AbstractFactory +class AnnotationsFactory extends AbstractFactory { /** diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/annotations/Collection.php index a8508263..d190e9b8 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/annotations/Collection.php @@ -1,12 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; +use Countable; +use Iterator; + /** * Represents a collection of annotations. This class allows to traverse a group * of annotations easily * - * ```php + *```php * // Traverse annotations * foreach ($classAnnotations as $annotation) { * echo "Name=", $annotation->getName(), PHP_EOL; @@ -17,9 +29,9 @@ * * // Get an specific annotation in the collection * $annotation = $classAnnotations->get("Cacheable"); - * ``` + *``` */ -class Collection implements \Iterator, \Countable +class Collection implements Iterator, Countable { /** * @var array diff --git a/src/Phalcon/annotations/Exception.php b/src/Phalcon/annotations/Exception.php index 8864d544..afb1fb02 100644 --- a/src/Phalcon/annotations/Exception.php +++ b/src/Phalcon/annotations/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; /** diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index fdc95680..250728f3 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; /** * Parses docblocks returning an array with the found annotations */ -class Reader implements \Phalcon\Annotations\ReaderInterface +class Reader implements ReaderInterface { /** diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index 5ba4b965..dea5b646 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; /** diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index 97072543..1359147c 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations; /** * Allows to manipulate the annotations reflection in an OO manner * - * ```php + *```php * use Phalcon\Annotations\Reader; * use Phalcon\Annotations\Reflection; * @@ -18,7 +27,7 @@ * * // Get the annotations in the class docblock * $classAnnotations = $reflection->getClassAnnotations(); - * ``` + *``` */ class Reflection { diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php index e20924a3..ff65e600 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -1,11 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Collection; +use Phalcon\Annotations\Reader; +use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Reflection; + /** * This is the base class for Phalcon\Annotations adapters */ -abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * @var array diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/annotations/adapter/AdapterInterface.php index 30f9b6c0..69ea606c 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/annotations/adapter/AdapterInterface.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Collection; +use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Reflection; + /** * This interface must be implemented by adapters in Phalcon\Annotations */ diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index 3eedce01..f6506d26 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -1,17 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations\Adapter; /** * Stores the parsed annotations in APCu. This adapter is suitable for production * - * ```php + *```php * use Phalcon\Annotations\Adapter\Apcu; * * $annotations = new Apcu(); - * ``` + *``` */ -class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Apcu extends AbstractAdapter { /** * @var string diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index dff5586e..e60d9cfe 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -1,12 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations\Adapter; /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing */ -class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * @var mixed diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Stream.php index 1ceda655..9ff5d004 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Annotations\Adapter; /** * Stores the parsed annotations in files. This adapter is suitable for production * - * ```php + *```php * use Phalcon\Annotations\Adapter\Stream; * * $annotations = new Stream( @@ -13,9 +22,9 @@ * "annotationsDir" => "app/cache/annotations/", * ] * ); - * ``` + *``` */ -class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * @var string diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index 9c441209..3f5c57f1 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -1,11 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Application; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Base class for Phalcon\Cli\Console and Phalcon\Mvc\Application. */ -abstract class AbstractApplication extends \Phalcon\Di\Injectable implements \Phalcon\Events\EventsAwareInterface +abstract class AbstractApplication extends Injectable implements EventsAwareInterface { /** * @var DiInterface @@ -66,8 +80,11 @@ public function getModules(): array {} /** * Handles a request + * + * @param string $uri + * @return bool|ResponseInterface */ - abstract public function handle(); + abstract public function handle(string $uri); /** * Register an array of modules present in the application @@ -105,8 +122,7 @@ public function setDefaultModule(string $defaultModule): AbstractApplication {} * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return AbstractApplication */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AbstractApplication {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} } diff --git a/src/Phalcon/application/Exception.php b/src/Phalcon/application/Exception.php index 9e2d5a57..a05cd19a 100644 --- a/src/Phalcon/application/Exception.php +++ b/src/Phalcon/application/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Application; /** diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 431db7dc..2b7ae928 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -1,15 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; /** * Represents an asset asset * - * ```php + *```php * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); - * ``` + *``` */ -class Asset implements \Phalcon\Assets\AssetInterface +class Asset implements AssetInterface { /** * @var array | null diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php index c7bdf739..8bdc5b8e 100644 --- a/src/Phalcon/assets/AssetInterface.php +++ b/src/Phalcon/assets/AssetInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; /** diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/assets/Collection.php index eafae5b1..2cc2b5e2 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/assets/Collection.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; +use Countable; +use Iterator; + /** * Represents a collection of assets */ -class Collection implements \Countable, \Iterator +class Collection implements Countable, Iterator { /** * @var array diff --git a/src/Phalcon/assets/Exception.php b/src/Phalcon/assets/Exception.php index 49148351..62e2b8f5 100644 --- a/src/Phalcon/assets/Exception.php +++ b/src/Phalcon/assets/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; /** diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index e0ba66c2..5a89727d 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; /** diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index de5d3bef..e62b7484 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -1,15 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; /** * Represents an inline asset * - * ```php + *```php * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); - * ``` + *``` */ -class Inline implements \Phalcon\Assets\AssetInterface +class Inline implements AssetInterface { /** * @var array | null diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index f34300b8..7aed696d 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -1,22 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets; +use Phalcon\Di\AbstractInjectionAware; + /** * Phalcon\Assets\Manager * * Manages collections of CSS/Javascript assets */ -class Manager implements \Phalcon\Di\InjectionAwareInterface +class Manager extends AbstractInjectionAware { protected $collections; - /** - * @var DiInterface - */ - protected $container; - /** * Options configure * @@ -198,13 +204,6 @@ public function getCollections(): array {} */ public function getCss(): Collection {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the CSS collection of assets * @@ -283,13 +282,6 @@ public function outputJs(string $collectionName = null): string {} */ public function set(string $id, \Phalcon\Assets\Collection $collection): Manager {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets the manager options * diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/assets/asset/Css.php index 7f4edfc2..364dd917 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/assets/asset/Css.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Asset; +use Phalcon\Assets\Asset as AssetBase; + /** * Represents CSS assets */ -class Css extends \Phalcon\Assets\Asset +class Css extends AssetBase { /** diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/assets/asset/Js.php index ca07bfa9..c7f7fb3a 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/assets/asset/Js.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Asset; +use Phalcon\Assets\Asset as AssetBase; + /** * Represents Javascript assets */ -class Js extends \Phalcon\Assets\Asset +class Js extends AssetBase { /** diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/assets/filters/Cssmin.php index 146bb436..fdb8eec0 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/assets/filters/Cssmin.php @@ -1,12 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Minify the css - removes comments removes newlines and line feeds keeping * removes last semicolon from last property */ -class Cssmin implements \Phalcon\Assets\FilterInterface +class Cssmin implements FilterInterface { /** diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/assets/filters/Jsmin.php index e9651221..8352f0d1 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/assets/filters/Jsmin.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Deletes the characters which are insignificant to JavaScript. Comments will * be removed. Tabs will be replaced with spaces. Carriage returns will be * replaced with linefeeds. Most spaces and linefeeds will be removed. */ -class Jsmin implements \Phalcon\Assets\FilterInterface +class Jsmin implements FilterInterface { /** diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/assets/filters/None.php index e8aca1f6..f77b9d9f 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/assets/filters/None.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Returns the content without make any modification to the original source */ -class None implements \Phalcon\Assets\FilterInterface +class None implements FilterInterface { /** diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/assets/inline/Css.php index 02e7f7b7..f098cf4e 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/assets/inline/Css.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Inline; +use Phalcon\Assets\Inline as InlineBase; + /** * Represents an inlined CSS */ -class Css extends \Phalcon\Assets\Inline +class Css extends InlineBase { /** diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/assets/inline/Js.php index a464a22b..b090911b 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/assets/inline/Js.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Assets\Inline; +use Phalcon\Assets\Inline as InlineBase; + /** * Represents an inline JavaScript */ -class Js extends \Phalcon\Assets\Inline +class Js extends InlineBase { /** diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/cache/AdapterFactory.php index 9cccc760..775d859d 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/cache/AdapterFactory.php @@ -1,11 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache; +use Phalcon\Cache\Adapter\AbstractAdapter; +use Phalcon\Factory\AbstractFactory; +use Phalcon\Storage\SerializerFactory; + /** * Factory to create Cache adapters */ -class AdapterFactory extends \Phalcon\Factory\AbstractFactory +class AdapterFactory extends AbstractFactory { /** * @var SerializerFactory diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/cache/CacheFactory.php index 1f909879..dc8f016f 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/cache/CacheFactory.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache; +use Phalcon\Cache\CacheInterface; + /** * Creates a new Cache class */ diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php index 0acab0d8..284a2938 100644 --- a/src/Phalcon/cache/adapter/AdapterInterface.php +++ b/src/Phalcon/cache/adapter/AdapterInterface.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Storage\Adapter\AdapterInterface as StorageAdapterInterface; + /** * Interface for Phalcon\Cache adapters */ -interface AdapterInterface extends \Phalcon\Storage\Adapter\AdapterInterface +interface AdapterInterface extends StorageAdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Apcu.php b/src/Phalcon/cache/adapter/Apcu.php index 30224f78..cd07a9bd 100644 --- a/src/Phalcon/cache/adapter/Apcu.php +++ b/src/Phalcon/cache/adapter/Apcu.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Apcu as StorageApcu; + /** * Apcu adapter */ -class Apcu extends \Phalcon\Storage\Adapter\Apcu implements \Phalcon\Cache\Adapter\AdapterInterface +class Apcu extends StorageApcu implements CacheAdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Libmemcached.php b/src/Phalcon/cache/adapter/Libmemcached.php index 964d2fd7..588ec179 100644 --- a/src/Phalcon/cache/adapter/Libmemcached.php +++ b/src/Phalcon/cache/adapter/Libmemcached.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Libmemcached as StorageLibmemcached; + /** * Libmemcached adapter */ -class Libmemcached extends \Phalcon\Storage\Adapter\Libmemcached implements \Phalcon\Cache\Adapter\AdapterInterface +class Libmemcached extends StorageLibmemcached implements CacheAdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Memory.php b/src/Phalcon/cache/adapter/Memory.php index 9b80800e..fb642281 100644 --- a/src/Phalcon/cache/adapter/Memory.php +++ b/src/Phalcon/cache/adapter/Memory.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Memory as StorageMemory; + /** * Memory adapter */ -class Memory extends \Phalcon\Storage\Adapter\Memory implements \Phalcon\Cache\Adapter\AdapterInterface +class Memory extends StorageMemory implements CacheAdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Redis.php b/src/Phalcon/cache/adapter/Redis.php index ec116325..6ed01117 100644 --- a/src/Phalcon/cache/adapter/Redis.php +++ b/src/Phalcon/cache/adapter/Redis.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Redis as StorageRedis; + /** * Redis adapter */ -class Redis extends \Phalcon\Storage\Adapter\Redis implements \Phalcon\Cache\Adapter\AdapterInterface +class Redis extends StorageRedis implements CacheAdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Stream.php b/src/Phalcon/cache/adapter/Stream.php index 23c3c1e3..eb4f7865 100644 --- a/src/Phalcon/cache/adapter/Stream.php +++ b/src/Phalcon/cache/adapter/Stream.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Adapter; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Stream as StorageStream; + /** * Stream adapter */ -class Stream extends \Phalcon\Storage\Adapter\Stream implements \Phalcon\Cache\Adapter\AdapterInterface +class Stream extends StorageStream implements CacheAdapterInterface { } diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php index b97a13d8..b9fec03b 100644 --- a/src/Phalcon/cache/exception/Exception.php +++ b/src/Phalcon/cache/exception/Exception.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Exception; /** * Exceptions thrown in Phalcon\Cache will use this class */ -class Exception extends \Exception implements \Psr\SimpleCache\CacheException +class Exception extends \Phalcon\Exception implements \Psr\SimpleCache\CacheException { } diff --git a/src/Phalcon/cache/exception/InvalidArgumentException.php b/src/Phalcon/cache/exception/InvalidArgumentException.php index 6d1c6a22..819fcbea 100644 --- a/src/Phalcon/cache/exception/InvalidArgumentException.php +++ b/src/Phalcon/cache/exception/InvalidArgumentException.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cache\Exception; /** * Exceptions thrown in Phalcon\Cache will use this class */ -class InvalidArgumentException extends \Exception implements \Psr\SimpleCache\InvalidArgumentException +class InvalidArgumentException extends \Phalcon\Exception implements \Psr\SimpleCache\InvalidArgumentException { } diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 2da7a60c..3c6609eb 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Application\AbstractApplication; + /** * This component allows to create CLI applications using Phalcon */ -class Console extends \Phalcon\Application\AbstractApplication +class Console extends AbstractApplication { /** * @var array @@ -21,9 +32,10 @@ class Console extends \Phalcon\Application\AbstractApplication /** * Handle the whole command-line tasks * - * @param array $arguments + * @param string $arguments + * @return bool|ResponseInterface */ - public function handle(array $arguments = null) {} + public function handle(string $arguments) {} /** * Set an specific argument diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index 3771ce22..bcc4cb7c 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Dispatcher\AbstractDispatcher as CliDispatcher; + /** * Dispatching is the process of taking the command-line arguments, extracting * the module name, task name, action name, and optional parameters contained in @@ -24,7 +35,7 @@ * $handle = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends CliDispatcher implements DispatcherInterface { /** * @var string diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index eed77c38..f35d5155 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; + /** * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends DispatcherInterfaceBase { /** diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 541e64b1..81d6dde5 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Di\AbstractInjectionAware; + /** * Phalcon\Cli\Router is the standard framework router. Routing is the process * of taking a command-line arguments and decomposing it into parameters to * determine which module, task, and action of that task should receive the * request. * - * ```php + *```php * $router = new \Phalcon\Cli\Router(); * * $router->handle( @@ -20,17 +31,14 @@ * ); * * echo $router->getTaskName(); - * ``` + *``` */ -class Router implements \Phalcon\Di\InjectionAwareInterface +class Router extends AbstractInjectionAware { protected $action; - protected $container; - - protected $defaultAction = null; @@ -95,13 +103,6 @@ public function add(string $pattern, $paths = null): RouteInterface {} */ public function getActionName(): string {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the route that matches the handled URI * @@ -207,13 +208,6 @@ public function setDefaults(array $defaults): Router {} */ public function setDefaultTask(string $taskName) {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Checks if the router matches any of the defined routes * diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 7f3d4abe..1bde6647 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Cli\Router\RouteInterface; + /** * Interface for Phalcon\Cli\Router */ diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 41ba3342..9db77a0d 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; +use Phalcon\Di\Injectable; + /** * Every command-line task should extend this class that encapsulates all the * task functionality @@ -10,7 +21,7 @@ * or anything that you want. The Task class should at least have a "mainAction" * method. * - * ```php + *```php * class HelloTask extends \Phalcon\Cli\Task * { * // This action will be executed by default @@ -24,9 +35,9 @@ * * } * } - * ``` + *``` */ -class Task extends \Phalcon\Di\Injectable implements \Phalcon\Cli\TaskInterface +class Task extends Injectable implements TaskInterface { /** diff --git a/src/Phalcon/cli/TaskInterface.php b/src/Phalcon/cli/TaskInterface.php index 9ceb7d69..ae2bee57 100644 --- a/src/Phalcon/cli/TaskInterface.php +++ b/src/Phalcon/cli/TaskInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli; /** diff --git a/src/Phalcon/cli/console/Exception.php b/src/Phalcon/cli/console/Exception.php index 09649fa2..7045b747 100644 --- a/src/Phalcon/cli/console/Exception.php +++ b/src/Phalcon/cli/console/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli\Console; /** diff --git a/src/Phalcon/cli/dispatcher/Exception.php b/src/Phalcon/cli/dispatcher/Exception.php index d03f5450..689dde96 100644 --- a/src/Phalcon/cli/dispatcher/Exception.php +++ b/src/Phalcon/cli/dispatcher/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli\Dispatcher; /** diff --git a/src/Phalcon/cli/router/Exception.php b/src/Phalcon/cli/router/Exception.php index 06f5a678..ae874ebb 100644 --- a/src/Phalcon/cli/router/Exception.php +++ b/src/Phalcon/cli/router/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli\Router; /** diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 5e0e0997..05e1c670 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli\Router; /** diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index d5cff844..0724e5cc 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Cli\Router; /** diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php index 95493ef5..3aca3660 100644 --- a/src/Phalcon/collection/Exception.php +++ b/src/Phalcon/collection/Exception.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Collection; +use Throwable; + /** * Exceptions for the Collection object */ -class Exception extends \Exception implements \Throwable +class Exception extends \Phalcon\Exception implements Throwable { } diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/collection/ReadOnly.php index 3d145a09..e42ed93c 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/collection/ReadOnly.php @@ -1,11 +1,22 @@ +* +* For the full copyright and license information, please view the LICENSE.txt +* file that was distributed with this source code. +*/ + namespace Phalcon\Collection; +use Phalcon\Collection; + /** * Phalcon\Collection\ReadOnly is a read only Collection object */ -class ReadOnly extends \Phalcon\Collection +class ReadOnly extends Collection { /** diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/config/ConfigFactory.php index 43b73cef..c59d8331 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/config/ConfigFactory.php @@ -1,12 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config; +use Phalcon\Factory\AbstractFactory; + /** * Loads Config Adapter class using 'adapter' option, if no extension is * provided it will be added to filePath * - * ```php + *```php * use Phalcon\Config\ConfigFactory; * * $options = [ @@ -15,9 +26,9 @@ * ]; * * $config = (new ConfigFactory())->load($options); - * ``` + *``` */ -class ConfigFactory extends \Phalcon\Factory\AbstractFactory +class ConfigFactory extends AbstractFactory { /** diff --git a/src/Phalcon/config/Exception.php b/src/Phalcon/config/Exception.php index 80954ccc..9d36d0e9 100644 --- a/src/Phalcon/config/Exception.php +++ b/src/Phalcon/config/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config; /** diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 5de00ac0..57eafe0e 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config\Adapter; +use Phalcon\Config; + /** * Reads multiple files (or arrays) and merges them all together. * @@ -53,7 +64,7 @@ * ); * ``` */ -class Grouped extends \Phalcon\Config +class Grouped extends Config { /** diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index d2679230..6dfedb88 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config\Adapter; +use Phalcon\Config; + /** * Reads ini files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * ```ini + *```ini * [database] * adapter = Mysql * host = localhost @@ -23,14 +34,14 @@ * * You can read it as follows: * - * ```php + *```php * use Phalcon\Config\Adapter\Ini; * * $config = new Ini("path/config.ini"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * ``` + *``` * * PHP constants may also be parsed in the ini file, so if you define a constant * as an ini value before calling the constructor, the constant's value will be @@ -44,7 +55,7 @@ * ); * ``` */ -class Ini extends \Phalcon\Config +class Ini extends Config { /** diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 6f20d09f..10ae69f4 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -1,28 +1,39 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config\Adapter; +use Phalcon\Config; + /** * Reads JSON files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * ```json + *```json * {"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"}} - * ``` + *``` * * You can read it as follows: * - * ```php + *```php * use Phalcon\Config\Adapter\Json; * * $config = new Json("path/config.json"); * * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * ``` + *``` */ -class Json extends \Phalcon\Config +class Json extends Config { /** diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index cea8c07c..478eabf6 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config\Adapter; +use Phalcon\Config; + /** * Reads php files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - * ```php + *```php * "../app/views/", * ], * ]; - * ``` + *``` * * You can read it as follows: * - * ```php + *```php * use Phalcon\Config\Adapter\Php; * * $config = new Php("path/config.php"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - * ``` + *``` */ -class Php extends \Phalcon\Config +class Php extends Config { /** diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index b0d7dc11..f45afc10 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -1,23 +1,34 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Config\Adapter; +use Phalcon\Config; + /** * Reads YAML files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - * ```yaml + *```yaml * phalcon: * baseuri: /phalcon/ * controllersDir: !approot /app/controllers/ * models: * metadata: memory - * ``` + *``` * * You can read it as follows: * - * ```php + *```php * define( * "APPROOT", * dirname(__DIR__) @@ -37,9 +48,9 @@ * echo $config->phalcon->controllersDir; * echo $config->phalcon->baseuri; * echo $config->models->metadata; - * ``` + *``` */ -class Yaml extends \Phalcon\Config +class Yaml extends Config { /** diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php index 2758e631..4432b1cc 100644 --- a/src/Phalcon/crypt/CryptInterface.php +++ b/src/Phalcon/crypt/CryptInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Crypt; /** diff --git a/src/Phalcon/crypt/Exception.php b/src/Phalcon/crypt/Exception.php index 3331c991..292e32b6 100644 --- a/src/Phalcon/crypt/Exception.php +++ b/src/Phalcon/crypt/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Crypt; /** diff --git a/src/Phalcon/crypt/Mismatch.php b/src/Phalcon/crypt/Mismatch.php index 3b3f731b..a92c9bc8 100644 --- a/src/Phalcon/crypt/Mismatch.php +++ b/src/Phalcon/crypt/Mismatch.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Crypt; /** * Exceptions thrown in Phalcon\Crypt will use this class. */ -class Mismatch extends \Phalcon\Crypt\Exception +class Mismatch extends Exception { } diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/db/AbstractDb.php index 991a95aa..6a7e8374 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/db/AbstractDb.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** @@ -15,7 +24,7 @@ * Phalcon\Db\AbstractDb is an abstract class. You only can use it with a * database adapter like Phalcon\Db\Adapter\Pdo * - * ```php + *```php * use Phalcon\Db; * use Phalcon\Db\Exception; * use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; @@ -32,7 +41,7 @@ * ); * * $result = $connection->query( - * "SELECT FROM robots LIMIT 5" + * "SELECT * FROM robots LIMIT 5" * ); * * $result->setFetchMode(Enum::FETCH_NUM); diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 30f71f34..45430218 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** * Allows to define columns to be used on create or alter table operations * - * ```php + *```php * use Phalcon\Db\Column as Column; * * // Column definition @@ -23,9 +32,9 @@ * * // Add column to existing table * $connection->addColumn("robots", null, $column); - * ``` + *``` */ -class Column implements \Phalcon\Db\ColumnInterface +class Column implements ColumnInterface { /** * Bind Type Blob diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index 2fc8226d..30928fbc 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index f72935c0..6a4ddae6 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -1,12 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ -abstract class Dialect implements \Phalcon\Db\DialectInterface +abstract class Dialect implements DialectInterface { protected $escapeChar; diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 0e8e587d..72b4cbc2 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php index 3049c8f7..9174f5e3 100644 --- a/src/Phalcon/db/Enum.php +++ b/src/Phalcon/db/Enum.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Exception.php b/src/Phalcon/db/Exception.php index 0f815657..81791270 100644 --- a/src/Phalcon/db/Exception.php +++ b/src/Phalcon/db/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Index.php b/src/Phalcon/db/Index.php index e3499292..acdb4042 100644 --- a/src/Phalcon/db/Index.php +++ b/src/Phalcon/db/Index.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** @@ -7,7 +16,7 @@ * to enhance database performance. An index allows the database server to find * and retrieve specific rows much faster than it could do without an index * - * ```php + *```php * // Define new unique index * $index_unique = new \Phalcon\Db\Index( * 'column_UNIQUE', @@ -29,9 +38,9 @@ * // Add index to existing table * $connection->addIndex("robots", null, $index_unique); * $connection->addIndex("robots", null, $index_primary); - * ``` + *``` */ -class Index implements \Phalcon\Db\IndexInterface +class Index implements IndexInterface { /** * Index columns diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index 036ed333..ba45ccae 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index c0e49136..fbe3ea40 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; +use Phalcon\Db\Profiler\Item; + /** * Instances of Phalcon\Db can generate execution profiles * on SQL statements sent to the relational database. Profiled @@ -36,6 +47,7 @@ * // Set the event manager on the connection * $connection->setEventsManager($eventsManager); * + * * $sql = "SELECT buyer_name, quantity, product_name * FROM buyers LEFT JOIN products ON * buyers.pid=products.id"; diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index e4f65201..b4040d2e 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** @@ -7,14 +16,14 @@ * * The next example shows how to use the MySQL now() function as a field value. * - * ```php + *```php * $subscriber = new Subscribers(); * - * $subscriber->email = "andres@phalconphp.com"; + * $subscriber->email = "andres@phalcon.io"; * $subscriber->createdAt = new \Phalcon\Db\RawValue("now()"); * * $subscriber->save(); - * ``` + *``` */ class RawValue { diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index 43eb5a35..f2d4cdcf 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** * Allows to define reference constraints on tables * - * ```php + *```php * $reference = new \Phalcon\Db\Reference( * "field_fk", * [ @@ -21,9 +30,9 @@ * ], * ] * ); - * ``` + *``` */ -class Reference implements \Phalcon\Db\ReferenceInterface +class Reference implements ReferenceInterface { /** * Local reference columns diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 738157ac..fbc00dbb 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index a6baa4b2..ca9cdade 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index d5a4c210..97c683de 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -1,11 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\RawValue; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Base class for Phalcon\Db adapters */ -abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Connection ID diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index 97744ae5..ee898e6f 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\RawValue; + /** * Interface for Phalcon\Db adapters */ diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php index 1d71f837..0d70c5ce 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class PdoFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Db\Adapter; + +use Phalcon\Factory\AbstractFactory; + +class PdoFactory extends AbstractFactory { /** @@ -33,7 +36,7 @@ public function load($config) {} * * @param string $name * @param array $options - * @return \Phalcon\Annotations\Adapter\AbstractAdapter + * @return \Phalcon\Db\Adapter\AbstractAdapter */ public function newInstance(string $name, array $options = array()): AbstractAdapter {} diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php index 80be64a0..77b7a617 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\AbstractAdapter; + /** * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect * to a database @@ -18,9 +29,9 @@ * ]; * * $connection = new Mysql($config); - * ``` + *``` */ -abstract class AbstractPdo extends \Phalcon\Db\Adapter\AbstractAdapter +abstract class AbstractPdo extends AbstractAdapter { /** * Last affected rows diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index 7e03f623..6885e13d 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; + /** * Specific functions for the Mysql database system * - * ```php + *```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -17,9 +28,9 @@ * ]; * * $connection = new Mysql($config); - * ``` + *``` */ -class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Mysql extends PdoAdapter { /** * @var string diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 16662427..27938637 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\RawValue; + /** * Specific functions for the Postgresql database system * @@ -19,7 +31,7 @@ * $connection = new Postgresql($config); * ``` */ -class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Postgresql extends PdoAdapter { /** * @var string diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index 8acf592d..5d945908 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\RawValue; + /** * Specific functions for the Sqlite database system * @@ -15,7 +27,7 @@ * ); * ``` */ -class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Sqlite extends PdoAdapter { /** * @var string diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 85905487..f5b9c031 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Dialect; +use Phalcon\Db\Dialect; + /** * Generates database specific SQL for the MySQL RDBMS */ -class Mysql extends \Phalcon\Db\Dialect +class Mysql extends Dialect { /** * @var string diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 2ef5c5ff..51c4c537 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Dialect; +use Phalcon\Db\Dialect; + /** * Generates database specific SQL for the PostgreSQL RDBMS */ -class Postgresql extends \Phalcon\Db\Dialect +class Postgresql extends Dialect { /** * @var string diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index f00fed05..09745433 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Dialect; +use Phalcon\Db\Dialect; + /** * Generates database specific SQL for the SQLite RDBMS */ -class Sqlite extends \Phalcon\Db\Dialect +class Sqlite extends Dialect { /** * @var string diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 8e0bce9e..8896d85f 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Profiler; /** diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 98a954a3..12293b77 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -1,12 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Db\Result; +use Phalcon\Db\Enum; +use Phalcon\Db\ResultInterface; + /** * Encapsulates the resultset internals * * ```php - * $result = $connection->query("SELECT FROM robots ORDER BY name"); + * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * * $result->setFetchMode( * \Phalcon\Db\Enum::FETCH_NUM @@ -17,7 +29,7 @@ * } * ``` */ -class Pdo implements \Phalcon\Db\ResultInterface +class Pdo implements ResultInterface { protected $bindParams; diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index 96186819..2f08b6f8 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Debug; /** diff --git a/src/Phalcon/debug/Exception.php b/src/Phalcon/debug/Exception.php index 9616f511..9f53942f 100644 --- a/src/Phalcon/debug/Exception.php +++ b/src/Phalcon/debug/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Debug; /** diff --git a/src/Phalcon/di/AbstractInjectionAware.php b/src/Phalcon/di/AbstractInjectionAware.php new file mode 100644 index 00000000..cae41139 --- /dev/null +++ b/src/Phalcon/di/AbstractInjectionAware.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +namespace Phalcon\Di; + +/** + * This abstract class offers common access to the DI in a class + */ +abstract class AbstractInjectionAware implements InjectionAwareInterface +{ + /** + * Dependency Injector + * + * @var DiInterface + */ + protected $container; + + + /** + * Returns the internal dependency injector + * + * @return \Phalcon\Di\DiInterface + */ + public function getDI(): DiInterface {} + + /** + * Sets the dependency injector + * + * @param \Phalcon\Di\DiInterface $container + */ + public function setDI(\Phalcon\Di\DiInterface $container) {} + +} diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/di/DiInterface.php index 0e63ebd8..13ee2276 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; +use ArrayAccess; + /** * Interface for Phalcon\Di */ -interface DiInterface extends \ArrayAccess +interface DiInterface extends ArrayAccess { /** diff --git a/src/Phalcon/di/Exception.php b/src/Phalcon/di/Exception.php index 076f3444..c9485d91 100644 --- a/src/Phalcon/di/Exception.php +++ b/src/Phalcon/di/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index a9ebce24..89294dbc 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index e2821622..605b6ede 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Session\BagInterface; + /** * This class allows to access services in the services container by just only * accessing a public property with the same name of a registered service @@ -12,7 +25,7 @@ * @property \Phalcon\Http\Request|\Phalcon\Http\RequestInterface $request * @property \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface $response * @property \Phalcon\Http\Response\Cookies|\Phalcon\Http\Response\CookiesInterface $cookies - * @property \Phalcon\Filter\FilterLocator $filter + * @property \Phalcon\Filter $filter * @property \Phalcon\Flash\Direct $flash * @property \Phalcon\Flash\Session $flashSession * @property \Phalcon\Session\ManagerInterface $session @@ -31,7 +44,7 @@ * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ -abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +abstract class Injectable implements InjectionAwareInterface, EventsAwareInterface { /** * Dependency Injector @@ -54,7 +67,7 @@ abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface, \Phalc * @param string $propertyName * @return mixed|null */ - public function __get(string $propertyName): ? {} + public function __get(string $propertyName) {} /** * Returns the internal dependency injector @@ -66,9 +79,9 @@ public function getDI(): DiInterface {} /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return null|\Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ?ManagerInterface {} /** * Sets the dependency injector diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index d12064ac..b725cd4c 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index fbc35b47..22e1dc08 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -1,20 +1,31 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; +use Phalcon\Di\Exception\ServiceResolutionException; + /** * Represents individually a service in the services container * - * ```php + *```php * $service = new \Phalcon\Di\Service( * "request", * \Phalcon\Http\Request::class * ); * * $request = service->resolve(); - * ``` + *``` */ -class Service implements \Phalcon\Di\ServiceInterface +class Service implements ServiceInterface { protected $definition; diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index a7447ae8..65d6d72c 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index e61eaedb..c7c11fa7 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php index 15c7d6b3..5bf50fe2 100644 --- a/src/Phalcon/di/exception/ServiceResolutionException.php +++ b/src/Phalcon/di/exception/ServiceResolutionException.php @@ -1,11 +1,5 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di\FactoryDefault; +use Phalcon\Di\FactoryDefault; + /** * Phalcon\Di\FactoryDefault\Cli * @@ -10,7 +21,7 @@ * Thanks to this, the developer does not need to register each service individually. * This class is specially suitable for CLI applications */ -class Cli extends \Phalcon\Di\FactoryDefault +class Cli extends FactoryDefault { /** diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/di/service/Builder.php index db5b1c1d..ed0ee461 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/di/service/Builder.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Di\Service; /** diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/dispatcher/AbstractDispatcher.php index 6dd1e2b4..7af8efcd 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/dispatcher/AbstractDispatcher.php @@ -1,13 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Dispatcher; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Model\BinderInterface; + /** * This is the base class for Phalcon\Mvc\Dispatcher and Phalcon\Cli\Dispatcher. * This class can't be instantiated directly, you can use it to create your own * dispatchers. */ -abstract class AbstractDispatcher implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractDispatcher extends AbstractInjectionAware implements DispatcherInterface, EventsAwareInterface { protected $activeHandler; @@ -30,9 +44,6 @@ abstract class AbstractDispatcher implements \Phalcon\Dispatcher\DispatcherInter */ protected $camelCaseMap = array(); - - protected $container; - /** * @var string */ @@ -193,13 +204,6 @@ public function getBoundModels(): array {} */ public function getDefaultNamespace(): string {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the internal event manager * @@ -289,13 +293,6 @@ public function setDefaultAction(string $actionName) {} */ public function setDefaultNamespace(string $namespaceName) {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Possible class name that will be located to dispatch the request * diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php index e28b1de8..1f8120e8 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Dispatcher; /** diff --git a/src/Phalcon/dispatcher/Exception.php b/src/Phalcon/dispatcher/Exception.php index a9867c1d..c9d40819 100644 --- a/src/Phalcon/dispatcher/Exception.php +++ b/src/Phalcon/dispatcher/Exception.php @@ -1,9 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Dispatcher; /** - * Exceptions thrown in Phalcon\Dispatcher/ will use this class + * Exceptions thrown in Phalcon\Dispatcher/* will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/domain/payload/Payload.php index fc312076..10c8fb0d 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/domain/payload/Payload.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** * Holds the payload */ -class Payload implements \Phalcon\Domain\Payload\PayloadInterface +class Payload implements PayloadInterface { /** * Extra information diff --git a/src/Phalcon/domain/payload/PayloadFactory.php b/src/Phalcon/domain/payload/PayloadFactory.php index 3febc04b..5d82c8c6 100644 --- a/src/Phalcon/domain/payload/PayloadFactory.php +++ b/src/Phalcon/domain/payload/PayloadFactory.php @@ -1,5 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** diff --git a/src/Phalcon/domain/payload/PayloadInterface.php b/src/Phalcon/domain/payload/PayloadInterface.php index 11b00467..54d7c9b9 100644 --- a/src/Phalcon/domain/payload/PayloadInterface.php +++ b/src/Phalcon/domain/payload/PayloadInterface.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** * This interface is used for consumers */ -interface PayloadInterface extends \Phalcon\Domain\Payload\ReadableInterface, \Phalcon\Domain\Payload\WriteableInterface +interface PayloadInterface extends ReadableInterface, WriteableInterface { } diff --git a/src/Phalcon/domain/payload/ReadableInterface.php b/src/Phalcon/domain/payload/ReadableInterface.php index ed8c1d23..ab5a937f 100644 --- a/src/Phalcon/domain/payload/ReadableInterface.php +++ b/src/Phalcon/domain/payload/ReadableInterface.php @@ -1,5 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** diff --git a/src/Phalcon/domain/payload/Status.php b/src/Phalcon/domain/payload/Status.php index 01ac2ab0..1c62308c 100644 --- a/src/Phalcon/domain/payload/Status.php +++ b/src/Phalcon/domain/payload/Status.php @@ -1,5 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/domain/payload/WriteableInterface.php index 4bdfbb46..aeead6c8 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/domain/payload/WriteableInterface.php @@ -1,5 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by phalcon-api and AuraPHP + * @link https://github.com/phalcon/phalcon-api + * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE + * @link https://github.com/auraphp/Aura.Payload + * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE + * + * @see Original inspiration for the https://github.com/phalcon/phalcon-api + */ + namespace Phalcon\Domain\Payload; /** diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/escaper/EscaperInterface.php index 784051f3..ade69a45 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/escaper/EscaperInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Escaper; /** diff --git a/src/Phalcon/escaper/Exception.php b/src/Phalcon/escaper/Exception.php index 75b6746a..2fbb8c1b 100644 --- a/src/Phalcon/escaper/Exception.php +++ b/src/Phalcon/escaper/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Escaper; /** diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/events/Event.php index 3818eca6..3f5411e3 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/events/Event.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** @@ -8,7 +17,7 @@ * This class offers contextual information of a fired event in the * EventsManager */ -class Event implements \Phalcon\Events\EventInterface +class Event implements EventInterface { /** * Is event cancelable? diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index 92f60516..99248fb4 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index a7fcff43..1239dded 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** @@ -14,9 +23,9 @@ interface EventsAwareInterface /** * Returns the internal event manager * - * @return ManagerInterface + * @return null|ManagerInterface */ - public function getEventsManager(): ManagerInterface; + public function getEventsManager(): ?ManagerInterface; /** * Sets the events manager diff --git a/src/Phalcon/events/Exception.php b/src/Phalcon/events/Exception.php index fc0f8206..fa2a2045 100644 --- a/src/Phalcon/events/Exception.php +++ b/src/Phalcon/events/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index 39b3fb35..fbab28bd 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** @@ -10,7 +19,7 @@ * can create hooks or plugins that will offer monitoring of data, manipulation, * conditional execution and much more. */ -class Manager implements \Phalcon\Events\ManagerInterface +class Manager implements ManagerInterface { const DEFAULT_PRIORITY = 100; diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 048672ab..48a21590 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Events; /** diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php index b54cb01b..235e2863 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/factory/AbstractFactory.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AbstractFactory + +namespace Phalcon\Factory; + +abstract class AbstractFactory { /** * @var array diff --git a/src/Phalcon/factory/Exception.php b/src/Phalcon/factory/Exception.php index 15f9cdc3..7466e7b6 100644 --- a/src/Phalcon/factory/Exception.php +++ b/src/Phalcon/factory/Exception.php @@ -1,15 +1,16 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Factory; + class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/filter/Exception.php b/src/Phalcon/filter/Exception.php index c7a2a279..55dffd06 100644 --- a/src/Phalcon/filter/Exception.php +++ b/src/Phalcon/filter/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter; /** diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/filter/FilterFactory.php index 76ba9b34..88fdebf7 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/filter/FilterFactory.php @@ -1,15 +1,16 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Filter; + class FilterFactory { diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php index 067ba31c..110ab1dd 100644 --- a/src/Phalcon/filter/FilterInterface.php +++ b/src/Phalcon/filter/FilterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter; /** diff --git a/src/Phalcon/filter/sanitize/AbsInt.php b/src/Phalcon/filter/sanitize/AbsInt.php index 0afb175b..fc2a2991 100644 --- a/src/Phalcon/filter/sanitize/AbsInt.php +++ b/src/Phalcon/filter/sanitize/AbsInt.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Alnum.php b/src/Phalcon/filter/sanitize/Alnum.php index b85666d7..16f8333d 100644 --- a/src/Phalcon/filter/sanitize/Alnum.php +++ b/src/Phalcon/filter/sanitize/Alnum.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Alpha.php b/src/Phalcon/filter/sanitize/Alpha.php index 943604b4..be47c5fb 100644 --- a/src/Phalcon/filter/sanitize/Alpha.php +++ b/src/Phalcon/filter/sanitize/Alpha.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/BoolVal.php b/src/Phalcon/filter/sanitize/BoolVal.php index 458228bc..dcc54015 100644 --- a/src/Phalcon/filter/sanitize/BoolVal.php +++ b/src/Phalcon/filter/sanitize/BoolVal.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Email.php b/src/Phalcon/filter/sanitize/Email.php index feaf09ad..bb18efa6 100644 --- a/src/Phalcon/filter/sanitize/Email.php +++ b/src/Phalcon/filter/sanitize/Email.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/FloatVal.php b/src/Phalcon/filter/sanitize/FloatVal.php index a540bc8f..d460f61c 100644 --- a/src/Phalcon/filter/sanitize/FloatVal.php +++ b/src/Phalcon/filter/sanitize/FloatVal.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/IntVal.php b/src/Phalcon/filter/sanitize/IntVal.php index 5729fe61..3dd492c1 100644 --- a/src/Phalcon/filter/sanitize/IntVal.php +++ b/src/Phalcon/filter/sanitize/IntVal.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Lower.php b/src/Phalcon/filter/sanitize/Lower.php index ebce8db3..ed4465fe 100644 --- a/src/Phalcon/filter/sanitize/Lower.php +++ b/src/Phalcon/filter/sanitize/Lower.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/LowerFirst.php b/src/Phalcon/filter/sanitize/LowerFirst.php index e90c188b..d737fa03 100644 --- a/src/Phalcon/filter/sanitize/LowerFirst.php +++ b/src/Phalcon/filter/sanitize/LowerFirst.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Regex.php b/src/Phalcon/filter/sanitize/Regex.php index 78f094e4..6e27be24 100644 --- a/src/Phalcon/filter/sanitize/Regex.php +++ b/src/Phalcon/filter/sanitize/Regex.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Remove.php b/src/Phalcon/filter/sanitize/Remove.php index e8b3445d..31101d44 100644 --- a/src/Phalcon/filter/sanitize/Remove.php +++ b/src/Phalcon/filter/sanitize/Remove.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Replace.php b/src/Phalcon/filter/sanitize/Replace.php index 19cfb638..c3ff0fd5 100644 --- a/src/Phalcon/filter/sanitize/Replace.php +++ b/src/Phalcon/filter/sanitize/Replace.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Special.php b/src/Phalcon/filter/sanitize/Special.php index 7a22d9a4..3f52ea75 100644 --- a/src/Phalcon/filter/sanitize/Special.php +++ b/src/Phalcon/filter/sanitize/Special.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/SpecialFull.php b/src/Phalcon/filter/sanitize/SpecialFull.php index 444775a2..548d9d55 100644 --- a/src/Phalcon/filter/sanitize/SpecialFull.php +++ b/src/Phalcon/filter/sanitize/SpecialFull.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/StringVal.php b/src/Phalcon/filter/sanitize/StringVal.php index 00114007..7f980c60 100644 --- a/src/Phalcon/filter/sanitize/StringVal.php +++ b/src/Phalcon/filter/sanitize/StringVal.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Striptags.php b/src/Phalcon/filter/sanitize/Striptags.php index eef41066..f5f73bc2 100644 --- a/src/Phalcon/filter/sanitize/Striptags.php +++ b/src/Phalcon/filter/sanitize/Striptags.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Trim.php b/src/Phalcon/filter/sanitize/Trim.php index 5e7feb27..198c17a4 100644 --- a/src/Phalcon/filter/sanitize/Trim.php +++ b/src/Phalcon/filter/sanitize/Trim.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Upper.php b/src/Phalcon/filter/sanitize/Upper.php index b3861d9b..39ccfbde 100644 --- a/src/Phalcon/filter/sanitize/Upper.php +++ b/src/Phalcon/filter/sanitize/Upper.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/UpperFirst.php b/src/Phalcon/filter/sanitize/UpperFirst.php index 491feeda..d1a8029c 100644 --- a/src/Phalcon/filter/sanitize/UpperFirst.php +++ b/src/Phalcon/filter/sanitize/UpperFirst.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/UpperWords.php b/src/Phalcon/filter/sanitize/UpperWords.php index 174fda5d..0f047dbc 100644 --- a/src/Phalcon/filter/sanitize/UpperWords.php +++ b/src/Phalcon/filter/sanitize/UpperWords.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/filter/sanitize/Url.php b/src/Phalcon/filter/sanitize/Url.php index 8217cf19..e53d2e31 100644 --- a/src/Phalcon/filter/sanitize/Url.php +++ b/src/Phalcon/filter/sanitize/Url.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Filter\Sanitize; /** diff --git a/src/Phalcon/firewall/Exception.php b/src/Phalcon/firewall/Exception.php index dd456f15..aeee2ad1 100644 --- a/src/Phalcon/firewall/Exception.php +++ b/src/Phalcon/firewall/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall; /** diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/firewall/adapter/AbstractAdapter.php index 1b0a633b..a87e3c7b 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/firewall/adapter/AbstractAdapter.php @@ -1,11 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall\Adapter; +use Closure; +use Phalcon\Acl\Enum; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; + /** * Adapter for Phalcon\Firewall adapters */ -abstract class AbstractAdapter implements \Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Storing active identity object implementing Phalcon/Acl/RoleAware @@ -71,13 +86,6 @@ public function getActiveIdentity() {} */ public function getActiveRole() {} - /** - * Should role always be resolved using role callback or just once? - * - * @param bool $alwaysResolvingRole - */ - public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} - /** * Default access * @@ -126,9 +134,8 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface {} * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return AdapterInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): AdapterInterface {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** * Sets role callback to fetch role name @@ -138,6 +145,13 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager */ public function setRoleCallback($callback): AdapterInterface {} + /** + * Sets always resolving role option + * + * @param bool $alwaysResolvingRole + */ + public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} + /** * @param \Phalcon\Di\DiInterface $container */ diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php index 7ac99290..a8b60071 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall\Adapter; /** * FirewallZ for Phalcon\Application which depends on acl and dispatcher */ -class Acl extends \Phalcon\Firewall\Adapter\AbstractAdapter +class Acl extends AbstractAdapter { /** * Acl service name diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/firewall/adapter/AdapterInterface.php index c8553be8..549aeafd 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/firewall/adapter/AdapterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall\Adapter; /** diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/firewall/adapter/Annotations.php index 3646b424..80232690 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/firewall/adapter/Annotations.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall\Adapter; /** * Firewall which depends on annotations and dispatcher */ -class Annotations extends \Phalcon\Firewall\Adapter\AbstractAdapter +class Annotations extends AbstractAdapter { /** * Number of active active arguments in active annotation diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/firewall/adapter/micro/Acl.php index 2fbf614f..aba97c48 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/firewall/adapter/micro/Acl.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Firewall\Adapter\Micro; +use Phalcon\Firewall\Adapter\AbstractAdapter; +use Phalcon\Mvc\Micro; + /** * Firewall for Phalcon\Mvc\Micro which depends on ACL */ -class Acl extends \Phalcon\Firewall\Adapter\AbstractAdapter +class Acl extends AbstractAdapter { /** * Acl service name diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/flash/AbstractFlash.php index 5d9e0bf6..45c41fda 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/flash/AbstractFlash.php @@ -1,17 +1,30 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Flash; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Session\ManagerInterface as SessionInterface; + /** * Shows HTML notifications related to different circumstances. Classes can be * stylized using CSS * - * ```php + *```php * $flash->success("The record was successfully deleted"); * $flash->error("Cannot open the file"); - * ``` + *``` */ -abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\Di\InjectionAwareInterface +abstract class AbstractFlash extends AbstractInjectionAware implements FlashInterface { /** * @var bool @@ -33,10 +46,9 @@ abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\ */ protected $customTemplate = ''; - - protected $container = null; - - + /** + * @var EscaperInterface | null + */ protected $escaperService = null; /** @@ -44,16 +56,39 @@ abstract class AbstractFlash implements \Phalcon\Flash\FlashInterface, \Phalcon\ */ protected $implicitFlush = true; - + /** + * @var array + */ protected $messages = array(); + /** + * @var SessionInterface | null + */ + protected $sessionService = null; + + + /** + * @return bool + */ + public function getAutoescape(): bool {} + + /** + * @return array + */ + public function getCssClasses(): array {} + + /** + * @return string + */ + public function getCustomTemplate(): string {} /** * Phalcon\Flash constructor * - * @param mixed $cssClasses + * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param \Phalcon\Session\ManagerInterface $session */ - public function __construct($cssClasses = null) {} + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) {} /** * Clears accumulated messages when implicit flush is disabled @@ -72,27 +107,6 @@ public function clear() {} */ public function error(string $message): string {} - /** - * Returns the autoescape mode in generated html - * - * @return bool - */ - public function getAutoescape(): bool {} - - /** - * Returns the custom template set - * - * @return string - */ - public function getCustomTemplate(): string {} - - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the Escaper Service * @@ -116,9 +130,9 @@ public function notice(string $message): string {} * Set the autoescape mode in generated html * * @param bool $autoescape - * @return Flash + * @return FlashInterface */ - public function setAutoescape(bool $autoescape): Flash {} + public function setAutoescape(bool $autoescape): FlashInterface {} /** * Set if the output must be implicitly formatted with HTML @@ -144,14 +158,6 @@ public function setCssClasses(array $cssClasses): FlashInterface {} */ public function setCustomTemplate(string $customTemplate): FlashInterface {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - * @return FlashInterface - */ - public function setDI(\Phalcon\Di\DiInterface $container): FlashInterface {} - /** * Sets the Escaper Service * diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index fda928b6..298f5f27 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -1,12 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Flash; /** * This is a variant of the Phalcon\Flash that immediately outputs any message * passed to it */ -class Direct extends \Phalcon\Flash\AbstractFlash +class Direct extends AbstractFlash { /** @@ -14,9 +23,9 @@ class Direct extends \Phalcon\Flash\AbstractFlash * * @param string $type * @param mixed $message - * @return string + * @return string|null */ - public function message(string $type, $message): string {} + public function message(string $type, $message): ?string {} /** * Prints the messages accumulated in the flasher diff --git a/src/Phalcon/flash/Exception.php b/src/Phalcon/flash/Exception.php index 6a123e85..342d796a 100644 --- a/src/Phalcon/flash/Exception.php +++ b/src/Phalcon/flash/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Flash; /** diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php index 8faa3dea..35ae67e0 100644 --- a/src/Phalcon/flash/FlashInterface.php +++ b/src/Phalcon/flash/FlashInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Flash; /** @@ -23,8 +32,9 @@ public function error(string $message): string; * * @param string $type * @param string $message + * @return string|null */ - public function message(string $type, string $message); + public function message(string $type, string $message): ?string; /** * Shows a HTML notice/information message diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/flash/Session.php index 3231edcd..2b3027a5 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/flash/Session.php @@ -1,12 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Flash; +use Phalcon\Session\ManagerInterface as SessionInterface; + /** * Temporarily stores the messages in session, then messages can be printed in * the next request */ -class Session extends \Phalcon\Flash\AbstractFlash +class Session extends AbstractFlash { /** @@ -36,8 +47,9 @@ public function has($type = null): bool {} * * @param string $type * @param string $message + * @return string|null */ - public function message(string $type, string $message) {} + public function message(string $type, string $message): ?string {} /** * Prints the messages in the session flasher @@ -63,4 +75,11 @@ protected function getSessionMessages(bool $remove, $type = null): array {} */ protected function setSessionMessages(array $messages): array {} + /** + * Returns the Session Service + * + * @return \Phalcon\Session\ManagerInterface + */ + public function getSessionService(): SessionInterface {} + } diff --git a/src/Phalcon/forms/Exception.php b/src/Phalcon/forms/Exception.php index b5778926..58b003f6 100644 --- a/src/Phalcon/forms/Exception.php +++ b/src/Phalcon/forms/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms; /** diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/forms/Form.php index 7c630ce4..101292cc 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/forms/Form.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms; +use Countable; +use Iterator; +use Phalcon\Di\Injectable; +use Phalcon\Forms\Element\ElementInterface; +use Phalcon\Html\Attributes; +use Phalcon\Html\Attributes\AttributesInterface; +use Phalcon\Messages\Messages; + /** * This component allows to build forms using an object-oriented interface */ -class Form extends \Phalcon\Di\Injectable implements \Countable, \Iterator, \Phalcon\Html\Attributes\AttributesInterface +class Form extends Injectable implements Countable, Iterator, AttributesInterface { protected $attributes; @@ -177,7 +194,7 @@ public function getUserOptions(): array {} * @param string $name * @return mixed|null */ - public function getValue(string $name): ? {} + public function getValue(string $name) {} /** * Check if the form contains an element diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index df4e51a2..91291d20 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms; /** diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/forms/element/AbstractElement.php index 5a9385cd..5f89f46c 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; +use Phalcon\Forms\Form; +use Phalcon\Messages\Messages; + /** * This is a base class for form elements */ -abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface +abstract class AbstractElement implements ElementInterface { protected $attributes; diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index 2225b1ca..60ad5466 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=check] for forms */ -class Check extends \Phalcon\Forms\Element\AbstractElement +class Check extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index 2b905e67..5b612851 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** * Component INPUT[type=date] for forms */ -class Date extends \Phalcon\Forms\Element\AbstractElement +class Date extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/forms/element/ElementInterface.php index dfe3ec0e..7c953abf 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/forms/element/ElementInterface.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; +use Phalcon\Forms\Form; +use Phalcon\Messages\Messages; + /** * Interface for Phalcon\Forms\Element classes */ diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index cd53d0b8..b86b767e 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=email] for forms */ -class Email extends \Phalcon\Forms\Element\AbstractElement +class Email extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index 78a18b84..7598acdf 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** * Component INPUT[type=file] for forms */ -class File extends \Phalcon\Forms\Element\AbstractElement +class File extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index 2a060ea9..20352655 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=hidden] for forms */ -class Hidden extends \Phalcon\Forms\Element\AbstractElement +class Hidden extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 08b6ab96..0aa08daa 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=number] for forms */ -class Numeric extends \Phalcon\Forms\Element\AbstractElement +class Numeric extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 8cc5ab6d..297c254e 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=password] for forms */ -class Password extends \Phalcon\Forms\Element\AbstractElement +class Password extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index a9a462fc..7da801d3 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=radio] for forms */ -class Radio extends \Phalcon\Forms\Element\AbstractElement +class Radio extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index 9fcbf112..4ee4d373 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component SELECT (choice) for forms */ -class Select extends \Phalcon\Forms\Element\AbstractElement +class Select extends AbstractElement { protected $optionsValues; diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index dae2a93d..6221fd32 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** * Component INPUT[type=submit] for forms */ -class Submit extends \Phalcon\Forms\Element\AbstractElement +class Submit extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index 6bccb1f9..5bfd5d4c 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** @@ -7,7 +16,7 @@ * * Component INPUT[type=text] for forms */ -class Text extends \Phalcon\Forms\Element\AbstractElement +class Text extends AbstractElement { /** diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index 480fdb62..daa53f1d 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Forms\Element; /** * Component TEXTAREA for forms */ -class TextArea extends \Phalcon\Forms\Element\AbstractElement +class TextArea extends AbstractElement { /** diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index 368e2140..74b60aaa 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Helper; /** @@ -8,11 +17,6 @@ class Arr { - /** - * @param array $collection - */ - final public static function arrayToObject(array $collection) {} - /** * Chunks an array into smaller arrays of a specified size. * @@ -198,6 +202,13 @@ final public static function sliceRight(array $collection, int $elements = 1): a */ final public static function split(array $collection): array {} + /** + * Returns the passed array as an object + * + * @param array $collection + */ + final public static function toObject(array $collection) {} + /** * Returns true if the provided function returns true for all elements of * the collection, false otherwise. diff --git a/src/Phalcon/helper/Exception.php b/src/Phalcon/helper/Exception.php index 308a77dc..cd7e73f8 100644 --- a/src/Phalcon/helper/Exception.php +++ b/src/Phalcon/helper/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Helper; /** diff --git a/src/Phalcon/helper/Fs.php b/src/Phalcon/helper/Fs.php new file mode 100644 index 00000000..729c68e9 --- /dev/null +++ b/src/Phalcon/helper/Fs.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Phalcon\Helper; + +/** + * This class offers file operation helper + */ +class Fs +{ + + /** + * Gets the filename from a given path, Same as PHP's basename() but has non-ASCII support. + * PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character. + * see https://bugs.php.net/bug.php?id=37738 + * + * @param string $suffix + * + * @param string $uri + * @param mixed $suffix + * @return string + */ + final public static function basename(string $uri, $suffix = null): string {} + +} diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php index a14f4b6b..40d93135 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/helper/Number.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Helper; /** diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/helper/Str.php index e17f8c87..e64a7d58 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/helper/Str.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Helper; /** diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/html/Attributes.php index e9d6deb0..b1826514 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/html/Attributes.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html; +use Phalcon\Collection; +use Phalcon\Html\Attributes\RenderInterface; + /** * This class helps to work with HTML Attributes */ -class Attributes extends \Phalcon\Collection implements \Phalcon\Html\Attributes\RenderInterface +class Attributes extends Collection implements RenderInterface { /** diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/html/Breadcrumbs.php index 2089f975..605c29b1 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/html/Breadcrumbs.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html; /** diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php index 2a33e680..bcb3ee05 100644 --- a/src/Phalcon/html/Exception.php +++ b/src/Phalcon/html/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html; /** diff --git a/src/Phalcon/html/Tag.php b/src/Phalcon/html/Tag.php deleted file mode 100644 index f825b280..00000000 --- a/src/Phalcon/html/Tag.php +++ /dev/null @@ -1,1182 +0,0 @@ - - */ - private $escaper; - - /** - * @var array - */ - private $prepend = array(); - - /** - * @var string - */ - private $separator = ''; - - /** - * @var string - */ - private $title = ''; - - /** - * @var array - */ - private $values = array(); - - /** - * @var - */ - private $url; - - - /** - * Constructor - * - * @param \Phalcon\Escaper\EscaperInterface $escaper - * @param \Phalcon\Url\UrlInterface $url - */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Url\UrlInterface $url = null) {} - - /** - * Appends a text to current document title - * - * @param mixed $title - * @return Tag - */ - public function appendTitle($title): Tag {} - - /** - * Builds a HTML input[type="button"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->button('Click Me'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ button('Click Me') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function button(string $name, array $parameters = array()): string {} - - /** - * Resets the request and internal values to avoid those fields will have - * any default value. - */ - public function clear() {} - - /** - * Builds a HTML tag - * - * Parameters - * `onlyStart` Only process the start of th element - * `selfClose` It is a self close element - * `useEol` Append PHP_EOL at the end - * - * @param string $tag - * @param array $parameters - * @return string - */ - public function element(string $tag, array $parameters = array()): string {} - - /** - * Builds the closing tag of an html element - * - * Parameters - * `useEol` Append PHP_EOL at the end - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', - * ] - * ); // - * - * echo $tag->elementClose( - * [ - * 'name' => 'aside', - * 'useEol' => true, - * ] - * ); // '' . PHP_EOL - * ``` - * - * @param string $tag - * @param array $parameters - * @return string - */ - public function elementClose(string $tag, array $parameters = array()): string {} - - /** - * Returns the closing tag of a form element - * - * @param bool $eol - * @return string - */ - public function endForm(bool $eol = true): string {} - - /** - * Builds a HTML FORM tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->form('posts/save'); - * - * echo $tag->form( - * 'posts/save', - * [ - * "method" => "post", - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ form('posts/save') }}{% endraw %} - * {% raw %}{{ form('posts/save', ['method': 'post') }}{% endraw %} - * ``` - * - * @param string $action - * @param array $parameters - * @return string - */ - public function form(string $action, array $parameters = array()): string {} - - /** - * Converts text to URL-friendly strings - * - * Parameters - * `text` The text to be processed - * `separator` Separator to use (default '-') - * `lowercase` Convert to lowercase - * `replace` - * - * ```php - * use Phalcon\Html\Tag; - * - * $tab = new Tag(); - * - * echo $tag->friendlyTitle( - * [ - * 'text' => 'These are big important news', - * 'separator' => '-', - * ] - * ); - * ``` - * - * Volt Syntax: - * ```php - * {% raw %}{{ friendly_title(['text': 'These are big important news', 'separator': '-']) }}{% endraw %} - * ``` - * - * @param string $text - * @param array $parameters - * @return string - */ - public function friendlyTitle(string $text, array $parameters = array()): string {} - - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Get the document type declaration of content. If the docType has not - * been set properly, XHTML5 is returned - * - * @return string - */ - public function getDocType(): string {} - - /** - * Gets the current document title. The title will be automatically escaped. - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->getTitle(); // Hello World from Phalcon - * echo $tag->getTitle(false); // World from Phalcon - * echo $tag->getTitle(true, false); // Hello World - * echo $tag->getTitle(false, false); // World - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ get_title() }}{% endraw %} - * ``` - * - * @param bool $prepend - * @param bool $append - * @return string - */ - public function getTitle(bool $prepend = true, bool $append = true): string {} - - /** - * Gets the current document title separator - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->getTitleSeparator(); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ get_title_separator() }}{% endraw %} - * ``` - * - * @return string - */ - public function getTitleSeparator(): string {} - - /** - * Every helper calls this function to check whether a component has a - * predefined value using `setAttribute` or value from $_POST - * - * @param string $name - * @param array $parameters - * @return mixed|null - */ - public function getValue(string $name, array $parameters = array()): ? {} - - /** - * Check if a helper has a default value set using `setAttribute()` or - * value from $_POST - * - * @param string $name - * @return bool - */ - public function hasValue(string $name): bool {} - - /** - * Builds HTML IMG tags - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->image('img/bg.png'); - * - * echo $tag->image( - * 'img/photo.jpg', - * [ - * 'alt' => 'Some Photo', - * ] - * ); - * - * echo $tag->image( - * 'http://static.mywebsite.com/img/bg.png', - * [ - * 'local' => false, - * ] - * ); - * ``` - * - * Volt Syntax: - * ```php - * {% raw %}{{ image('img/bg.png') }}{% endraw %} - * {% raw %}{{ image('img/photo.jpg', ['alt': 'Some Photo') }}{% endraw %} - * {% raw %}{{ image('http://static.mywebsite.com/img/bg.png', ['local': false]) }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function image(string $url = '', array $parameters = array()): string {} - - /** - * Builds a HTML input[type="check"] tag - * - * ```php - * echo $tag->inputCheckbox( - * [ - * 'name' => 'terms, - * 'value' => 'Y', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_checkbox(['name': 'terms, 'value': 'Y']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputCheckbox(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='color'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputColor(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='date'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDate( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDate(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='datetime'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTime( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date_time(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDateTime(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='datetime-local'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputDateTimeLocal( - * [ - * 'name' => 'born', - * 'value' => '14-12-1980', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_date_time_local(['name':'born', 'value':'14-12-1980']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputDateTimeLocal(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='email'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputEmail( - * [ - * 'name' => 'email', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_email(['name': 'email']);{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputEmail(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='file'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputFile( - * [ - * 'name' => 'file', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_file(['name': 'file']){% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputFile(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='hidden'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputHidden( - * [ - * 'name' => 'my-field', - * 'value' => 'mike', - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputHidden(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="image"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * echo $tag->inputImage( - * [ - * 'src' => '/img/button.png', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_image(['src': '/img/button.png']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputImage(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='month'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputMonth(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='number'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->numericField( - * [ - * 'name' => 'price', - * 'min' => '1', - * 'max' => '5', - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputNumeric(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='password'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->passwordField( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputPassword(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="radio"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputRadio( - * [ - * 'name' => 'weather', - * 'value" => 'hot', - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ input_radio(['name': 'weather', 'value": 'hot']) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputRadio(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='range'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputRange(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='search'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputSearch(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='tel'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputTel(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='text'] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->inputText( - * [ - * 'name' => 'my-field', - * 'size' => 30, - * ] - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputText(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='time'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputTime(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='url'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputUrl(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML input[type='week'] tag - * - * @param string $name - * @param array $parameters - * @return string - */ - public function inputWeek(string $name, array $parameters = array()): string {} - - /** - * Builds a script[type="javascript"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->javascript( - * 'http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->javascript('javascript/jquery.js'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ javascript('http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js', ['local': false]) }}{% endraw %} - * {% raw %}{{ javascript('javascript/jquery.js') }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function javascript(string $url, array $parameters = array()): string {} - - /** - * Builds a HTML A tag using framework conventions - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->link('signup/register', 'Register Here!'); - * - * echo $tag->link( - * 'signup/register', - * 'Register Here!', - * [ - * 'class' => 'btn-primary', - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->link( - * 'https://phalconphp.com/', - * 'Phalcon!', - * [ - * 'local' => false, - * 'target' => '_new', - * ] - * ); - * ``` - * - * @param string $url - * @param string $text - * @param array $parameters - * @return string - */ - public function link(string $url, string $text = '', array $parameters = array()): string {} - - /** - * Prepends a text to current document title - * - * @param mixed $title - * @return Tag - */ - public function prependTitle($title): Tag {} - - /** - * Renders the title with title tags. The title is automaticall escaped - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag - * ->setTitleSeparator(' ') - * ->prependTitle(['Hello']) - * ->setTitle('World') - * ->appendTitle(['from Phalcon']); - * - * echo $tag->renderTitle(); // Hello World from Phalcon - * echo $tag->renderTitle(false); // World from Phalcon - * echo $tag->renderTitle(true, false); // Hello World - * echo $tag->renderTitle(false, false); // World - * ``` - * - * ```php - * {% raw %}{{ render_title() }}{% endraw %} - * ``` - * - * @param bool $prepend - * @param bool $append - * @return string - */ - public function renderTitle(bool $prepend = true, bool $append = true): string {} - - /** - * Builds a HTML input[type="reset"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->reset('Reset') - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ reset('Save') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function reset(string $name, array $parameters = array()): string {} - - /** - * Builds a select element. It accepts an array or a resultset from - * a Phalcon\Mvc\Model - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Status...', - * ], - * [ - * 'A' => 'Active', - * 'I' => 'Inactive', - * ] - * ); - * - * echo $tag->select( - * 'status', - * [ - * 'id' => 'status-id', - * 'useEmpty' => true, - * 'emptyValue => '', - * 'emptyText' => 'Choose Type...', - * 'using' => [ - * 'id, - * 'name', - * ], - * ], - * Robots::find( - * [ - * 'conditions' => 'type = :type:', - * 'bind' => [ - * 'type' => 'mechanical', - * ] - * ] - * ) - * ); - * ``` - * - * @param string $name - * @param array $parameters - * @param mixed $data - * @return string - */ - public function select(string $name, array $parameters = array(), $data = null): string {} - - /** - * Assigns default values to generated tags by helpers - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute('name', 'peter'); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * ``` - * - * @param string $name - * @param mixed $value - * @return Tag - */ - public function setAttribute(string $name, $value): Tag {} - - /** - * Assigns default values to generated tags by helpers - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * // Assigning 'peter' to 'name' component - * $tag->setAttribute( - * [ - * 'name' => 'peter', - * ] - * ); - * - * // Later in the view - * echo $tag->inputText('name'); // Will have the value 'peter' by default - * ``` - * - * @param array $values - * @param bool $merge - * @return Tag - */ - public function setAttributes(array $values, bool $merge = false): Tag {} - - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Set the document type of content - * - * @param int $doctype - * @return Tag - */ - public function setDocType(int $doctype): Tag {} - - /** - * Set the title separator of view content - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * $tag->setTitle('Phalcon Framework'); - * ``` - * - * @param string $title - * @return Tag - */ - public function setTitle(string $title): Tag {} - - /** - * Set the title separator of view content - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->setTitleSeparator('-'); - * ``` - * - * @param string $separator - * @return Tag - */ - public function setTitleSeparator(string $separator): Tag {} - - /** - * Builds a LINK[rel="stylesheet"] tag - * - * Parameters - * `local` Local resource or not (default `true`) - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->stylesheet( - * 'http://fonts.googleapis.com/css?family=Rosario', - * [ - * 'local' => false, - * ] - * ); - * - * echo $tag->stylesheet('css/style.css'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ stylesheet('http://fonts.googleapis.com/css?family=Rosario', ['local': false]) }}{% endraw %} - * {% raw %}{{ stylesheet('css/style.css') }}{% endraw %} - * ``` - * - * @param string $url - * @param array $parameters - * @return string - */ - public function stylesheet(string $url, array $parameters = array()): string {} - - /** - * Builds a HTML input[type="submit"] tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->submit('Save'); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ submit('Save') }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function submit(string $name, array $parameters = array()): string {} - - /** - * Builds a HTML TEXTAREA tag - * - * ```php - * use Phalcon\Html\Tag; - * - * $tag = new Tag(); - * - * echo $tag->textArea( - * 'comments', - * [ - * 'cols' => 10, - * 'rows' => 4, - * ] - * ); - * ``` - * - * Volt syntax: - * ```php - * {% raw %}{{ text_area('comments', ['cols': 10, 'rows': 4]) }}{% endraw %} - * ``` - * - * @param string $name - * @param array $parameters - * @return string - */ - public function textArea(string $name, array $parameters = array()): string {} - - /** - * Returns the escaper service from the DI container - * - * @param string $name - */ - private function getService(string $name) {} - - /** - * Renders the attributes of an HTML element - * - * @param string $code - * @param array $attributes - * @return string - */ - private function renderAttributes(string $code, array $attributes): string {} - - /** - * Returns the closing tag depending on the doctype - * - * @param bool $addEol - * @return string - */ - private function renderCloseTag(bool $addEol = false): string {} - - /** - * Builds `input` elements - * - * @param string $type - * @param string $name - * @param array $parameters - * @return string - */ - private function renderInput(string $type, string $name, array $parameters = array()): string {} - - /** - * Builds INPUT tags that implements the checked attribute - * - * @param string $type - * @param string $name - * @param array $parameters - * @return string - */ - private function renderInputChecked(string $type, string $name, array $parameters = array()): string {} - - /** - * Generates the option values or optgroup from an array - * - * @param array $options - * @param mixed $value - * @param string $closeOption - * @return string - */ - private function renderSelectArray(array $options, $value, string $closeOption): string {} - - /** - * Generates the option values from a resultset - * - * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset - * @param mixed $using - * @param mixed $value - * @param string $closeOption - * @return string - */ - private function renderSelectResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string {} - -} diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php index 3621c52c..73baf876 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/html/TagFactory.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Factory\AbstractFactory; + /** * ServiceLocator implementation for Tag helpers */ -class TagFactory extends \Phalcon\Factory\AbstractFactory +class TagFactory extends AbstractFactory { /** * @var diff --git a/src/Phalcon/html/attributes/AttributesInterface.php b/src/Phalcon/html/attributes/AttributesInterface.php index 248939b8..e3e60ffc 100644 --- a/src/Phalcon/html/attributes/AttributesInterface.php +++ b/src/Phalcon/html/attributes/AttributesInterface.php @@ -1,12 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Attributes; +use Phalcon\Html\Attributes; + /** - * Phalcon\Html\Attributes\AttributesInterface - * - * Interface Phalcon\Html\Attributes\AttributesInterface - */ +* Phalcon\Html\Attributes\AttributesInterface +* +* Interface Phalcon\Html\Attributes\AttributesInterface +*/ interface AttributesInterface { diff --git a/src/Phalcon/html/attributes/RenderInterface.php b/src/Phalcon/html/attributes/RenderInterface.php index 4d1574b3..455f9fde 100644 --- a/src/Phalcon/html/attributes/RenderInterface.php +++ b/src/Phalcon/html/attributes/RenderInterface.php @@ -1,12 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Attributes; /** - * Phalcon\Html\Attributes\RenderInterface - * - * Interface Phalcon\Html\Attributes\RenderInterface - */ +* Phalcon\Html\Attributes\RenderInterface +* +* Interface Phalcon\Html\Attributes\RenderInterface +*/ interface RenderInterface { diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/html/helper/AbstractHelper.php index b1b95248..80b7e92f 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/html/helper/AbstractHelper.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; +use Phalcon\Escaper\EscaperInterface; + /** * Phalcon\Html\Helper\AbstractHelper * diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 5e8646d1..80f9cd36 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates an anchor */ -class Anchor extends \Phalcon\Html\Helper\AbstractHelper +class Anchor extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php index 1bdb84b7..6bf57784 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a raw anchor */ -class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper +class AnchorRaw extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Body.php b/src/Phalcon/html/helper/Body.php index a7b31fb1..955484b7 100644 --- a/src/Phalcon/html/helper/Body.php +++ b/src/Phalcon/html/helper/Body.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a body tag */ -class Body extends \Phalcon\Html\Helper\AbstractHelper +class Body extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/html/helper/Button.php index efee2b5e..87ae74d4 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/html/helper/Button.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a button tag */ -class Button extends \Phalcon\Html\Helper\AbstractHelper +class Button extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Close.php b/src/Phalcon/html/helper/Close.php index ced9b89e..6f6e3b65 100644 --- a/src/Phalcon/html/helper/Close.php +++ b/src/Phalcon/html/helper/Close.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a closing tag */ -class Close extends \Phalcon\Html\Helper\AbstractHelper +class Close extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/html/helper/Element.php index 60334197..065a7237 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/html/helper/Element.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates an element */ -class Element extends \Phalcon\Html\Helper\AbstractHelper +class Element extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/ElementRaw.php b/src/Phalcon/html/helper/ElementRaw.php index 53162a69..0b4e12ed 100644 --- a/src/Phalcon/html/helper/ElementRaw.php +++ b/src/Phalcon/html/helper/ElementRaw.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; +use Phalcon\Html\Exception; + /** * Phalcon\Html\Helper\ElementRaw * * Creates an element raw */ -class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper +class ElementRaw extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/html/helper/Form.php index 8358998d..ddc17d69 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/html/helper/Form.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a form opening tag */ -class Form extends \Phalcon\Html\Helper\AbstractHelper +class Form extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Img.php b/src/Phalcon/html/helper/Img.php index 72ac9296..8f3dcb79 100644 --- a/src/Phalcon/html/helper/Img.php +++ b/src/Phalcon/html/helper/Img.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; +use Phalcon\Html\Exception; + /** * Phalcon\Html\Helper\Img * * Creates am img tag */ -class Img extends \Phalcon\Html\Helper\AbstractHelper +class Img extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/Label.php b/src/Phalcon/html/helper/Label.php index 3000ab94..0487ecc3 100644 --- a/src/Phalcon/html/helper/Label.php +++ b/src/Phalcon/html/helper/Label.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; +use Phalcon\Html\Exception; + /** * Phalcon\Html\Helper\Label * * Creates a label */ -class Label extends \Phalcon\Html\Helper\AbstractHelper +class Label extends AbstractHelper { /** diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/html/helper/TextArea.php index 98c5e501..ecf797a2 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/html/helper/TextArea.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Html\Helper; /** @@ -7,7 +16,7 @@ * * Creates a textarea tag */ -class TextArea extends \Phalcon\Html\Helper\AbstractHelper +class TextArea extends AbstractHelper { /** diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/http/Cookie.php index e5edf3d5..236df2ef 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/http/Cookie.php @@ -1,16 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; +use Phalcon\Di\AbstractInjectionAware; + /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie implements \Phalcon\Http\CookieInterface, \Phalcon\Di\InjectionAwareInterface +class Cookie extends AbstractInjectionAware implements CookieInterface { - protected $container; - - protected $domain; @@ -76,13 +84,6 @@ public function __toString(): string {} */ public function delete() {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the domain that the cookie is available to * @@ -162,13 +163,6 @@ public function restore(): CookieInterface {} */ public function send(): CookieInterface {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets the domain that the cookie is available to * diff --git a/src/Phalcon/http/CookieInterface.php b/src/Phalcon/http/CookieInterface.php index afbf0c44..90e58390 100644 --- a/src/Phalcon/http/CookieInterface.php +++ b/src/Phalcon/http/CookieInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; /** diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/http/Request.php index 47882ff7..0f2c08ea 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/http/Request.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Filter\FilterInterface; + /** * Encapsulates request information for easy and secure access from application * controllers. @@ -9,7 +21,7 @@ * The request object is a simple value object that is passed between the * dispatcher and controller classes. It packages the HTTP request environment. * - * ```php + *```php * use Phalcon\Http\Request; * * $request = new Request(); @@ -26,14 +38,11 @@ * * // An array of languages the client accepts * $request->getLanguages(); - * ``` + *``` */ -class Request implements \Phalcon\Http\RequestInterface, \Phalcon\Di\InjectionAwareInterface +class Request extends AbstractInjectionAware implements RequestInterface { - private $container; - - private $filterService; /** @@ -154,13 +163,6 @@ public function getClientCharsets(): array {} */ public function getContentType(): ?string {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Gets auth info accepted by the browser/client from * $_SERVER["PHP_AUTH_DIGEST"] @@ -422,11 +424,20 @@ public function getServerName(): string {} public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array {} /** - * Gets HTTP URI which request has been made + * Gets HTTP URI which request has been made to + * + * ```php + * // Returns /some/path?with=queryParams + * $uri = $request->getURI(); + * + * // Returns /some/path + * $uri = $request->getURI(true); + * ``` * + * @param bool $onlyPath If true, query part will be omitted * @return string */ - final public function getURI(): string {} + final public function getURI(bool $onlyPath = false): string {} /** * Gets HTTP user agent used to made the request @@ -620,13 +631,6 @@ public function isTrace(): bool {} */ public function isValidHttpMethod(string $method): bool {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets automatic sanitizers/filters for a particular field and for * particular methods diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 853091b0..025ae088 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; /** @@ -212,11 +221,20 @@ public function getMethod(): string; public function getPort(): int; /** - * Gets HTTP URI which request has been made + * Gets HTTP URI which request has been made to + * + * ```php + * // Returns /some/path?with=queryParams + * $uri = $request->getURI(); + * + * // Returns /some/path + * $uri = $request->getURI(true); + * ``` * + * @param bool $onlyPath If true, query part will be omitted * @return string */ - final public function getURI(): string; + public function getURI(bool $onlyPath = false): string; /** * Gets a variable from the $_POST superglobal applying filters if needed diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 31051ef3..2a397a26 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -1,22 +1,38 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Http\Response\HeadersInterface; + /** * Part of the HTTP cycle is return responses to the clients. * Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. * HTTP responses are usually composed by headers and body. * - * ```php + *```php * $response = new \Phalcon\Http\Response(); * * $response->setStatusCode(200, "OK"); * $response->setContent("Hello"); * * $response->send(); - * ``` + *``` */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Response implements ResponseInterface, InjectionAwareInterface, EventsAwareInterface { protected $container; diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index d3176976..c9974ddc 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http; +use Phalcon\Http\Response\HeadersInterface; + /** * Phalcon\Http\Response * diff --git a/src/Phalcon/http/cookie/Exception.php b/src/Phalcon/http/cookie/Exception.php index 17582b55..6775aefc 100644 --- a/src/Phalcon/http/cookie/Exception.php +++ b/src/Phalcon/http/cookie/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Cookie; /** diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php index 99f4f9c7..45a52c69 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -1,5 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; /** diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/http/message/AbstractMessage.php index ac7fcda0..693afd56 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/http/message/AbstractMessage.php @@ -1,11 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Phalcon\Collection; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + /** * Message methods */ -abstract class AbstractMessage extends \Phalcon\Http\Message\AbstractCommon +abstract class AbstractMessage extends AbstractCommon { /** * Gets the body of the message. diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php index 3fdf32fd..6a86b5c7 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -1,11 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\UriInterface; + /** * Request methods */ -abstract class AbstractRequest extends \Phalcon\Http\Message\AbstractMessage +abstract class AbstractRequest extends AbstractMessage { /** * Retrieves the HTTP method of the request. diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/http/message/Request.php index 84491eb3..1f8f9cb8 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/http/message/Request.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + /** * PSR-7 Request */ -final class Request extends \Phalcon\Http\Message\AbstractRequest implements \Psr\Http\Message\RequestInterface +final class Request extends AbstractRequest implements RequestInterface { /** diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/http/message/RequestFactory.php index e20bd9b0..6b3cd1d3 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/http/message/RequestFactory.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; + /** * PSR-17 RequestFactory */ -final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface +final class RequestFactory implements RequestFactoryInterface { /** diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/http/message/Response.php index 5c46a3c0..cd401bcf 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/http/message/Response.php @@ -1,11 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\ResponseInterface; + /** * PSR-7 Response */ -final class Response extends \Phalcon\Http\Message\AbstractMessage implements \Psr\Http\Message\ResponseInterface +final class Response extends AbstractMessage implements ResponseInterface { /** * Gets the response reason phrase associated with the status code. diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/http/message/ResponseFactory.php index 9aa39a71..98e588e7 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/http/message/ResponseFactory.php @@ -1,11 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ResponseInterface; + /** * PSR-17 ResponseFactory */ -final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterface +final class ResponseFactory implements ResponseFactoryInterface { /** diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/http/message/ServerRequest.php index 69ebfdaa..7c1f2243 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/http/message/ServerRequest.php @@ -1,11 +1,31 @@ +* +* For the full copyright and license information, please view the LICENSE.txt +* file that was distributed with this source code. +* +* Implementation of this file has been influenced by Zend Diactoros +* @link https://github.com/zendframework/zend-diactoros +* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md +*/ + namespace Phalcon\Http\Message; +use Phalcon\Collection; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriInterface; + /** * PSR-7 ServerRequest */ -final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implements \Psr\Http\Message\ServerRequestInterface +final class ServerRequest extends AbstractRequest implements ServerRequestInterface { /** * @var Collection @@ -255,8 +275,7 @@ public function withCookieParams(array $cookies): ServerRequest {} * * @param array|object|null $data * - * @throws InvalidArgumentException if an unsupported argument type is - * provided. + * @throws InvalidArgumentException if an unsupported argument type is provided. * * @param mixed $data * @return ServerRequest diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php index 2821ea96..815ac86e 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -1,11 +1,31 @@ +* +* For the full copyright and license information, please view the LICENSE.txt +* file that was distributed with this source code. +* +* Implementation of this file has been influenced by Zend Diactoros +* @link https://github.com/zendframework/zend-diactoros +* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md +*/ + namespace Phalcon\Http\Message; +use Phalcon\Collection; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\ServerRequestFactoryInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriInterface; + /** * PSR-17 ServerRequestFactory */ -class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInterface +class ServerRequestFactory implements ServerRequestFactoryInterface { /** diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/http/message/Stream.php index 3d61ce74..6085c3a6 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/http/message/Stream.php @@ -1,11 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\StreamInterface; + /** * PSR-7 Stream */ -class Stream implements \Psr\Http\Message\StreamInterface +class Stream implements StreamInterface { /** * @var resource | null @@ -64,7 +79,7 @@ public function close() {} * * @return resource|null */ - public function detach(): ? {} + public function detach() {} /** * Returns true if the stream is at the end of the stream. diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/http/message/StreamFactory.php index 12c1687b..0795e955 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/http/message/StreamFactory.php @@ -1,11 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\StreamInterface; + /** * PSR-17 StreamFactory */ -final class StreamFactory implements \Psr\Http\Message\StreamFactoryInterface +final class StreamFactory implements StreamFactoryInterface { /** diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/http/message/UploadedFile.php index bd30178d..f5581b31 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/http/message/UploadedFile.php @@ -1,11 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; +use RuntimeException; + /** * PSR-7 UploadedFile */ -final class UploadedFile implements \Psr\Http\Message\UploadedFileInterface +final class UploadedFile implements UploadedFileInterface { /** * If the file has already been moved, we hold that status here @@ -162,8 +180,7 @@ public function __construct($stream, int $size = null, int $error = 0, string $c * If the moveTo() method has been called previously, this method MUST * raise an exception. * - * @throws RuntimeException in cases when no stream is available or can be - * created. + * @throws RuntimeException in cases when no stream is available or can be created. * @return mixed */ public function getStream() {} diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/http/message/UploadedFileFactory.php index c87d18e1..158a0bc8 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/http/message/UploadedFileFactory.php @@ -1,11 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; + /** * PSR-17 UploadedFileFactory */ -final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactoryInterface +final class UploadedFileFactory implements UploadedFileFactoryInterface { /** diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/http/message/Uri.php index a0f019c2..41e46a17 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/http/message/Uri.php @@ -1,11 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Psr\Http\Message\UriInterface; + /** * PSR-7 Uri */ -final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Http\Message\UriInterface +final class Uri extends AbstractCommon implements UriInterface { /** * Returns the fragment of the URL diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/http/message/UriFactory.php index a708603d..c67ba3ab 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/http/message/UriFactory.php @@ -1,11 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message; +use Psr\Http\Message\UriFactoryInterface; +use Psr\Http\Message\UriInterface; + /** * PSR-17 UriFactory */ -final class UriFactory implements \Psr\Http\Message\UriFactoryInterface +final class UriFactory implements UriFactoryInterface { /** diff --git a/src/Phalcon/http/message/exception/InvalidArgumentException.php b/src/Phalcon/http/message/exception/InvalidArgumentException.php index 4d68bf7a..91f77fc1 100644 --- a/src/Phalcon/http/message/exception/InvalidArgumentException.php +++ b/src/Phalcon/http/message/exception/InvalidArgumentException.php @@ -1,16 +1,18 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class InvalidArgumentException extends InvalidArgumentException implements \Throwable + +namespace Phalcon\Http\Message\Exception; + +use Throwable; + +class InvalidArgumentException extends \InvalidArgumentException implements Throwable { } diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php index 40b7b316..8bd3bb86 100644 --- a/src/Phalcon/http/message/stream/Input.php +++ b/src/Phalcon/http/message/stream/Input.php @@ -1,7 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message\Stream; +use Phalcon\Http\Message\Stream; + /** * Describes a data stream from "php://input" * @@ -9,7 +24,7 @@ * a wrapper around the most common operations, including serialization of * the entire stream to a string. */ -class Input extends \Phalcon\Http\Message\Stream +class Input extends Stream { /** * @var string diff --git a/src/Phalcon/http/message/stream/Memory.php b/src/Phalcon/http/message/stream/Memory.php index f3a22de5..a2c7a765 100644 --- a/src/Phalcon/http/message/stream/Memory.php +++ b/src/Phalcon/http/message/stream/Memory.php @@ -1,7 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message\Stream; +use Phalcon\Http\Message\Stream; + /** * Describes a data stream from "php://memory" * @@ -9,7 +24,7 @@ * a wrapper around the most common operations, including serialization of * the entire stream to a string. */ -class Memory extends \Phalcon\Http\Message\Stream +class Memory extends Stream { /** diff --git a/src/Phalcon/http/message/stream/Temp.php b/src/Phalcon/http/message/stream/Temp.php index c8410a81..d79f1f1e 100644 --- a/src/Phalcon/http/message/stream/Temp.php +++ b/src/Phalcon/http/message/stream/Temp.php @@ -1,7 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + * + * Implementation of this file has been influenced by Zend Diactoros + * @link https://github.com/zendframework/zend-diactoros + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md + */ + namespace Phalcon\Http\Message\Stream; +use Phalcon\Http\Message\Stream; + /** * Describes a data stream from "php://temp" * @@ -9,7 +24,7 @@ * a wrapper around the most common operations, including serialization of * the entire stream to a string. */ -class Temp extends \Phalcon\Http\Message\Stream +class Temp extends Stream { /** diff --git a/src/Phalcon/http/request/Exception.php b/src/Phalcon/http/request/Exception.php index 9e91a792..31fe7927 100644 --- a/src/Phalcon/http/request/Exception.php +++ b/src/Phalcon/http/request/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Request; /** diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/http/request/File.php index 5935775d..56524bff 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/http/request/File.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Request; /** @@ -7,7 +16,7 @@ * * Provides OO wrappers to the $_FILES superglobal * - * ```php + *```php * use Phalcon\Mvc\Controller; * * class PostsController extends Controller @@ -23,9 +32,9 @@ * } * } * } - * ``` + *``` */ -class File implements \Phalcon\Http\Request\FileInterface +class File implements FileInterface { /** * @var string|null diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 69f37a10..13694730 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -1,11 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Request; /** * Phalcon\Http\Request\FileInterface * * Interface for Phalcon\Http\Request\File + * */ interface FileInterface { diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 8e63b483..4c0ebad5 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Response; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Http\CookieInterface; + /** * Phalcon\Http\Response\Cookies * @@ -41,7 +53,7 @@ * * // The `$key' MUST be at least 32 characters long and generated using a * // cryptographically secure pseudo random generator. - * $key = "#1dj8$=dp?.ak//j1V$~%0XaK\xb1\x8d\xa9\x98\x054t7w!z%CF-Jk\x98\x05\\\x5c"; + * $key = "#1dj8$=dp?.ak//j1V$~%*0XaK\xb1\x8d\xa9\x98\x054t7w!z%C*F-Jk\x98\x05\\\x5c"; * * $cookies->setSignKey($key); * @@ -50,12 +62,9 @@ * ); * ``` */ -class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\InjectionAwareInterface +class Cookies extends AbstractInjectionAware implements CookiesInterface { - protected $container; - - protected $cookies = array(); @@ -104,13 +113,6 @@ public function get(string $name): CookieInterface {} */ public function getCookies(): array {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Check if a cookie is defined in the bag or exists in the _COOKIE * superglobal @@ -172,13 +174,6 @@ public function send(): bool {} */ public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets the cookie's sign key. * diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index abe18b6f..8a9f444a 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Response; +use Phalcon\Http\CookieInterface; + /** * Phalcon\Http\Response\CookiesInterface * diff --git a/src/Phalcon/http/response/Exception.php b/src/Phalcon/http/response/Exception.php index fd5fcc03..ab723a39 100644 --- a/src/Phalcon/http/response/Exception.php +++ b/src/Phalcon/http/response/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Response; /** diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 31f52cbd..b85d7655 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Response; /** @@ -7,7 +16,7 @@ * * This class is a bag to manage the response headers */ -class Headers implements \Phalcon\Http\Response\HeadersInterface +class Headers implements HeadersInterface { protected $headers = array(); @@ -33,8 +42,9 @@ public function has(string $name): bool {} * Removes a header to be sent at the end of the request * * @param string $header + * @return \Phalcon\Http\Response\HeadersInterface */ - public function remove(string $header) {} + public function remove(string $header): HeadersInterface {} /** * Reset set headers @@ -53,15 +63,17 @@ public function send(): bool {} * * @param string $name * @param string $value + * @return \Phalcon\Http\Response\HeadersInterface */ - public function set(string $name, string $value) {} + public function set(string $name, string $value): HeadersInterface {} /** * Sets a raw header to be sent at the end of the request * * @param string $header + * @return \Phalcon\Http\Response\HeadersInterface */ - public function setRaw(string $header) {} + public function setRaw(string $header): HeadersInterface {} /** * Returns the current headers as an array diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index a2b439a8..d1aee9cf 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Response; /** diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php index 8f3353b7..e160d1cc 100644 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -1,7 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Server; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\MiddlewareInterface; +use Psr\Http\Server\RequestHandlerInterface; + /** * Participant in processing a server request and response. * @@ -9,7 +23,7 @@ * by acting on the request, generating the response, or forwarding the * request to a subsequent middleware and possibly acting on its response. */ -abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterface +abstract class AbstractMiddleware implements MiddlewareInterface { /** diff --git a/src/Phalcon/http/server/AbstractRequestHandler.php b/src/Phalcon/http/server/AbstractRequestHandler.php index 397062be..5bf1e601 100644 --- a/src/Phalcon/http/server/AbstractRequestHandler.php +++ b/src/Phalcon/http/server/AbstractRequestHandler.php @@ -1,14 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Http\Server; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; + /** * Handles a server request and produces a response. * * An HTTP request handler process an HTTP request in order to produce an * HTTP response. */ -abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandlerInterface +abstract class AbstractRequestHandler implements RequestHandlerInterface { /** diff --git a/src/Phalcon/image/Enum.php b/src/Phalcon/image/Enum.php index cfba69b5..ef2aad5c 100644 --- a/src/Phalcon/image/Enum.php +++ b/src/Phalcon/image/Enum.php @@ -1,15 +1,16 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Image; + class Enum { diff --git a/src/Phalcon/image/Exception.php b/src/Phalcon/image/Exception.php index d590f857..47df7115 100644 --- a/src/Phalcon/image/Exception.php +++ b/src/Phalcon/image/Exception.php @@ -1,15 +1,16 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Image; + class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php index 234d2713..88a27cae 100644 --- a/src/Phalcon/image/ImageFactory.php +++ b/src/Phalcon/image/ImageFactory.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Image; +use Phalcon\Factory\AbstractFactory; +use Phalcon\Image\Adapter\AdapterInterface; + /** * Phalcon\Image/ImageFactory */ -class ImageFactory extends \Phalcon\Factory\AbstractFactory +class ImageFactory extends AbstractFactory { /** diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/image/adapter/AbstractAdapter.php index 131e59e4..eb8ce44a 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/image/adapter/AbstractAdapter.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Image\Adapter; +use Phalcon\Image\Enum; + /** * Phalcon\Image\Adapter * * All image adapters must use this class */ -abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { static protected $checked = false; @@ -93,17 +104,17 @@ public function getWidth(): int {} * * @param string $color * @param int $opacity - * @return Adapter + * @return AdapterInterface */ - public function background(string $color, int $opacity = 100): Adapter {} + public function background(string $color, int $opacity = 100): AdapterInterface {} /** * Blur image * * @param int $radius - * @return Adapter + * @return AdapterInterface */ - public function blur(int $radius): Adapter {} + public function blur(int $radius): AdapterInterface {} /** * Crop an image to the given size @@ -112,17 +123,17 @@ public function blur(int $radius): Adapter {} * @param int $height * @param int $offsetX * @param int $offsetY - * @return Adapter + * @return AdapterInterface */ - public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null): Adapter {} + public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null): AdapterInterface {} /** * Flip the image along the horizontal or vertical axis * * @param int $direction - * @return Adapter + * @return AdapterInterface */ - public function flip(int $direction): Adapter {} + public function flip(int $direction): AdapterInterface {} /** * This method scales the images using liquid rescaling method. Only support @@ -132,25 +143,25 @@ public function flip(int $direction): Adapter {} * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. - * @return Adapter + * @return AbstractAdapter */ - public function liquidRescale(int $width, int $height, int $deltaX = 0, int $rigidity = 0): Adapter {} + public function liquidRescale(int $width, int $height, int $deltaX = 0, int $rigidity = 0): AbstractAdapter {} /** * Composite one image onto another * * @param AdapterInterface $watermark - * @return Adapter + * @return AdapterInterface */ - public function mask(AdapterInterface $watermark): Adapter {} + public function mask(AdapterInterface $watermark): AdapterInterface {} /** * Pixelate image * * @param int $amount - * @return Adapter + * @return AdapterInterface */ - public function pixelate(int $amount): Adapter {} + public function pixelate(int $amount): AdapterInterface {} /** * Add a reflection to an image @@ -158,9 +169,9 @@ public function pixelate(int $amount): Adapter {} * @param int $height * @param int $opacity * @param bool $fadeIn - * @return Adapter + * @return AdapterInterface */ - public function reflection(int $height, int $opacity = 100, bool $fadeIn = false): Adapter {} + public function reflection(int $height, int $opacity = 100, bool $fadeIn = false): AdapterInterface {} /** * Render the image and return the binary string @@ -177,34 +188,34 @@ public function render(string $ext = null, int $quality = 100): string {} * @param int $width * @param int $height * @param int $master - * @return Adapter + * @return AdapterInterface */ - public function resize(int $width = null, int $height = null, int $master = Enum::AUTO): Adapter {} + public function resize(int $width = null, int $height = null, int $master = Enum::AUTO): AdapterInterface {} /** * Rotate the image by a given amount * * @param int $degrees - * @return Adapter + * @return AdapterInterface */ - public function rotate(int $degrees): Adapter {} + public function rotate(int $degrees): AdapterInterface {} /** * Save the image * * @param string $file * @param int $quality - * @return Adapter + * @return AdapterInterface */ - public function save(string $file = null, int $quality = -1): Adapter {} + public function save(string $file = null, int $quality = -1): AdapterInterface {} /** * Sharpen the image by a given amount * * @param int $amount - * @return Adapter + * @return AdapterInterface */ - public function sharpen(int $amount): Adapter {} + public function sharpen(int $amount): AdapterInterface {} /** * Add a text to an image with a specified opacity @@ -216,9 +227,9 @@ public function sharpen(int $amount): Adapter {} * @param string $color * @param int $size * @param string $fontfile - * @return Adapter + * @return AdapterInterface */ - public function text(string $text, $offsetX = false, $offsetY = false, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null): Adapter {} + public function text(string $text, $offsetX = false, $offsetY = false, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null): AdapterInterface {} /** * Add a watermark to an image with the specified opacity @@ -227,8 +238,8 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac * @param int $offsetX * @param int $offsetY * @param int $opacity - * @return Adapter + * @return AdapterInterface */ - public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): Adapter {} + public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface {} } diff --git a/src/Phalcon/image/adapter/AdapterInterface.php b/src/Phalcon/image/adapter/AdapterInterface.php index 2ee99371..96886a82 100644 --- a/src/Phalcon/image/adapter/AdapterInterface.php +++ b/src/Phalcon/image/adapter/AdapterInterface.php @@ -1,87 +1,102 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Image\Adapter; + +use Phalcon\Image\Enum; + interface AdapterInterface { /** * @param string $color * @param int $opacity + * @return AdapterInterface */ - public function background(string $color, int $opacity = 100); + public function background(string $color, int $opacity = 100): AdapterInterface; /** * @param int $radius + * @return AdapterInterface */ - public function blur(int $radius); + public function blur(int $radius): AdapterInterface; /** * @param int $width * @param int $height * @param int $offsetX * @param int $offsetY + * @return AdapterInterface */ - public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null); + public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null): AdapterInterface; /** * @param int $direction + * @return AdapterInterface */ - public function flip(int $direction); + public function flip(int $direction): AdapterInterface; /** * @param AdapterInterface $watermark + * @return AdapterInterface */ - public function mask(AdapterInterface $watermark); + public function mask(AdapterInterface $watermark): AdapterInterface; /** * @param int $amount + * @return AdapterInterface */ - public function pixelate(int $amount); + public function pixelate(int $amount): AdapterInterface; /** * @param int $height * @param int $opacity * @param bool $fadeIn + * @return AdapterInterface */ - public function reflection(int $height, int $opacity = 100, bool $fadeIn = false); + public function reflection(int $height, int $opacity = 100, bool $fadeIn = false): AdapterInterface; /** * @param string $ext * @param int $quality + * @return string */ - public function render(string $ext = null, int $quality = 100); + public function render(string $ext = null, int $quality = 100): string; /** * @param int $width * @param int $height * @param int $master + * @return AdapterInterface */ - public function resize(int $width = null, int $height = null, int $master = Image::AUTO); + public function resize(int $width = null, int $height = null, int $master = Enum::AUTO): AdapterInterface; /** * @param int $degrees + * @return AdapterInterface */ - public function rotate(int $degrees); + public function rotate(int $degrees): AdapterInterface; /** * @param string $file * @param int $quality + * @return AdapterInterface */ - public function save(string $file = null, int $quality = 100); + public function save(string $file = null, int $quality = 100): AdapterInterface; /** * @param int $amount + * @return AdapterInterface */ - public function sharpen(int $amount); + public function sharpen(int $amount): AdapterInterface; /** * @param string $text @@ -91,15 +106,17 @@ public function sharpen(int $amount); * @param string $color * @param int $size * @param string $fontfile + * @return AdapterInterface */ - public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null); + public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null): AdapterInterface; /** * @param AdapterInterface $watermark * @param int $offsetX * @param int $offsetY * @param int $opacity + * @return AdapterInterface */ - public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100); + public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; } diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index e8769205..0e3715c3 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Gd extends \Phalcon\Image\Adapter\AbstractAdapter + +namespace Phalcon\Image\Adapter; + +class Gd extends AbstractAdapter { static protected $checked = false; diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 6164a769..5599ec72 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Image\Adapter; +use Imagick as ImagicNative; + /** * Phalcon\Image\Adapter\Imagick * * Image manipulation support. Allows images to be resized, cropped, etc. * - * ```php + *```php * $image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg"); * * $image->resize(200, 200)->rotate(90)->crop(100, 100); @@ -15,9 +26,9 @@ * if ($image->save()) { * echo "success"; * } - * ``` + *``` */ -class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter +class Imagick extends AbstractAdapter { static protected $checked = false; @@ -52,7 +63,7 @@ public static function check(): bool {} * * @return \Imagick */ - public function getInternalImInstance(): \Imagick {} + public function getInternalImInstance(): ImagicNative {} /** * Sets the limit for a particular resource in megabytes diff --git a/src/Phalcon/loader/Exception.php b/src/Phalcon/loader/Exception.php index c8bdf86b..aa24bf20 100644 --- a/src/Phalcon/loader/Exception.php +++ b/src/Phalcon/loader/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Loader; /** diff --git a/src/Phalcon/logger/AdapterFactory.php b/src/Phalcon/logger/AdapterFactory.php index 584e6b12..f3f81b71 100644 --- a/src/Phalcon/logger/AdapterFactory.php +++ b/src/Phalcon/logger/AdapterFactory.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AdapterFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Logger; + +use Phalcon\Factory\AbstractFactory; + +class AdapterFactory extends AbstractFactory { /** diff --git a/src/Phalcon/logger/Exception.php b/src/Phalcon/logger/Exception.php index 8569a5a3..a319d041 100644 --- a/src/Phalcon/logger/Exception.php +++ b/src/Phalcon/logger/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger; /** diff --git a/src/Phalcon/logger/Item.php b/src/Phalcon/logger/Item.php index 271fef8d..86093fe3 100644 --- a/src/Phalcon/logger/Item.php +++ b/src/Phalcon/logger/Item.php @@ -1,11 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger; /** * Phalcon\Logger\Item * * Represents each item in a logging transaction + * */ class Item { diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php index a53c608b..555c5b40 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/logger/LoggerFactory.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger; +use Phalcon\Logger; + /** * PhalconNG\Logger\LoggerFactory * @@ -35,7 +46,7 @@ public function load($config) {} * * @param string $name * @param array $adapters - * @return \Phalcon\Logger\Logger + * @return \Phalcon\Logger */ public function newInstance(string $name, array $adapters = array()): Logger {} diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/logger/adapter/AbstractAdapter.php index 5ec710f7..d11b36df 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/logger/adapter/AbstractAdapter.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface + +namespace Phalcon\Logger\Adapter; + +use Phalcon\Logger\Formatter\FormatterInterface; + +abstract class AbstractAdapter implements AdapterInterface { /** * Name of the default formatter class diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php index b9317e56..2afb8a47 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Formatter\FormatterInterface; + /** * Phalcon\Logger\AdapterInterface * @@ -14,8 +25,9 @@ interface AdapterInterface * Adds a message in the queue * * @param \Phalcon\Logger\Item $item + * @return AdapterInterface */ - public function add(\Phalcon\Logger\Item $item); + public function add(\Phalcon\Logger\Item $item): AdapterInterface; /** * Starts a transaction diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 9f2e6578..485e56f0 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Adapter; /** @@ -7,16 +16,16 @@ * * Adapter to store logs in plain text files * - * ```php + *```php * $logger = new \Phalcon\Logger\Adapter\Noop(); * * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); * * $logger->close(); - * ``` + *``` */ -class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter +class Noop extends AbstractAdapter { /** diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 94b479a3..dc25852c 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Adapter; /** @@ -7,7 +16,7 @@ * * Adapter to store logs in plain text files * - * ```php + *```php * $logger = new \Phalcon\Logger\Adapter\Stream("app/logs/test.log"); * * $logger->log("This is a message"); @@ -15,9 +24,9 @@ * $logger->error("This is another error"); * * $logger->close(); - * ``` + *``` */ -class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * Stream handler resource diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index 14c95796..b759f02e 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Adapter; /** @@ -23,9 +32,9 @@ * $logger->log("This is a message"); * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - * ``` + *``` */ -class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter +class Syslog extends AbstractAdapter { /** * Name of the default formatter class diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php index 9049eb11..a70fa18b 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface + +namespace Phalcon\Logger\Formatter; + +abstract class AbstractFormatter implements FormatterInterface { /** diff --git a/src/Phalcon/logger/formatter/FormatterInterface.php b/src/Phalcon/logger/formatter/FormatterInterface.php index 0aaf8bd2..0e09b641 100644 --- a/src/Phalcon/logger/formatter/FormatterInterface.php +++ b/src/Phalcon/logger/formatter/FormatterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Formatter; /** diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index a1552d6a..f0f17344 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Formatter; /** @@ -7,7 +16,7 @@ * * Formats messages using JSON encoding */ -class Json extends \Phalcon\Logger\Formatter\AbstractFormatter +class Json extends AbstractFormatter { /** * Default date format diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index b575d37d..905ba9c7 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Formatter\Formatter; + /** * Phalcon\Logger\Formatter\Line * * Formats messages using an one-line string */ -class Line extends \Phalcon\Logger\Formatter\AbstractFormatter +class Line extends AbstractFormatter { /** * Default date format diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 6f886239..6b01a514 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Logger\Formatter; /** @@ -7,7 +16,7 @@ * * Prepares a message to be used in a Syslog backend */ -class Syslog extends \Phalcon\Logger\Formatter\AbstractFormatter +class Syslog extends AbstractFormatter { /** diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php index bca86886..f1cab232 100644 --- a/src/Phalcon/messages/Exception.php +++ b/src/Phalcon/messages/Exception.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Messages; /** * Phalcon\Validation\Exception * - * Exceptions thrown in Phalcon\Messages\ classes will use this class + * Exceptions thrown in Phalcon\Messages\* classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index e1d94052..f03e0447 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Messages; +use JsonSerializable; + /** * Phalcon\Messages\Message * * Stores a message from various components */ -class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable +class Message implements MessageInterface, JsonSerializable { /** * @var int diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php index 550abcfa..53908db3 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/messages/MessageInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Messages; /** diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/messages/Messages.php index 13c2c3ec..c4ba0b73 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/messages/Messages.php @@ -1,11 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Messages; +use ArrayAccess; +use Countable; +use Iterator; +use JsonSerializable; + /** * Represents a collection of messages */ -class Messages implements \ArrayAccess, \Countable, \Iterator, \JsonSerializable +class Messages implements ArrayAccess, Countable, Iterator, JsonSerializable { /** * @var int diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 9faf4966..cffcdf7c 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Application\AbstractApplication; + /** * Phalcon\Mvc\Application * @@ -9,23 +20,23 @@ * every component needed and integrating it with the rest to allow the MVC * pattern to operate as desired. * - * ```php + *```php * use Phalcon\Mvc\Application; * * class MyApp extends Application * { - * / - * Register the services here to make them general or register - * in the ModuleDefinition to make them module-specific - * \/ + * /** + * * Register the services here to make them general or register + * * in the ModuleDefinition to make them module-specific + * *\/ * protected function registerServices() * { * * } * - * / - * This method registers all the modules in the application - * \/ + * /** + * * This method registers all the modules in the application + * *\/ * public function main() * { * $this->registerModules( @@ -46,9 +57,9 @@ * $application = new MyApp(); * * $application->main(); - * ``` + *``` */ -class Application extends \Phalcon\Application\AbstractApplication +class Application extends AbstractApplication { protected $implicitView = true; diff --git a/src/Phalcon/mvc/Collection.php b/src/Phalcon/mvc/Collection.php deleted file mode 100644 index a5dbf4ae..00000000 --- a/src/Phalcon/mvc/Collection.php +++ /dev/null @@ -1,664 +0,0 @@ -name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - * ``` - * - * @param \Phalcon\Messages\MessageInterface $message - */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} - - /** - * Returns a cloned collection - * - * @param CollectionInterface $collection - * @param array $document - * @return CollectionInterface - */ - public static function cloneResult(CollectionInterface $collection, array $document): CollectionInterface {} - - /** - * Creates a collection based on the values in the attributes - * - * @return bool - */ - public function create(): bool {} - - /** - * Creates a document based on the values in the attributes, if not found by - * criteria. Preferred way to avoid duplication is to create index o - * attribute - * - * ```php - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * ``` - * - * @param array $criteria - * @return bool - */ - public function createIfNotExist(array $criteria): bool {} - - /** - * Perform a count over a collection - * - * ```php - * echo "There are ", Robots::count(), " robots"; - * ``` - * - * @param array $parameters - * @return int - */ - public static function count(array $parameters = null): int {} - - /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * ```php - * $robot = Robots::findFirst(); - * - * $robot->delete(); - * - * $robots = Robots::find(); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * ``` - * - * @return bool - */ - public function delete(): bool {} - - /** - * Allows to query a set of records that match the specified conditions - * - * ```php - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * ``` - * - * @param array $parameters - * @return array - */ - public static function find(array $parameters = null): array {} - - /** - * Find a document by its id (_id) - * - * ```php - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * ``` - * - * @param mixed $id - * @return null|CollectionInterface - */ - public static function findById($id): ?CollectionInterface {} - - /** - * Allows to query the first record that match the specified conditions - * - * ```php - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * ``` - * - * @param array $parameters - * @return array - */ - public static function findFirst(array $parameters = null): array {} - - /** - * Fires an internal event - * - * @param string $eventName - * @return bool - */ - public function fireEvent(string $eventName): bool {} - - /** - * Fires an internal event that cancels the operation - * - * @param string $eventName - * @return bool - */ - public function fireEventCancel(string $eventName): bool {} - - /** - * Returns the models manager related to the entity instance - * - * @return \Phalcon\Mvc\Collection\ManagerInterface - */ - public function getCollectionManager(): ManagerInterface {} - - /** - * Retrieves a database connection - * - * @return \MongoDb - */ - public function getConnection() {} - - /** - * Returns DependencyInjection connection service - * - * @return string - */ - public function getConnectionService(): string {} - - /** - * Returns the dependency injection container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns one of the DIRTY_STATE_ constants telling if the document exists - * in the collection or not - * - * @return int - */ - public function getDirtyState(): int {} - - /** - * Returns the custom events manager - * - * @return \Phalcon\Mvc\Collection\ManagerInterface - */ - protected function getEventsManager(): ManagerInterface {} - - /** - * Returns the value of the _id property - * - * @return \MongoId - */ - public function getId() {} - - /** - * Returns all the validation messages - * - * ```php - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); - * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * ``` - * - * @return array|\Phalcon\Messages\MessageInterface[] - */ - public function getMessages(): array {} - - /** - * Returns an array with reserved properties that cannot be part of the - * insert/update - * - * @return array - */ - public function getReservedAttributes(): array {} - - /** - * Returns collection name mapped in the model - * - * @return string - */ - public function getSource(): string {} - - /** - * Reads an attribute value by its name - * - * ```php - * echo $robot->readAttribute("name"); - * ``` - * - * @param string $attribute - * @return mixed|null - */ - public function readAttribute(string $attribute): ? {} - - /** - * Creates/Updates a collection based on the values in the attributes - * - * @return bool - */ - public function save(): bool {} - - /** - * Serializes the object ignoring connections or protected properties - * - * @return string - */ - public function serialize(): string {} - - /** - * Sets the DependencyInjection connection service name - * - * @param string $connectionService - * @return Collection - */ - public function setConnectionService(string $connectionService): Collection {} - - /** - * Sets the dependency injection container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Sets the dirty state of the object using one of the DIRTY_STATE_ - * constants - * - * @param int $dirtyState - * @return CollectionInterface - */ - public function setDirtyState(int $dirtyState): CollectionInterface {} - - /** - * Sets a custom events manager - * - * @param \Phalcon\Mvc\Collection\ManagerInterface $eventsManager - */ - protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {} - - /** - * Sets a value for the _id property, creates a MongoId object if needed - * - * @param mixed $id - */ - public function setId($id) {} - - /** - * Sets collection name which model should be mapped - * - * @param string $source - * @return Collection - */ - protected function setSource(string $source): Collection {} - - /** - * Skips the current operation forcing a success state - * - * @param bool $skip - */ - public function skipOperation(bool $skip) {} - - /** - * Allows to perform a summatory group for a column in the collection - * - * @param string $field - * @param mixed $conditions - * @param mixed $finalize - * @return array - */ - public static function summatory(string $field, $conditions = null, $finalize = null): array {} - - /** - * Returns the instance as an array representation - * - * ```php - * print_r( - * $robot->toArray() - * ); - * ``` - * - * @return array - */ - public function toArray(): array {} - - /** - * Unserializes the object from a serialized string - * - * @param mixed $data - */ - public function unserialize($data) {} - - /** - * Creates/Updates a collection based on the values in the attributes - * - * @return bool - */ - public function update(): bool {} - - /** - * Executes validators on every validation call - * - * ```php - * use Phalcon\Mvc\Collection; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - * ``` - * - * @param \Phalcon\Validation\ValidationInterface $validator - * @return bool - */ - protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} - - /** - * Sets if a model must use implicit objects ids - * - * @param bool $useImplicitObjectIds - */ - protected function useImplicitObjectIds(bool $useImplicitObjectIds) {} - - /** - * Writes an attribute value by its name - * - * ```php - * $robot->writeAttribute("name", "Rosey"); - * ``` - * - * @param string $attribute - * @param mixed $value - */ - public function writeAttribute(string $attribute, $value) {} - - /** - * Cancel the current operation - * - * @param bool $disableEvents - * @return bool - */ - protected function cancelOperation(bool $disableEvents): bool {} - - /** - * Checks if the document exists in the collection - * - * @param MongoCollection $collection - * @return bool - */ - protected function exists($collection): bool {} - - /** - * Perform a count over a resultset - * - * @param array $params - * @param Collection $collection - * @param \MongoDb $connection - * @return int - */ - protected static function getGroupResultset($params, Collection $collection, $connection): int {} - - /** - * Returns a collection resultset - * - * @param array $params - * @param CollectionInterface $collection - * @param \MongoDb $connection - * @param bool $unique - * @return array - */ - protected static function getResultset($params, CollectionInterface $collection, $connection, bool $unique) {} - - /** - * Executes internal hooks before save a document - * - * @param \Phalcon\Di\DiInterface $container - * @param bool $disableEvents - * @param bool $exists - * @return bool - */ - final protected function preSave(\Phalcon\Di\DiInterface $container, bool $disableEvents, bool $exists): bool {} - - /** - * Executes internal events after save a document - * - * @param bool $disableEvents - * @param bool $success - * @param bool $exists - * @return bool - */ - final protected function postSave(bool $disableEvents, bool $success, bool $exists): bool {} - - /** - * Shared Code for CU Operations - * Prepares Collection - */ - protected function prepareCU() {} - -} diff --git a/src/Phalcon/mvc/CollectionInterface.php b/src/Phalcon/mvc/CollectionInterface.php deleted file mode 100644 index ead5cdd5..00000000 --- a/src/Phalcon/mvc/CollectionInterface.php +++ /dev/null @@ -1,165 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Di\Injectable; + /** * Phalcon\Mvc\Controller * @@ -13,7 +24,7 @@ * interrogating the models for data, and passing that data on to the views for * presentation. * - * ```php + *```php * + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; /** diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index 50644e36..267a7fbe 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Dispatcher\AbstractDispatcher as BaseDispatcher; + /** * Dispatching is the process of taking the request object, extracting the * module name, controller name, action name, and optional parameters contained * in it, and then instantiating a controller and calling an action of that * controller. * - * ```php + *```php * $di = new \Phalcon\Di(); * * $dispatcher = new \Phalcon\Mvc\Dispatcher(); @@ -20,9 +31,9 @@ * $dispatcher->setParams([]); * * $controller = $dispatcher->dispatch(); - * ``` + *``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends BaseDispatcher implements DispatcherInterface { protected $defaultAction = 'index'; diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index 3019e142..af4d162f 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; + /** * Phalcon\Mvc\DispatcherInterface * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends DispatcherInterfaceBase { /** diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index ccff1790..bc6cf0b2 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; /** @@ -16,7 +25,7 @@ interface EntityInterface * @param string $attribute * @return mixed|null */ - public function readAttribute(string $attribute): ?; + public function readAttribute(string $attribute); /** * Writes an attribute value by its name diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index b1fba1ac..8bb31faa 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -1,7 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use ArrayAccess; +use Phalcon\Di\Injectable; +use Phalcon\Di\ServiceInterface; +use Phalcon\Mvc\Model\BinderInterface; +use Phalcon\Mvc\Router\RouteInterface; + /** * Phalcon\Mvc\Micro * @@ -10,7 +25,7 @@ * application. Micro applications are suitable to small applications, APIs and * prototypes in a practical way. * - * ```php + *```php * $app = new \Phalcon\Mvc\Micro(); * * $app->get( @@ -21,9 +36,9 @@ * ); * * $app->handle("/say/welcome/Phalcon"); - * ``` + *``` */ -class Micro extends \Phalcon\Di\Injectable implements \ArrayAccess +class Micro extends Injectable implements ArrayAccess { protected $activeHandler; diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 4778080b..317d0a62 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -1,7 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; +use JsonSerializable; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\ManagerInterface as EventsManagerInterface; +use Phalcon\Mvc\Model\CriteriaInterface; +use Phalcon\Mvc\Model\ManagerInterface; +use Phalcon\Mvc\Model\MetaDataInterface; +use Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\ResultInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Serializable; + /** * Phalcon\Mvc\Model * @@ -39,7 +60,7 @@ * } * ``` */ -abstract class Model implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable, \JsonSerializable +abstract class Model extends AbstractInjectionAware implements EntityInterface, ModelInterface, ResultInterface, Serializable, JsonSerializable { const DIRTY_STATE_DETACHED = 2; @@ -66,9 +87,6 @@ abstract class Model implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model const TRANSACTION_INDEX = 'transaction'; - protected $container; - - protected $dirtyState = 1; @@ -247,7 +265,6 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * // Allow assign only name and year * $robot->assign( * $_POST, - * null, * [ * "name", * "year", @@ -260,7 +277,6 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * * $robot->assign( * $_POST, - * null, * [ * "name", * "year", @@ -269,11 +285,11 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * ``` * * @param array $data - * @param array $dataColumnMap array to transform keys of data to another * @param array $whiteList + * @param array $dataColumnMap array to transform keys of data to another * @return \Phalcon\Mvc\ModelInterface */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface {} + public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface {} /** * Returns the average value on a column for a result-set of rows matching @@ -724,13 +740,6 @@ public function getChangedFields(): array {} */ public function getDirtyState(): int {} - /** - * Returns the dependency injection container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the custom events manager * @@ -1032,7 +1041,7 @@ public static function query(\Phalcon\Di\DiInterface $container = null): Criteri * @param string $attribute * @return mixed|null */ - public function readAttribute(string $attribute): ? {} + public function readAttribute(string $attribute) {} /** * Refreshes the model attributes re-querying the record from the database @@ -1086,9 +1095,8 @@ public function unserialize($data) {} * Sets the DependencyInjection connection service name * * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface */ - final public function setConnectionService(string $connectionService): ModelInterface {} + final public function setConnectionService(string $connectionService) {} /** * Sets the dirty state of the object using one of the DIRTY_STATE_ constants @@ -1098,13 +1106,6 @@ final public function setConnectionService(string $connectionService): ModelInte */ public function setDirtyState(int $dirtyState) {} - /** - * Sets the dependency injection container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets a custom events manager * @@ -1116,9 +1117,8 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * Sets the DependencyInjection connection service name used to read data * * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface */ - final public function setReadConnectionService(string $connectionService): ModelInterface {} + final public function setReadConnectionService(string $connectionService) {} /** * Sets the record's old snapshot data. @@ -1195,9 +1195,8 @@ public static function setup(array $options) {} * Sets the DependencyInjection connection service name used to write data * * @param string $connectionService - * @return \Phalcon\Mvc\ModelInterface */ - final public function setWriteConnectionService(string $connectionService): ModelInterface {} + final public function setWriteConnectionService(string $connectionService) {} /** * Skips the current operation forcing a success state diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index b65f6f6d..b090836f 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Mvc\Model\CriteriaInterface; +use Phalcon\Mvc\Model\MetaDataInterface; +use Phalcon\Mvc\Model\ResultsetInterface; + /** * Phalcon\Mvc\ModelInterface * @@ -14,7 +27,7 @@ interface ModelInterface * Appends a customized message on the validation process * * @param \Phalcon\Messages\MessageInterface $message - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface; @@ -22,12 +35,12 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * Assigns values to a model from an array * * @param array $data - * @param mixed $dataColumnMap * @param mixed $whiteList + * @param mixed $dataColumnMap * @param array $columnMap - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ - public function assign(array $data, $dataColumnMap = null, $whiteList = null): ModelInterface; + public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface; /** * Allows to calculate the average value on a column matching the specified @@ -41,12 +54,12 @@ public static function average($parameters = null): float; /** * Assigns values to a model from an array returning a new model * - * @param \Phalcon\Mvc\ModelInterface $base + * @param ModelInterface $base * @param array $data * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface; + public static function cloneResult(ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface; /** * Assigns values to a model from an array returning a new model @@ -56,7 +69,7 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * @param array $columnMap * @param int $dirtyState * @param bool $keepSnapshots - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; @@ -105,7 +118,7 @@ public static function find($parameters = null): ResultsetInterface; * Allows to query the first record that match the specified conditions * * @param array $parameters - * @return bool|\Phalcon\Mvc\ModelInterface + * @return bool|ModelInterface */ public static function findFirst($parameters = null); @@ -238,7 +251,7 @@ public static function query(\Phalcon\Di\DiInterface $container = null): Criteri /** * Refreshes the model attributes re-querying the record from the database * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function refresh(): ModelInterface; @@ -262,7 +275,7 @@ public function setConnectionService(string $connectionService); * constants * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return bool|ModelInterface */ public function setDirtyState(int $dirtyState); @@ -286,7 +299,7 @@ public function setSnapshotData(array $data, $columnMap = null); * Sets a transaction related to the Model instance * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface; diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index fe59a300..e6765205 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; /** diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index 852feabd..bc9a17e2 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -1,7 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Router\RouteInterface; + /** * Phalcon\Mvc\Router * @@ -30,7 +44,7 @@ * echo $router->getControllerName(); * ``` */ -class Router implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface +class Router extends AbstractInjectionAware implements RouterInterface, EventsAwareInterface { const POSITION_FIRST = 0; @@ -42,9 +56,6 @@ class Router implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Router protected $action = null; - protected $container; - - protected $controller = null; @@ -286,13 +297,6 @@ public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Ro */ public function clear() {} - /** - * Returns the internal dependency injector - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - /** * Returns the internal event manager * @@ -474,13 +478,6 @@ public function setDefaults(array $defaults): RouterInterface {} */ public function getDefaults(): array {} - /** - * Sets the dependency injector - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - /** * Sets the events manager * diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index f78d3286..314f9c20 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Mvc\Router\RouteInterface; + /** * Interface for Phalcon\Mvc\Router */ @@ -214,29 +225,33 @@ public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterfac * Sets the default action name * * @param string $actionName + * @return RouterInterface */ - public function setDefaultAction(string $actionName); + public function setDefaultAction(string $actionName): RouterInterface; /** * Sets the default controller name * * @param string $controllerName + * @return RouterInterface */ - public function setDefaultController(string $controllerName); + public function setDefaultController(string $controllerName): RouterInterface; /** * Sets the name of the default module * * @param string $moduleName + * @return RouterInterface */ - public function setDefaultModule(string $moduleName); + public function setDefaultModule(string $moduleName): RouterInterface; /** * Sets an array of default paths * * @param array $defaults + * @return RouterInterface */ - public function setDefaults(array $defaults); + public function setDefaults(array $defaults): RouterInterface; /** * Check if the router matches any of the defined routes diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index e8270a85..d58c56af 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; +use Phalcon\Di\Injectable; + /** * Phalcon\Mvc\View * @@ -28,7 +39,7 @@ * echo $view->getContent(); * ``` */ -class View extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewInterface +class View extends Injectable implements ViewInterface { /** * Render Level: To the action view @@ -153,7 +164,7 @@ public function __construct(array $options = array()) {} * @param string $key * @return mixed|null */ - public function __get(string $key): ? {} + public function __get(string $key) {} /** * Magic method to retrieve if a variable is set in the view diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index a88fca68..99968b7a 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; /** diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index c27c5ca3..9fb15059 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc; /** @@ -7,7 +16,7 @@ * * Interface for Phalcon\Mvc\View */ -interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface +interface ViewInterface extends ViewBaseInterface { /** diff --git a/src/Phalcon/mvc/application/Exception.php b/src/Phalcon/mvc/application/Exception.php index 09fd0a89..fb7728b6 100644 --- a/src/Phalcon/mvc/application/Exception.php +++ b/src/Phalcon/mvc/application/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Application; /** diff --git a/src/Phalcon/mvc/collection/Behavior.php b/src/Phalcon/mvc/collection/Behavior.php deleted file mode 100644 index b0683096..00000000 --- a/src/Phalcon/mvc/collection/Behavior.php +++ /dev/null @@ -1,56 +0,0 @@ -x or array[x]. - */ -class Document implements \Phalcon\Mvc\EntityInterface, \ArrayAccess -{ - - /** - * Returns the value of a field using the ArrayAccess interfase - * - * @param mixed $index - * @return mixed - */ - public function offsetGet($index) {} - - /** - * Checks whether an offset exists in the document - * - * @param mixed $index - * @return bool - */ - public function offsetExists($index): bool {} - - /** - * Change a value using the ArrayAccess interface - * - * @param mixed $index - * @param mixed $value - */ - public function offsetSet($index, $value) {} - - /** - * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface - * - * @param mixed $index - */ - public function offsetUnset($index) {} - - /** - * Reads an attribute value by its name - * - * ```php - * echo $robot->readAttribute("name"); - * ``` - * - * @param string $attribute - * @return mixed|null - */ - public function readAttribute(string $attribute): ? {} - - /** - * Returns the instance as an array representation - * - * @return array - */ - public function toArray(): array {} - - /** - * Writes an attribute value by its name - * - * ```php - * $robot->writeAttribute("name", "Rosey"); - * ``` - * - * @param string $attribute - * @param mixed $value - */ - public function writeAttribute(string $attribute, $value) {} - -} diff --git a/src/Phalcon/mvc/collection/Exception.php b/src/Phalcon/mvc/collection/Exception.php deleted file mode 100644 index 5f83ba92..00000000 --- a/src/Phalcon/mvc/collection/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ -set( - * "collectionManager", - * function () { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots($di); - * ``` - */ -class Manager implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface -{ - - protected $behaviors; - - - protected $connectionServices; - - - protected $container; - - - protected $customEventsManager; - - - protected $eventsManager; - - - protected $implicitObjectsIds; - - - protected $initialized; - - - protected $lastInitialized; - - - protected $serviceName = 'mongo'; - - - - public function getServiceName() {} - - /** - * @param mixed $serviceName - */ - public function setServiceName($serviceName) {} - - /** - * Binds a behavior to a model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior - */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior) {} - - /** - * Returns a custom events manager related to a model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return mixed|null - */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): ? {} - - /** - * Returns the connection related to a model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Mongo - */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model) {} - - /** - * Gets a connection service for a specific model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return string - */ - public function getConnectionService(\Phalcon\Mvc\CollectionInterface $model): string {} - - /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns the internal event manager - * - * @return \Phalcon\Events\ManagerInterface - */ - public function getEventsManager(): ManagerInterface {} - - /** - * Get the latest initialized model - * - * @return \Phalcon\Mvc\CollectionInterface - */ - public function getLastInitialized(): CollectionInterface {} - - /** - * Checks if a model is using implicit object ids - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return bool - */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool {} - - /** - * Check whether a model is already initialized - * - * @param string $className - * @return bool - */ - public function isInitialized(string $className): bool {} - - /** - * Initializes a model in the models manager - * - * @param \Phalcon\Mvc\CollectionInterface $model - */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model) {} - - /** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $eventName - * @param mixed $data - * @return bool - */ - public function missingMethod(\Phalcon\Mvc\CollectionInterface $model, string $eventName, $data): bool {} - - /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - * - * @param string $eventName - * @param \Phalcon\Mvc\CollectionInterface $model - */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model) {} - - /** - * Sets a custom events manager for a specific model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Sets a connection service for a specific model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService - */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService) {} - - /** - * Sets the DependencyInjector container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Sets the event manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - - /** - * Sets whether a model must use implicit objects ids - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds - */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds) {} - -} diff --git a/src/Phalcon/mvc/collection/ManagerInterface.php b/src/Phalcon/mvc/collection/ManagerInterface.php deleted file mode 100644 index 1d575f79..00000000 --- a/src/Phalcon/mvc/collection/ManagerInterface.php +++ /dev/null @@ -1,116 +0,0 @@ -set( - * "collectionManager", - * function() { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots(di); - * ``` - */ -interface ManagerInterface -{ - - /** - * Binds a behavior to a collection - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Mvc\Collection\BehaviorInterface $behavior - */ - public function addBehavior(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Mvc\Collection\BehaviorInterface $behavior); - - /** - * Returns the connection related to a model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface - */ - public function getConnection(\Phalcon\Mvc\CollectionInterface $model): AdapterInterface; - - /** - * Returns a custom events manager related to a model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return \Phalcon\Events\ManagerInterface - */ - public function getCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model): EventsManagerInterface; - - /** - * Get the latest initialized model - * - * @return \Phalcon\Mvc\CollectionInterface - */ - public function getLastInitialized(): CollectionInterface; - - /** - * Initializes a model in the models manager - * - * @param \Phalcon\Mvc\CollectionInterface $model - */ - public function initialize(\Phalcon\Mvc\CollectionInterface $model); - - /** - * Check whether a model is already initialized - * - * @param string $className - * @return bool - */ - public function isInitialized(string $className): bool; - - /** - * Checks if a model is using implicit object ids - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @return bool - */ - public function isUsingImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model): bool; - - /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - * - * @param string $eventName - * @param \Phalcon\Mvc\CollectionInterface $model - */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\CollectionInterface $model); - - /** - * Sets a custom events manager for a specific model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setCustomEventsManager(\Phalcon\Mvc\CollectionInterface $model, \Phalcon\Events\ManagerInterface $eventsManager); - - /** - * Sets a connection service for a specific model - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param string $connectionService - */ - public function setConnectionService(\Phalcon\Mvc\CollectionInterface $model, string $connectionService); - - /** - * Sets if a model must use implicit objects ids - * - * @param \Phalcon\Mvc\CollectionInterface $model - * @param bool $useImplicitObjectIds - */ - public function useImplicitObjectIds(\Phalcon\Mvc\CollectionInterface $model, bool $useImplicitObjectIds); - -} diff --git a/src/Phalcon/mvc/collection/behavior/SoftDelete.php b/src/Phalcon/mvc/collection/behavior/SoftDelete.php deleted file mode 100644 index 18c2959f..00000000 --- a/src/Phalcon/mvc/collection/behavior/SoftDelete.php +++ /dev/null @@ -1,22 +0,0 @@ - + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Controller; /** diff --git a/src/Phalcon/mvc/dispatcher/Exception.php b/src/Phalcon/mvc/dispatcher/Exception.php index b7f06862..48f203a3 100644 --- a/src/Phalcon/mvc/dispatcher/Exception.php +++ b/src/Phalcon/mvc/dispatcher/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Dispatcher; /** diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 5c1ba381..77eb06ab 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Micro; /** @@ -7,7 +16,7 @@ * * Groups Micro-Mvc handlers as controllers * - * ```php + *```php * $app = new \Phalcon\Mvc\Micro(); * * $collection = new Collection(); @@ -19,9 +28,9 @@ * $collection->get("/posts/edit/{id}", "edit"); * * $app->mount($collection); - * ``` + *``` */ -class Collection implements \Phalcon\Mvc\Micro\CollectionInterface +class Collection implements CollectionInterface { protected $handler; diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index 8254ccc9..061e309c 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Micro; /** diff --git a/src/Phalcon/mvc/micro/Exception.php b/src/Phalcon/mvc/micro/Exception.php index cd352fc1..8348ef66 100644 --- a/src/Phalcon/mvc/micro/Exception.php +++ b/src/Phalcon/mvc/micro/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Micro; /** diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index d7cb0a66..b52d1eef 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Micro; /** diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index daa73549..83968f0f 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Micro; /** diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index e3366fdd..92072be9 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** @@ -7,7 +16,7 @@ * * This is an optional base class for ORM behaviors */ -abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface +abstract class Behavior implements BehaviorInterface { /** * @var array diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 77ed3cc6..6d85c243 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index 086ca316..a972d074 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Cache\Adapter\AdapterInterface; + /** * Phalcon\Mvc\Model\Binding * * This is an class for binding models into params for handler */ -class Binder implements \Phalcon\Mvc\Model\BinderInterface +class Binder implements BinderInterface { /** * Array for storing active bound models diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index 811f792e..e75f013a 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Cache\Adapter\AdapterInterface; + /** * Phalcon\Mvc\Model\BinderInterface * diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index 99b5a18f..de995ca9 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; + /** * Phalcon\Mvc\Model\Criteria * @@ -19,7 +32,7 @@ * ->execute(); * ``` */ -class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface +class Criteria implements CriteriaInterface, InjectionAwareInterface { protected $bindParams; diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index 923f16b8..2f82d702 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** diff --git a/src/Phalcon/mvc/model/Exception.php b/src/Phalcon/mvc/model/Exception.php index 61bfb83a..ce4b4f4f 100644 --- a/src/Phalcon/mvc/model/Exception.php +++ b/src/Phalcon/mvc/model/Exception.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** * Phalcon\Mvc\Model\Exception * - * Exceptions thrown in Phalcon\Mvc\Model\ classes will use this class + * Exceptions thrown in Phalcon\Mvc\Model\* classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index a398bec4..b3a5f9ef 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -1,7 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface as EventsManagerInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Manager * @@ -27,7 +44,7 @@ * $robot = new Robots($di); * ``` */ -class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareInterface { protected $aliases = array(); @@ -151,9 +168,8 @@ public function getDI(): DiInterface {} * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return \Phalcon\Mvc\Model\ManagerInterface */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): ManagerInterface {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} /** * Returns the internal event manager diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 9cd12efc..53b38204 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ManagerInterface * @@ -358,7 +371,7 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; * @param string $property * @return bool */ - final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; + public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; /** * Sets if a model must keep snapshots diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/mvc/model/MetaData.php index 8c894b55..255ba457 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/mvc/model/MetaData.php @@ -1,7 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\MetaData\StrategyInterface; + /** * Phalcon\Mvc\Model\MetaData * @@ -22,7 +36,7 @@ * print_r($attributes); * ``` */ -abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface +abstract class MetaData implements InjectionAwareInterface, MetaDataInterface { const MODELS_ATTRIBUTES = 0; diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index bea647c2..56f836c1 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\MetaData\StrategyInterface; + /** * Phalcon\Mvc\Model\MetaDataInterface * diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index 5d33d3c1..d7de03e4 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -1,14 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\Query\StatusInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Query * * This class takes a PHQL intermediate representation and executes it. * - * ```php - * $phql = "SELECT c.price0.16 AS taxes, c. FROM Cars AS c JOIN Brands AS b + *```php + * $phql = "SELECT c.price*0.16 AS taxes, c.* FROM Cars AS c JOIN Brands AS b * WHERE b.name = :name: ORDER BY c.name"; * * $result = $manager->executeQuery( @@ -31,7 +46,7 @@ * // $di needs to have the service "db" registered for this to work * $di = Phalcon\Di\FactoryDefault::getDefault(); * - * $phql = 'SELECT FROM robot'; + * $phql = 'SELECT * FROM robot'; * * $myTransaction = new Transaction($di); * $myTransaction->begin(); @@ -50,9 +65,9 @@ * * $queryWithOutTransaction = new Query($phql, $di); * $resultWithOutEntries = $queryWithTransaction->execute(); - * ``` + *``` */ -class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface +class Query implements QueryInterface, InjectionAwareInterface { const TYPE_DELETE = 303; @@ -372,7 +387,7 @@ public function parse(): array {} /** * Returns the current cache backend instance * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ public function getCache(): AdapterInterface {} @@ -556,7 +571,7 @@ public static function clean() {} * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} @@ -568,7 +583,7 @@ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $ * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return \Phalcon\Db\Adapter\AdapterInterface */ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 80c28f29..9a795463 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\QueryInterface * diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index 4284bf95..de06d3e2 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** @@ -7,7 +16,7 @@ * * This class represents a relationship between two models */ -class Relation implements \Phalcon\Mvc\Model\RelationInterface +class Relation implements RelationInterface { const ACTION_CASCADE = 2; diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index 4f018af5..d0db540d 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 9ba8f10b..942dfe88 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index 4064c4a7..f9236731 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -1,7 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use ArrayAccess; +use Countable; +use Iterator; +use JsonSerializable; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Mvc\ModelInterface; +use SeekableIterator; +use Serializable; + /** * Phalcon\Mvc\Model\Resultset * @@ -43,7 +61,8 @@ * } * ``` */ -abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable +abstract class Resultset + implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable { const HYDRATE_ARRAYS = 1; diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index b36b34d7..e97a9ddc 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ResultsetInterface * diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 9d9200e2..fc45ac10 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -1,14 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use ArrayAccess; +use JsonSerializable; +use Phalcon\Mvc\EntityInterface; + /** * Phalcon\Mvc\Model\Row * * This component allows Phalcon\Mvc\Model to return rows without an associated entity. * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. */ -class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable +class Row implements EntityInterface, ResultInterface, ArrayAccess, JsonSerializable { /** diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index 6559b68e..e2997872 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** @@ -46,7 +55,7 @@ * } * ``` */ -class Transaction implements \Phalcon\Mvc\Model\TransactionInterface +class Transaction implements TransactionInterface { protected $activeTransaction = false; diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index da437029..18183f61 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; /** diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index e64943b7..1520e23e 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ValidationFailed * * This exception is generated when a model fails to save a record * Phalcon\Mvc\Model must be set up to have this behavior */ -class ValidationFailed extends \Phalcon\Mvc\Model\Exception +class ValidationFailed extends Exception { protected $messages; diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/mvc/model/behavior/SoftDelete.php index 7a922302..5ee497c3 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/model/behavior/SoftDelete.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Behavior; + /** * Phalcon\Mvc\Model\Behavior\SoftDelete * * Instead of permanently delete a record it marks the record as deleted * changing the value of a flag column */ -class SoftDelete extends \Phalcon\Mvc\Model\Behavior +class SoftDelete extends Behavior { /** diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/mvc/model/behavior/Timestampable.php index 6b5111cc..c15fff34 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/mvc/model/behavior/Timestampable.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Behavior; + /** * Phalcon\Mvc\Model\Behavior\Timestampable * * Allows to automatically update a model’s attribute saving the datetime when a * record is created or updated */ -class Timestampable extends \Phalcon\Mvc\Model\Behavior +class Timestampable extends Behavior { /** diff --git a/src/Phalcon/mvc/model/binder/BindableInterface.php b/src/Phalcon/mvc/model/binder/BindableInterface.php index 48208879..48dba9ec 100644 --- a/src/Phalcon/mvc/model/binder/BindableInterface.php +++ b/src/Phalcon/mvc/model/binder/BindableInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Binder; /** diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index b676700d..3381986e 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Apcu * @@ -11,16 +22,16 @@ * * You can query the meta-data by printing apcu_fetch('$PMM$') or apcu_fetch('$PMM$my-app-id') * - * ```php + *```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Apcu( * [ * "prefix" => "my-app-id", * "lifetime" => 86400, * ] * ); - * ``` + *``` */ -class Apcu extends \Phalcon\Mvc\Model\MetaData +class Apcu extends MetaData { /** diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index fad94fe0..8e42cd19 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Libmemcached * @@ -9,7 +20,7 @@ * * By default meta-data is stored for 48 hours (172800 seconds) */ -class Libmemcached extends \Phalcon\Mvc\Model\MetaData +class Libmemcached extends MetaData { /** diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index c647040f..f52fe8a6 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -1,13 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Memory * * Stores model meta-data in memory. Data will be erased when the request finishes + * */ -class Memory extends \Phalcon\Mvc\Model\MetaData +class Memory extends MetaData { /** diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index c32c0bca..32dd7728 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Redis * @@ -9,7 +20,7 @@ * * By default meta-data is stored for 48 hours (172800 seconds) * - * ```php + *```php * use Phalcon\Mvc\Model\MetaData\Redis; * * $metaData = new Redis( @@ -21,9 +32,9 @@ * "index" => 2, * ] * ); - * ``` + *``` */ -class Redis extends \Phalcon\Mvc\Model\MetaData +class Redis extends MetaData { /** diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/StrategyInterface.php index 9ba73ec4..8a8814c3 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/StrategyInterface.php @@ -1,15 +1,16 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ + +namespace Phalcon\Mvc\Model\MetaData; + interface StrategyInterface { diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Stream.php index c14155d6..50128b68 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -1,21 +1,32 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Stream * * Stores model meta-data in PHP files. * - * ```php + *```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Files( * [ * "metaDataDir" => "app/cache/metadata/", * ] * ); - * ``` + *``` */ -class Stream extends \Phalcon\Mvc\Model\MetaData +class Stream extends MetaData { protected $metaDataDir = './'; diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 86f0806f..4f569660 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Annotations implements \Phalcon\Mvc\Model\MetaData\StrategyInterface + +namespace Phalcon\Mvc\Model\MetaData\Strategy; + +use Phalcon\Mvc\Model\MetaData\StrategyInterface; + +class Annotations implements StrategyInterface { /** diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index 361aa28e..3677fc82 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\MetaData\Strategy; +use Phalcon\Mvc\Model\MetaData\StrategyInterface; + /** * Phalcon\Mvc\Model\MetaData\Strategy\Introspection * * Queries the table meta-data in order to introspect the model's metadata */ -class Introspection implements \Phalcon\Mvc\Model\MetaData\StrategyInterface +class Introspection implements StrategyInterface { /** diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index 73447ad5..791b9783 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -1,13 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Query; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\QueryInterface; + /** * Phalcon\Mvc\Model\Query\Builder * * Helps to create PHQL queries using an OO interface * - * ```php + *```php * $params = [ * "models" => [ * Users::class, @@ -36,9 +49,9 @@ * ]; * * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); - * ``` + *``` */ -class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface +class Builder implements BuilderInterface, InjectionAwareInterface { protected $bindParams; @@ -730,9 +743,8 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setDI(\Phalcon\Di\DiInterface $container): BuilderInterface {} + public function setDI(\Phalcon\Di\DiInterface $container) {} /** * Sets the query WHERE conditions diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index 636c17c6..e4843b4e 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\Model\QueryInterface; + /** * Phalcon\Mvc\Model\Query\BuilderInterface * diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 28727de1..4c2cb267 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Query; /** @@ -17,7 +26,7 @@ * * ```php * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL( - * "SELECT r. FROM Robots r LIMIT 10" + * "SELECT r.* FROM Robots r LIMIT 10" * ); * ``` */ diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index f902467d..2c2fda24 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Query\Status * @@ -10,7 +21,7 @@ * information and the related messages produced by the * model which finally executes the operations when it fails * - * ```php + *```php * $phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:"; * * $status = $app->modelsManager->executeQuery( @@ -27,9 +38,9 @@ * if ($status->success()) { * echo "OK"; * } - * ``` + *``` */ -class Status implements \Phalcon\Mvc\Model\Query\StatusInterface +class Status implements StatusInterface { protected $model; diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index 1f16632c..2bb1c34b 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Query\StatusInterface * diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 7f057733..3c645df5 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -1,14 +1,26 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\ResultsetInterface; + /** * Phalcon\Mvc\Model\Resultset\Complex * * Complex resultsets may include complete objects and scalar values. * This class builds every complex row as it is required */ -class Complex extends \Phalcon\Mvc\Model\Resultset implements \Phalcon\Mvc\Model\ResultsetInterface +class Complex extends Resultset implements ResultsetInterface { protected $columnTypes; diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 1209af8a..3b036c17 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -1,14 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\Resultset; + /** * Phalcon\Mvc\Model\Resultset\Simple * * Simple resultsets only contains a complete objects * This class builds every complete object as it is required */ -class Simple extends \Phalcon\Mvc\Model\Resultset +class Simple extends Resultset { protected $columnMap; diff --git a/src/Phalcon/mvc/model/transaction/Exception.php b/src/Phalcon/mvc/model/transaction/Exception.php index 51ec8b7d..422ef152 100644 --- a/src/Phalcon/mvc/model/transaction/Exception.php +++ b/src/Phalcon/mvc/model/transaction/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Transaction; /** diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 08fa28f4..298969ff 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Transaction\Failed * * This class will be thrown to exit a try/catch block for isolated transactions */ -class Failed extends \Phalcon\Mvc\Model\Transaction\Exception +class Failed extends Exception { protected $record = null; diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index 31af4afd..928b8c1b 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -1,7 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\TransactionInterface; + /** * Phalcon\Mvc\Model\Transaction\Manager * @@ -47,9 +60,9 @@ * } catch (Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - * ``` + *``` */ -class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface +class Manager implements ManagerInterface, InjectionAwareInterface { protected $container; diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index 21fa668d..1f1d5235 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Mvc\Model\TransactionInterface; + /** * Phalcon\Mvc\Model\Transaction\ManagerInterface * diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index b8adad00..91a1efc1 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; +use Phalcon\Mvc\Router; + /** * Phalcon\Mvc\Router\Annotations * @@ -24,7 +35,7 @@ * ); * ``` */ -class Annotations extends \Phalcon\Mvc\Router +class Annotations extends Router { protected $actionSuffix = 'Action'; diff --git a/src/Phalcon/mvc/router/Exception.php b/src/Phalcon/mvc/router/Exception.php index 6811d962..55e57855 100644 --- a/src/Phalcon/mvc/router/Exception.php +++ b/src/Phalcon/mvc/router/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; /** diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index 864e7821..b7cc2aa5 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; /** @@ -7,7 +16,7 @@ * * Helper class to create a group of routes with common attributes * - * ```php + *```php * $router = new \Phalcon\Mvc\Router(); * * //Create a group with a common module and controller @@ -48,9 +57,9 @@ * * //Add the group to the router * $router->mount($blog); - * ``` + *``` */ -class Group implements \Phalcon\Mvc\Router\GroupInterface +class Group implements GroupInterface { protected $beforeMatch; @@ -65,7 +74,7 @@ class Group implements \Phalcon\Mvc\Router\GroupInterface protected $prefix; - protected $routes; + protected $routes = array(); /** diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index 33d59115..6c0c18cb 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; /** * Phalcon\Mvc\Router\GroupInterface * - * ```php + *```php * $router = new \Phalcon\Mvc\Router(); * * // Create a group with a common module and controller @@ -46,7 +55,7 @@ * * // Add the group to the router * $router->mount($blog); - * ``` + *``` */ interface GroupInterface { diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 5f86e634..45429c1e 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; /** @@ -7,7 +16,7 @@ * * This class represents every route added to the router */ -class Route implements \Phalcon\Mvc\Router\RouteInterface +class Route implements RouteInterface { protected $beforeMatch; diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index 77877799..6eb49c93 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\Router; /** @@ -103,8 +112,9 @@ public function setHttpMethods($httpMethods): RouteInterface; * Sets the route's name * * @param string $name + * @return RouteInterface */ - public function setName(string $name); + public function setName(string $name): RouteInterface; /** * Reconfigure the route adding a new pattern and a set of paths @@ -123,7 +133,8 @@ public static function reset(); * Set one or more HTTP methods that constraint the matching of the route * * @param mixed $httpMethods + * @return RouteInterface */ - public function via($httpMethods); + public function via($httpMethods): RouteInterface; } diff --git a/src/Phalcon/mvc/view/Exception.php b/src/Phalcon/mvc/view/Exception.php index 7ee9726e..dd0c0c4c 100644 --- a/src/Phalcon/mvc/view/Exception.php +++ b/src/Phalcon/mvc/view/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View; /** diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/mvc/view/Simple.php index 9e39e5cf..e13fec59 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/mvc/view/Simple.php @@ -1,13 +1,25 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View; +use Phalcon\Di\Injectable; +use Phalcon\Mvc\ViewBaseInterface; + /** * Phalcon\Mvc\View\Simple * * This component allows to render views without hierarchical levels * - * ```php + *```php * use Phalcon\Mvc\View\Simple as View; * * $view = new View(); @@ -27,9 +39,9 @@ * "parameter" => $here, * ] * ); - * ``` + *``` */ -class Simple extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\ViewBaseInterface +class Simple extends Injectable implements ViewBaseInterface { protected $activeRenderPath; @@ -82,7 +94,7 @@ public function __construct(array $options = array()) {} * @param string $key * @return mixed|null */ - public function __get(string $key): ? {} + public function __get(string $key) {} /** * Magic method to pass variables to the views @@ -123,7 +135,7 @@ public function getParamsToView(): array {} * @param string $key * @return mixed|null */ - public function getVar(string $key): ? {} + public function getVar(string $key) {} /** * Gets views directory diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php index 786bf49e..30ad3c5c 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -1,12 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\Injectable; +use Phalcon\Mvc\ViewBaseInterface; + /** * All the template engine adapters must inherit this class. This provides * basic interfacing between the engine and the Phalcon\Mvc\View component. */ -abstract class AbstractEngine extends \Phalcon\Di\Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface +abstract class AbstractEngine extends Injectable implements EngineInterface { protected $view; diff --git a/src/Phalcon/mvc/view/engine/EngineInterface.php b/src/Phalcon/mvc/view/engine/EngineInterface.php index 0fac661d..f7b51e8d 100644 --- a/src/Phalcon/mvc/view/engine/EngineInterface.php +++ b/src/Phalcon/mvc/view/engine/EngineInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine; /** diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index fb3cbc4f..895a8c13 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine; /** * Adapter to use PHP itself as templating engine */ -class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine +class Php extends AbstractEngine { /** diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index 32da40c4..8121f646 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine; +use Phalcon\Mvc\View\Engine\Volt\Compiler; + /** * Designer friendly and fast template engine for PHP written in Zephir/C */ -class Volt extends \Phalcon\Mvc\View\Engine\AbstractEngine +class Volt extends AbstractEngine { protected $compiler; diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 74db5d01..329578ba 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -1,19 +1,31 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine\Volt; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; + /** * This class reads and compiles Volt templates into PHP plain code * - * ```php + *```php * $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); * * $compiler->compile("views/partials/header.volt"); * * require $compiler->getCompiledTemplatePath(); - * ``` + *``` */ -class Compiler implements \Phalcon\Di\InjectionAwareInterface +class Compiler implements InjectionAwareInterface { protected $autoescape = false; diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 8f230a7c..9952eaa2 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Mvc\View\Engine\Volt; +use Phalcon\Mvc\View\Exception as BaseException; + /** * Class for exceptions thrown by Phalcon\Mvc\View */ -class Exception extends \Phalcon\Mvc\View\Exception +class Exception extends BaseException { protected $statement; diff --git a/src/Phalcon/paginator/Exception.php b/src/Phalcon/paginator/Exception.php index 031cfb36..181a13a5 100644 --- a/src/Phalcon/paginator/Exception.php +++ b/src/Phalcon/paginator/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator; /** diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php index 1b6a8f76..b13fd582 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -1,16 +1,20 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class PaginatorFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Paginator; + +use Phalcon\Factory\AbstractFactory; +use Phalcon\Paginator\Adapter\AbstractAdapter; + +class PaginatorFactory extends AbstractFactory { /** diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index 1d5fe849..da4ac65c 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator; /** @@ -7,7 +16,7 @@ * * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements \Phalcon\Paginator\RepositoryInterface +class Repository implements RepositoryInterface { /** * @var array @@ -26,7 +35,7 @@ class Repository implements \Phalcon\Paginator\RepositoryInterface * @param string $property * @return mixed|null */ - public function __get(string $property): ? {} + public function __get(string $property) {} /** * {@inheritdoc} diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php index 94b41503..3e39d4bb 100644 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator; /** diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/paginator/adapter/AbstractAdapter.php index 5e8b0888..05cbcfff 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/paginator/adapter/AbstractAdapter.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\RepositoryInterface; + /** * Phalcon\Paginator\Adapter\AbstractAdapter */ -abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * Configuration of paginator diff --git a/src/Phalcon/paginator/adapter/AdapterInterface.php b/src/Phalcon/paginator/adapter/AdapterInterface.php index f784a544..947c4483 100644 --- a/src/Phalcon/paginator/adapter/AdapterInterface.php +++ b/src/Phalcon/paginator/adapter/AdapterInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\RepositoryInterface; + /** * Phalcon\Paginator\AdapterInterface * diff --git a/src/Phalcon/paginator/adapter/Model.php b/src/Phalcon/paginator/adapter/Model.php index 2da288d1..f6c3f1c1 100644 --- a/src/Phalcon/paginator/adapter/Model.php +++ b/src/Phalcon/paginator/adapter/Model.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\RepositoryInterface; + /** * Phalcon\Paginator\Adapter\Model * @@ -20,9 +31,9 @@ * ); * * $paginate = $paginator->paginate(); - * ``` + *``` */ -class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter +class Model extends AbstractAdapter { /** diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 36547901..999c9e85 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\RepositoryInterface; + /** * Phalcon\Paginator\Adapter\NativeArray * @@ -23,9 +34,9 @@ * "page" => $currentPage, * ] * ); - * ``` + *``` */ -class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter +class NativeArray extends AbstractAdapter { /** diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index 7e810c18..e3ea076f 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Paginator\Adapter; +use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Paginator\RepositoryInterface; + /** * Phalcon\Paginator\Adapter\QueryBuilder * @@ -22,9 +34,9 @@ * "page" => 1, * ] * ); - * ``` + *``` */ -class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter +class QueryBuilder extends AbstractAdapter { /** * Paginator's data diff --git a/src/Phalcon/security/Exception.php b/src/Phalcon/security/Exception.php index c13eabd7..c4732477 100644 --- a/src/Phalcon/security/Exception.php +++ b/src/Phalcon/security/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Security; /** diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/security/Random.php index 3ff0e433..80686906 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/security/Random.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Security; /** @@ -16,7 +25,7 @@ * - Generating random passwords for new user accounts * - Encryption systems * - * ```php + *```php * $random = new \Phalcon\Security\Random(); * * // Random binary string @@ -61,7 +70,7 @@ * echo $random->base58(); // Umjxqf7ZPwh765yR * echo $random->base58(24); // qoXcgmw4A9dys26HaNEdCRj9 * echo $random->base58(7); // 774SJD3vgP - * ``` + *``` * * This class partially borrows SecureRandom library from Ruby * diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/session/Bag.php index 40b32d3a..cff78aa8 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/session/Bag.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Phalcon\Session; +use Phalcon\Collection; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; + /** * Phalcon\Session\Bag * @@ -16,7 +28,7 @@ * $user->age = 22; * ``` */ -class Bag extends \Phalcon\Collection implements \Phalcon\Di\InjectionAwareInterface +class Bag extends Collection implements InjectionAwareInterface { private $container; diff --git a/src/Phalcon/session/Exception.php b/src/Phalcon/session/Exception.php index 3bff6887..8d4fc6dd 100644 --- a/src/Phalcon/session/Exception.php +++ b/src/Phalcon/session/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session; /** diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 1ce22d22..0429b387 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -1,23 +1,31 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session; +use InvalidArgumentException; +use Phalcon\DI\AbstractInjectionAware; +use SessionHandlerInterface; + /** * Phalcon\Session\Manager * * Session manager class */ -class Manager implements \Phalcon\Session\ManagerInterface, \Phalcon\DI\InjectionAwareInterface +class Manager extends AbstractInjectionAware implements ManagerInterface { - /** - * @var - */ - private $container; - /** * @var |null */ - private $handler = null; + private $adapter = null; /** * @var string @@ -96,18 +104,11 @@ public function exists(): bool {} public function get(string $key, $defaultValue = null, bool $remove = false) {} /** - * Returns the DependencyInjector container - * - * @return \Phalcon\Di\DiInterface - */ - public function getDI(): DiInterface {} - - /** - * Returns the stored session handler + * Returns the stored session adapter * * @return \SessionHandlerInterface */ - public function getHandler(): SessionHandlerInterface {} + public function getAdapter(): SessionHandlerInterface {} /** * Returns the session id @@ -139,21 +140,13 @@ public function has(string $key): bool {} public function getOptions(): array {} /** - * Regenerates the session id using the handler. + * Regenerates the session id using the adapter. * * @param mixed $deleteOldSession * @return \Phalcon\Session\ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface {} - /** - * Registers a handler with the session - * - * @param \SessionHandlerInterface $handler - * @return bool - */ - public function registerHandler(\SessionHandlerInterface $handler): bool {} - /** * Removes a session variable from an application context * @@ -170,19 +163,12 @@ public function remove(string $key) {} public function set(string $key, $value) {} /** - * Sets the DependencyInjector container - * - * @param \Phalcon\Di\DiInterface $container - */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - - /** - * Set the handler for the session + * Set the adapter for the session * - * @param \SessionHandlerInterface $handler + * @param \SessionHandlerInterface $adapter * @return \Phalcon\Session\ManagerInterface */ - public function setHandler(\SessionHandlerInterface $handler): ManagerInterface {} + public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface {} /** * Set session Id diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php index 0bdb4024..20b0ce6d 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/session/ManagerInterface.php @@ -1,7 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session; +use InvalidArgumentException; +use SessionHandlerInterface; + /** * Phalcon\Session * @@ -23,6 +35,7 @@ interface ManagerInterface * Alias: Gets a session variable from an application context * * @param string $key + * @return mixed */ public function __get(string $key); @@ -79,11 +92,11 @@ public function get(string $key, $defaultValue = null, bool $remove = false); public function getId(): string; /** - * Returns the stored session handler + * Returns the stored session adapter * * @return \SessionHandlerInterface */ - public function getHandler(): SessionHandlerInterface; + public function getAdapter(): SessionHandlerInterface; /** * Returns the name of the session @@ -123,12 +136,12 @@ public function remove(string $key); public function set(string $key, $value); /** - * Set the handler for the session + * Set the adapter for the session * - * @param \SessionHandlerInterface $handler + * @param \SessionHandlerInterface $adapter * @return ManagerInterface */ - public function setHandler(\SessionHandlerInterface $handler): ManagerInterface; + public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface; /** * Set session Id @@ -171,19 +184,11 @@ public function status(): int; public function start(): bool; /** - * Regenerates the session id using the handler. + * Regenerates the session id using the adapter. * * @param mixed $deleteOldSession * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; - /** - * Registers a handler with the session - * - * @param \SessionHandlerInterface $handler - * @return bool - */ - public function registerHandler(\SessionHandlerInterface $handler): bool; - } diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/session/adapter/AbstractAdapter.php index 4a56f4f1..f21ef260 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/session/adapter/AbstractAdapter.php @@ -1,7 +1,5 @@ diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 83668e14..56c63d0f 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session\Adapter; /** * Phalcon\Session\Adapter\Libmemcached */ -class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter +class Libmemcached extends AbstractAdapter { /** diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index 02a62873..23834c1f 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session\Adapter; +use SessionHandlerInterface; + /** * Phalcon\Session\Adapter\Noop * @@ -15,10 +26,10 @@ * use Phalcon\Session\Adapter\Noop; * * $session = new Manager(); - * $session->setHandler(new Noop()); + * $session->setAdapter(new Noop()); * ``` */ -class Noop implements \SessionHandlerInterface +class Noop implements SessionHandlerInterface { /** * The connection of some adapters diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 9df67fd7..855cad32 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session\Adapter; /** * Phalcon\Session\Adapter\Redis */ -class Redis extends \Phalcon\Session\Adapter\AbstractAdapter + class Redis extends AbstractAdapter { /** diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php index 50f4da55..6d188e19 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/session/adapter/Stream.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Phalcon\Session\Adapter; /** @@ -19,10 +28,10 @@ * 'savePath' => '/tmp', * ] * ); - * $session->setHandler($files); + * $session->setAdapter($files); * ``` */ -class Stream extends \Phalcon\Session\Adapter\Noop +class Stream extends Noop { /** * @var string @@ -48,6 +57,8 @@ public function destroy($id): bool {} public function gc($maxlifetime): bool {} /** + * Ignore the savePath and use local defined path + * * @param mixed $savePath * @param mixed $sessionName * @return bool diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php index 22477029..d997f346 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/storage/AdapterFactory.php @@ -1,16 +1,20 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AdapterFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Storage; + +use Phalcon\Factory\AbstractFactory; +use Phalcon\Storage\Adapter\AbstractAdapter; + +class AdapterFactory extends AbstractFactory { /** * @var diff --git a/src/Phalcon/storage/Exception.php b/src/Phalcon/storage/Exception.php index e699f6fa..49c63fe6 100644 --- a/src/Phalcon/storage/Exception.php +++ b/src/Phalcon/storage/Exception.php @@ -1,11 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage; /** * Phalcon\Storage\Exception * * Exceptions thrown in Phalcon\Storage will use this class + * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/storage/SerializerFactory.php b/src/Phalcon/storage/SerializerFactory.php index 7e2ecdcf..790028a6 100644 --- a/src/Phalcon/storage/SerializerFactory.php +++ b/src/Phalcon/storage/SerializerFactory.php @@ -1,16 +1,20 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class SerializerFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Storage; + +use Phalcon\Factory\AbstractFactory; +use Phalcon\Storage\Serializer\SerializerInterface; + +class SerializerFactory extends AbstractFactory { /** diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php index ec177404..e5ad17f9 100644 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -1,16 +1,22 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface + +namespace Phalcon\Storage\Adapter; + +use DateInterval; +use Phalcon\Storage\Exception; +use Phalcon\Storage\Serializer\SerializerInterface; +use Phalcon\Storage\SerializerFactory; + +abstract class AbstractAdapter implements AdapterInterface { /** * @var mixed diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php index a7f35523..3228aeac 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; /** diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/storage/adapter/Apcu.php index 1af97d32..d2aa3fdf 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/storage/adapter/Apcu.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; /** * Apcu adapter */ -class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter +class Apcu extends AbstractAdapter { /** * @var array diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/storage/adapter/Libmemcached.php index aeed0578..d0092724 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/storage/adapter/Libmemcached.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; +use Phalcon\Storage\Exception; + /** * Libmemcached adapter */ -class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter +class Libmemcached extends AbstractAdapter { /** * @var array diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/storage/adapter/Memory.php index 2bd31bcc..802a60e5 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/storage/adapter/Memory.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; +use Phalcon\Collection; + /** * Memory adapter */ -class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * @var Collection diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/storage/adapter/Redis.php index bbacdd43..541aad14 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/storage/adapter/Redis.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; +use Phalcon\Storage\Exception; + /** * Redis adapter */ -class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter +class Redis extends AbstractAdapter { /** * @var array diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/storage/adapter/Stream.php index 5762cae2..9e2d6fc8 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/storage/adapter/Stream.php @@ -1,11 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Storage\Adapter; +use Iterator; +use Phalcon\Storage\Exception; + /** * Stream adapter */ -class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * @var string diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/storage/serializer/AbstractSerializer.php index ee00747a..aaace3b8 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/storage/serializer/AbstractSerializer.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface + +namespace Phalcon\Storage\Serializer; + +abstract class AbstractSerializer implements SerializerInterface { /** * @var mixed @@ -18,16 +19,6 @@ abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\Seriali protected $data = null; - /** - * @return mixed - */ - public function getData() {} - - /** - * @param mixed $data - */ - public function setData($data) {} - /** * Constructor * @@ -43,4 +34,14 @@ public function __construct($data = null) {} */ protected function isSerializable($data): bool {} + /** + * @return mixed + */ + public function getData() {} + + /** + * @param mixed $data + */ + public function setData($data) {} + } diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php index 6dfbad46..f42b5448 100644 --- a/src/Phalcon/storage/serializer/Base64.php +++ b/src/Phalcon/storage/serializer/Base64.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class Base64 extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php index 5047c4bc..9e0dae56 100644 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class Igbinary extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php index ef79de7a..7b22a8ba 100644 --- a/src/Phalcon/storage/serializer/Json.php +++ b/src/Phalcon/storage/serializer/Json.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Json extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class Json extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php index 8b8a3e80..390a6940 100644 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class Msgpack extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php index bba29154..bff7f7a5 100644 --- a/src/Phalcon/storage/serializer/None.php +++ b/src/Phalcon/storage/serializer/None.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class None extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class None extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php index ea6e0ef6..046b4ef2 100644 --- a/src/Phalcon/storage/serializer/Php.php +++ b/src/Phalcon/storage/serializer/Php.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Php extends \Phalcon\Storage\Serializer\AbstractSerializer + +namespace Phalcon\Storage\Serializer; + +class Php extends AbstractSerializer { /** diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php index b13acdd3..5bbc9ac1 100644 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -interface SerializerInterface extends \Serializable + +namespace Phalcon\Storage\Serializer; + +use Serializable; + +interface SerializerInterface extends Serializable { /** @@ -20,7 +23,6 @@ public function getData(); /** * @param mixed $data - * @param $data */ public function setData($data); diff --git a/src/Phalcon/tag/Exception.php b/src/Phalcon/tag/Exception.php index d2f45291..10e26f52 100644 --- a/src/Phalcon/tag/Exception.php +++ b/src/Phalcon/tag/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Tag; /** diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 7b670532..d4844f81 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Tag; /** diff --git a/src/Phalcon/translate/Exception.php b/src/Phalcon/translate/Exception.php index 5e18d0a1..17785ee2 100644 --- a/src/Phalcon/translate/Exception.php +++ b/src/Phalcon/translate/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate; /** diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php index 5907eda6..00d97024 100644 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -1,16 +1,20 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class InterpolatorFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Translate; + +use Phalcon\Factory\AbstractFactory; +use Phalcon\Translate\Adapter\AdapterInterface; + +class InterpolatorFactory extends AbstractFactory { /** * @var array diff --git a/src/Phalcon/translate/TranslateFactory.php b/src/Phalcon/translate/TranslateFactory.php index 00d07867..780522a9 100644 --- a/src/Phalcon/translate/TranslateFactory.php +++ b/src/Phalcon/translate/TranslateFactory.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class TranslateFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Translate; + +use Phalcon\Factory\AbstractFactory; + +class TranslateFactory extends AbstractFactory { /** * @var InterpolatorFactory diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php index 8d221db3..5d00f1c7 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Adapter; +use Phalcon\Translate\InterpolatorFactory; + /** * Phalcon\Translate\Adapter * * Base class for Phalcon\Translate adapters */ -abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * @var string diff --git a/src/Phalcon/translate/adapter/AdapterInterface.php b/src/Phalcon/translate/adapter/AdapterInterface.php index 77811881..7c1058f4 100644 --- a/src/Phalcon/translate/adapter/AdapterInterface.php +++ b/src/Phalcon/translate/adapter/AdapterInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Adapter; /** diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 85b504c7..9ec2a74d 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Adapter; +use ArrayAccess; + /** * Phalcon\Translate\Adapter\Csv * * Allows to define translation lists using CSV file */ -class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Csv extends AbstractAdapter implements ArrayAccess { /** * @var array diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 50833867..0be89697 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Adapter; +use ArrayAccess; + /** * Phalcon\Translate\Adapter\Gettext * @@ -20,7 +31,7 @@ * * Allows translate using gettext */ -class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Gettext extends AbstractAdapter implements ArrayAccess { /** * @var int diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index 710d5661..389eddb0 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -1,13 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Adapter; +use ArrayAccess; + /** * Phalcon\Translate\Adapter\NativeArray * * Allows to define translation lists using PHP arrays */ -class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class NativeArray extends AbstractAdapter implements ArrayAccess { /** * @var array diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index 55bc4363..f5a5758d 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface + +namespace Phalcon\Translate\Interpolator; + +class AssociativeArray implements InterpolatorInterface { /** diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index af57aa6f..64522c63 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -1,16 +1,17 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface + +namespace Phalcon\Translate\Interpolator; + +class IndexedArray implements InterpolatorInterface { /** diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php index 4adb6a41..ed96d56f 100644 --- a/src/Phalcon/translate/interpolator/InterpolatorInterface.php +++ b/src/Phalcon/translate/interpolator/InterpolatorInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Translate\Interpolator; /** diff --git a/src/Phalcon/url/Exception.php b/src/Phalcon/url/Exception.php index 806bb1bb..c7990195 100644 --- a/src/Phalcon/url/Exception.php +++ b/src/Phalcon/url/Exception.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Url; /** diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/url/UrlInterface.php index e67b5ed5..9ee891ec 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/url/UrlInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Url; /** diff --git a/src/Phalcon/validation/AbstractCombinedFieldsValidator.php b/src/Phalcon/validation/AbstractCombinedFieldsValidator.php index 1ac58d5c..27026224 100644 --- a/src/Phalcon/validation/AbstractCombinedFieldsValidator.php +++ b/src/Phalcon/validation/AbstractCombinedFieldsValidator.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; /** * This is a base class for combined fields validators */ -abstract class AbstractCombinedFieldsValidator extends \Phalcon\Validation\AbstractValidator +abstract class AbstractCombinedFieldsValidator extends AbstractValidator { } diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/validation/AbstractValidator.php index eaf29f86..7e32fb8a 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/validation/AbstractValidator.php @@ -1,11 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; +use Phalcon\Messages\Message; + /** * This is a base class for validators */ -abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface +abstract class AbstractValidator implements ValidatorInterface { /** * Message template diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/validation/AbstractValidatorComposite.php index c560f142..d5f53f2c 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/validation/AbstractValidatorComposite.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; /** * This is a base class for combined fields validators */ -abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements \Phalcon\Validation\ValidatorCompositeInterface +abstract class AbstractValidatorComposite extends AbstractValidator implements ValidatorCompositeInterface { /** * @var array diff --git a/src/Phalcon/validation/Exception.php b/src/Phalcon/validation/Exception.php index 24ac4a6b..2d69169b 100644 --- a/src/Phalcon/validation/Exception.php +++ b/src/Phalcon/validation/Exception.php @@ -1,9 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; /** - * Exceptions thrown in Phalcon\Validation\ classes will use this class + * Exceptions thrown in Phalcon\Validation\* classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/validation/ValidationInterface.php index 2d1e20c2..f4c05ab1 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/validation/ValidationInterface.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; +use Phalcon\Messages\Messages; + /** * Interface for the Phalcon\Validation component */ @@ -48,7 +59,7 @@ public function getEntity(); * @param string $field * @return mixed|null */ - public function getFilters(string $field = null): ?; + public function getFilters(string $field = null); /** * Get label for field @@ -78,7 +89,7 @@ public function getValidators(): array; * @param string $field * @return mixed|null */ - public function getValue(string $field): ?; + public function getValue(string $field); /** * Alias of `add` method diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/validation/ValidatorCompositeInterface.php index 7798b58b..c098626d 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/validation/ValidatorCompositeInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; /** diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/validation/ValidatorFactory.php index 3f3aa103..2b615b48 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/validation/ValidatorFactory.php @@ -1,16 +1,19 @@ + * (c) Phalcon Team * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class ValidatorFactory extends \Phalcon\Factory\AbstractFactory + +namespace Phalcon\Validation; + +use Phalcon\Factory\AbstractFactory; + +class ValidatorFactory extends AbstractFactory { /** diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 307747be..16bdd711 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation; /** diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index e44a4154..814f1936 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check for alphanumeric character(s) * @@ -36,7 +47,7 @@ * ); * ``` */ -class Alnum extends \Phalcon\Validation\AbstractValidator +class Alnum extends AbstractValidator { protected $template = 'Field :field must contain only letters and numbers'; diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index c4a0ef8c..42650863 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check for alphabetic character(s) * @@ -36,7 +47,7 @@ * ); * ``` */ -class Alpha extends \Phalcon\Validation\AbstractValidator +class Alpha extends AbstractValidator { protected $template = 'Field :field must contain only letters'; diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 62ae2db7..f41e0a38 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Validates that a value is between an inclusive range of two values. * For a value x, the test is passed if minimum<=x<=maximum. @@ -47,7 +58,7 @@ * ); * ``` */ -class Between extends \Phalcon\Validation\AbstractValidator +class Between extends AbstractValidator { protected $template = 'Field :field must be within the range of :min to :max'; diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 61c7a9fa..ab3860ab 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Calls user function for validation * @@ -46,7 +57,7 @@ * ); * ``` */ -class Callback extends \Phalcon\Validation\AbstractValidator +class Callback extends AbstractValidator { protected $template = 'Field :field must match the callback function'; diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 9adbf563..9c7baade 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks that two values have the same value * @@ -41,7 +52,7 @@ * ); * ``` */ -class Confirmation extends \Phalcon\Validation\AbstractValidator +class Confirmation extends AbstractValidator { protected $template = 'Field :field must be the same as :with'; diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index 659e1445..c5144cf6 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value has a valid credit card number * @@ -36,7 +47,7 @@ * ); * ``` */ -class CreditCard extends \Phalcon\Validation\AbstractValidator +class CreditCard extends AbstractValidator { protected $template = 'Field :field is not valid for a credit card number'; diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index 47ce72e1..52b74ff0 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value is a valid date * @@ -41,7 +52,7 @@ * ); * ``` */ -class Date extends \Phalcon\Validation\AbstractValidator +class Date extends AbstractValidator { protected $template = 'Field :field is not a valid date'; diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 038cb5d8..ee134d53 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check for numeric character(s) * @@ -36,7 +47,7 @@ * ); * ``` */ -class Digit extends \Phalcon\Validation\AbstractValidator +class Digit extends AbstractValidator { protected $template = 'Field :field must be numeric'; diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 93b774b3..be776a7d 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value has a correct e-mail format * @@ -36,7 +47,7 @@ * ); * ``` */ -class Email extends \Phalcon\Validation\AbstractValidator +class Email extends AbstractValidator { protected $template = 'Field :field must be an email address'; diff --git a/src/Phalcon/validation/validator/Exception.php b/src/Phalcon/validation/validator/Exception.php index 240b1809..3307bc9b 100644 --- a/src/Phalcon/validation/validator/Exception.php +++ b/src/Phalcon/validation/validator/Exception.php @@ -1,9 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; /** - * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this + * Exceptions thrown in Phalcon\Validation\Validator\* classes will use this * class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index aa870b04..8f6c3463 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check if a value is not included into a list of values * @@ -47,7 +58,7 @@ * ); * ``` */ -class ExclusionIn extends \Phalcon\Validation\AbstractValidator +class ExclusionIn extends AbstractValidator { protected $template = 'Field :field must not be a part of list: :domain'; diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index 3ab08575..d1eec32e 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidatorComposite; + /** * Checks if a value has a correct file * @@ -69,7 +80,7 @@ * ); * ``` */ -class File extends \Phalcon\Validation\AbstractValidatorComposite +class File extends AbstractValidatorComposite { /** diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 152a25ab..240a5c71 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value is identical to other * @@ -41,7 +52,7 @@ * ); * ``` */ -class Identical extends \Phalcon\Validation\AbstractValidator +class Identical extends AbstractValidator { protected $template = 'Field :field does not have the expected value'; diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 2b69130e..489d383f 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check if a value is included into a list of values * @@ -41,7 +52,7 @@ * ); * ``` */ -class InclusionIn extends \Phalcon\Validation\AbstractValidator +class InclusionIn extends AbstractValidator { protected $template = 'Field :field must be a part of list: :domain'; diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 485fdb5b..3fd9af00 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check for IP addresses * @@ -53,7 +64,7 @@ * ); * ``` */ -class Ip extends \Phalcon\Validation\AbstractValidator +class Ip extends AbstractValidator { const VERSION_4 = 1048576; diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index 4a55030b..7f93c397 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Check for a valid numeric value * @@ -36,7 +47,7 @@ * ); * ``` */ -class Numericality extends \Phalcon\Validation\AbstractValidator +class Numericality extends AbstractValidator { protected $template = 'Field :field does not have a valid numeric format'; diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index f7e1a631..ea6f0a63 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Validates that a value is not null or empty string * @@ -36,7 +47,7 @@ * ); * ``` */ -class PresenceOf extends \Phalcon\Validation\AbstractValidator +class PresenceOf extends AbstractValidator { protected $template = 'Field :field is required'; diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index 23aa7ec5..b37ea0ee 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Allows validate if the value of a field matches a regular expression * @@ -41,7 +52,7 @@ * ); * ``` */ -class Regex extends \Phalcon\Validation\AbstractValidator +class Regex extends AbstractValidator { protected $template = 'Field :field does not match the required format'; diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index 7cded7d9..4eb2e945 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidatorComposite; + /** * Validates that a string has the specified maximum and minimum constraints * The test is passed if for a string's length L, min<=L<=max, i.e. L must @@ -64,7 +75,7 @@ * ); * ``` */ -class StringLength extends \Phalcon\Validation\AbstractValidatorComposite +class StringLength extends AbstractValidatorComposite { /** diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index fa70ed86..b5e777d0 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -1,7 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractCombinedFieldsValidator; + +//use Phalcon\Mvc\CollectionInterface; +//use Phalcon\Mvc\Collection; + /** * Check that a field is unique in the related table * @@ -72,7 +86,7 @@ * ); * ``` */ -class Uniqueness extends \Phalcon\Validation\AbstractCombinedFieldsValidator +class Uniqueness extends AbstractCombinedFieldsValidator { protected $template = 'Field :field must be unique'; @@ -106,15 +120,6 @@ protected function getColumnNameReal($record, string $field): string {} */ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool {} - /** - * Uniqueness method used for collection - * - * @param mixed $record - * @param array $field - * @param array $values - */ - protected function isUniquenessCollection($record, array $field, array $values) {} - /** * Uniqueness method used for model * diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 0c85f1f0..57e3312f 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value has a url format * @@ -36,7 +47,7 @@ * ); * ``` */ -class Url extends \Phalcon\Validation\AbstractValidator +class Url extends AbstractValidator { protected $template = 'Field :field must be a url'; diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php index 2a2c15cd..de85590b 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File; +use Phalcon\Validation\AbstractValidator; + /** * Checks if a value has a correct file * @@ -41,7 +52,7 @@ * ); * ``` */ -abstract class AbstractFile extends \Phalcon\Validation\AbstractValidator +abstract class AbstractFile extends AbstractValidator { /** * Empty is empty diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php index b642b371..2d50b13e 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File; /** @@ -50,7 +59,7 @@ * ); * ``` */ -class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile +class MimeType extends AbstractFile { protected $template = 'File :field must be of type: :types'; diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php index cc59fdd6..b9118087 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a file has the rigth resolution * @@ -41,7 +52,7 @@ * ); * ``` */ -class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +class Equal extends AbstractFile { protected $template = 'The resolution of the field :field has to be equal :resolution'; diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php index 32ca0ec1..e16aff7b 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a file has the rigth resolution * @@ -46,7 +57,7 @@ * ); * ``` */ -class Max extends \Phalcon\Validation\Validator\File\AbstractFile +class Max extends AbstractFile { protected $template = 'File :field exceeds the maximum resolution of :resolution'; diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php index db1e4db0..dbcbdf3e 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a file has the rigth resolution * @@ -46,7 +57,7 @@ * ); * ``` */ -class Min extends \Phalcon\Validation\Validator\File\AbstractFile +class Min extends AbstractFile { protected $template = 'File :field can not have the minimum resolution of :resolution'; diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php index 2e7de623..90708201 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a value has a correct file * @@ -46,7 +57,7 @@ * ); * ``` */ -class Equal extends \Phalcon\Validation\Validator\File\AbstractFile +class Equal extends AbstractFile { protected $template = 'File :field does not have the exact :size filesize'; diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php index 1e634676..50474cd2 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a value has a correct file * @@ -46,7 +57,7 @@ * ); * ``` */ -class Max extends \Phalcon\Validation\Validator\File\AbstractFile +class Max extends AbstractFile { protected $template = 'File :field exceeds the size of :size'; diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php index 92d65f3f..cb5bbf5c 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a value has a correct file * @@ -46,7 +57,7 @@ * ); * ``` */ -class Min extends \Phalcon\Validation\Validator\File\AbstractFile +class Min extends AbstractFile { protected $template = 'File :field can not have the minimum size of :size'; diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php index fe294b5f..b68c274f 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Validation\AbstractValidator; + /** * Validates that a string has the specified maximum constraints * The test is passed if for a string's length L, L<=max, i.e. L must @@ -48,7 +59,7 @@ * ); * ``` */ -class Max extends \Phalcon\Validation\AbstractValidator +class Max extends AbstractValidator { protected $template = 'Field :field must not exceed :max characters long'; diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php index 606924c0..e9991752 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -1,7 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Validation\AbstractValidator; + /** * Validates that a string has the specified minimum constraints * The test is passed if for a string's length L, min<=L, i.e. L must @@ -48,7 +59,7 @@ * ); * ``` */ -class Min extends \Phalcon\Validation\AbstractValidator +class Min extends AbstractValidator { protected $template = 'Field :field must be at least :min characters long'; From c19139cbc4a2f31b4a3ce177a43b76d7a6950d8f Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Tue, 24 Sep 2019 12:28:36 +0200 Subject: [PATCH 13/25] Bumped ide-stubs to 4.0.0-rc.1 Fixed stubs generator errors Added psalm and phpcs --- .travis.yml | 27 ++ composer.json | 4 + phpcs.xml | 12 + psalm.xml | 23 ++ src/Phalcon/Cache.php | 49 ++- src/Phalcon/Collection.php | 93 +++-- src/Phalcon/Config.php | 29 +- src/Phalcon/Container.php | 13 +- src/Phalcon/Crypt.php | 109 +++-- src/Phalcon/Debug.php | 83 +++- src/Phalcon/Di.php | 107 +++-- src/Phalcon/Escaper.php | 45 +- src/Phalcon/Exception.php | 5 +- src/Phalcon/Filter.php | 33 +- src/Phalcon/Kernel.php | 5 +- src/Phalcon/Loader.php | 81 +++- src/Phalcon/Logger.php | 81 +++- src/Phalcon/Registry.php | 89 ++-- src/Phalcon/Security.php | 85 +++- src/Phalcon/Tag.php | 249 ++++++++--- src/Phalcon/Text.php | 53 ++- src/Phalcon/Url.php | 41 +- src/Phalcon/Validation.php | 77 +++- src/Phalcon/Version.php | 21 +- src/Phalcon/acl/Component.php | 17 +- src/Phalcon/acl/ComponentAware.php | 1 - src/Phalcon/acl/ComponentInterface.php | 1 - src/Phalcon/acl/Enum.php | 2 - src/Phalcon/acl/Role.php | 17 +- src/Phalcon/acl/RoleAware.php | 1 - src/Phalcon/acl/RoleInterface.php | 1 - src/Phalcon/acl/adapter/AbstractAdapter.php | 29 +- src/Phalcon/acl/adapter/AdapterInterface.php | 1 - src/Phalcon/acl/adapter/Memory.php | 81 +++- src/Phalcon/annotations/Annotation.php | 41 +- .../annotations/AnnotationsFactory.php | 17 +- src/Phalcon/annotations/Collection.php | 45 +- src/Phalcon/annotations/Reader.php | 9 +- src/Phalcon/annotations/ReaderInterface.php | 1 - src/Phalcon/annotations/Reflection.php | 21 +- .../annotations/adapter/AbstractAdapter.php | 29 +- .../annotations/adapter/AdapterInterface.php | 1 - src/Phalcon/annotations/adapter/Apcu.php | 13 +- src/Phalcon/annotations/adapter/Memory.php | 9 +- src/Phalcon/annotations/adapter/Stream.php | 13 +- .../application/AbstractApplication.php | 41 +- src/Phalcon/assets/Asset.php | 105 +++-- src/Phalcon/assets/AssetInterface.php | 1 - src/Phalcon/assets/Collection.php | 169 ++++++-- src/Phalcon/assets/FilterInterface.php | 1 - src/Phalcon/assets/Inline.php | 37 +- src/Phalcon/assets/Manager.php | 109 +++-- src/Phalcon/assets/asset/Css.php | 5 +- src/Phalcon/assets/asset/Js.php | 5 +- src/Phalcon/assets/filters/Cssmin.php | 5 +- src/Phalcon/assets/filters/Jsmin.php | 5 +- src/Phalcon/assets/filters/None.php | 5 +- src/Phalcon/assets/inline/Css.php | 5 +- src/Phalcon/assets/inline/Js.php | 5 +- src/Phalcon/cache/AdapterFactory.php | 13 +- src/Phalcon/cache/CacheFactory.php | 13 +- src/Phalcon/cli/Console.php | 12 +- src/Phalcon/cli/Dispatcher.php | 57 ++- src/Phalcon/cli/DispatcherInterface.php | 1 - src/Phalcon/cli/Router.php | 69 +++- src/Phalcon/cli/RouterInterface.php | 1 - src/Phalcon/cli/Task.php | 5 +- src/Phalcon/cli/router/Route.php | 85 ++-- src/Phalcon/cli/router/RouteInterface.php | 1 - src/Phalcon/collection/ReadOnly.php | 9 +- src/Phalcon/config/ConfigFactory.php | 17 +- src/Phalcon/config/adapter/Grouped.php | 5 +- src/Phalcon/config/adapter/Ini.php | 13 +- src/Phalcon/config/adapter/Json.php | 5 +- src/Phalcon/config/adapter/Php.php | 5 +- src/Phalcon/config/adapter/Yaml.php | 5 +- src/Phalcon/crypt/CryptInterface.php | 1 - src/Phalcon/db/AbstractDb.php | 5 +- src/Phalcon/db/Column.php | 69 +++- src/Phalcon/db/ColumnInterface.php | 1 - src/Phalcon/db/Dialect.php | 165 ++++++-- src/Phalcon/db/DialectInterface.php | 1 - src/Phalcon/db/Enum.php | 2 - src/Phalcon/db/Index.php | 17 +- src/Phalcon/db/IndexInterface.php | 1 - src/Phalcon/db/Profiler.php | 29 +- src/Phalcon/db/RawValue.php | 13 +- src/Phalcon/db/Reference.php | 37 +- src/Phalcon/db/ReferenceInterface.php | 1 - src/Phalcon/db/ResultInterface.php | 1 - src/Phalcon/db/adapter/AbstractAdapter.php | 231 ++++++++--- src/Phalcon/db/adapter/AdapterInterface.php | 1 - src/Phalcon/db/adapter/PdoFactory.php | 17 +- src/Phalcon/db/adapter/pdo/AbstractPdo.php | 73 +++- src/Phalcon/db/adapter/pdo/Mysql.php | 21 +- src/Phalcon/db/adapter/pdo/Postgresql.php | 41 +- src/Phalcon/db/adapter/pdo/Sqlite.php | 33 +- src/Phalcon/db/dialect/Mysql.php | 113 +++-- src/Phalcon/db/dialect/Postgresql.php | 105 +++-- src/Phalcon/db/dialect/Sqlite.php | 109 +++-- src/Phalcon/db/profiler/Item.php | 45 +- src/Phalcon/db/result/Pdo.php | 37 +- src/Phalcon/debug/Dump.php | 45 +- src/Phalcon/di/AbstractInjectionAware.php | 9 +- src/Phalcon/di/DiInterface.php | 1 - src/Phalcon/di/FactoryDefault.php | 5 +- src/Phalcon/di/Injectable.php | 21 +- src/Phalcon/di/InjectionAwareInterface.php | 1 - src/Phalcon/di/Service.php | 41 +- src/Phalcon/di/ServiceInterface.php | 1 - src/Phalcon/di/ServiceProviderInterface.php | 1 - src/Phalcon/di/factorydefault/Cli.php | 5 +- src/Phalcon/di/service/Builder.php | 13 +- src/Phalcon/dispatcher/AbstractDispatcher.php | 137 ++++-- .../dispatcher/DispatcherInterface.php | 1 - src/Phalcon/dispatcher/Exception.php | 2 - src/Phalcon/domain/payload/Payload.php | 41 +- src/Phalcon/domain/payload/PayloadFactory.php | 5 +- .../domain/payload/ReadableInterface.php | 1 - src/Phalcon/domain/payload/Status.php | 5 +- .../domain/payload/WriteableInterface.php | 1 - src/Phalcon/escaper/EscaperInterface.php | 1 - src/Phalcon/events/Event.php | 37 +- src/Phalcon/events/EventInterface.php | 1 - src/Phalcon/events/EventsAwareInterface.php | 1 - src/Phalcon/events/Manager.php | 49 ++- src/Phalcon/events/ManagerInterface.php | 1 - src/Phalcon/factory/AbstractFactory.php | 13 +- src/Phalcon/filter/FilterFactory.php | 9 +- src/Phalcon/filter/FilterInterface.php | 1 - src/Phalcon/filter/sanitize/AbsInt.php | 5 +- src/Phalcon/filter/sanitize/Alnum.php | 5 +- src/Phalcon/filter/sanitize/Alpha.php | 5 +- src/Phalcon/filter/sanitize/BoolVal.php | 5 +- src/Phalcon/filter/sanitize/Email.php | 5 +- src/Phalcon/filter/sanitize/FloatVal.php | 5 +- src/Phalcon/filter/sanitize/IntVal.php | 5 +- src/Phalcon/filter/sanitize/Lower.php | 5 +- src/Phalcon/filter/sanitize/LowerFirst.php | 5 +- src/Phalcon/filter/sanitize/Regex.php | 5 +- src/Phalcon/filter/sanitize/Remove.php | 5 +- src/Phalcon/filter/sanitize/Replace.php | 5 +- src/Phalcon/filter/sanitize/Special.php | 5 +- src/Phalcon/filter/sanitize/SpecialFull.php | 5 +- src/Phalcon/filter/sanitize/StringVal.php | 5 +- src/Phalcon/filter/sanitize/Striptags.php | 5 +- src/Phalcon/filter/sanitize/Trim.php | 5 +- src/Phalcon/filter/sanitize/Upper.php | 5 +- src/Phalcon/filter/sanitize/UpperFirst.php | 5 +- src/Phalcon/filter/sanitize/UpperWords.php | 5 +- src/Phalcon/filter/sanitize/Url.php | 5 +- .../firewall/adapter/AbstractAdapter.php | 69 +++- src/Phalcon/firewall/adapter/Acl.php | 69 +++- .../firewall/adapter/AdapterInterface.php | 1 - src/Phalcon/firewall/adapter/Annotations.php | 41 +- src/Phalcon/firewall/adapter/micro/Acl.php | 73 +++- src/Phalcon/flash/AbstractFlash.php | 81 +++- src/Phalcon/flash/Direct.php | 9 +- src/Phalcon/flash/FlashInterface.php | 1 - src/Phalcon/flash/Session.php | 33 +- src/Phalcon/forms/Form.php | 137 ++++-- src/Phalcon/forms/Manager.php | 17 +- src/Phalcon/forms/element/AbstractElement.php | 129 ++++-- src/Phalcon/forms/element/Check.php | 5 +- src/Phalcon/forms/element/Date.php | 5 +- .../forms/element/ElementInterface.php | 1 - src/Phalcon/forms/element/Email.php | 5 +- src/Phalcon/forms/element/File.php | 5 +- src/Phalcon/forms/element/Hidden.php | 5 +- src/Phalcon/forms/element/Numeric.php | 5 +- src/Phalcon/forms/element/Password.php | 5 +- src/Phalcon/forms/element/Radio.php | 5 +- src/Phalcon/forms/element/Select.php | 21 +- src/Phalcon/forms/element/Submit.php | 5 +- src/Phalcon/forms/element/Text.php | 5 +- src/Phalcon/forms/element/TextArea.php | 5 +- src/Phalcon/helper/Arr.php | 85 +++- src/Phalcon/helper/Fs.php | 5 +- src/Phalcon/helper/Number.php | 5 +- src/Phalcon/helper/Str.php | 93 +++-- src/Phalcon/html/Attributes.php | 9 +- src/Phalcon/html/Breadcrumbs.php | 29 +- src/Phalcon/html/TagFactory.php | 13 +- .../html/attributes/AttributesInterface.php | 1 - .../html/attributes/RenderInterface.php | 1 - src/Phalcon/html/helper/AbstractHelper.php | 25 +- src/Phalcon/html/helper/Anchor.php | 5 +- src/Phalcon/html/helper/AnchorRaw.php | 5 +- src/Phalcon/html/helper/Body.php | 5 +- src/Phalcon/html/helper/Button.php | 5 +- src/Phalcon/html/helper/Close.php | 5 +- src/Phalcon/html/helper/Element.php | 5 +- src/Phalcon/html/helper/ElementRaw.php | 5 +- src/Phalcon/html/helper/Form.php | 5 +- src/Phalcon/html/helper/Img.php | 5 +- src/Phalcon/html/helper/Label.php | 5 +- src/Phalcon/html/helper/TextArea.php | 5 +- src/Phalcon/http/Cookie.php | 89 ++-- src/Phalcon/http/CookieInterface.php | 1 - src/Phalcon/http/Request.php | 269 +++++++++--- src/Phalcon/http/RequestInterface.php | 1 - src/Phalcon/http/Response.php | 137 ++++-- src/Phalcon/http/ResponseInterface.php | 1 - src/Phalcon/http/message/AbstractCommon.php | 13 +- src/Phalcon/http/message/AbstractMessage.php | 85 +++- src/Phalcon/http/message/AbstractRequest.php | 33 +- src/Phalcon/http/message/Request.php | 5 +- src/Phalcon/http/message/RequestFactory.php | 5 +- src/Phalcon/http/message/Response.php | 33 +- src/Phalcon/http/message/ResponseFactory.php | 5 +- src/Phalcon/http/message/ServerRequest.php | 61 ++- .../http/message/ServerRequestFactory.php | 65 ++- src/Phalcon/http/message/Stream.php | 89 ++-- src/Phalcon/http/message/StreamFactory.php | 13 +- src/Phalcon/http/message/UploadedFile.php | 45 +- .../http/message/UploadedFileFactory.php | 5 +- src/Phalcon/http/message/Uri.php | 97 +++-- src/Phalcon/http/message/UriFactory.php | 5 +- src/Phalcon/http/message/stream/Input.php | 21 +- src/Phalcon/http/message/stream/Memory.php | 5 +- src/Phalcon/http/message/stream/Temp.php | 5 +- src/Phalcon/http/request/File.php | 45 +- src/Phalcon/http/request/FileInterface.php | 1 - src/Phalcon/http/response/Cookies.php | 45 +- .../http/response/CookiesInterface.php | 1 - src/Phalcon/http/response/Headers.php | 33 +- .../http/response/HeadersInterface.php | 1 - .../http/server/AbstractMiddleware.php | 1 - .../http/server/AbstractRequestHandler.php | 1 - src/Phalcon/image/Enum.php | 2 - src/Phalcon/image/ImageFactory.php | 17 +- src/Phalcon/image/adapter/AbstractAdapter.php | 87 ++-- .../image/adapter/AdapterInterface.php | 1 - src/Phalcon/image/adapter/Gd.php | 79 +++- src/Phalcon/image/adapter/Imagick.php | 85 ++-- src/Phalcon/logger/AdapterFactory.php | 13 +- src/Phalcon/logger/Item.php | 25 +- src/Phalcon/logger/LoggerFactory.php | 13 +- .../logger/adapter/AbstractAdapter.php | 33 +- .../logger/adapter/AdapterInterface.php | 1 - src/Phalcon/logger/adapter/Noop.php | 9 +- src/Phalcon/logger/adapter/Stream.php | 17 +- src/Phalcon/logger/adapter/Syslog.php | 17 +- .../logger/formatter/AbstractFormatter.php | 5 +- .../logger/formatter/FormatterInterface.php | 1 - src/Phalcon/logger/formatter/Json.php | 17 +- src/Phalcon/logger/formatter/Line.php | 25 +- src/Phalcon/logger/formatter/Syslog.php | 5 +- src/Phalcon/messages/Message.php | 53 ++- src/Phalcon/messages/MessageInterface.php | 1 - src/Phalcon/messages/Messages.php | 61 ++- src/Phalcon/mvc/Application.php | 17 +- src/Phalcon/mvc/Controller.php | 5 +- src/Phalcon/mvc/Dispatcher.php | 53 ++- src/Phalcon/mvc/DispatcherInterface.php | 1 - src/Phalcon/mvc/EntityInterface.php | 1 - src/Phalcon/mvc/Micro.php | 145 +++++-- src/Phalcon/mvc/Model.php | 389 +++++++++++++----- src/Phalcon/mvc/ModelInterface.php | 1 - src/Phalcon/mvc/ModuleDefinitionInterface.php | 1 - src/Phalcon/mvc/Router.php | 169 ++++++-- src/Phalcon/mvc/RouterInterface.php | 1 - src/Phalcon/mvc/View.php | 217 +++++++--- src/Phalcon/mvc/ViewBaseInterface.php | 1 - src/Phalcon/mvc/ViewInterface.php | 1 - .../mvc/controller/BindModelInterface.php | 1 - src/Phalcon/mvc/micro/Collection.php | 69 +++- src/Phalcon/mvc/micro/CollectionInterface.php | 1 - src/Phalcon/mvc/micro/LazyLoader.php | 13 +- src/Phalcon/mvc/micro/MiddlewareInterface.php | 1 - src/Phalcon/mvc/model/Behavior.php | 21 +- src/Phalcon/mvc/model/BehaviorInterface.php | 1 - src/Phalcon/mvc/model/Binder.php | 37 +- src/Phalcon/mvc/model/BinderInterface.php | 1 - src/Phalcon/mvc/model/Criteria.php | 153 +++++-- src/Phalcon/mvc/model/CriteriaInterface.php | 1 - src/Phalcon/mvc/model/Manager.php | 249 ++++++++--- src/Phalcon/mvc/model/ManagerInterface.php | 1 - src/Phalcon/mvc/model/MetaData.php | 133 ++++-- src/Phalcon/mvc/model/MetaDataInterface.php | 1 - src/Phalcon/mvc/model/Query.php | 203 ++++++--- src/Phalcon/mvc/model/QueryInterface.php | 1 - src/Phalcon/mvc/model/Relation.php | 65 ++- src/Phalcon/mvc/model/RelationInterface.php | 1 - src/Phalcon/mvc/model/ResultInterface.php | 1 - src/Phalcon/mvc/model/Resultset.php | 100 +++-- src/Phalcon/mvc/model/ResultsetInterface.php | 1 - src/Phalcon/mvc/model/Row.php | 37 +- src/Phalcon/mvc/model/Transaction.php | 53 ++- .../mvc/model/TransactionInterface.php | 1 - src/Phalcon/mvc/model/ValidationFailed.php | 13 +- src/Phalcon/mvc/model/behavior/SoftDelete.php | 5 +- .../mvc/model/behavior/Timestampable.php | 9 +- .../mvc/model/binder/BindableInterface.php | 1 - src/Phalcon/mvc/model/metadata/Apcu.php | 5 +- .../mvc/model/metadata/Libmemcached.php | 9 +- src/Phalcon/mvc/model/metadata/Memory.php | 13 +- src/Phalcon/mvc/model/metadata/Redis.php | 9 +- .../mvc/model/metadata/StrategyInterface.php | 1 - src/Phalcon/mvc/model/metadata/Stream.php | 17 +- .../model/metadata/strategy/Annotations.php | 9 +- .../model/metadata/strategy/Introspection.php | 9 +- src/Phalcon/mvc/model/query/Builder.php | 209 +++++++--- .../mvc/model/query/BuilderInterface.php | 1 - src/Phalcon/mvc/model/query/Lang.php | 5 +- src/Phalcon/mvc/model/query/Status.php | 17 +- .../mvc/model/query/StatusInterface.php | 1 - src/Phalcon/mvc/model/resultset/Complex.php | 21 +- src/Phalcon/mvc/model/resultset/Simple.php | 21 +- src/Phalcon/mvc/model/transaction/Failed.php | 13 +- src/Phalcon/mvc/model/transaction/Manager.php | 69 +++- .../model/transaction/ManagerInterface.php | 1 - src/Phalcon/mvc/router/Annotations.php | 33 +- src/Phalcon/mvc/router/Group.php | 93 +++-- src/Phalcon/mvc/router/GroupInterface.php | 1 - src/Phalcon/mvc/router/Route.php | 111 +++-- src/Phalcon/mvc/router/RouteInterface.php | 1 - src/Phalcon/mvc/view/Simple.php | 77 +++- .../mvc/view/engine/AbstractEngine.php | 17 +- .../mvc/view/engine/EngineInterface.php | 1 - src/Phalcon/mvc/view/engine/Php.php | 5 +- src/Phalcon/mvc/view/engine/Volt.php | 41 +- src/Phalcon/mvc/view/engine/volt/Compiler.php | 185 ++++++--- .../mvc/view/engine/volt/Exception.php | 9 +- src/Phalcon/paginator/PaginatorFactory.php | 17 +- src/Phalcon/paginator/Repository.php | 57 ++- src/Phalcon/paginator/RepositoryInterface.php | 1 - .../paginator/adapter/AbstractAdapter.php | 25 +- .../paginator/adapter/AdapterInterface.php | 1 - src/Phalcon/paginator/adapter/Model.php | 5 +- src/Phalcon/paginator/adapter/NativeArray.php | 5 +- .../paginator/adapter/QueryBuilder.php | 21 +- src/Phalcon/security/Random.php | 37 +- src/Phalcon/session/Bag.php | 29 +- src/Phalcon/session/Manager.php | 93 +++-- src/Phalcon/session/ManagerInterface.php | 1 - .../session/adapter/AbstractAdapter.php | 25 +- src/Phalcon/session/adapter/Libmemcached.php | 5 +- src/Phalcon/session/adapter/Noop.php | 33 +- src/Phalcon/session/adapter/Redis.php | 7 +- src/Phalcon/session/adapter/Stream.php | 25 +- src/Phalcon/storage/AdapterFactory.php | 13 +- src/Phalcon/storage/SerializerFactory.php | 13 +- .../storage/adapter/AbstractAdapter.php | 37 +- .../storage/adapter/AdapterInterface.php | 1 - src/Phalcon/storage/adapter/Apcu.php | 41 +- src/Phalcon/storage/adapter/Libmemcached.php | 45 +- src/Phalcon/storage/adapter/Memory.php | 41 +- src/Phalcon/storage/adapter/Redis.php | 45 +- src/Phalcon/storage/adapter/Stream.php | 57 ++- .../storage/serializer/AbstractSerializer.php | 17 +- src/Phalcon/storage/serializer/Base64.php | 9 +- src/Phalcon/storage/serializer/Igbinary.php | 9 +- src/Phalcon/storage/serializer/Json.php | 9 +- src/Phalcon/storage/serializer/Msgpack.php | 9 +- src/Phalcon/storage/serializer/None.php | 9 +- src/Phalcon/storage/serializer/Php.php | 9 +- .../serializer/SerializerInterface.php | 1 - src/Phalcon/tag/Select.php | 13 +- src/Phalcon/translate/InterpolatorFactory.php | 13 +- src/Phalcon/translate/TranslateFactory.php | 17 +- .../translate/adapter/AbstractAdapter.php | 33 +- .../translate/adapter/AdapterInterface.php | 1 - src/Phalcon/translate/adapter/Csv.php | 17 +- src/Phalcon/translate/adapter/Gettext.php | 61 ++- src/Phalcon/translate/adapter/NativeArray.php | 17 +- .../interpolator/AssociativeArray.php | 5 +- .../translate/interpolator/IndexedArray.php | 5 +- .../interpolator/InterpolatorInterface.php | 1 - src/Phalcon/url/UrlInterface.php | 1 - src/Phalcon/validation/AbstractValidator.php | 45 +- .../validation/AbstractValidatorComposite.php | 9 +- .../validation/ValidationInterface.php | 1 - .../ValidatorCompositeInterface.php | 1 - src/Phalcon/validation/ValidatorFactory.php | 13 +- src/Phalcon/validation/ValidatorInterface.php | 1 - src/Phalcon/validation/validator/Alnum.php | 5 +- src/Phalcon/validation/validator/Alpha.php | 5 +- src/Phalcon/validation/validator/Between.php | 5 +- src/Phalcon/validation/validator/Callback.php | 5 +- .../validation/validator/Confirmation.php | 9 +- .../validation/validator/CreditCard.php | 9 +- src/Phalcon/validation/validator/Date.php | 9 +- src/Phalcon/validation/validator/Digit.php | 5 +- src/Phalcon/validation/validator/Email.php | 5 +- .../validation/validator/ExclusionIn.php | 5 +- src/Phalcon/validation/validator/File.php | 5 +- .../validation/validator/Identical.php | 5 +- .../validation/validator/InclusionIn.php | 5 +- src/Phalcon/validation/validator/Ip.php | 5 +- .../validation/validator/Numericality.php | 5 +- .../validation/validator/PresenceOf.php | 5 +- src/Phalcon/validation/validator/Regex.php | 5 +- .../validation/validator/StringLength.php | 5 +- .../validation/validator/Uniqueness.php | 17 +- src/Phalcon/validation/validator/Url.php | 5 +- .../validator/file/AbstractFile.php | 49 ++- .../validation/validator/file/MimeType.php | 5 +- .../validator/file/resolution/Equal.php | 5 +- .../validator/file/resolution/Max.php | 5 +- .../validator/file/resolution/Min.php | 5 +- .../validation/validator/file/size/Equal.php | 5 +- .../validation/validator/file/size/Max.php | 5 +- .../validation/validator/file/size/Min.php | 5 +- .../validation/validator/stringlength/Max.php | 5 +- .../validation/validator/stringlength/Min.php | 5 +- 406 files changed, 8352 insertions(+), 3194 deletions(-) create mode 100644 .travis.yml create mode 100644 phpcs.xml create mode 100644 psalm.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e863ba8b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: php + +php: + - '7.3' + +dist: bionic + +cache: + timeout: 604800 + directories: + - "$HOME/.composer/cache" + - "$HOME/assets" + +before_install: + - git config --global advice.detachedHead false + - if [ -n "$GITHUB_TOKEN" ]; then composer config github-oauth.github.com "$GITHUB_TOKEN"; fi + +before_script: + - travis_retry composer install --no-interaction --no-ansi --no-progress --no-suggest + +script: + - vendor/bin/psalm --show-info=false + - phpenv config-rm xdebug.ini || true + - vendor/bin/phpcs + +notifications: + email: false diff --git a/composer.json b/composer.json index 2ef2e113..bf3b684e 100644 --- a/composer.json +++ b/composer.json @@ -33,5 +33,9 @@ }, "require": { "php": ">=7.2.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "3.*", + "vimeo/psalm": "^3.4" } } diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..c3454726 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,12 @@ + + + Phalcon Coding Standards + + + + + + + + src + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..36ec92a1 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index 4c844d1f..fa7f9bf2 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -33,21 +33,27 @@ class Cache implements CacheInterface * * @return AdapterInterface */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Constructor. * * @param AdapterInterface $adapter The cache adapter */ - public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $adapter) {} + public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $adapter) + { + } /** * Wipes clean the entire cache's keys. * * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Delete an item from the cache by its unique key. @@ -60,7 +66,9 @@ public function clear(): bool {} * @param mixed $key * @return bool */ - public function delete($key): bool {} + public function delete($key): bool + { + } /** * Deletes multiple cache items in a single operation. @@ -73,7 +81,9 @@ public function delete($key): bool {} * @param mixed $keys * @return bool */ - public function deleteMultiple($keys): bool {} + public function deleteMultiple($keys): bool + { + } /** * Fetches a value from the cache. @@ -87,7 +97,9 @@ public function deleteMultiple($keys): bool {} * @param mixed $defaultValue * @return mixed */ - public function get($key, $defaultValue = null) {} + public function get($key, $defaultValue = null) + { + } /** * Obtains multiple cache items by their unique keys. @@ -101,7 +113,9 @@ public function get($key, $defaultValue = null) {} * @param mixed $defaultValue * @return mixed */ - public function getMultiple($keys, $defaultValue = null) {} + public function getMultiple($keys, $defaultValue = null) + { + } /** * Determines whether an item is present in the cache. @@ -114,7 +128,9 @@ public function getMultiple($keys, $defaultValue = null) {} * @param mixed $key * @return bool */ - public function has($key): bool {} + public function has($key): bool + { + } /** * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. @@ -131,7 +147,9 @@ public function has($key): bool {} * @param mixed $ttl * @return bool */ - public function set($key, $value, $ttl = null): bool {} + public function set($key, $value, $ttl = null): bool + { + } /** * Persists a set of key => value pairs in the cache, with an optional TTL. @@ -147,20 +165,25 @@ public function set($key, $value, $ttl = null): bool {} * @param mixed $ttl * @return bool */ - public function setMultiple($values, $ttl = null): bool {} + public function setMultiple($values, $ttl = null): bool + { + } /** * Checks the key. If it contains invalid characters an exception is thrown * * @param mixed $key */ - protected function checkKey($key) {} + protected function checkKey($key) + { + } /** * Checks the key. If it contains invalid characters an exception is thrown * * @param mixed $keys */ - protected function checkKeys($keys) {} - + protected function checkKeys($keys) + { + } } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index 34d86fb3..d19d68b1 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -54,7 +54,9 @@ class Collection implements * @param array $data * @param bool $insensitive */ - public function __construct(array $data = array(), bool $insensitive = true) {} + public function __construct(array $data = array(), bool $insensitive = true) + { + } /** * Magic getter to get an element from the collection @@ -62,7 +64,9 @@ public function __construct(array $data = array(), bool $insensitive = true) {} * @param string $element * @return mixed */ - public function __get(string $element) {} + public function __get(string $element) + { + } /** * Magic isset to check whether an element exists or not @@ -70,7 +74,9 @@ public function __get(string $element) {} * @param string $element * @return bool */ - public function __isset(string $element): bool {} + public function __isset(string $element): bool + { + } /** * Magic setter to assign values to an element @@ -78,19 +84,25 @@ public function __isset(string $element): bool {} * @param string $element * @param mixed $value */ - public function __set(string $element, $value) {} + public function __set(string $element, $value) + { + } /** * Magic unset to remove an element from the collection * * @param string $element */ - public function __unset(string $element) {} + public function __unset(string $element) + { + } /** * Clears the internal collection */ - public function clear() {} + public function clear() + { + } /** * Count elements of an object. @@ -98,7 +110,9 @@ public function clear() {} * * @return int */ - public function count(): int {} + public function count(): int + { + } /** * Get the element from the collection @@ -107,14 +121,18 @@ public function count(): int {} * @param mixed $defaultValue * @return mixed */ - public function get(string $element, $defaultValue = null) {} + public function get(string $element, $defaultValue = null) + { + } /** * Returns the iterator of the class * * @return \Traversable */ - public function getIterator(): Traversable {} + public function getIterator(): Traversable + { + } /** * Get the element from the collection @@ -122,14 +140,18 @@ public function getIterator(): Traversable {} * @param string $element * @return bool */ - public function has(string $element): bool {} + public function has(string $element): bool + { + } /** * Initialize internal array * * @param array $data */ - public function init(array $data = array()) {} + public function init(array $data = array()) + { + } /** * Specify data which should be serialized to JSON @@ -137,7 +159,9 @@ public function init(array $data = array()) {} * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Whether a offset exists @@ -146,7 +170,9 @@ public function jsonSerialize(): array {} * @param mixed $element * @return bool */ - public function offsetExists($element): bool {} + public function offsetExists($element): bool + { + } /** * Offset to retrieve @@ -154,7 +180,9 @@ public function offsetExists($element): bool {} * * @param mixed $element */ - public function offsetGet($element) {} + public function offsetGet($element) + { + } /** * Offset to set @@ -163,7 +191,9 @@ public function offsetGet($element) {} * @param mixed $element * @param mixed $value */ - public function offsetSet($element, $value) {} + public function offsetSet($element, $value) + { + } /** * Offset to unset @@ -171,14 +201,18 @@ public function offsetSet($element, $value) {} * * @param mixed $element */ - public function offsetUnset($element) {} + public function offsetUnset($element) + { + } /** * Delete the element from the collection * * @param string $element */ - public function remove(string $element) {} + public function remove(string $element) + { + } /** * Set an element in the collection @@ -186,7 +220,9 @@ public function remove(string $element) {} * @param string $element * @param mixed $value */ - public function set(string $element, $value) {} + public function set(string $element, $value) + { + } /** * String representation of object @@ -194,14 +230,18 @@ public function set(string $element, $value) {} * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Returns the object in an array format * * @return array */ - public function toArray(): array {} + public function toArray(): array + { + } /** * Returns the object in a JSON format @@ -216,7 +256,9 @@ public function toArray(): array {} * @param int $options * @return string */ - public function toJson(int $options = 79): string {} + public function toJson(int $options = 79): string + { + } /** * Constructs the object @@ -224,7 +266,9 @@ public function toJson(int $options = 79): string {} * * @param mixed $serialized */ - public function unserialize($serialized) {} + public function unserialize($serialized) + { + } /** * Internal method to set data @@ -232,6 +276,7 @@ public function unserialize($serialized) {} * @param string $element * @param mixed $value */ - protected function setData(string $element, $value) {} - + protected function setData(string $element, $value) + { + } } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index e21f8410..db171fb1 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -52,7 +52,9 @@ class Config extends Collection * * @return string */ - public function getPathDelimiter(): string {} + public function getPathDelimiter(): string + { + } /** * Merges a configuration into the current one @@ -72,7 +74,9 @@ public function getPathDelimiter(): string {} * @param mixed $toMerge * @return Config */ - public function merge($toMerge): Config {} + public function merge($toMerge): Config + { + } /** * Returns a value from current config using a dot separated path. @@ -85,7 +89,9 @@ public function merge($toMerge): Config {} * @param mixed $defaultValue * @param mixed $delimiter */ - public function path(string $path, $defaultValue = null, $delimiter = null) {} + public function path(string $path, $defaultValue = null, $delimiter = null) + { + } /** * Sets the default path delimiter @@ -93,7 +99,9 @@ public function path(string $path, $defaultValue = null, $delimiter = null) {} * @param string $delimiter * @return Config */ - public function setPathDelimiter(string $delimiter = null): Config {} + public function setPathDelimiter(string $delimiter = null): Config + { + } /** * Converts recursively the object to an array @@ -106,7 +114,9 @@ public function setPathDelimiter(string $delimiter = null): Config {} * * @return array */ - public function toArray(): array {} + public function toArray(): array + { + } /** * Performs a merge recursively @@ -115,7 +125,9 @@ public function toArray(): array {} * @param array $target * @return array */ - final protected function internalMerge(array $source, array $target): array {} + final protected function internalMerge(array $source, array $target): array + { + } /** * Sets the collection data @@ -123,6 +135,7 @@ final protected function internalMerge(array $source, array $target): array {} * @param mixed $element * @param mixed $value */ - protected function setData($element, $value) {} - + protected function setData($element, $value) + { + } } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index c734da9b..601c174e 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -30,7 +30,9 @@ class Container implements ContainerInterface * * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container) {} + public function __construct(\Phalcon\Di\DiInterface $container) + { + } /** * Return the service @@ -38,7 +40,9 @@ public function __construct(\Phalcon\Di\DiInterface $container) {} * @param mixed $name * @return mixed */ - public function get($name) {} + public function get($name) + { + } /** * Whether a service exists or not in the container @@ -46,6 +50,7 @@ public function get($name) {} * @param mixed $name * @return bool */ - public function has($name): bool {} - + public function has($name): bool + { + } } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 4f4aebaf..1a814c37 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -116,17 +116,23 @@ class Crypt implements CryptInterface /** * @return string */ - public function getAuthTag(): string {} + public function getAuthTag(): string + { + } /** * @return string */ - public function getAuthData(): string {} + public function getAuthData(): string + { + } /** * @return int */ - public function getAuthTagLength(): int {} + public function getAuthTagLength(): int + { + } /** * Phalcon\Crypt constructor. @@ -134,7 +140,9 @@ public function getAuthTagLength(): int {} * @param string $cipher * @param bool $useSigning */ - public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = false) {} + public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = false) + { + } /** * Decrypts an encrypted text. @@ -150,7 +158,9 @@ public function __construct(string $cipher = 'aes-256-cfb', bool $useSigning = f * @param string $key * @return string */ - public function decrypt(string $text, string $key = null): string {} + public function decrypt(string $text, string $key = null): string + { + } /** * Decrypt a text that is coded as a base64 string. @@ -161,7 +171,9 @@ public function decrypt(string $text, string $key = null): string {} * @param bool $safe * @return string */ - public function decryptBase64(string $text, $key = null, bool $safe = false): string {} + public function decryptBase64(string $text, $key = null, bool $safe = false): string + { + } /** * Encrypts a text. @@ -177,7 +189,9 @@ public function decryptBase64(string $text, $key = null, bool $safe = false): st * @param string $key * @return string */ - public function encrypt(string $text, string $key = null): string {} + public function encrypt(string $text, string $key = null): string + { + } /** * Encrypts a text returning the result as a base64 string. @@ -187,60 +201,78 @@ public function encrypt(string $text, string $key = null): string {} * @param bool $safe * @return string */ - public function encryptBase64(string $text, $key = null, bool $safe = false): string {} + public function encryptBase64(string $text, $key = null, bool $safe = false): string + { + } /** * Returns a list of available ciphers. * * @return array */ - public function getAvailableCiphers(): array {} + public function getAvailableCiphers(): array + { + } /** * Return a list of registered hashing algorithms suitable for hash_hmac. * * @return array */ - public function getAvailableHashAlgos(): array {} + public function getAvailableHashAlgos(): array + { + } /** * Returns the current cipher * * @return string */ - public function getCipher(): string {} + public function getCipher(): string + { + } /** * Get the name of hashing algorithm. * * @return string */ - public function getHashAlgo(): string {} + public function getHashAlgo(): string + { + } /** * Returns the encryption key * * @return string */ - public function getKey(): string {} + public function getKey(): string + { + } /** * @param string $tag * @return \Phalcon\Crypt\CryptInterface */ - public function setAuthTag(string $tag): CryptInterface {} + public function setAuthTag(string $tag): CryptInterface + { + } /** * @param string $data * @return \Phalcon\Crypt\CryptInterface */ - public function setAuthData(string $data): CryptInterface {} + public function setAuthData(string $data): CryptInterface + { + } /** * @param int $length * @return \Phalcon\Crypt\CryptInterface */ - public function setAuthTagLength(int $length): CryptInterface {} + public function setAuthTagLength(int $length): CryptInterface + { + } /** * Sets the cipher algorithm for data encryption and decryption. @@ -254,7 +286,9 @@ public function setAuthTagLength(int $length): CryptInterface {} * @param string $cipher * @return \Phalcon\Crypt\CryptInterface */ - public function setCipher(string $cipher): CryptInterface {} + public function setCipher(string $cipher): CryptInterface + { + } /** * Set the name of hashing algorithm. @@ -263,7 +297,9 @@ public function setCipher(string $cipher): CryptInterface {} * @param string $hashAlgo * @return \Phalcon\Crypt\CryptInterface */ - public function setHashAlgo(string $hashAlgo): CryptInterface {} + public function setHashAlgo(string $hashAlgo): CryptInterface + { + } /** * Sets the encryption key. @@ -283,7 +319,9 @@ public function setHashAlgo(string $hashAlgo): CryptInterface {} * @param string $key * @return \Phalcon\Crypt\CryptInterface */ - public function setKey(string $key): CryptInterface {} + public function setKey(string $key): CryptInterface + { + } /** * Changes the padding scheme used. @@ -291,7 +329,9 @@ public function setKey(string $key): CryptInterface {} * @param int $scheme * @return \Phalcon\Crypt\CryptInterface */ - public function setPadding(int $scheme): CryptInterface {} + public function setPadding(int $scheme): CryptInterface + { + } /** * Sets if the calculating message digest must used. @@ -299,21 +339,27 @@ public function setPadding(int $scheme): CryptInterface {} * @param bool $useSigning * @return \Phalcon\Crypt\CryptInterface */ - public function useSigning(bool $useSigning): CryptInterface {} + public function useSigning(bool $useSigning): CryptInterface + { + } /** * Assert the cipher is available. * * @param string $cipher */ - protected function assertCipherIsAvailable(string $cipher) {} + protected function assertCipherIsAvailable(string $cipher) + { + } /** * Assert the hash algorithm is available. * * @param string $hashAlgo */ - protected function assertHashAlgorithmAvailable(string $hashAlgo) {} + protected function assertHashAlgorithmAvailable(string $hashAlgo) + { + } /** * Initialize available cipher algorithms. @@ -321,12 +367,16 @@ protected function assertHashAlgorithmAvailable(string $hashAlgo) {} * @param string $cipher * @return int */ - protected function getIvLength(string $cipher): int {} + protected function getIvLength(string $cipher): int + { + } /** * Initialize available cipher algorithms. */ - protected function initializeAvailableCiphers() {} + protected function initializeAvailableCiphers() + { + } /** * Pads texts before encryption. See [cryptopad](http://www.di-mgt.com.au/cryptopad.html) @@ -337,7 +387,9 @@ protected function initializeAvailableCiphers() {} * @param int $paddingType * @return string */ - protected function cryptPadText(string $text, string $mode, int $blockSize, int $paddingType): string {} + protected function cryptPadText(string $text, string $mode, int $blockSize, int $paddingType): string + { + } /** * Removes a padding from a text. @@ -350,6 +402,7 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int * @param int $blockSize * @param int $paddingType */ - protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) {} - + protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) + { + } } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 11e08ed9..d2ec1830 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -32,7 +32,7 @@ class Debug /** * @var bool */ - static protected $isActive; + protected static $isActive; /** * @var bool @@ -60,7 +60,9 @@ class Debug * * @return Debug */ - public function clearVars(): Debug {} + public function clearVars(): Debug + { + } /** * Adds a variable to the debug output @@ -69,33 +71,43 @@ public function clearVars(): Debug {} * @param string $key * @return Debug */ - public function debugVar($varz, string $key = null): Debug {} + public function debugVar($varz, string $key = null): Debug + { + } /** * Returns the css sources * * @return string */ - public function getCssSources(): string {} + public function getCssSources(): string + { + } /** * Returns the javascript sources * * @return string */ - public function getJsSources(): string {} + public function getJsSources(): string + { + } /** * Generates a link to the current version documentation * * @return string */ - public function getVersion(): string {} + public function getVersion(): string + { + } /** * Halts the request showing a backtrace */ - public function halt() {} + public function halt() + { + } /** * Listen for uncaught exceptions and unsilent notices or warnings @@ -104,21 +116,27 @@ public function halt() {} * @param bool $lowSeverity * @return Debug */ - public function listen(bool $exceptions = true, bool $lowSeverity = false): Debug {} + public function listen(bool $exceptions = true, bool $lowSeverity = false): Debug + { + } /** * Listen for uncaught exceptions * * @return Debug */ - public function listenExceptions(): Debug {} + public function listenExceptions(): Debug + { + } /** * Listen for unsilent notices or warnings * * @return Debug */ - public function listenLowSeverity(): Debug {} + public function listenLowSeverity(): Debug + { + } /** * Handles uncaught exceptions @@ -126,7 +144,9 @@ public function listenLowSeverity(): Debug {} * @param \Exception $exception * @return bool */ - public function onUncaughtException(\Exception $exception): bool {} + public function onUncaughtException(\Exception $exception): bool + { + } /** * Throws an exception when a notice or warning is raised @@ -137,7 +157,9 @@ public function onUncaughtException(\Exception $exception): bool {} * @param mixed $line * @param mixed $context */ - public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) {} + public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) + { + } /** * Sets if files the exception's backtrace must be showed @@ -145,7 +167,9 @@ public function onUncaughtLowSeverity($severity, $message, $file, $line, $contex * @param array $blacklist * @return Debug */ - public function setBlacklist(array $blacklist): Debug {} + public function setBlacklist(array $blacklist): Debug + { + } /** * Sets if files the exception's backtrace must be showed @@ -153,7 +177,9 @@ public function setBlacklist(array $blacklist): Debug {} * @param bool $showBackTrace * @return Debug */ - public function setShowBackTrace(bool $showBackTrace): Debug {} + public function setShowBackTrace(bool $showBackTrace): Debug + { + } /** * Sets if files must be completely opened and showed in the output @@ -162,7 +188,9 @@ public function setShowBackTrace(bool $showBackTrace): Debug {} * @param bool $showFileFragment * @return Debug */ - public function setShowFileFragment(bool $showFileFragment): Debug {} + public function setShowFileFragment(bool $showFileFragment): Debug + { + } /** * Set if files part of the backtrace must be shown in the output @@ -170,7 +198,9 @@ public function setShowFileFragment(bool $showFileFragment): Debug {} * @param bool $showFiles * @return Debug */ - public function setShowFiles(bool $showFiles): Debug {} + public function setShowFiles(bool $showFiles): Debug + { + } /** * Change the base URI for static resources @@ -178,7 +208,9 @@ public function setShowFiles(bool $showFiles): Debug {} * @param string $uri * @return Debug */ - public function setUri(string $uri): Debug {} + public function setUri(string $uri): Debug + { + } /** * Escapes a string with htmlentities @@ -186,7 +218,9 @@ public function setUri(string $uri): Debug {} * @param mixed $value * @return string */ - protected function escapeString($value): string {} + protected function escapeString($value): string + { + } /** * Produces a recursive representation of an array @@ -195,7 +229,9 @@ protected function escapeString($value): string {} * @param mixed $n * @return string|null */ - protected function getArrayDump(array $argument, $n = 0): ?string {} + protected function getArrayDump(array $argument, $n = 0): ?string + { + } /** * Produces an string representation of a variable @@ -203,7 +239,9 @@ protected function getArrayDump(array $argument, $n = 0): ?string {} * @param mixed $variable * @return string */ - protected function getVarDump($variable): string {} + protected function getVarDump($variable): string + { + } /** * Shows a backtrace item @@ -212,6 +250,7 @@ protected function getVarDump($variable): string {} * @param array $trace * @return string */ - final protected function showTraceItem(int $n, array $trace): string {} - + final protected function showTraceItem(int $n, array $trace): string + { + } } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 59d5b5a6..38ff5f68 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -76,13 +76,15 @@ class Di implements DiInterface /** * Latest DI build */ - static protected $_default; + protected static $_default; /** * Phalcon\Di constructor */ - public function __construct() {} + public function __construct() + { + } /** * Magic method to get or set services using setters/getters @@ -91,7 +93,9 @@ public function __construct() {} * @param array $arguments * @return mixed|null */ - public function __call(string $method, array $arguments = array()) {} + public function __call(string $method, array $arguments = array()) + { + } /** * Attempts to register a service in the services container @@ -103,7 +107,9 @@ public function __call(string $method, array $arguments = array()) {} * @param bool $shared * @return bool|\Phalcon\Di\ServiceInterface */ - public function attempt(string $name, $definition, bool $shared = false) {} + public function attempt(string $name, $definition, bool $shared = false) + { + } /** * Resolves the service based on its configuration @@ -112,21 +118,27 @@ public function attempt(string $name, $definition, bool $shared = false) {} * @param mixed $parameters * @return mixed */ - public function get(string $name, $parameters = null) {} + public function get(string $name, $parameters = null) + { + } /** * Return the latest DI created * * @return null|\Phalcon\Di\DiInterface */ - public static function getDefault(): ?DiInterface {} + public static function getDefault(): ?DiInterface + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getInternalEventsManager(): ManagerInterface {} + public function getInternalEventsManager(): ManagerInterface + { + } /** * Returns a service definition without resolving @@ -134,7 +146,9 @@ public function getInternalEventsManager(): ManagerInterface {} * @param string $name * @return mixed */ - public function getRaw(string $name) {} + public function getRaw(string $name) + { + } /** * Returns a Phalcon\Di\Service instance @@ -142,14 +156,18 @@ public function getRaw(string $name) {} * @param string $name * @return \Phalcon\Di\ServiceInterface */ - public function getService(string $name): ServiceInterface {} + public function getService(string $name): ServiceInterface + { + } /** * Return the services registered in the DI * * @return array|\Phalcon\Di\ServiceInterface[] */ - public function getServices(): array {} + public function getServices(): array + { + } /** * Resolves a service, the resolved service is stored in the DI, subsequent @@ -159,14 +177,18 @@ public function getServices(): array {} * @param mixed $parameters * @return mixed */ - public function getShared(string $name, $parameters = null) {} + public function getShared(string $name, $parameters = null) + { + } /** * Loads services from a Config object. * * @param \Phalcon\Config $config */ - protected function loadFromConfig(\Phalcon\Config $config) {} + protected function loadFromConfig(\Phalcon\Config $config) + { + } /** * Loads services from a php config file. @@ -201,7 +223,9 @@ protected function loadFromConfig(\Phalcon\Config $config) {} * @link https://docs.phalcon.io/en/latest/reference/di.html * @param string $filePath */ - public function loadFromPhp(string $filePath) {} + public function loadFromPhp(string $filePath) + { + } /** * Loads services from a yaml file. @@ -238,7 +262,9 @@ public function loadFromPhp(string $filePath) {} * @param string $filePath * @param array $callbacks */ - public function loadFromYaml(string $filePath, array $callbacks = null) {} + public function loadFromYaml(string $filePath, array $callbacks = null) + { + } /** * Check whether the DI contains a service by a name @@ -246,7 +272,9 @@ public function loadFromYaml(string $filePath, array $callbacks = null) {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Allows to obtain a shared service using the array syntax @@ -258,7 +286,9 @@ public function has(string $name): bool {} * @param mixed $name * @return mixed */ - public function offsetGet($name) {} + public function offsetGet($name) + { + } /** * Check if a service is registered using the array syntax @@ -266,7 +296,9 @@ public function offsetGet($name) {} * @param mixed $name * @return bool */ - public function offsetExists($name): bool {} + public function offsetExists($name): bool + { + } /** * Allows to register a shared service using the array syntax @@ -278,14 +310,18 @@ public function offsetExists($name): bool {} * @param mixed $name * @param mixed $definition */ - public function offsetSet($name, $definition) {} + public function offsetSet($name, $definition) + { + } /** * Removes a service from the services container using the array syntax * * @param mixed $name */ - public function offsetUnset($name) {} + public function offsetUnset($name) + { + } /** * Registers a service provider. @@ -310,7 +346,9 @@ public function offsetUnset($name) {} * * @param \Phalcon\Di\ServiceProviderInterface $provider */ - public function register(\Phalcon\Di\ServiceProviderInterface $provider) {} + public function register(\Phalcon\Di\ServiceProviderInterface $provider) + { + } /** * Removes a service in the services container @@ -318,12 +356,16 @@ public function register(\Phalcon\Di\ServiceProviderInterface $provider) {} * * @param string $name */ - public function remove(string $name) {} + public function remove(string $name) + { + } /** * Resets the internal default DI */ - public static function reset() {} + public static function reset() + { + } /** * Registers a service in the services container @@ -333,7 +375,9 @@ public static function reset() {} * @param bool $shared * @return \Phalcon\Di\ServiceInterface */ - public function set(string $name, $definition, bool $shared = false): ServiceInterface {} + public function set(string $name, $definition, bool $shared = false): ServiceInterface + { + } /** * Set a default dependency injection container to be obtained into static @@ -341,14 +385,18 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * * @param \Phalcon\Di\DiInterface $container */ - public static function setDefault(\Phalcon\Di\DiInterface $container) {} + public static function setDefault(\Phalcon\Di\DiInterface $container) + { + } /** * Sets the internal event manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets a service using a raw Phalcon\Di\Service definition @@ -357,7 +405,9 @@ public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $event * @param \Phalcon\Di\ServiceInterface $rawDefinition * @return \Phalcon\Di\ServiceInterface */ - public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface {} + public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface + { + } /** * Registers an "always shared" service in the services container @@ -366,6 +416,7 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition * @param mixed $definition * @return \Phalcon\Di\ServiceInterface */ - public function setShared(string $name, $definition): ServiceInterface {} - + public function setShared(string $name, $definition): ServiceInterface + { + } } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index f6c9a990..fc30325e 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -57,7 +57,9 @@ class Escaper implements EscaperInterface * @param string $str * @return string|null */ - final public function detectEncoding(string $str): ?string {} + final public function detectEncoding(string $str): ?string + { + } /** * Escape CSS strings by replacing non-alphanumeric chars by their @@ -66,7 +68,9 @@ final public function detectEncoding(string $str): ?string {} * @param string $css * @return string */ - public function escapeCss(string $css): string {} + public function escapeCss(string $css): string + { + } /** * Escape javascript strings by replacing non-alphanumeric chars by their @@ -75,7 +79,9 @@ public function escapeCss(string $css): string {} * @param string $js * @return string */ - public function escapeJs(string $js): string {} + public function escapeJs(string $js): string + { + } /** * Escapes a HTML string. Internally uses htmlspecialchars @@ -83,7 +89,9 @@ public function escapeJs(string $js): string {} * @param string $text * @return string */ - public function escapeHtml(string $text): string {} + public function escapeHtml(string $text): string + { + } /** * Escapes a HTML attribute string @@ -91,7 +99,9 @@ public function escapeHtml(string $text): string {} * @param string $attribute * @return string */ - public function escapeHtmlAttr(string $attribute): string {} + public function escapeHtmlAttr(string $attribute): string + { + } /** * Escapes a URL. Internally uses rawurlencode @@ -99,14 +109,18 @@ public function escapeHtmlAttr(string $attribute): string {} * @param string $url * @return string */ - public function escapeUrl(string $url): string {} + public function escapeUrl(string $url): string + { + } /** * Returns the internal encoding used by the escaper * * @return string */ - public function getEncoding(): string {} + public function getEncoding(): string + { + } /** * Utility to normalize a string's encoding to UTF-32. @@ -114,7 +128,9 @@ public function getEncoding(): string {} * @param string $str * @return string */ - final public function normalizeEncoding(string $str): string {} + final public function normalizeEncoding(string $str): string + { + } /** * Sets the double_encode to be used by the escaper @@ -125,7 +141,9 @@ final public function normalizeEncoding(string $str): string {} * * @param bool $doubleEncode */ - public function setDoubleEncode(bool $doubleEncode) {} + public function setDoubleEncode(bool $doubleEncode) + { + } /** * Sets the encoding to be used by the escaper @@ -136,7 +154,9 @@ public function setDoubleEncode(bool $doubleEncode) {} * * @param string $encoding */ - public function setEncoding(string $encoding) {} + public function setEncoding(string $encoding) + { + } /** * Sets the HTML quoting type for htmlspecialchars @@ -147,6 +167,7 @@ public function setEncoding(string $encoding) {} * * @param int $quoteType */ - public function setHtmlQuoteType(int $quoteType) {} - + public function setHtmlQuoteType(int $quoteType) + { + } } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 916eb89f..3e4fb7de 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -25,6 +25,7 @@ class Exception extends \Exception implements Throwable * @param string $service * @return string */ - public static function containerServiceNotFound(string $service): string {} - + public static function containerServiceNotFound(string $service): string + { + } } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index d9c45215..68914484 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -98,7 +98,9 @@ class Filter implements FilterInterface * * @param array $mapper */ - public function __construct(array $mapper = array()) {} + public function __construct(array $mapper = array()) + { + } /** * Get a service. If it is not in the mapper array, create a new object, @@ -107,7 +109,9 @@ public function __construct(array $mapper = array()) {} * @param string $name * @return object */ - public function get(string $name) {} + public function get(string $name) + { + } /** * Checks if a service exists in the map array @@ -115,7 +119,9 @@ public function get(string $name) {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Sanitizes a value with a specified single or set of sanitizers @@ -125,7 +131,9 @@ public function has(string $name): bool {} * @param bool $noRecursive * @return mixed */ - public function sanitize($value, $sanitizers, bool $noRecursive = false) {} + public function sanitize($value, $sanitizers, bool $noRecursive = false) + { + } /** * Set a new service to the mapper array @@ -133,14 +141,18 @@ public function sanitize($value, $sanitizers, bool $noRecursive = false) {} * @param string $name * @param callable $service */ - public function set(string $name, $service) {} + public function set(string $name, $service) + { + } /** * Loads the objects in the internal mapper array * * @param array $mapper */ - protected function init(array $mapper) {} + protected function init(array $mapper) + { + } /** * Processes the array values with the relevant sanitizers @@ -150,7 +162,9 @@ protected function init(array $mapper) {} * @param array $sanitizerParams * @return array */ - private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = array()): array {} + private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = array()): array + { + } /** * Internal sanitize wrapper for recursion @@ -160,6 +174,7 @@ private function processArrayValues(array $values, string $sanitizerName, array * @param array $sanitizerParams * @return mixed */ - private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) {} - + private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) + { + } } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index ba6ba1ea..7f859101 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -24,6 +24,7 @@ class Kernel * @param string $key * @return string */ - public static function preComputeHashKey(string $key) {} - + public static function preComputeHashKey(string $key) + { + } } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 20f5168f..20e79b0b 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -93,68 +93,88 @@ class Loader implements EventsAwareInterface * @param string $className * @return bool */ - public function autoLoad(string $className): bool {} + public function autoLoad(string $className): bool + { + } /** * Get the path the loader is checking for a path * * @return string */ - public function getCheckedPath(): string {} + public function getCheckedPath(): string + { + } /** * Returns the class-map currently registered in the autoloader * * @return array */ - public function getClasses(): array {} + public function getClasses(): array + { + } /** * Returns the directories currently registered in the autoloader * * @return array */ - public function getDirs(): array {} + public function getDirs(): array + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Returns the file extensions registered in the loader * * @return array */ - public function getExtensions(): array {} + public function getExtensions(): array + { + } /** * Returns the files currently registered in the autoloader * * @return array */ - public function getFiles(): array {} + public function getFiles(): array + { + } /** * Get the path when a class was found * * @return string */ - public function getFoundPath(): string {} + public function getFoundPath(): string + { + } /** * Returns the namespaces currently registered in the autoloader * * @return array */ - public function getNamespaces(): array {} + public function getNamespaces(): array + { + } /** * Checks if a file exists and then adds the file by doing virtual require */ - public function loadFiles() {} + public function loadFiles() + { + } /** * Register the autoload method @@ -162,7 +182,9 @@ public function loadFiles() {} * @param bool $prepend * @return Loader */ - public function register(bool $prepend = false): Loader {} + public function register(bool $prepend = false): Loader + { + } /** * Register classes and their locations @@ -171,7 +193,9 @@ public function register(bool $prepend = false): Loader {} * @param bool $merge * @return Loader */ - public function registerClasses(array $classes, bool $merge = false): Loader {} + public function registerClasses(array $classes, bool $merge = false): Loader + { + } /** * Register directories in which "not found" classes could be found @@ -180,7 +204,9 @@ public function registerClasses(array $classes, bool $merge = false): Loader {} * @param bool $merge * @return Loader */ - public function registerDirs(array $directories, bool $merge = false): Loader {} + public function registerDirs(array $directories, bool $merge = false): Loader + { + } /** * Registers files that are "non-classes" hence need a "require". This is @@ -190,7 +216,9 @@ public function registerDirs(array $directories, bool $merge = false): Loader {} * @param bool $merge * @return Loader */ - public function registerFiles(array $files, bool $merge = false): Loader {} + public function registerFiles(array $files, bool $merge = false): Loader + { + } /** * Register namespaces and their related directories @@ -199,14 +227,18 @@ public function registerFiles(array $files, bool $merge = false): Loader {} * @param bool $merge * @return Loader */ - public function registerNamespaces(array $namespaces, bool $merge = false): Loader {} + public function registerNamespaces(array $namespaces, bool $merge = false): Loader + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets an array of file extensions that the loader must try in each attempt @@ -215,7 +247,9 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * @param array $extensions * @return Loader */ - public function setExtensions(array $extensions): Loader {} + public function setExtensions(array $extensions): Loader + { + } /** * Sets the file check callback. @@ -235,19 +269,24 @@ public function setExtensions(array $extensions): Loader {} * @param mixed $callback * @return Loader */ - public function setFileCheckingCallback($callback = null): Loader {} + public function setFileCheckingCallback($callback = null): Loader + { + } /** * Unregister the autoload method * * @return Loader */ - public function unregister(): Loader {} + public function unregister(): Loader + { + } /** * @param array $namespaceName * @return array */ - protected function prepareNamespace(array $namespaceName): array {} - + protected function prepareNamespace(array $namespaceName): array + { + } } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 11b07316..1bc59d09 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -104,7 +104,9 @@ class Logger implements LoggerInterface * @param string $name The name of the logger * @param array $adapters The collection of adapters to be used for logging (default []) */ - public function __construct(string $name, array $adapters = array()) {} + public function __construct(string $name, array $adapters = array()) + { + } /** * Add an adapter to the stack. For processing we use FIFO @@ -113,7 +115,9 @@ public function __construct(string $name, array $adapters = array()) {} * @param $adapter The adapter to add to the stack * @return Logger */ - public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger {} + public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger + { + } /** * Action must be taken immediately. @@ -124,7 +128,9 @@ public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterfac * @param string $message * @param array $context */ - public function alert($message, array $context = array()) {} + public function alert($message, array $context = array()) + { + } /** * Critical conditions. @@ -134,7 +140,9 @@ public function alert($message, array $context = array()) {} * @param string $message * @param array $context */ - public function critical($message, array $context = array()) {} + public function critical($message, array $context = array()) + { + } /** * Detailed debug information. @@ -142,7 +150,9 @@ public function critical($message, array $context = array()) {} * @param string $message * @param array $context */ - public function debug($message, array $context = array()) {} + public function debug($message, array $context = array()) + { + } /** * Runtime errors that do not require immediate action but should typically @@ -151,7 +161,9 @@ public function debug($message, array $context = array()) {} * @param string $message * @param array $context */ - public function error($message, array $context = array()) {} + public function error($message, array $context = array()) + { + } /** * System is unusable. @@ -159,7 +171,9 @@ public function error($message, array $context = array()) {} * @param string $message * @param array $context */ - public function emergency($message, array $context = array()) {} + public function emergency($message, array $context = array()) + { + } /** * Exclude certain adapters. @@ -167,7 +181,9 @@ public function emergency($message, array $context = array()) {} * @param array $adapters * @return Logger */ - public function excludeAdapters(array $adapters = array()): Logger {} + public function excludeAdapters(array $adapters = array()): Logger + { + } /** * Returns an adapter from the stack @@ -178,21 +194,27 @@ public function excludeAdapters(array $adapters = array()): Logger {} * @param string $name * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function getAdapter(string $name): AdapterInterface {} + public function getAdapter(string $name): AdapterInterface + { + } /** * Returns the adapter stack array * * @return array */ - public function getAdapters(): array {} + public function getAdapters(): array + { + } /** * Returns the name of the logger * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Interesting events. @@ -202,7 +224,9 @@ public function getName(): string {} * @param string $message * @param array $context */ - public function info($message, array $context = array()) {} + public function info($message, array $context = array()) + { + } /** * Logs with an arbitrary level. @@ -211,7 +235,9 @@ public function info($message, array $context = array()) {} * @param string $message * @param array $context */ - public function log($level, $message, array $context = array()) {} + public function log($level, $message, array $context = array()) + { + } /** * Normal but significant events. @@ -219,7 +245,9 @@ public function log($level, $message, array $context = array()) {} * @param string $message * @param array $context */ - public function notice($message, array $context = array()) {} + public function notice($message, array $context = array()) + { + } /** * Removes an adapter from the stack @@ -230,7 +258,9 @@ public function notice($message, array $context = array()) {} * @param string $name * @return Logger */ - public function removeAdapter(string $name): Logger {} + public function removeAdapter(string $name): Logger + { + } /** * Sets the adapters stack overriding what is already there @@ -238,7 +268,9 @@ public function removeAdapter(string $name): Logger {} * @param array $adapters An array of adapters * @return Logger */ - public function setAdapters(array $adapters): Logger {} + public function setAdapters(array $adapters): Logger + { + } /** * Exceptional occurrences that are not errors. @@ -249,7 +281,9 @@ public function setAdapters(array $adapters): Logger {} * @param string $message * @param array $context */ - public function warning($message, array $context = array()) {} + public function warning($message, array $context = array()) + { + } /** * Adds a message to each handler for processing @@ -262,14 +296,18 @@ public function warning($message, array $context = array()) {} * @param array $context * @return bool */ - protected function addMessage(int $level, string $message, array $context = array()): bool {} + protected function addMessage(int $level, string $message, array $context = array()): bool + { + } /** * Returns an array of log levels with integer to string conversion * * @return array */ - protected function getLevels(): array {} + protected function getLevels(): array + { + } /** * Converts the level from string/word to an integer @@ -277,6 +315,7 @@ protected function getLevels(): array {} * @param string|int $level * @return int */ - private function getLevelNumber($level): int {} - + private function getLevelNumber($level): int + { + } } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 92a17413..207cc786 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -71,7 +71,9 @@ final class Registry extends Collection * * @param array $data */ - final public function __construct(array $data = null) {} + final public function __construct(array $data = null) + { + } /** * Magic getter to get an element from the collection @@ -79,7 +81,9 @@ final public function __construct(array $data = null) {} * @param string $element * @return mixed */ - final public function __get(string $element) {} + final public function __get(string $element) + { + } /** * Magic isset to check whether an element exists or not @@ -87,7 +91,9 @@ final public function __get(string $element) {} * @param string $element * @return bool */ - final public function __isset(string $element): bool {} + final public function __isset(string $element): bool + { + } /** * Magic setter to assign values to an element @@ -95,19 +101,25 @@ final public function __isset(string $element): bool {} * @param string $element * @param mixed $value */ - final public function __set(string $element, $value) {} + final public function __set(string $element, $value) + { + } /** * Magic unset to remove an element from the collection * * @param string $element */ - final public function __unset(string $element) {} + final public function __unset(string $element) + { + } /** * Clears the internal collection */ - final public function clear() {} + final public function clear() + { + } /** * Count elements of an object @@ -115,7 +127,9 @@ final public function clear() {} * @link https://php.net/manual/en/countable.count.php * @return int */ - final public function count(): int {} + final public function count(): int + { + } /** * Get the element from the collection @@ -124,14 +138,18 @@ final public function count(): int {} * @param mixed $defaultValue * @return mixed */ - final public function get(string $element, $defaultValue = null) {} + final public function get(string $element, $defaultValue = null) + { + } /** * Returns the iterator of the class * * @return \Traversable */ - final public function getIterator(): Traversable {} + final public function getIterator(): Traversable + { + } /** * Get the element from the collection @@ -139,14 +157,18 @@ final public function getIterator(): Traversable {} * @param string $element * @return bool */ - final public function has(string $element): bool {} + final public function has(string $element): bool + { + } /** * Initialize internal array * * @param array $data */ - final public function init(array $data = array()) {} + final public function init(array $data = array()) + { + } /** * Specify data which should be serialized to JSON @@ -154,7 +176,9 @@ final public function init(array $data = array()) {} * @link https://php.net/manual/en/jsonserializable.jsonserialize.php * @return array */ - final public function jsonSerialize(): array {} + final public function jsonSerialize(): array + { + } /** * Whether a offset exists @@ -163,7 +187,9 @@ final public function jsonSerialize(): array {} * @param mixed $element * @return bool */ - final public function offsetExists($element): bool {} + final public function offsetExists($element): bool + { + } /** * Offset to retrieve @@ -172,7 +198,9 @@ final public function offsetExists($element): bool {} * @param mixed $element * @return mixed */ - final public function offsetGet($element) {} + final public function offsetGet($element) + { + } /** * Offset to set @@ -181,7 +209,9 @@ final public function offsetGet($element) {} * @param mixed $element * @param mixed $value */ - final public function offsetSet($element, $value) {} + final public function offsetSet($element, $value) + { + } /** * Offset to unset @@ -189,14 +219,18 @@ final public function offsetSet($element, $value) {} * @link https://php.net/manual/en/arrayaccess.offsetunset.php * @param mixed $element */ - final public function offsetUnset($element) {} + final public function offsetUnset($element) + { + } /** * Delete the element from the collection * * @param string $element */ - final public function remove(string $element) {} + final public function remove(string $element) + { + } /** * String representation of object @@ -204,7 +238,9 @@ final public function remove(string $element) {} * @link https://php.net/manual/en/serializable.serialize.php * @return string */ - final public function serialize(): string {} + final public function serialize(): string + { + } /** * Set an element in the collection @@ -212,14 +248,18 @@ final public function serialize(): string {} * @param string $element * @param mixed $value */ - final public function set(string $element, $value) {} + final public function set(string $element, $value) + { + } /** * Returns the object in an array format * * @return array */ - final public function toArray(): array {} + final public function toArray(): array + { + } /** * Returns the object in a JSON format @@ -232,7 +272,9 @@ final public function toArray(): array {} * @param int $options * @return string */ - final public function toJson(int $options = 79): string {} + final public function toJson(int $options = 79): string + { + } /** * Constructs the object @@ -240,6 +282,7 @@ final public function toJson(int $options = 79): string {} * @link https://php.net/manual/en/serializable.unserialize.php * @param mixed $serialized */ - final public function unserialize($serialized) {} - + final public function unserialize($serialized) + { + } } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 32359ac7..23ffbbe0 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -102,10 +102,14 @@ class Security extends AbstractInjectionAware /** * @param mixed $workFactor */ - public function setWorkFactor($workFactor) {} + public function setWorkFactor($workFactor) + { + } - public function getWorkFactor() {} + public function getWorkFactor() + { + } /** * Phalcon\Security constructor @@ -113,7 +117,9 @@ public function getWorkFactor() {} * @param \Phalcon\Session\ManagerInterface $session * @param \Phalcon\Http\RequestInterface $request */ - public function __construct(\Phalcon\Session\ManagerInterface $session = null, \Phalcon\Http\RequestInterface $request = null) {} + public function __construct(\Phalcon\Session\ManagerInterface $session = null, \Phalcon\Http\RequestInterface $request = null) + { + } /** * Checks a plain text password and its hash version to check if the @@ -124,7 +130,9 @@ public function __construct(\Phalcon\Session\ManagerInterface $session = null, \ * @param int $maxPassLength * @return bool */ - public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool {} + public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool + { + } /** * Check if the CSRF token sent in the request is the same that the current @@ -135,7 +143,9 @@ public function checkHash(string $password, string $passwordHash, int $maxPassLe * @param bool $destroyIfValid * @return bool */ - public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool {} + public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool + { + } /** * Computes a HMAC @@ -146,28 +156,36 @@ public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIf * @param bool $raw * @return string */ - public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string {} + public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string + { + } /** * Removes the value of the CSRF token and key from session * * @return Security */ - public function destroyToken(): Security {} + public function destroyToken(): Security + { + } /** * Returns the default hash * * @return int|null */ - public function getDefaultHash(): ?int {} + public function getDefaultHash(): ?int + { + } /** * Returns a secure random number generator instance * * @return \Phalcon\Security\Random */ - public function getRandom(): Random {} + public function getRandom(): Random + { + } /** * Returns a number of bytes to be generated by the openssl pseudo random @@ -175,21 +193,27 @@ public function getRandom(): Random {} * * @return string */ - public function getRandomBytes(): string {} + public function getRandomBytes(): string + { + } /** * Returns the value of the CSRF token for the current request. * * @return string|null */ - public function getRequestToken(): ?string {} + public function getRequestToken(): ?string + { + } /** * Returns the value of the CSRF token in session * * @return string|null */ - public function getSessionToken(): ?string {} + public function getSessionToken(): ?string + { + } /** * Generate a >22-length pseudo random string to be used as salt for @@ -198,7 +222,9 @@ public function getSessionToken(): ?string {} * @param int $numberBytes * @return string */ - public function getSaltBytes(int $numberBytes = 0): string {} + public function getSaltBytes(int $numberBytes = 0): string + { + } /** * Generates a pseudo random token value to be used as input's value in a @@ -206,7 +232,9 @@ public function getSaltBytes(int $numberBytes = 0): string {} * * @return string */ - public function getToken(): string {} + public function getToken(): string + { + } /** * Generates a pseudo random token key to be used as input's name in a CSRF @@ -214,7 +242,9 @@ public function getToken(): string {} * * @return string */ - public function getTokenKey(): string {} + public function getTokenKey(): string + { + } /** * Creates a password hash using bcrypt with a pseudo random salt @@ -223,7 +253,9 @@ public function getTokenKey(): string {} * @param int $workFactor * @return string */ - public function hash(string $password, int $workFactor = 0): string {} + public function hash(string $password, int $workFactor = 0): string + { + } /** * Checks if a password hash is a valid bcrypt's hash @@ -231,7 +263,9 @@ public function hash(string $password, int $workFactor = 0): string {} * @param string $passwordHash * @return bool */ - public function isLegacyHash(string $passwordHash): bool {} + public function isLegacyHash(string $passwordHash): bool + { + } /** * Sets the default hash @@ -239,7 +273,9 @@ public function isLegacyHash(string $passwordHash): bool {} * @param int $defaultHash * @return Security */ - public function setDefaultHash(int $defaultHash): Security {} + public function setDefaultHash(int $defaultHash): Security + { + } /** * Sets a number of bytes to be generated by the openssl pseudo random @@ -248,16 +284,21 @@ public function setDefaultHash(int $defaultHash): Security {} * @param long $randomBytes * @return Security */ - public function setRandomBytes(int $randomBytes): Security {} + public function setRandomBytes(int $randomBytes): Security + { + } /** * @return null|\Phalcon\Http\RequestInterface */ - private function getLocalRequest(): ?RequestInterface {} + private function getLocalRequest(): ?RequestInterface + { + } /** * @return null|\Phalcon\Session\ManagerInterface */ - private function getLocalSession(): ?SessionInterface {} - + private function getLocalSession(): ?SessionInterface + { + } } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 6afc26e8..aa5eb743 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -56,40 +56,40 @@ class Tag const XHTML5 = 11; - static protected $autoEscape = true; + protected static $autoEscape = true; /** * DI Container */ - static protected $container; + protected static $container; /** * Pre-assigned values for components */ - static protected $displayValues; + protected static $displayValues; - static protected $documentAppendTitle = null; + protected static $documentAppendTitle = null; - static protected $documentPrependTitle = null; + protected static $documentPrependTitle = null; /** * HTML document title */ - static protected $documentTitle = null; + protected static $documentTitle = null; - static protected $documentTitleSeparator = null; + protected static $documentTitleSeparator = null; - static protected $documentType = 11; + protected static $documentType = 11; - static protected $escaperService = null; + protected static $escaperService = null; - static protected $urlService = null; + protected static $urlService = null; /** @@ -97,7 +97,9 @@ class Tag * * @param mixed $title */ - public static function appendTitle($title) {} + public static function appendTitle($title) + { + } /** * Builds a HTML input[type="check"] tag @@ -105,7 +107,9 @@ public static function appendTitle($title) {} * @param mixed $parameters * @return string */ - public static function checkField($parameters): string {} + public static function checkField($parameters): string + { + } /** * Builds a HTML input[type="color"] tag @@ -113,7 +117,9 @@ public static function checkField($parameters): string {} * @param mixed $parameters * @return string */ - public static function colorField($parameters): string {} + public static function colorField($parameters): string + { + } /** * Builds a HTML input[type="date"] tag @@ -121,7 +127,9 @@ public static function colorField($parameters): string {} * @param mixed $parameters * @return string */ - public static function dateField($parameters): string {} + public static function dateField($parameters): string + { + } /** * Builds a HTML input[type="datetime"] tag @@ -129,7 +137,9 @@ public static function dateField($parameters): string {} * @param mixed $parameters * @return string */ - public static function dateTimeField($parameters): string {} + public static function dateTimeField($parameters): string + { + } /** * Builds a HTML input[type="datetime-local"] tag @@ -137,7 +147,9 @@ public static function dateTimeField($parameters): string {} * @param mixed $parameters * @return string */ - public static function dateTimeLocalField($parameters): string {} + public static function dateTimeLocalField($parameters): string + { + } /** * Alias of Phalcon\Tag::setDefault() @@ -145,7 +157,9 @@ public static function dateTimeLocalField($parameters): string {} * @param string $id * @param mixed $value */ - public static function displayTo(string $id, $value) {} + public static function displayTo(string $id, $value) + { + } /** * Builds a HTML input[type="email"] tag @@ -153,14 +167,18 @@ public static function displayTo(string $id, $value) {} * @param mixed $parameters * @return string */ - public static function emailField($parameters): string {} + public static function emailField($parameters): string + { + } /** * Builds a HTML close FORM tag * * @return string */ - public static function endForm(): string {} + public static function endForm(): string + { + } /** * Builds a HTML input[type="file"] tag @@ -168,7 +186,9 @@ public static function endForm(): string {} * @param mixed $parameters * @return string */ - public static function fileField($parameters): string {} + public static function fileField($parameters): string + { + } /** * Builds a HTML FORM tag @@ -176,7 +196,9 @@ public static function fileField($parameters): string {} * @param mixed $parameters * @return string */ - public static function form($parameters): string {} + public static function form($parameters): string + { + } /** * Converts texts into URL-friendly titles @@ -187,14 +209,18 @@ public static function form($parameters): string {} * @param mixed $replace * @return string */ - public static function friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string {} + public static function friendlyTitle(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string + { + } /** * Get the document type declaration of content * * @return string */ - public static function getDocType(): string {} + public static function getDocType(): string + { + } /** * Obtains the 'escaper' service if required @@ -202,21 +228,27 @@ public static function getDocType(): string {} * @param array $params * @return null|\Phalcon\Escaper\EscaperInterface */ - public static function getEscaper(array $params): ?EscaperInterface {} + public static function getEscaper(array $params): ?EscaperInterface + { + } /** * Internally gets the request dispatcher * * @return \Phalcon\Di\DiInterface */ - public static function getDI(): DiInterface {} + public static function getDI(): DiInterface + { + } /** * Returns an Escaper service from the default DI * * @return \Phalcon\Escaper\EscaperInterface */ - public static function getEscaperService(): EscaperInterface {} + public static function getEscaperService(): EscaperInterface + { + } /** * Gets the current document title. The title will be automatically escaped. @@ -225,21 +257,27 @@ public static function getEscaperService(): EscaperInterface {} * @param bool $append * @return string */ - public static function getTitle(bool $prepend = true, bool $append = true): string {} + public static function getTitle(bool $prepend = true, bool $append = true): string + { + } /** * Gets the current document title separator * * @return string */ - public static function getTitleSeparator(): string {} + public static function getTitleSeparator(): string + { + } /** * Returns a URL service from the default DI * * @return \Phalcon\Url\UrlInterface */ - public static function getUrlService(): UrlInterface {} + public static function getUrlService(): UrlInterface + { + } /** * Every helper calls this function to check whether a component has a @@ -248,7 +286,9 @@ public static function getUrlService(): UrlInterface {} * @param mixed $name * @param array $params */ - public static function getValue($name, array $params = array()) {} + public static function getValue($name, array $params = array()) + { + } /** * Check if a helper has a default value set using Phalcon\Tag::setDefault() @@ -257,7 +297,9 @@ public static function getValue($name, array $params = array()) {} * @param mixed $name * @return bool */ - public static function hasValue($name): bool {} + public static function hasValue($name): bool + { + } /** * Builds a HTML input[type="hidden"] tag @@ -265,7 +307,9 @@ public static function hasValue($name): bool {} * @param mixed $parameters * @return string */ - public static function hiddenField($parameters): string {} + public static function hiddenField($parameters): string + { + } /** * Builds HTML IMG tags @@ -274,7 +318,9 @@ public static function hiddenField($parameters): string {} * @param bool $local * @return string */ - public static function image($parameters = null, bool $local = true): string {} + public static function image($parameters = null, bool $local = true): string + { + } /** * Builds a HTML input[type="image"] tag @@ -282,7 +328,9 @@ public static function image($parameters = null, bool $local = true): string {} * @param mixed $parameters * @return string */ - public static function imageInput($parameters): string {} + public static function imageInput($parameters): string + { + } /** * Builds a SCRIPT[type="javascript"] tag @@ -291,7 +339,9 @@ public static function imageInput($parameters): string {} * @param bool $local * @return string */ - public static function javascriptInclude($parameters = null, bool $local = true): string {} + public static function javascriptInclude($parameters = null, bool $local = true): string + { + } /** * Builds a HTML A tag using framework conventions @@ -301,7 +351,9 @@ public static function javascriptInclude($parameters = null, bool $local = true) * @param mixed $local * @return string */ - public static function linkTo($parameters, $text = null, $local = true): string {} + public static function linkTo($parameters, $text = null, $local = true): string + { + } /** * Builds a HTML input[type="month"] tag @@ -309,7 +361,9 @@ public static function linkTo($parameters, $text = null, $local = true): string * @param mixed $parameters * @return string */ - public static function monthField($parameters): string {} + public static function monthField($parameters): string + { + } /** * Builds a HTML input[type="number"] tag @@ -317,7 +371,9 @@ public static function monthField($parameters): string {} * @param mixed $parameters * @return string */ - public static function numericField($parameters): string {} + public static function numericField($parameters): string + { + } /** * Builds a HTML input[type="password"] tag @@ -325,14 +381,18 @@ public static function numericField($parameters): string {} * @param mixed $parameters * @return string */ - public static function passwordField($parameters): string {} + public static function passwordField($parameters): string + { + } /** * Prepends a text to current document title * * @param mixed $title */ - public static function prependTitle($title) {} + public static function prependTitle($title) + { + } /** * Builds a HTML input[type="radio"] tag @@ -340,7 +400,9 @@ public static function prependTitle($title) {} * @param mixed $parameters * @return string */ - public static function radioField($parameters): string {} + public static function radioField($parameters): string + { + } /** * Builds a HTML input[type="range"] tag @@ -348,7 +410,9 @@ public static function radioField($parameters): string {} * @param mixed $parameters * @return string */ - public static function rangeField($parameters): string {} + public static function rangeField($parameters): string + { + } /** * Renders parameters keeping order in their HTML attributes @@ -357,7 +421,9 @@ public static function rangeField($parameters): string {} * @param array $attributes * @return string */ - public static function renderAttributes(string $code, array $attributes): string {} + public static function renderAttributes(string $code, array $attributes): string + { + } /** * Renders the title with title tags. The title is automaticall escaped @@ -366,7 +432,9 @@ public static function renderAttributes(string $code, array $attributes): string * @param bool $append * @return string */ - public static function renderTitle(bool $prepend = true, bool $append = true): string {} + public static function renderTitle(bool $prepend = true, bool $append = true): string + { + } /** * Resets the request and internal values to avoid those fields will have @@ -375,7 +443,9 @@ public static function renderTitle(bool $prepend = true, bool $append = true): s * @deprecated Will be removed in 4.0.0 * @deprecated */ - public static function resetInput() {} + public static function resetInput() + { + } /** * Builds a HTML input[type="search"] tag @@ -383,7 +453,9 @@ public static function resetInput() {} * @param mixed $parameters * @return string */ - public static function searchField($parameters): string {} + public static function searchField($parameters): string + { + } /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options @@ -392,7 +464,9 @@ public static function searchField($parameters): string {} * @param mixed $data * @return string */ - public static function select($parameters, $data = null): string {} + public static function select($parameters, $data = null): string + { + } /** * Builds a HTML SELECT tag using a PHP array for options @@ -401,14 +475,18 @@ public static function select($parameters, $data = null): string {} * @param mixed $data * @return string */ - public static function selectStatic($parameters, $data = null): string {} + public static function selectStatic($parameters, $data = null): string + { + } /** * Set autoescape mode in generated html * * @param bool $autoescape */ - public static function setAutoescape(bool $autoescape) {} + public static function setAutoescape(bool $autoescape) + { + } /** * Assigns default values to generated tags by helpers @@ -416,7 +494,9 @@ public static function setAutoescape(bool $autoescape) {} * @param string $id * @param mixed $value */ - public static function setDefault(string $id, $value) {} + public static function setDefault(string $id, $value) + { + } /** * Assigns default values to generated tags by helpers @@ -424,35 +504,45 @@ public static function setDefault(string $id, $value) {} * @param array $values * @param bool $merge */ - public static function setDefaults(array $values, bool $merge = false) {} + public static function setDefaults(array $values, bool $merge = false) + { + } /** * Sets the dependency injector container. * * @param \Phalcon\Di\DiInterface $container */ - public static function setDI(\Phalcon\Di\DiInterface $container) {} + public static function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Set the document type of content * * @param int $doctype */ - public static function setDocType(int $doctype) {} + public static function setDocType(int $doctype) + { + } /** * Set the title of view content * * @param string $title */ - public static function setTitle(string $title) {} + public static function setTitle(string $title) + { + } /** * Set the title separator of view content * * @param string $titleSeparator */ - public static function setTitleSeparator(string $titleSeparator) {} + public static function setTitleSeparator(string $titleSeparator) + { + } /** * Builds a LINK[rel="stylesheet"] tag @@ -461,7 +551,9 @@ public static function setTitleSeparator(string $titleSeparator) {} * @param bool $local * @return string */ - public static function stylesheetLink($parameters = null, bool $local = true): string {} + public static function stylesheetLink($parameters = null, bool $local = true): string + { + } /** * Builds a HTML input[type="submit"] tag @@ -469,7 +561,9 @@ public static function stylesheetLink($parameters = null, bool $local = true): s * @param mixed $parameters * @return string */ - public static function submitButton($parameters): string {} + public static function submitButton($parameters): string + { + } /** * Builds a HTML tag @@ -481,7 +575,9 @@ public static function submitButton($parameters): string {} * @param bool $useEol * @return string */ - public static function tagHtml(string $tagName, $parameters = null, bool $selfClose = false, bool $onlyStart = false, bool $useEol = false): string {} + public static function tagHtml(string $tagName, $parameters = null, bool $selfClose = false, bool $onlyStart = false, bool $useEol = false): string + { + } /** * Builds a HTML tag closing tag @@ -490,7 +586,9 @@ public static function tagHtml(string $tagName, $parameters = null, bool $selfCl * @param bool $useEol * @return string */ - public static function tagHtmlClose(string $tagName, bool $useEol = false): string {} + public static function tagHtmlClose(string $tagName, bool $useEol = false): string + { + } /** * Builds a HTML input[type="tel"] tag @@ -498,7 +596,9 @@ public static function tagHtmlClose(string $tagName, bool $useEol = false): stri * @param mixed $parameters * @return string */ - public static function telField($parameters): string {} + public static function telField($parameters): string + { + } /** * Builds a HTML TEXTAREA tag @@ -506,7 +606,9 @@ public static function telField($parameters): string {} * @param mixed $parameters * @return string */ - public static function textArea($parameters): string {} + public static function textArea($parameters): string + { + } /** * Builds a HTML input[type="text"] tag @@ -514,7 +616,9 @@ public static function textArea($parameters): string {} * @param mixed $parameters * @return string */ - public static function textField($parameters): string {} + public static function textField($parameters): string + { + } /** * Builds a HTML input[type="time"] tag @@ -522,7 +626,9 @@ public static function textField($parameters): string {} * @param mixed $parameters * @return string */ - public static function timeField($parameters): string {} + public static function timeField($parameters): string + { + } /** * Builds a HTML input[type="url"] tag @@ -530,7 +636,9 @@ public static function timeField($parameters): string {} * @param mixed $parameters * @return string */ - public static function urlField($parameters): string {} + public static function urlField($parameters): string + { + } /** * Builds a HTML input[type="week"] tag @@ -538,7 +646,9 @@ public static function urlField($parameters): string {} * @param mixed $parameters * @return string */ - public static function weekField($parameters): string {} + public static function weekField($parameters): string + { + } /** * Builds generic INPUT tags @@ -548,7 +658,9 @@ public static function weekField($parameters): string {} * @param bool $asValue * @return string */ - static final protected function inputField(string $type, $parameters, bool $asValue = false): string {} + final protected static function inputField(string $type, $parameters, bool $asValue = false): string + { + } /** * Builds INPUT tags that implements the checked attribute @@ -557,6 +669,7 @@ static final protected function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - static final protected function inputFieldChecked(string $type, $parameters): string {} - + final protected static function inputFieldChecked(string $type, $parameters): string + { + } } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 0d58385c..16c64802 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -48,7 +48,9 @@ class Text * @param mixed $delimiter * @return string */ - public static function camelize(string $text, $delimiter = null): string {} + public static function camelize(string $text, $delimiter = null): string + { + } /** * Concatenates strings using the separator only once without duplication in @@ -73,7 +75,9 @@ public static function camelize(string $text, $delimiter = null): string {} * @param string $...N * @return string */ - public static function concat(): string {} + public static function concat(): string + { + } /** * Generates random text in accordance with the template @@ -102,7 +106,9 @@ public static function concat(): string {} * @param string $separator * @return string */ - public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string {} + public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string + { + } /** * Check if a string ends with a given string @@ -118,7 +124,9 @@ public static function dynamic(string $text, string $leftDelimiter = '{', string * @param bool $ignoreCase * @return bool */ - public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool {} + public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool + { + } /** * Makes an underscored or dashed phrase human-readable @@ -131,7 +139,9 @@ public static function endsWith(string $text, string $end, bool $ignoreCase = tr * @param string $text * @return string */ - public static function humanize(string $text): string {} + public static function humanize(string $text): string + { + } /** * Adds a number to a string or increment that number if it already is @@ -146,7 +156,9 @@ public static function humanize(string $text): string {} * @param string $separator * @return string */ - public static function increment(string $text, string $separator = '_'): string {} + public static function increment(string $text, string $separator = '_'): string + { + } /** * Lowercases a string, this function makes use of the mbstring extension if @@ -160,7 +172,9 @@ public static function increment(string $text, string $separator = '_'): string * @param string $encoding * @return string */ - public static function lower(string $text, string $encoding = 'UTF-8'): string {} + public static function lower(string $text, string $encoding = 'UTF-8'): string + { + } /** * Check if a string starts with a given string @@ -176,7 +190,9 @@ public static function lower(string $text, string $encoding = 'UTF-8'): string { * @param bool $ignoreCase * @return bool */ - public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool {} + public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool + { + } /** * Generates a random string based on the given type. Type is one of the @@ -193,7 +209,9 @@ public static function startsWith(string $text, string $start, bool $ignoreCase * @param long $length * @return string */ - public static function random(int $type = 0, int $length = 8): string {} + public static function random(int $type = 0, int $length = 8): string + { + } /** * Reduces multiple slashes in a string to single slashes @@ -209,7 +227,9 @@ public static function random(int $type = 0, int $length = 8): string {} * @param string $text * @return string */ - public static function reduceSlashes(string $text): string {} + public static function reduceSlashes(string $text): string + { + } /** * Uncamelize strings which are camelized @@ -223,7 +243,9 @@ public static function reduceSlashes(string $text): string {} * @param mixed $delimiter * @return string */ - public static function uncamelize(string $text, $delimiter = null): string {} + public static function uncamelize(string $text, $delimiter = null): string + { + } /** * Makes a phrase underscored instead of spaced @@ -236,7 +258,9 @@ public static function uncamelize(string $text, $delimiter = null): string {} * @param string $text * @return string */ - public static function underscore(string $text): string {} + public static function underscore(string $text): string + { + } /** * Uppercases a string, this function makes use of the mbstring extension if @@ -250,6 +274,7 @@ public static function underscore(string $text): string {} * @param string $encoding * @return string */ - public static function upper(string $text, string $encoding = 'UTF-8'): string {} - + public static function upper(string $text, string $encoding = 'UTF-8'): string + { + } } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index d760b5a6..991a364f 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -58,7 +58,9 @@ class Url extends AbstractInjectionAware implements UrlInterface /** * @param \Phalcon\Mvc\RouterInterface $router */ - public function __construct(\Phalcon\Mvc\RouterInterface $router = null) {} + public function __construct(\Phalcon\Mvc\RouterInterface $router = null) + { + } /** * Generates a URL @@ -99,21 +101,27 @@ public function __construct(\Phalcon\Mvc\RouterInterface $router = null) {} * @param mixed $baseUri * @return string */ - public function get($uri = null, $args = null, bool $local = null, $baseUri = null): string {} + public function get($uri = null, $args = null, bool $local = null, $baseUri = null): string + { + } /** * Returns the base path * * @return string */ - public function getBasePath(): string {} + public function getBasePath(): string + { + } /** * Returns the prefix for all the generated urls. By default / * * @return string */ - public function getBaseUri(): string {} + public function getBaseUri(): string + { + } /** * Generates a URL for a static resource @@ -133,14 +141,18 @@ public function getBaseUri(): string {} * @param mixed $uri * @return string */ - public function getStatic($uri = null): string {} + public function getStatic($uri = null): string + { + } /** * Returns the prefix for all the generated static urls. By default / * * @return string */ - public function getStaticBaseUri(): string {} + public function getStaticBaseUri(): string + { + } /** * Sets a base path for all the generated paths @@ -152,7 +164,9 @@ public function getStaticBaseUri(): string {} * @param string $basePath * @return \Phalcon\Url\UrlInterface */ - public function setBasePath(string $basePath): UrlInterface {} + public function setBasePath(string $basePath): UrlInterface + { + } /** * Sets a prefix for all the URIs to be generated @@ -166,7 +180,9 @@ public function setBasePath(string $basePath): UrlInterface {} * @param string $baseUri * @return \Phalcon\Url\UrlInterface */ - public function setBaseUri(string $baseUri): UrlInterface {} + public function setBaseUri(string $baseUri): UrlInterface + { + } /** * Sets a prefix for all static URLs generated @@ -178,7 +194,9 @@ public function setBaseUri(string $baseUri): UrlInterface {} * @param string $staticBaseUri * @return \Phalcon\Url\UrlInterface */ - public function setStaticBaseUri(string $staticBaseUri): UrlInterface {} + public function setStaticBaseUri(string $staticBaseUri): UrlInterface + { + } /** * Generates a local path @@ -186,6 +204,7 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface {} * @param string $path * @return string */ - public function path(string $path = null): string {} - + public function path(string $path = null): string + { + } } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index f5cc53ec..f04fa34f 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -46,19 +46,25 @@ class Validation extends Injectable implements ValidationInterface - public function getData() {} + public function getData() + { + } /** * @param mixed $validators */ - public function setValidators($validators) {} + public function setValidators($validators) + { + } /** * Phalcon\Validation constructor * * @param array $validators */ - public function __construct(array $validators = array()) {} + public function __construct(array $validators = array()) + { + } /** * Adds a validator to a field @@ -67,7 +73,9 @@ public function __construct(array $validators = array()) {} * @param \Phalcon\Validation\ValidatorInterface $validator * @return \Phalcon\Validation\ValidationInterface */ - public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface {} + public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + { + } /** * Appends a message to the messages list @@ -75,7 +83,9 @@ public function add($field, \Phalcon\Validation\ValidatorInterface $validator): * @param \Phalcon\Messages\MessageInterface $message * @return \Phalcon\Validation\ValidationInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface + { + } /** * Assigns the data to an entity @@ -85,14 +95,18 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Vali * @param array|object $data * @return \Phalcon\Validation\ValidationInterface */ - public function bind($entity, $data): ValidationInterface {} + public function bind($entity, $data): ValidationInterface + { + } /** * Returns the bound entity * * @return object */ - public function getEntity() {} + public function getEntity() + { + } /** * Returns all the filters or a specific one @@ -100,7 +114,9 @@ public function getEntity() {} * @param string $field * @return mixed|null */ - public function getFilters(string $field = null) {} + public function getFilters(string $field = null) + { + } /** * Get label for field @@ -108,21 +124,27 @@ public function getFilters(string $field = null) {} * @param string $field * @return string */ - public function getLabel($field): string {} + public function getLabel($field): string + { + } /** * Returns the registered validators * * @return \Phalcon\Messages\Messages */ - public function getMessages(): Messages {} + public function getMessages(): Messages + { + } /** * Returns the validators added to the validation * * @return array */ - public function getValidators(): array {} + public function getValidators(): array + { + } /** * Gets the a value to validate in the array/object data source @@ -130,7 +152,9 @@ public function getValidators(): array {} * @param string $field * @return mixed|null */ - public function getValue(string $field) {} + public function getValue(string $field) + { + } /** * Alias of `add` method @@ -139,7 +163,9 @@ public function getValue(string $field) {} * @param \Phalcon\Validation\ValidatorInterface $validator * @return \Phalcon\Validation\ValidationInterface */ - public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface {} + public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + { + } /** * Adds the validators to a field @@ -148,14 +174,18 @@ public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): * @param array $validators * @return \Phalcon\Validation\ValidationInterface */ - public function rules($field, array $validators): ValidationInterface {} + public function rules($field, array $validators): ValidationInterface + { + } /** * Sets the bound entity * * @param object $entity */ - public function setEntity($entity) {} + public function setEntity($entity) + { + } /** * Adds filters to the field @@ -164,14 +194,18 @@ public function setEntity($entity) {} * @param array|string $filters * @return \Phalcon\Validation\ValidationInterface */ - public function setFilters($field, $filters): ValidationInterface {} + public function setFilters($field, $filters): ValidationInterface + { + } /** * Adds labels for fields * * @param array $labels */ - public function setLabels(array $labels) {} + public function setLabels(array $labels) + { + } /** * Validate a set of data according to a set of rules @@ -180,7 +214,9 @@ public function setLabels(array $labels) {} * @param object $entity * @return \Phalcon\Messages\Messages */ - public function validate($data = null, $entity = null): Messages {} + public function validate($data = null, $entity = null): Messages + { + } /** * Internal validations, if it returns true, then skip the current validator @@ -189,6 +225,7 @@ public function validate($data = null, $entity = null): Messages {} * @param \Phalcon\Validation\ValidatorInterface $validator * @return bool */ - protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool {} - + protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool + { + } } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 2094ca57..1f2730eb 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -84,7 +84,9 @@ class Version * * @return array */ - protected static function _getVersion(): array {} + protected static function _getVersion(): array + { + } /** * Translates a number to a special release. @@ -92,7 +94,9 @@ protected static function _getVersion(): array {} * @param int $special * @return string */ - protected final static function _getSpecial(int $special): string {} + final protected static function _getSpecial(int $special): string + { + } /** * Returns the active version (string) @@ -103,7 +107,9 @@ protected final static function _getSpecial(int $special): string {} * * @return string */ - public static function get(): string {} + public static function get(): string + { + } /** * Returns the numeric active version @@ -114,7 +120,9 @@ public static function get(): string {} * * @return string */ - public static function getId(): string {} + public static function getId(): string + { + } /** * Returns a specific part of the version. If the wrong parameter is passed @@ -129,6 +137,7 @@ public static function getId(): string {} * @param int $part * @return string */ - public static function getPart(int $part): string {} - + public static function getPart(int $part): string + { + } } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index dd062ed4..2f569a59 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -36,21 +36,27 @@ class Component implements ComponentInterface * * @return string */ - public function getDescription(): string {} + public function getDescription(): string + { + } /** * Component name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Component name * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Phalcon\Acl\Component constructor @@ -58,6 +64,7 @@ public function __toString(): string {} * @param string $name * @param string $description */ - public function __construct(string $name, string $description = null) {} - + public function __construct(string $name, string $description = null) + { + } } diff --git a/src/Phalcon/acl/ComponentAware.php b/src/Phalcon/acl/ComponentAware.php index 894576a3..165249db 100644 --- a/src/Phalcon/acl/ComponentAware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -23,5 +23,4 @@ interface ComponentAware * @return string */ public function getComponentName(): string; - } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php index de39056f..d158aa4a 100644 --- a/src/Phalcon/acl/ComponentInterface.php +++ b/src/Phalcon/acl/ComponentInterface.php @@ -37,5 +37,4 @@ public function getName(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/acl/Enum.php b/src/Phalcon/acl/Enum.php index 849ad26d..9dcff0ce 100644 --- a/src/Phalcon/acl/Enum.php +++ b/src/Phalcon/acl/Enum.php @@ -21,6 +21,4 @@ class Enum const DENY = 0; - - } diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/acl/Role.php index bc6c0193..589f2ba0 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/acl/Role.php @@ -36,21 +36,27 @@ class Role implements RoleInterface * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Role name * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Role description * * @return string */ - public function getDescription(): string {} + public function getDescription(): string + { + } /** * Phalcon\Acl\Role constructor @@ -58,6 +64,7 @@ public function getDescription(): string {} * @param string $name * @param string $description */ - public function __construct(string $name, string $description = null) {} - + public function __construct(string $name, string $description = null) + { + } } diff --git a/src/Phalcon/acl/RoleAware.php b/src/Phalcon/acl/RoleAware.php index 9ebd5166..f3bad4c8 100644 --- a/src/Phalcon/acl/RoleAware.php +++ b/src/Phalcon/acl/RoleAware.php @@ -23,5 +23,4 @@ interface RoleAware * @return string */ public function getRoleName(): string; - } diff --git a/src/Phalcon/acl/RoleInterface.php b/src/Phalcon/acl/RoleInterface.php index d8dab9cb..aef5881a 100644 --- a/src/Phalcon/acl/RoleInterface.php +++ b/src/Phalcon/acl/RoleInterface.php @@ -37,5 +37,4 @@ public function getDescription(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/adapter/AbstractAdapter.php index ac4780e4..3be00202 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/adapter/AbstractAdapter.php @@ -68,7 +68,9 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface * * @return string */ - public function getActiveAccess(): string {} + public function getActiveAccess(): string + { + } /** * Role which the list is checking if it's allowed to certain @@ -77,41 +79,52 @@ public function getActiveAccess(): string {} * * @return string */ - public function getActiveRole(): string {} + public function getActiveRole(): string + { + } /** * Component which the list is checking if some role can access it * * @return string */ - public function getActiveComponent(): string {} + public function getActiveComponent(): string + { + } /** * Returns the default ACL access level * * @return int */ - public function getDefaultAction(): int {} + public function getDefaultAction(): int + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) * * @param int $defaultAccess */ - public function setDefaultAction(int $defaultAccess) {} + public function setDefaultAction(int $defaultAccess) + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } } diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/acl/adapter/AdapterInterface.php index a90688a0..627c96d6 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/acl/adapter/AdapterInterface.php @@ -179,5 +179,4 @@ public function setDefaultAction(int $defaultAccess); * @param int $defaultAccess */ public function setNoArgumentsDefaultAction(int $defaultAccess); - } diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/acl/adapter/Memory.php index 4610366d..5c13d4d9 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/acl/adapter/Memory.php @@ -168,26 +168,34 @@ class Memory extends AbstractAdapter * * @return mixed */ - public function getActiveFunction() {} + public function getActiveFunction() + { + } /** * Returns number of additional arguments(excluding role and resource) for active function * * @return int */ - public function getActiveFunctionCustomArgumentsCount(): int {} + public function getActiveFunctionCustomArgumentsCount(): int + { + } /** * Returns latest key used to acquire access * * @return string|null */ - public function getActiveKey(): ?string {} + public function getActiveKey(): ?string + { + } /** * Phalcon\Acl\Adapter\Memory constructor */ - public function __construct() {} + public function __construct() + { + } /** * Adds a component to the ACL list @@ -227,7 +235,9 @@ public function __construct() {} * @param mixed $accessList * @return bool */ - public function addComponent($componentValue, $accessList): bool {} + public function addComponent($componentValue, $accessList): bool + { + } /** * Adds access to components @@ -236,7 +246,9 @@ public function addComponent($componentValue, $accessList): bool {} * @param mixed $accessList * @return bool */ - public function addComponentAccess(string $componentName, $accessList): bool {} + public function addComponentAccess(string $componentName, $accessList): bool + { + } /** * Do a role inherit from another existing role @@ -250,7 +262,9 @@ public function addComponentAccess(string $componentName, $accessList): bool {} * @param mixed $roleToInherits * @return bool */ - public function addInherit(string $roleName, $roleToInherits): bool {} + public function addInherit(string $roleName, $roleToInherits): bool + { + } /** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role @@ -269,7 +283,9 @@ public function addInherit(string $roleName, $roleToInherits): bool {} * @param mixed $accessInherits * @return bool */ - public function addRole($role, $accessInherits = null): bool {} + public function addRole($role, $accessInherits = null): bool + { + } /** * Allow access to a role on a component. You can use `` as wildcard @@ -292,7 +308,9 @@ public function addRole($role, $accessInherits = null): bool {} * @param mixed $access * @param mixed $func */ - public function allow(string $roleName, string $componentName, $access, $func = null) {} + public function allow(string $roleName, string $componentName, $access, $func = null) + { + } /** * Deny access to a role on a component. You can use `` as wildcard @@ -316,7 +334,9 @@ public function allow(string $roleName, string $componentName, $access, $func = * @param mixed $access * @param mixed $func */ - public function deny(string $roleName, string $componentName, $access, $func = null) {} + public function deny(string $roleName, string $componentName, $access, $func = null) + { + } /** * Removes an access from a component @@ -324,7 +344,9 @@ public function deny(string $roleName, string $componentName, $access, $func = n * @param string $componentName * @param mixed $accessList */ - public function dropComponentAccess(string $componentName, $accessList) {} + public function dropComponentAccess(string $componentName, $accessList) + { + } /** * Returns the default ACL access level for no arguments provided in @@ -332,21 +354,27 @@ public function dropComponentAccess(string $componentName, $accessList) {} * * @return int */ - public function getNoArgumentsDefaultAction(): int {} + public function getNoArgumentsDefaultAction(): int + { + } /** * Return an array with every role registered in the list * * @return array|\Phalcon\Acl\RoleInterface[] */ - public function getRoles(): array {} + public function getRoles(): array + { + } /** * Return an array with every component registered in the list * * @return array|\Phalcon\Acl\ComponentInterface[] */ - public function getComponents(): array {} + public function getComponents(): array + { + } /** * Check whether a role is allowed to access an action from a component @@ -365,7 +393,9 @@ public function getComponents(): array {} * @param array $parameters * @return bool */ - public function isAllowed($roleName, $componentName, string $access, array $parameters = null): bool {} + public function isAllowed($roleName, $componentName, string $access, array $parameters = null): bool + { + } /** * Check whether role exist in the roles list @@ -373,7 +403,9 @@ public function isAllowed($roleName, $componentName, string $access, array $para * @param string $roleName * @return bool */ - public function isRole(string $roleName): bool {} + public function isRole(string $roleName): bool + { + } /** * Check whether component exist in the components list @@ -381,7 +413,9 @@ public function isRole(string $roleName): bool {} * @param string $componentName * @return bool */ - public function isComponent(string $componentName): bool {} + public function isComponent(string $componentName): bool + { + } /** * Sets the default access level (`Phalcon\Enum::ALLOW` or `Phalcon\Enum::DENY`) @@ -390,7 +424,9 @@ public function isComponent(string $componentName): bool {} * * @param int $defaultAccess */ - public function setNoArgumentsDefaultAction(int $defaultAccess) {} + public function setNoArgumentsDefaultAction(int $defaultAccess) + { + } /** * Checks if a role has access to a component @@ -401,7 +437,9 @@ public function setNoArgumentsDefaultAction(int $defaultAccess) {} * @param mixed $action * @param mixed $func */ - private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) {} + private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) + { + } /** * Check whether a role is allowed to access an action from a component @@ -411,6 +449,7 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ * @param string $access * @return string|bool */ - private function canAccess(string $roleName, string $componentName, string $access) {} - + private function canAccess(string $roleName, string $componentName, string $access) + { + } } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index fc75870b..1cba64cd 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -43,28 +43,36 @@ class Annotation * * @param array $reflectionData */ - public function __construct(array $reflectionData) {} + public function __construct(array $reflectionData) + { + } /** * Returns an argument in a specific position * * @param mixed $position */ - public function getArgument($position) {} + public function getArgument($position) + { + } /** * Returns the expression arguments * * @return array */ - public function getArguments(): array {} + public function getArguments(): array + { + } /** * Returns the expression arguments without resolving * * @return array */ - public function getExprArguments(): array {} + public function getExprArguments(): array + { + } /** * Resolves an annotation expression @@ -72,21 +80,27 @@ public function getExprArguments(): array {} * @param array $expr * @return mixed */ - public function getExpression(array $expr) {} + public function getExpression(array $expr) + { + } /** * Returns the annotation's name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Returns a named argument * * @param string $name */ - public function getNamedArgument(string $name) {} + public function getNamedArgument(string $name) + { + } /** * Returns a named parameter @@ -94,7 +108,9 @@ public function getNamedArgument(string $name) {} * @param string $name * @return mixed */ - public function getNamedParameter(string $name) {} + public function getNamedParameter(string $name) + { + } /** * Returns an argument in a specific position @@ -102,13 +118,16 @@ public function getNamedParameter(string $name) {} * @param mixed $position * @return bool */ - public function hasArgument($position): bool {} + public function hasArgument($position): bool + { + } /** * Returns the number of arguments that the annotation has * * @return int */ - public function numberArguments(): int {} - + public function numberArguments(): int + { + } } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php index 51fdb14c..c7ffa06d 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -25,7 +25,9 @@ class AnnotationsFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Factory to create an instace from a Config object @@ -33,7 +35,9 @@ public function __construct(array $services = array()) {} * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Create a new instance of the adapter @@ -42,13 +46,16 @@ public function load($config) {} * @param array $options * @return \Phalcon\Annotations\Adapter\AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * The available adapters * * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/annotations/Collection.php index d190e9b8..644b0662 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/annotations/Collection.php @@ -49,21 +49,27 @@ class Collection implements Iterator, Countable * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) {} + public function __construct(array $reflectionData = array()) + { + } /** * Returns the number of annotations in the collection * * @return int */ - public function count(): int {} + public function count(): int + { + } /** * Returns the current annotation in the iterator * * @return bool|\Phalcon\Annotations\Annotation */ - public function current() {} + public function current() + { + } /** * Returns the first annotation that match a name @@ -71,7 +77,9 @@ public function current() {} * @param string $name * @return \Phalcon\Annotations\Annotation */ - public function get(string $name): Annotation {} + public function get(string $name): Annotation + { + } /** * Returns all the annotations that match a name @@ -79,14 +87,18 @@ public function get(string $name): Annotation {} * @param string $name * @return array|\Phalcon\Annotations\Annotation[] */ - public function getAll(string $name): array {} + public function getAll(string $name): array + { + } /** * Returns the internal annotations as an array * * @return array|\Phalcon\Annotations\Annotation[] */ - public function getAnnotations(): array {} + public function getAnnotations(): array + { + } /** * Check if an annotation exists in a collection @@ -94,30 +106,39 @@ public function getAnnotations(): array {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Returns the current position/key in the iterator * * @return int */ - public function key(): int {} + public function key(): int + { + } /** * Moves the internal iteration pointer to the next position */ - public function next() {} + public function next() + { + } /** * Rewinds the internal iterator */ - public function rewind() {} + public function rewind() + { + } /** * Check if the current annotation in the iterator is valid * * @return bool */ - public function valid(): bool {} - + public function valid(): bool + { + } } diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index 250728f3..7b10f361 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -23,7 +23,9 @@ class Reader implements ReaderInterface * @param string $className * @return array */ - public function parse(string $className): array {} + public function parse(string $className): array + { + } /** * Parses a raw doc block returning the annotations found @@ -33,6 +35,7 @@ public function parse(string $className): array {} * @param mixed $line * @return array */ - public static function parseDocBlock(string $docBlock, $file = null, $line = null): array {} - + public static function parseDocBlock(string $docBlock, $file = null, $line = null): array + { + } } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index dea5b646..ec8824e5 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -34,5 +34,4 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; - } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index 1359147c..e4fc316b 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -51,28 +51,36 @@ class Reflection * * @param array $reflectionData */ - public function __construct(array $reflectionData = array()) {} + public function __construct(array $reflectionData = array()) + { + } /** * Returns the annotations found in the class docblock * * @return bool|\Phalcon\Annotations\Collection */ - public function getClassAnnotations() {} + public function getClassAnnotations() + { + } /** * Returns the annotations found in the methods' docblocks * * @return array|bool|\Phalcon\Annotations\Collection[] */ - public function getMethodsAnnotations() {} + public function getMethodsAnnotations() + { + } /** * Returns the annotations found in the properties' docblocks * * @return array|bool|\Phalcon\Annotations\Collection[] */ - public function getPropertiesAnnotations() {} + public function getPropertiesAnnotations() + { + } /** * Returns the raw parsing intermediate definitions used to construct the @@ -80,6 +88,7 @@ public function getPropertiesAnnotations() {} * * @return array */ - public function getReflectionData(): array {} - + public function getReflectionData(): array + { + } } diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php index ff65e600..ac714d61 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -38,7 +38,9 @@ abstract class AbstractAdapter implements AdapterInterface * @param mixed $className * @return \Phalcon\Annotations\Reflection */ - public function get($className): Reflection {} + public function get($className): Reflection + { + } /** * Returns the annotations found in a specific method @@ -47,7 +49,9 @@ public function get($className): Reflection {} * @param string $methodName * @return \Phalcon\Annotations\Collection */ - public function getMethod(string $className, string $methodName): Collection {} + public function getMethod(string $className, string $methodName): Collection + { + } /** * Returns the annotations found in all the class' methods @@ -55,7 +59,9 @@ public function getMethod(string $className, string $methodName): Collection {} * @param string $className * @return array */ - public function getMethods(string $className): array {} + public function getMethods(string $className): array + { + } /** * Returns the annotations found in a specific property @@ -64,7 +70,9 @@ public function getMethods(string $className): array {} * @param string $propertyName * @return \Phalcon\Annotations\Collection */ - public function getProperty(string $className, string $propertyName): Collection {} + public function getProperty(string $className, string $propertyName): Collection + { + } /** * Returns the annotations found in all the class' methods @@ -72,20 +80,25 @@ public function getProperty(string $className, string $propertyName): Collection * @param string $className * @return array */ - public function getProperties(string $className): array {} + public function getProperties(string $className): array + { + } /** * Returns the annotation reader * * @return \Phalcon\Annotations\ReaderInterface */ - public function getReader(): ReaderInterface {} + public function getReader(): ReaderInterface + { + } /** * Sets the annotations parser * * @param \Phalcon\Annotations\ReaderInterface $reader */ - public function setReader(\Phalcon\Annotations\ReaderInterface $reader) {} - + public function setReader(\Phalcon\Annotations\ReaderInterface $reader) + { + } } diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/annotations/adapter/AdapterInterface.php index 69ea606c..41ccb129 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/annotations/adapter/AdapterInterface.php @@ -76,5 +76,4 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); - } diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index f6506d26..e38ccb48 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -38,7 +38,9 @@ class Apcu extends AbstractAdapter * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Reads parsed annotations from APCu @@ -46,7 +48,9 @@ public function __construct(array $options = array()) {} * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read(string $key) + { + } /** * Writes parsed annotations to APCu @@ -55,6 +59,7 @@ public function read(string $key) {} * @param \Phalcon\Annotations\Reflection $data * @return bool */ - public function write(string $key, \Phalcon\Annotations\Reflection $data): bool {} - + public function write(string $key, \Phalcon\Annotations\Reflection $data): bool + { + } } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index e60d9cfe..f885747a 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -29,7 +29,9 @@ class Memory extends AbstractAdapter * @param string $key * @return bool|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read(string $key) + { + } /** * Writes parsed annotations to memory @@ -37,6 +39,7 @@ public function read(string $key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) {} - + public function write(string $key, \Phalcon\Annotations\Reflection $data) + { + } } diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Stream.php index 9ff5d004..9d891971 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -37,7 +37,9 @@ class Stream extends AbstractAdapter * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Reads parsed annotations from files @@ -45,7 +47,9 @@ public function __construct(array $options = array()) {} * @param string $key * @return bool|int|\Phalcon\Annotations\Reflection */ - public function read(string $key) {} + public function read(string $key) + { + } /** * Writes parsed annotations to files @@ -53,6 +57,7 @@ public function read(string $key) {} * @param string $key * @param \Phalcon\Annotations\Reflection $data */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) {} - + public function write(string $key, \Phalcon\Annotations\Reflection $data) + { + } } diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index 3f5c57f1..90c5ea19 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -47,21 +47,27 @@ abstract class AbstractApplication extends Injectable implements EventsAwareInte * * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) + { + } /** * Returns the default module name * * @return string */ - public function getDefaultModule(): string {} + public function getDefaultModule(): string + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Gets the module definition registered in the application via module name @@ -69,22 +75,18 @@ public function getEventsManager(): ManagerInterface {} * @param string $name * @return array|object */ - public function getModule(string $name): array {} + public function getModule(string $name): array + { + } /** * Return the modules registered in the application * * @return array */ - public function getModules(): array {} - - /** - * Handles a request - * - * @param string $uri - * @return bool|ResponseInterface - */ - abstract public function handle(string $uri); + public function getModules(): array + { + } /** * Register an array of modules present in the application @@ -108,7 +110,9 @@ abstract public function handle(string $uri); * @param bool $merge * @return AbstractApplication */ - public function registerModules(array $modules, bool $merge = false): AbstractApplication {} + public function registerModules(array $modules, bool $merge = false): AbstractApplication + { + } /** * Sets the module name to be used if the router doesn't return a valid module @@ -116,13 +120,16 @@ public function registerModules(array $modules, bool $merge = false): AbstractAp * @param string $defaultModule * @return AbstractApplication */ - public function setDefaultModule(string $defaultModule): AbstractApplication {} + public function setDefaultModule(string $defaultModule): AbstractApplication + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } } diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 2b7ae928..e35ec0f3 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -76,61 +76,83 @@ class Asset implements AssetInterface /** * @return array|null */ - public function getAttributes(): ?array {} + public function getAttributes(): ?array + { + } /** * @param bool $autoVersion */ - public function setAutoVersion(bool $autoVersion) {} + public function setAutoVersion(bool $autoVersion) + { + } /** * @return bool */ - public function getFilter(): bool {} + public function getFilter(): bool + { + } /** * @return bool */ - public function getLocal(): bool {} + public function getLocal(): bool + { + } /** * @return string */ - public function getPath(): string {} + public function getPath(): string + { + } /** * @return string */ - public function getSourcePath(): string {} + public function getSourcePath(): string + { + } /** * @return string */ - public function getTargetPath(): string {} + public function getTargetPath(): string + { + } /** * @return string */ - public function getTargetUri(): string {} + public function getTargetUri(): string + { + } /** * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Version of resource * * @return string */ - public function getVersion(): string {} + public function getVersion(): string + { + } /** * Version of resource * * @param string $version */ - public function setVersion(string $version) {} + public function setVersion(string $version) + { + } /** * Phalcon\Assets\Asset constructor @@ -143,14 +165,18 @@ public function setVersion(string $version) {} * @param string $version * @param bool $autoVersion */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} + public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + { + } /** * Gets the asset's key. * * @return string */ - public function getAssetKey(): string {} + public function getAssetKey(): string + { + } /** * Returns the content of the asset as an string @@ -159,7 +185,9 @@ public function getAssetKey(): string {} * @param string $basePath * @return string */ - public function getContent(string $basePath = null): string {} + public function getContent(string $basePath = null): string + { + } /** * Returns the complete location where the asset is located @@ -167,7 +195,9 @@ public function getContent(string $basePath = null): string {} * @param string $basePath * @return string */ - public function getRealSourcePath(string $basePath = null): string {} + public function getRealSourcePath(string $basePath = null): string + { + } /** * Returns the complete location where the asset must be written @@ -175,21 +205,27 @@ public function getRealSourcePath(string $basePath = null): string {} * @param string $basePath * @return string */ - public function getRealTargetPath(string $basePath = null): string {} + public function getRealTargetPath(string $basePath = null): string + { + } /** * Returns the real target uri for the generated HTML * * @return string */ - public function getRealTargetUri(): string {} + public function getRealTargetUri(): string + { + } /** * Checks if resource is using auto version * * @return bool */ - public function isAutoVersion(): bool {} + public function isAutoVersion(): bool + { + } /** * Sets extra HTML attributes @@ -197,7 +233,9 @@ public function isAutoVersion(): bool {} * @param array $attributes * @return AssetInterface */ - public function setAttributes(array $attributes): AssetInterface {} + public function setAttributes(array $attributes): AssetInterface + { + } /** * Sets if the asset must be filtered or not @@ -205,7 +243,9 @@ public function setAttributes(array $attributes): AssetInterface {} * @param bool $filter * @return AssetInterface */ - public function setFilter(bool $filter): AssetInterface {} + public function setFilter(bool $filter): AssetInterface + { + } /** * Sets if the asset is local or external @@ -213,7 +253,9 @@ public function setFilter(bool $filter): AssetInterface {} * @param bool $local * @return AssetInterface */ - public function setLocal(bool $local): AssetInterface {} + public function setLocal(bool $local): AssetInterface + { + } /** * Sets the asset's source path @@ -221,7 +263,9 @@ public function setLocal(bool $local): AssetInterface {} * @param string $sourcePath * @return AssetInterface */ - public function setSourcePath(string $sourcePath): AssetInterface {} + public function setSourcePath(string $sourcePath): AssetInterface + { + } /** * Sets the asset's target path @@ -229,7 +273,9 @@ public function setSourcePath(string $sourcePath): AssetInterface {} * @param string $targetPath * @return AssetInterface */ - public function setTargetPath(string $targetPath): AssetInterface {} + public function setTargetPath(string $targetPath): AssetInterface + { + } /** * Sets a target uri for the generated HTML @@ -237,7 +283,9 @@ public function setTargetPath(string $targetPath): AssetInterface {} * @param string $targetUri * @return AssetInterface */ - public function setTargetUri(string $targetUri): AssetInterface {} + public function setTargetUri(string $targetUri): AssetInterface + { + } /** * Sets the asset's type @@ -245,7 +293,9 @@ public function setTargetUri(string $targetUri): AssetInterface {} * @param string $type * @return AssetInterface */ - public function setType(string $type): AssetInterface {} + public function setType(string $type): AssetInterface + { + } /** * Sets the asset's path @@ -253,6 +303,7 @@ public function setType(string $type): AssetInterface {} * @param string $path * @return AssetInterface */ - public function setPath(string $path): AssetInterface {} - + public function setPath(string $path): AssetInterface + { + } } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php index 8bdc5b8e..aa8050da 100644 --- a/src/Phalcon/assets/AssetInterface.php +++ b/src/Phalcon/assets/AssetInterface.php @@ -68,5 +68,4 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; - } diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/assets/Collection.php index 2cc2b5e2..fbc9a756 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/assets/Collection.php @@ -102,88 +102,120 @@ class Collection implements Countable, Iterator /** * @return array */ - public function getAssets(): array {} + public function getAssets(): array + { + } /** * @return array */ - public function getAttributes(): array {} + public function getAttributes(): array + { + } /** * Should version be determined from file modification time * * @param bool $autoVersion */ - public function setAutoVersion(bool $autoVersion) {} + public function setAutoVersion(bool $autoVersion) + { + } /** * @return array */ - public function getCodes(): array {} + public function getCodes(): array + { + } /** * @return array */ - public function getFilters(): array {} + public function getFilters(): array + { + } /** * @return bool */ - public function getJoin(): bool {} + public function getJoin(): bool + { + } /** * @return bool */ - public function getLocal(): bool {} + public function getLocal(): bool + { + } /** * @return string */ - public function getPrefix(): string {} + public function getPrefix(): string + { + } /** * @return int */ - public function getPosition(): int {} + public function getPosition(): int + { + } /** * @return string */ - public function getSourcePath(): string {} + public function getSourcePath(): string + { + } /** * @return bool */ - public function getTargetLocal(): bool {} + public function getTargetLocal(): bool + { + } /** * @return string */ - public function getTargetPath(): string {} + public function getTargetPath(): string + { + } /** * @return string */ - public function getTargetUri(): string {} + public function getTargetUri(): string + { + } /** * Version of resource * * @return string */ - public function getVersion(): string {} + public function getVersion(): string + { + } /** * Version of resource * * @param string $version */ - public function setVersion(string $version) {} + public function setVersion(string $version) + { + } /** * Phalcon\Assets\Collection constructor */ - public function __construct() {} + public function __construct() + { + } /** * Adds a asset to the collection @@ -191,7 +223,9 @@ public function __construct() {} * @param AssetInterface $asset * @return Collection */ - public function add(AssetInterface $asset): Collection {} + public function add(AssetInterface $asset): Collection + { + } /** * Adds a CSS asset to the collection @@ -204,7 +238,9 @@ public function add(AssetInterface $asset): Collection {} * @param bool $autoVersion * @return Collection */ - public function addCss(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection {} + public function addCss(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection + { + } /** * Adds a filter to the collection @@ -212,7 +248,9 @@ public function addCss(string $path, $local = null, bool $filter = true, $attrib * @param \Phalcon\Assets\FilterInterface $filter * @return Collection */ - public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection {} + public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection + { + } /** * Adds an inline code to the collection @@ -220,7 +258,9 @@ public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection { * @param \Phalcon\Assets\Inline $code * @return Collection */ - public function addInline(\Phalcon\Assets\Inline $code): Collection {} + public function addInline(\Phalcon\Assets\Inline $code): Collection + { + } /** * Adds an inline CSS to the collection @@ -230,7 +270,9 @@ public function addInline(\Phalcon\Assets\Inline $code): Collection {} * @param mixed $attributes * @return Collection */ - public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection {} + public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection + { + } /** * Adds an inline javascript to the collection @@ -240,7 +282,9 @@ public function addInlineCss(string $content, bool $filter = true, $attributes = * @param mixed $attributes * @return Collection */ - public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection {} + public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection + { + } /** * Adds a javascript asset to the collection @@ -253,21 +297,27 @@ public function addInlineJs(string $content, bool $filter = true, $attributes = * @param bool $autoVersion * @return Collection */ - public function addJs(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection {} + public function addJs(string $path, $local = null, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Collection + { + } /** * Returns the number of elements in the form * * @return int */ - public function count(): int {} + public function count(): int + { + } /** * Returns the current asset in the iterator * * @return \Phalcon\Assets\Asset */ - public function current(): Asset {} + public function current(): Asset + { + } /** * Returns the complete location where the joined/filtered collection must @@ -276,7 +326,9 @@ public function current(): Asset {} * @param string $basePath * @return string */ - public function getRealTargetPath(string $basePath): string {} + public function getRealTargetPath(string $basePath): string + { + } /** * Checks this the asset is added to the collection. @@ -296,14 +348,18 @@ public function getRealTargetPath(string $basePath): string {} * @param AssetInterface $asset * @return bool */ - public function has(AssetInterface $asset): bool {} + public function has(AssetInterface $asset): bool + { + } /** * Checks if collection is using auto version * * @return bool */ - public function isAutoVersion(): bool {} + public function isAutoVersion(): bool + { + } /** * Sets if all filtered assets in the collection must be joined in a single @@ -312,24 +368,32 @@ public function isAutoVersion(): bool {} * @param bool $join * @return Collection */ - public function join(bool $join): Collection {} + public function join(bool $join): Collection + { + } /** * Returns the current position/key in the iterator * * @return int */ - public function key(): int {} + public function key(): int + { + } /** * Moves the internal iteration pointer to the next position */ - public function next() {} + public function next() + { + } /** * Rewinds the internal iterator */ - public function rewind() {} + public function rewind() + { + } /** * Sets extra HTML attributes @@ -337,7 +401,9 @@ public function rewind() {} * @param array $attributes * @return Collection */ - public function setAttributes(array $attributes): Collection {} + public function setAttributes(array $attributes): Collection + { + } /** * Sets an array of filters in the collection @@ -345,7 +411,9 @@ public function setAttributes(array $attributes): Collection {} * @param array $filters * @return Collection */ - public function setFilters(array $filters): Collection {} + public function setFilters(array $filters): Collection + { + } /** * Sets if the collection uses local assets by default @@ -353,7 +421,9 @@ public function setFilters(array $filters): Collection {} * @param bool $local * @return Collection */ - public function setLocal(bool $local): Collection {} + public function setLocal(bool $local): Collection + { + } /** * Sets a common prefix for all the assets @@ -361,7 +431,9 @@ public function setLocal(bool $local): Collection {} * @param string $prefix * @return Collection */ - public function setPrefix(string $prefix): Collection {} + public function setPrefix(string $prefix): Collection + { + } /** * Sets the target local @@ -369,7 +441,9 @@ public function setPrefix(string $prefix): Collection {} * @param bool $targetLocal * @return Collection */ - public function setTargetLocal(bool $targetLocal): Collection {} + public function setTargetLocal(bool $targetLocal): Collection + { + } /** * Sets the target path of the file for the filtered/join output @@ -377,7 +451,9 @@ public function setTargetLocal(bool $targetLocal): Collection {} * @param string $targetPath * @return Collection */ - public function setTargetPath(string $targetPath): Collection {} + public function setTargetPath(string $targetPath): Collection + { + } /** * Sets a target uri for the generated HTML @@ -385,7 +461,9 @@ public function setTargetPath(string $targetPath): Collection {} * @param string $targetUri * @return Collection */ - public function setTargetUri(string $targetUri): Collection {} + public function setTargetUri(string $targetUri): Collection + { + } /** * Sets a base source path for all the assets in this collection @@ -393,14 +471,18 @@ public function setTargetUri(string $targetUri): Collection {} * @param string $sourcePath * @return Collection */ - public function setSourcePath(string $sourcePath): Collection {} + public function setSourcePath(string $sourcePath): Collection + { + } /** * Check if the current element in the iterator is valid * * @return bool */ - public function valid(): bool {} + public function valid(): bool + { + } /** * Adds a asset or inline-code to the collection @@ -408,6 +490,7 @@ public function valid(): bool {} * @param AssetInterface $asset * @return bool */ - final protected function addAsset(AssetInterface $asset): bool {} - + final protected function addAsset(AssetInterface $asset): bool + { + } } diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index 5a89727d..eae3f9de 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -24,5 +24,4 @@ interface FilterInterface * @return string */ public function filter(string $content): string; - } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index e62b7484..30c391f0 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -44,22 +44,30 @@ class Inline implements AssetInterface /** * @return array|null */ - public function getAttributes(): ?array {} + public function getAttributes(): ?array + { + } /** * @return string */ - public function getContent(): string {} + public function getContent(): string + { + } /** * @return bool */ - public function getFilter(): bool {} + public function getFilter(): bool + { + } /** * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Phalcon\Assets\Inline constructor @@ -69,14 +77,18 @@ public function getType(): string {} * @param bool $filter * @param array $attributes */ - public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) {} + public function __construct(string $type, string $content, bool $filter = true, array $attributes = array()) + { + } /** * Gets the asset's key. * * @return string */ - public function getAssetKey(): string {} + public function getAssetKey(): string + { + } /** * Sets extra HTML attributes @@ -84,7 +96,9 @@ public function getAssetKey(): string {} * @param array $attributes * @return AssetInterface */ - public function setAttributes(array $attributes): AssetInterface {} + public function setAttributes(array $attributes): AssetInterface + { + } /** * Sets if the asset must be filtered or not @@ -92,7 +106,9 @@ public function setAttributes(array $attributes): AssetInterface {} * @param bool $filter * @return AssetInterface */ - public function setFilter(bool $filter): AssetInterface {} + public function setFilter(bool $filter): AssetInterface + { + } /** * Sets the inline's type @@ -100,6 +116,7 @@ public function setFilter(bool $filter): AssetInterface {} * @param string $type * @return AssetInterface */ - public function setType(string $type): AssetInterface {} - + public function setType(string $type): AssetInterface + { + } } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index 7aed696d..81db6995 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -41,7 +41,9 @@ class Manager extends AbstractInjectionAware * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Adds a raw asset to the manager @@ -55,7 +57,9 @@ public function __construct(array $options = array()) {} * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function addAsset(\Phalcon\Assets\Asset $asset): Manager {} + public function addAsset(\Phalcon\Assets\Asset $asset): Manager + { + } /** * Adds a asset by its type @@ -71,7 +75,9 @@ public function addAsset(\Phalcon\Assets\Asset $asset): Manager {} * @param \Phalcon\Assets\Asset $asset * @return Manager */ - public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager {} + public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager + { + } /** * Adds a Css asset to the 'css' collection @@ -89,7 +95,9 @@ public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Mana * @param bool $autoVersion * @return Manager */ - public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} + public function addCss(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager + { + } /** * Adds a raw inline code to the manager @@ -97,7 +105,9 @@ public function addCss(string $path, $local = true, bool $filter = true, $attrib * @param Inline $code * @return Manager */ - public function addInlineCode(Inline $code): Manager {} + public function addInlineCode(Inline $code): Manager + { + } /** * Adds an inline code by its type @@ -106,7 +116,9 @@ public function addInlineCode(Inline $code): Manager {} * @param Inline $code * @return Manager */ - public function addInlineCodeByType(string $type, Inline $code): Manager {} + public function addInlineCodeByType(string $type, Inline $code): Manager + { + } /** * Adds an inline Css to the 'css' collection @@ -116,7 +128,9 @@ public function addInlineCodeByType(string $type, Inline $code): Manager {} * @param mixed $attributes * @return Manager */ - public function addInlineCss(string $content, $filter = true, $attributes = null): Manager {} + public function addInlineCss(string $content, $filter = true, $attributes = null): Manager + { + } /** * Adds an inline javascript to the 'js' collection @@ -126,7 +140,9 @@ public function addInlineCss(string $content, $filter = true, $attributes = null * @param mixed $attributes * @return Manager */ - public function addInlineJs(string $content, $filter = true, $attributes = null): Manager {} + public function addInlineJs(string $content, $filter = true, $attributes = null): Manager + { + } /** * Adds a javascript asset to the 'js' collection @@ -144,7 +160,9 @@ public function addInlineJs(string $content, $filter = true, $attributes = null) * @param bool $autoVersion * @return Manager */ - public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager {} + public function addJs(string $path, $local = true, bool $filter = true, $attributes = null, string $version = null, bool $autoVersion = false): Manager + { + } /** * Creates/Returns a collection of assets @@ -152,7 +170,9 @@ public function addJs(string $path, $local = true, bool $filter = true, $attribu * @param string $name * @return \Phalcon\Assets\Collection */ - public function collection(string $name): Collection {} + public function collection(string $name): Collection + { + } /** * Creates/Returns a collection of assets by type @@ -161,7 +181,9 @@ public function collection(string $name): Collection {} * @param string $type * @return array */ - public function collectionAssetsByType(array $assets, string $type): array {} + public function collectionAssetsByType(array $assets, string $type): array + { + } /** * Returns true or false if collection exists. @@ -176,7 +198,9 @@ public function collectionAssetsByType(array $assets, string $type): array {} * @param string $id * @return bool */ - public function exists(string $id): bool {} + public function exists(string $id): bool + { + } /** * Returns a collection by its id. @@ -188,35 +212,45 @@ public function exists(string $id): bool {} * @param string $id * @return \Phalcon\Assets\Collection */ - public function get(string $id): Collection {} + public function get(string $id): Collection + { + } /** * Returns existing collections in the manager * * @return array|\Phalcon\Assets\Collection[] */ - public function getCollections(): array {} + public function getCollections(): array + { + } /** * Returns the CSS collection of assets * * @return \Phalcon\Assets\Collection */ - public function getCss(): Collection {} + public function getCss(): Collection + { + } /** * Returns the CSS collection of assets * * @return \Phalcon\Assets\Collection */ - public function getJs(): Collection {} + public function getJs(): Collection + { + } /** * Returns the manager options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Traverses a collection calling the callback to generate its HTML @@ -226,7 +260,9 @@ public function getOptions(): array {} * @param string $type * @return string|null */ - public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string {} + public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string + { + } /** * Prints the HTML for CSS assets @@ -234,7 +270,9 @@ public function output(\Phalcon\Assets\Collection $collection, $callback, $type) * @param string $collectionName * @return string */ - public function outputCss(string $collectionName = null): string {} + public function outputCss(string $collectionName = null): string + { + } /** * Traverses a collection and generate its HTML @@ -243,7 +281,9 @@ public function outputCss(string $collectionName = null): string {} * @param string $type * @return string */ - public function outputInline(\Phalcon\Assets\Collection $collection, $type): string {} + public function outputInline(\Phalcon\Assets\Collection $collection, $type): string + { + } /** * Prints the HTML for inline CSS @@ -251,7 +291,9 @@ public function outputInline(\Phalcon\Assets\Collection $collection, $type): str * @param string $collectionName * @return string */ - public function outputInlineCss(string $collectionName = null): string {} + public function outputInlineCss(string $collectionName = null): string + { + } /** * Prints the HTML for inline JS @@ -259,7 +301,9 @@ public function outputInlineCss(string $collectionName = null): string {} * @param string $collectionName * @return string */ - public function outputInlineJs(string $collectionName = null): string {} + public function outputInlineJs(string $collectionName = null): string + { + } /** * Prints the HTML for JS assets @@ -267,7 +311,9 @@ public function outputInlineJs(string $collectionName = null): string {} * @param string $collectionName * @return string */ - public function outputJs(string $collectionName = null): string {} + public function outputJs(string $collectionName = null): string + { + } /** * Sets a collection in the Assets Manager @@ -280,7 +326,9 @@ public function outputJs(string $collectionName = null): string {} * @param \Phalcon\Assets\Collection $collection * @return Manager */ - public function set(string $id, \Phalcon\Assets\Collection $collection): Manager {} + public function set(string $id, \Phalcon\Assets\Collection $collection): Manager + { + } /** * Sets the manager options @@ -288,7 +336,9 @@ public function set(string $id, \Phalcon\Assets\Collection $collection): Manager * @param array $options * @return Manager */ - public function setOptions(array $options): Manager {} + public function setOptions(array $options): Manager + { + } /** * Sets if the HTML generated must be directly printed or returned @@ -296,7 +346,9 @@ public function setOptions(array $options): Manager {} * @param bool $implicitOutput * @return Manager */ - public function useImplicitOutput(bool $implicitOutput): Manager {} + public function useImplicitOutput(bool $implicitOutput): Manager + { + } /** * Returns the prefixed path @@ -305,6 +357,7 @@ public function useImplicitOutput(bool $implicitOutput): Manager {} * @param string $path * @return string */ - private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string {} - + private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string + { + } } diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/assets/asset/Css.php index 364dd917..719e73b1 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/assets/asset/Css.php @@ -29,6 +29,7 @@ class Css extends AssetBase * @param string $version * @param bool $autoVersion */ - public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} - + public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + { + } } diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/assets/asset/Js.php index c7f7fb3a..becb4980 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/assets/asset/Js.php @@ -29,6 +29,7 @@ class Js extends AssetBase * @param string $version * @param bool $autoVersion */ - public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) {} - + public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) + { + } } diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/assets/filters/Cssmin.php index fdb8eec0..d7012025 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/assets/filters/Cssmin.php @@ -27,6 +27,7 @@ class Cssmin implements FilterInterface * @param string $content * @return string */ - public function filter(string $content): string {} - + public function filter(string $content): string + { + } } diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/assets/filters/Jsmin.php index 8352f0d1..11ac6468 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/assets/filters/Jsmin.php @@ -28,6 +28,7 @@ class Jsmin implements FilterInterface * @param string $content * @return string */ - public function filter(string $content): string {} - + public function filter(string $content): string + { + } } diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/assets/filters/None.php index f77b9d9f..4fe7cc34 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/assets/filters/None.php @@ -25,6 +25,7 @@ class None implements FilterInterface * @param string $content * @return string */ - public function filter(string $content): string {} - + public function filter(string $content): string + { + } } diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/assets/inline/Css.php index f098cf4e..0727ce11 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/assets/inline/Css.php @@ -26,6 +26,7 @@ class Css extends InlineBase * @param bool $filter * @param mixed $attributes */ - public function __construct(string $content, bool $filter = true, $attributes = null) {} - + public function __construct(string $content, bool $filter = true, $attributes = null) + { + } } diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/assets/inline/Js.php index b090911b..39ecc6dd 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/assets/inline/Js.php @@ -26,6 +26,7 @@ class Js extends InlineBase * @param bool $filter * @param mixed $attributes */ - public function __construct(string $content, bool $filter = true, $attributes = null) {} - + public function __construct(string $content, bool $filter = true, $attributes = null) + { + } } diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/cache/AdapterFactory.php index 775d859d..e28c8f04 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/cache/AdapterFactory.php @@ -32,7 +32,9 @@ class AdapterFactory extends AbstractFactory * @param \Phalcon\Storage\SerializerFactory $factory * @param array $services */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) + { + } /** * Create a new instance of the adapter @@ -41,13 +43,16 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * @param array $options * @return \Phalcon\Cache\Adapter\AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * Returns the available adapters * * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/cache/CacheFactory.php index dc8f016f..fd0a0fe5 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/cache/CacheFactory.php @@ -29,7 +29,9 @@ class CacheFactory * * @param \Phalcon\Cache\AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory) + { + } /** * Factory to create an instace from a Config object @@ -37,7 +39,9 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory) {} * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Constructs a new Cache instance. @@ -46,6 +50,7 @@ public function load($config) {} * @param array $options * @return \Phalcon\Cache\CacheInterface */ - public function newInstance(string $name, array $options = array()): CacheInterface {} - + public function newInstance(string $name, array $options = array()): CacheInterface + { + } } diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 3c6609eb..8c1ee027 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -32,10 +32,11 @@ class Console extends AbstractApplication /** * Handle the whole command-line tasks * - * @param string $arguments - * @return bool|ResponseInterface + * @param array $arguments */ - public function handle(string $arguments) {} + public function handle(array $arguments = null) + { + } /** * Set an specific argument @@ -45,6 +46,7 @@ public function handle(string $arguments) {} * @param bool $shift * @return Console */ - public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console {} - + public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console + { + } } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index bcc4cb7c..d641303a 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -66,21 +66,27 @@ class Dispatcher extends CliDispatcher implements DispatcherInterface * @param array $params * @return mixed */ - public function callActionMethod($handler, string $actionMethod, array $params = array()) {} + public function callActionMethod($handler, string $actionMethod, array $params = array()) + { + } /** * Returns the active task in the dispatcher * * @return TaskInterface */ - public function getActiveTask(): TaskInterface {} + public function getActiveTask(): TaskInterface + { + } /** * Returns the latest dispatched controller * * @return TaskInterface */ - public function getLastTask(): TaskInterface {} + public function getLastTask(): TaskInterface + { + } /** * Gets an option by its name or numeric index @@ -90,28 +96,36 @@ public function getLastTask(): TaskInterface {} * @param mixed $defaultValue * @return mixed */ - public function getOption($option, $filters = null, $defaultValue = null) {} + public function getOption($option, $filters = null, $defaultValue = null) + { + } /** * Get dispatched options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Gets last dispatched task name * * @return string */ - public function getTaskName(): string {} + public function getTaskName(): string + { + } /** * Gets the default task suffix * * @return string */ - public function getTaskSuffix(): string {} + public function getTaskSuffix(): string + { + } /** * Check if an option exists @@ -119,42 +133,54 @@ public function getTaskSuffix(): string {} * @param mixed $option * @return bool */ - public function hasOption($option): bool {} + public function hasOption($option): bool + { + } /** * Sets the default task name * * @param string $taskName */ - public function setDefaultTask(string $taskName) {} + public function setDefaultTask(string $taskName) + { + } /** * Set the options to be dispatched * * @param array $options */ - public function setOptions(array $options) {} + public function setOptions(array $options) + { + } /** * Sets the task name to be dispatched * * @param string $taskName */ - public function setTaskName(string $taskName) {} + public function setTaskName(string $taskName) + { + } /** * Sets the default task suffix * * @param string $taskSuffix */ - public function setTaskSuffix(string $taskSuffix) {} + public function setTaskSuffix(string $taskSuffix) + { + } /** * Handles a user exception * * @param \Exception $exception */ - protected function handleException(\Exception $exception) {} + protected function handleException(\Exception $exception) + { + } /** * Throws an internal exception @@ -162,6 +188,7 @@ protected function handleException(\Exception $exception) {} * @param string $message * @param int $exceptionCode */ - protected function throwDispatchException(string $message, int $exceptionCode = 0) {} - + protected function throwDispatchException(string $message, int $exceptionCode = 0) + { + } } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index f35d5155..e2fe0261 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -81,5 +81,4 @@ public function setTaskName(string $taskName); * @param string $taskSuffix */ public function setTaskSuffix(string $taskSuffix); - } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 81d6dde5..e8cb2525 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -81,7 +81,9 @@ class Router extends AbstractInjectionAware * * @param bool $defaultRoutes */ - public function __construct(bool $defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) + { + } /** * Adds a route to the router @@ -94,42 +96,54 @@ public function __construct(bool $defaultRoutes = true) {} * @param string|array $paths * @return RouteInterface */ - public function add(string $pattern, $paths = null): RouteInterface {} + public function add(string $pattern, $paths = null): RouteInterface + { + } /** * Returns processed action name * * @return string */ - public function getActionName(): string {} + public function getActionName(): string + { + } /** * Returns the route that matches the handled URI * * @return RouteInterface */ - public function getMatchedRoute(): RouteInterface {} + public function getMatchedRoute(): RouteInterface + { + } /** * Returns the sub expressions in the regular expression matched * * @return array */ - public function getMatches(): array {} + public function getMatches(): array + { + } /** * Returns processed module name * * @return string */ - public function getModuleName(): string {} + public function getModuleName(): string + { + } /** * Returns processed extra params * * @return array */ - public function getParams(): array {} + public function getParams(): array + { + } /** * Returns a route object by its id @@ -137,7 +151,9 @@ public function getParams(): array {} * @param int $id * @return bool|RouteInterface */ - public function getRouteById($id) {} + public function getRouteById($id) + { + } /** * Returns a route object by its name @@ -145,42 +161,54 @@ public function getRouteById($id) {} * @param string $name * @return bool|RouteInterface */ - public function getRouteByName(string $name) {} + public function getRouteByName(string $name) + { + } /** * Returns all the routes defined in the router * * @return array|\Phalcon\Cli\Router\Route[] */ - public function getRoutes(): array {} + public function getRoutes(): array + { + } /** * Returns processed task name * * @return string */ - public function getTaskName(): string {} + public function getTaskName(): string + { + } /** * Handles routing information received from command-line arguments * * @param array $arguments */ - public function handle($arguments = null) {} + public function handle($arguments = null) + { + } /** * Sets the default action name * * @param string $actionName */ - public function setDefaultAction(string $actionName) {} + public function setDefaultAction(string $actionName) + { + } /** * Sets the name of the default module * * @param string $moduleName */ - public function setDefaultModule(string $moduleName) {} + public function setDefaultModule(string $moduleName) + { + } /** * Sets an array of default paths. If a route is missing a path the router @@ -199,20 +227,25 @@ public function setDefaultModule(string $moduleName) {} * @param array $defaults * @return Router */ - public function setDefaults(array $defaults): Router {} + public function setDefaults(array $defaults): Router + { + } /** * Sets the default controller name * * @param string $taskName */ - public function setDefaultTask(string $taskName) {} + public function setDefaultTask(string $taskName) + { + } /** * Checks if the router matches any of the defined routes * * @return bool */ - public function wasMatched(): bool {} - + public function wasMatched(): bool + { + } } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 1bde6647..371d32f7 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -134,5 +134,4 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 9db77a0d..78f2980f 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -43,6 +43,7 @@ class Task extends Injectable implements TaskInterface /** * Phalcon\Cli\Task constructor */ - final public function __construct() {} - + final public function __construct() + { + } } diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 05e1c670..4395d76d 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -32,7 +32,7 @@ class Route protected $delimiter; - static protected $delimiterPath = self::DEFAULT_DELIMITER; + protected static $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -50,14 +50,16 @@ class Route protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; /** * @param string $pattern * @param array|string $paths */ - public function __construct(string $pattern, $paths = null) {} + public function __construct(string $pattern, $paths = null) + { + } /** * Sets a callback that is called if the route is matched. @@ -67,7 +69,9 @@ public function __construct(string $pattern, $paths = null) {} * @param callback $callback * @return RouteInterface */ - public function beforeMatch($callback): RouteInterface {} + public function beforeMatch($callback): RouteInterface + { + } /** * Replaces placeholders from pattern returning a valid PCRE regular @@ -76,7 +80,9 @@ public function beforeMatch($callback): RouteInterface {} * @param string $pattern * @return string */ - public function compilePattern(string $pattern): string {} + public function compilePattern(string $pattern): string + { + } /** * Adds a converter to perform an additional transformation for certain @@ -86,14 +92,18 @@ public function compilePattern(string $pattern): string {} * @param callable $converter * @return RouteInterface */ - public function convert(string $name, $converter): RouteInterface {} + public function convert(string $name, $converter): RouteInterface + { + } /** * Set the routing delimiter * * @param string $delimiter */ - public static function delimiter(string $delimiter = null) {} + public static function delimiter(string $delimiter = null) + { + } /** * Extracts parameters from a string @@ -101,77 +111,99 @@ public static function delimiter(string $delimiter = null) {} * @param string $pattern * @return array|bool */ - public function extractNamedParams(string $pattern) {} + public function extractNamedParams(string $pattern) + { + } /** * Returns the 'before match' callback if any * * @return mixed */ - public function getBeforeMatch() {} + public function getBeforeMatch() + { + } /** * Returns the route's compiled pattern * * @return string */ - public function getCompiledPattern(): string {} + public function getCompiledPattern(): string + { + } /** * Returns the router converter * * @return array */ - public function getConverters(): array {} + public function getConverters(): array + { + } /** * Get routing delimiter * * @return string */ - public static function getDelimiter(): string {} + public static function getDelimiter(): string + { + } /** * Returns the route's description * * @return string */ - public function getDescription(): string {} + public function getDescription(): string + { + } /** * Returns the route's name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Returns the paths * * @return array */ - public function getPaths(): array {} + public function getPaths(): array + { + } /** * Returns the route's pattern * * @return string */ - public function getPattern(): string {} + public function getPattern(): string + { + } /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths(): array {} + public function getReversedPaths(): array + { + } /** * Returns the route's id * * @return string */ - public function getRouteId(): string {} + public function getRouteId(): string + { + } /** * Reconfigure the route adding a new pattern and a set of paths @@ -179,12 +211,16 @@ public function getRouteId(): string {} * @param string $pattern * @param array|string $paths */ - public function reConfigure(string $pattern, $paths = null) {} + public function reConfigure(string $pattern, $paths = null) + { + } /** * Resets the internal route id generator */ - public static function reset() {} + public static function reset() + { + } /** * Sets the route's description @@ -192,7 +228,9 @@ public static function reset() {} * @param string $description * @return RouteInterface */ - public function setDescription(string $description): RouteInterface {} + public function setDescription(string $description): RouteInterface + { + } /** * Sets the route's name @@ -209,6 +247,7 @@ public function setDescription(string $description): RouteInterface {} * @param string $name * @return RouteInterface */ - public function setName(string $name): RouteInterface {} - + public function setName(string $name): RouteInterface + { + } } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index 0724e5cc..fbdea9e2 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -117,5 +117,4 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; - } diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/collection/ReadOnly.php index e42ed93c..522d50f9 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/collection/ReadOnly.php @@ -24,7 +24,9 @@ class ReadOnly extends Collection * * @param string $element */ - public function remove(string $element) {} + public function remove(string $element) + { + } /** * Set an element in the collection @@ -32,6 +34,7 @@ public function remove(string $element) {} * @param string $element * @param mixed $value */ - public function set(string $element, $value) {} - + public function set(string $element, $value) + { + } } diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/config/ConfigFactory.php index c59d8331..3e20cace 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/config/ConfigFactory.php @@ -36,7 +36,9 @@ class ConfigFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Load a config to create a new instance @@ -44,7 +46,9 @@ public function __construct(array $services = array()) {} * @param mixed $config * @return object */ - public function load($config) {} + public function load($config) + { + } /** * Returns a new Config instance @@ -54,13 +58,16 @@ public function load($config) {} * @param mixed $params * @return object */ - public function newInstance(string $name, string $fileName, $params = null) {} + public function newInstance(string $name, string $fileName, $params = null) + { + } /** * Returns the adapters for the factory * * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 57eafe0e..33cb4844 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -73,6 +73,7 @@ class Grouped extends Config * @param array $arrayConfig * @param string $defaultAdapter */ - public function __construct(array $arrayConfig, string $defaultAdapter = 'php') {} - + public function __construct(array $arrayConfig, string $defaultAdapter = 'php') + { + } } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 6dfedb88..643ad9cf 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -64,7 +64,9 @@ class Ini extends Config * @param string $filePath * @param mixed $mode */ - public function __construct(string $filePath, $mode = null) {} + public function __construct(string $filePath, $mode = null) + { + } /** * We have to cast values manually because parse_ini_file() has a poor @@ -73,7 +75,9 @@ public function __construct(string $filePath, $mode = null) {} * @param mixed $ini * @return bool|null|double|int|string */ - protected function cast($ini) {} + protected function cast($ini) + { + } /** * Build multidimensional array from string @@ -82,6 +86,7 @@ protected function cast($ini) {} * @param mixed $value * @return array */ - protected function parseIniString(string $path, $value): array {} - + protected function parseIniString(string $path, $value): array + { + } } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 10ae69f4..ecb773ca 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -41,6 +41,7 @@ class Json extends Config * * @param string $filePath */ - public function __construct(string $filePath) {} - + public function __construct(string $filePath) + { + } } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index 478eabf6..0399da11 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -56,6 +56,7 @@ class Php extends Config * * @param string $filePath */ - public function __construct(string $filePath) {} - + public function __construct(string $filePath) + { + } } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index f45afc10..c586eace 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -59,6 +59,7 @@ class Yaml extends Config * @param string $filePath * @param array $callbacks */ - public function __construct(string $filePath, array $callbacks = null) {} - + public function __construct(string $filePath, array $callbacks = null) + { + } } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php index 4432b1cc..ce124ece 100644 --- a/src/Phalcon/crypt/CryptInterface.php +++ b/src/Phalcon/crypt/CryptInterface.php @@ -142,5 +142,4 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; - } diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/db/AbstractDb.php index 6a7e8374..e901c5b4 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/db/AbstractDb.php @@ -62,6 +62,7 @@ abstract class AbstractDb * * @param array $options */ - public static function setup(array $options) {} - + public static function setup(array $options) + { + } } diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 45430218..9e1ea34e 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -307,49 +307,63 @@ class Column implements ColumnInterface /** * Default column value */ - public function getDefault() {} + public function getDefault() + { + } /** * Column's name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Integer column number scale * * @return int */ - public function getScale(): int {} + public function getScale(): int + { + } /** * Integer column size * * @return int */ - public function getSize(): int {} + public function getSize(): int + { + } /** * Column data type * * @return int */ - public function getType(): int {} + public function getType(): int + { + } /** * Column data type reference * * @return int */ - public function getTypeReference(): int {} + public function getTypeReference(): int + { + } /** * Column data type values * * @return array|string */ - public function getTypeValues() {} + public function getTypeValues() + { + } /** * Phalcon\Db\Column constructor @@ -357,69 +371,88 @@ public function getTypeValues() {} * @param string $name * @param array $definition */ - public function __construct(string $name, array $definition) {} + public function __construct(string $name, array $definition) + { + } /** * Check whether field absolute to position in table * * @return string */ - public function getAfterPosition(): string {} + public function getAfterPosition(): string + { + } /** * Returns the type of bind handling * * @return int */ - public function getBindType(): int {} + public function getBindType(): int + { + } /** * Check whether column has default value * * @return bool */ - public function hasDefault(): bool {} + public function hasDefault(): bool + { + } /** * Auto-Increment * * @return bool */ - public function isAutoIncrement(): bool {} + public function isAutoIncrement(): bool + { + } /** * Check whether column have first position in table * * @return bool */ - public function isFirst(): bool {} + public function isFirst(): bool + { + } /** * Not null * * @return bool */ - public function isNotNull(): bool {} + public function isNotNull(): bool + { + } /** * Check whether column have an numeric type * * @return bool */ - public function isNumeric(): bool {} + public function isNumeric(): bool + { + } /** * Column is part of the primary key? * * @return bool */ - public function isPrimary(): bool {} + public function isPrimary(): bool + { + } /** * Returns true if number column is unsigned * * @return bool */ - public function isUnsigned(): bool {} - + public function isUnsigned(): bool + { + } } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index 30928fbc..3339bc0a 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -128,5 +128,4 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; - } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index 6a4ddae6..72a3fa01 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -30,7 +30,9 @@ abstract class Dialect implements DialectInterface * @param string $name * @return string */ - public function createSavepoint(string $name): string {} + public function createSavepoint(string $name): string + { + } /** * Escape identifiers @@ -39,7 +41,9 @@ public function createSavepoint(string $name): string {} * @param string $escapeChar * @return string */ - final public function escape(string $str, string $escapeChar = null): string {} + final public function escape(string $str, string $escapeChar = null): string + { + } /** * Escape Schema @@ -48,7 +52,9 @@ final public function escape(string $str, string $escapeChar = null): string {} * @param string $escapeChar * @return string */ - final public function escapeSchema(string $str, string $escapeChar = null): string {} + final public function escapeSchema(string $str, string $escapeChar = null): string + { + } /** * Returns a SQL modified with a FOR UPDATE clause @@ -62,7 +68,9 @@ final public function escapeSchema(string $str, string $escapeChar = null): stri * @param string $sqlQuery * @return string */ - public function forUpdate(string $sqlQuery): string {} + public function forUpdate(string $sqlQuery): string + { + } /** * Gets a list of columns with escaped identifiers @@ -81,14 +89,18 @@ public function forUpdate(string $sqlQuery): string {} * @param mixed $bindCounts * @return string */ - final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string {} + final public function getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string + { + } /** * Returns registered functions * * @return array */ - public function getCustomFunctions(): array {} + public function getCustomFunctions(): array + { + } /** * Resolve Column expressions @@ -98,7 +110,9 @@ public function getCustomFunctions(): array {} * @param mixed $bindCounts * @return string */ - final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string {} + final public function getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string + { + } /** * Transforms an intermediate representation for an expression into a database system valid expression @@ -108,7 +122,9 @@ final public function getSqlColumn($column, string $escapeChar = null, $bindCoun * @param mixed $bindCounts * @return string */ - public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string {} + public function getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Transform an intermediate representation of a schema/table into a @@ -118,7 +134,9 @@ public function getSqlExpression(array $expression, string $escapeChar = null, $ * @param string $escapeChar * @return string */ - final public function getSqlTable($table, string $escapeChar = null): string {} + final public function getSqlTable($table, string $escapeChar = null): string + { + } /** * Generates the SQL for LIMIT clause @@ -141,7 +159,9 @@ final public function getSqlTable($table, string $escapeChar = null): string {} * @param mixed $number * @return string */ - public function limit(string $sqlQuery, $number): string {} + public function limit(string $sqlQuery, $number): string + { + } /** * Registers custom SQL functions @@ -150,7 +170,9 @@ public function limit(string $sqlQuery, $number): string {} * @param callable $customFunction * @return Dialect */ - public function registerCustomFunction(string $name, $customFunction): Dialect {} + public function registerCustomFunction(string $name, $customFunction): Dialect + { + } /** * Generate SQL to release a savepoint @@ -158,7 +180,9 @@ public function registerCustomFunction(string $name, $customFunction): Dialect { * @param string $name * @return string */ - public function releaseSavepoint(string $name): string {} + public function releaseSavepoint(string $name): string + { + } /** * Generate SQL to rollback a savepoint @@ -166,7 +190,9 @@ public function releaseSavepoint(string $name): string {} * @param string $name * @return string */ - public function rollbackSavepoint(string $name): string {} + public function rollbackSavepoint(string $name): string + { + } /** * Builds a SELECT statement @@ -174,21 +200,27 @@ public function rollbackSavepoint(string $name): string {} * @param array $definition * @return string */ - public function select(array $definition): string {} + public function select(array $definition): string + { + } /** * Checks whether the platform supports savepoints * * @return bool */ - public function supportsSavepoints(): bool {} + public function supportsSavepoints(): bool + { + } /** * Checks whether the platform supports releasing savepoints. * * @return bool */ - public function supportsReleaseSavepoints(): bool {} + public function supportsReleaseSavepoints(): bool + { + } /** * Returns the size of the column enclosed in parentheses @@ -196,7 +228,9 @@ public function supportsReleaseSavepoints(): bool {} * @param ColumnInterface $column * @return string */ - protected function getColumnSize(ColumnInterface $column): string {} + protected function getColumnSize(ColumnInterface $column): string + { + } /** * Returns the column size and scale enclosed in parentheses @@ -204,7 +238,9 @@ protected function getColumnSize(ColumnInterface $column): string {} * @param ColumnInterface $column * @return string */ - protected function getColumnSizeAndScale(ColumnInterface $column): string {} + protected function getColumnSizeAndScale(ColumnInterface $column): string + { + } /** * Checks the column type and if not string it returns the type reference @@ -212,7 +248,9 @@ protected function getColumnSizeAndScale(ColumnInterface $column): string {} * @param ColumnInterface $column * @return string */ - protected function checkColumnType(ColumnInterface $column): string {} + protected function checkColumnType(ColumnInterface $column): string + { + } /** * Checks the column type and returns the updated SQL statement @@ -220,7 +258,9 @@ protected function checkColumnType(ColumnInterface $column): string {} * @param ColumnInterface $column * @return string */ - protected function checkColumnTypeSql(ColumnInterface $column): string {} + protected function checkColumnTypeSql(ColumnInterface $column): string + { + } /** * Resolve @@ -229,7 +269,9 @@ protected function checkColumnTypeSql(ColumnInterface $column): string {} * @param string $escapeChar * @return string */ - final protected function getSqlExpressionAll(array $expression, string $escapeChar = null): string {} + final protected function getSqlExpressionAll(array $expression, string $escapeChar = null): string + { + } /** * Resolve binary operations expressions @@ -239,7 +281,9 @@ final protected function getSqlExpressionAll(array $expression, string $escapeCh * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionBinaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve CASE expressions @@ -249,7 +293,9 @@ final protected function getSqlExpressionBinaryOperations(array $expression, str * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionCase(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve CAST of values @@ -259,7 +305,9 @@ final protected function getSqlExpressionCase(array $expression, string $escapeC * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionCastValue(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve CONVERT of values encodings @@ -269,7 +317,9 @@ final protected function getSqlExpressionCastValue(array $expression, string $es * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionConvertValue(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve a FROM clause @@ -278,7 +328,9 @@ final protected function getSqlExpressionConvertValue(array $expression, string * @param string $escapeChar * @return string */ - final protected function getSqlExpressionFrom($expression, string $escapeChar = null): string {} + final protected function getSqlExpressionFrom($expression, string $escapeChar = null): string + { + } /** * Resolve function calls @@ -288,7 +340,9 @@ final protected function getSqlExpressionFrom($expression, string $escapeChar = * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string {} + final protected function getSqlExpressionFunctionCall(array $expression, string $escapeChar = null, $bindCounts): string + { + } /** * Resolve a GROUP BY clause @@ -298,7 +352,9 @@ final protected function getSqlExpressionFunctionCall(array $expression, string * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionGroupBy($expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve a HAVING clause @@ -308,7 +364,9 @@ final protected function getSqlExpressionGroupBy($expression, string $escapeChar * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionHaving(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve a JOINs clause @@ -318,7 +376,9 @@ final protected function getSqlExpressionHaving(array $expression, string $escap * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionJoins($expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve a LIMIT clause @@ -328,7 +388,9 @@ final protected function getSqlExpressionJoins($expression, string $escapeChar = * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionLimit($expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve Lists @@ -338,7 +400,9 @@ final protected function getSqlExpressionLimit($expression, string $escapeChar = * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionList(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve object expressions @@ -348,7 +412,9 @@ final protected function getSqlExpressionList(array $expression, string $escapeC * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionObject(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve an ORDER BY clause @@ -358,7 +424,9 @@ final protected function getSqlExpressionObject(array $expression, string $escap * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionOrderBy($expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve qualified expressions @@ -367,7 +435,9 @@ final protected function getSqlExpressionOrderBy($expression, string $escapeChar * @param string $escapeChar * @return string */ - final protected function getSqlExpressionQualified(array $expression, string $escapeChar = null): string {} + final protected function getSqlExpressionQualified(array $expression, string $escapeChar = null): string + { + } /** * Resolve Column expressions @@ -377,7 +447,9 @@ final protected function getSqlExpressionQualified(array $expression, string $es * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionScalar(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve unary operations expressions @@ -387,7 +459,9 @@ final protected function getSqlExpressionScalar(array $expression, string $escap * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionUnaryOperations(array $expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Resolve a WHERE clause @@ -397,7 +471,9 @@ final protected function getSqlExpressionUnaryOperations(array $expression, stri * @param mixed $bindCounts * @return string */ - final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string {} + final protected function getSqlExpressionWhere($expression, string $escapeChar = null, $bindCounts = null): string + { + } /** * Prepares column for this RDBMS @@ -407,7 +483,9 @@ final protected function getSqlExpressionWhere($expression, string $escapeChar = * @param string $escapeChar * @return string */ - protected function prepareColumnAlias(string $qualified, string $alias = null, string $escapeChar = null): string {} + protected function prepareColumnAlias(string $qualified, string $alias = null, string $escapeChar = null): string + { + } /** * Prepares table for this RDBMS @@ -418,7 +496,9 @@ protected function prepareColumnAlias(string $qualified, string $alias = null, s * @param string $escapeChar * @return string */ - protected function prepareTable(string $table, string $schema = null, string $alias = null, string $escapeChar = null): string {} + protected function prepareTable(string $table, string $schema = null, string $alias = null, string $escapeChar = null): string + { + } /** * Prepares qualified for this RDBMS @@ -428,6 +508,7 @@ protected function prepareTable(string $table, string $schema = null, string $al * @param string $escapeChar * @return string */ - protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string {} - + protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string + { + } } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 72b4cbc2..00d837c1 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -321,5 +321,4 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; - } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php index 9174f5e3..aa486df7 100644 --- a/src/Phalcon/db/Enum.php +++ b/src/Phalcon/db/Enum.php @@ -66,6 +66,4 @@ class Enum const FETCH_UNIQUE = 196608; - - } diff --git a/src/Phalcon/db/Index.php b/src/Phalcon/db/Index.php index acdb4042..f5246851 100644 --- a/src/Phalcon/db/Index.php +++ b/src/Phalcon/db/Index.php @@ -69,21 +69,27 @@ class Index implements IndexInterface * * @return array */ - public function getColumns(): array {} + public function getColumns(): array + { + } /** * Index name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Index type * * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Phalcon\Db\Index constructor @@ -92,6 +98,7 @@ public function getType(): string {} * @param array $columns * @param string $type */ - public function __construct(string $name, array $columns, string $type = '') {} - + public function __construct(string $name, array $columns, string $type = '') + { + } } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index ba45ccae..f7ee342d 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -37,5 +37,4 @@ public function getName(): string; * @return string */ public function getType(): string; - } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index fbe3ea40..dd6d5e04 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -93,35 +93,45 @@ class Profiler * * @return \Phalcon\Db\Profiler\Item */ - public function getLastProfile(): Item {} + public function getLastProfile(): Item + { + } /** * Returns the total number of SQL statements processed * * @return int */ - public function getNumberTotalStatements(): int {} + public function getNumberTotalStatements(): int + { + } /** * Returns the total time in seconds spent by the profiles * * @return double */ - public function getTotalElapsedSeconds(): float {} + public function getTotalElapsedSeconds(): float + { + } /** * Returns all the processed profiles * * @return array|\Phalcon\Db\Profiler\Item[] */ - public function getProfiles(): array {} + public function getProfiles(): array + { + } /** * Resets the profiler, cleaning up all the profiles * * @return Profiler */ - public function reset(): Profiler {} + public function reset(): Profiler + { + } /** * Starts the profile of a SQL sentence @@ -131,13 +141,16 @@ public function reset(): Profiler {} * @param mixed $sqlBindTypes * @return Profiler */ - public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBindTypes = null): Profiler {} + public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBindTypes = null): Profiler + { + } /** * Stops the active profile * * @return Profiler */ - public function stopProfile(): Profiler {} - + public function stopProfile(): Profiler + { + } } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index b4040d2e..87faeafe 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -40,20 +40,25 @@ class RawValue * * @return string */ - public function getValue(): string {} + public function getValue(): string + { + } /** * Raw value without quoting or formatting * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Phalcon\Db\RawValue constructor * * @param mixed $value */ - public function __construct($value) {} - + public function __construct($value) + { + } } diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index f2d4cdcf..2fa59d98 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -96,56 +96,72 @@ class Reference implements ReferenceInterface * * @return array */ - public function getColumns(): array {} + public function getColumns(): array + { + } /** * Constraint name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Referenced Columns * * @return array */ - public function getReferencedColumns(): array {} + public function getReferencedColumns(): array + { + } /** * Referenced Schema * * @return string */ - public function getReferencedSchema(): string {} + public function getReferencedSchema(): string + { + } /** * Referenced Table * * @return string */ - public function getReferencedTable(): string {} + public function getReferencedTable(): string + { + } /** * Schema name * * @return string */ - public function getSchemaName(): string {} + public function getSchemaName(): string + { + } /** * ON DELETE * * @return string */ - public function getOnDelete(): string {} + public function getOnDelete(): string + { + } /** * ON UPDATE * * @return string */ - public function getOnUpdate(): string {} + public function getOnUpdate(): string + { + } /** * Phalcon\Db\Reference constructor @@ -153,6 +169,7 @@ public function getOnUpdate(): string {} * @param string $name * @param array $definition */ - public function __construct(string $name, array $definition) {} - + public function __construct(string $name, array $definition) + { + } } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index fbc00dbb..42e1fb62 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -72,5 +72,4 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; - } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index ca9cdade..5cf82928 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -82,5 +82,4 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; - } diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index 97c683de..3607f9e0 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -25,7 +25,7 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface /** * Connection ID */ - static protected $connectionConsecutive = 0; + protected static $connectionConsecutive = 0; /** * Active connection ID @@ -102,28 +102,36 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface * * @return string */ - public function getDialectType(): string {} + public function getDialectType(): string + { + } /** * Active SQL bound parameter variables * * @return array */ - public function getSqlVariables(): array {} + public function getSqlVariables(): array + { + } /** * Type of database system the adapter is used for * * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Phalcon\Db\Adapter constructor * * @param array $descriptor */ - public function __construct(array $descriptor) {} + public function __construct(array $descriptor) + { + } /** * Adds a column to a table @@ -133,7 +141,9 @@ public function __construct(array $descriptor) {} * @param \Phalcon\Db\ColumnInterface $column * @return bool */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): bool {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): bool + { + } /** * Adds a foreign key to a table @@ -143,7 +153,9 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * @param \Phalcon\Db\ReferenceInterface $reference * @return bool */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool + { + } /** * Adds an index to a table @@ -153,7 +165,9 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * @param \Phalcon\Db\IndexInterface $index * @return bool */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool + { + } /** * Adds a primary key to a table @@ -163,7 +177,9 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * @param \Phalcon\Db\IndexInterface $index * @return bool */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool + { + } /** * Creates a new savepoint @@ -171,7 +187,9 @@ public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db * @param string $name * @return bool */ - public function createSavepoint(string $name): bool {} + public function createSavepoint(string $name): bool + { + } /** * Creates a table @@ -181,7 +199,9 @@ public function createSavepoint(string $name): bool {} * @param array $definition * @return bool */ - public function createTable(string $tableName, string $schemaName, array $definition): bool {} + public function createTable(string $tableName, string $schemaName, array $definition): bool + { + } /** * Creates a view @@ -191,7 +211,9 @@ public function createTable(string $tableName, string $schemaName, array $defini * @param string $schemaName * @return bool */ - public function createView(string $viewName, array $definition, string $schemaName = null): bool {} + public function createView(string $viewName, array $definition, string $schemaName = null): bool + { + } /** * Deletes data from a table using custom RBDM SQL syntax @@ -213,7 +235,9 @@ public function createView(string $viewName, array $definition, string $schemaNa * @param mixed $dataTypes * @return bool */ - public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool {} + public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool + { + } /** * Lists table indexes @@ -228,7 +252,9 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * @param string $schema * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes(string $table, string $schema = null): array {} + public function describeIndexes(string $table, string $schema = null): array + { + } /** * Lists table references @@ -243,7 +269,9 @@ public function describeIndexes(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences(string $table, string $schema = null): array {} + public function describeReferences(string $table, string $schema = null): array + { + } /** * Drops a column from a table @@ -253,7 +281,9 @@ public function describeReferences(string $table, string $schema = null): array * @param string $columnName * @return bool */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): bool {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): bool + { + } /** * Drops a foreign key from a table @@ -263,7 +293,9 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return bool */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): bool {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): bool + { + } /** * Drop an index from a table @@ -273,7 +305,9 @@ public function dropForeignKey(string $tableName, string $schemaName, string $re * @param mixed $indexName * @return bool */ - public function dropIndex(string $tableName, string $schemaName, $indexName): bool {} + public function dropIndex(string $tableName, string $schemaName, $indexName): bool + { + } /** * Drops a table's primary key @@ -282,7 +316,9 @@ public function dropIndex(string $tableName, string $schemaName, $indexName): bo * @param string $schemaName * @return bool */ - public function dropPrimaryKey(string $tableName, string $schemaName): bool {} + public function dropPrimaryKey(string $tableName, string $schemaName): bool + { + } /** * Drops a table from a schema/database @@ -292,7 +328,9 @@ public function dropPrimaryKey(string $tableName, string $schemaName): bool {} * @param bool $ifExists * @return bool */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): bool {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): bool + { + } /** * Drops a view @@ -302,7 +340,9 @@ public function dropTable(string $tableName, string $schemaName = null, bool $if * @param bool $ifExists * @return bool */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): bool {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): bool + { + } /** * Escapes a column/table/schema name @@ -323,7 +363,9 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx * @param mixed $identifier * @return string */ - public function escapeIdentifier($identifier): string {} + public function escapeIdentifier($identifier): string + { + } /** * Dumps the complete result of a query into an array @@ -358,7 +400,9 @@ public function escapeIdentifier($identifier): string {} * @param mixed $bindTypes * @return array */ - public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} + public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array + { + } /** * Returns the n'th field of first row in a SQL query result @@ -381,7 +425,9 @@ public function fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $ * @param mixed $column * @return string|bool */ - public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) {} + public function fetchColumn(string $sqlQuery, array $placeholders = array(), $column = 0) + { + } /** * Returns the first row in a SQL query result @@ -405,7 +451,9 @@ public function fetchColumn(string $sqlQuery, array $placeholders = array(), $co * @param mixed $bindTypes * @return array */ - public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array {} + public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array + { + } /** * Returns a SQL modified with a FOR UPDATE clause @@ -413,7 +461,9 @@ public function fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bind * @param string $sqlQuery * @return string */ - public function forUpdate(string $sqlQuery): string {} + public function forUpdate(string $sqlQuery): string + { + } /** * Returns the SQL column definition from a column @@ -421,7 +471,9 @@ public function forUpdate(string $sqlQuery): string {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + { + } /** * Gets a list of columns @@ -429,14 +481,18 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string * @param mixed $columnList * @return string */ - public function getColumnList($columnList): string {} + public function getColumnList($columnList): string + { + } /** * Gets the active connection unique identifier * * @return string */ - public function getConnectionId(): string {} + public function getConnectionId(): string + { + } /** * Returns the default identity value to be inserted in an identity column @@ -460,7 +516,9 @@ public function getConnectionId(): string {} * * @return \Phalcon\Db\RawValue */ - public function getDefaultIdValue(): RawValue {} + public function getDefaultIdValue(): RawValue + { + } /** * Returns the default value to make the RBDM use the default value declared @@ -483,56 +541,72 @@ public function getDefaultIdValue(): RawValue {} * * @return \Phalcon\Db\RawValue */ - public function getDefaultValue(): RawValue {} + public function getDefaultValue(): RawValue + { + } /** * Return descriptor used to connect to the active database * * @return array */ - public function getDescriptor(): array {} + public function getDescriptor(): array + { + } /** * Returns internal dialect instance * * @return \Phalcon\Db\DialectInterface */ - public function getDialect(): DialectInterface {} + public function getDialect(): DialectInterface + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Returns the savepoint name to use for nested transactions * * @return string */ - public function getNestedTransactionSavepointName(): string {} + public function getNestedTransactionSavepointName(): string + { + } /** * Active SQL statement in the object without replace bound parameters * * @return string */ - public function getRealSQLStatement(): string {} + public function getRealSQLStatement(): string + { + } /** * Active SQL statement in the object * * @return array */ - public function getSQLBindTypes(): array {} + public function getSQLBindTypes(): array + { + } /** * Active SQL statement in the object * * @return string */ - public function getSQLStatement(): string {} + public function getSQLStatement(): string + { + } /** * Inserts data into a table using custom RDBMS SQL syntax @@ -555,7 +629,9 @@ public function getSQLStatement(): string {} * @param mixed $dataTypes * @return bool */ - public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool {} + public function insert(string $table, array $values, $fields = null, $dataTypes = null): bool + { + } /** * Inserts data into a table using custom RBDM SQL syntax @@ -579,14 +655,18 @@ public function insert(string $table, array $values, $fields = null, $dataTypes * @param mixed $dataTypes * @return bool */ - public function insertAsDict(string $table, $data, $dataTypes = null): bool {} + public function insertAsDict(string $table, $data, $dataTypes = null): bool + { + } /** * Returns if nested transactions should use savepoints * * @return bool */ - public function isNestedTransactionsWithSavepoints(): bool {} + public function isNestedTransactionsWithSavepoints(): bool + { + } /** * Appends a LIMIT clause to $sqlQuery argument @@ -599,7 +679,9 @@ public function isNestedTransactionsWithSavepoints(): bool {} * @param int $number * @return string */ - public function limit(string $sqlQuery, int $number): string {} + public function limit(string $sqlQuery, int $number): string + { + } /** * List all tables on a database @@ -613,7 +695,9 @@ public function limit(string $sqlQuery, int $number): string {} * @param string $schemaName * @return array */ - public function listTables(string $schemaName = null): array {} + public function listTables(string $schemaName = null): array + { + } /** * List all views on a database @@ -627,7 +711,9 @@ public function listTables(string $schemaName = null): array {} * @param string $schemaName * @return array */ - public function listViews(string $schemaName = null): array {} + public function listViews(string $schemaName = null): array + { + } /** * Modifies a table column based on a definition @@ -638,7 +724,9 @@ public function listViews(string $schemaName = null): array {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool + { + } /** * Releases given savepoint @@ -646,7 +734,9 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $name * @return bool */ - public function releaseSavepoint(string $name): bool {} + public function releaseSavepoint(string $name): bool + { + } /** * Rollbacks given savepoint @@ -654,21 +744,27 @@ public function releaseSavepoint(string $name): bool {} * @param string $name * @return bool */ - public function rollbackSavepoint(string $name): bool {} + public function rollbackSavepoint(string $name): bool + { + } /** * Sets the event manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets the dialect used to produce the SQL * * @param \Phalcon\Db\DialectInterface $dialect */ - public function setDialect(\Phalcon\Db\DialectInterface $dialect) {} + public function setDialect(\Phalcon\Db\DialectInterface $dialect) + { + } /** * Set if nested transactions should use savepoints @@ -676,7 +772,9 @@ public function setDialect(\Phalcon\Db\DialectInterface $dialect) {} * @param bool $nestedTransactionsWithSavepoints * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface {} + public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface + { + } /** * Returns a SQL modified with a LOCK IN SHARE MODE clause @@ -684,7 +782,9 @@ public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWith * @param string $sqlQuery * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function sharedLock(string $sqlQuery): string + { + } /** * Check whether the database system requires a sequence to produce @@ -692,7 +792,9 @@ public function sharedLock(string $sqlQuery): string {} * * @return bool */ - public function supportSequences(): bool {} + public function supportSequences(): bool + { + } /** * Generates SQL checking for the existence of a schema.table @@ -707,7 +809,9 @@ public function supportSequences(): bool {} * @param string $schemaName * @return bool */ - public function tableExists(string $tableName, string $schemaName = null): bool {} + public function tableExists(string $tableName, string $schemaName = null): bool + { + } /** * Gets creation options from a table @@ -722,7 +826,9 @@ public function tableExists(string $tableName, string $schemaName = null): bool * @param string $schemaName * @return array */ - public function tableOptions(string $tableName, string $schemaName = null): array {} + public function tableOptions(string $tableName, string $schemaName = null): array + { + } /** * Updates data on a table using custom RBDM SQL syntax @@ -765,7 +871,9 @@ public function tableOptions(string $tableName, string $schemaName = null): arra * @param mixed $dataTypes * @return bool */ - public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool {} + public function update(string $table, $fields, $values, $whereCondition = null, $dataTypes = null): bool + { + } /** * Updates data on a table using custom RBDM SQL syntax @@ -791,7 +899,9 @@ public function update(string $table, $fields, $values, $whereCondition = null, * @param mixed $dataTypes * @return bool */ - public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool {} + public function updateAsDict(string $table, $data, $whereCondition = null, $dataTypes = null): bool + { + } /** * Check whether the database system requires an explicit value for identity @@ -799,7 +909,9 @@ public function updateAsDict(string $table, $data, $whereCondition = null, $data * * @return bool */ - public function useExplicitIdValue(): bool {} + public function useExplicitIdValue(): bool + { + } /** * Generates SQL checking for the existence of a schema.view @@ -814,6 +926,7 @@ public function useExplicitIdValue(): bool {} * @param string $schemaName * @return bool */ - public function viewExists(string $viewName, string $schemaName = null): bool {} - + public function viewExists(string $viewName, string $schemaName = null): bool + { + } } diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index ee898e6f..9791f1af 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -630,5 +630,4 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; - } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php index 0d70c5ce..fa3dcb1c 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -21,7 +21,9 @@ class PdoFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Factory to create an instace from a Config object @@ -29,7 +31,9 @@ public function __construct(array $services = array()) {} * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Create a new instance of the adapter @@ -38,13 +42,16 @@ public function load($config) {} * @param array $options * @return \Phalcon\Db\Adapter\AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * Returns the available adapters * * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php index 77b7a617..4b4a6dba 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -51,7 +51,9 @@ abstract class AbstractPdo extends AbstractAdapter * * @param array $descriptor */ - public function __construct(array $descriptor) {} + public function __construct(array $descriptor) + { + } /** * Returns the number of affected rows by the latest INSERT/UPDATE/DELETE @@ -67,7 +69,9 @@ public function __construct(array $descriptor) {} * * @return int */ - public function affectedRows(): int {} + public function affectedRows(): int + { + } /** * Starts a transaction in the connection @@ -75,7 +79,9 @@ public function affectedRows(): int {} * @param bool $nesting * @return bool */ - public function begin(bool $nesting = true): bool {} + public function begin(bool $nesting = true): bool + { + } /** * Commits the active transaction in the connection @@ -83,7 +89,9 @@ public function begin(bool $nesting = true): bool {} * @param bool $nesting * @return bool */ - public function commit(bool $nesting = true): bool {} + public function commit(bool $nesting = true): bool + { + } /** * Closes the active connection returning success. Phalcon automatically @@ -91,7 +99,9 @@ public function commit(bool $nesting = true): bool {} * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * This method is automatically called in \Phalcon\Db\Adapter\Pdo @@ -120,7 +130,9 @@ public function close(): bool {} * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null): bool {} + public function connect(array $descriptor = null): bool + { + } /** * Converts bound parameters such as :name: or ?1 into PDO bind params ? @@ -140,7 +152,9 @@ public function connect(array $descriptor = null): bool {} * @param array $params * @return array */ - public function convertBoundParams(string $sql, array $params = array()): array {} + public function convertBoundParams(string $sql, array $params = array()): array + { + } /** * Escapes a value to avoid SQL injections according to the active charset @@ -153,7 +167,9 @@ public function convertBoundParams(string $sql, array $params = array()): array * @param string $str * @return string */ - public function escapeString(string $str): string {} + public function escapeString(string $str): string + { + } /** * Sends SQL statements to the database server returning the success state. @@ -180,7 +196,9 @@ public function escapeString(string $str): string {} * @param mixed $bindTypes * @return bool */ - public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool {} + public function execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool + { + } /** * Executes a prepared statement binding. This function uses integer indexes @@ -209,26 +227,34 @@ public function execute(string $sqlStatement, $bindParams = null, $bindTypes = n * @param mixed $dataTypes * @return \PDOStatement */ - public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement {} + public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement + { + } /** * Return the error info, if any */ - public function getErrorInfo() {} + public function getErrorInfo() + { + } /** * Return internal PDO handler * * @return \Pdo */ - public function getInternalHandler(): \Pdo {} + public function getInternalHandler(): \Pdo + { + } /** * Returns the current transaction nesting level * * @return int */ - public function getTransactionLevel(): int {} + public function getTransactionLevel(): int + { + } /** * Checks whether the connection is under a transaction @@ -244,7 +270,9 @@ public function getTransactionLevel(): int {} * * @return bool */ - public function isUnderTransaction(): bool {} + public function isUnderTransaction(): bool + { + } /** * Returns the insert id for the auto_increment/serial column inserted in @@ -271,7 +299,9 @@ public function isUnderTransaction(): bool {} * @param mixed $sequenceName * @return int|bool */ - public function lastInsertId($sequenceName = null) {} + public function lastInsertId($sequenceName = null) + { + } /** * Returns a PDO prepared statement to be executed with 'executePrepared' @@ -297,7 +327,9 @@ public function lastInsertId($sequenceName = null) {} * @param string $sqlStatement * @return \PDOStatement */ - public function prepare(string $sqlStatement): \PDOStatement {} + public function prepare(string $sqlStatement): \PDOStatement + { + } /** * Sends SQL statements to the database server returning the success state. @@ -323,7 +355,9 @@ public function prepare(string $sqlStatement): \PDOStatement {} * @param mixed $bindTypes * @return bool|\Phalcon\Db\ResultInterface */ - public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) {} + public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) + { + } /** * Rollbacks the active transaction in the connection @@ -331,7 +365,9 @@ public function query(string $sqlStatement, $bindParams = null, $bindTypes = nul * @param bool $nesting * @return bool */ - public function rollback(bool $nesting = true): bool {} + public function rollback(bool $nesting = true): bool + { + } /** * Returns PDO adapter DSN defaults as a key-value map. @@ -339,5 +375,4 @@ public function rollback(bool $nesting = true): bool {} * @return array */ abstract protected function getDsnDefaults(): array; - } diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index 6885e13d..f7d0d3bf 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -51,7 +51,9 @@ class Mysql extends PdoAdapter * @param \Phalcon\Db\ReferenceInterface $reference * @return bool */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool + { + } /** * Returns an array of Phalcon\Db\Column objects describing a table @@ -66,7 +68,9 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * @param string $schema * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns(string $table, string $schema = null): array {} + public function describeColumns(string $table, string $schema = null): array + { + } /** * Lists table indexes @@ -81,7 +85,9 @@ public function describeColumns(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes(string $table, string $schema = null): array {} + public function describeIndexes(string $table, string $schema = null): array + { + } /** * Lists table references @@ -96,13 +102,16 @@ public function describeIndexes(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences(string $table, string $schema = null): array {} + public function describeReferences(string $table, string $schema = null): array + { + } /** * Returns PDO adapter DSN defaults as a key-value map. * * @return array */ - protected function getDsnDefaults(): array {} - + protected function getDsnDefaults(): array + { + } } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 27938637..051d615e 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -49,7 +49,9 @@ class Postgresql extends PdoAdapter * * @param array $descriptor */ - public function __construct(array $descriptor) {} + public function __construct(array $descriptor) + { + } /** * This method is automatically called in Phalcon\Db\Adapter\Pdo @@ -58,7 +60,9 @@ public function __construct(array $descriptor) {} * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null): bool {} + public function connect(array $descriptor = null): bool + { + } /** * Creates a table @@ -68,7 +72,9 @@ public function connect(array $descriptor = null): bool {} * @param array $definition * @return bool */ - public function createTable(string $tableName, string $schemaName, array $definition): bool {} + public function createTable(string $tableName, string $schemaName, array $definition): bool + { + } /** * Returns an array of Phalcon\Db\Column objects describing a table @@ -83,7 +89,9 @@ public function createTable(string $tableName, string $schemaName, array $defini * @param string $schema * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns(string $table, string $schema = null): array {} + public function describeColumns(string $table, string $schema = null): array + { + } /** * Lists table references @@ -98,7 +106,9 @@ public function describeColumns(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences(string $table, string $schema = null): array {} + public function describeReferences(string $table, string $schema = null): array + { + } /** * Returns the default identity value to be inserted in an identity column @@ -122,7 +132,9 @@ public function describeReferences(string $table, string $schema = null): array * * @return \Phalcon\Db\RawValue */ - public function getDefaultIdValue(): RawValue {} + public function getDefaultIdValue(): RawValue + { + } /** * Modifies a table column based on a definition @@ -133,7 +145,9 @@ public function getDefaultIdValue(): RawValue {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool + { + } /** * Check whether the database system requires a sequence to produce @@ -141,7 +155,9 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * * @return bool */ - public function supportSequences(): bool {} + public function supportSequences(): bool + { + } /** * Check whether the database system requires an explicit value for identity @@ -149,13 +165,16 @@ public function supportSequences(): bool {} * * @return bool */ - public function useExplicitIdValue(): bool {} + public function useExplicitIdValue(): bool + { + } /** * Returns PDO adapter DSN defaults as a key-value map. * * @return array */ - protected function getDsnDefaults(): array {} - + protected function getDsnDefaults(): array + { + } } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index 5d945908..a4df4f55 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -45,7 +45,9 @@ class Sqlite extends PdoAdapter * * @param array $descriptor */ - public function __construct(array $descriptor) {} + public function __construct(array $descriptor) + { + } /** * This method is automatically called in Phalcon\Db\Adapter\Pdo @@ -54,7 +56,9 @@ public function __construct(array $descriptor) {} * @param array $descriptor * @return bool */ - public function connect(array $descriptor = null): bool {} + public function connect(array $descriptor = null): bool + { + } /** * Returns an array of Phalcon\Db\Column objects describing a table @@ -69,7 +73,9 @@ public function connect(array $descriptor = null): bool {} * @param string $schema * @return array|\Phalcon\Db\ColumnInterface[] */ - public function describeColumns(string $table, string $schema = null): array {} + public function describeColumns(string $table, string $schema = null): array + { + } /** * Lists table indexes @@ -84,7 +90,9 @@ public function describeColumns(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\IndexInterface[] */ - public function describeIndexes(string $table, string $schema = null): array {} + public function describeIndexes(string $table, string $schema = null): array + { + } /** * Lists table references @@ -93,7 +101,9 @@ public function describeIndexes(string $table, string $schema = null): array {} * @param string $schema * @return array|\Phalcon\Db\ReferenceInterface[] */ - public function describeReferences(string $table, string $schema = null): array {} + public function describeReferences(string $table, string $schema = null): array + { + } /** * Returns the default value to make the RBDM use the default value declared @@ -116,7 +126,9 @@ public function describeReferences(string $table, string $schema = null): array * * @return \Phalcon\Db\RawValue */ - public function getDefaultValue(): RawValue {} + public function getDefaultValue(): RawValue + { + } /** * Check whether the database system requires an explicit value for identity @@ -124,13 +136,16 @@ public function getDefaultValue(): RawValue {} * * @return bool */ - public function useExplicitIdValue(): bool {} + public function useExplicitIdValue(): bool + { + } /** * Returns PDO adapter DSN defaults as a key-value map. * * @return array */ - protected function getDsnDefaults(): array {} - + protected function getDsnDefaults(): array + { + } } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index f5b9c031..10d7e3c2 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -32,7 +32,9 @@ class Mysql extends Dialect * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + { + } /** * Generates SQL to add an index to a table @@ -42,7 +44,9 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + { + } /** * Generates SQL to add an index to a table @@ -52,7 +56,9 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to add the primary key to a table @@ -62,7 +68,9 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to create a table @@ -72,7 +80,9 @@ public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db * @param array $definition * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function createTable(string $tableName, string $schemaName, array $definition): string + { + } /** * Generates SQL to create a view @@ -82,7 +92,9 @@ public function createTable(string $tableName, string $schemaName, array $defini * @param string $schemaName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} + public function createView(string $viewName, array $definition, string $schemaName = null): string + { + } /** * Generates SQL describing a table @@ -97,7 +109,9 @@ public function createView(string $viewName, array $definition, string $schemaNa * @param string $schema * @return string */ - public function describeColumns(string $table, string $schema = null): string {} + public function describeColumns(string $table, string $schema = null): string + { + } /** * Generates SQL to query indexes on a table @@ -106,7 +120,9 @@ public function describeColumns(string $table, string $schema = null): string {} * @param string $schema * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function describeIndexes(string $table, string $schema = null): string + { + } /** * Generates SQL to query foreign keys on a table @@ -115,7 +131,9 @@ public function describeIndexes(string $table, string $schema = null): string {} * @param string $schema * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function describeReferences(string $table, string $schema = null): string + { + } /** * Generates SQL to delete a column from a table @@ -125,7 +143,9 @@ public function describeReferences(string $table, string $schema = null): string * @param string $columnName * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string + { + } /** * Generates SQL to delete a foreign key from a table @@ -135,7 +155,9 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string + { + } /** * Generates SQL to delete an index from a table @@ -145,7 +167,9 @@ public function dropForeignKey(string $tableName, string $schemaName, string $re * @param string $indexName * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string + { + } /** * Generates SQL to delete primary key from a table @@ -154,7 +178,9 @@ public function dropIndex(string $tableName, string $schemaName, string $indexNa * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function dropPrimaryKey(string $tableName, string $schemaName): string + { + } /** * Generates SQL to drop a table @@ -164,7 +190,9 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Generates SQL to drop a view @@ -174,7 +202,9 @@ public function dropTable(string $tableName, string $schemaName = null, bool $if * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Gets the column name in MySQL @@ -182,14 +212,18 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + { + } /** * Generates SQL to check DB parameter FOREIGN_KEY_CHECKS. * * @return string */ - public function getForeignKeyChecks(): string {} + public function getForeignKeyChecks(): string + { + } /** * List all tables in database @@ -203,7 +237,9 @@ public function getForeignKeyChecks(): string {} * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function listTables(string $schemaName = null): string + { + } /** * Generates the SQL to list all views of a schema or user @@ -211,7 +247,9 @@ public function listTables(string $schemaName = null): string {} * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function listViews(string $schemaName = null): string + { + } /** * Generates SQL to modify a column in a table @@ -222,7 +260,9 @@ public function listViews(string $schemaName = null): string {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + { + } /** * Returns a SQL modified with a LOCK IN SHARE MODE clause @@ -236,7 +276,9 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlQuery * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function sharedLock(string $sqlQuery): string + { + } /** * Generates SQL checking for the existence of a schema.table @@ -251,7 +293,9 @@ public function sharedLock(string $sqlQuery): string {} * @param string $schemaName * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function tableExists(string $tableName, string $schemaName = null): string + { + } /** * Generates the SQL to describe the table creation options @@ -260,7 +304,9 @@ public function tableExists(string $tableName, string $schemaName = null): strin * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function tableOptions(string $table, string $schema = null): string + { + } /** * Generates SQL to truncate a table @@ -269,7 +315,9 @@ public function tableOptions(string $table, string $schema = null): string {} * @param string $schemaName * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function truncateTable(string $tableName, string $schemaName): string + { + } /** * Generates SQL checking for the existence of a schema.view @@ -278,7 +326,9 @@ public function truncateTable(string $tableName, string $schemaName): string {} * @param string $schemaName * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} + public function viewExists(string $viewName, string $schemaName = null): string + { + } /** * Generates SQL to add the table creation options @@ -286,7 +336,9 @@ public function viewExists(string $viewName, string $schemaName = null): string * @param array $definition * @return string */ - protected function getTableOptions(array $definition): string {} + protected function getTableOptions(array $definition): string + { + } /** * Checks if the size and/or scale are present and encloses those values @@ -295,7 +347,9 @@ protected function getTableOptions(array $definition): string {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string {} + private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string + { + } /** * Checks if a column is unsigned or not and returns the relevant SQL syntax @@ -303,6 +357,7 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s * @param \Phalcon\Db\ColumnInterface $column * @return string */ - private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string {} - + private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string + { + } } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 51c4c537..1718e52c 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -32,7 +32,9 @@ class Postgresql extends Dialect * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + { + } /** * Generates SQL to add an index to a table @@ -42,7 +44,9 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + { + } /** * Generates SQL to add an index to a table @@ -52,7 +56,9 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to add the primary key to a table @@ -62,7 +68,9 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to create a table @@ -72,7 +80,9 @@ public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db * @param array $definition * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function createTable(string $tableName, string $schemaName, array $definition): string + { + } /** * Generates SQL to create a view @@ -82,7 +92,9 @@ public function createTable(string $tableName, string $schemaName, array $defini * @param string $schemaName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} + public function createView(string $viewName, array $definition, string $schemaName = null): string + { + } /** * Generates SQL describing a table @@ -97,7 +109,9 @@ public function createView(string $viewName, array $definition, string $schemaNa * @param string $schema * @return string */ - public function describeColumns(string $table, string $schema = null): string {} + public function describeColumns(string $table, string $schema = null): string + { + } /** * Generates SQL to query indexes on a table @@ -106,7 +120,9 @@ public function describeColumns(string $table, string $schema = null): string {} * @param string $schema * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function describeIndexes(string $table, string $schema = null): string + { + } /** * Generates SQL to query foreign keys on a table @@ -115,7 +131,9 @@ public function describeIndexes(string $table, string $schema = null): string {} * @param string $schema * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function describeReferences(string $table, string $schema = null): string + { + } /** * Generates SQL to delete a column from a table @@ -125,7 +143,9 @@ public function describeReferences(string $table, string $schema = null): string * @param string $columnName * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string + { + } /** * Generates SQL to delete a foreign key from a table @@ -135,7 +155,9 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string + { + } /** * Generates SQL to delete an index from a table @@ -145,7 +167,9 @@ public function dropForeignKey(string $tableName, string $schemaName, string $re * @param string $indexName * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string + { + } /** * Generates SQL to delete primary key from a table @@ -154,7 +178,9 @@ public function dropIndex(string $tableName, string $schemaName, string $indexNa * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function dropPrimaryKey(string $tableName, string $schemaName): string + { + } /** * Generates SQL to drop a table @@ -164,7 +190,9 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Generates SQL to drop a view @@ -174,7 +202,9 @@ public function dropTable(string $tableName, string $schemaName = null, bool $if * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Gets the column name in PostgreSQL @@ -182,7 +212,9 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + { + } /** * List all tables in database @@ -196,7 +228,9 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function listTables(string $schemaName = null): string + { + } /** * Generates the SQL to list all views of a schema or user @@ -204,7 +238,9 @@ public function listTables(string $schemaName = null): string {} * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function listViews(string $schemaName = null): string + { + } /** * Generates SQL to modify a column in a table @@ -215,7 +251,9 @@ public function listViews(string $schemaName = null): string {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + { + } /** * Returns a SQL modified a shared lock statement. For now this method @@ -224,7 +262,9 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlQuery * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function sharedLock(string $sqlQuery): string + { + } /** * Generates SQL checking for the existence of a schema.table @@ -239,7 +279,9 @@ public function sharedLock(string $sqlQuery): string {} * @param string $schemaName * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function tableExists(string $tableName, string $schemaName = null): string + { + } /** * Generates the SQL to describe the table creation options @@ -248,7 +290,9 @@ public function tableExists(string $tableName, string $schemaName = null): strin * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function tableOptions(string $table, string $schema = null): string + { + } /** * Generates SQL to truncate a table @@ -257,7 +301,9 @@ public function tableOptions(string $table, string $schema = null): string {} * @param string $schemaName * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function truncateTable(string $tableName, string $schemaName): string + { + } /** * Generates SQL checking for the existence of a schema.view @@ -266,18 +312,23 @@ public function truncateTable(string $tableName, string $schemaName): string {} * @param string $schemaName * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} + public function viewExists(string $viewName, string $schemaName = null): string + { + } /** * @param \Phalcon\Db\ColumnInterface $column * @return string */ - protected function castDefault(\Phalcon\Db\ColumnInterface $column): string {} + protected function castDefault(\Phalcon\Db\ColumnInterface $column): string + { + } /** * @param array $definition * @return string */ - protected function getTableOptions(array $definition): string {} - + protected function getTableOptions(array $definition): string + { + } } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index 09745433..ea2c551a 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -32,7 +32,9 @@ class Sqlite extends Dialect * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string {} + public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + { + } /** * Generates SQL to add an index to a table @@ -42,7 +44,9 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * @param \Phalcon\Db\ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string {} + public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + { + } /** * Generates SQL to add an index to a table @@ -52,7 +56,9 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to add the primary key to a table @@ -62,7 +68,9 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * @param \Phalcon\Db\IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string {} + public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + { + } /** * Generates SQL to create a table @@ -72,7 +80,9 @@ public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db * @param array $definition * @return string */ - public function createTable(string $tableName, string $schemaName, array $definition): string {} + public function createTable(string $tableName, string $schemaName, array $definition): string + { + } /** * Generates SQL to create a view @@ -82,7 +92,9 @@ public function createTable(string $tableName, string $schemaName, array $defini * @param string $schemaName * @return string */ - public function createView(string $viewName, array $definition, string $schemaName = null): string {} + public function createView(string $viewName, array $definition, string $schemaName = null): string + { + } /** * Generates SQL describing a table @@ -97,7 +109,9 @@ public function createView(string $viewName, array $definition, string $schemaNa * @param string $schema * @return string */ - public function describeColumns(string $table, string $schema = null): string {} + public function describeColumns(string $table, string $schema = null): string + { + } /** * Generates SQL to query indexes detail on a table @@ -105,7 +119,9 @@ public function describeColumns(string $table, string $schema = null): string {} * @param string $index * @return string */ - public function describeIndex(string $index): string {} + public function describeIndex(string $index): string + { + } /** * Generates SQL to query indexes on a table @@ -114,7 +130,9 @@ public function describeIndex(string $index): string {} * @param string $schema * @return string */ - public function describeIndexes(string $table, string $schema = null): string {} + public function describeIndexes(string $table, string $schema = null): string + { + } /** * Generates SQL to query foreign keys on a table @@ -123,7 +141,9 @@ public function describeIndexes(string $table, string $schema = null): string {} * @param string $schema * @return string */ - public function describeReferences(string $table, string $schema = null): string {} + public function describeReferences(string $table, string $schema = null): string + { + } /** * Generates SQL to delete a column from a table @@ -133,7 +153,9 @@ public function describeReferences(string $table, string $schema = null): string * @param string $columnName * @return string */ - public function dropColumn(string $tableName, string $schemaName, string $columnName): string {} + public function dropColumn(string $tableName, string $schemaName, string $columnName): string + { + } /** * Generates SQL to delete a foreign key from a table @@ -143,7 +165,9 @@ public function dropColumn(string $tableName, string $schemaName, string $column * @param string $referenceName * @return string */ - public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string {} + public function dropForeignKey(string $tableName, string $schemaName, string $referenceName): string + { + } /** * Generates SQL to delete an index from a table @@ -153,7 +177,9 @@ public function dropForeignKey(string $tableName, string $schemaName, string $re * @param string $indexName * @return string */ - public function dropIndex(string $tableName, string $schemaName, string $indexName): string {} + public function dropIndex(string $tableName, string $schemaName, string $indexName): string + { + } /** * Generates SQL to delete primary key from a table @@ -162,7 +188,9 @@ public function dropIndex(string $tableName, string $schemaName, string $indexNa * @param string $schemaName * @return string */ - public function dropPrimaryKey(string $tableName, string $schemaName): string {} + public function dropPrimaryKey(string $tableName, string $schemaName): string + { + } /** * Generates SQL to drop a table @@ -172,7 +200,9 @@ public function dropPrimaryKey(string $tableName, string $schemaName): string {} * @param bool $ifExists * @return string */ - public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string {} + public function dropTable(string $tableName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Generates SQL to drop a view @@ -182,7 +212,9 @@ public function dropTable(string $tableName, string $schemaName = null, bool $if * @param bool $ifExists * @return string */ - public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string {} + public function dropView(string $viewName, string $schemaName = null, bool $ifExists = true): string + { + } /** * Returns a SQL modified with a FOR UPDATE clause. For SQLite it returns @@ -191,7 +223,9 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx * @param string $sqlQuery * @return string */ - public function forUpdate(string $sqlQuery): string {} + public function forUpdate(string $sqlQuery): string + { + } /** * Gets the column name in SQLite @@ -199,7 +233,9 @@ public function forUpdate(string $sqlQuery): string {} * @param \Phalcon\Db\ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string {} + public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + { + } /** * Generates the SQL to get query list of indexes @@ -215,7 +251,9 @@ public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string * @param string $keyName * @return string */ - public function listIndexesSql(string $table, string $schema = null, string $keyName = null): string {} + public function listIndexesSql(string $table, string $schema = null, string $keyName = null): string + { + } /** * List all tables in database @@ -229,7 +267,9 @@ public function listIndexesSql(string $table, string $schema = null, string $key * @param string $schemaName * @return string */ - public function listTables(string $schemaName = null): string {} + public function listTables(string $schemaName = null): string + { + } /** * Generates the SQL to list all views of a schema or user @@ -237,7 +277,9 @@ public function listTables(string $schemaName = null): string {} * @param string $schemaName * @return string */ - public function listViews(string $schemaName = null): string {} + public function listViews(string $schemaName = null): string + { + } /** * Generates SQL to modify a column in a table @@ -248,7 +290,9 @@ public function listViews(string $schemaName = null): string {} * @param \Phalcon\Db\ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string {} + public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + { + } /** * Returns a SQL modified a shared lock statement. For now this method @@ -257,7 +301,9 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlQuery * @return string */ - public function sharedLock(string $sqlQuery): string {} + public function sharedLock(string $sqlQuery): string + { + } /** * Generates SQL checking for the existence of a schema.table @@ -272,7 +318,9 @@ public function sharedLock(string $sqlQuery): string {} * @param string $schemaName * @return string */ - public function tableExists(string $tableName, string $schemaName = null): string {} + public function tableExists(string $tableName, string $schemaName = null): string + { + } /** * Generates the SQL to describe the table creation options @@ -281,7 +329,9 @@ public function tableExists(string $tableName, string $schemaName = null): strin * @param string $schema * @return string */ - public function tableOptions(string $table, string $schema = null): string {} + public function tableOptions(string $table, string $schema = null): string + { + } /** * Generates SQL to truncate a table @@ -290,7 +340,9 @@ public function tableOptions(string $table, string $schema = null): string {} * @param string $schemaName * @return string */ - public function truncateTable(string $tableName, string $schemaName): string {} + public function truncateTable(string $tableName, string $schemaName): string + { + } /** * Generates SQL checking for the existence of a schema.view @@ -299,6 +351,7 @@ public function truncateTable(string $tableName, string $schemaName): string {} * @param string $schemaName * @return string */ - public function viewExists(string $viewName, string $schemaName = null): string {} - + public function viewExists(string $viewName, string $schemaName = null): string + { + } } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 8896d85f..8e862127 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -57,76 +57,97 @@ class Item * * @param double $finalTime */ - public function setFinalTime(float $finalTime) {} + public function setFinalTime(float $finalTime) + { + } /** * Timestamp when the profile ended * * @return double */ - public function getFinalTime(): float {} + public function getFinalTime(): float + { + } /** * Timestamp when the profile started * * @param double $initialTime */ - public function setInitialTime(float $initialTime) {} + public function setInitialTime(float $initialTime) + { + } /** * Timestamp when the profile started * * @return double */ - public function getInitialTime(): float {} + public function getInitialTime(): float + { + } /** * SQL bind types related to the profile * * @param array $sqlBindTypes */ - public function setSqlBindTypes(array $sqlBindTypes) {} + public function setSqlBindTypes(array $sqlBindTypes) + { + } /** * SQL bind types related to the profile * * @return array */ - public function getSqlBindTypes(): array {} + public function getSqlBindTypes(): array + { + } /** * SQL statement related to the profile * * @param string $sqlStatement */ - public function setSqlStatement(string $sqlStatement) {} + public function setSqlStatement(string $sqlStatement) + { + } /** * SQL statement related to the profile * * @return string */ - public function getSqlStatement(): string {} + public function getSqlStatement(): string + { + } /** * SQL variables related to the profile * * @param array $sqlVariables */ - public function setSqlVariables(array $sqlVariables) {} + public function setSqlVariables(array $sqlVariables) + { + } /** * SQL variables related to the profile * * @return array */ - public function getSqlVariables(): array {} + public function getSqlVariables(): array + { + } /** * Returns the total time in seconds spent by the profile * * @return double */ - public function getTotalElapsedSeconds(): float {} - + public function getTotalElapsedSeconds(): float + { + } } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 12293b77..a5ffa8f8 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -71,7 +71,9 @@ class Pdo implements ResultInterface * @param mixed $bindParams * @param mixed $bindTypes */ - public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) {} + public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) + { + } /** * Moves internal resultset cursor to another position letting us to fetch a @@ -91,7 +93,9 @@ public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \P * * @param long $number */ - public function dataSeek(int $number) {} + public function dataSeek(int $number) + { + } /** * Allows to execute the statement again. Some database systems don't @@ -100,7 +104,9 @@ public function dataSeek(int $number) {} * * @return bool */ - public function execute(): bool {} + public function execute(): bool + { + } /** * Fetches an array/object of strings that corresponds to the fetched row, @@ -123,7 +129,9 @@ public function execute(): bool {} * @param mixed $cursorOrientation * @param mixed $cursorOffset */ - public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) {} + public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) + { + } /** * Returns an array of arrays containing all the records in the result @@ -143,7 +151,9 @@ public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffs * @param mixed $ctorArgs * @return array */ - public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null): array {} + public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = null): array + { + } /** * Returns an array of strings that corresponds to the fetched row, or FALSE @@ -162,14 +172,18 @@ public function fetchAll($fetchStyle = null, $fetchArgument = null, $ctorArgs = * } * ``` */ - public function fetchArray() {} + public function fetchArray() + { + } /** * Gets the internal PDO result object * * @return \PDOStatement */ - public function getInternalResult(): \PDOStatement {} + public function getInternalResult(): \PDOStatement + { + } /** * Gets number of rows returned by a resultset @@ -184,7 +198,9 @@ public function getInternalResult(): \PDOStatement {} * * @return int */ - public function numRows(): int {} + public function numRows(): int + { + } /** * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() @@ -216,6 +232,7 @@ public function numRows(): int {} * @param mixed $ctorargs * @return bool */ - public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool {} - + public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool + { + } } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index 2f08b6f8..0819fde4 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -49,12 +49,16 @@ class Dump /** * @return bool */ - public function getDetailed(): bool {} + public function getDetailed(): bool + { + } /** * @param bool $detailed */ - public function setDetailed(bool $detailed) {} + public function setDetailed(bool $detailed) + { + } /** * Phalcon\Debug\Dump constructor @@ -62,14 +66,18 @@ public function setDetailed(bool $detailed) {} * @param array $styles * @param bool $detailed */ - public function __construct(array $styles = array(), bool $detailed = false) {} + public function __construct(array $styles = array(), bool $detailed = false) + { + } /** * Alias of variables() method * * @return string */ - public function all(): string {} + public function all(): string + { + } /** * Alias of variable() method @@ -78,7 +86,9 @@ public function all(): string {} * @param string $name * @return string */ - public function one($variable, string $name = null): string {} + public function one($variable, string $name = null): string + { + } /** * Set styles for vars type @@ -86,7 +96,9 @@ public function one($variable, string $name = null): string {} * @param array $styles * @return array */ - public function setStyles(array $styles = array()): array {} + public function setStyles(array $styles = array()): array + { + } /** * Returns an JSON string of information about a single variable. @@ -107,7 +119,9 @@ public function setStyles(array $styles = array()): array {} * @param mixed $variable * @return string */ - public function toJson($variable): string {} + public function toJson($variable): string + { + } /** * Returns an HTML string of information about a single variable. @@ -120,7 +134,9 @@ public function toJson($variable): string {} * @param string $name * @return string */ - public function variable($variable, string $name = null): string {} + public function variable($variable, string $name = null): string + { + } /** * Returns an HTML string of debugging information about any number of @@ -136,7 +152,9 @@ public function variable($variable, string $name = null): string {} * * @return string */ - public function variables(): string {} + public function variables(): string + { + } /** * Get style for type @@ -144,7 +162,9 @@ public function variables(): string {} * @param string $type * @return string */ - protected function getStyle(string $type): string {} + protected function getStyle(string $type): string + { + } /** * Prepare an HTML string of information about a single variable. @@ -154,6 +174,7 @@ protected function getStyle(string $type): string {} * @param int $tab * @return string */ - protected function output($variable, string $name = null, int $tab = 1): string {} - + protected function output($variable, string $name = null, int $tab = 1): string + { + } } diff --git a/src/Phalcon/di/AbstractInjectionAware.php b/src/Phalcon/di/AbstractInjectionAware.php index cae41139..266c0132 100644 --- a/src/Phalcon/di/AbstractInjectionAware.php +++ b/src/Phalcon/di/AbstractInjectionAware.php @@ -29,13 +29,16 @@ abstract class AbstractInjectionAware implements InjectionAwareInterface * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - + public function setDI(\Phalcon\Di\DiInterface $container) + { + } } diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/di/DiInterface.php index 13ee2276..9a300e26 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -134,5 +134,4 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition * @return \Phalcon\Di\ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; - } diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index 89294dbc..ead1f2af 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -23,6 +23,7 @@ class FactoryDefault extends \Phalcon\Di /** * Phalcon\Di\FactoryDefault constructor */ - public function __construct() {} - + public function __construct() + { + } } diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index 605b6ede..d5096ea2 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -67,34 +67,43 @@ abstract class Injectable implements InjectionAwareInterface, EventsAwareInterfa * @param string $propertyName * @return mixed|null */ - public function __get(string $propertyName) {} + public function __get(string $propertyName) + { + } /** * Returns the internal dependency injector * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Returns the internal event manager * * @return null|\Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ?ManagerInterface {} + public function getEventsManager(): ?ManagerInterface + { + } /** * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Sets the event manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} - + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } } diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index b725cd4c..3b583389 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -31,5 +31,4 @@ public function setDI(\Phalcon\Di\DiInterface $container); * @return \Phalcon\Di\DiInterface */ public function getDI(): DiInterface; - } diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index 22e1dc08..83dc349b 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -50,14 +50,18 @@ class Service implements ServiceInterface * @param mixed $definition * @param bool $shared */ - final public function __construct($definition, bool $shared = false) {} + final public function __construct($definition, bool $shared = false) + { + } /** * Returns the service definition * * @return mixed */ - public function getDefinition() {} + public function getDefinition() + { + } /** * Returns a parameter in a specific position @@ -65,21 +69,27 @@ public function getDefinition() {} * @param int $position * @return array */ - public function getParameter(int $position) {} + public function getParameter(int $position) + { + } /** * Returns true if the service was resolved * * @return bool */ - public function isResolved(): bool {} + public function isResolved(): bool + { + } /** * Check whether the service is shared or not * * @return bool */ - public function isShared(): bool {} + public function isShared(): bool + { + } /** * Resolves the service @@ -88,14 +98,18 @@ public function isShared(): bool {} * @param \Phalcon\Di\DiInterface $container * @return mixed */ - public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) {} + public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) + { + } /** * Set the service definition * * @param mixed $definition */ - public function setDefinition($definition) {} + public function setDefinition($definition) + { + } /** * Changes a parameter in the definition without resolve the service @@ -104,20 +118,25 @@ public function setDefinition($definition) {} * @param array $parameter * @return \Phalcon\Di\ServiceInterface */ - public function setParameter(int $position, array $parameter): ServiceInterface {} + public function setParameter(int $position, array $parameter): ServiceInterface + { + } /** * Sets if the service is shared or not * * @param bool $shared */ - public function setShared(bool $shared) {} + public function setShared(bool $shared) + { + } /** * Sets/Resets the shared instance related to the service * * @param mixed $sharedInstance */ - public function setSharedInstance($sharedInstance) {} - + public function setSharedInstance($sharedInstance) + { + } } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index 65d6d72c..a2cbf919 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -77,5 +77,4 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); - } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index c7c11fa7..327b378d 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -44,5 +44,4 @@ interface ServiceProviderInterface * @param \Phalcon\Di\DiInterface $di */ public function register(\Phalcon\Di\DiInterface $di); - } diff --git a/src/Phalcon/di/factorydefault/Cli.php b/src/Phalcon/di/factorydefault/Cli.php index f7236d1b..4aae109b 100644 --- a/src/Phalcon/di/factorydefault/Cli.php +++ b/src/Phalcon/di/factorydefault/Cli.php @@ -27,6 +27,7 @@ class Cli extends FactoryDefault /** * Phalcon\Di\FactoryDefault\Cli constructor */ - public function __construct() {} - + public function __construct() + { + } } diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/di/service/Builder.php index ed0ee461..12de4bcc 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/di/service/Builder.php @@ -27,7 +27,9 @@ class Builder * @param array $parameters * @return mixed */ - public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) {} + public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) + { + } /** * Resolves a constructor/call parameter @@ -37,7 +39,9 @@ public function build(\Phalcon\Di\DiInterface $container, array $definition, $pa * @param array $argument * @return mixed */ - private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) {} + private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) + { + } /** * Resolves an array of parameters @@ -46,6 +50,7 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio * @param array $arguments * @return array */ - private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array {} - + private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array + { + } } diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/dispatcher/AbstractDispatcher.php index 7af8efcd..ece649f6 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/dispatcher/AbstractDispatcher.php @@ -126,7 +126,9 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements Disp * @param string $actionMethod * @param array $params */ - public function callActionMethod($handler, string $actionMethod, array $params = array()) {} + public function callActionMethod($handler, string $actionMethod, array $params = array()) + { + } /** * Process the results of the router by calling into the appropriate @@ -139,7 +141,9 @@ public function callActionMethod($handler, string $actionMethod, array $params = * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. * @return object|bool */ - public function dispatch(): bool {} + public function dispatch(): bool + { + } /** * Forwards the execution flow to another controller/action. @@ -156,28 +160,36 @@ public function dispatch(): bool {} * @throws \Phalcon\Exception * @param array $forward */ - public function forward(array $forward) {} + public function forward(array $forward) + { + } /** * Gets the latest dispatched action name * * @return string */ - public function getActionName(): string {} + public function getActionName(): string + { + } /** * Gets the default action suffix * * @return string */ - public function getActionSuffix(): string {} + public function getActionSuffix(): string + { + } /** * Returns the current method to be/executed in the dispatcher * * @return string */ - public function getActiveMethod(): string {} + public function getActiveMethod(): string + { + } /** * Returns bound models from binder instance @@ -195,49 +207,63 @@ public function getActiveMethod(): string {} * * @return array */ - public function getBoundModels(): array {} + public function getBoundModels(): array + { + } /** * Returns the default namespace * * @return string */ - public function getDefaultNamespace(): string {} + public function getDefaultNamespace(): string + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Gets the default handler suffix * * @return string */ - public function getHandlerSuffix(): string {} + public function getHandlerSuffix(): string + { + } /** * Gets model binder * * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getModelBinder(): ?BinderInterface {} + public function getModelBinder(): ?BinderInterface + { + } /** * Gets the module where the controller class is * * @return string */ - public function getModuleName(): string {} + public function getModuleName(): string + { + } /** * Gets a namespace to be prepended to the current handler name * * @return string */ - public function getNamespaceName(): string {} + public function getNamespaceName(): string + { + } /** * Gets a param by its name or numeric index @@ -247,14 +273,18 @@ public function getNamespaceName(): string {} * @param mixed $defaultValue * @return mixed */ - public function getParam($param, $filters = null, $defaultValue = null) {} + public function getParam($param, $filters = null, $defaultValue = null) + { + } /** * Gets action params * * @return array */ - public function getParams(): array {} + public function getParams(): array + { + } /** * Check if a param exists @@ -262,7 +292,9 @@ public function getParams(): array {} * @param mixed $param * @return bool */ - public function hasParam($param): bool {} + public function hasParam($param): bool + { + } /** * Checks if the dispatch loop is finished or has more pendent @@ -270,35 +302,45 @@ public function hasParam($param): bool {} * * @return bool */ - public function isFinished(): bool {} + public function isFinished(): bool + { + } /** * Sets the action name to be dispatched * * @param string $actionName */ - public function setActionName(string $actionName) {} + public function setActionName(string $actionName) + { + } /** * Sets the default action name * * @param string $actionName */ - public function setDefaultAction(string $actionName) {} + public function setDefaultAction(string $actionName) + { + } /** * Sets the default namespace * * @param string $namespaceName */ - public function setDefaultNamespace(string $namespaceName) {} + public function setDefaultNamespace(string $namespaceName) + { + } /** * Possible class name that will be located to dispatch the request * * @return string */ - public function getHandlerClass(): string {} + public function getHandlerClass(): string + { + } /** * Set a param by its name or numeric index @@ -306,42 +348,54 @@ public function getHandlerClass(): string {} * @param mixed $param * @param mixed $value */ - public function setParam($param, $value) {} + public function setParam($param, $value) + { + } /** * Sets action params to be dispatched * * @param array $params */ - public function setParams(array $params) {} + public function setParams(array $params) + { + } /** * Sets the latest returned value by an action manually * * @param mixed $value */ - public function setReturnedValue($value) {} + public function setReturnedValue($value) + { + } /** * Sets the default action suffix * * @param string $actionSuffix */ - public function setActionSuffix(string $actionSuffix) {} + public function setActionSuffix(string $actionSuffix) + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets the default suffix for the handler * * @param string $handlerSuffix */ - public function setHandlerSuffix(string $handlerSuffix) {} + public function setHandlerSuffix(string $handlerSuffix) + { + } /** * Enable model binding during dispatch @@ -366,45 +420,58 @@ public function setHandlerSuffix(string $handlerSuffix) {} * @param mixed $cache * @return Dispatcher */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher + { + } /** * Sets the module where the controller is (only informative) * * @param string $moduleName */ - public function setModuleName(string $moduleName) {} + public function setModuleName(string $moduleName) + { + } /** * Sets the namespace where the controller class is * * @param string $namespaceName */ - public function setNamespaceName(string $namespaceName) {} + public function setNamespaceName(string $namespaceName) + { + } /** * Returns value returned by the latest dispatched action * * @return mixed */ - public function getReturnedValue() {} + public function getReturnedValue() + { + } /** * Check if the current executed action was forwarded by another one * * @return bool */ - public function wasForwarded(): bool {} + public function wasForwarded(): bool + { + } /** * Set empty properties to their defaults (where defaults are available) */ - protected function resolveEmptyProperties() {} + protected function resolveEmptyProperties() + { + } /** * @param string $input * @return string */ - protected function toCamelCase(string $input): string {} - + protected function toCamelCase(string $input): string + { + } } diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php index 1f8120e8..8c68bb73 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -154,5 +154,4 @@ public function setParam($param, $value); * @param array $params */ public function setParams(array $params); - } diff --git a/src/Phalcon/dispatcher/Exception.php b/src/Phalcon/dispatcher/Exception.php index c9d40819..7cd18a37 100644 --- a/src/Phalcon/dispatcher/Exception.php +++ b/src/Phalcon/dispatcher/Exception.php @@ -33,6 +33,4 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; - - } diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/domain/payload/Payload.php index 10c8fb0d..c9902a52 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/domain/payload/Payload.php @@ -65,35 +65,45 @@ class Payload implements PayloadInterface * * @return mixed */ - public function getExtras() {} + public function getExtras() + { + } /** * Input * * @return mixed */ - public function getInput() {} + public function getInput() + { + } /** * Messages * * @return mixed */ - public function getMessages() {} + public function getMessages() + { + } /** * Status * * @return mixed */ - public function getStatus() {} + public function getStatus() + { + } /** * Output * * @return mixed */ - public function getOutput() {} + public function getOutput() + { + } /** * Sets arbitrary extra domain information. @@ -101,7 +111,9 @@ public function getOutput() {} * @param mixed $extras * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function setExtras($extras): PayloadInterface {} + public function setExtras($extras): PayloadInterface + { + } /** * Sets the domain input. @@ -109,7 +121,9 @@ public function setExtras($extras): PayloadInterface {} * @param mixed $input * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function setInput($input): PayloadInterface {} + public function setInput($input): PayloadInterface + { + } /** * Sets the domain messages. @@ -117,7 +131,9 @@ public function setInput($input): PayloadInterface {} * @param mixed $messages * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function setMessages($messages): PayloadInterface {} + public function setMessages($messages): PayloadInterface + { + } /** * Sets the domain output. @@ -125,7 +141,9 @@ public function setMessages($messages): PayloadInterface {} * @param mixed $output * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function setOutput($output): PayloadInterface {} + public function setOutput($output): PayloadInterface + { + } /** * Sets the payload status. @@ -133,6 +151,7 @@ public function setOutput($output): PayloadInterface {} * @param mixed $status * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function setStatus($status): PayloadInterface {} - + public function setStatus($status): PayloadInterface + { + } } diff --git a/src/Phalcon/domain/payload/PayloadFactory.php b/src/Phalcon/domain/payload/PayloadFactory.php index 5d82c8c6..89007b37 100644 --- a/src/Phalcon/domain/payload/PayloadFactory.php +++ b/src/Phalcon/domain/payload/PayloadFactory.php @@ -30,6 +30,7 @@ class PayloadFactory * * @return \Phalcon\Domain\Payload\PayloadInterface */ - public function newInstance(): PayloadInterface {} - + public function newInstance(): PayloadInterface + { + } } diff --git a/src/Phalcon/domain/payload/ReadableInterface.php b/src/Phalcon/domain/payload/ReadableInterface.php index ab5a937f..3eff75c8 100644 --- a/src/Phalcon/domain/payload/ReadableInterface.php +++ b/src/Phalcon/domain/payload/ReadableInterface.php @@ -60,5 +60,4 @@ public function getMessages(); * @return mixed */ public function getExtras(); - } diff --git a/src/Phalcon/domain/payload/Status.php b/src/Phalcon/domain/payload/Status.php index 1c62308c..56833c73 100644 --- a/src/Phalcon/domain/payload/Status.php +++ b/src/Phalcon/domain/payload/Status.php @@ -88,6 +88,7 @@ class Status /** * Instantiation not allowed. */ - final private function __construct() {} - + final private function __construct() + { + } } diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/domain/payload/WriteableInterface.php index aeead6c8..9bcd8261 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/domain/payload/WriteableInterface.php @@ -67,5 +67,4 @@ public function setMessages($messages): PayloadInterface; * @return \Phalcon\Domain\Payload\PayloadInterface */ public function setExtras($extras): PayloadInterface; - } diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/escaper/EscaperInterface.php index ade69a45..e419b340 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/escaper/EscaperInterface.php @@ -79,5 +79,4 @@ public function setEncoding(string $encoding); * @param int $quoteType */ public function setHtmlQuoteType(int $quoteType); - } diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/events/Event.php index 3f5411e3..4b399641 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/events/Event.php @@ -60,21 +60,27 @@ class Event implements EventInterface * * @return mixed */ - public function getData() {} + public function getData() + { + } /** * Event source * * @return object */ - public function getSource() {} + public function getSource() + { + } /** * Event type * * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Phalcon\Events\Event constructor @@ -84,7 +90,9 @@ public function getType(): string {} * @param mixed $data * @param bool $cancelable */ - public function __construct(string $type, $source, $data = null, bool $cancelable = true) {} + public function __construct(string $type, $source, $data = null, bool $cancelable = true) + { + } /** * Check whether the event is cancelable. @@ -97,14 +105,18 @@ public function __construct(string $type, $source, $data = null, bool $cancelabl * * @return bool */ - public function isCancelable(): bool {} + public function isCancelable(): bool + { + } /** * Check whether the event is currently stopped. * * @return bool */ - public function isStopped(): bool {} + public function isStopped(): bool + { + } /** * Sets event data. @@ -112,7 +124,9 @@ public function isStopped(): bool {} * @param mixed $data * @return EventInterface */ - public function setData($data = null): EventInterface {} + public function setData($data = null): EventInterface + { + } /** * Sets event type. @@ -120,7 +134,9 @@ public function setData($data = null): EventInterface {} * @param string $type * @return EventInterface */ - public function setType(string $type): EventInterface {} + public function setType(string $type): EventInterface + { + } /** * Stops the event preventing propagation. @@ -133,6 +149,7 @@ public function setType(string $type): EventInterface {} * * @return EventInterface */ - public function stop(): EventInterface {} - + public function stop(): EventInterface + { + } } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index 99248fb4..66523896 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -69,5 +69,4 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; - } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index 1239dded..444133c1 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -33,5 +33,4 @@ public function getEventsManager(): ?ManagerInterface; * @param ManagerInterface $eventsManager */ public function setEventsManager(ManagerInterface $eventsManager); - } diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index fbab28bd..64d63c93 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -48,14 +48,18 @@ class Manager implements ManagerInterface * @param object|callable $handler * @param int $priority */ - public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) {} + public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) + { + } /** * Returns if priorities are enabled * * @return bool */ - public function arePrioritiesEnabled(): bool {} + public function arePrioritiesEnabled(): bool + { + } /** * Tells the event manager if it needs to collect all the responses returned @@ -63,7 +67,9 @@ public function arePrioritiesEnabled(): bool {} * * @param bool $collect */ - public function collectResponses(bool $collect) {} + public function collectResponses(bool $collect) + { + } /** * Detach the listener from the events manager @@ -71,21 +77,27 @@ public function collectResponses(bool $collect) {} * @param string $eventType * @param object $handler */ - public function detach(string $eventType, $handler) {} + public function detach(string $eventType, $handler) + { + } /** * Removes all events from the EventsManager * * @param string $type */ - public function detachAll(string $type = null) {} + public function detachAll(string $type = null) + { + } /** * Set if priorities are enabled in the EventsManager * * @param bool $enablePriorities */ - public function enablePriorities(bool $enablePriorities) {} + public function enablePriorities(bool $enablePriorities) + { + } /** * Fires an event in the events manager causing the active listeners to be @@ -101,7 +113,9 @@ public function enablePriorities(bool $enablePriorities) {} * @param bool $cancelable * @return mixed */ - public function fire(string $eventType, $source, $data = null, bool $cancelable = true) {} + public function fire(string $eventType, $source, $data = null, bool $cancelable = true) + { + } /** * Internal handler to call a queue of events @@ -110,7 +124,9 @@ public function fire(string $eventType, $source, $data = null, bool $cancelable * @param EventInterface $event * @return mixed */ - final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) {} + final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) + { + } /** * Returns all the attached listeners of a certain type @@ -118,7 +134,9 @@ final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) * @param string $type * @return array */ - public function getListeners(string $type): array {} + public function getListeners(string $type): array + { + } /** * Returns all the responses returned by every handler executed by the last @@ -126,7 +144,9 @@ public function getListeners(string $type): array {} * * @return array */ - public function getResponses(): array {} + public function getResponses(): array + { + } /** * Check whether certain type of event has listeners @@ -134,7 +154,9 @@ public function getResponses(): array {} * @param string $type * @return bool */ - public function hasListeners(string $type): bool {} + public function hasListeners(string $type): bool + { + } /** * Check if the events manager is collecting all all the responses returned @@ -142,6 +164,7 @@ public function hasListeners(string $type): bool {} * * @return bool */ - public function isCollecting(): bool {} - + public function isCollecting(): bool + { + } } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 48a21590..5d934c90 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -71,5 +71,4 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; - } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php index 235e2863..fdd06cf1 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/factory/AbstractFactory.php @@ -29,7 +29,9 @@ abstract class AbstractFactory * * @param string $name */ - protected function checkService(string $name) {} + protected function checkService(string $name) + { + } /** * Checks the config if it is a valid object @@ -37,7 +39,9 @@ protected function checkService(string $name) {} * @param mixed $config * @return array */ - protected function checkConfig($config): array {} + protected function checkConfig($config): array + { + } /** * Returns the adapters for the factory @@ -51,6 +55,7 @@ abstract protected function getAdapters(): array; * * @param array $services */ - protected function init(array $services = array()) {} - + protected function init(array $services = array()) + { + } } diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/filter/FilterFactory.php index 88fdebf7..e82768ad 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/filter/FilterFactory.php @@ -20,11 +20,14 @@ class FilterFactory * * @return LocatorInterface */ - public function newInstance(): LocatorInterface {} + public function newInstance(): LocatorInterface + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php index 110ab1dd..e7334ea0 100644 --- a/src/Phalcon/filter/FilterInterface.php +++ b/src/Phalcon/filter/FilterInterface.php @@ -26,5 +26,4 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); - } diff --git a/src/Phalcon/filter/sanitize/AbsInt.php b/src/Phalcon/filter/sanitize/AbsInt.php index fc2a2991..e0c32714 100644 --- a/src/Phalcon/filter/sanitize/AbsInt.php +++ b/src/Phalcon/filter/sanitize/AbsInt.php @@ -22,6 +22,7 @@ class AbsInt /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Alnum.php b/src/Phalcon/filter/sanitize/Alnum.php index 16f8333d..e1298737 100644 --- a/src/Phalcon/filter/sanitize/Alnum.php +++ b/src/Phalcon/filter/sanitize/Alnum.php @@ -22,6 +22,7 @@ class Alnum /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Alpha.php b/src/Phalcon/filter/sanitize/Alpha.php index be47c5fb..c8f19dfe 100644 --- a/src/Phalcon/filter/sanitize/Alpha.php +++ b/src/Phalcon/filter/sanitize/Alpha.php @@ -22,6 +22,7 @@ class Alpha /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/BoolVal.php b/src/Phalcon/filter/sanitize/BoolVal.php index dcc54015..d3f1d980 100644 --- a/src/Phalcon/filter/sanitize/BoolVal.php +++ b/src/Phalcon/filter/sanitize/BoolVal.php @@ -22,6 +22,7 @@ class BoolVal /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Email.php b/src/Phalcon/filter/sanitize/Email.php index bb18efa6..76c61da1 100644 --- a/src/Phalcon/filter/sanitize/Email.php +++ b/src/Phalcon/filter/sanitize/Email.php @@ -22,6 +22,7 @@ class Email /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/FloatVal.php b/src/Phalcon/filter/sanitize/FloatVal.php index d460f61c..f989740b 100644 --- a/src/Phalcon/filter/sanitize/FloatVal.php +++ b/src/Phalcon/filter/sanitize/FloatVal.php @@ -22,6 +22,7 @@ class FloatVal /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/IntVal.php b/src/Phalcon/filter/sanitize/IntVal.php index 3dd492c1..72662990 100644 --- a/src/Phalcon/filter/sanitize/IntVal.php +++ b/src/Phalcon/filter/sanitize/IntVal.php @@ -22,6 +22,7 @@ class IntVal /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Lower.php b/src/Phalcon/filter/sanitize/Lower.php index ed4465fe..5d6b5889 100644 --- a/src/Phalcon/filter/sanitize/Lower.php +++ b/src/Phalcon/filter/sanitize/Lower.php @@ -22,6 +22,7 @@ class Lower /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/LowerFirst.php b/src/Phalcon/filter/sanitize/LowerFirst.php index d737fa03..c19560cb 100644 --- a/src/Phalcon/filter/sanitize/LowerFirst.php +++ b/src/Phalcon/filter/sanitize/LowerFirst.php @@ -22,6 +22,7 @@ class LowerFirst /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Regex.php b/src/Phalcon/filter/sanitize/Regex.php index 6e27be24..ec1117be 100644 --- a/src/Phalcon/filter/sanitize/Regex.php +++ b/src/Phalcon/filter/sanitize/Regex.php @@ -24,6 +24,7 @@ class Regex * @param mixed $pattern * @param mixed $replace */ - public function __invoke($input, $pattern, $replace) {} - + public function __invoke($input, $pattern, $replace) + { + } } diff --git a/src/Phalcon/filter/sanitize/Remove.php b/src/Phalcon/filter/sanitize/Remove.php index 31101d44..8d9b24e7 100644 --- a/src/Phalcon/filter/sanitize/Remove.php +++ b/src/Phalcon/filter/sanitize/Remove.php @@ -23,6 +23,7 @@ class Remove * @param mixed $input * @param mixed $replace */ - public function __invoke($input, $replace) {} - + public function __invoke($input, $replace) + { + } } diff --git a/src/Phalcon/filter/sanitize/Replace.php b/src/Phalcon/filter/sanitize/Replace.php index c3ff0fd5..60fd7558 100644 --- a/src/Phalcon/filter/sanitize/Replace.php +++ b/src/Phalcon/filter/sanitize/Replace.php @@ -24,6 +24,7 @@ class Replace * @param mixed $from * @param mixed $to */ - public function __invoke($input, $from, $to) {} - + public function __invoke($input, $from, $to) + { + } } diff --git a/src/Phalcon/filter/sanitize/Special.php b/src/Phalcon/filter/sanitize/Special.php index 3f52ea75..66cd7cbd 100644 --- a/src/Phalcon/filter/sanitize/Special.php +++ b/src/Phalcon/filter/sanitize/Special.php @@ -22,6 +22,7 @@ class Special /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/SpecialFull.php b/src/Phalcon/filter/sanitize/SpecialFull.php index 548d9d55..ed8c7695 100644 --- a/src/Phalcon/filter/sanitize/SpecialFull.php +++ b/src/Phalcon/filter/sanitize/SpecialFull.php @@ -22,6 +22,7 @@ class SpecialFull /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/StringVal.php b/src/Phalcon/filter/sanitize/StringVal.php index 7f980c60..57d4601a 100644 --- a/src/Phalcon/filter/sanitize/StringVal.php +++ b/src/Phalcon/filter/sanitize/StringVal.php @@ -22,6 +22,7 @@ class StringVal /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Striptags.php b/src/Phalcon/filter/sanitize/Striptags.php index f5f73bc2..1ac2cff5 100644 --- a/src/Phalcon/filter/sanitize/Striptags.php +++ b/src/Phalcon/filter/sanitize/Striptags.php @@ -22,6 +22,7 @@ class Striptags /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Trim.php b/src/Phalcon/filter/sanitize/Trim.php index 198c17a4..da8e2614 100644 --- a/src/Phalcon/filter/sanitize/Trim.php +++ b/src/Phalcon/filter/sanitize/Trim.php @@ -22,6 +22,7 @@ class Trim /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Upper.php b/src/Phalcon/filter/sanitize/Upper.php index 39ccfbde..506ba986 100644 --- a/src/Phalcon/filter/sanitize/Upper.php +++ b/src/Phalcon/filter/sanitize/Upper.php @@ -22,6 +22,7 @@ class Upper /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/UpperFirst.php b/src/Phalcon/filter/sanitize/UpperFirst.php index d1a8029c..d961bff5 100644 --- a/src/Phalcon/filter/sanitize/UpperFirst.php +++ b/src/Phalcon/filter/sanitize/UpperFirst.php @@ -22,6 +22,7 @@ class UpperFirst /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/UpperWords.php b/src/Phalcon/filter/sanitize/UpperWords.php index 0f047dbc..cdf242bb 100644 --- a/src/Phalcon/filter/sanitize/UpperWords.php +++ b/src/Phalcon/filter/sanitize/UpperWords.php @@ -22,6 +22,7 @@ class UpperWords /** * @param string $input */ - public function __invoke(string $input) {} - + public function __invoke(string $input) + { + } } diff --git a/src/Phalcon/filter/sanitize/Url.php b/src/Phalcon/filter/sanitize/Url.php index e53d2e31..d99006fa 100644 --- a/src/Phalcon/filter/sanitize/Url.php +++ b/src/Phalcon/filter/sanitize/Url.php @@ -22,6 +22,7 @@ class Url /** * @param mixed $input */ - public function __invoke($input) {} - + public function __invoke($input) + { + } } diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/firewall/adapter/AbstractAdapter.php index a87e3c7b..17d6670c 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/firewall/adapter/AbstractAdapter.php @@ -79,40 +79,52 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface /** * Storing active identity object implementing Phalcon/Acl/RoleAware */ - public function getActiveIdentity() {} + public function getActiveIdentity() + { + } /** * Storing active user role */ - public function getActiveRole() {} + public function getActiveRole() + { + } /** * Default access * * @return int */ - public function getDefaultAccess(): int {} + public function getDefaultAccess(): int + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Gets role callback to fetch role name * * @return \Closure */ - public function getRoleCallback(): Closure {} + public function getRoleCallback(): Closure + { + } /** * Gets always resolving role option * * @return bool */ - public function isAlwaysResolvingRole(): bool {} + public function isAlwaysResolvingRole(): bool + { + } /** * Sets the cache adapter @@ -120,7 +132,9 @@ public function isAlwaysResolvingRole(): bool {} * @param \Phalcon\Cache\Adapter\AdapterInterface $cache * @return AdapterInterface */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface {} + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface + { + } /** * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) @@ -128,14 +142,18 @@ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): Adapte * @param int $defaultAccess * @return AdapterInterface */ - public function setDefaultAccess(int $defaultAccess): AdapterInterface {} + public function setDefaultAccess(int $defaultAccess): AdapterInterface + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets role callback to fetch role name @@ -143,19 +161,25 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * @param mixed $callback * @return AdapterInterface */ - public function setRoleCallback($callback): AdapterInterface {} + public function setRoleCallback($callback): AdapterInterface + { + } /** * Sets always resolving role option * * @param bool $alwaysResolvingRole */ - public function setAlwaysResolvingRole(bool $alwaysResolvingRole) {} + public function setAlwaysResolvingRole(bool $alwaysResolvingRole) + { + } /** * @param \Phalcon\Di\DiInterface $container */ - protected function callRoleCallback(\Phalcon\Di\DiInterface $container) {} + protected function callRoleCallback(\Phalcon\Di\DiInterface $container) + { + } /** * Gets access from cache @@ -165,14 +189,18 @@ protected function callRoleCallback(\Phalcon\Di\DiInterface $container) {} * @param string $roleCacheKey * @return bool|null */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool + { + } /** * Handles a user exception * * @param \Exception $exception */ - protected function handleException(\Exception $exception) {} + protected function handleException(\Exception $exception) + { + } /** * Fires event or throwing exception @@ -182,7 +210,9 @@ protected function handleException(\Exception $exception) {} * @param string $controllerName * @param bool $access */ - protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) {} + protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) + { + } /** * Saves access in cache and internal cache @@ -190,7 +220,9 @@ protected function fireEventOrThrowException($role, string $actionName, string $ * @param string $key * @param bool $access */ - protected function saveAccessInCache(string $key, bool $access) {} + protected function saveAccessInCache(string $key, bool $access) + { + } /** * Throws an internal exception @@ -199,6 +231,7 @@ protected function saveAccessInCache(string $key, bool $access) {} * @param int $exceptionCode * @return bool */ - protected function throwFirewallException(string $message, int $exceptionCode = 0): bool {} - + protected function throwFirewallException(string $message, int $exceptionCode = 0): bool + { + } } diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php index a8b60071..4afd92b2 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -69,54 +69,70 @@ class Acl extends AbstractAdapter * * @return string */ - public function getAclServiceName(): string {} + public function getAclServiceName(): string + { + } /** * Acl service name * * @param string $aclServiceName */ - public function setAclServiceName(string $aclServiceName) {} + public function setAclServiceName(string $aclServiceName) + { + } /** * Property used for setting different key names in associated acl function than got from Binder */ - public function getBoundModelsKeyMap() {} + public function getBoundModelsKeyMap() + { + } /** * Property used for setting different key names in associated acl function than got from Binder * * @param mixed $boundModelsKeyMap */ - public function setBoundModelsKeyMap($boundModelsKeyMap) {} + public function setBoundModelsKeyMap($boundModelsKeyMap) + { + } /** * Separator between module name and controller prefix * * @return string */ - public function getModuleSeparator(): string {} + public function getModuleSeparator(): string + { + } /** * Separator between module name and controller prefix * * @param string $moduleSeparator */ - public function setModuleSeparator(string $moduleSeparator) {} + public function setModuleSeparator(string $moduleSeparator) + { + } /** * Function returning string for role cache key * * @return mixed */ - public function getRoleCacheCallback() {} + public function getRoleCacheCallback() + { + } /** * Function returning string for role cache key * * @param mixed $roleCacheCallback */ - public function setRoleCacheCallback($roleCacheCallback) {} + public function setRoleCacheCallback($roleCacheCallback) + { + } /** * Phalcon\Firewall\Adapter\Acl constructor @@ -124,42 +140,54 @@ public function setRoleCacheCallback($roleCacheCallback) {} * @param string $aclServiceName * @param array $boundModelsKeyMap */ - public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) {} + public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) + { + } /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Mvc\DispatcherInterface $dispatcher * @param mixed $data */ - public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) {} + public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) + { + } /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Mvc\DispatcherInterface $dispatcher * @param mixed $data */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) {} + public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) + { + } /** * Gets dispatcher * * @return Dispatcher */ - public function getDispatcher(): Dispatcher {} + public function getDispatcher(): Dispatcher + { + } /** * Returns multiModuleConfiguration * * @return bool */ - public function isMultiModuleConfiguration(): bool {} + public function isMultiModuleConfiguration(): bool + { + } /** * Sets multiModuleConfiguration * * @param bool $multiModuleConfiguration */ - public function useMultiModuleConfiguration(bool $multiModuleConfiguration) {} + public function useMultiModuleConfiguration(bool $multiModuleConfiguration) + { + } /** * @param string $key @@ -167,17 +195,22 @@ public function useMultiModuleConfiguration(bool $multiModuleConfiguration) {} * @param string $roleCacheKey * @return bool|null */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool + { + } /** * @param \Phalcon\Mvc\DispatcherInterface $dispatcher */ - protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher) {} + protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher) + { + } /** * @param string $key * @param bool $access */ - protected function saveAccessInCache(string $key, bool $access) {} - + protected function saveAccessInCache(string $key, bool $access) + { + } } diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/firewall/adapter/AdapterInterface.php index 549aeafd..1e443ab7 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/firewall/adapter/AdapterInterface.php @@ -66,5 +66,4 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface; * @return AdapterInterface */ public function setRoleCallback($callback): AdapterInterface; - } diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/firewall/adapter/Annotations.php index 80232690..a9524489 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/firewall/adapter/Annotations.php @@ -48,48 +48,62 @@ class Annotations extends AbstractAdapter * * @return mixed */ - public function getAnnotationsAdapter() {} + public function getAnnotationsAdapter() + { + } /** * Adapter for annotations * * @param mixed $annotationsAdapter */ - public function setAnnotationsAdapter($annotationsAdapter) {} + public function setAnnotationsAdapter($annotationsAdapter) + { + } /** * Phalcon\Firewall\Adapter\Annotations constructor * * @param \Phalcon\Annotations\Adapter\AdapterInterface $annotationsAdapter */ - public function __construct(\Phalcon\Annotations\Adapter\AdapterInterface $annotationsAdapter) {} + public function __construct(\Phalcon\Annotations\Adapter\AdapterInterface $annotationsAdapter) + { + } /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Mvc\DispatcherInterface $dispatcher * @param mixed $data */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) {} + public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) + { + } /** * Gets dispatcher * * @return Dispatcher */ - public function getDispatcher(): Dispatcher {} + public function getDispatcher(): Dispatcher + { + } /** * @param string $controllerClass * @param string $controllerName * @param mixed $role */ - protected function checkControllerAnnotationAccess(string $controllerClass, string $controllerName, $role) {} + protected function checkControllerAnnotationAccess(string $controllerClass, string $controllerName, $role) + { + } /** * @param mixed $annotations * @param mixed $role */ - protected function checkAnnotations($annotations, $role) {} + protected function checkAnnotations($annotations, $role) + { + } /** * @param string $controllerClass @@ -97,7 +111,9 @@ protected function checkAnnotations($annotations, $role) {} * @param string $actionName * @param mixed $role */ - protected function checkActionAnnotationAccess(string $controllerClass, string $controllerName, string $actionName, $role) {} + protected function checkActionAnnotationAccess(string $controllerClass, string $controllerName, string $actionName, $role) + { + } /** * @param string $key @@ -105,13 +121,16 @@ protected function checkActionAnnotationAccess(string $controllerClass, string $ * @param string $roleCacheKey * @return bool|null */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool + { + } /** * @param mixed $annotation * @param bool $access * @param mixed $role */ - protected function handleAnnotation($annotation, bool $access, $role) {} - + protected function handleAnnotation($annotation, bool $access, $role) + { + } } diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/firewall/adapter/micro/Acl.php index aba97c48..8feffce2 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/firewall/adapter/micro/Acl.php @@ -81,21 +81,27 @@ class Acl extends AbstractAdapter * * @return string */ - public function getAclServiceName(): string {} + public function getAclServiceName(): string + { + } /** * Acl service name * * @param string $aclServiceName */ - public function setAclServiceName(string $aclServiceName) {} + public function setAclServiceName(string $aclServiceName) + { + } /** * Property used for setting different key names in associated ACL function * * than got from Binder */ - public function getBoundModelsKeyMap() {} + public function getBoundModelsKeyMap() + { + } /** * Property used for setting different key names in associated ACL function @@ -104,35 +110,45 @@ public function getBoundModelsKeyMap() {} * * @param mixed $boundModelsKeyMap */ - public function setBoundModelsKeyMap($boundModelsKeyMap) {} + public function setBoundModelsKeyMap($boundModelsKeyMap) + { + } /** * Component name used to acquire access, be default it's Micro * * @return string */ - public function getComponentName(): string {} + public function getComponentName(): string + { + } /** * Component name used to acquire access, be default it's Micro * * @param string $componentName */ - public function setComponentName(string $componentName) {} + public function setComponentName(string $componentName) + { + } /** * Function returning string for role cache key * * @return mixed */ - public function getRoleCacheCallback() {} + public function getRoleCacheCallback() + { + } /** * Function returning string for role cache key * * @param mixed $roleCacheCallback */ - public function setRoleCacheCallback($roleCacheCallback) {} + public function setRoleCacheCallback($roleCacheCallback) + { + } /** * By default using route names which are required, you can change it to @@ -141,41 +157,53 @@ public function setRoleCacheCallback($roleCacheCallback) {} * * @param bool $routeNameConfiguration */ - public function setRouteNameConfiguration(bool $routeNameConfiguration) {} + public function setRouteNameConfiguration(bool $routeNameConfiguration) + { + } /** * @param string $aclServiceName * @param array $boundModelsKeyMap */ - public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) {} + public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) + { + } /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Mvc\Micro $micro * @param mixed $data */ - public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) {} + public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) + { + } /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Mvc\Micro $micro * @param mixed $data */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) {} + public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) + { + } /** * Gets micro * * @return \Phalcon\Mvc\Micro */ - public function getMicro(): Micro {} + public function getMicro(): Micro + { + } /** * Gets route name configuration * * @return bool */ - public function isRouteNameConfiguration(): bool {} + public function isRouteNameConfiguration(): bool + { + } /** * Fires event or throwing exception @@ -185,7 +213,9 @@ public function isRouteNameConfiguration(): bool {} * @param string $controllerName * @param bool $access */ - protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) {} + protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) + { + } /** * @param string $key @@ -193,17 +223,22 @@ protected function fireEventOrThrowException($role, string $actionName, string $ * @param string $roleCacheKey * @return bool|null */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool {} + protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool + { + } /** * @param \Phalcon\Mvc\Micro $micro */ - protected function handleRouter(\Phalcon\Mvc\Micro $micro) {} + protected function handleRouter(\Phalcon\Mvc\Micro $micro) + { + } /** * @param string $key * @param bool $access */ - protected function saveAccessInCache(string $key, bool $access) {} - + protected function saveAccessInCache(string $key, bool $access) + { + } } diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/flash/AbstractFlash.php index 45c41fda..cac5a834 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/flash/AbstractFlash.php @@ -70,17 +70,23 @@ abstract class AbstractFlash extends AbstractInjectionAware implements FlashInte /** * @return bool */ - public function getAutoescape(): bool {} + public function getAutoescape(): bool + { + } /** * @return array */ - public function getCssClasses(): array {} + public function getCssClasses(): array + { + } /** * @return string */ - public function getCustomTemplate(): string {} + public function getCustomTemplate(): string + { + } /** * Phalcon\Flash constructor @@ -88,12 +94,16 @@ public function getCustomTemplate(): string {} * @param \Phalcon\Escaper\EscaperInterface $escaper * @param \Phalcon\Session\ManagerInterface $session */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) {} + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) + { + } /** * Clears accumulated messages when implicit flush is disabled */ - public function clear() {} + public function clear() + { + } /** * Shows a HTML error message @@ -105,14 +115,18 @@ public function clear() {} * @param string $message * @return string */ - public function error(string $message): string {} + public function error(string $message): string + { + } /** * Returns the Escaper Service * * @return \Phalcon\Escaper\EscaperInterface */ - public function getEscaperService(): EscaperInterface {} + public function getEscaperService(): EscaperInterface + { + } /** * Shows a HTML notice/information message @@ -124,7 +138,9 @@ public function getEscaperService(): EscaperInterface {} * @param string $message * @return string */ - public function notice(string $message): string {} + public function notice(string $message): string + { + } /** * Set the autoescape mode in generated html @@ -132,7 +148,9 @@ public function notice(string $message): string {} * @param bool $autoescape * @return FlashInterface */ - public function setAutoescape(bool $autoescape): FlashInterface {} + public function setAutoescape(bool $autoescape): FlashInterface + { + } /** * Set if the output must be implicitly formatted with HTML @@ -140,7 +158,9 @@ public function setAutoescape(bool $autoescape): FlashInterface {} * @param bool $automaticHtml * @return FlashInterface */ - public function setAutomaticHtml(bool $automaticHtml): FlashInterface {} + public function setAutomaticHtml(bool $automaticHtml): FlashInterface + { + } /** * Set an array with CSS classes to format the messages @@ -148,7 +168,9 @@ public function setAutomaticHtml(bool $automaticHtml): FlashInterface {} * @param array $cssClasses * @return FlashInterface */ - public function setCssClasses(array $cssClasses): FlashInterface {} + public function setCssClasses(array $cssClasses): FlashInterface + { + } /** * Set an custom template for showing the messages @@ -156,7 +178,9 @@ public function setCssClasses(array $cssClasses): FlashInterface {} * @param string $customTemplate * @return FlashInterface */ - public function setCustomTemplate(string $customTemplate): FlashInterface {} + public function setCustomTemplate(string $customTemplate): FlashInterface + { + } /** * Sets the Escaper Service @@ -164,7 +188,9 @@ public function setCustomTemplate(string $customTemplate): FlashInterface {} * @param \Phalcon\Escaper\EscaperInterface $escaperService * @return FlashInterface */ - public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface {} + public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface + { + } /** * Set whether the output must be implicitly flushed to the output or @@ -173,7 +199,9 @@ public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperServ * @param bool $implicitFlush * @return FlashInterface */ - public function setImplicitFlush(bool $implicitFlush): FlashInterface {} + public function setImplicitFlush(bool $implicitFlush): FlashInterface + { + } /** * Shows a HTML success message @@ -185,7 +213,9 @@ public function setImplicitFlush(bool $implicitFlush): FlashInterface {} * @param string $message * @return string */ - public function success(string $message): string {} + public function success(string $message): string + { + } /** * Outputs a message formatting it with HTML @@ -198,7 +228,9 @@ public function success(string $message): string {} * @param string|array $message * @return string|void */ - public function outputMessage(string $type, $message) {} + public function outputMessage(string $type, $message) + { + } /** * Shows a HTML warning message @@ -210,13 +242,17 @@ public function outputMessage(string $type, $message) {} * @param string $message * @return string */ - public function warning(string $message): string {} + public function warning(string $message): string + { + } /** * @param string $cssClassses * @return string */ - private function getTemplate(string $cssClassses): string {} + private function getTemplate(string $cssClassses): string + { + } /** * Returns the message escaped if the autoEscape is true, otherwise the @@ -225,7 +261,9 @@ private function getTemplate(string $cssClassses): string {} * @param string $message * @return string */ - private function prepareEscapedMessage(string $message): string {} + private function prepareEscapedMessage(string $message): string + { + } /** * Prepares the HTML output for the message. If automaticHtml is not set @@ -235,6 +273,7 @@ private function prepareEscapedMessage(string $message): string {} * @param string $message * @return string */ - private function prepareHtmlMessage(string $type, string $message): string {} - + private function prepareHtmlMessage(string $type, string $message): string + { + } } diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index 298f5f27..9756e166 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -25,13 +25,16 @@ class Direct extends AbstractFlash * @param mixed $message * @return string|null */ - public function message(string $type, $message): ?string {} + public function message(string $type, $message): ?string + { + } /** * Prints the messages accumulated in the flasher * * @param bool $remove */ - public function output(bool $remove = true) {} - + public function output(bool $remove = true) + { + } } diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php index 35ae67e0..ba35ac75 100644 --- a/src/Phalcon/flash/FlashInterface.php +++ b/src/Phalcon/flash/FlashInterface.php @@ -59,5 +59,4 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; - } diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/flash/Session.php index 2b3027a5..b5670697 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/flash/Session.php @@ -23,7 +23,9 @@ class Session extends AbstractFlash /** * Clear messages in the session messenger */ - public function clear() {} + public function clear() + { + } /** * Returns the messages in the session flasher @@ -32,7 +34,9 @@ public function clear() {} * @param bool $remove * @return array */ - public function getMessages($type = null, bool $remove = true): array {} + public function getMessages($type = null, bool $remove = true): array + { + } /** * Checks whether there are messages @@ -40,7 +44,9 @@ public function getMessages($type = null, bool $remove = true): array {} * @param mixed $type * @return bool */ - public function has($type = null): bool {} + public function has($type = null): bool + { + } /** * Adds a message to the session flasher @@ -49,14 +55,18 @@ public function has($type = null): bool {} * @param string $message * @return string|null */ - public function message(string $type, string $message): ?string {} + public function message(string $type, string $message): ?string + { + } /** * Prints the messages in the session flasher * * @param bool $remove */ - public function output(bool $remove = true) {} + public function output(bool $remove = true) + { + } /** * Returns the messages stored in session @@ -65,7 +75,9 @@ public function output(bool $remove = true) {} * @param mixed $type * @return array */ - protected function getSessionMessages(bool $remove, $type = null): array {} + protected function getSessionMessages(bool $remove, $type = null): array + { + } /** * Stores the messages in session @@ -73,13 +85,16 @@ protected function getSessionMessages(bool $remove, $type = null): array {} * @param array $messages * @return array */ - protected function setSessionMessages(array $messages): array {} + protected function setSessionMessages(array $messages): array + { + } /** * Returns the Session Service * * @return \Phalcon\Session\ManagerInterface */ - public function getSessionService(): SessionInterface {} - + public function getSessionService(): SessionInterface + { + } } diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/forms/Form.php index 101292cc..4d331de0 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/forms/Form.php @@ -55,10 +55,14 @@ class Form extends Injectable implements Countable, Iterator, AttributesInterfac /** * @param mixed $validation */ - public function setValidation($validation) {} + public function setValidation($validation) + { + } - public function getValidation() {} + public function getValidation() + { + } /** * Phalcon\Forms\Form constructor @@ -66,7 +70,9 @@ public function getValidation() {} * @param mixed $entity * @param array $userOptions */ - public function __construct($entity = null, array $userOptions = array()) {} + public function __construct($entity = null, array $userOptions = array()) + { + } /** * Adds an element to the form @@ -76,7 +82,9 @@ public function __construct($entity = null, array $userOptions = array()) {} * @param bool $type * @return Form */ - public function add(\Phalcon\Forms\Element\ElementInterface $element, string $position = null, bool $type = null): Form {} + public function add(\Phalcon\Forms\Element\ElementInterface $element, string $position = null, bool $type = null): Form + { + } /** * Binds data to the entity @@ -86,7 +94,9 @@ public function add(\Phalcon\Forms\Element\ElementInterface $element, string $po * @param array $whitelist * @return Form */ - public function bind(array $data, $entity, $whitelist = null): Form {} + public function bind(array $data, $entity, $whitelist = null): Form + { + } /** * Clears every element in the form to its default value @@ -94,21 +104,27 @@ public function bind(array $data, $entity, $whitelist = null): Form {} * @param array|string|null $fields * @return Form */ - public function clear($fields = null): Form {} + public function clear($fields = null): Form + { + } /** * Returns the number of elements in the form * * @return int */ - public function count(): int {} + public function count(): int + { + } /** * Returns the current element in the iterator * * @return bool|\Phalcon\Forms\Element\ElementInterface */ - public function current() {} + public function current() + { + } /** * Returns an element added to the form by its name @@ -116,28 +132,36 @@ public function current() {} * @param string $name * @return \Phalcon\Forms\Element\ElementInterface */ - public function get(string $name): ElementInterface {} + public function get(string $name): ElementInterface + { + } /** * Returns the form's action * * @return string */ - public function getAction(): string {} + public function getAction(): string + { + } /** * Returns the form elements added to the form * * @return array|\Phalcon\Forms\Element\ElementInterface[] */ - public function getElements(): array {} + public function getElements(): array + { + } /** * Returns the entity related to the model * * @return object */ - public function getEntity() {} + public function getEntity() + { + } /** * Returns a label for an element @@ -145,7 +169,9 @@ public function getEntity() {} * @param string $name * @return string */ - public function getLabel(string $name): string {} + public function getLabel(string $name): string + { + } /** * Returns the messages generated in the validation. @@ -162,7 +188,9 @@ public function getLabel(string $name): string {} * * @return array|\Phalcon\Messages\Messages */ - public function getMessages() {} + public function getMessages() + { + } /** * Returns the messages generated for a specific element @@ -170,7 +198,9 @@ public function getMessages() {} * @param string $name * @return \Phalcon\Messages\Messages */ - public function getMessagesFor(string $name): Messages {} + public function getMessagesFor(string $name): Messages + { + } /** * Returns the value of an option if present @@ -179,14 +209,18 @@ public function getMessagesFor(string $name): Messages {} * @param mixed $defaultValue * @return mixed */ - public function getUserOption(string $option, $defaultValue = null) {} + public function getUserOption(string $option, $defaultValue = null) + { + } /** * Returns the options for the element * * @return array */ - public function getUserOptions(): array {} + public function getUserOptions(): array + { + } /** * Gets a value from the internal related entity or from the default value @@ -194,7 +228,9 @@ public function getUserOptions(): array {} * @param string $name * @return mixed|null */ - public function getValue(string $name) {} + public function getValue(string $name) + { + } /** * Check if the form contains an element @@ -202,7 +238,9 @@ public function getValue(string $name) {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Check if messages were generated for a specific element @@ -210,7 +248,9 @@ public function has(string $name): bool {} * @param string $name * @return bool */ - public function hasMessagesFor(string $name): bool {} + public function hasMessagesFor(string $name): bool + { + } /** * Validates the form @@ -219,14 +259,18 @@ public function hasMessagesFor(string $name): bool {} * @param object $entity * @return bool */ - public function isValid($data = null, $entity = null): bool {} + public function isValid($data = null, $entity = null): bool + { + } /** * Returns the current position/key in the iterator * * @return int */ - public function key(): int {} + public function key(): int + { + } /** * Generate the label of an element added to the form including HTML @@ -235,12 +279,16 @@ public function key(): int {} * @param array $attributes * @return string */ - public function label(string $name, array $attributes = null): string {} + public function label(string $name, array $attributes = null): string + { + } /** * Moves the internal iteration pointer to the next position */ - public function next() {} + public function next() + { + } /** * Renders a specific item in the form @@ -249,7 +297,9 @@ public function next() {} * @param array $attributes * @return string */ - public function render(string $name, array $attributes = array()): string {} + public function render(string $name, array $attributes = array()): string + { + } /** * Removes an element from the form @@ -257,12 +307,16 @@ public function render(string $name, array $attributes = array()): string {} * @param string $name * @return bool */ - public function remove(string $name): bool {} + public function remove(string $name): bool + { + } /** * Rewinds the internal iterator */ - public function rewind() {} + public function rewind() + { + } /** * Sets the form's action @@ -270,7 +324,9 @@ public function rewind() {} * @param string $action * @return Form */ - public function setAction(string $action): Form {} + public function setAction(string $action): Form + { + } /** * Sets the entity related to the model @@ -278,7 +334,9 @@ public function setAction(string $action): Form {} * @param object $entity * @return Form */ - public function setEntity($entity): Form {} + public function setEntity($entity): Form + { + } /** * Sets an option for the form @@ -287,7 +345,9 @@ public function setEntity($entity): Form {} * @param mixed $value * @return Form */ - public function setUserOption(string $option, $value): Form {} + public function setUserOption(string $option, $value): Form + { + } /** * Sets options for the element @@ -295,21 +355,27 @@ public function setUserOption(string $option, $value): Form {} * @param array $options * @return Form */ - public function setUserOptions(array $options): Form {} + public function setUserOptions(array $options): Form + { + } /** * Check if the current element in the iterator is valid * * @return bool */ - public function valid(): bool {} + public function valid(): bool + { + } /** * Get Form attributes collection * * @return \Phalcon\Html\Attributes */ - public function getAttributes(): Attributes {} + public function getAttributes(): Attributes + { + } /** * Set form attributes collection @@ -317,6 +383,7 @@ public function getAttributes(): Attributes {} * @param \Phalcon\Html\Attributes $attributes * @return \Phalcon\Html\Attributes\AttributesInterface */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface {} - + public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface + { + } } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index 91291d20..709b6229 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -27,7 +27,9 @@ class Manager * @param object $entity * @return Form */ - public function create(string $name, $entity = null): Form {} + public function create(string $name, $entity = null): Form + { + } /** * Returns a form by its name @@ -35,7 +37,9 @@ public function create(string $name, $entity = null): Form {} * @param string $name * @return Form */ - public function get(string $name): Form {} + public function get(string $name): Form + { + } /** * Checks if a form is registered in the forms manager @@ -43,7 +47,9 @@ public function get(string $name): Form {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Registers a form in the Forms Manager @@ -52,6 +58,7 @@ public function has(string $name): bool {} * @param Form $form * @return FormManager */ - public function set(string $name, Form $form): FormManager {} - + public function set(string $name, Form $form): FormManager + { + } } diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/forms/element/AbstractElement.php index 5f89f46c..5497766a 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -55,14 +55,18 @@ abstract class AbstractElement implements ElementInterface * @param string $name Attribute name (value of 'name' attribute of HTML element) * @param array $attributes Additional HTML element attributes */ - public function __construct(string $name, array $attributes = array()) {} + public function __construct(string $name, array $attributes = array()) + { + } /** * Magic method __toString renders the widget without attributes * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Adds a filter to current list of filters @@ -70,7 +74,9 @@ public function __toString(): string {} * @param string $filter * @return ElementInterface */ - public function addFilter(string $filter): ElementInterface {} + public function addFilter(string $filter): ElementInterface + { + } /** * Adds a validator to the element @@ -78,7 +84,9 @@ public function addFilter(string $filter): ElementInterface {} * @param \Phalcon\Validation\ValidatorInterface $validator * @return ElementInterface */ - public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface {} + public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface + { + } /** * Adds a group of validators @@ -87,7 +95,9 @@ public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): * @param bool $merge * @return ElementInterface */ - public function addValidators(array $validators, bool $merge = true): ElementInterface {} + public function addValidators(array $validators, bool $merge = true): ElementInterface + { + } /** * Appends a message to the internal message list @@ -95,14 +105,18 @@ public function addValidators(array $validators, bool $merge = true): ElementInt * @param \Phalcon\Messages\MessageInterface $message * @return ElementInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ElementInterface {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ElementInterface + { + } /** * Clears element to its default value * * @return ElementInterface */ - public function clear(): ElementInterface {} + public function clear(): ElementInterface + { + } /** * Returns the value of an attribute if present @@ -111,42 +125,54 @@ public function clear(): ElementInterface {} * @param mixed $defaultValue * @return mixed */ - public function getAttribute(string $attribute, $defaultValue = null) {} + public function getAttribute(string $attribute, $defaultValue = null) + { + } /** * Returns the default attributes for the element * * @return array */ - public function getAttributes(): array {} + public function getAttributes(): array + { + } /** * Returns the default value assigned to the element * * @return mixed */ - public function getDefault() {} + public function getDefault() + { + } /** * Returns the element filters * * @return mixed */ - public function getFilters() {} + public function getFilters() + { + } /** * Returns the parent form to the element * * @return \Phalcon\Forms\Form */ - public function getForm(): Form {} + public function getForm(): Form + { + } /** * Returns the element label * * @return string */ - public function getLabel(): string {} + public function getLabel(): string + { + } /** * Returns the messages that belongs to the element @@ -154,14 +180,18 @@ public function getLabel(): string {} * * @return \Phalcon\Messages\Messages */ - public function getMessages(): Messages {} + public function getMessages(): Messages + { + } /** * Returns the element name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Returns the value of an option if present @@ -170,35 +200,45 @@ public function getName(): string {} * @param mixed $defaultValue * @return mixed */ - public function getUserOption(string $option, $defaultValue = null) {} + public function getUserOption(string $option, $defaultValue = null) + { + } /** * Returns the options for the element * * @return array */ - public function getUserOptions(): array {} + public function getUserOptions(): array + { + } /** * Returns the validators registered for the element * * @return array|\Phalcon\Validation\ValidatorInterface[] */ - public function getValidators(): array {} + public function getValidators(): array + { + } /** * Returns the element's value * * @return mixed */ - public function getValue() {} + public function getValue() + { + } /** * Checks whether there are messages attached to the element * * @return bool */ - public function hasMessages(): bool {} + public function hasMessages(): bool + { + } /** * Generate the HTML to label the element @@ -206,7 +246,9 @@ public function hasMessages(): bool {} * @param array $attributes * @return string */ - public function label(array $attributes = array()): string {} + public function label(array $attributes = array()): string + { + } /** * Returns an array of prepared attributes for Phalcon\Tag helpers @@ -216,7 +258,9 @@ public function label(array $attributes = array()): string {} * @param bool $useChecked * @return array */ - public function prepareAttributes(array $attributes = array(), bool $useChecked = false): array {} + public function prepareAttributes(array $attributes = array(), bool $useChecked = false): array + { + } /** * Sets a default attribute for the element @@ -225,7 +269,9 @@ public function prepareAttributes(array $attributes = array(), bool $useChecked * @param mixed $value * @return ElementInterface */ - public function setAttribute(string $attribute, $value): ElementInterface {} + public function setAttribute(string $attribute, $value): ElementInterface + { + } /** * Sets default attributes for the element @@ -233,7 +279,9 @@ public function setAttribute(string $attribute, $value): ElementInterface {} * @param array $attributes * @return ElementInterface */ - public function setAttributes(array $attributes): ElementInterface {} + public function setAttributes(array $attributes): ElementInterface + { + } /** * Sets a default value in case the form does not use an entity @@ -242,7 +290,9 @@ public function setAttributes(array $attributes): ElementInterface {} * @param mixed $value * @return ElementInterface */ - public function setDefault($value): ElementInterface {} + public function setDefault($value): ElementInterface + { + } /** * Sets the element filters @@ -250,7 +300,9 @@ public function setDefault($value): ElementInterface {} * @param array|string $filters * @return ElementInterface */ - public function setFilters($filters): ElementInterface {} + public function setFilters($filters): ElementInterface + { + } /** * Sets the parent form to the element @@ -258,7 +310,9 @@ public function setFilters($filters): ElementInterface {} * @param \Phalcon\Forms\Form $form * @return ElementInterface */ - public function setForm(\Phalcon\Forms\Form $form): ElementInterface {} + public function setForm(\Phalcon\Forms\Form $form): ElementInterface + { + } /** * Sets the element label @@ -266,7 +320,9 @@ public function setForm(\Phalcon\Forms\Form $form): ElementInterface {} * @param string $label * @return ElementInterface */ - public function setLabel(string $label): ElementInterface {} + public function setLabel(string $label): ElementInterface + { + } /** * Sets the validation messages related to the element @@ -274,7 +330,9 @@ public function setLabel(string $label): ElementInterface {} * @param \Phalcon\Messages\Messages $messages * @return ElementInterface */ - public function setMessages(\Phalcon\Messages\Messages $messages): ElementInterface {} + public function setMessages(\Phalcon\Messages\Messages $messages): ElementInterface + { + } /** * Sets the element name @@ -282,7 +340,9 @@ public function setMessages(\Phalcon\Messages\Messages $messages): ElementInterf * @param string $name * @return ElementInterface */ - public function setName(string $name): ElementInterface {} + public function setName(string $name): ElementInterface + { + } /** * Sets an option for the element @@ -291,7 +351,9 @@ public function setName(string $name): ElementInterface {} * @param mixed $value * @return ElementInterface */ - public function setUserOption(string $option, $value): ElementInterface {} + public function setUserOption(string $option, $value): ElementInterface + { + } /** * Sets options for the element @@ -299,6 +361,7 @@ public function setUserOption(string $option, $value): ElementInterface {} * @param array $options * @return ElementInterface */ - public function setUserOptions(array $options): ElementInterface {} - + public function setUserOptions(array $options): ElementInterface + { + } } diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index 60ad5466..df600585 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -25,6 +25,7 @@ class Check extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index 5b612851..b810d56a 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -23,6 +23,7 @@ class Date extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/forms/element/ElementInterface.php index 7c953abf..e7157ea8 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/forms/element/ElementInterface.php @@ -264,5 +264,4 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; - } diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index b86b767e..af36265a 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -25,6 +25,7 @@ class Email extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index 7598acdf..581e43f1 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -23,6 +23,7 @@ class File extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index 20352655..c33ba0fa 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -25,6 +25,7 @@ class Hidden extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 0aa08daa..617403ab 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -25,6 +25,7 @@ class Numeric extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 297c254e..0d2beb78 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -25,6 +25,7 @@ class Password extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index 7da801d3..54e2352f 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -25,6 +25,7 @@ class Radio extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index 4ee4d373..eb3ba6f2 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -29,7 +29,9 @@ class Select extends AbstractElement * @param object|array $options * @param array $attributes */ - public function __construct(string $name, $options = null, $attributes = null) {} + public function __construct(string $name, $options = null, $attributes = null) + { + } /** * Adds an option to the current options @@ -37,14 +39,18 @@ public function __construct(string $name, $options = null, $attributes = null) { * @param array|string $option * @return Element */ - public function addOption($option): Element {} + public function addOption($option): Element + { + } /** * Returns the choices' options * * @return array|object */ - public function getOptions() {} + public function getOptions() + { + } /** * Renders the element widget returning html @@ -52,7 +58,9 @@ public function getOptions() {} * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} + public function render(array $attributes = array()): string + { + } /** * Set the choice's options @@ -60,6 +68,7 @@ public function render(array $attributes = array()): string {} * @param array|object $options * @return Element */ - public function setOptions($options): Element {} - + public function setOptions($options): Element + { + } } diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index 6221fd32..9a5d2f34 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -23,6 +23,7 @@ class Submit extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index 5bfd5d4c..487f59b9 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -25,6 +25,7 @@ class Text extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index daa53f1d..d1e8a300 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -23,6 +23,7 @@ class TextArea extends AbstractElement * @param array $attributes * @return string */ - public function render(array $attributes = array()): string {} - + public function render(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index 74b60aaa..a7496798 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -27,7 +27,9 @@ class Arr * @param bool $preserveKeys * @return array */ - final public static function chunk(array $collection, int $size, bool $preserveKeys = false): array {} + final public static function chunk(array $collection, int $size, bool $preserveKeys = false): array + { + } /** * Returns the first element of the collection. If a callable is passed, the @@ -39,7 +41,9 @@ final public static function chunk(array $collection, int $size, bool $preserveK * @param mixed $method * @return mixed */ - final public static function first(array $collection, $method = null) {} + final public static function first(array $collection, $method = null) + { + } /** * Returns the key of the first element of the collection. If a callable @@ -51,7 +55,9 @@ final public static function first(array $collection, $method = null) {} * @param mixed $method * @return mixed */ - final public static function firstKey(array $collection, $method = null) {} + final public static function firstKey(array $collection, $method = null) + { + } /** * Flattens an array up to the one level depth, unless `$deep` is set to `true` @@ -62,7 +68,9 @@ final public static function firstKey(array $collection, $method = null) {} * @param bool $deep * @return array */ - final public static function flatten(array $collection, bool $deep = false): array {} + final public static function flatten(array $collection, bool $deep = false): array + { + } /** * Helper method to get an array element or a default @@ -72,7 +80,9 @@ final public static function flatten(array $collection, bool $deep = false): arr * @param mixed $defaultValue * @return mixed */ - final public static function get(array $collection, $index, $defaultValue = null) {} + final public static function get(array $collection, $index, $defaultValue = null) + { + } /** * Groups the elements of an array based on the passed callable @@ -83,7 +93,9 @@ final public static function get(array $collection, $index, $defaultValue = null * @param mixed $method * @return array */ - final public static function group(array $collection, $method): array {} + final public static function group(array $collection, $method): array + { + } /** * Helper method to get an array element or a default @@ -95,7 +107,9 @@ final public static function group(array $collection, $method): array {} * @param mixed $index * @return bool */ - final public static function has(array $collection, $index): bool {} + final public static function has(array $collection, $index): bool + { + } /** * Checks a flat list for duplicate values. Returns true if duplicate @@ -106,7 +120,9 @@ final public static function has(array $collection, $index): bool {} * @param array $collection * @return bool */ - final public static function isUnique(array $collection): bool {} + final public static function isUnique(array $collection): bool + { + } /** * Returns the last element of the collection. If a callable is passed, the @@ -119,7 +135,9 @@ final public static function isUnique(array $collection): bool {} * @param mixed $method * @return mixed */ - final public static function last(array $collection, $method = null) {} + final public static function last(array $collection, $method = null) + { + } /** * Returns the key of the last element of the collection. If a callable is @@ -131,7 +149,9 @@ final public static function last(array $collection, $method = null) {} * @param mixed $method * @return mixed */ - final public static function lastKey(array $collection, $method = null) {} + final public static function lastKey(array $collection, $method = null) + { + } /** * Sorts a collection of arrays or objects by key @@ -144,7 +164,9 @@ final public static function lastKey(array $collection, $method = null) {} * @param mixed $attr * @return array */ - final public static function order(array $collection, $attribute, string $order = 'asc'): array {} + final public static function order(array $collection, $attribute, string $order = 'asc'): array + { + } /** * Retrieves all of the values for a given key: @@ -155,7 +177,9 @@ final public static function order(array $collection, $attribute, string $order * @param string $element * @return array */ - final public static function pluck(array $collection, string $element): array {} + final public static function pluck(array $collection, string $element): array + { + } /** * Helper method to set an array element @@ -167,7 +191,9 @@ final public static function pluck(array $collection, string $element): array {} * @param mixed $index * @return array */ - final public static function set(array $collection, $value, $index = null): array {} + final public static function set(array $collection, $value, $index = null): array + { + } /** * Returns a new array with n elements removed from the right. @@ -178,7 +204,9 @@ final public static function set(array $collection, $value, $index = null): arra * @param int $elements * @return array */ - final public static function sliceLeft(array $collection, int $elements = 1): array {} + final public static function sliceLeft(array $collection, int $elements = 1): array + { + } /** * Returns a new array with the X elements from the right @@ -189,7 +217,9 @@ final public static function sliceLeft(array $collection, int $elements = 1): ar * @param int $elements * @return array */ - final public static function sliceRight(array $collection, int $elements = 1): array {} + final public static function sliceRight(array $collection, int $elements = 1): array + { + } /** * Returns a new array with keys of the passed array as one element and @@ -200,14 +230,18 @@ final public static function sliceRight(array $collection, int $elements = 1): a * @param array $collection * @return array */ - final public static function split(array $collection): array {} + final public static function split(array $collection): array + { + } /** * Returns the passed array as an object * * @param array $collection */ - final public static function toObject(array $collection) {} + final public static function toObject(array $collection) + { + } /** * Returns true if the provided function returns true for all elements of @@ -219,7 +253,9 @@ final public static function toObject(array $collection) {} * @param mixed $method * @return bool */ - final public static function validateAll(array $collection, $method): bool {} + final public static function validateAll(array $collection, $method): bool + { + } /** * Returns true if the provided function returns true for at least one @@ -231,7 +267,9 @@ final public static function validateAll(array $collection, $method): bool {} * @param mixed $method * @return bool */ - final public static function validateAny(array $collection, $method): bool {} + final public static function validateAny(array $collection, $method): bool + { + } /** * Helper method to filter the collection @@ -242,7 +280,9 @@ final public static function validateAny(array $collection, $method): bool {} * @param mixed $method * @return array */ - final private static function filterCollection(array $collection, $method = null): array {} + final private static function filterCollection(array $collection, $method = null): array + { + } /** * White list filter by key: obtain elements of an array filtering @@ -254,6 +294,7 @@ final private static function filterCollection(array $collection, $method = null * @param array $whiteList * @return array */ - final public static function whiteList(array $collection, array $whiteList): array {} - + final public static function whiteList(array $collection, array $whiteList): array + { + } } diff --git a/src/Phalcon/helper/Fs.php b/src/Phalcon/helper/Fs.php index 729c68e9..94cbfbb2 100644 --- a/src/Phalcon/helper/Fs.php +++ b/src/Phalcon/helper/Fs.php @@ -28,6 +28,7 @@ class Fs * @param mixed $suffix * @return string */ - final public static function basename(string $uri, $suffix = null): string {} - + final public static function basename(string $uri, $suffix = null): string + { + } } diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php index 40d93135..6d933a62 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/helper/Number.php @@ -27,6 +27,7 @@ class Number * @param int $to * @return bool */ - final public static function between(int $value, int $from, int $to): bool {} - + final public static function between(int $value, int $from, int $to): bool + { + } } diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/helper/Str.php index e64a7d58..23d0a880 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/helper/Str.php @@ -52,7 +52,9 @@ class Str * @param mixed $delimiter * @return string */ - final public static function camelize(string $text, $delimiter = null): string {} + final public static function camelize(string $text, $delimiter = null): string + { + } /** * Concatenates strings using the separator only once without duplication in @@ -77,7 +79,9 @@ final public static function camelize(string $text, $delimiter = null): string { * @param string $b * @return string */ - final public static function concat(): string {} + final public static function concat(): string + { + } /** * Retuns number of vowels in provided string. Uses a regular expression @@ -88,7 +92,9 @@ final public static function concat(): string {} * @param string $text * @return int */ - final public static function countVowels(string $text): int {} + final public static function countVowels(string $text): int + { + } /** * Decapitalizes the first letter of the sring and then adds it with rest @@ -103,7 +109,9 @@ final public static function countVowels(string $text): int {} * @param string $string * @return string */ - final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string {} + final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string + { + } /** * Accepts a file name (without extension) and returns a calculated @@ -120,7 +128,9 @@ final public static function decapitalize(string $text, bool $upperRest = false, * @param string $file * @return string */ - final public static function dirFromFile(string $file): string {} + final public static function dirFromFile(string $file): string + { + } /** * Accepts a directory name and ensures that it ends with @@ -137,7 +147,9 @@ final public static function dirFromFile(string $file): string {} * @param string $directory * @return string */ - final public static function dirSeparator(string $directory): string {} + final public static function dirSeparator(string $directory): string + { + } /** * Generates random text in accordance with the template @@ -170,7 +182,9 @@ final public static function dirSeparator(string $directory): string {} * @param string $separator * @return string */ - final public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string {} + final public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string + { + } /** * Check if a string ends with a given string @@ -190,7 +204,9 @@ final public static function dynamic(string $text, string $leftDelimiter = '{', * @param bool $ignoreCase * @return bool */ - final public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool {} + final public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool + { + } /** * Returns the first string there is between the strings from the @@ -203,7 +219,9 @@ final public static function endsWith(string $text, string $end, bool $ignoreCas * @param string $end * @return string */ - final public static function firstBetween(string $text, string $start, string $end): string {} + final public static function firstBetween(string $text, string $start, string $end): string + { + } /** * Makes an underscored or dashed phrase human-readable @@ -220,7 +238,9 @@ final public static function firstBetween(string $text, string $start, string $e * @param string $text * @return string */ - final public static function humanize(string $text): string {} + final public static function humanize(string $text): string + { + } /** * Lets you determine whether or not a string includes another string. @@ -231,7 +251,9 @@ final public static function humanize(string $text): string {} * @param string $haystack * @return bool */ - final public static function includes(string $needle, string $haystack): bool {} + final public static function includes(string $needle, string $haystack): bool + { + } /** * Adds a number to a string or increment that number if it already is @@ -250,7 +272,9 @@ final public static function includes(string $needle, string $haystack): bool {} * @param string $separator * @return string */ - final public static function increment(string $text, string $separator = '_'): string {} + final public static function increment(string $text, string $separator = '_'): string + { + } /** * Compare two strings and returns true if both strings are anagram, @@ -262,7 +286,9 @@ final public static function increment(string $text, string $separator = '_'): s * @param string $second * @return bool */ - final public static function isAnagram(string $first, string $second): bool {} + final public static function isAnagram(string $first, string $second): bool + { + } /** * Returns true if the given string is lower case, false otherwise. @@ -273,7 +299,9 @@ final public static function isAnagram(string $first, string $second): bool {} * @param string $encoding * @return bool */ - final public static function isLower(string $text, string $encoding = 'UTF-8'): bool {} + final public static function isLower(string $text, string $encoding = 'UTF-8'): bool + { + } /** * Returns true if the given string is a palindrome, false otherwise. @@ -283,7 +311,9 @@ final public static function isLower(string $text, string $encoding = 'UTF-8'): * @param string $text * @return bool */ - final public static function isPalindrome(string $text): bool {} + final public static function isPalindrome(string $text): bool + { + } /** * Returns true if the given string is upper case, false otherwise. @@ -294,7 +324,9 @@ final public static function isPalindrome(string $text): bool {} * @param string $encoding * @return bool */ - final public static function isUpper(string $text, string $encoding = 'UTF-8'): bool {} + final public static function isUpper(string $text, string $encoding = 'UTF-8'): bool + { + } /** * Lowercases a string, this function makes use of the mbstring extension if @@ -310,7 +342,9 @@ final public static function isUpper(string $text, string $encoding = 'UTF-8'): * @param string $encoding * @return string */ - final public static function lower(string $text, string $encoding = 'UTF-8'): string {} + final public static function lower(string $text, string $encoding = 'UTF-8'): string + { + } /** * Generates a random string based on the given type. Type is one of the @@ -328,7 +362,9 @@ final public static function lower(string $text, string $encoding = 'UTF-8'): st * @param long $length * @return string */ - final public static function random(int $type = 0, int $length = 8): string {} + final public static function random(int $type = 0, int $length = 8): string + { + } /** * Reduces multiple slashes in a string to single slashes @@ -346,7 +382,9 @@ final public static function random(int $type = 0, int $length = 8): string {} * @param string $text * @return string */ - final public static function reduceSlashes(string $text): string {} + final public static function reduceSlashes(string $text): string + { + } /** * Check if a string starts with a given string @@ -366,7 +404,9 @@ final public static function reduceSlashes(string $text): string {} * @param bool $ignoreCase * @return bool */ - final public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool {} + final public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool + { + } /** * Uncamelize strings which are camelized @@ -384,7 +424,9 @@ final public static function startsWith(string $text, string $start, bool $ignor * @param mixed $delimiter * @return string */ - final public static function uncamelize(string $text, $delimiter = null): string {} + final public static function uncamelize(string $text, $delimiter = null): string + { + } /** * Makes a phrase underscored instead of spaced @@ -401,7 +443,9 @@ final public static function uncamelize(string $text, $delimiter = null): string * @param string $text * @return string */ - final public static function underscore(string $text): string {} + final public static function underscore(string $text): string + { + } /** * Uppercases a string, this function makes use of the mbstring extension if @@ -417,6 +461,7 @@ final public static function underscore(string $text): string {} * @param string $encoding * @return string */ - final public static function upper(string $text, string $encoding = 'UTF-8'): string {} - + final public static function upper(string $text, string $encoding = 'UTF-8'): string + { + } } diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/html/Attributes.php index b1826514..6fa08f92 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/html/Attributes.php @@ -25,13 +25,16 @@ class Attributes extends Collection implements RenderInterface * * @return string */ - public function render(): string {} + public function render(): string + { + } /** * Alias of the render method * * @return string */ - public function __toString(): string {} - + public function __toString(): string + { + } } diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/html/Breadcrumbs.php index 605c29b1..a9f76db7 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/html/Breadcrumbs.php @@ -47,14 +47,18 @@ class Breadcrumbs * * @return string */ - public function getSeparator(): string {} + public function getSeparator(): string + { + } /** * Crumb separator * * @param string $separator */ - public function setSeparator(string $separator) {} + public function setSeparator(string $separator) + { + } /** * Adds a new crumb. @@ -71,7 +75,9 @@ public function setSeparator(string $separator) {} * @param string $link * @return Breadcrumbs */ - public function add(string $label, string $link = ''): Breadcrumbs {} + public function add(string $label, string $link = ''): Breadcrumbs + { + } /** * Clears the crumbs @@ -80,7 +86,9 @@ public function add(string $label, string $link = ''): Breadcrumbs {} * $breadcrumbs->clear() * ``` */ - public function clear() {} + public function clear() + { + } /** * Removes crumb by url. @@ -94,7 +102,9 @@ public function clear() {} * * @param string $link */ - public function remove(string $link) {} + public function remove(string $link) + { + } /** * Renders and outputs breadcrumbs based on previously set template. @@ -105,13 +115,16 @@ public function remove(string $link) {} * * @return string */ - public function render(): string {} + public function render(): string + { + } /** * Returns the internal breadcrumbs array * * @return array */ - public function toArray(): array {} - + public function toArray(): array + { + } } diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php index 73baf876..74c85c30 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/html/TagFactory.php @@ -31,7 +31,9 @@ class TagFactory extends AbstractFactory * @param \Phalcon\Escaper\EscaperInterface $escaper * @param array $services */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) {} + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) + { + } /** * @param string name @@ -40,11 +42,14 @@ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $s * @param string $name * @return mixed */ - public function newInstance(string $name) {} + public function newInstance(string $name) + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/html/attributes/AttributesInterface.php b/src/Phalcon/html/attributes/AttributesInterface.php index e3e60ffc..c54e7b59 100644 --- a/src/Phalcon/html/attributes/AttributesInterface.php +++ b/src/Phalcon/html/attributes/AttributesInterface.php @@ -34,5 +34,4 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; - } diff --git a/src/Phalcon/html/attributes/RenderInterface.php b/src/Phalcon/html/attributes/RenderInterface.php index 455f9fde..f801f75b 100644 --- a/src/Phalcon/html/attributes/RenderInterface.php +++ b/src/Phalcon/html/attributes/RenderInterface.php @@ -24,5 +24,4 @@ interface RenderInterface * @return string */ public function render(): string; - } diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/html/helper/AbstractHelper.php index 80b7e92f..80b525f5 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/html/helper/AbstractHelper.php @@ -31,7 +31,9 @@ abstract class AbstractHelper * * @param \Phalcon\Escaper\EscaperInterface $escaper */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) {} + public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) + { + } /** * Renders an element @@ -42,7 +44,9 @@ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) {} * @param bool $raw * @return string */ - protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string {} + protected function renderFullElement(string $tag, string $text, array $attributes = array(), bool $raw = false): string + { + } /** * Renders an element @@ -51,7 +55,9 @@ protected function renderFullElement(string $tag, string $text, array $attribute * @param array $attributes * @return string */ - protected function renderElement(string $tag, array $attributes = array()): string {} + protected function renderElement(string $tag, array $attributes = array()): string + { + } /** * Keeps all the attributes sorted - same order all the tome @@ -62,7 +68,9 @@ protected function renderElement(string $tag, array $attributes = array()): stri * @param array $attributes * @return array */ - protected function orderAttributes(array $overrides, array $attributes): array {} + protected function orderAttributes(array $overrides, array $attributes): array + { + } /** * Renders all the attributes @@ -70,7 +78,9 @@ protected function orderAttributes(array $overrides, array $attributes): array { * @param array $attributes * @return string */ - protected function renderAttributes(array $attributes): string {} + protected function renderAttributes(array $attributes): string + { + } /** * Produces a self close tag i.e. @@ -79,6 +89,7 @@ protected function renderAttributes(array $attributes): string {} * @param array $attributes * @return string */ - protected function selfClose(string $tag, array $attributes = array()): string {} - + protected function selfClose(string $tag, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 80f9cd36..07cd5ed0 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -25,6 +25,7 @@ class Anchor extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $href, string $text, array $attributes = array()): string {} - + public function __invoke(string $href, string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php index 6bf57784..c2db84cc 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -25,6 +25,7 @@ class AnchorRaw extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $href, string $text, array $attributes = array()): string {} - + public function __invoke(string $href, string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Body.php b/src/Phalcon/html/helper/Body.php index 955484b7..509a4054 100644 --- a/src/Phalcon/html/helper/Body.php +++ b/src/Phalcon/html/helper/Body.php @@ -23,6 +23,7 @@ class Body extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(array $attributes = array()): string {} - + public function __invoke(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/html/helper/Button.php index 87ae74d4..d0f61533 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/html/helper/Button.php @@ -24,6 +24,7 @@ class Button extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $text, array $attributes = array()): string {} - + public function __invoke(string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Close.php b/src/Phalcon/html/helper/Close.php index 6f6e3b65..77260bf9 100644 --- a/src/Phalcon/html/helper/Close.php +++ b/src/Phalcon/html/helper/Close.php @@ -25,6 +25,7 @@ class Close extends AbstractHelper * @param string $tag * @return string */ - public function __invoke(string $tag): string {} - + public function __invoke(string $tag): string + { + } } diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/html/helper/Element.php index 065a7237..19bf6439 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/html/helper/Element.php @@ -25,6 +25,7 @@ class Element extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $tag, string $text, array $attributes = array()): string {} - + public function __invoke(string $tag, string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/ElementRaw.php b/src/Phalcon/html/helper/ElementRaw.php index 0b4e12ed..7b96489a 100644 --- a/src/Phalcon/html/helper/ElementRaw.php +++ b/src/Phalcon/html/helper/ElementRaw.php @@ -30,6 +30,7 @@ class ElementRaw extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $tag, string $text, array $attributes = array()): string {} - + public function __invoke(string $tag, string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/html/helper/Form.php index ddc17d69..2bd7d2ea 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/html/helper/Form.php @@ -23,6 +23,7 @@ class Form extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(array $attributes = array()): string {} - + public function __invoke(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Img.php b/src/Phalcon/html/helper/Img.php index 8f3dcb79..3d77205f 100644 --- a/src/Phalcon/html/helper/Img.php +++ b/src/Phalcon/html/helper/Img.php @@ -29,6 +29,7 @@ class Img extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $src, array $attributes = array()): string {} - + public function __invoke(string $src, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/Label.php b/src/Phalcon/html/helper/Label.php index 0487ecc3..849a72ed 100644 --- a/src/Phalcon/html/helper/Label.php +++ b/src/Phalcon/html/helper/Label.php @@ -28,6 +28,7 @@ class Label extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(array $attributes = array()): string {} - + public function __invoke(array $attributes = array()): string + { + } } diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/html/helper/TextArea.php index ecf797a2..e78a792e 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/html/helper/TextArea.php @@ -24,6 +24,7 @@ class TextArea extends AbstractHelper * @param array $attributes * @return string */ - public function __invoke(string $text, array $attributes = array()): string {} - + public function __invoke(string $text, array $attributes = array()): string + { + } } diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/http/Cookie.php index 236df2ef..de13c767 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/http/Cookie.php @@ -70,54 +70,70 @@ class Cookie extends AbstractInjectionAware implements CookieInterface * @param string $domain * @param bool $httpOnly */ - public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = false) {} + public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = false) + { + } /** * Magic __toString method converts the cookie's value to string * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Deletes the cookie by setting an expire time in the past */ - public function delete() {} + public function delete() + { + } /** * Returns the domain that the cookie is available to * * @return string */ - public function getDomain(): string {} + public function getDomain(): string + { + } /** * Returns the current expiration time * * @return string */ - public function getExpiration(): string {} + public function getExpiration(): string + { + } /** * Returns if the cookie is accessible only through the HTTP protocol * * @return bool */ - public function getHttpOnly(): bool {} + public function getHttpOnly(): bool + { + } /** * Returns the current cookie's name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Returns the current cookie's path * * @return string */ - public function getPath(): string {} + public function getPath(): string + { + } /** * Returns whether the cookie must only be sent when the connection is @@ -125,7 +141,9 @@ public function getPath(): string {} * * @return bool */ - public function getSecure(): bool {} + public function getSecure(): bool + { + } /** * Returns the cookie's value. @@ -134,14 +152,18 @@ public function getSecure(): bool {} * @param mixed $defaultValue * @return mixed */ - public function getValue($filters = null, $defaultValue = null) {} + public function getValue($filters = null, $defaultValue = null) + { + } /** * Check if the cookie is using implicit encryption * * @return bool */ - public function isUsingEncryption(): bool {} + public function isUsingEncryption(): bool + { + } /** * Reads the cookie-related info from the SESSION to restore the cookie as @@ -152,7 +174,9 @@ public function isUsingEncryption(): bool {} * * @return CookieInterface */ - public function restore(): CookieInterface {} + public function restore(): CookieInterface + { + } /** * Sends the cookie to the HTTP client. @@ -161,7 +185,9 @@ public function restore(): CookieInterface {} * * @return CookieInterface */ - public function send(): CookieInterface {} + public function send(): CookieInterface + { + } /** * Sets the domain that the cookie is available to @@ -169,7 +195,9 @@ public function send(): CookieInterface {} * @param string $domain * @return CookieInterface */ - public function setDomain(string $domain): CookieInterface {} + public function setDomain(string $domain): CookieInterface + { + } /** * Sets the cookie's expiration time @@ -177,7 +205,9 @@ public function setDomain(string $domain): CookieInterface {} * @param int $expire * @return CookieInterface */ - public function setExpiration(int $expire): CookieInterface {} + public function setExpiration(int $expire): CookieInterface + { + } /** * Sets if the cookie is accessible only through the HTTP protocol @@ -185,7 +215,9 @@ public function setExpiration(int $expire): CookieInterface {} * @param bool $httpOnly * @return CookieInterface */ - public function setHttpOnly(bool $httpOnly): CookieInterface {} + public function setHttpOnly(bool $httpOnly): CookieInterface + { + } /** * Sets the cookie's expiration time @@ -193,7 +225,9 @@ public function setHttpOnly(bool $httpOnly): CookieInterface {} * @param string $path * @return CookieInterface */ - public function setPath(string $path): CookieInterface {} + public function setPath(string $path): CookieInterface + { + } /** * Sets if the cookie must only be sent when the connection is secure (HTTPS) @@ -201,7 +235,9 @@ public function setPath(string $path): CookieInterface {} * @param bool $secure * @return CookieInterface */ - public function setSecure(bool $secure): CookieInterface {} + public function setSecure(bool $secure): CookieInterface + { + } /** * Sets the cookie's sign key. @@ -216,7 +252,9 @@ public function setSecure(bool $secure): CookieInterface {} * @param string $signKey * @return CookieInterface */ - public function setSignKey(string $signKey = null): CookieInterface {} + public function setSignKey(string $signKey = null): CookieInterface + { + } /** * Sets the cookie's value @@ -224,7 +262,9 @@ public function setSignKey(string $signKey = null): CookieInterface {} * @param string $value * @return CookieInterface */ - public function setValue($value): CookieInterface {} + public function setValue($value): CookieInterface + { + } /** * Sets if the cookie must be encrypted/decrypted automatically @@ -232,7 +272,9 @@ public function setValue($value): CookieInterface {} * @param bool $useEncryption * @return CookieInterface */ - public function useEncryption(bool $useEncryption): CookieInterface {} + public function useEncryption(bool $useEncryption): CookieInterface + { + } /** * Assert the cookie's key is enough long. @@ -240,6 +282,7 @@ public function useEncryption(bool $useEncryption): CookieInterface {} * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey */ - protected function assertSignKeyIsLongEnough(string $signKey) {} - + protected function assertSignKeyIsLongEnough(string $signKey) + { + } } diff --git a/src/Phalcon/http/CookieInterface.php b/src/Phalcon/http/CookieInterface.php index 90e58390..9d94fd42 100644 --- a/src/Phalcon/http/CookieInterface.php +++ b/src/Phalcon/http/CookieInterface.php @@ -144,5 +144,4 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; - } diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/http/Request.php index 0f2c08ea..2c83177c 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/http/Request.php @@ -70,12 +70,16 @@ class Request extends AbstractInjectionAware implements RequestInterface /** * @return bool */ - public function getHttpMethodParameterOverride(): bool {} + public function getHttpMethodParameterOverride(): bool + { + } /** * @param bool $httpMethodParameterOverride */ - public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride) {} + public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride) + { + } /** * Gets a variable from the $_REQUEST superglobal applying filters if @@ -96,7 +100,9 @@ public function setHttpMethodParameterOverride(bool $httpMethodParameterOverride * @param bool $noRecursive * @return mixed */ - public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function get(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Gets an array with mime/types and their quality accepted by the @@ -104,7 +110,9 @@ public function get(string $name = null, $filters = null, $defaultValue = null, * * @return array */ - public function getAcceptableContent(): array {} + public function getAcceptableContent(): array + { + } /** * Gets auth info accepted by the browser/client from @@ -112,7 +120,9 @@ public function getAcceptableContent(): array {} * * @return array|null */ - public function getBasicAuth(): ?array {} + public function getBasicAuth(): ?array + { + } /** * Gets best mime/type accepted by the browser/client from @@ -120,7 +130,9 @@ public function getBasicAuth(): ?array {} * * @return string */ - public function getBestAccept(): string {} + public function getBestAccept(): string + { + } /** * Gets best charset accepted by the browser/client from @@ -128,7 +140,9 @@ public function getBestAccept(): string {} * * @return string */ - public function getBestCharset(): string {} + public function getBestCharset(): string + { + } /** * Gets best language accepted by the browser/client from @@ -136,7 +150,9 @@ public function getBestCharset(): string {} * * @return string */ - public function getBestLanguage(): string {} + public function getBestLanguage(): string + { + } /** * Gets most possible client IPv4 Address. This method searches in @@ -146,7 +162,9 @@ public function getBestLanguage(): string {} * @param bool $trustForwardedHeader * @return string|bool */ - public function getClientAddress(bool $trustForwardedHeader = false) {} + public function getClientAddress(bool $trustForwardedHeader = false) + { + } /** * Gets a charsets array and their quality accepted by the browser/client @@ -154,14 +172,18 @@ public function getClientAddress(bool $trustForwardedHeader = false) {} * * @return array */ - public function getClientCharsets(): array {} + public function getClientCharsets(): array + { + } /** * Gets content type which request has been made * * @return string|null */ - public function getContentType(): ?string {} + public function getContentType(): ?string + { + } /** * Gets auth info accepted by the browser/client from @@ -169,7 +191,9 @@ public function getContentType(): ?string {} * * @return array */ - public function getDigestAuth(): array {} + public function getDigestAuth(): array + { + } /** * Retrieves a query/get value always sanitized with the preset filters @@ -180,7 +204,9 @@ public function getDigestAuth(): array {} * @param bool $noRecursive * @return mixed */ - public function getFilteredQuery(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getFilteredQuery(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Retrieves a post value always sanitized with the preset filters @@ -191,7 +217,9 @@ public function getFilteredQuery(string $name = null, $defaultValue = null, bool * @param bool $noRecursive * @return mixed */ - public function getFilteredPost(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getFilteredPost(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Retrieves a put value always sanitized with the preset filters @@ -202,7 +230,9 @@ public function getFilteredPost(string $name = null, $defaultValue = null, bool * @param bool $noRecursive * @return mixed */ - public function getFilteredPut(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getFilteredPut(string $name = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Gets HTTP header from request data @@ -210,7 +240,9 @@ public function getFilteredPut(string $name = null, $defaultValue = null, bool $ * @param string $header * @return string */ - final public function getHeader(string $header): string {} + final public function getHeader(string $header): string + { + } /** * Returns the available headers in the request @@ -228,7 +260,9 @@ final public function getHeader(string $header): string {} * * @return array */ - public function getHeaders(): array {} + public function getHeaders(): array + { + } /** * Gets host name used by the request. @@ -266,14 +300,18 @@ public function getHeaders(): array {} * * @return string */ - public function getHttpHost(): string {} + public function getHttpHost(): string + { + } /** * Gets web page that refers active request. ie: http://www.google.com * * @return string */ - public function getHTTPReferer(): string {} + public function getHTTPReferer(): string + { + } /** * Gets decoded JSON HTTP raw request body @@ -281,7 +319,9 @@ public function getHTTPReferer(): string {} * @param bool $associative * @return array|bool|\stdClass */ - public function getJsonRawBody(bool $associative = false) {} + public function getJsonRawBody(bool $associative = false) + { + } /** * Gets languages array and their quality accepted by the browser/client @@ -289,7 +329,9 @@ public function getJsonRawBody(bool $associative = false) {} * * @return array */ - public function getLanguages(): array {} + public function getLanguages(): array + { + } /** * Gets HTTP method which request has been made @@ -304,14 +346,18 @@ public function getLanguages(): array {} * * @return string */ - final public function getMethod(): string {} + final public function getMethod(): string + { + } /** * Gets information about the port on which the request is made. * * @return int */ - public function getPort(): int {} + public function getPort(): int + { + } /** * Gets a variable from the $_POST superglobal applying filters if needed @@ -332,7 +378,9 @@ public function getPort(): int {} * @param bool $noRecursive * @return mixed */ - public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getPost(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Gets a variable from put request @@ -352,7 +400,9 @@ public function getPost(string $name = null, $filters = null, $defaultValue = nu * @param bool $noRecursive * @return mixed */ - public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getPut(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Gets variable from $_GET superglobal applying filters if needed @@ -376,21 +426,27 @@ public function getPut(string $name = null, $filters = null, $defaultValue = nul * @param bool $noRecursive * @return mixed */ - public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + public function getQuery(string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Gets HTTP raw request body * * @return string */ - public function getRawBody(): string {} + public function getRawBody(): string + { + } /** * Gets HTTP schema (http/https) * * @return string */ - public function getScheme(): string {} + public function getScheme(): string + { + } /** * Gets variable from $_SERVER superglobal @@ -398,21 +454,27 @@ public function getScheme(): string {} * @param string $name * @return string|null */ - public function getServer(string $name): ?string {} + public function getServer(string $name): ?string + { + } /** * Gets active server address IP * * @return string */ - public function getServerAddress(): string {} + public function getServerAddress(): string + { + } /** * Gets active server name * * @return string */ - public function getServerName(): string {} + public function getServerName(): string + { + } /** * Gets attached files as Phalcon\Http\Request\File instances @@ -421,7 +483,9 @@ public function getServerName(): string {} * @param bool $namedKeys * @return array|\Phalcon\Http\Request\FileInterface[] */ - public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array {} + public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array + { + } /** * Gets HTTP URI which request has been made to @@ -437,14 +501,18 @@ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = * @param bool $onlyPath If true, query part will be omitted * @return string */ - final public function getURI(bool $onlyPath = false): string {} + final public function getURI(bool $onlyPath = false): string + { + } /** * Gets HTTP user agent used to made the request * * @return string */ - public function getUserAgent(): string {} + public function getUserAgent(): string + { + } /** * Checks whether $_REQUEST superglobal has certain index @@ -452,7 +520,9 @@ public function getUserAgent(): string {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Returns the number of files available @@ -462,7 +532,9 @@ public function has(string $name): bool {} * @param bool $onlySuccessful * @return long */ - public function hasFiles(bool $onlySuccessful = false): int {} + public function hasFiles(bool $onlySuccessful = false): int + { + } /** * Checks whether headers has certain index @@ -470,7 +542,9 @@ public function hasFiles(bool $onlySuccessful = false): int {} * @param string $header * @return bool */ - final public function hasHeader(string $header): bool {} + final public function hasHeader(string $header): bool + { + } /** * Checks whether $_POST superglobal has certain index @@ -478,7 +552,9 @@ final public function hasHeader(string $header): bool {} * @param string $name * @return bool */ - public function hasPost(string $name): bool {} + public function hasPost(string $name): bool + { + } /** * Checks whether the PUT data has certain index @@ -486,7 +562,9 @@ public function hasPost(string $name): bool {} * @param string $name * @return bool */ - public function hasPut(string $name): bool {} + public function hasPut(string $name): bool + { + } /** * Checks whether $_GET superglobal has certain index @@ -494,7 +572,9 @@ public function hasPut(string $name): bool {} * @param string $name * @return bool */ - public function hasQuery(string $name): bool {} + public function hasQuery(string $name): bool + { + } /** * Checks whether $_SERVER superglobal has certain index @@ -502,14 +582,18 @@ public function hasQuery(string $name): bool {} * @param string $name * @return bool */ - final public function hasServer(string $name): bool {} + final public function hasServer(string $name): bool + { + } /** * Checks whether request has been made using ajax * * @return bool */ - public function isAjax(): bool {} + public function isAjax(): bool + { + } /** * Checks whether HTTP method is CONNECT. @@ -517,7 +601,9 @@ public function isAjax(): bool {} * * @return bool */ - public function isConnect(): bool {} + public function isConnect(): bool + { + } /** * Checks whether HTTP method is DELETE. @@ -525,7 +611,9 @@ public function isConnect(): bool {} * * @return bool */ - public function isDelete(): bool {} + public function isDelete(): bool + { + } /** * Checks whether HTTP method is GET. @@ -533,7 +621,9 @@ public function isDelete(): bool {} * * @return bool */ - public function isGet(): bool {} + public function isGet(): bool + { + } /** * Checks whether HTTP method is HEAD. @@ -541,7 +631,9 @@ public function isGet(): bool {} * * @return bool */ - public function isHead(): bool {} + public function isHead(): bool + { + } /** * Check if HTTP method match any of the passed methods @@ -551,7 +643,9 @@ public function isHead(): bool {} * @param bool $strict * @return bool */ - public function isMethod($methods, bool $strict = false): bool {} + public function isMethod($methods, bool $strict = false): bool + { + } /** * Checks whether HTTP method is OPTIONS. @@ -559,7 +653,9 @@ public function isMethod($methods, bool $strict = false): bool {} * * @return bool */ - public function isOptions(): bool {} + public function isOptions(): bool + { + } /** * Checks whether HTTP method is PATCH. @@ -567,7 +663,9 @@ public function isOptions(): bool {} * * @return bool */ - public function isPatch(): bool {} + public function isPatch(): bool + { + } /** * Checks whether HTTP method is POST. @@ -575,7 +673,9 @@ public function isPatch(): bool {} * * @return bool */ - public function isPost(): bool {} + public function isPost(): bool + { + } /** * Checks whether HTTP method is PUT. @@ -583,7 +683,9 @@ public function isPost(): bool {} * * @return bool */ - public function isPut(): bool {} + public function isPut(): bool + { + } /** * Checks whether HTTP method is PURGE (Squid and Varnish support). @@ -591,14 +693,18 @@ public function isPut(): bool {} * * @return bool */ - public function isPurge(): bool {} + public function isPurge(): bool + { + } /** * Checks whether request has been made using any secure layer * * @return bool */ - public function isSecure(): bool {} + public function isSecure(): bool + { + } /** * Checks if the `Request::getHttpHost` method will be use strict validation @@ -606,14 +712,18 @@ public function isSecure(): bool {} * * @return bool */ - public function isStrictHostCheck(): bool {} + public function isStrictHostCheck(): bool + { + } /** * Checks whether request has been made using SOAP * * @return bool */ - public function isSoap(): bool {} + public function isSoap(): bool + { + } /** * Checks whether HTTP method is TRACE. @@ -621,7 +731,9 @@ public function isSoap(): bool {} * * @return bool */ - public function isTrace(): bool {} + public function isTrace(): bool + { + } /** * Checks if a method is a valid HTTP method @@ -629,7 +741,9 @@ public function isTrace(): bool {} * @param string $method * @return bool */ - public function isValidHttpMethod(string $method): bool {} + public function isValidHttpMethod(string $method): bool + { + } /** * Sets automatic sanitizers/filters for a particular field and for @@ -640,7 +754,9 @@ public function isValidHttpMethod(string $method): bool {} * @param array $scope * @return RequestInterface */ - public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface {} + public function setParameterFilters(string $name, array $filters = array(), array $scope = array()): RequestInterface + { + } /** * Sets if the `Request::getHttpHost` method must be use strict validation @@ -649,7 +765,9 @@ public function setParameterFilters(string $name, array $filters = array(), arra * @param bool $flag * @return RequestInterface */ - public function setStrictHostCheck(bool $flag = true): RequestInterface {} + public function setStrictHostCheck(bool $flag = true): RequestInterface + { + } /** * Process a request header and return the one with best quality @@ -658,7 +776,9 @@ public function setStrictHostCheck(bool $flag = true): RequestInterface {} * @param string $name * @return string */ - final protected function getBestQuality(array $qualityParts, string $name): string {} + final protected function getBestQuality(array $qualityParts, string $name): string + { + } /** * Helper to get data from superglobals, applying filters if needed. @@ -672,7 +792,9 @@ final protected function getBestQuality(array $qualityParts, string $name): stri * @param bool $noRecursive * @return mixed */ - final protected function getHelper(array $source, string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) {} + final protected function getHelper(array $source, string $name = null, $filters = null, $defaultValue = null, bool $notAllowEmpty = false, bool $noRecursive = false) + { + } /** * Recursively counts file in an array of files @@ -681,7 +803,9 @@ final protected function getHelper(array $source, string $name = null, $filters * @param bool $onlySuccessful * @return long */ - final protected function hasFileHelper($data, bool $onlySuccessful): int {} + final protected function hasFileHelper($data, bool $onlySuccessful): int + { + } /** * Process a request header and return an array of values with their qualities @@ -690,14 +814,18 @@ final protected function hasFileHelper($data, bool $onlySuccessful): int {} * @param string $name * @return array */ - final protected function getQualityHeader(string $serverIndex, string $name): array {} + final protected function getQualityHeader(string $serverIndex, string $name): array + { + } /** * Resolve authorization headers. * * @return array */ - protected function resolveAuthorizationHeaders(): array {} + protected function resolveAuthorizationHeaders(): array + { + } /** * Smooth out $_FILES to have plain array with all files uploaded @@ -710,18 +838,23 @@ protected function resolveAuthorizationHeaders(): array {} * @param string $prefix * @return array */ - final protected function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, string $prefix): array {} + final protected function smoothFiles(array $names, array $types, array $tmp_names, array $sizes, array $errors, string $prefix): array + { + } /** * Checks the filter service and assigns it to the class parameter * * @return \Phalcon\Filter\FilterInterface */ - private function getFilterService(): FilterInterface {} + private function getFilterService(): FilterInterface + { + } /** * @return array */ - private function getServerArray(): array {} - + private function getServerArray(): array + { + } } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 025ae088..ba68f5c0 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -504,5 +504,4 @@ public function isSoap(): bool; * @return bool */ public function isTrace(): bool; - } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 2a397a26..685b4630 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -68,7 +68,9 @@ class Response implements ResponseInterface, InjectionAwareInterface, EventsAwar * @param mixed $code * @param mixed $status */ - public function __construct($content = null, $code = null, $status = null) {} + public function __construct($content = null, $code = null, $status = null) + { + } /** * Appends a string to the HTTP response body @@ -76,42 +78,54 @@ public function __construct($content = null, $code = null, $status = null) {} * @param mixed $content * @return ResponseInterface */ - public function appendContent($content): ResponseInterface {} + public function appendContent($content): ResponseInterface + { + } /** * Gets the HTTP response body * * @return string */ - public function getContent(): string {} + public function getContent(): string + { + } /** * Returns cookies set by the user * * @return \Phalcon\Http\Response\CookiesInterface */ - public function getCookies(): CookiesInterface {} + public function getCookies(): CookiesInterface + { + } /** * Returns the internal dependency injector * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Returns headers set by the user * * @return \Phalcon\Http\Response\HeadersInterface */ - public function getHeaders(): HeadersInterface {} + public function getHeaders(): HeadersInterface + { + } /** * Returns the reason phrase @@ -122,7 +136,9 @@ public function getHeaders(): HeadersInterface {} * * @return string|null */ - public function getReasonPhrase(): ?string {} + public function getReasonPhrase(): ?string + { + } /** * Returns the status code @@ -133,7 +149,9 @@ public function getReasonPhrase(): ?string {} * * @return int|null */ - public function getStatusCode(): ?int {} + public function getStatusCode(): ?int + { + } /** * Checks if a header exists @@ -145,14 +163,18 @@ public function getStatusCode(): ?int {} * @param string $name * @return bool */ - public function hasHeader(string $name): bool {} + public function hasHeader(string $name): bool + { + } /** * Check if the response is already sent * * @return bool */ - public function isSent(): bool {} + public function isSent(): bool + { + } /** * Redirect by HTTP to another action or URL @@ -178,7 +200,9 @@ public function isSent(): bool {} * @param int $statusCode * @return ResponseInterface */ - public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface {} + public function redirect($location = null, bool $externalRedirect = false, int $statusCode = 302): ResponseInterface + { + } /** * Remove a header in the response @@ -190,35 +214,45 @@ public function redirect($location = null, bool $externalRedirect = false, int $ * @param string $name * @return ResponseInterface */ - public function removeHeader(string $name): ResponseInterface {} + public function removeHeader(string $name): ResponseInterface + { + } /** * Resets all the established headers * * @return ResponseInterface */ - public function resetHeaders(): ResponseInterface {} + public function resetHeaders(): ResponseInterface + { + } /** * Prints out HTTP response to the client * * @return ResponseInterface */ - public function send(): ResponseInterface {} + public function send(): ResponseInterface + { + } /** * Sends cookies to the client * * @return ResponseInterface */ - public function sendCookies(): ResponseInterface {} + public function sendCookies(): ResponseInterface + { + } /** * Sends headers to the client * * @return bool|ResponseInterface */ - public function sendHeaders() {} + public function sendHeaders() + { + } /** * Sets Cache headers to use HTTP cache @@ -230,7 +264,9 @@ public function sendHeaders() {} * @param int $minutes * @return ResponseInterface */ - public function setCache(int $minutes): ResponseInterface {} + public function setCache(int $minutes): ResponseInterface + { + } /** * Sets HTTP response body @@ -242,7 +278,9 @@ public function setCache(int $minutes): ResponseInterface {} * @param string $content * @return ResponseInterface */ - public function setContent(string $content): ResponseInterface {} + public function setContent(string $content): ResponseInterface + { + } /** * Sets the response content-length @@ -254,7 +292,9 @@ public function setContent(string $content): ResponseInterface {} * @param int $contentLength * @return ResponseInterface */ - public function setContentLength(int $contentLength): ResponseInterface {} + public function setContentLength(int $contentLength): ResponseInterface + { + } /** * Sets the response content-type mime, optionally the charset @@ -268,7 +308,9 @@ public function setContentLength(int $contentLength): ResponseInterface {} * @param mixed $charset * @return ResponseInterface */ - public function setContentType(string $contentType, $charset = null): ResponseInterface {} + public function setContentType(string $contentType, $charset = null): ResponseInterface + { + } /** * Sets a cookies bag for the response externally @@ -276,14 +318,18 @@ public function setContentType(string $contentType, $charset = null): ResponseIn * @param \Phalcon\Http\Response\CookiesInterface $cookies * @return ResponseInterface */ - public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface {} + public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface + { + } /** * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Set a custom ETag @@ -299,7 +345,9 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} * @param string $etag * @return ResponseInterface */ - public function setEtag(string $etag): ResponseInterface {} + public function setEtag(string $etag): ResponseInterface + { + } /** * Sets an Expires header in the response that allows to use the HTTP cache @@ -313,14 +361,18 @@ public function setEtag(string $etag): ResponseInterface {} * @param \DateTime $datetime * @return ResponseInterface */ - public function setExpires(\DateTime $datetime): ResponseInterface {} + public function setExpires(\DateTime $datetime): ResponseInterface + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets an attached file to be sent at the end of the request @@ -330,7 +382,9 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * @param mixed $attachment * @return ResponseInterface */ - public function setFileToSend(string $filePath, $attachmentName = null, $attachment = true): ResponseInterface {} + public function setFileToSend(string $filePath, $attachmentName = null, $attachment = true): ResponseInterface + { + } /** * Overwrites a header in the response @@ -343,7 +397,9 @@ public function setFileToSend(string $filePath, $attachmentName = null, $attachm * @param mixed $value * @return ResponseInterface */ - public function setHeader(string $name, $value): ResponseInterface {} + public function setHeader(string $name, $value): ResponseInterface + { + } /** * Sets a headers bag for the response externally @@ -351,7 +407,9 @@ public function setHeader(string $name, $value): ResponseInterface {} * @param \Phalcon\Http\Response\HeadersInterface $headers * @return ResponseInterface */ - public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface {} + public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface + { + } /** * Sets HTTP response body. The parameter is automatically converted to JSON @@ -370,7 +428,9 @@ public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): Re * @param int $depth * @return ResponseInterface */ - public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512): ResponseInterface {} + public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512): ResponseInterface + { + } /** * Sets Last-Modified header @@ -384,14 +444,18 @@ public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512) * @param \DateTime $datetime * @return ResponseInterface */ - public function setLastModified(\DateTime $datetime): ResponseInterface {} + public function setLastModified(\DateTime $datetime): ResponseInterface + { + } /** * Sends a Not-Modified response * * @return ResponseInterface */ - public function setNotModified(): ResponseInterface {} + public function setNotModified(): ResponseInterface + { + } /** * Sets the HTTP response code @@ -404,7 +468,9 @@ public function setNotModified(): ResponseInterface {} * @param string $message * @return ResponseInterface */ - public function setStatusCode(int $code, string $message = null): ResponseInterface {} + public function setStatusCode(int $code, string $message = null): ResponseInterface + { + } /** * Send a raw header to the response @@ -416,6 +482,7 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf * @param string $header * @return ResponseInterface */ - public function setRawHeader(string $header): ResponseInterface {} - + public function setRawHeader(string $header): ResponseInterface + { + } } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index c9974ddc..98f28a57 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -193,5 +193,4 @@ public function sendCookies(): ResponseInterface; * @return bool|ResponseInterface */ public function sendHeaders(); - } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php index 45a52c69..5a878bc4 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -30,14 +30,18 @@ abstract class AbstractCommon * @param string $property * @return object */ - final protected function cloneInstance($element, string $property) {} + final protected function cloneInstance($element, string $property) + { + } /** * Checks the element passed if it is a string * * @param mixed $element */ - final protected function checkStringParameter($element) {} + final protected function checkStringParameter($element) + { + } /** * Checks the element passed; assigns it to the property and returns a @@ -49,6 +53,7 @@ final protected function checkStringParameter($element) {} * @param string $property * @return object */ - final protected function processWith($element, string $property) {} - + final protected function processWith($element, string $property) + { + } } diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/http/message/AbstractMessage.php index 693afd56..f62f4598 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/http/message/AbstractMessage.php @@ -66,7 +66,9 @@ abstract class AbstractMessage extends AbstractCommon * * @return */ - public function getBody() {} + public function getBody() + { + } /** * Retrieves the HTTP protocol version as a string. @@ -76,7 +78,9 @@ public function getBody() {} * * @return string */ - public function getProtocolVersion(): string {} + public function getProtocolVersion(): string + { + } /** * Retrieves the URI instance. @@ -85,7 +89,9 @@ public function getProtocolVersion(): string {} * * @return UriInterface */ - public function getUri() {} + public function getUri() + { + } /** * Retrieves a message header value by the given case-insensitive name. @@ -101,7 +107,9 @@ public function getUri() {} * @param mixed $name * @return array */ - public function getHeader($name): array {} + public function getHeader($name): array + { + } /** * Retrieves a comma-separated string of the values for a single header. @@ -122,7 +130,9 @@ public function getHeader($name): array {} * @param mixed $name * @return string */ - public function getHeaderLine($name): string {} + public function getHeaderLine($name): string + { + } /** * Retrieves all message header values. @@ -147,7 +157,9 @@ public function getHeaderLine($name): string {} * * @return array */ - public function getHeaders(): array {} + public function getHeaders(): array + { + } /** * Checks if a header exists by the given case-insensitive name. @@ -157,7 +169,9 @@ public function getHeaders(): array {} * @param mixed $name * @return bool */ - public function hasHeader($name): bool {} + public function hasHeader($name): bool + { + } /** * Return an instance with the specified header appended with the given @@ -177,7 +191,9 @@ public function hasHeader($name): bool {} * @param mixed $value * @return object */ - public function withAddedHeader($name, $value) {} + public function withAddedHeader($name, $value) + { + } /** * Return an instance with the specified message body. @@ -195,7 +211,9 @@ public function withAddedHeader($name, $value) {} * @param \Psr\Http\Message\StreamInterface $body * @return object */ - public function withBody(\Psr\Http\Message\StreamInterface $body) {} + public function withBody(\Psr\Http\Message\StreamInterface $body) + { + } /** * Return an instance with the provided value replacing the specified @@ -216,7 +234,9 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) {} * @param mixed $value * @return object */ - public function withHeader($name, $value) {} + public function withHeader($name, $value) + { + } /** * Return an instance with the specified HTTP protocol version. @@ -233,7 +253,9 @@ public function withHeader($name, $value) {} * @param mixed $version * @return object */ - public function withProtocolVersion($version) {} + public function withProtocolVersion($version) + { + } /** * Return an instance without the specified header. @@ -249,7 +271,9 @@ public function withProtocolVersion($version) {} * @param mixed $name * @return object */ - public function withoutHeader($name) {} + public function withoutHeader($name) + { + } /** * Ensure Host is the first header. @@ -261,7 +285,9 @@ public function withoutHeader($name) {} * @param \Phalcon\Collection $collection * @return \Phalcon\Collection */ - final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection {} + final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection + { + } /** * Check the name of the header. Throw exception if not valid @@ -271,7 +297,9 @@ final protected function checkHeaderHost(\Phalcon\Collection $collection): Colle * @param mixed $name * @param $name */ - final protected function checkHeaderName($name) {} + final protected function checkHeaderName($name) + { + } /** * Validates a header value @@ -321,7 +349,9 @@ final protected function checkHeaderName($name) {} * @param mixed $value * @param $value */ - final protected function checkHeaderValue($value) {} + final protected function checkHeaderValue($value) + { + } /** * Returns the header values checked for validity @@ -331,7 +361,9 @@ final protected function checkHeaderValue($value) {} * @param mixed $values * @return array */ - final protected function getHeaderValue($values): array {} + final protected function getHeaderValue($values): array + { + } /** * Return the host and if applicable the port @@ -341,7 +373,9 @@ final protected function getHeaderValue($values): array {} * @param \Psr\Http\Message\UriInterface $uri * @return string */ - final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string {} + final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string + { + } /** * Populates the header collection @@ -351,7 +385,9 @@ final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string * @param array $headers * @return \Phalcon\Collection */ - final protected function populateHeaderCollection(array $headers): Collection {} + final protected function populateHeaderCollection(array $headers): Collection + { + } /** * Set a valid stream @@ -362,7 +398,9 @@ final protected function populateHeaderCollection(array $headers): Collection {} * @param string $mode * @return \Psr\Http\Message\StreamInterface */ - final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface {} + final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface + { + } /** * Sets the headers @@ -372,7 +410,9 @@ final protected function processBody($body = 'php://memory', string $mode = 'r+b * @param mixed $headers * @return \Phalcon\Collection */ - final protected function processHeaders($headers): Collection {} + final protected function processHeaders($headers): Collection + { + } /** * Checks the protocol @@ -382,6 +422,7 @@ final protected function processHeaders($headers): Collection {} * @param mixed $protocol * @return string */ - final protected function processProtocol($protocol = ''): string {} - + final protected function processProtocol($protocol = ''): string + { + } } diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php index 6a86b5c7..d1f00345 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -54,7 +54,9 @@ abstract class AbstractRequest extends AbstractMessage * * @return string */ - public function getMethod(): string {} + public function getMethod(): string + { + } /** * Retrieves the URI instance. @@ -63,7 +65,9 @@ public function getMethod(): string {} * * @return UriInterface */ - public function getUri() {} + public function getUri() + { + } /** * Retrieves the message's request target. @@ -78,7 +82,9 @@ public function getUri() {} * * @return string */ - public function getRequestTarget(): string {} + public function getRequestTarget(): string + { + } /** * Return an instance with the provided HTTP method. @@ -98,7 +104,9 @@ public function getRequestTarget(): string {} * @param mixed $method * @return object */ - public function withMethod($method) {} + public function withMethod($method) + { + } /** * Return an instance with the specific request-target. @@ -120,7 +128,9 @@ public function withMethod($method) {} * @param mixed $requestTarget * @return object */ - public function withRequestTarget($requestTarget) {} + public function withRequestTarget($requestTarget) + { + } /** * Returns an instance with the provided URI. @@ -156,7 +166,9 @@ public function withRequestTarget($requestTarget) {} * @param mixed $preserveHost * @return object */ - public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) {} + public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) + { + } /** * Check the method @@ -166,7 +178,9 @@ public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = fal * @param mixed $method * @return string */ - final protected function processMethod($method = ''): string {} + final protected function processMethod($method = ''): string + { + } /** * Sets a valid Uri @@ -176,6 +190,7 @@ final protected function processMethod($method = ''): string {} * @param mixed $uri * @return \Psr\Http\Message\UriInterface */ - final protected function processUri($uri): UriInterface {} - + final protected function processUri($uri): UriInterface + { + } } diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/http/message/Request.php index 1f8f9cb8..7c1b5225 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/http/message/Request.php @@ -33,6 +33,7 @@ final class Request extends AbstractRequest implements RequestInterface * @param StreamInterface|resource|string $body * @param array $headers */ - public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) {} - + public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) + { + } } diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/http/message/RequestFactory.php index 6b3cd1d3..4f59948f 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/http/message/RequestFactory.php @@ -34,6 +34,7 @@ final class RequestFactory implements RequestFactoryInterface * @param mixed $uri * @return \Psr\Http\Message\RequestInterface */ - public function createRequest(string $method, $uri): RequestInterface {} - + public function createRequest(string $method, $uri): RequestInterface + { + } } diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/http/message/Response.php index cd401bcf..c4376a09 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/http/message/Response.php @@ -62,7 +62,9 @@ final class Response extends AbstractMessage implements ResponseInterface * * @return string */ - public function getReasonPhrase(): string {} + public function getReasonPhrase(): string + { + } /** * Gets the response status code. @@ -72,7 +74,9 @@ public function getReasonPhrase(): string {} * * @return int */ - public function getStatusCode(): int {} + public function getStatusCode(): int + { + } /** * Response constructor. @@ -81,7 +85,9 @@ public function getStatusCode(): int {} * @param int $code * @param array $headers */ - public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) {} + public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) + { + } /** * Return an instance with the specified status code and, optionally, @@ -104,28 +110,36 @@ public function __construct($body = 'php://memory', int $code = 200, array $head * @param mixed $reasonPhrase * @return Response */ - public function withStatus($code, $reasonPhrase = ''): Response {} + public function withStatus($code, $reasonPhrase = ''): Response + { + } /** * Checks if a code is integer or string * * @param mixed $code */ - private function checkCodeType($code) {} + private function checkCodeType($code) + { + } /** * Checks if a code is integer or string * * @param int $code */ - private function checkCodeValue(int $code) {} + private function checkCodeValue(int $code) + { + } /** * Returns the list of status codes available * * @return array */ - private function getPhrases(): array {} + private function getPhrases(): array + { + } /** * Set a valid status code and phrase @@ -133,6 +147,7 @@ private function getPhrases(): array {} * @param mixed $code * @param mixed $phrase */ - private function processCode($code, $phrase = '') {} - + private function processCode($code, $phrase = '') + { + } } diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/http/message/ResponseFactory.php index 98e588e7..2bc307a1 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/http/message/ResponseFactory.php @@ -36,6 +36,7 @@ final class ResponseFactory implements ResponseFactoryInterface * @param string $reasonPhrase * @return \Psr\Http\Message\ResponseInterface */ - public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface {} - + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + } } diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/http/message/ServerRequest.php index 7c1f2243..4d1ef8d7 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/http/message/ServerRequest.php @@ -109,7 +109,9 @@ final class ServerRequest extends AbstractRequest implements ServerRequestInterf * * @return array */ - public function getCookieParams(): array {} + public function getCookieParams(): array + { + } /** * Retrieve any parameters provided in the request body. @@ -125,7 +127,9 @@ public function getCookieParams(): array {} * * @return mixed */ - public function getParsedBody() {} + public function getParsedBody() + { + } /** * Retrieve query string arguments. @@ -139,7 +143,9 @@ public function getParsedBody() {} * * @return array */ - public function getQueryParams(): array {} + public function getQueryParams(): array + { + } /** * Retrieve server parameters. @@ -150,7 +156,9 @@ public function getQueryParams(): array {} * * @return array */ - public function getServerParams(): array {} + public function getServerParams(): array + { + } /** * Retrieve normalized file upload data. @@ -163,7 +171,9 @@ public function getServerParams(): array {} * * @return array */ - public function getUploadedFiles(): array {} + public function getUploadedFiles(): array + { + } /** * ServerRequest constructor. @@ -179,7 +189,9 @@ public function getUploadedFiles(): array {} * @param null|array|object $parsedBody * @param string $protocol */ - public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') {} + public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') + { + } /** * Retrieve a single derived request attribute. @@ -197,7 +209,9 @@ public function __construct(string $method = 'GET', $uri = null, array $serverPa * @param mixed $defaultValue * @return mixed */ - public function getAttribute($name, $defaultValue = null) {} + public function getAttribute($name, $defaultValue = null) + { + } /** * Retrieve attributes derived from the request. @@ -210,7 +224,9 @@ public function getAttribute($name, $defaultValue = null) {} * * @return array */ - public function getAttributes(): array {} + public function getAttributes(): array + { + } /** * Return an instance with the specified derived request attribute. @@ -228,7 +244,9 @@ public function getAttributes(): array {} * @param mixed $value * @return ServerRequest */ - public function withAttribute($name, $value): ServerRequest {} + public function withAttribute($name, $value): ServerRequest + { + } /** * Return an instance with the specified cookies. @@ -249,7 +267,9 @@ public function withAttribute($name, $value): ServerRequest {} * @param array $cookies * @return ServerRequest */ - public function withCookieParams(array $cookies): ServerRequest {} + public function withCookieParams(array $cookies): ServerRequest + { + } /** * Return an instance with the specified body parameters. @@ -280,7 +300,9 @@ public function withCookieParams(array $cookies): ServerRequest {} * @param mixed $data * @return ServerRequest */ - public function withParsedBody($data): ServerRequest {} + public function withParsedBody($data): ServerRequest + { + } /** * Return an instance with the specified query string arguments. @@ -305,7 +327,9 @@ public function withParsedBody($data): ServerRequest {} * @param array $query * @return ServerRequest */ - public function withQueryParams(array $query): ServerRequest {} + public function withQueryParams(array $query): ServerRequest + { + } /** * Create a new instance with the specified uploaded files. @@ -321,7 +345,9 @@ public function withQueryParams(array $query): ServerRequest {} * @param array $uploadedFiles * @return ServerRequest */ - public function withUploadedFiles(array $uploadedFiles): ServerRequest {} + public function withUploadedFiles(array $uploadedFiles): ServerRequest + { + } /** * Return an instance that removes the specified derived request attribute. @@ -338,13 +364,16 @@ public function withUploadedFiles(array $uploadedFiles): ServerRequest {} * @param mixed $name * @return ServerRequest */ - public function withoutAttribute($name): ServerRequest {} + public function withoutAttribute($name): ServerRequest + { + } /** * Checks the uploaded files * * @param array $files */ - private function checkUploadedFiles(array $files) {} - + private function checkUploadedFiles(array $files) + { + } } diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php index 815ac86e..1df04b28 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -52,7 +52,9 @@ class ServerRequestFactory implements ServerRequestFactoryInterface * @param array $serverParams * @return \Psr\Http\Message\ServerRequestInterface */ - public function createServerRequest(string $method, $uri, array $serverParams = array()): ServerRequestInterface {} + public function createServerRequest(string $method, $uri, array $serverParams = array()): ServerRequestInterface + { + } /** * Create a request from the supplied superglobal values. @@ -73,14 +75,18 @@ public function createServerRequest(string $method, $uri, array $serverParams = * @param array $files * @return \Phalcon\Http\Message\ServerRequest */ - public function load(array $server = null, array $get = null, array $post = null, array $cookies = null, array $files = null): ServerRequest {} + public function load(array $server = null, array $get = null, array $post = null, array $cookies = null, array $files = null): ServerRequest + { + } /** * Returns the apache_request_headers if it exists * * @return array|false */ - protected function getHeaders() {} + protected function getHeaders() + { + } /** * Calculates the host and port from the headers or the server superglobal @@ -91,7 +97,9 @@ protected function getHeaders() {} * @param \Phalcon\Collection $headers * @return array */ - private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collection $headers): array {} + private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collection $headers): array + { + } /** * Get the host and calculate the port if present from the header @@ -101,7 +109,9 @@ private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collecti * @param string $host * @return array */ - private function calculateUriHostFromHeader(string $host): array {} + private function calculateUriHostFromHeader(string $host): array + { + } /** * Get the path from the request from IIS7/Rewrite, REQUEST_URL or @@ -112,7 +122,9 @@ private function calculateUriHostFromHeader(string $host): array {} * @param \Phalcon\Collection $server * @return string */ - private function calculateUriPath(\Phalcon\Collection $server): string {} + private function calculateUriPath(\Phalcon\Collection $server): string + { + } /** * Get the query string from the server array @@ -122,7 +134,9 @@ private function calculateUriPath(\Phalcon\Collection $server): string {} * @param \Phalcon\Collection $server * @return string */ - private function calculateUriQuery(\Phalcon\Collection $server): string {} + private function calculateUriQuery(\Phalcon\Collection $server): string + { + } /** * Calculates the scheme from the server variables @@ -133,7 +147,9 @@ private function calculateUriQuery(\Phalcon\Collection $server): string {} * @param \Phalcon\Collection $headers * @return string */ - private function calculateUriScheme(\Phalcon\Collection $server, \Phalcon\Collection $headers): string {} + private function calculateUriScheme(\Phalcon\Collection $server, \Phalcon\Collection $headers): string + { + } /** * Checks the source if it null and returns the super, otherwise the source @@ -143,7 +159,9 @@ private function calculateUriScheme(\Phalcon\Collection $server, \Phalcon\Collec * @param array $super * @return array */ - private function checkNullArray($source, array $super): array {} + private function checkNullArray($source, array $super): array + { + } /** * Create an UploadedFile object from an $_FILES array element @@ -156,7 +174,9 @@ private function checkNullArray($source, array $super): array {} * @param array $file * @return \Phalcon\Http\Message\UploadedFile */ - private function createUploadedFile(array $file): UploadedFile {} + private function createUploadedFile(array $file): UploadedFile + { + } /** * Returns a header @@ -168,7 +188,9 @@ private function createUploadedFile(array $file): UploadedFile {} * @param mixed $defaultValue * @return mixed */ - private function getHeader(\Phalcon\Collection $headers, string $name, $defaultValue = null) {} + private function getHeader(\Phalcon\Collection $headers, string $name, $defaultValue = null) + { + } /** * Parse a cookie header according to RFC 6265. @@ -180,7 +202,9 @@ private function getHeader(\Phalcon\Collection $headers, string $name, $defaultV * @param string $cookieHeader * @return array */ - private function parseCookieHeader(string $cookieHeader): array {} + private function parseCookieHeader(string $cookieHeader): array + { + } /** * Processes headers from SAPI @@ -190,7 +214,9 @@ private function parseCookieHeader(string $cookieHeader): array {} * @param \Phalcon\Collection $server * @return \Phalcon\Collection */ - private function parseHeaders(\Phalcon\Collection $server): Collection {} + private function parseHeaders(\Phalcon\Collection $server): Collection + { + } /** * Parse the $_SERVER array amd return it back after looking for the @@ -202,7 +228,9 @@ private function parseHeaders(\Phalcon\Collection $server): Collection {} * @param array $server * @return \Phalcon\Collection */ - private function parseServer(array $server): Collection {} + private function parseServer(array $server): Collection + { + } /** * Traverses a $_FILES and creates UploadedFile objects from it. It is used @@ -213,7 +241,9 @@ private function parseServer(array $server): Collection {} * @param array $files * @return \Phalcon\Collection */ - private function parseUploadedFiles(array $files): Collection {} + private function parseUploadedFiles(array $files): Collection + { + } /** * Calculates the Uri from the server superglobal or the headers @@ -224,6 +254,7 @@ private function parseUploadedFiles(array $files): Collection {} * @param \Phalcon\Collection $headers * @return \Phalcon\Http\Message\Uri */ - private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri {} - + private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri + { + } } diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/http/message/Stream.php index 6085c3a6..22b0fd73 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/http/message/Stream.php @@ -44,12 +44,16 @@ class Stream implements StreamInterface * @param mixed $stream * @param string $mode */ - public function __construct($stream, string $mode = 'rb') {} + public function __construct($stream, string $mode = 'rb') + { + } /** * Closes the stream when the destructed. */ - public function __destruct() {} + public function __destruct() + { + } /** * Reads all data from the stream into a string, from the beginning to end. @@ -65,12 +69,16 @@ public function __destruct() {} * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Closes the stream and any underlying resources. */ - public function close() {} + public function close() + { + } /** * Separates any underlying resources from the stream. @@ -79,21 +87,27 @@ public function close() {} * * @return resource|null */ - public function detach() {} + public function detach() + { + } /** * Returns true if the stream is at the end of the stream. * * @return bool */ - public function eof(): bool {} + public function eof(): bool + { + } /** * Returns the remaining contents in a string * * @return string */ - public function getContents(): string {} + public function getContents(): string + { + } /** * Get stream metadata as an associative array or retrieve a specific key. @@ -106,35 +120,45 @@ public function getContents(): string {} * @param mixed $key * @return array|mixed|null */ - public function getMetadata($key = null) {} + public function getMetadata($key = null) + { + } /** * Get the size of the stream if known. * * @return null|int */ - public function getSize(): ?int {} + public function getSize(): ?int + { + } /** * Returns whether or not the stream is readable. * * @return bool */ - public function isReadable(): bool {} + public function isReadable(): bool + { + } /** * Returns whether or not the stream is seekable. * * @return bool */ - public function isSeekable(): bool {} + public function isSeekable(): bool + { + } /** * Returns whether or not the stream is writable. * * @return bool */ - public function isWritable(): bool {} + public function isWritable(): bool + { + } /** * Read data from the stream. @@ -144,7 +168,9 @@ public function isWritable(): bool {} * @param mixed $length * @return string */ - public function read($length): string {} + public function read($length): string + { + } /** * Seek to the beginning of the stream. @@ -152,7 +178,9 @@ public function read($length): string {} * If the stream is not seekable, this method will raise an exception; * otherwise, it will perform a seek(0). */ - public function rewind() {} + public function rewind() + { + } /** * Seek to a position in the stream. @@ -160,7 +188,9 @@ public function rewind() {} * @param int $offset * @param int $whence */ - public function seek($offset, $whence = 0) {} + public function seek($offset, $whence = 0) + { + } /** * Sets the stream - existing instance @@ -168,14 +198,18 @@ public function seek($offset, $whence = 0) {} * @param mixed $stream * @param string $mode */ - public function setStream($stream, string $mode = 'rb') {} + public function setStream($stream, string $mode = 'rb') + { + } /** * Returns the current position of the file read/write pointer * * @return int */ - public function tell(): int {} + public function tell(): int + { + } /** * Write data to the stream. @@ -185,26 +219,35 @@ public function tell(): int {} * @param mixed $data * @return int */ - public function write($data): int {} + public function write($data): int + { + } /** * Checks if a handle is available and throws an exception otherwise */ - private function checkHandle() {} + private function checkHandle() + { + } /** * Checks if a handle is readable and throws an exception otherwise */ - private function checkReadable() {} + private function checkReadable() + { + } /** * Checks if a handle is seekable and throws an exception otherwise */ - private function checkSeekable() {} + private function checkSeekable() + { + } /** * Checks if a handle is writeable and throws an exception otherwise */ - private function checkWritable() {} - + private function checkWritable() + { + } } diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/http/message/StreamFactory.php index 0795e955..da6b8b0c 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/http/message/StreamFactory.php @@ -34,7 +34,9 @@ final class StreamFactory implements StreamFactoryInterface * @param string $content * @return \Psr\Http\Message\StreamInterface */ - public function createStream(string $content = ''): StreamInterface {} + public function createStream(string $content = ''): StreamInterface + { + } /** * Create a stream from an existing file. @@ -53,7 +55,9 @@ public function createStream(string $content = ''): StreamInterface {} * @param string $mode * @return \Psr\Http\Message\StreamInterface */ - public function createStreamFromFile(string $filename, string $mode = 'r+b'): StreamInterface {} + public function createStreamFromFile(string $filename, string $mode = 'r+b'): StreamInterface + { + } /** * Create a new stream from an existing resource. @@ -63,6 +67,7 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St * @param mixed $phpResource * @return \Psr\Http\Message\StreamInterface */ - public function createStreamFromResource($phpResource): StreamInterface {} - + public function createStreamFromResource($phpResource): StreamInterface + { + } } diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/http/message/UploadedFile.php index f5581b31..7a8a81fc 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/http/message/UploadedFile.php @@ -115,7 +115,9 @@ final class UploadedFile implements UploadedFileInterface * * @return string|null */ - public function getClientFilename(): ?string {} + public function getClientFilename(): ?string + { + } /** * Retrieve the media type sent by the client. @@ -129,7 +131,9 @@ public function getClientFilename(): ?string {} * * @return string|null */ - public function getClientMediaType(): ?string {} + public function getClientMediaType(): ?string + { + } /** * Retrieve the error associated with the uploaded file. @@ -144,7 +148,9 @@ public function getClientMediaType(): ?string {} * * @return int */ - public function getError(): int {} + public function getError(): int + { + } /** * Retrieve the file size. @@ -155,7 +161,9 @@ public function getError(): int {} * * @return int|null */ - public function getSize(): ?int {} + public function getSize(): ?int + { + } /** * UploadedFile constructor. @@ -166,7 +174,9 @@ public function getSize(): ?int {} * @param string|null $clientFilename * @param string|null $clientMediaType */ - public function __construct($stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null) {} + public function __construct($stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null) + { + } /** * Retrieve a stream representing the uploaded file. @@ -183,7 +193,9 @@ public function __construct($stream, int $size = null, int $error = 0, string $c * @throws RuntimeException in cases when no stream is available or can be created. * @return mixed */ - public function getStream() {} + public function getStream() + { + } /** * Move the uploaded file to a new location. @@ -220,14 +232,18 @@ public function getStream() {} * the second or subsequent call to the method. * @param mixed $targetPath */ - public function moveTo($targetPath) {} + public function moveTo($targetPath) + { + } /** * Checks the passed error code and if not in the range throws an exception * * @param int $error */ - private function checkError(int $error) {} + private function checkError(int $error) + { + } /** * Checks the passed error code and if not in the range throws an exception @@ -235,7 +251,9 @@ private function checkError(int $error) {} * @param StreamInterface|resource|string $stream * @param int $error */ - private function checkStream($stream, int $error) {} + private function checkStream($stream, int $error) + { + } /** * Returns a description string depending on the upload error code passed @@ -245,13 +263,16 @@ private function checkStream($stream, int $error) {} * @param int $error * @return string */ - private function getErrorDescription(int $error): string {} + private function getErrorDescription(int $error): string + { + } /** * Store a file in the new location (stream) * * @param string $targetPath */ - private function storeFile(string $targetPath) {} - + private function storeFile(string $targetPath) + { + } } diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/http/message/UploadedFileFactory.php index 158a0bc8..8234c89c 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/http/message/UploadedFileFactory.php @@ -46,6 +46,7 @@ final class UploadedFileFactory implements UploadedFileFactoryInterface * @param string $clientMediaType * @return \Psr\Http\Message\UploadedFileInterface */ - public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface {} - + public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface + { + } } diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/http/message/Uri.php index 41e46a17..74833d9d 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/http/message/Uri.php @@ -106,7 +106,9 @@ final class Uri extends AbstractCommon implements UriInterface /** * Returns the fragment of the URL */ - public function getFragment() {} + public function getFragment() + { + } /** * Retrieve the host component of the URI. @@ -116,12 +118,16 @@ public function getFragment() {} * The value returned MUST be normalized to lowercase, per RFC 3986 * Section 3.2.2. */ - public function getHost() {} + public function getHost() + { + } /** * Returns the path of the URL */ - public function getPath() {} + public function getPath() + { + } /** * Retrieve the port component of the URI. @@ -136,12 +142,16 @@ public function getPath() {} * If no port is present, but a scheme is present, this method MAY return * the standard port for that scheme, but SHOULD return null. */ - public function getPort() {} + public function getPort() + { + } /** * Returns the query of the URL */ - public function getQuery() {} + public function getQuery() + { + } /** * Retrieve the scheme component of the URI. @@ -154,14 +164,18 @@ public function getQuery() {} * The trailing ":" character is not part of the scheme and MUST NOT be * added. */ - public function getScheme() {} + public function getScheme() + { + } /** * Uri constructor. * * @param string $uri */ - public function __construct(string $uri = '') {} + public function __construct(string $uri = '') + { + } /** * Return the string representation as a URI reference. @@ -173,14 +187,18 @@ public function __construct(string $uri = '') {} * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Retrieve the authority component of the URI. * * @return string */ - public function getAuthority(): string {} + public function getAuthority(): string + { + } /** * Retrieve the user information component of the URI. @@ -197,7 +215,9 @@ public function getAuthority(): string {} * * @return string */ - public function getUserInfo(): string {} + public function getUserInfo(): string + { + } /** * Return an instance with the specified URI fragment. @@ -215,7 +235,9 @@ public function getUserInfo(): string {} * @param mixed $fragment * @return Uri */ - public function withFragment($fragment): Uri {} + public function withFragment($fragment): Uri + { + } /** * Return an instance with the specified path. @@ -241,7 +263,9 @@ public function withFragment($fragment): Uri {} * @param mixed $path * @return Uri */ - public function withPath($path): Uri {} + public function withPath($path): Uri + { + } /** * Return an instance with the specified port. @@ -261,7 +285,9 @@ public function withPath($path): Uri {} * @param mixed $port * @return Uri */ - public function withPort($port): Uri {} + public function withPort($port): Uri + { + } /** * Return an instance with the specified query string. @@ -280,7 +306,9 @@ public function withPort($port): Uri {} * @param mixed $query * @return Uri */ - public function withQuery($query): Uri {} + public function withQuery($query): Uri + { + } /** * Return an instance with the specified scheme. @@ -300,7 +328,9 @@ public function withQuery($query): Uri {} * @param mixed $scheme * @return Uri */ - public function withScheme($scheme): Uri {} + public function withScheme($scheme): Uri + { + } /** * Return an instance with the specified user information. @@ -311,7 +341,9 @@ public function withScheme($scheme): Uri {} * @param mixed $password * @return Uri */ - public function withUserInfo($user, $password = null): Uri {} + public function withUserInfo($user, $password = null): Uri + { + } /** * Return an instance with the specified host. @@ -328,7 +360,9 @@ public function withUserInfo($user, $password = null): Uri {} * @param mixed $host * @return Uri */ - public function withHost($host): Uri {} + public function withHost($host): Uri + { + } /** * If the value passed is empty it returns it prefixed and suffixed with @@ -341,7 +375,9 @@ public function withHost($host): Uri {} * @param string $suffix * @return string */ - private function checkValue(string $value, string $prefix = '', string $suffix = ''): string {} + private function checkValue(string $value, string $prefix = '', string $suffix = ''): string + { + } /** * If no fragment is present, this method MUST return an empty string. @@ -361,7 +397,9 @@ private function checkValue(string $value, string $prefix = '', string $suffix = * @param string $fragment * @return string */ - private function filterFragment(string $fragment): string {} + private function filterFragment(string $fragment): string + { + } /** * @@ -391,7 +429,9 @@ private function filterFragment(string $fragment): string {} * @param string $path * @return string */ - private function filterPath(string $path): string {} + private function filterPath(string $path): string + { + } /** * Checks the port. If it is a standard one (80,443) then it returns null @@ -401,7 +441,9 @@ private function filterPath(string $path): string {} * @param mixed $port * @return int */ - private function filterPort($port): int {} + private function filterPort($port): int + { + } /** * If no query string is present, this method MUST return an empty string. @@ -425,7 +467,9 @@ private function filterPort($port): int {} * @param string $query * @return string */ - private function filterQuery(string $query): string {} + private function filterQuery(string $query): string + { + } /** * Filters the passed scheme - only allowed schemes @@ -435,7 +479,9 @@ private function filterQuery(string $query): string {} * @param string $scheme * @return string */ - private function filterScheme(string $scheme): string {} + private function filterScheme(string $scheme): string + { + } /** * @param string $element @@ -443,6 +489,7 @@ private function filterScheme(string $scheme): string {} * @param string $element * @return array */ - private function splitQueryValue(string $element): array {} - + private function splitQueryValue(string $element): array + { + } } diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/http/message/UriFactory.php index c67ba3ab..568410a1 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/http/message/UriFactory.php @@ -31,6 +31,7 @@ final class UriFactory implements UriFactoryInterface * @param string $uri * @return \Psr\Http\Message\UriInterface */ - public function createUri(string $uri = ''): UriInterface {} - + public function createUri(string $uri = ''): UriInterface + { + } } diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php index 8bd3bb86..ccba5c0a 100644 --- a/src/Phalcon/http/message/stream/Input.php +++ b/src/Phalcon/http/message/stream/Input.php @@ -40,7 +40,9 @@ class Input extends Stream /** * Input constructor. */ - public function __construct() {} + public function __construct() + { + } /** * Reads all data from the stream into a string, from the beginning to end. @@ -56,7 +58,9 @@ public function __construct() {} * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Returns the remaining contents in a string @@ -69,14 +73,18 @@ public function __toString(): string {} * @param int $length * @return string */ - public function getContents(int $length = -1): string {} + public function getContents(int $length = -1): string + { + } /** * Returns whether or not the stream is writeable. * * @return bool */ - public function isWritable(): bool {} + public function isWritable(): bool + { + } /** * Read data from the stream. @@ -86,6 +94,7 @@ public function isWritable(): bool {} * @param mixed $length * @return string */ - public function read($length): string {} - + public function read($length): string + { + } } diff --git a/src/Phalcon/http/message/stream/Memory.php b/src/Phalcon/http/message/stream/Memory.php index a2c7a765..d064f585 100644 --- a/src/Phalcon/http/message/stream/Memory.php +++ b/src/Phalcon/http/message/stream/Memory.php @@ -32,6 +32,7 @@ class Memory extends Stream * * @param mixed $mode */ - public function __construct($mode = 'rb') {} - + public function __construct($mode = 'rb') + { + } } diff --git a/src/Phalcon/http/message/stream/Temp.php b/src/Phalcon/http/message/stream/Temp.php index d79f1f1e..a741f786 100644 --- a/src/Phalcon/http/message/stream/Temp.php +++ b/src/Phalcon/http/message/stream/Temp.php @@ -32,6 +32,7 @@ class Temp extends Stream * * @param mixed $mode */ - public function __construct($mode = 'rb') {} - + public function __construct($mode = 'rb') + { + } } diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/http/request/File.php index 56524bff..29566fd4 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/http/request/File.php @@ -70,17 +70,23 @@ class File implements FileInterface /** * @return string|null */ - public function getError(): ?string {} + public function getError(): ?string + { + } /** * @return string */ - public function getExtension(): string {} + public function getExtension(): string + { + } /** * @return string|null */ - public function getKey(): ?string {} + public function getKey(): ?string + { + } /** * Phalcon\Http\Request\File constructor @@ -88,35 +94,45 @@ public function getKey(): ?string {} * @param array $file * @param mixed $key */ - public function __construct(array $file, $key = null) {} + public function __construct(array $file, $key = null) + { + } /** * Returns the real name of the uploaded file * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Gets the real mime type of the upload file using finfo * * @return string */ - public function getRealType(): string {} + public function getRealType(): string + { + } /** * Returns the file size of the uploaded file * * @return int */ - public function getSize(): int {} + public function getSize(): int + { + } /** * Returns the temporary name of the uploaded file * * @return string */ - public function getTempName(): string {} + public function getTempName(): string + { + } /** * Returns the mime type reported by the browser @@ -124,14 +140,18 @@ public function getTempName(): string {} * * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * Checks whether the file has been uploaded via Post. * * @return bool */ - public function isUploadedFile(): bool {} + public function isUploadedFile(): bool + { + } /** * Moves the temporary file to a destination within the application @@ -139,6 +159,7 @@ public function isUploadedFile(): bool {} * @param string $destination * @return bool */ - public function moveTo(string $destination): bool {} - + public function moveTo(string $destination): bool + { + } } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 13694730..63f39b41 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -63,5 +63,4 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; - } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 4c0ebad5..16798e8c 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -87,7 +87,9 @@ class Cookies extends AbstractInjectionAware implements CookiesInterface * @param bool $useEncryption * @param string $signKey */ - public function __construct(bool $useEncryption = true, string $signKey = null) {} + public function __construct(bool $useEncryption = true, string $signKey = null) + { + } /** * Deletes a cookie by its name @@ -96,7 +98,9 @@ public function __construct(bool $useEncryption = true, string $signKey = null) * @param string $name * @return bool */ - public function delete(string $name): bool {} + public function delete(string $name): bool + { + } /** * Gets a cookie from the bag @@ -104,14 +108,18 @@ public function delete(string $name): bool {} * @param string $name * @return \Phalcon\Http\CookieInterface */ - public function get(string $name): CookieInterface {} + public function get(string $name): CookieInterface + { + } /** * Gets all cookies from the bag * * @return array */ - public function getCookies(): array {} + public function getCookies(): array + { + } /** * Check if a cookie is defined in the bag or exists in the _COOKIE @@ -120,21 +128,27 @@ public function getCookies(): array {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Returns if the bag is automatically encrypting/decrypting cookies * * @return bool */ - public function isUsingEncryption(): bool {} + public function isUsingEncryption(): bool + { + } /** * Reset set cookies * * @return \Phalcon\Http\Response\CookiesInterface */ - public function reset(): CookiesInterface {} + public function reset(): CookiesInterface + { + } /** * Sends the cookies to the client @@ -142,7 +156,9 @@ public function reset(): CookiesInterface {} * * @return bool */ - public function send(): bool {} + public function send(): bool + { + } /** * Sets a cookie to be sent at the end of the request. @@ -172,7 +188,9 @@ public function send(): bool {} * @param bool $httpOnly * @return \Phalcon\Http\Response\CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface {} + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface + { + } /** * Sets the cookie's sign key. @@ -186,7 +204,9 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @param string $signKey * @return \Phalcon\Http\CookieInterface */ - public function setSignKey(string $signKey = null): CookieInterface {} + public function setSignKey(string $signKey = null): CookieInterface + { + } /** * Set if cookies in the bag must be automatically encrypted/decrypted @@ -194,6 +214,7 @@ public function setSignKey(string $signKey = null): CookieInterface {} * @param bool $useEncryption * @return \Phalcon\Http\Response\CookiesInterface */ - public function useEncryption(bool $useEncryption): CookiesInterface {} - + public function useEncryption(bool $useEncryption): CookiesInterface + { + } } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index 8a9f444a..841d459e 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -88,5 +88,4 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; - } diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index b85d7655..26de8a59 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -28,7 +28,9 @@ class Headers implements HeadersInterface * @param string $name * @return string|bool */ - public function get(string $name) {} + public function get(string $name) + { + } /** * Sets a header to be sent at the end of the request @@ -36,7 +38,9 @@ public function get(string $name) {} * @param string $name * @return bool */ - public function has(string $name): bool {} + public function has(string $name): bool + { + } /** * Removes a header to be sent at the end of the request @@ -44,19 +48,25 @@ public function has(string $name): bool {} * @param string $header * @return \Phalcon\Http\Response\HeadersInterface */ - public function remove(string $header): HeadersInterface {} + public function remove(string $header): HeadersInterface + { + } /** * Reset set headers */ - public function reset() {} + public function reset() + { + } /** * Sends the headers to the client * * @return bool */ - public function send(): bool {} + public function send(): bool + { + } /** * Sets a header to be sent at the end of the request @@ -65,7 +75,9 @@ public function send(): bool {} * @param string $value * @return \Phalcon\Http\Response\HeadersInterface */ - public function set(string $name, string $value): HeadersInterface {} + public function set(string $name, string $value): HeadersInterface + { + } /** * Sets a raw header to be sent at the end of the request @@ -73,13 +85,16 @@ public function set(string $name, string $value): HeadersInterface {} * @param string $header * @return \Phalcon\Http\Response\HeadersInterface */ - public function setRaw(string $header): HeadersInterface {} + public function setRaw(string $header): HeadersInterface + { + } /** * Returns the current headers as an array * * @return array */ - public function toArray(): array {} - + public function toArray(): array + { + } } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index d1aee9cf..8a7e218e 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -61,5 +61,4 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); - } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php index e160d1cc..264df34b 100644 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -38,5 +38,4 @@ abstract class AbstractMiddleware implements MiddlewareInterface * @return \Psr\Http\Message\ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; - } diff --git a/src/Phalcon/http/server/AbstractRequestHandler.php b/src/Phalcon/http/server/AbstractRequestHandler.php index 5bf1e601..8fb30df7 100644 --- a/src/Phalcon/http/server/AbstractRequestHandler.php +++ b/src/Phalcon/http/server/AbstractRequestHandler.php @@ -33,5 +33,4 @@ abstract class AbstractRequestHandler implements RequestHandlerInterface * @return \Psr\Http\Message\ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; - } diff --git a/src/Phalcon/image/Enum.php b/src/Phalcon/image/Enum.php index ef2aad5c..deab9c3d 100644 --- a/src/Phalcon/image/Enum.php +++ b/src/Phalcon/image/Enum.php @@ -39,6 +39,4 @@ class Enum const VERTICAL = 12; - - } diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php index 88a27cae..06cf0768 100644 --- a/src/Phalcon/image/ImageFactory.php +++ b/src/Phalcon/image/ImageFactory.php @@ -25,7 +25,9 @@ class ImageFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Factory to create an instace from a Config object @@ -33,7 +35,9 @@ public function __construct(array $services = array()) {} * @param mixed $config * @return \Phalcon\Image\Adapter\AdapterInterface */ - public function load($config): AdapterInterface {} + public function load($config): AdapterInterface + { + } /** * Creates a new instance @@ -44,11 +48,14 @@ public function load($config): AdapterInterface {} * @param int $height * @return \Phalcon\Image\Adapter\AdapterInterface */ - public function newInstance(string $name, string $file, int $width = null, int $height = null): AdapterInterface {} + public function newInstance(string $name, string $file, int $width = null, int $height = null): AdapterInterface + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/image/adapter/AbstractAdapter.php index eb8ce44a..9738f830 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/image/adapter/AbstractAdapter.php @@ -21,7 +21,7 @@ abstract class AbstractAdapter implements AdapterInterface { - static protected $checked = false; + protected static $checked = false; protected $file; @@ -68,20 +68,28 @@ abstract class AbstractAdapter implements AdapterInterface * * @return int */ - public function getHeight(): int {} + public function getHeight(): int + { + } - public function getImage() {} + public function getImage() + { + } /** * Image mime type * * @return string */ - public function getMime(): string {} + public function getMime(): string + { + } - public function getRealpath() {} + public function getRealpath() + { + } /** * Image type @@ -90,14 +98,18 @@ public function getRealpath() {} * * @return int */ - public function getType(): int {} + public function getType(): int + { + } /** * Image width * * @return int */ - public function getWidth(): int {} + public function getWidth(): int + { + } /** * Set the background color of an image @@ -106,7 +118,9 @@ public function getWidth(): int {} * @param int $opacity * @return AdapterInterface */ - public function background(string $color, int $opacity = 100): AdapterInterface {} + public function background(string $color, int $opacity = 100): AdapterInterface + { + } /** * Blur image @@ -114,7 +128,9 @@ public function background(string $color, int $opacity = 100): AdapterInterface * @param int $radius * @return AdapterInterface */ - public function blur(int $radius): AdapterInterface {} + public function blur(int $radius): AdapterInterface + { + } /** * Crop an image to the given size @@ -125,7 +141,9 @@ public function blur(int $radius): AdapterInterface {} * @param int $offsetY * @return AdapterInterface */ - public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null): AdapterInterface {} + public function crop(int $width, int $height, int $offsetX = null, int $offsetY = null): AdapterInterface + { + } /** * Flip the image along the horizontal or vertical axis @@ -133,7 +151,9 @@ public function crop(int $width, int $height, int $offsetX = null, int $offsetY * @param int $direction * @return AdapterInterface */ - public function flip(int $direction): AdapterInterface {} + public function flip(int $direction): AdapterInterface + { + } /** * This method scales the images using liquid rescaling method. Only support @@ -145,7 +165,9 @@ public function flip(int $direction): AdapterInterface {} * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. * @return AbstractAdapter */ - public function liquidRescale(int $width, int $height, int $deltaX = 0, int $rigidity = 0): AbstractAdapter {} + public function liquidRescale(int $width, int $height, int $deltaX = 0, int $rigidity = 0): AbstractAdapter + { + } /** * Composite one image onto another @@ -153,7 +175,9 @@ public function liquidRescale(int $width, int $height, int $deltaX = 0, int $rig * @param AdapterInterface $watermark * @return AdapterInterface */ - public function mask(AdapterInterface $watermark): AdapterInterface {} + public function mask(AdapterInterface $watermark): AdapterInterface + { + } /** * Pixelate image @@ -161,7 +185,9 @@ public function mask(AdapterInterface $watermark): AdapterInterface {} * @param int $amount * @return AdapterInterface */ - public function pixelate(int $amount): AdapterInterface {} + public function pixelate(int $amount): AdapterInterface + { + } /** * Add a reflection to an image @@ -171,7 +197,9 @@ public function pixelate(int $amount): AdapterInterface {} * @param bool $fadeIn * @return AdapterInterface */ - public function reflection(int $height, int $opacity = 100, bool $fadeIn = false): AdapterInterface {} + public function reflection(int $height, int $opacity = 100, bool $fadeIn = false): AdapterInterface + { + } /** * Render the image and return the binary string @@ -180,7 +208,9 @@ public function reflection(int $height, int $opacity = 100, bool $fadeIn = false * @param int $quality * @return string */ - public function render(string $ext = null, int $quality = 100): string {} + public function render(string $ext = null, int $quality = 100): string + { + } /** * Resize the image to the given size @@ -190,7 +220,9 @@ public function render(string $ext = null, int $quality = 100): string {} * @param int $master * @return AdapterInterface */ - public function resize(int $width = null, int $height = null, int $master = Enum::AUTO): AdapterInterface {} + public function resize(int $width = null, int $height = null, int $master = Enum::AUTO): AdapterInterface + { + } /** * Rotate the image by a given amount @@ -198,7 +230,9 @@ public function resize(int $width = null, int $height = null, int $master = Enum * @param int $degrees * @return AdapterInterface */ - public function rotate(int $degrees): AdapterInterface {} + public function rotate(int $degrees): AdapterInterface + { + } /** * Save the image @@ -207,7 +241,9 @@ public function rotate(int $degrees): AdapterInterface {} * @param int $quality * @return AdapterInterface */ - public function save(string $file = null, int $quality = -1): AdapterInterface {} + public function save(string $file = null, int $quality = -1): AdapterInterface + { + } /** * Sharpen the image by a given amount @@ -215,7 +251,9 @@ public function save(string $file = null, int $quality = -1): AdapterInterface { * @param int $amount * @return AdapterInterface */ - public function sharpen(int $amount): AdapterInterface {} + public function sharpen(int $amount): AdapterInterface + { + } /** * Add a text to an image with a specified opacity @@ -229,7 +267,9 @@ public function sharpen(int $amount): AdapterInterface {} * @param string $fontfile * @return AdapterInterface */ - public function text(string $text, $offsetX = false, $offsetY = false, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null): AdapterInterface {} + public function text(string $text, $offsetX = false, $offsetY = false, int $opacity = 100, string $color = '000000', int $size = 12, string $fontfile = null): AdapterInterface + { + } /** * Add a watermark to an image with the specified opacity @@ -240,6 +280,7 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac * @param int $opacity * @return AdapterInterface */ - public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface {} - + public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface + { + } } diff --git a/src/Phalcon/image/adapter/AdapterInterface.php b/src/Phalcon/image/adapter/AdapterInterface.php index 96886a82..0422bf22 100644 --- a/src/Phalcon/image/adapter/AdapterInterface.php +++ b/src/Phalcon/image/adapter/AdapterInterface.php @@ -118,5 +118,4 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; - } diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index 0e3715c3..85a0f90c 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -14,7 +14,7 @@ class Gd extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; /** @@ -22,20 +22,28 @@ class Gd extends AbstractAdapter * @param int $width * @param int $height */ - public function __construct(string $file, int $width = null, int $height = null) {} + public function __construct(string $file, int $width = null, int $height = null) + { + } - public function __destruct() {} + public function __destruct() + { + } /** * @return bool */ - public static function check(): bool {} + public static function check(): bool + { + } /** * @return string */ - public static function getVersion(): string {} + public static function getVersion(): string + { + } /** * @param int $r @@ -43,18 +51,24 @@ public static function getVersion(): string {} * @param int $b * @param int $opacity */ - protected function processBackground(int $r, int $g, int $b, int $opacity) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) + { + } /** * @param int $radius */ - protected function processBlur(int $radius) {} + protected function processBlur(int $radius) + { + } /** * @param int $width * @param int $height */ - protected function processCreate(int $width, int $height) {} + protected function processCreate(int $width, int $height) + { + } /** * @param int $width @@ -62,57 +76,77 @@ protected function processCreate(int $width, int $height) {} * @param int $offsetX * @param int $offsetY */ - protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) + { + } /** * @param int $direction */ - protected function processFlip(int $direction) {} + protected function processFlip(int $direction) + { + } /** * @param AdapterInterface $mask */ - protected function processMask(AdapterInterface $mask) {} + protected function processMask(AdapterInterface $mask) + { + } /** * @param int $amount */ - protected function processPixelate(int $amount) {} + protected function processPixelate(int $amount) + { + } /** * @param int $height * @param int $opacity * @param bool $fadeIn */ - protected function processReflection(int $height, int $opacity, bool $fadeIn) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) + { + } /** * @param string $ext * @param int $quality */ - protected function processRender(string $ext, int $quality) {} + protected function processRender(string $ext, int $quality) + { + } /** * @param int $width * @param int $height */ - protected function processResize(int $width, int $height) {} + protected function processResize(int $width, int $height) + { + } /** * @param int $degrees */ - protected function processRotate(int $degrees) {} + protected function processRotate(int $degrees) + { + } /** * @param string $file * @param int $quality */ - protected function processSave(string $file, int $quality) {} + protected function processSave(string $file, int $quality) + { + } /** * @param int $amount */ - protected function processSharpen(int $amount) {} + protected function processSharpen(int $amount) + { + } /** * @param string $text @@ -125,7 +159,9 @@ protected function processSharpen(int $amount) {} * @param int $size * @param string $fontfile */ - protected function processText(string $text, int $offsetX, int $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} + protected function processText(string $text, int $offsetX, int $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) + { + } /** * @param AdapterInterface $watermark @@ -133,6 +169,7 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op * @param int $offsetY * @param int $opacity */ - protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) {} - + protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) + { + } } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 5599ec72..9dd873a6 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -31,10 +31,10 @@ class Imagick extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; - static protected $version = 0; + protected static $version = 0; /** @@ -44,26 +44,34 @@ class Imagick extends AbstractAdapter * @param int $width * @param int $height */ - public function __construct(string $file, int $width = null, int $height = null) {} + public function __construct(string $file, int $width = null, int $height = null) + { + } /** * Destroys the loaded image to free up resources. */ - public function __destruct() {} + public function __destruct() + { + } /** * Checks if Imagick is enabled * * @return bool */ - public static function check(): bool {} + public static function check(): bool + { + } /** * Get instance * * @return \Imagick */ - public function getInternalImInstance(): ImagicNative {} + public function getInternalImInstance(): ImagicNative + { + } /** * Sets the limit for a particular resource in megabytes @@ -72,7 +80,9 @@ public function getInternalImInstance(): ImagicNative {} * @param int $type * @param int $limit */ - public function setResourceLimit(int $type, int $limit) {} + public function setResourceLimit(int $type, int $limit) + { + } /** * Execute a background. @@ -82,14 +92,18 @@ public function setResourceLimit(int $type, int $limit) {} * @param int $b * @param int $opacity */ - protected function processBackground(int $r, int $g, int $b, int $opacity) {} + protected function processBackground(int $r, int $g, int $b, int $opacity) + { + } /** * Blur image * * @param int $radius Blur radius */ - protected function processBlur(int $radius) {} + protected function processBlur(int $radius) + { + } /** * Execute a crop. @@ -99,14 +113,18 @@ protected function processBlur(int $radius) {} * @param int $offsetX * @param int $offsetY */ - protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) {} + protected function processCrop(int $width, int $height, int $offsetX, int $offsetY) + { + } /** * Execute a flip. * * @param int $direction */ - protected function processFlip(int $direction) {} + protected function processFlip(int $direction) + { + } /** * This method scales the images using liquid rescaling method. Only support @@ -117,21 +135,27 @@ protected function processFlip(int $direction) {} * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ - protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) {} + protected function processLiquidRescale(int $width, int $height, int $deltaX, int $rigidity) + { + } /** * Composite one image onto another * * @param AdapterInterface $image */ - protected function processMask(AdapterInterface $image) {} + protected function processMask(AdapterInterface $image) + { + } /** * Pixelate image * * @param int $amount amount to pixelate */ - protected function processPixelate(int $amount) {} + protected function processPixelate(int $amount) + { + } /** * Execute a reflection. @@ -140,7 +164,9 @@ protected function processPixelate(int $amount) {} * @param int $opacity * @param bool $fadeIn */ - protected function processReflection(int $height, int $opacity, bool $fadeIn) {} + protected function processReflection(int $height, int $opacity, bool $fadeIn) + { + } /** * Execute a render. @@ -149,7 +175,9 @@ protected function processReflection(int $height, int $opacity, bool $fadeIn) {} * @param int $quality * @return string */ - protected function processRender(string $extension, int $quality): string {} + protected function processRender(string $extension, int $quality): string + { + } /** * Execute a resize. @@ -157,14 +185,18 @@ protected function processRender(string $extension, int $quality): string {} * @param int $width * @param int $height */ - protected function processResize(int $width, int $height) {} + protected function processResize(int $width, int $height) + { + } /** * Execute a rotation. * * @param int $degrees */ - protected function processRotate(int $degrees) {} + protected function processRotate(int $degrees) + { + } /** * Execute a save. @@ -172,14 +204,18 @@ protected function processRotate(int $degrees) {} * @param string $file * @param int $quality */ - protected function processSave(string $file, int $quality) {} + protected function processSave(string $file, int $quality) + { + } /** * Execute a sharpen. * * @param int $amount */ - protected function processSharpen(int $amount) {} + protected function processSharpen(int $amount) + { + } /** * Execute a text @@ -194,7 +230,9 @@ protected function processSharpen(int $amount) {} * @param int $size * @param string $fontfile */ - protected function processText(string $text, $offsetX, $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) {} + protected function processText(string $text, $offsetX, $offsetY, int $opacity, int $r, int $g, int $b, int $size, string $fontfile) + { + } /** * Execute a watermarking. @@ -204,6 +242,7 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i * @param int $offsetY * @param int $opacity */ - protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) {} - + protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) + { + } } diff --git a/src/Phalcon/logger/AdapterFactory.php b/src/Phalcon/logger/AdapterFactory.php index f3f81b71..1b27539a 100644 --- a/src/Phalcon/logger/AdapterFactory.php +++ b/src/Phalcon/logger/AdapterFactory.php @@ -21,7 +21,9 @@ class AdapterFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Create a new instance of the adapter @@ -31,11 +33,14 @@ public function __construct(array $services = array()) {} * @param array $options * @return AdapterInterface */ - public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface {} + public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/logger/Item.php b/src/Phalcon/logger/Item.php index 86093fe3..a1d741cf 100644 --- a/src/Phalcon/logger/Item.php +++ b/src/Phalcon/logger/Item.php @@ -52,35 +52,45 @@ class Item - public function getContext() {} + public function getContext() + { + } /** * Log message * * @return string */ - public function getMessage(): string {} + public function getMessage(): string + { + } /** * Log message * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Log timestamp * * @return integer */ - public function getTime() {} + public function getTime() + { + } /** * Log type * * @return integer */ - public function getType() {} + public function getType() + { + } /** * Phalcon\Logger\Item constructor @@ -91,6 +101,7 @@ public function getType() {} * @param int $time * @param mixed $context */ - public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) {} - + public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) + { + } } diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php index 555c5b40..eb09ef52 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/logger/LoggerFactory.php @@ -29,7 +29,9 @@ class LoggerFactory /** * @param \Phalcon\Logger\AdapterFactory $factory */ - public function __construct(\Phalcon\Logger\AdapterFactory $factory) {} + public function __construct(\Phalcon\Logger\AdapterFactory $factory) + { + } /** * Factory to create an instace from a Config object @@ -37,7 +39,9 @@ public function __construct(\Phalcon\Logger\AdapterFactory $factory) {} * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Returns a Logger object @@ -48,6 +52,7 @@ public function load($config) {} * @param array $adapters * @return \Phalcon\Logger */ - public function newInstance(string $name, array $adapters = array()): Logger {} - + public function newInstance(string $name, array $adapters = array()): Logger + { + } } diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/logger/adapter/AbstractAdapter.php index d11b36df..8fd0ae1b 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/logger/adapter/AbstractAdapter.php @@ -47,7 +47,9 @@ abstract class AbstractAdapter implements AdapterInterface /** * Destructor cleanup */ - public function __destruct() {} + public function __destruct() + { + } /** * Adds a message to the queue @@ -55,33 +57,43 @@ public function __destruct() {} * @param \Phalcon\Logger\Item $item * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function add(\Phalcon\Logger\Item $item): AdapterInterface {} + public function add(\Phalcon\Logger\Item $item): AdapterInterface + { + } /** * Starts a transaction * * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function begin(): AdapterInterface {} + public function begin(): AdapterInterface + { + } /** * Commits the internal transaction * * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function commit(): AdapterInterface {} + public function commit(): AdapterInterface + { + } /** * @return \Phalcon\Logger\Formatter\FormatterInterface */ - public function getFormatter(): FormatterInterface {} + public function getFormatter(): FormatterInterface + { + } /** * Returns the whether the logger is currently in an active transaction or not * * @return bool */ - public function inTransaction(): bool {} + public function inTransaction(): bool + { + } /** * Processes the message in the adapter @@ -95,7 +107,9 @@ abstract public function process(\Phalcon\Logger\Item $item); * * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function rollback(): AdapterInterface {} + public function rollback(): AdapterInterface + { + } /** * Sets the message formatter @@ -103,6 +117,7 @@ public function rollback(): AdapterInterface {} * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter * @return \Phalcon\Logger\Adapter\AdapterInterface */ - public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface {} - + public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface + { + } } diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php index 2afb8a47..271da4f5 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -78,5 +78,4 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; - } diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 485e56f0..8a3942f6 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -33,13 +33,16 @@ class Noop extends AbstractAdapter * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * Processes the message i.e. writes it to the file * * @param \Phalcon\Logger\Item $item */ - public function process(\Phalcon\Logger\Item $item) {} - + public function process(\Phalcon\Logger\Item $item) + { + } } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index dc25852c..20845ab0 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -62,7 +62,9 @@ class Stream extends AbstractAdapter * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Constructor. Accepts the name and some options @@ -70,20 +72,25 @@ public function getName(): string {} * @param string $name * @param array $options */ - public function __construct(string $name, array $options = array()) {} + public function __construct(string $name, array $options = array()) + { + } /** * Closes the stream * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * Processes the message i.e. writes it to the file * * @param \Phalcon\Logger\Item $item */ - public function process(\Phalcon\Logger\Item $item) {} - + public function process(\Phalcon\Logger\Item $item) + { + } } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index b759f02e..07983548 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -70,21 +70,27 @@ class Syslog extends AbstractAdapter * @param string $name * @param array $options */ - public function __construct(string $name, array $options = array()) {} + public function __construct(string $name, array $options = array()) + { + } /** * Closes the logger * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * Processes the message i.e. writes it to the syslog * * @param \Phalcon\Logger\Item $item */ - public function process(\Phalcon\Logger\Item $item) {} + public function process(\Phalcon\Logger\Item $item) + { + } /** * Translates a Logger level to a Syslog level @@ -92,6 +98,7 @@ public function process(\Phalcon\Logger\Item $item) {} * @param string $level * @return int */ - private function logLevelToSyslog(string $level): int {} - + private function logLevelToSyslog(string $level): int + { + } } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php index a70fa18b..7f38d5d2 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -21,6 +21,7 @@ abstract class AbstractFormatter implements FormatterInterface * @param string $message * @param array $context */ - public function interpolate(string $message, $context = null) {} - + public function interpolate(string $message, $context = null) + { + } } diff --git a/src/Phalcon/logger/formatter/FormatterInterface.php b/src/Phalcon/logger/formatter/FormatterInterface.php index 0e09b641..ed132f23 100644 --- a/src/Phalcon/logger/formatter/FormatterInterface.php +++ b/src/Phalcon/logger/formatter/FormatterInterface.php @@ -26,5 +26,4 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); - } diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index f0f17344..763eb1b7 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -31,21 +31,27 @@ class Json extends AbstractFormatter * * @return string */ - public function getDateFormat(): string {} + public function getDateFormat(): string + { + } /** * Default date format * * @param string $dateFormat */ - public function setDateFormat(string $dateFormat) {} + public function setDateFormat(string $dateFormat) + { + } /** * Phalcon\Logger\Formatter\Json construct * * @param string $dateFormat */ - public function __construct(string $dateFormat = 'D, d M y H:i:s O') {} + public function __construct(string $dateFormat = 'D, d M y H:i:s O') + { + } /** * Applies a format to a message before sent it to the internal log @@ -53,6 +59,7 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') {} * @param \Phalcon\Logger\Item $item * @return string */ - public function format(\Phalcon\Logger\Item $item): string {} - + public function format(\Phalcon\Logger\Item $item): string + { + } } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index 905ba9c7..6de4eb39 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -40,28 +40,36 @@ class Line extends AbstractFormatter * * @return string */ - public function getDateFormat(): string {} + public function getDateFormat(): string + { + } /** * Default date format * * @param string $dateFormat */ - public function setDateFormat(string $dateFormat) {} + public function setDateFormat(string $dateFormat) + { + } /** * Format applied to each message * * @return string */ - public function getFormat(): string {} + public function getFormat(): string + { + } /** * Format applied to each message * * @param string $format */ - public function setFormat(string $format) {} + public function setFormat(string $format) + { + } /** * Phalcon\Logger\Formatter\Line construct @@ -69,7 +77,9 @@ public function setFormat(string $format) {} * @param string $format * @param string $dateFormat */ - public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') {} + public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') + { + } /** * Applies a format to a message before sent it to the internal log @@ -77,6 +87,7 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin * @param \Phalcon\Logger\Item $item * @return string */ - public function format(\Phalcon\Logger\Item $item): string {} - + public function format(\Phalcon\Logger\Item $item): string + { + } } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 6b01a514..9f81ae7a 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -25,6 +25,7 @@ class Syslog extends AbstractFormatter * @param \Phalcon\Logger\Item $item * @return array */ - public function format(\Phalcon\Logger\Item $item): array {} - + public function format(\Phalcon\Logger\Item $item): array + { + } } diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index f03e0447..f71cefa1 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -49,27 +49,37 @@ class Message implements MessageInterface, JsonSerializable /** * @return int */ - public function getCode(): int {} + public function getCode(): int + { + } /** * @return string */ - public function getField(): string {} + public function getField(): string + { + } /** * @return string */ - public function getMessage(): string {} + public function getMessage(): string + { + } /** * @return string */ - public function getType(): string {} + public function getType(): string + { + } /** * @return array */ - public function getMetaData(): array {} + public function getMetaData(): array + { + } /** * Phalcon\Messages\Message constructor @@ -80,21 +90,27 @@ public function getMetaData(): array {} * @param int $code * @param array $metaData */ - public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) {} + public function __construct(string $message, $field = '', string $type = '', int $code = 0, array $metaData = array()) + { + } /** * Magic __toString method returns verbose message * * @return string */ - public function __toString(): string {} + public function __toString(): string + { + } /** * Serializes the object for json_encode * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Sets code for the message @@ -102,7 +118,9 @@ public function jsonSerialize(): array {} * @param int $code * @return \Phalcon\Messages\MessageInterface */ - public function setCode(int $code): MessageInterface {} + public function setCode(int $code): MessageInterface + { + } /** * Sets field name related to message @@ -110,7 +128,9 @@ public function setCode(int $code): MessageInterface {} * @param mixed $field * @return \Phalcon\Messages\MessageInterface */ - public function setField($field): MessageInterface {} + public function setField($field): MessageInterface + { + } /** * Sets verbose message @@ -118,7 +138,9 @@ public function setField($field): MessageInterface {} * @param string $message * @return \Phalcon\Messages\MessageInterface */ - public function setMessage(string $message): MessageInterface {} + public function setMessage(string $message): MessageInterface + { + } /** * Sets message metadata @@ -126,7 +148,9 @@ public function setMessage(string $message): MessageInterface {} * @param array $metaData * @return \Phalcon\Messages\MessageInterface */ - public function setMetaData(array $metaData): MessageInterface {} + public function setMetaData(array $metaData): MessageInterface + { + } /** * Sets message type @@ -134,6 +158,7 @@ public function setMetaData(array $metaData): MessageInterface {} * @param string $type * @return \Phalcon\Messages\MessageInterface */ - public function setType(string $type): MessageInterface {} - + public function setType(string $type): MessageInterface + { + } } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php index 53908db3..f3cf57b1 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/messages/MessageInterface.php @@ -100,5 +100,4 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; - } diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/messages/Messages.php index c4ba0b73..a19585b4 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/messages/Messages.php @@ -37,7 +37,9 @@ class Messages implements ArrayAccess, Countable, Iterator, JsonSerializable * * @param array $messages */ - public function __construct(array $messages = array()) {} + public function __construct(array $messages = array()) + { + } /** * Appends a message to the collection @@ -50,7 +52,9 @@ public function __construct(array $messages = array()) {} * * @param \Phalcon\Messages\MessageInterface $message */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message) + { + } /** * Appends an array of messages to the collection @@ -61,21 +65,27 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message) {} * * @param \Phalcon\Messages\MessageInterface[] $messages */ - public function appendMessages($messages) {} + public function appendMessages($messages) + { + } /** * Returns the number of messages in the list * * @return int */ - public function count(): int {} + public function count(): int + { + } /** * Returns the current message in the iterator * * @return \Phalcon\Messages\MessageInterface */ - public function current(): MessageInterface {} + public function current(): MessageInterface + { + } /** * Filters the message collection by field name @@ -83,7 +93,9 @@ public function current(): MessageInterface {} * @param string $fieldName * @return array */ - public function filter(string $fieldName): array {} + public function filter(string $fieldName): array + { + } /** * Returns serialised message objects as array for json_encode. Calls @@ -96,19 +108,25 @@ public function filter(string $fieldName): array {} * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Returns the current position/key in the iterator * * @return int */ - public function key(): int {} + public function key(): int + { + } /** * Moves the internal iteration pointer to the next position */ - public function next() {} + public function next() + { + } /** * Checks if an index exists @@ -122,7 +140,9 @@ public function next() {} * @param int $index * @return bool */ - public function offsetExists($index): bool {} + public function offsetExists($index): bool + { + } /** * Gets an attribute a message using the array syntax @@ -136,7 +156,9 @@ public function offsetExists($index): bool {} * @param mixed $index * @return mixed */ - public function offsetGet($index) {} + public function offsetGet($index) + { + } /** * Sets an attribute using the array-syntax @@ -148,7 +170,9 @@ public function offsetGet($index) {} * @param mixed $index * @param \Phalcon\Messages\Message $message */ - public function offsetSet($index, $message) {} + public function offsetSet($index, $message) + { + } /** * Removes a message from the list @@ -159,18 +183,23 @@ public function offsetSet($index, $message) {} * * @param mixed $index */ - public function offsetUnset($index) {} + public function offsetUnset($index) + { + } /** * Rewinds the internal iterator */ - public function rewind() {} + public function rewind() + { + } /** * Check if the current message in the iterator is valid * * @return bool */ - public function valid(): bool {} - + public function valid(): bool + { + } } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index cffcdf7c..0547ac58 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -77,7 +77,9 @@ class Application extends AbstractApplication * @param string $uri * @return bool|\Phalcon\Http\ResponseInterface */ - public function handle(string $uri) {} + public function handle(string $uri) + { + } /** * Enables or disables sending cookies by each request handling @@ -85,7 +87,9 @@ public function handle(string $uri) {} * @param bool $sendCookies * @return Application */ - public function sendCookiesOnHandleRequest(bool $sendCookies): Application {} + public function sendCookiesOnHandleRequest(bool $sendCookies): Application + { + } /** * Enables or disables sending headers by each request handling @@ -93,7 +97,9 @@ public function sendCookiesOnHandleRequest(bool $sendCookies): Application {} * @param bool $sendHeaders * @return Application */ - public function sendHeadersOnHandleRequest(bool $sendHeaders): Application {} + public function sendHeadersOnHandleRequest(bool $sendHeaders): Application + { + } /** * By default. The view is implicitly buffering all the output @@ -102,6 +108,7 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application {} * @param bool $implicitView * @return Application */ - public function useImplicitView(bool $implicitView): Application {} - + public function useImplicitView(bool $implicitView): Application + { + } } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index 65a30c17..7d24b930 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -59,6 +59,7 @@ abstract class Controller extends Injectable implements ControllerInterface /** * Phalcon\Mvc\Controller constructor */ - final public function __construct() {} - + final public function __construct() + { + } } diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index 267a7fbe..60825b0d 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -104,14 +104,18 @@ class Dispatcher extends BaseDispatcher implements DispatcherInterface * * @param array $forward */ - public function forward($forward) {} + public function forward($forward) + { + } /** * Returns the active controller in the dispatcher * * @return \Phalcon\Mvc\ControllerInterface */ - public function getActiveController(): ControllerInterface {} + public function getActiveController(): ControllerInterface + { + } /** * Possible controller class name that will be located to dispatch the @@ -119,70 +123,90 @@ public function getActiveController(): ControllerInterface {} * * @return string */ - public function getControllerClass(): string {} + public function getControllerClass(): string + { + } /** * Gets last dispatched controller name * * @return string */ - public function getControllerName(): string {} + public function getControllerName(): string + { + } /** * Returns the latest dispatched controller * * @return \Phalcon\Mvc\ControllerInterface */ - public function getLastController(): ControllerInterface {} + public function getLastController(): ControllerInterface + { + } /** * Gets previous dispatched action name * * @return string */ - public function getPreviousActionName(): string {} + public function getPreviousActionName(): string + { + } /** * Gets previous dispatched controller name * * @return string */ - public function getPreviousControllerName(): string {} + public function getPreviousControllerName(): string + { + } /** * Gets previous dispatched namespace name * * @return string */ - public function getPreviousNamespaceName(): string {} + public function getPreviousNamespaceName(): string + { + } /** * Sets the controller name to be dispatched * * @param string $controllerName */ - public function setControllerName(string $controllerName) {} + public function setControllerName(string $controllerName) + { + } /** * Sets the default controller suffix * * @param string $controllerSuffix */ - public function setControllerSuffix(string $controllerSuffix) {} + public function setControllerSuffix(string $controllerSuffix) + { + } /** * Sets the default controller name * * @param string $controllerName */ - public function setDefaultController(string $controllerName) {} + public function setDefaultController(string $controllerName) + { + } /** * Handles a user exception * * @param \Exception $exception */ - protected function handleException(\Exception $exception) {} + protected function handleException(\Exception $exception) + { + } /** * Throws an internal exception @@ -190,6 +214,7 @@ protected function handleException(\Exception $exception) {} * @param string $message * @param int $exceptionCode */ - protected function throwDispatchException(string $message, int $exceptionCode = 0) {} - + protected function throwDispatchException(string $message, int $exceptionCode = 0) + { + } } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index af4d162f..01a9f151 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -62,5 +62,4 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); - } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index bc6cf0b2..a58fe248 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -34,5 +34,4 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); - } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index 8bb31faa..d6b7ae9d 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -88,7 +88,9 @@ class Micro extends Injectable implements ArrayAccess * * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) + { + } /** * Appends an 'after' middleware to be called after execute the route @@ -96,7 +98,9 @@ public function __construct(\Phalcon\Di\DiInterface $container = null) {} * @param callable $handler * @return Micro */ - public function after($handler): Micro {} + public function after($handler): Micro + { + } /** * Appends a afterBinding middleware to be called after model binding @@ -104,7 +108,9 @@ public function after($handler): Micro {} * @param callable $handler * @return Micro */ - public function afterBinding($handler): Micro {} + public function afterBinding($handler): Micro + { + } /** * Appends a before middleware to be called before execute the route @@ -112,7 +118,9 @@ public function afterBinding($handler): Micro {} * @param callable $handler * @return Micro */ - public function before($handler): Micro {} + public function before($handler): Micro + { + } /** * Maps a route to a handler that only matches if the HTTP method is DELETE @@ -121,7 +129,9 @@ public function before($handler): Micro {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function delete(string $routePattern, $handler): RouteInterface {} + public function delete(string $routePattern, $handler): RouteInterface + { + } /** * Sets a handler that will be called when an exception is thrown handling @@ -130,7 +140,9 @@ public function delete(string $routePattern, $handler): RouteInterface {} * @param callable $handler * @return Micro */ - public function error($handler): Micro {} + public function error($handler): Micro + { + } /** * Appends a 'finish' middleware to be called when the request is finished @@ -138,7 +150,9 @@ public function error($handler): Micro {} * @param callable $handler * @return Micro */ - public function finish($handler): Micro {} + public function finish($handler): Micro + { + } /** * Maps a route to a handler that only matches if the HTTP method is GET @@ -147,49 +161,63 @@ public function finish($handler): Micro {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function get(string $routePattern, $handler): RouteInterface {} + public function get(string $routePattern, $handler): RouteInterface + { + } /** * Return the handler that will be called for the matched route * * @return callable */ - public function getActiveHandler() {} + public function getActiveHandler() + { + } /** * Returns bound models from binder instance * * @return array */ - public function getBoundModels(): array {} + public function getBoundModels(): array + { + } /** * Returns the internal handlers attached to the application * * @return array */ - public function getHandlers(): array {} + public function getHandlers(): array + { + } /** * Gets model binder * * @return null|\Phalcon\Mvc\Model\BinderInterface */ - public function getModelBinder(): ?BinderInterface {} + public function getModelBinder(): ?BinderInterface + { + } /** * Returns the value returned by the executed handler * * @return mixed */ - public function getReturnedValue() {} + public function getReturnedValue() + { + } /** * Returns the internal router used by the application * * @return RouterInterface */ - public function getRouter(): RouterInterface {} + public function getRouter(): RouterInterface + { + } /** * Obtains a service from the DI @@ -197,7 +225,9 @@ public function getRouter(): RouterInterface {} * @param string $serviceName * @return object */ - public function getService(string $serviceName) {} + public function getService(string $serviceName) + { + } /** * Obtains a shared service from the DI @@ -205,7 +235,9 @@ public function getService(string $serviceName) {} * @param string $serviceName * @return mixed */ - public function getSharedService(string $serviceName) {} + public function getSharedService(string $serviceName) + { + } /** * Handle the whole request @@ -213,7 +245,9 @@ public function getSharedService(string $serviceName) {} * @param string $uri * @return mixed */ - public function handle(string $uri) {} + public function handle(string $uri) + { + } /** * Checks if a service is registered in the DI @@ -221,7 +255,9 @@ public function handle(string $uri) {} * @param string $serviceName * @return bool */ - public function hasService(string $serviceName): bool {} + public function hasService(string $serviceName): bool + { + } /** * Maps a route to a handler that only matches if the HTTP method is HEAD @@ -230,7 +266,9 @@ public function hasService(string $serviceName): bool {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function head(string $routePattern, $handler): RouteInterface {} + public function head(string $routePattern, $handler): RouteInterface + { + } /** * Maps a route to a handler without any HTTP method constraint @@ -239,7 +277,9 @@ public function head(string $routePattern, $handler): RouteInterface {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function map(string $routePattern, $handler): RouteInterface {} + public function map(string $routePattern, $handler): RouteInterface + { + } /** * Mounts a collection of handlers @@ -247,7 +287,9 @@ public function map(string $routePattern, $handler): RouteInterface {} * @param \Phalcon\Mvc\Micro\CollectionInterface $collection * @return Micro */ - public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro {} + public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro + { + } /** * Sets a handler that will be called when the router doesn't match any of @@ -256,7 +298,9 @@ public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro * @param callable $handler * @return Micro */ - public function notFound($handler): Micro {} + public function notFound($handler): Micro + { + } /** * Check if a service is registered in the internal services container using @@ -265,7 +309,9 @@ public function notFound($handler): Micro {} * @param mixed $alias * @return bool */ - public function offsetExists($alias): bool {} + public function offsetExists($alias): bool + { + } /** * Allows to obtain a shared service in the internal services container @@ -280,7 +326,9 @@ public function offsetExists($alias): bool {} * @param mixed $alias * @return mixed */ - public function offsetGet($alias) {} + public function offsetGet($alias) + { + } /** * Allows to register a shared service in the internal services container @@ -293,7 +341,9 @@ public function offsetGet($alias) {} * @param mixed $alias * @param mixed $definition */ - public function offsetSet($alias, $definition) {} + public function offsetSet($alias, $definition) + { + } /** * Removes a service from the internal services container using the array @@ -301,7 +351,9 @@ public function offsetSet($alias, $definition) {} * * @param mixed $alias */ - public function offsetUnset($alias) {} + public function offsetUnset($alias) + { + } /** * Maps a route to a handler that only matches if the HTTP method is OPTIONS @@ -310,7 +362,9 @@ public function offsetUnset($alias) {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function options(string $routePattern, $handler): RouteInterface {} + public function options(string $routePattern, $handler): RouteInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is PATCH @@ -319,7 +373,9 @@ public function options(string $routePattern, $handler): RouteInterface {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function patch(string $routePattern, $handler): RouteInterface {} + public function patch(string $routePattern, $handler): RouteInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is POST @@ -328,7 +384,9 @@ public function patch(string $routePattern, $handler): RouteInterface {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function post(string $routePattern, $handler): RouteInterface {} + public function post(string $routePattern, $handler): RouteInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is PUT @@ -337,21 +395,27 @@ public function post(string $routePattern, $handler): RouteInterface {} * @param callable $handler * @return \Phalcon\Mvc\Router\RouteInterface */ - public function put(string $routePattern, $handler): RouteInterface {} + public function put(string $routePattern, $handler): RouteInterface + { + } /** * Sets externally the handler that must be called by the matched route * * @param callable $activeHandler */ - public function setActiveHandler($activeHandler) {} + public function setActiveHandler($activeHandler) + { + } /** * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Sets model binder @@ -369,7 +433,9 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} * @param mixed $cache * @return Micro */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro {} + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro + { + } /** * Appends a custom 'reponse' handler to be called insted of the default @@ -378,7 +444,9 @@ public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, * @param callable $handler * @return Micro */ - public function setResponseHandler($handler): Micro {} + public function setResponseHandler($handler): Micro + { + } /** * Sets a service from the DI @@ -388,12 +456,15 @@ public function setResponseHandler($handler): Micro {} * @param bool $shared * @return \Phalcon\Di\ServiceInterface */ - public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface {} + public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface + { + } /** * Stops the middleware execution avoiding than other middlewares be * executed */ - public function stop() {} - + public function stop() + { + } } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 317d0a62..08f52a26 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -130,7 +130,9 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface, - public function getTransaction() {} + public function getTransaction() + { + } /** * Phalcon\Mvc\Model constructor @@ -139,7 +141,9 @@ public function getTransaction() {} * @param \Phalcon\Di\DiInterface $container * @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager */ - final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) {} + final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) + { + } /** * Handles method calls when a method is not implemented @@ -148,7 +152,9 @@ final public function __construct($data = null, \Phalcon\Di\DiInterface $contain * @param array $arguments * @return mixed */ - public function __call(string $method, array $arguments) {} + public function __call(string $method, array $arguments) + { + } /** * Handles method calls when a static method is not implemented @@ -157,7 +163,9 @@ public function __call(string $method, array $arguments) {} * @param array $arguments * @return mixed */ - public static function __callStatic(string $method, array $arguments) {} + public static function __callStatic(string $method, array $arguments) + { + } /** * Magic method to get related records using the relation alias as a @@ -166,7 +174,9 @@ public static function __callStatic(string $method, array $arguments) {} * @param string $property * @return mixed */ - public function __get(string $property) {} + public function __get(string $property) + { + } /** * Magic method to check if a property is a valid relation @@ -174,7 +184,9 @@ public function __get(string $property) {} * @param string $property * @return bool */ - public function __isset(string $property): bool {} + public function __isset(string $property): bool + { + } /** * Magic method to assign values to the the model @@ -182,7 +194,9 @@ public function __isset(string $property): bool {} * @param string $property * @param mixed $value */ - public function __set(string $property, $value) {} + public function __set(string $property, $value) + { + } /** * Setups a behavior in a model @@ -211,7 +225,9 @@ public function __set(string $property, $value) {} * * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} + public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) + { + } /** * Appends a customized message on the validation process @@ -238,7 +254,9 @@ public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) {} * @param \Phalcon\Messages\MessageInterface $message * @return \Phalcon\Mvc\ModelInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface {} + public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface + { + } /** * Assigns values to a model from an array @@ -289,7 +307,9 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * @param array $dataColumnMap array to transform keys of data to another * @return \Phalcon\Mvc\ModelInterface */ - public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface {} + public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface + { + } /** * Returns the average value on a column for a result-set of rows matching @@ -319,7 +339,9 @@ public function assign(array $data, $whiteList = null, $dataColumnMap = null): M * @param array $parameters * @return double */ - public static function average($parameters = null): float {} + public static function average($parameters = null): float + { + } /** * Assigns values to a model from an array returning a new model @@ -340,7 +362,9 @@ public static function average($parameters = null): float {} * @param int $dirtyState * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface {} + public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface + { + } /** * Assigns values to a model from an array, returning a new model. @@ -363,7 +387,9 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * @param bool $keepSnapshots * @return \Phalcon\Mvc\ModelInterface */ - public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface {} + public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface + { + } /** * Returns an hydrated result based on the data and the column map @@ -373,7 +399,9 @@ public static function cloneResultMap($base, array $data, $columnMap, int $dirty * @param int $hydrationMode * @return mixed */ - public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) {} + public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) + { + } /** * Counts how many records match the specified conditions @@ -393,7 +421,9 @@ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydra * @param array $parameters * @return int */ - public static function count($parameters = null): int {} + public static function count($parameters = null): int + { + } /** * Inserts a model instance. If the instance already exists in the @@ -426,7 +456,9 @@ public static function count($parameters = null): int {} * * @return bool */ - public function create(): bool {} + public function create(): bool + { + } /** * Deletes a model instance. Returning true on success or false otherwise. @@ -445,7 +477,9 @@ public function create(): bool {} * * @return bool */ - public function delete(): bool {} + public function delete(): bool + { + } /** * Returns a simple representation of the object that can be used with @@ -459,7 +493,9 @@ public function delete(): bool {} * * @return array */ - public function dump(): array {} + public function dump(): array + { + } /** * Query for a set of records that match the specified conditions @@ -623,7 +659,9 @@ public function dump(): array {} * @param mixed $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public static function find($parameters = null): ResultsetInterface {} + public static function find($parameters = null): ResultsetInterface + { + } /** * Query the first record that matches the specified conditions @@ -694,7 +732,9 @@ public static function find($parameters = null): ResultsetInterface {} * @param string|array $parameters * @return bool|\Phalcon\Mvc\ModelInterface */ - public static function findFirst($parameters = null) {} + public static function findFirst($parameters = null) + { + } /** * Fires an event, implicitly calls behaviors and listeners in the events @@ -703,7 +743,9 @@ public static function findFirst($parameters = null) {} * @param string $eventName * @return bool */ - public function fireEvent(string $eventName): bool {} + public function fireEvent(string $eventName): bool + { + } /** * Fires an event, implicitly calls behaviors and listeners in the events @@ -713,7 +755,9 @@ public function fireEvent(string $eventName): bool {} * @param string $eventName * @return bool */ - public function fireEventCancel(string $eventName): bool {} + public function fireEventCancel(string $eventName): bool + { + } /** * Returns a list of changed values. @@ -730,7 +774,9 @@ public function fireEventCancel(string $eventName): bool {} * * @return array */ - public function getChangedFields(): array {} + public function getChangedFields(): array + { + } /** * Returns one of the DIRTY_STATE_ constants telling if the record exists @@ -738,14 +784,18 @@ public function getChangedFields(): array {} * * @return int */ - public function getDirtyState(): int {} + public function getDirtyState(): int + { + } /** * Returns the custom events manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): EventsManagerInterface {} + public function getEventsManager(): EventsManagerInterface + { + } /** * Returns array of validation messages @@ -773,21 +823,27 @@ public function getEventsManager(): EventsManagerInterface {} * @param mixed $filter * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getMessages($filter = null): array {} + public function getMessages($filter = null): array + { + } /** * Returns the models manager related to the entity instance * * @return \Phalcon\Mvc\Model\ManagerInterface */ - public function getModelsManager(): ManagerInterface {} + public function getModelsManager(): ManagerInterface + { + } /** * {@inheritdoc} * * @return \Phalcon\Mvc\Model\MetaDataInterface */ - public function getModelsMetaData(): MetaDataInterface {} + public function getModelsMetaData(): MetaDataInterface + { + } /** * Returns the type of the latest operation performed by the ORM @@ -795,21 +851,27 @@ public function getModelsMetaData(): MetaDataInterface {} * * @return int */ - public function getOperationMade(): int {} + public function getOperationMade(): int + { + } /** * Returns the internal old snapshot data * * @return array */ - public function getOldSnapshotData(): array {} + public function getOldSnapshotData(): array + { + } /** * Gets the connection used to read data for the model * * @return \Phalcon\Db\Adapter\AdapterInterface */ - final public function getReadConnection(): AdapterInterface {} + final public function getReadConnection(): AdapterInterface + { + } /** * Returns the DependencyInjection connection service name used to read data @@ -817,7 +879,9 @@ final public function getReadConnection(): AdapterInterface {} * * @return string */ - final public function getReadConnectionService(): string {} + final public function getReadConnectionService(): string + { + } /** * Returns related records based on defined relations @@ -826,7 +890,9 @@ final public function getReadConnectionService(): string {} * @param array $arguments * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ - public function getRelated(string $alias, $arguments = null) {} + public function getRelated(string $alias, $arguments = null) + { + } /** * Checks if saved related records have already been loaded. @@ -851,28 +917,36 @@ public function getRelated(string $alias, $arguments = null) {} * @param string $relationshipAlias * @return bool */ - public function isRelationshipLoaded(string $relationshipAlias): bool {} + public function isRelationshipLoaded(string $relationshipAlias): bool + { + } /** * Returns schema name where the mapped table is located * * @return string */ - final public function getSchema(): string {} + final public function getSchema(): string + { + } /** * Returns the internal snapshot data * * @return array */ - public function getSnapshotData(): array {} + public function getSnapshotData(): array + { + } /** * Returns the table name mapped in the model * * @return string */ - final public function getSource(): string {} + final public function getSource(): string + { + } /** * Returns a list of updated values. @@ -892,14 +966,18 @@ final public function getSource(): string {} * * @return array */ - public function getUpdatedFields(): array {} + public function getUpdatedFields(): array + { + } /** * Gets the connection used to write data to the model * * @return \Phalcon\Db\Adapter\AdapterInterface */ - final public function getWriteConnection(): AdapterInterface {} + final public function getWriteConnection(): AdapterInterface + { + } /** * Returns the DependencyInjection connection service name used to write @@ -907,7 +985,9 @@ final public function getWriteConnection(): AdapterInterface {} * * @return string */ - final public function getWriteConnectionService(): string {} + final public function getWriteConnectionService(): string + { + } /** * Check if a specific attribute has changed @@ -933,14 +1013,18 @@ final public function getWriteConnectionService(): string {} * @param boolean $allFields * @return bool */ - public function hasChanged($fieldName = null, bool $allFields = false): bool {} + public function hasChanged($fieldName = null, bool $allFields = false): bool + { + } /** * Checks if the object has internal snapshot data * * @return bool */ - public function hasSnapshotData(): bool {} + public function hasSnapshotData(): bool + { + } /** * Check if a specific attribute was updated @@ -950,7 +1034,9 @@ public function hasSnapshotData(): bool {} * @param bool $allFields * @return bool */ - public function hasUpdated($fieldName = null, bool $allFields = false): bool {} + public function hasUpdated($fieldName = null, bool $allFields = false): bool + { + } /** * Serializes the object for json_encode @@ -961,7 +1047,9 @@ public function hasUpdated($fieldName = null, bool $allFields = false): bool {} * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Returns the maximum value of a column for a result-set of rows that match @@ -991,7 +1079,9 @@ public function jsonSerialize(): array {} * @param array $parameters * @return mixed */ - public static function maximum($parameters = null) {} + public static function maximum($parameters = null) + { + } /** * Returns the minimum value of a column for a result-set of rows that match @@ -1021,7 +1111,9 @@ public static function maximum($parameters = null) {} * @param array $parameters * @return mixed */ - public static function minimum($parameters = null) {} + public static function minimum($parameters = null) + { + } /** * Create a criteria for a specific model @@ -1029,7 +1121,9 @@ public static function minimum($parameters = null) {} * @param \Phalcon\Di\DiInterface $container * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface {} + public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface + { + } /** * Reads an attribute value by its name @@ -1041,14 +1135,18 @@ public static function query(\Phalcon\Di\DiInterface $container = null): Criteri * @param string $attribute * @return mixed|null */ - public function readAttribute(string $attribute) {} + public function readAttribute(string $attribute) + { + } /** * Refreshes the model attributes re-querying the record from the database * * @return \Phalcon\Mvc\ModelInterface */ - public function refresh(): ModelInterface {} + public function refresh(): ModelInterface + { + } /** * Inserts or updates a model instance. Returning true on success or false @@ -1074,7 +1172,9 @@ public function refresh(): ModelInterface {} * * @return bool */ - public function save(): bool {} + public function save(): bool + { + } /** * Serializes the object ignoring connections, services, related objects or @@ -1082,21 +1182,27 @@ public function save(): bool {} * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes the object from a serialized string * * @param mixed $data */ - public function unserialize($data) {} + public function unserialize($data) + { + } /** * Sets the DependencyInjection connection service name * * @param string $connectionService */ - final public function setConnectionService(string $connectionService) {} + final public function setConnectionService(string $connectionService) + { + } /** * Sets the dirty state of the object using one of the DIRTY_STATE_ constants @@ -1104,21 +1210,27 @@ final public function setConnectionService(string $connectionService) {} * @param int $dirtyState * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState(int $dirtyState) {} + public function setDirtyState(int $dirtyState) + { + } /** * Sets a custom events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Sets the DependencyInjection connection service name used to read data * * @param string $connectionService */ - final public function setReadConnectionService(string $connectionService) {} + final public function setReadConnectionService(string $connectionService) + { + } /** * Sets the record's old snapshot data. @@ -1128,7 +1240,9 @@ final public function setReadConnectionService(string $connectionService) {} * @param array $data * @param array $columnMap */ - public function setOldSnapshotData(array $data, $columnMap = null) {} + public function setOldSnapshotData(array $data, $columnMap = null) + { + } /** * Sets the record's snapshot data. @@ -1138,7 +1252,9 @@ public function setOldSnapshotData(array $data, $columnMap = null) {} * @param array $data * @param array $columnMap */ - public function setSnapshotData(array $data, $columnMap = null) {} + public function setSnapshotData(array $data, $columnMap = null) + { + } /** * Sets a transaction related to the Model instance @@ -1182,28 +1298,36 @@ public function setSnapshotData(array $data, $columnMap = null) {} * @param \Phalcon\Mvc\Model\TransactionInterface $transaction * @return \Phalcon\Mvc\ModelInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface {} + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface + { + } /** * Enables/disables options in the ORM * * @param array $options */ - public static function setup(array $options) {} + public static function setup(array $options) + { + } /** * Sets the DependencyInjection connection service name used to write data * * @param string $connectionService */ - final public function setWriteConnectionService(string $connectionService) {} + final public function setWriteConnectionService(string $connectionService) + { + } /** * Skips the current operation forcing a success state * * @param bool $skip */ - public function skipOperation(bool $skip) {} + public function skipOperation(bool $skip) + { + } /** * Calculates the sum on a column for a result-set of rows that match the @@ -1233,7 +1357,9 @@ public function skipOperation(bool $skip) {} * @param array $parameters * @return double */ - public static function sum($parameters = null): float {} + public static function sum($parameters = null): float + { + } /** * Returns the instance as an array representation @@ -1247,7 +1373,9 @@ public static function sum($parameters = null): float {} * @param array $columns * @return array */ - public function toArray($columns = null): array {} + public function toArray($columns = null): array + { + } /** * Updates a model instance. If the instance doesn't exist in the @@ -1265,7 +1393,9 @@ public function toArray($columns = null): array {} * * @return bool */ - public function update(): bool {} + public function update(): bool + { + } /** * Writes an attribute value by its name @@ -1277,7 +1407,9 @@ public function update(): bool {} * @param string $attribute * @param mixed $value */ - public function writeAttribute(string $attribute, $value) {} + public function writeAttribute(string $attribute, $value) + { + } /** * Reads "belongs to" relations and check the virtual foreign keys when @@ -1286,7 +1418,9 @@ public function writeAttribute(string $attribute, $value) {} * * @return bool */ - final protected function _checkForeignKeysRestrict(): bool {} + final protected function _checkForeignKeysRestrict(): bool + { + } /** * Reads both "hasMany" and "hasOne" relations and checks the virtual @@ -1294,7 +1428,9 @@ final protected function _checkForeignKeysRestrict(): bool {} * * @return bool */ - final protected function _checkForeignKeysReverseCascade(): bool {} + final protected function _checkForeignKeysReverseCascade(): bool + { + } /** * Reads both "hasMany" and "hasOne" relations and checks the virtual @@ -1302,7 +1438,9 @@ final protected function _checkForeignKeysReverseCascade(): bool {} * * @return bool */ - final protected function _checkForeignKeysReverseRestrict(): bool {} + final protected function _checkForeignKeysReverseRestrict(): bool + { + } /** * Sends a pre-build INSERT SQL statement to the relational database system @@ -1313,7 +1451,9 @@ final protected function _checkForeignKeysReverseRestrict(): bool {} * @param bool|string $identityField * @return bool */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool {} + protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool + { + } /** * Sends a pre-build UPDATE SQL statement to the relational database system @@ -1323,7 +1463,9 @@ protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, * @param string|array $table * @return bool */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool {} + protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool + { + } /** * Checks whether the current record already exists @@ -1332,7 +1474,9 @@ protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @return bool */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool {} + protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool + { + } /** * Returns related records defined relations depending on the method name @@ -1342,7 +1486,9 @@ protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phal * @param array $arguments * @return mixed */ - protected function _getRelatedRecords(string $modelName, string $method, $arguments) {} + protected function _getRelatedRecords(string $modelName, string $method, $arguments) + { + } /** * Generate a PHQL SELECT statement for an aggregate @@ -1352,7 +1498,9 @@ protected function _getRelatedRecords(string $modelName, string $method, $argume * @param array $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ - protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface {} + protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface + { + } /** * Try to check if the query must invoke a finder @@ -1361,7 +1509,9 @@ protected static function _groupResult(string $functionName, string $alias, $par * @param array $arguments * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool */ - protected final static function _invokeFinder(string $method, array $arguments) {} + final protected static function _invokeFinder(string $method, array $arguments) + { + } /** * Check for, and attempt to use, possible setter. @@ -1370,7 +1520,9 @@ protected final static function _invokeFinder(string $method, array $arguments) * @param mixed $value * @return bool */ - final protected function _possibleSetter(string $property, $value): bool {} + final protected function _possibleSetter(string $property, $value): bool + { + } /** * Executes internal hooks before save a record @@ -1380,7 +1532,9 @@ final protected function _possibleSetter(string $property, $value): bool {} * @param mixed $identityField * @return bool */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool {} + protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool + { + } /** * Saves related records that must be stored prior to save the master record @@ -1389,7 +1543,9 @@ protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool * @param \Phalcon\Mvc\ModelInterface[] $related * @return bool */ - protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool + { + } /** * Executes internal events after save a record @@ -1398,7 +1554,9 @@ protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $ * @param bool $exists * @return bool */ - protected function _postSave(bool $success, bool $exists): bool {} + protected function _postSave(bool $success, bool $exists): bool + { + } /** * Save the related records assigned in the has-one/has-many relations @@ -1407,7 +1565,9 @@ protected function _postSave(bool $success, bool $exists): bool {} * @param \Phalcon\Mvc\ModelInterface[] $related * @return bool */ - protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool {} + protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool + { + } /** * Sets a list of attributes that must be skipped from the @@ -1429,12 +1589,16 @@ protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface * * @param array $attributes */ - protected function allowEmptyStringValues(array $attributes) {} + protected function allowEmptyStringValues(array $attributes) + { + } /** * Cancel the current operation */ - protected function _cancelOperation() {} + protected function _cancelOperation() + { + } /** * Setup a reverse 1-1 or n-1 relation between two models @@ -1459,7 +1623,9 @@ protected function _cancelOperation() {} * @param mixed $options * @return \Phalcon\Mvc\Model\Relation */ - protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation + { + } /** * shared prepare query logic for find and findFirst method @@ -1468,7 +1634,9 @@ protected function belongsTo($fields, string $referenceModel, $referencedFields, * @param mixed $limit * @return \Phalcon\Mvc\Model\Query */ - private static function getPreparedQuery($params, $limit = null): Query {} + private static function getPreparedQuery($params, $limit = null): Query + { + } /** * Setup a 1-n relation between two models @@ -1493,7 +1661,9 @@ private static function getPreparedQuery($params, $limit = null): Query {} * @param mixed $options * @return \Phalcon\Mvc\Model\Relation */ - protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation + { + } /** * Setup an n-n relation between two models, through an intermediate @@ -1526,7 +1696,9 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * @param array $options * @return \Phalcon\Mvc\Model\Relation */ - protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation {} + protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation + { + } /** * Setup a 1-1 relation between two models @@ -1551,7 +1723,9 @@ protected function hasManyToMany($fields, string $intermediateModel, $intermedia * @param mixed $options * @return \Phalcon\Mvc\Model\Relation */ - protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation {} + protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation + { + } /** * Sets if the model must keep the original record snapshot in memory @@ -1570,7 +1744,9 @@ protected function hasOne($fields, string $referenceModel, $referencedFields, $o * * @param bool $keepSnapshot */ - protected function keepSnapshots(bool $keepSnapshot) {} + protected function keepSnapshots(bool $keepSnapshot) + { + } /** * Sets schema name where the mapped table is located @@ -1578,7 +1754,9 @@ protected function keepSnapshots(bool $keepSnapshot) {} * @param string $schema * @return \Phalcon\Mvc\ModelInterface */ - final protected function setSchema(string $schema): ModelInterface {} + final protected function setSchema(string $schema): ModelInterface + { + } /** * Sets the table name to which model should be mapped @@ -1586,7 +1764,9 @@ final protected function setSchema(string $schema): ModelInterface {} * @param string $source * @return \Phalcon\Mvc\ModelInterface */ - final protected function setSource(string $source): ModelInterface {} + final protected function setSource(string $source): ModelInterface + { + } /** * Sets a list of attributes that must be skipped from the @@ -1608,7 +1788,9 @@ final protected function setSource(string $source): ModelInterface {} * * @param array $attributes */ - protected function skipAttributes(array $attributes) {} + protected function skipAttributes(array $attributes) + { + } /** * Sets a list of attributes that must be skipped from the @@ -1630,7 +1812,9 @@ protected function skipAttributes(array $attributes) {} * * @param array $attributes */ - protected function skipAttributesOnCreate(array $attributes) {} + protected function skipAttributesOnCreate(array $attributes) + { + } /** * Sets a list of attributes that must be skipped from the @@ -1652,7 +1836,9 @@ protected function skipAttributesOnCreate(array $attributes) {} * * @param array $attributes */ - protected function skipAttributesOnUpdate(array $attributes) {} + protected function skipAttributesOnUpdate(array $attributes) + { + } /** * Sets if a model must use dynamic update instead of the all-field update @@ -1671,7 +1857,9 @@ protected function skipAttributesOnUpdate(array $attributes) {} * * @param bool $dynamicUpdate */ - protected function useDynamicUpdate(bool $dynamicUpdate) {} + protected function useDynamicUpdate(bool $dynamicUpdate) + { + } /** * Executes validators on every validation call @@ -1707,7 +1895,9 @@ protected function useDynamicUpdate(bool $dynamicUpdate) {} * @param \Phalcon\Validation\ValidationInterface $validator * @return bool */ - protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool {} + protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool + { + } /** * Check whether validation process has generated any messages @@ -1742,7 +1932,9 @@ protected function validate(\Phalcon\Validation\ValidationInterface $validator): * * @return bool */ - public function validationHasFailed(): bool {} + public function validationHasFailed(): bool + { + } /** * Attempts to find key case-insensitively @@ -1751,6 +1943,7 @@ public function validationHasFailed(): bool {} * @param mixed $key * @return string */ - private static function caseInsensitiveColumnMap($columnMap, $key): string {} - + private static function caseInsensitiveColumnMap($columnMap, $key): string + { + } } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index b090836f..05b904e3 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -340,5 +340,4 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; - } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index e6765205..df3d8fa4 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -32,5 +32,4 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); - } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index bc9a17e2..4a6b37f0 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -114,27 +114,37 @@ class Router extends AbstractInjectionAware implements RouterInterface, EventsAw - public function getKeyRouteNames() {} + public function getKeyRouteNames() + { + } /** * @param mixed $keyRouteNames */ - public function setKeyRouteNames($keyRouteNames) {} + public function setKeyRouteNames($keyRouteNames) + { + } - public function getKeyRouteIds() {} + public function getKeyRouteIds() + { + } /** * @param mixed $keyRouteIds */ - public function setKeyRouteIds($keyRouteIds) {} + public function setKeyRouteIds($keyRouteIds) + { + } /** * Phalcon\Mvc\Router constructor * * @param bool $defaultRoutes */ - public function __construct(bool $defaultRoutes = true) {} + public function __construct(bool $defaultRoutes = true) + { + } /** * Adds a route to the router without any HTTP constraint @@ -164,7 +174,9 @@ public function __construct(bool $defaultRoutes = true) {} * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface {} + public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is CONNECT @@ -174,7 +186,9 @@ public function add(string $pattern, $paths = null, $httpMethods = null, $positi * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is DELETE @@ -184,7 +198,9 @@ public function addConnect(string $pattern, $paths = null, $position = Router::P * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is GET @@ -194,7 +210,9 @@ public function addDelete(string $pattern, $paths = null, $position = Router::PO * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is HEAD @@ -204,7 +222,9 @@ public function addGet(string $pattern, $paths = null, $position = Router::POSIT * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Add a route to the router that only match if the HTTP method is OPTIONS @@ -214,7 +234,9 @@ public function addHead(string $pattern, $paths = null, $position = Router::POSI * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PATCH @@ -224,7 +246,9 @@ public function addOptions(string $pattern, $paths = null, $position = Router::P * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is POST @@ -234,7 +258,9 @@ public function addPatch(string $pattern, $paths = null, $position = Router::POS * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PURGE @@ -245,7 +271,9 @@ public function addPost(string $pattern, $paths = null, $position = Router::POSI * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PUT @@ -255,7 +283,9 @@ public function addPurge(string $pattern, $paths = null, $position = Router::POS * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is TRACE @@ -265,7 +295,9 @@ public function addPut(string $pattern, $paths = null, $position = Router::POSIT * @param mixed $position * @return \Phalcon\Mvc\Router\RouteInterface */ - public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface {} + public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface + { + } /** * Attach Route object to the routes stack. @@ -290,68 +322,88 @@ public function addTrace(string $pattern, $paths = null, $position = Router::POS * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface {} + public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface + { + } /** * Removes all the pre-defined routes */ - public function clear() {} + public function clear() + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): ManagerInterface {} + public function getEventsManager(): ManagerInterface + { + } /** * Returns the processed action name * * @return string */ - public function getActionName(): string {} + public function getActionName(): string + { + } /** * Returns the processed controller name * * @return string */ - public function getControllerName(): string {} + public function getControllerName(): string + { + } /** * Returns the route that matches the handled URI * * @return \Phalcon\Mvc\Router\RouteInterface */ - public function getMatchedRoute(): RouteInterface {} + public function getMatchedRoute(): RouteInterface + { + } /** * Returns the sub expressions in the regular expression matched * * @return array */ - public function getMatches(): array {} + public function getMatches(): array + { + } /** * Returns the processed module name * * @return string */ - public function getModuleName(): string {} + public function getModuleName(): string + { + } /** * Returns the processed namespace name * * @return string */ - public function getNamespaceName(): string {} + public function getNamespaceName(): string + { + } /** * Returns the processed parameters * * @return array */ - public function getParams(): array {} + public function getParams(): array + { + } /** * Returns a route object by its id @@ -359,7 +411,9 @@ public function getParams(): array {} * @param mixed $id * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getRouteById($id) {} + public function getRouteById($id) + { + } /** * Returns a route object by its name @@ -367,14 +421,18 @@ public function getRouteById($id) {} * @param string $name * @return bool|\Phalcon\Mvc\Router\RouteInterface */ - public function getRouteByName(string $name) {} + public function getRouteByName(string $name) + { + } /** * Returns all the routes defined in the router * * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ - public function getRoutes(): array {} + public function getRoutes(): array + { + } /** * Handles routing information received from the rewrite engine @@ -386,14 +444,18 @@ public function getRoutes(): array {} * * @param string $uri */ - public function handle(string $uri) {} + public function handle(string $uri) + { + } /** * Returns whether controller name should not be mangled * * @return bool */ - public function isExactControllerName(): bool {} + public function isExactControllerName(): bool + { + } /** * Mounts a group of routes in the router @@ -401,7 +463,9 @@ public function isExactControllerName(): bool {} * @param \Phalcon\Mvc\Router\GroupInterface $group * @return RouterInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface {} + public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface + { + } /** * Set a group of paths to be returned when none of the defined routes are @@ -410,7 +474,9 @@ public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterfac * @param mixed $paths * @return RouterInterface */ - public function notFound($paths): RouterInterface {} + public function notFound($paths): RouterInterface + { + } /** * Set whether router must remove the extra slashes in the handled routes @@ -418,7 +484,9 @@ public function notFound($paths): RouterInterface {} * @param bool $remove * @return RouterInterface */ - public function removeExtraSlashes(bool $remove): RouterInterface {} + public function removeExtraSlashes(bool $remove): RouterInterface + { + } /** * Sets the default action name @@ -426,7 +494,9 @@ public function removeExtraSlashes(bool $remove): RouterInterface {} * @param string $actionName * @return RouterInterface */ - public function setDefaultAction(string $actionName): RouterInterface {} + public function setDefaultAction(string $actionName): RouterInterface + { + } /** * Sets the default controller name @@ -434,7 +504,9 @@ public function setDefaultAction(string $actionName): RouterInterface {} * @param string $controllerName * @return RouterInterface */ - public function setDefaultController(string $controllerName): RouterInterface {} + public function setDefaultController(string $controllerName): RouterInterface + { + } /** * Sets the name of the default module @@ -442,7 +514,9 @@ public function setDefaultController(string $controllerName): RouterInterface {} * @param string $moduleName * @return RouterInterface */ - public function setDefaultModule(string $moduleName): RouterInterface {} + public function setDefaultModule(string $moduleName): RouterInterface + { + } /** * Sets the name of the default namespace @@ -450,7 +524,9 @@ public function setDefaultModule(string $moduleName): RouterInterface {} * @param string $namespaceName * @return RouterInterface */ - public function setDefaultNamespace(string $namespaceName): RouterInterface {} + public function setDefaultNamespace(string $namespaceName): RouterInterface + { + } /** * Sets an array of default paths. If a route is missing a path the router @@ -469,27 +545,34 @@ public function setDefaultNamespace(string $namespaceName): RouterInterface {} * @param array $defaults * @return RouterInterface */ - public function setDefaults(array $defaults): RouterInterface {} + public function setDefaults(array $defaults): RouterInterface + { + } /** * Returns an array of default parameters * * @return array */ - public function getDefaults(): array {} + public function getDefaults(): array + { + } /** * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Checks if the router matches any of the defined routes * * @return bool */ - public function wasMatched(): bool {} - + public function wasMatched(): bool + { + } } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index 314f9c20..b654ef7c 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -259,5 +259,4 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index d58c56af..5062da17 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -139,20 +139,28 @@ class View extends Injectable implements ViewInterface - public function getCurrentRenderLevel() {} + public function getCurrentRenderLevel() + { + } - public function getRegisteredEngines() {} + public function getRegisteredEngines() + { + } - public function getRenderLevel() {} + public function getRenderLevel() + { + } /** * Phalcon\Mvc\View constructor * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Magic method to retrieve a variable passed to the view @@ -164,7 +172,9 @@ public function __construct(array $options = array()) {} * @param string $key * @return mixed|null */ - public function __get(string $key) {} + public function __get(string $key) + { + } /** * Magic method to retrieve if a variable is set in the view @@ -176,7 +186,9 @@ public function __get(string $key) {} * @param string $key * @return bool */ - public function __isset(string $key): bool {} + public function __isset(string $key): bool + { + } /** * Magic method to pass variables to the views @@ -188,21 +200,27 @@ public function __isset(string $key): bool {} * @param string $key * @param mixed $value */ - public function __set(string $key, $value) {} + public function __set(string $key, $value) + { + } /** * Resets any template before layouts * * @return View */ - public function cleanTemplateAfter(): View {} + public function cleanTemplateAfter(): View + { + } /** * Resets any "template before" layouts * * @return View */ - public function cleanTemplateBefore(): View {} + public function cleanTemplateBefore(): View + { + } /** * Disables a specific level of rendering @@ -217,21 +235,27 @@ public function cleanTemplateBefore(): View {} * @param mixed $level * @return \Phalcon\Mvc\ViewInterface */ - public function disableLevel($level): ViewInterface {} + public function disableLevel($level): ViewInterface + { + } /** * Disables the auto-rendering process * * @return View */ - public function disable(): View {} + public function disable(): View + { + } /** * Enables the auto-rendering process * * @return View */ - public function enable(): View {} + public function enable(): View + { + } /** * Checks whether view exists @@ -239,77 +263,99 @@ public function enable(): View {} * @param string $view * @return bool */ - public function exists(string $view): bool {} + public function exists(string $view): bool + { + } /** * Finishes the render process by stopping the output buffering * * @return View */ - public function finish(): View {} + public function finish(): View + { + } /** * Gets the name of the action rendered * * @return string */ - public function getActionName(): string {} + public function getActionName(): string + { + } /** * Returns the path (or paths) of the views that are currently rendered * * @return string|array */ - public function getActiveRenderPath() {} + public function getActiveRenderPath() + { + } /** * Gets base path * * @return string */ - public function getBasePath(): string {} + public function getBasePath(): string + { + } /** * Returns output from another view stage * * @return string */ - public function getContent(): string {} + public function getContent(): string + { + } /** * Gets the name of the controller rendered * * @return string */ - public function getControllerName(): string {} + public function getControllerName(): string + { + } /** * Returns the name of the main view * * @return string */ - public function getLayout(): string {} + public function getLayout(): string + { + } /** * Gets the current layouts sub-directory * * @return string */ - public function getLayoutsDir(): string {} + public function getLayoutsDir(): string + { + } /** * Returns the name of the main view * * @return string */ - public function getMainView(): string {} + public function getMainView(): string + { + } /** * Returns parameters to views * * @return array */ - public function getParamsToView(): array {} + public function getParamsToView(): array + { + } /** * Renders a partial view @@ -333,14 +379,18 @@ public function getParamsToView(): array {} * @param mixed $params * @return string */ - public function getPartial(string $partialPath, $params = null): string {} + public function getPartial(string $partialPath, $params = null): string + { + } /** * Gets the current partials sub-directory * * @return string */ - public function getPartialsDir(): string {} + public function getPartialsDir(): string + { + } /** * Perform the automatic rendering returning the output as a string @@ -361,35 +411,45 @@ public function getPartialsDir(): string {} * @param mixed $configCallback * @return string */ - public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string {} + public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string + { + } /** * Returns a parameter previously set in the view * * @param string $key */ - public function getVar(string $key) {} + public function getVar(string $key) + { + } /** * Gets views directory * * @return string|array */ - public function getViewsDir() {} + public function getViewsDir() + { + } /** * Gets views directories * * @return array */ - protected function getViewsDirs(): array {} + protected function getViewsDirs(): array + { + } /** * Whether automatic rendering is enabled * * @return bool */ - public function isDisabled(): bool {} + public function isDisabled(): bool + { + } /** * Renders a partial view @@ -412,7 +472,9 @@ public function isDisabled(): bool {} * @param string $partialPath * @param mixed $params */ - public function partial(string $partialPath, $params = null) {} + public function partial(string $partialPath, $params = null) + { + } /** * Choose a different view to render instead of last-controller/last-action @@ -435,7 +497,9 @@ public function partial(string $partialPath, $params = null) {} * @param mixed $renderView * @return View */ - public function pick($renderView): View {} + public function pick($renderView): View + { + } /** * Register templating engines @@ -453,7 +517,9 @@ public function pick($renderView): View {} * @param array $engines * @return View */ - public function registerEngines(array $engines): View {} + public function registerEngines(array $engines): View + { + } /** * Executes render process from dispatching data @@ -468,14 +534,18 @@ public function registerEngines(array $engines): View {} * @param array $params * @return bool|View */ - public function render(string $controllerName, string $actionName, array $params = array()) {} + public function render(string $controllerName, string $actionName, array $params = array()) + { + } /** * Resets the view component to its factory default values * * @return View */ - public function reset(): View {} + public function reset(): View + { + } /** * Sets base path. Depending of your platform, always add a trailing slash @@ -488,7 +558,9 @@ public function reset(): View {} * @param string $basePath * @return View */ - public function setBasePath(string $basePath): View {} + public function setBasePath(string $basePath): View + { + } /** * Externally sets the view content @@ -500,7 +572,9 @@ public function setBasePath(string $basePath): View {} * @param string $content * @return View */ - public function setContent(string $content): View {} + public function setContent(string $content): View + { + } /** * Change the layout to be used instead of using the name of the latest @@ -513,7 +587,9 @@ public function setContent(string $content): View {} * @param string $layout * @return View */ - public function setLayout(string $layout): View {} + public function setLayout(string $layout): View + { + } /** * Sets the layouts sub-directory. Must be a directory under the views @@ -527,7 +603,9 @@ public function setLayout(string $layout): View {} * @param string $layoutsDir * @return View */ - public function setLayoutsDir(string $layoutsDir): View {} + public function setLayoutsDir(string $layoutsDir): View + { + } /** * Sets default view name. Must be a file without extension in the views @@ -541,7 +619,9 @@ public function setLayoutsDir(string $layoutsDir): View {} * @param string $viewPath * @return View */ - public function setMainView(string $viewPath): View {} + public function setMainView(string $viewPath): View + { + } /** * Sets a partials sub-directory. Must be a directory under the views @@ -555,7 +635,9 @@ public function setMainView(string $viewPath): View {} * @param string $partialsDir * @return View */ - public function setPartialsDir(string $partialsDir): View {} + public function setPartialsDir(string $partialsDir): View + { + } /** * Adds parameters to views (alias of setVar) @@ -568,7 +650,9 @@ public function setPartialsDir(string $partialsDir): View {} * @param mixed $value * @return View */ - public function setParamToView(string $key, $value): View {} + public function setParamToView(string $key, $value): View + { + } /** * Sets the render level for the view @@ -583,7 +667,9 @@ public function setParamToView(string $key, $value): View {} * @param int $level * @return \Phalcon\Mvc\ViewInterface */ - public function setRenderLevel(int $level): ViewInterface {} + public function setRenderLevel(int $level): ViewInterface + { + } /** * Sets a "template after" controller layout @@ -591,7 +677,9 @@ public function setRenderLevel(int $level): ViewInterface {} * @param mixed $templateAfter * @return View */ - public function setTemplateAfter($templateAfter): View {} + public function setTemplateAfter($templateAfter): View + { + } /** * Sets a template before the controller layout @@ -599,7 +687,9 @@ public function setTemplateAfter($templateAfter): View {} * @param mixed $templateBefore * @return View */ - public function setTemplateBefore($templateBefore): View {} + public function setTemplateBefore($templateBefore): View + { + } /** * Set a single view parameter @@ -612,7 +702,9 @@ public function setTemplateBefore($templateBefore): View {} * @param mixed $value * @return View */ - public function setVar(string $key, $value): View {} + public function setVar(string $key, $value): View + { + } /** * Set all the render params @@ -629,7 +721,9 @@ public function setVar(string $key, $value): View {} * @param bool $merge * @return View */ - public function setVars(array $params, bool $merge = true): View {} + public function setVars(array $params, bool $merge = true): View + { + } /** * Sets the views directory. Depending of your platform, @@ -638,14 +732,18 @@ public function setVars(array $params, bool $merge = true): View {} * @param mixed $viewsDir * @return View */ - public function setViewsDir($viewsDir): View {} + public function setViewsDir($viewsDir): View + { + } /** * Starts rendering process enabling the output buffering * * @return View */ - public function start(): View {} + public function start(): View + { + } /** * Renders the view and returns it as a string @@ -655,7 +753,9 @@ public function start(): View {} * @param array $params * @return string */ - public function toString(string $controllerName, string $actionName, array $params = array()): string {} + public function toString(string $controllerName, string $actionName, array $params = array()): string + { + } /** * Checks whether view exists on registered extensions and render it @@ -665,14 +765,18 @@ public function toString(string $controllerName, string $actionName, array $para * @param bool $silence * @param bool $mustClean */ - protected function engineRender(array $engines, string $viewPath, bool $silence, bool $mustClean = true) {} + protected function engineRender(array $engines, string $viewPath, bool $silence, bool $mustClean = true) + { + } /** * Checks if a path is absolute or not * * @param string $path */ - final protected function isAbsolutePath(string $path) {} + final protected function isAbsolutePath(string $path) + { + } /** * Loads registered template engines, if none is registered it will use @@ -680,7 +784,9 @@ final protected function isAbsolutePath(string $path) {} * * @return array */ - protected function loadTemplateEngines(): array {} + protected function loadTemplateEngines(): array + { + } /** * Processes the view and templates; Fires events if needed @@ -691,6 +797,7 @@ protected function loadTemplateEngines(): array {} * @param bool $fireEvents * @return bool */ - public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool {} - + public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool + { + } } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index 99968b7a..866d04aa 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -78,5 +78,4 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); - } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index 9fb15059..cd544276 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -204,5 +204,4 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); - } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 8f177c4d..53afd7f8 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -25,5 +25,4 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; - } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 77eb06ab..789316f7 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -53,7 +53,9 @@ class Collection implements CollectionInterface * @param string $name * @return CollectionInterface */ - public function delete(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function delete(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is GET. @@ -63,28 +65,36 @@ public function delete(string $routePattern, $handler, string $name = null): Col * @param string $name * @return CollectionInterface */ - public function get(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function get(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Returns the main handler * * @return mixed */ - public function getHandler() {} + public function getHandler() + { + } /** * Returns the registered handlers * * @return array */ - public function getHandlers(): array {} + public function getHandlers(): array + { + } /** * Returns the collection prefix if any * * @return string */ - public function getPrefix(): string {} + public function getPrefix(): string + { + } /** * Maps a route to a handler that only matches if the HTTP method is HEAD. @@ -94,14 +104,18 @@ public function getPrefix(): string {} * @param string $name * @return CollectionInterface */ - public function head(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function head(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Returns if the main handler must be lazy loaded * * @return bool */ - public function isLazy(): bool {} + public function isLazy(): bool + { + } /** * Maps a route to a handler. @@ -111,7 +125,9 @@ public function isLazy(): bool {} * @param string $name * @return CollectionInterface */ - public function map(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function map(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler via methods. @@ -131,7 +147,9 @@ public function map(string $routePattern, $handler, string $name = null): Collec * @param string $name * @return CollectionInterface */ - public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface {} + public function mapVia(string $routePattern, $handler, $method, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is @@ -142,7 +160,9 @@ public function mapVia(string $routePattern, $handler, $method, string $name = n * @param string $name * @return CollectionInterface */ - public function options(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function options(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is PATCH. @@ -152,7 +172,9 @@ public function options(string $routePattern, $handler, string $name = null): Co * @param string $name * @return CollectionInterface */ - public function patch(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function patch(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is POST. @@ -162,7 +184,9 @@ public function patch(string $routePattern, $handler, string $name = null): Coll * @param string $name * @return CollectionInterface */ - public function post(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function post(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Maps a route to a handler that only matches if the HTTP method is PUT. @@ -172,7 +196,9 @@ public function post(string $routePattern, $handler, string $name = null): Colle * @param string $name * @return CollectionInterface */ - public function put(string $routePattern, $handler, string $name = null): CollectionInterface {} + public function put(string $routePattern, $handler, string $name = null): CollectionInterface + { + } /** * Sets the main handler. @@ -181,7 +207,9 @@ public function put(string $routePattern, $handler, string $name = null): Collec * @param bool $lazy * @return CollectionInterface */ - public function setHandler($handler, bool $lazy = false): CollectionInterface {} + public function setHandler($handler, bool $lazy = false): CollectionInterface + { + } /** * Sets if the main handler must be lazy loaded @@ -189,7 +217,9 @@ public function setHandler($handler, bool $lazy = false): CollectionInterface {} * @param bool $lazy * @return CollectionInterface */ - public function setLazy(bool $lazy): CollectionInterface {} + public function setLazy(bool $lazy): CollectionInterface + { + } /** * Sets a prefix for all routes added to the collection @@ -197,7 +227,9 @@ public function setLazy(bool $lazy): CollectionInterface {} * @param string $prefix * @return CollectionInterface */ - public function setPrefix(string $prefix): CollectionInterface {} + public function setPrefix(string $prefix): CollectionInterface + { + } /** * Internal function to add a handler to the group. @@ -207,6 +239,7 @@ public function setPrefix(string $prefix): CollectionInterface {} * @param callable|string $handler * @param string $name */ - protected function addMap($method, string $routePattern, $handler, string $name) {} - + protected function addMap($method, string $routePattern, $handler, string $name) + { + } } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index 061e309c..4dd0c4eb 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -151,5 +151,4 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; - } diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index b52d1eef..aba652f2 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -26,14 +26,18 @@ class LazyLoader - public function getDefinition() {} + public function getDefinition() + { + } /** * Phalcon\Mvc\Micro\LazyLoader constructor * * @param string $definition */ - public function __construct(string $definition) {} + public function __construct(string $definition) + { + } /** * Calling __call method @@ -43,6 +47,7 @@ public function __construct(string $definition) {} * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @return mixed */ - public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) {} - + public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) + { + } } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index 83968f0f..f6ed8ad3 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -23,5 +23,4 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); - } diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 92072be9..0e36aa61 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -29,7 +29,9 @@ abstract class Behavior implements BehaviorInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Returns the behavior options related to an event @@ -37,7 +39,9 @@ public function __construct(array $options = array()) {} * @param string $eventName * @return array */ - protected function getOptions(string $eventName = null) {} + protected function getOptions(string $eventName = null) + { + } /** * Acts as fallbacks when a missing method is called on the model @@ -46,7 +50,9 @@ protected function getOptions(string $eventName = null) {} * @param string $method * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) + { + } /** * Checks whether the behavior must take action on certain event @@ -54,7 +60,9 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param string $eventName * @return bool */ - protected function mustTakeAction(string $eventName): bool {} + protected function mustTakeAction(string $eventName): bool + { + } /** * This method receives the notifications from the EventsManager @@ -62,6 +70,7 @@ protected function mustTakeAction(string $eventName): bool {} * @param string $type * @param \Phalcon\Mvc\ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} - + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + { + } } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 6d85c243..54681fc8 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -35,5 +35,4 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); - } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index a972d074..111a76f4 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -48,19 +48,25 @@ class Binder implements BinderInterface * * @return array */ - public function getBoundModels(): array {} + public function getBoundModels(): array + { + } /** * Array for original values */ - public function getOriginalValues() {} + public function getOriginalValues() + { + } /** * Phalcon\Mvc\Model\Binder constructor * * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) + { + } /** * Bind models into params in proper handler @@ -71,7 +77,9 @@ public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = nul * @param string $methodName * @return array */ - public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array {} + public function bindToHandler($handler, array $params, string $cacheKey, string $methodName = null): array + { + } /** * Find the model by param value. @@ -80,14 +88,18 @@ public function bindToHandler($handler, array $params, string $cacheKey, string * @param string $className * @return object|bool */ - protected function findBoundModel($paramValue, string $className): bool {} + protected function findBoundModel($paramValue, string $className): bool + { + } /** * Sets cache instance * * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function getCache(): AdapterInterface {} + public function getCache(): AdapterInterface + { + } /** * Get params classes from cache by key @@ -95,7 +107,9 @@ public function getCache(): AdapterInterface {} * @param string $cacheKey * @return array|null */ - protected function getParamsFromCache(string $cacheKey): ?array {} + protected function getParamsFromCache(string $cacheKey): ?array + { + } /** * Get modified params for handler using reflection @@ -106,7 +120,9 @@ protected function getParamsFromCache(string $cacheKey): ?array {} * @param string $methodName * @return array */ - protected function getParamsFromReflection($handler, array $params, string $cacheKey, string $methodName): array {} + protected function getParamsFromReflection($handler, array $params, string $cacheKey, string $methodName): array + { + } /** * Gets cache instance @@ -114,6 +130,7 @@ protected function getParamsFromReflection($handler, array $params, string $cach * @param \Phalcon\Cache\Adapter\AdapterInterface $cache * @return BinderInterface */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface {} - + public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface + { + } } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index e75f013a..a000a0bf 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -53,5 +53,4 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; - } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index de995ca9..d6527a48 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -55,14 +55,18 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Returns the DependencyInjector container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Set a model on which the query will be executed @@ -70,14 +74,18 @@ public function getDI(): DiInterface {} * @param string $modelName * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function setModelName(string $modelName): CriteriaInterface {} + public function setModelName(string $modelName): CriteriaInterface + { + } /** * Returns an internal model name on which the criteria will be applied * * @return string */ - public function getModelName(): string {} + public function getModelName(): string + { + } /** * Sets the bound parameters in the criteria @@ -87,7 +95,9 @@ public function getModelName(): string {} * @param bool $merge * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bind(array $bindParams, bool $merge = false): CriteriaInterface {} + public function bind(array $bindParams, bool $merge = false): CriteriaInterface + { + } /** * Sets the bind types in the criteria @@ -96,7 +106,9 @@ public function bind(array $bindParams, bool $merge = false): CriteriaInterface * @param array $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function bindTypes(array $bindTypes): CriteriaInterface {} + public function bindTypes(array $bindTypes): CriteriaInterface + { + } /** * Sets SELECT DISTINCT / SELECT ALL flag @@ -104,7 +116,9 @@ public function bindTypes(array $bindTypes): CriteriaInterface {} * @param mixed $distinct * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function distinct($distinct): CriteriaInterface {} + public function distinct($distinct): CriteriaInterface + { + } /** * Sets the columns to be queried @@ -121,7 +135,9 @@ public function distinct($distinct): CriteriaInterface {} * @param string|array $columns * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function columns($columns): CriteriaInterface {} + public function columns($columns): CriteriaInterface + { + } /** * Adds an INNER join to the query @@ -156,7 +172,9 @@ public function columns($columns): CriteriaInterface {} * @param mixed $type * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface {} + public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface + { + } /** * Adds an INNER join to the query @@ -183,7 +201,9 @@ public function join(string $model, $conditions = null, $alias = null, $type = n * @param mixed $alias * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface + { + } /** * Adds a LEFT join to the query @@ -201,7 +221,9 @@ public function innerJoin(string $model, $conditions = null, $alias = null): Cri * @param mixed $alias * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface + { + } /** * Adds a RIGHT join to the query @@ -219,7 +241,9 @@ public function leftJoin(string $model, $conditions = null, $alias = null): Crit * @param mixed $alias * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface {} + public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface + { + } /** * Sets the conditions parameter in the criteria @@ -229,7 +253,9 @@ public function rightJoin(string $model, $conditions = null, $alias = null): Cri * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface + { + } /** * Appends a condition to the current conditions using an AND operator @@ -239,7 +265,9 @@ public function where(string $conditions, $bindParams = null, $bindTypes = null) * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface + { + } /** * Appends a condition to the current conditions using an OR operator @@ -249,7 +277,9 @@ public function andWhere(string $conditions, $bindParams = null, $bindTypes = nu * @param mixed $bindTypes * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface {} + public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface + { + } /** * Appends a BETWEEN condition to the current conditions @@ -263,7 +293,9 @@ public function orWhere(string $conditions, $bindParams = null, $bindTypes = nul * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} + public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface + { + } /** * Appends a NOT BETWEEN condition to the current conditions @@ -277,7 +309,9 @@ public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterfac * @param mixed $maximum * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface {} + public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface + { + } /** * Appends an IN condition to the current conditions @@ -290,7 +324,9 @@ public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInter * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function inWhere(string $expr, array $values): CriteriaInterface {} + public function inWhere(string $expr, array $values): CriteriaInterface + { + } /** * Appends a NOT IN condition to the current conditions @@ -303,7 +339,9 @@ public function inWhere(string $expr, array $values): CriteriaInterface {} * @param array $values * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function notInWhere(string $expr, array $values): CriteriaInterface {} + public function notInWhere(string $expr, array $values): CriteriaInterface + { + } /** * Adds the conditions parameter to the criteria @@ -311,7 +349,9 @@ public function notInWhere(string $expr, array $values): CriteriaInterface {} * @param string $conditions * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function conditions(string $conditions): CriteriaInterface {} + public function conditions(string $conditions): CriteriaInterface + { + } /** * Adds the order-by clause to the criteria @@ -319,7 +359,9 @@ public function conditions(string $conditions): CriteriaInterface {} * @param string $orderColumns * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function orderBy(string $orderColumns): CriteriaInterface {} + public function orderBy(string $orderColumns): CriteriaInterface + { + } /** * Adds the group-by clause to the criteria @@ -327,7 +369,9 @@ public function orderBy(string $orderColumns): CriteriaInterface {} * @param mixed $group * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function groupBy($group): CriteriaInterface {} + public function groupBy($group): CriteriaInterface + { + } /** * Adds the having clause to the criteria @@ -335,7 +379,9 @@ public function groupBy($group): CriteriaInterface {} * @param mixed $having * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function having($having): CriteriaInterface {} + public function having($having): CriteriaInterface + { + } /** * Adds the limit parameter to the criteria. @@ -350,7 +396,9 @@ public function having($having): CriteriaInterface {} * @param int $offset * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function limit(int $limit, int $offset = 0): CriteriaInterface {} + public function limit(int $limit, int $offset = 0): CriteriaInterface + { + } /** * Adds the "for_update" parameter to the criteria @@ -358,7 +406,9 @@ public function limit(int $limit, int $offset = 0): CriteriaInterface {} * @param bool $forUpdate * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function forUpdate(bool $forUpdate = true): CriteriaInterface {} + public function forUpdate(bool $forUpdate = true): CriteriaInterface + { + } /** * Adds the "shared_lock" parameter to the criteria @@ -366,7 +416,9 @@ public function forUpdate(bool $forUpdate = true): CriteriaInterface {} * @param bool $sharedLock * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function sharedLock(bool $sharedLock = true): CriteriaInterface {} + public function sharedLock(bool $sharedLock = true): CriteriaInterface + { + } /** * Sets the cache options in the criteria @@ -375,28 +427,36 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface {} * @param array $cache * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public function cache(array $cache): CriteriaInterface {} + public function cache(array $cache): CriteriaInterface + { + } /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getWhere(): ?string {} + public function getWhere(): ?string + { + } /** * Returns the columns to be queried * * @return string|null */ - public function getColumns(): ?string {} + public function getColumns(): ?string + { + } /** * Returns the conditions parameter in the criteria * * @return string|null */ - public function getConditions(): ?string {} + public function getConditions(): ?string + { + } /** * Returns the limit parameter in the criteria, which will be an integer if @@ -405,31 +465,41 @@ public function getConditions(): ?string {} * * @return string|null */ - public function getLimit(): ?string {} + public function getLimit(): ?string + { + } /** * Returns the order clause in the criteria * * @return string|null */ - public function getOrderBy(): ?string {} + public function getOrderBy(): ?string + { + } /** * Returns the group clause in the criteria */ - public function getGroupBy() {} + public function getGroupBy() + { + } /** * Returns the having clause in the criteria */ - public function getHaving() {} + public function getHaving() + { + } /** * Returns all the parameters defined in the criteria * * @return array */ - public function getParams(): array {} + public function getParams(): array + { + } /** * Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST @@ -440,7 +510,9 @@ public function getParams(): array {} * @param string $operator * @return \Phalcon\Mvc\Model\CriteriaInterface */ - public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface {} + public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface + { + } /** * Creates a query builder from criteria. @@ -454,13 +526,16 @@ public static function fromInput(\Phalcon\Di\DiInterface $container, string $mod * * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder(): BuilderInterface {} + public function createBuilder(): BuilderInterface + { + } /** * Executes a find using the parameters built with the criteria * * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function execute(): ResultsetInterface {} - + public function execute(): ResultsetInterface + { + } } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index 2f82d702..229a7e0a 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -331,5 +331,4 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; - } diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index b3a5f9ef..c8491f41 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -155,28 +155,36 @@ class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareI * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Returns the DependencyInjector container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) {} + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Returns the internal event manager * * @return \Phalcon\Events\ManagerInterface */ - public function getEventsManager(): EventsManagerInterface {} + public function getEventsManager(): EventsManagerInterface + { + } /** * Sets a custom events manager for a specific model @@ -184,7 +192,9 @@ public function getEventsManager(): EventsManagerInterface {} * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Events\ManagerInterface $eventsManager */ - public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) {} + public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) + { + } /** * Returns a custom events manager related to a model @@ -192,7 +202,9 @@ public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phal * @param \Phalcon\Mvc\ModelInterface $model * @return bool|\Phalcon\Events\ManagerInterface */ - public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) {} + public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) + { + } /** * Initializes a model in the model manager @@ -200,7 +212,9 @@ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) {} * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function initialize(\Phalcon\Mvc\ModelInterface $model): bool {} + public function initialize(\Phalcon\Mvc\ModelInterface $model): bool + { + } /** * Check whether a model is already initialized @@ -208,14 +222,18 @@ public function initialize(\Phalcon\Mvc\ModelInterface $model): bool {} * @param string $className * @return bool */ - public function isInitialized(string $className): bool {} + public function isInitialized(string $className): bool + { + } /** * Get last initialized model * * @return \Phalcon\Mvc\ModelInterface */ - public function getLastInitialized(): ModelInterface {} + public function getLastInitialized(): ModelInterface + { + } /** * Loads a model throwing an exception if it doesn't exist @@ -223,7 +241,9 @@ public function getLastInitialized(): ModelInterface {} * @param string $modelName * @return \Phalcon\Mvc\ModelInterface */ - public function load(string $modelName): ModelInterface {} + public function load(string $modelName): ModelInterface + { + } /** * Sets the prefix for all model sources. @@ -249,14 +269,18 @@ public function load(string $modelName): ModelInterface {} * * @param string $prefix */ - public function setModelPrefix(string $prefix) {} + public function setModelPrefix(string $prefix) + { + } /** * Returns the prefix for all model sources. * * @return string */ - public function getModelPrefix(): string {} + public function getModelPrefix(): string + { + } /** * Sets the mapped source for a model @@ -264,7 +288,9 @@ public function getModelPrefix(): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $source */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) {} + public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) + { + } /** * Check whether a model property is declared as public. @@ -280,7 +306,9 @@ public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $sourc * @param string $property * @return bool */ - final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool {} + final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool + { + } /** * Returns the mapped source for a model @@ -288,7 +316,9 @@ final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} + public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string + { + } /** * Sets the mapped schema for a model @@ -296,7 +326,9 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) {} + public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) + { + } /** * Returns the mapped schema for a model @@ -304,7 +336,9 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schem * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} + public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string + { + } /** * Sets both write and read connection service for a model @@ -312,7 +346,9 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string {} * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + { + } /** * Sets write connection service for a model @@ -320,7 +356,9 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + { + } /** * Sets read connection service for a model @@ -328,7 +366,9 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) {} + public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + { + } /** * Returns the connection to read data related to a model @@ -336,7 +376,9 @@ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, str * @param \Phalcon\Mvc\ModelInterface $model * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} + public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface + { + } /** * Returns the connection to write data related to a model @@ -344,7 +386,9 @@ public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterIn * @param \Phalcon\Mvc\ModelInterface $model * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface {} + public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface + { + } /** * Returns the connection to read or write data related to a model depending on the connection services. @@ -353,7 +397,9 @@ public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterI * @param mixed $connectionServices * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface {} + protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface + { + } /** * Returns the connection service name used to read data related to a model @@ -361,7 +407,9 @@ protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectio * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} + public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string + { + } /** * Returns the connection service name used to write data related to a model @@ -369,7 +417,9 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): st * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string {} + public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string + { + } /** * Returns the connection service name used to read or write data related to @@ -379,7 +429,9 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): s * @param mixed $connectionServices * @return string */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string {} + public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string + { + } /** * Receives events generated in the models and dispatches them to an @@ -389,7 +441,9 @@ public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $conne * @param string $eventName * @param \Phalcon\Mvc\ModelInterface $model */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) {} + public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) + { + } /** * Dispatch an event to the listeners and behaviors @@ -400,7 +454,9 @@ public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $mode * @param string $eventName * @param mixed $data */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) {} + public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) + { + } /** * Binds a behavior to a model @@ -408,7 +464,9 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventN * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior) {} + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior) + { + } /** * Sets if a model must keep snapshots @@ -416,7 +474,9 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) {} + public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) + { + } /** * Checks if a model is keeping snapshots for the queried records @@ -424,7 +484,9 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} + public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool + { + } /** * Sets if a model must use dynamic update instead of the all-field update @@ -432,7 +494,9 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool {} * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) {} + public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) + { + } /** * Checks if a model is using dynamic update instead of all-field update @@ -440,7 +504,9 @@ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynam * @param \Phalcon\Mvc\ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool {} + public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool + { + } /** * Setup a 1-1 relation between two models @@ -452,7 +518,9 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool { * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + { + } /** * Setup a relation reverse many to one between two models @@ -464,7 +532,9 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + { + } /** * Setup a relation 1-n between two models @@ -476,7 +546,9 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + { + } /** * Setups a relation n-m between two models @@ -491,7 +563,9 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface {} + public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface + { + } /** * Checks whether a model has a belongsTo relation with another model @@ -500,7 +574,9 @@ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, st * @param string $modelRelation * @return bool */ - public function existsBelongsTo(string $modelName, string $modelRelation): bool {} + public function existsBelongsTo(string $modelName, string $modelRelation): bool + { + } /** * Checks whether a model has a hasMany relation with another model @@ -509,7 +585,9 @@ public function existsBelongsTo(string $modelName, string $modelRelation): bool * @param string $modelRelation * @return bool */ - public function existsHasMany(string $modelName, string $modelRelation): bool {} + public function existsHasMany(string $modelName, string $modelRelation): bool + { + } /** * Checks whether a model has a hasOne relation with another model @@ -518,7 +596,9 @@ public function existsHasMany(string $modelName, string $modelRelation): bool {} * @param string $modelRelation * @return bool */ - public function existsHasOne(string $modelName, string $modelRelation): bool {} + public function existsHasOne(string $modelName, string $modelRelation): bool + { + } /** * Checks whether a model has a hasManyToMany relation with another model @@ -527,7 +607,9 @@ public function existsHasOne(string $modelName, string $modelRelation): bool {} * @param string $modelRelation * @return bool */ - public function existsHasManyToMany(string $modelName, string $modelRelation): bool {} + public function existsHasManyToMany(string $modelName, string $modelRelation): bool + { + } /** * Returns a relation by its alias @@ -536,7 +618,9 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b * @param string $alias * @return bool|\Phalcon\Mvc\Model\RelationInterface */ - public function getRelationByAlias(string $modelName, string $alias) {} + public function getRelationByAlias(string $modelName, string $alias) + { + } /** * Merge two arrays of find parameters @@ -545,7 +629,9 @@ public function getRelationByAlias(string $modelName, string $alias) {} * @param mixed $findParamsTwo * @return array */ - final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): array {} + final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): array + { + } /** * Helper method to query records based on a relation definition @@ -556,7 +642,9 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a * @param string $method * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + { + } /** * Returns a reusable object from the internal list @@ -564,7 +652,9 @@ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relatio * @param string $modelName * @param string $key */ - public function getReusableRecords(string $modelName, string $key) {} + public function getReusableRecords(string $modelName, string $key) + { + } /** * Stores a reusable record in the internal list @@ -573,12 +663,16 @@ public function getReusableRecords(string $modelName, string $key) {} * @param string $key * @param mixed $records */ - public function setReusableRecords(string $modelName, string $key, $records) {} + public function setReusableRecords(string $modelName, string $key, $records) + { + } /** * Clears the internal reusable list */ - public function clearReusableObjects() {} + public function clearReusableObjects() + { + } /** * Gets belongsTo related records from a model @@ -590,7 +684,9 @@ public function clearReusableObjects() {} * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + { + } /** * Gets hasMany related records from a model @@ -602,7 +698,9 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * @param string $method * @return bool|\Phalcon\Mvc\Model\ResultsetInterface */ - public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + { + } /** * Gets belongsTo related records from a model @@ -614,7 +712,9 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * @param string $method * @return bool|\Phalcon\Mvc\ModelInterface */ - public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) {} + public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + { + } /** * Gets all the belongsTo relations defined in a model @@ -628,7 +728,9 @@ public function getHasOneRecords(string $modelName, string $modelRelation, \Phal * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} + public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Gets hasMany relations defined on a model @@ -636,7 +738,9 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Gets hasOne relations defined on a model @@ -644,7 +748,9 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Gets hasManyToMany relations defined on a model @@ -652,7 +758,9 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Gets hasOne relations defined on a model @@ -660,7 +768,9 @@ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array {} + public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Query all the relationships defined on a model @@ -668,7 +778,9 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array { * @param string $modelName * @return array|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelations(string $modelName): array {} + public function getRelations(string $modelName): array + { + } /** * Query the first relationship defined between two models @@ -677,7 +789,9 @@ public function getRelations(string $modelName): array {} * @param string $second * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] */ - public function getRelationsBetween(string $first, string $second) {} + public function getRelationsBetween(string $first, string $second) + { + } /** * Creates a Phalcon\Mvc\Model\Query without execute it @@ -685,7 +799,9 @@ public function getRelationsBetween(string $first, string $second) {} * @param string $phql * @return \Phalcon\Mvc\Model\QueryInterface */ - public function createQuery(string $phql): QueryInterface {} + public function createQuery(string $phql): QueryInterface + { + } /** * Creates a Phalcon\Mvc\Model\Query and execute it @@ -695,7 +811,9 @@ public function createQuery(string $phql): QueryInterface {} * @param mixed $types * @return \Phalcon\Mvc\Model\QueryInterface */ - public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface {} + public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface + { + } /** * Creates a Phalcon\Mvc\Model\Query\Builder @@ -703,18 +821,23 @@ public function executeQuery(string $phql, $placeholders = null, $types = null): * @param mixed $params * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function createBuilder($params = null): BuilderInterface {} + public function createBuilder($params = null): BuilderInterface + { + } /** * Returns the last query created or executed in the models manager * * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getLastQuery(): QueryInterface {} + public function getLastQuery(): QueryInterface + { + } /** * Destroys the current PHQL cache */ - public function __destruct() {} - + public function __destruct() + { + } } diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 53b38204..db9719b9 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -449,5 +449,4 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param bool $dynamicUpdate */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); - } diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/mvc/model/MetaData.php index 255ba457..085cdbe1 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/mvc/model/MetaData.php @@ -118,7 +118,9 @@ abstract class MetaData implements InjectionAwareInterface, MetaDataInterface * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes that must be ignored from the INSERT SQL generation @@ -134,7 +136,9 @@ public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes that must be ignored from the UPDATE SQL generation @@ -150,7 +154,9 @@ public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model) * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes and their bind data types @@ -166,7 +172,9 @@ public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model) * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns the column map if any @@ -182,7 +190,9 @@ public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} + public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes (which have default values) and their default values @@ -198,7 +208,9 @@ public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array {} + public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes and their data types @@ -214,7 +226,9 @@ public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns attributes which types are numerical @@ -230,14 +244,18 @@ public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array {} + public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns the DependencyInjector container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Returns attributes allow empty strings @@ -253,7 +271,9 @@ public function getDI(): DiInterface {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns the name of identity field (if one is present) @@ -269,7 +289,9 @@ public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): ar * @param \Phalcon\Mvc\ModelInterface $model * @return string */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string {} + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string + { + } /** * Returns an array of fields which are not part of the primary key @@ -285,7 +307,9 @@ public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string {} * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns an array of not null attributes @@ -301,7 +325,9 @@ public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns an array of fields which are part of the primary key @@ -317,7 +343,9 @@ public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array {} + public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Returns the reverse column map if any @@ -333,14 +361,18 @@ public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): arr * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array {} + public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Return the strategy to obtain the meta-data * * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface */ - public function getStrategy(): StrategyInterface {} + public function getStrategy(): StrategyInterface + { + } /** * Check if a model has certain attribute @@ -358,7 +390,9 @@ public function getStrategy(): StrategyInterface {} * @param string $attribute * @return bool */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool {} + public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool + { + } /** * Checks if the internal meta-data container is empty @@ -371,7 +405,9 @@ public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribu * * @return bool */ - public function isEmpty(): bool {} + public function isEmpty(): bool + { + } /** * Reads metadata from the adapter @@ -379,7 +415,9 @@ public function isEmpty(): bool {} * @param string $key * @return array|null */ - public function read(string $key): ?array {} + public function read(string $key): ?array + { + } /** * Reads the ordered/reversed column map for certain model @@ -395,7 +433,9 @@ public function read(string $key): ?array {} * @param \Phalcon\Mvc\ModelInterface $model * @return array|null */ - final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array {} + final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array + { + } /** * Reads column-map information for certain model using a MODEL_ constant @@ -412,7 +452,9 @@ final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array * @param \Phalcon\Mvc\ModelInterface $model * @param int $index */ - final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} + final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) + { + } /** * Reads the complete meta-data for certain model @@ -428,7 +470,9 @@ final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int * @param \Phalcon\Mvc\ModelInterface $model * @return array */ - final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array {} + final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array + { + } /** * Reads meta-data for certain model @@ -445,7 +489,9 @@ final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array {} * @param \Phalcon\Mvc\ModelInterface $model * @param int $index */ - final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) {} + final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) + { + } /** * Resets internal meta-data in order to regenerate it @@ -454,7 +500,9 @@ final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int * $metaData->reset(); * ``` */ - public function reset() {} + public function reset() + { + } /** * Set the attributes that must be ignored from the INSERT SQL generation @@ -471,7 +519,9 @@ public function reset() {} * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} + public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + { + } /** * Set the attributes that must be ignored from the UPDATE SQL generation @@ -488,7 +538,9 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} + public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + { + } /** * Set the attributes that allow empty string values @@ -505,21 +557,27 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) {} + public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + { + } /** * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Set the meta-data extraction strategy * * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) {} + public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) + { + } /** * Writes the metadata to adapter @@ -527,7 +585,9 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strat * @param string $key * @param array $data */ - public function write(string $key, array $data) {} + public function write(string $key, array $data) + { + } /** * Writes meta-data for certain model using a MODEL_ constant @@ -548,7 +608,9 @@ public function write(string $key, array $data) {} * @param int $index * @param mixed $data */ - final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) {} + final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) + { + } /** * Initialize the metadata for certain table @@ -558,13 +620,16 @@ final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int * @param mixed $table * @param mixed $schema */ - final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) {} + final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) + { + } /** * Throws an exception when the metadata cannot be written * * @param mixed $option */ - private function throwWriteException($option) {} - + private function throwWriteException($option) + { + } } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index 56f836c1..d450ce5b 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -249,5 +249,4 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strat * @param array $data */ public function write(string $key, array $data); - } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index d7de03e4..843be4b3 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -148,7 +148,7 @@ class Query implements QueryInterface, InjectionAwareInterface protected $uniqueRow; - static protected $_irPhqlCache; + protected static $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -166,7 +166,9 @@ class Query implements QueryInterface, InjectionAwareInterface * however if a model got a transaction set inside it will use the local * transaction instead of this one */ - public function getTransaction() {} + public function getTransaction() + { + } /** * Phalcon\Mvc\Model\Query constructor @@ -175,21 +177,27 @@ public function getTransaction() {} * @param \Phalcon\Di\DiInterface $container * @param array $options */ - public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) {} + public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) + { + } /** * Sets the dependency injection container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Returns the dependency injection container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Tells to the query if only the first row in the resultset must be @@ -198,7 +206,9 @@ public function getDI(): DiInterface {} * @param bool $uniqueRow * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setUniqueRow(bool $uniqueRow): QueryInterface {} + public function setUniqueRow(bool $uniqueRow): QueryInterface + { + } /** * Check if the query is programmed to get only the first row in the @@ -206,7 +216,9 @@ public function setUniqueRow(bool $uniqueRow): QueryInterface {} * * @return bool */ - public function getUniqueRow(): bool {} + public function getUniqueRow(): bool + { + } /** * Replaces the model's name to its source name in a qualified-name @@ -215,7 +227,9 @@ public function getUniqueRow(): bool {} * @param array $expr * @return array */ - final protected function _getQualified(array $expr): array {} + final protected function _getQualified(array $expr): array + { + } /** * Resolves an expression in a single call argument @@ -223,7 +237,9 @@ final protected function _getQualified(array $expr): array {} * @param array $argument * @return array */ - final protected function _getCallArgument(array $argument): array {} + final protected function _getCallArgument(array $argument): array + { + } /** * Resolves an expression in a single call argument @@ -231,7 +247,9 @@ final protected function _getCallArgument(array $argument): array {} * @param array $expr * @return array */ - final protected function _getCaseExpression(array $expr): array {} + final protected function _getCaseExpression(array $expr): array + { + } /** * Resolves an expression in a single call argument @@ -239,7 +257,9 @@ final protected function _getCaseExpression(array $expr): array {} * @param array $expr * @return array */ - final protected function _getFunctionCall(array $expr): array {} + final protected function _getFunctionCall(array $expr): array + { + } /** * Resolves an expression from its intermediate code into a string @@ -248,7 +268,9 @@ final protected function _getFunctionCall(array $expr): array {} * @param bool $quoting * @return string */ - final protected function _getExpression(array $expr, bool $quoting = true): string {} + final protected function _getExpression(array $expr, bool $quoting = true): string + { + } /** * Resolves a column from its intermediate representation into an array @@ -257,7 +279,9 @@ final protected function _getExpression(array $expr, bool $quoting = true): stri * @param array $column * @return array */ - final protected function _getSelectColumn(array $column): array {} + final protected function _getSelectColumn(array $column): array + { + } /** * Resolves a table in a SELECT statement checking if the model exists @@ -266,7 +290,9 @@ final protected function _getSelectColumn(array $column): array {} * @param array $qualifiedName * @return string */ - final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) {} + final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) + { + } /** * Resolves a JOIN clause checking if the associated models exist @@ -275,7 +301,9 @@ final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, * @param array $join * @return array */ - final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array {} + final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array + { + } /** * Resolves a JOIN type @@ -283,7 +311,9 @@ final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, * @param array $join * @return string */ - final protected function _getJoinType(array $join): string {} + final protected function _getJoinType(array $join): string + { + } /** * Resolves joins involving has-one/belongs-to/has-many relations @@ -295,7 +325,9 @@ final protected function _getJoinType(array $join): string {} * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} + final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array + { + } /** * Resolves joins involving many-to-many relations @@ -307,7 +339,9 @@ final protected function _getSingleJoin(string $joinType, $joinSource, string $m * @param \Phalcon\Mvc\Model\RelationInterface $relation * @return array */ - final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array {} + final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array + { + } /** * Processes the JOINs in the query returning an internal representation for @@ -316,7 +350,9 @@ final protected function _getMultiJoin(string $joinType, $joinSource, string $mo * @param array $select * @return array */ - final protected function _getJoins(array $select): array {} + final protected function _getJoins(array $select): array + { + } /** * Returns a processed order clause for a SELECT statement @@ -324,7 +360,9 @@ final protected function _getJoins(array $select): array {} * @param array|string $order * @return array */ - final protected function _getOrderClause($order): array {} + final protected function _getOrderClause($order): array + { + } /** * Returns a processed group clause for a SELECT statement @@ -332,7 +370,9 @@ final protected function _getOrderClause($order): array {} * @param array $group * @return array */ - final protected function _getGroupClause(array $group): array {} + final protected function _getGroupClause(array $group): array + { + } /** * Returns a processed limit clause for a SELECT statement @@ -340,7 +380,9 @@ final protected function _getGroupClause(array $group): array {} * @param array $limitClause * @return array */ - final protected function _getLimitClause(array $limitClause): array {} + final protected function _getLimitClause(array $limitClause): array + { + } /** * Analyzes a SELECT intermediate code and produces an array to be executed later @@ -349,7 +391,9 @@ final protected function _getLimitClause(array $limitClause): array {} * @param bool $merge * @return array */ - final protected function _prepareSelect($ast = null, bool $merge = false): array {} + final protected function _prepareSelect($ast = null, bool $merge = false): array + { + } /** * Analyzes an INSERT intermediate code and produces an array to be executed @@ -357,7 +401,9 @@ final protected function _prepareSelect($ast = null, bool $merge = false): array * * @return array */ - final protected function _prepareInsert(): array {} + final protected function _prepareInsert(): array + { + } /** * Analyzes an UPDATE intermediate code and produces an array to be executed @@ -365,7 +411,9 @@ final protected function _prepareInsert(): array {} * * @return array */ - final protected function _prepareUpdate(): array {} + final protected function _prepareUpdate(): array + { + } /** * Analyzes a DELETE intermediate code and produces an array to be executed @@ -373,7 +421,9 @@ final protected function _prepareUpdate(): array {} * * @return array */ - final protected function _prepareDelete(): array {} + final protected function _prepareDelete(): array + { + } /** * Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang @@ -382,14 +432,18 @@ final protected function _prepareDelete(): array {} * * @return array */ - public function parse(): array {} + public function parse(): array + { + } /** * Returns the current cache backend instance * * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getCache(): AdapterInterface {} + public function getCache(): AdapterInterface + { + } /** * Executes the SELECT intermediate representation producing a @@ -401,7 +455,9 @@ public function getCache(): AdapterInterface {} * @param bool $simulate * @return array|\Phalcon\Mvc\Model\ResultsetInterface */ - final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) {} + final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) + { + } /** * Executes the INSERT intermediate representation producing a @@ -412,7 +468,9 @@ final protected function _executeSelect(array $intermediate, array $bindParams, * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + { + } /** * Executes the UPDATE intermediate representation producing a @@ -423,7 +481,9 @@ final protected function _executeInsert(array $intermediate, array $bindParams, * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + { + } /** * Executes the DELETE intermediate representation producing a @@ -434,7 +494,9 @@ final protected function _executeUpdate(array $intermediate, array $bindParams, * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface */ - final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface {} + final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface + { + } /** * Query the records on which the UPDATE/DELETE operation will be done @@ -445,7 +507,9 @@ final protected function _executeDelete(array $intermediate, array $bindParams, * @param array $bindTypes * @return \Phalcon\Mvc\Model\ResultsetInterface */ - final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface {} + final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface + { + } /** * Executes a parsed PHQL statement @@ -454,7 +518,9 @@ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, * @param array $bindTypes * @return mixed */ - public function execute(array $bindParams = array(), array $bindTypes = array()) {} + public function execute(array $bindParams = array(), array $bindTypes = array()) + { + } /** * Executes the query returning the first result @@ -463,7 +529,9 @@ public function execute(array $bindParams = array(), array $bindTypes = array()) * @param array $bindTypes * @return \Phalcon\Mvc\ModelInterface */ - public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface {} + public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface + { + } /** * Sets the type of PHQL statement to be executed @@ -471,14 +539,18 @@ public function getSingleResult(array $bindParams = array(), array $bindTypes = * @param int $type * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setType(int $type): QueryInterface {} + public function setType(int $type): QueryInterface + { + } /** * Gets the type of PHQL statement executed * * @return int */ - public function getType(): int {} + public function getType(): int + { + } /** * Set default bind parameters @@ -487,14 +559,18 @@ public function getType(): int {} * @param bool $merge * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindParams(array $bindParams, bool $merge = false): QueryInterface {} + public function setBindParams(array $bindParams, bool $merge = false): QueryInterface + { + } /** * Returns default bind params * * @return array */ - public function getBindParams(): array {} + public function getBindParams(): array + { + } /** * Set default bind parameters @@ -503,7 +579,9 @@ public function getBindParams(): array {} * @param bool $merge * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface {} + public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface + { + } /** * Set SHARED LOCK clause @@ -511,14 +589,18 @@ public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterf * @param bool $sharedLock * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setSharedLock(bool $sharedLock = false): QueryInterface {} + public function setSharedLock(bool $sharedLock = false): QueryInterface + { + } /** * Returns default bind types * * @return array */ - public function getBindTypes(): array {} + public function getBindTypes(): array + { + } /** * Allows to set the IR to be executed @@ -526,14 +608,18 @@ public function getBindTypes(): array {} * @param array $intermediate * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setIntermediate(array $intermediate): QueryInterface {} + public function setIntermediate(array $intermediate): QueryInterface + { + } /** * Returns the intermediate representation of the PHQL statement * * @return array */ - public function getIntermediate(): array {} + public function getIntermediate(): array + { + } /** * Sets the cache parameters of the query @@ -541,14 +627,18 @@ public function getIntermediate(): array {} * @param array $cacheOptions * @return \Phalcon\Mvc\Model\QueryInterface */ - public function cache(array $cacheOptions): QueryInterface {} + public function cache(array $cacheOptions): QueryInterface + { + } /** * Returns the current cache options * * @return array */ - public function getCacheOptions(): array {} + public function getCacheOptions(): array + { + } /** * Returns the SQL to be generated by the internal PHQL (only works in @@ -556,12 +646,16 @@ public function getCacheOptions(): array {} * * @return array */ - public function getSql(): array {} + public function getSql(): array + { + } /** * Destroys the internal PHQL cache */ - public static function clean() {} + public static function clean() + { + } /** * Gets the read connection from the model if there is no transaction set @@ -573,7 +667,9 @@ public static function clean() {} * @param array $bindTypes * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} + protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + { + } /** * Gets the write connection from the model if there is no transaction @@ -585,7 +681,9 @@ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $ * @param array $bindTypes * @return \Phalcon\Db\Adapter\AdapterInterface */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface {} + protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + { + } /** * allows to wrap a transaction around all queries @@ -593,6 +691,7 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array * @param \Phalcon\Mvc\Model\TransactionInterface $transaction * @return \Phalcon\Mvc\Model\QueryInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface {} - + public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface + { + } } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 9a795463..8cce6248 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -123,5 +123,4 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; - } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index de06d3e2..b7c4a10e 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -76,42 +76,54 @@ class Relation implements RelationInterface * @param string|array $referencedFields * @param array $options */ - public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) {} + public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) + { + } /** * Returns the fields * * @return string|array */ - public function getFields() {} + public function getFields() + { + } /** * Returns the foreign key configuration * * @return string|array */ - public function getForeignKey() {} + public function getForeignKey() + { + } /** * Gets the intermediate fields for has--through relations * * @return string|array */ - public function getIntermediateFields() {} + public function getIntermediateFields() + { + } /** * Gets the intermediate model for has--through relations * * @return string */ - public function getIntermediateModel(): string {} + public function getIntermediateModel(): string + { + } /** * Gets the intermediate referenced fields for has--through relations * * @return string|array */ - public function getIntermediateReferencedFields() {} + public function getIntermediateReferencedFields() + { + } /** * Returns an option by the specified name @@ -119,63 +131,81 @@ public function getIntermediateReferencedFields() {} * * @param string $name */ - public function getOption(string $name) {} + public function getOption(string $name) + { + } /** * Returns the options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Returns parameters that must be always used when the related records are obtained * * @return array */ - public function getParams() {} + public function getParams() + { + } /** * Returns the relation type * * @return int */ - public function getType(): int {} + public function getType(): int + { + } /** * Returns the referenced fields * * @return string|array */ - public function getReferencedFields() {} + public function getReferencedFields() + { + } /** * Returns the referenced model * * @return string */ - public function getReferencedModel(): string {} + public function getReferencedModel(): string + { + } /** * Check whether the relation act as a foreign key * * @return bool */ - public function isForeignKey(): bool {} + public function isForeignKey(): bool + { + } /** * Check whether the relation is a 'many-to-many' relation or not * * @return bool */ - public function isThrough(): bool {} + public function isThrough(): bool + { + } /** * Check if records returned by getting belongs-to/has-many are implicitly cached during the current request * * @return bool */ - public function isReusable(): bool {} + public function isReusable(): bool + { + } /** * Sets the intermediate model data for has--through relations @@ -184,6 +214,7 @@ public function isReusable(): bool {} * @param string $intermediateModel * @param string $intermediateReferencedFields */ - public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) {} - + public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) + { + } } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index d0db540d..a0e757fe 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -126,5 +126,4 @@ public function isThrough(): bool; * @param string|array $intermediateReferencedFields */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); - } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 942dfe88..8849286e 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -26,5 +26,4 @@ interface ResultInterface * @return bool|\Phalcon\Mvc\ModelInterface */ public function setDirtyState(int $dirtyState); - } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index f9236731..b2a70358 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -61,8 +61,7 @@ * } * ``` */ -abstract class Resultset - implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable +abstract class Resultset implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable { const HYDRATE_ARRAYS = 1; @@ -118,14 +117,18 @@ abstract class Resultset * @param \Phalcon\Db\ResultInterface|false $result * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + { + } /** * Counts how many rows are in the resultset * * @return int */ - final public function count(): int {} + final public function count(): int + { + } /** * Deletes every record in the resultset @@ -133,7 +136,9 @@ final public function count(): int {} * @param \Closure $conditionCallback * @return bool */ - public function delete(\Closure $conditionCallback = null): bool {} + public function delete(\Closure $conditionCallback = null): bool + { + } /** * Filters a resultset returning only those the developer requires @@ -151,56 +156,72 @@ public function delete(\Closure $conditionCallback = null): bool {} * @param callable $filter * @return array|\Phalcon\Mvc\ModelInterface[] */ - public function filter($filter): array {} + public function filter($filter): array + { + } /** * Returns the associated cache for the resultset * * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function getCache(): AdapterInterface {} + public function getCache(): AdapterInterface + { + } /** * Get first row in the resultset * * @return null|\Phalcon\Mvc\ModelInterface */ - public function getFirst(): ?ModelInterface {} + public function getFirst(): ?ModelInterface + { + } /** * Returns the current hydration mode * * @return int */ - public function getHydrateMode(): int {} + public function getHydrateMode(): int + { + } /** * Get last row in the resultset * * @return null|\Phalcon\Mvc\ModelInterface */ - public function getLast(): ?ModelInterface {} + public function getLast(): ?ModelInterface + { + } /** * Returns the error messages produced by a batch operation * * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getMessages(): array {} + public function getMessages(): array + { + } /** * Returns the internal type of data retrieval that the resultset is using * * @return int */ - public function getType(): int {} + public function getType(): int + { + } /** * Tell if the resultset if fresh or an old one cached * * @return bool */ - public function isFresh(): bool {} + public function isFresh(): bool + { + } /** * Returns serialised model objects as array for json_encode. @@ -214,19 +235,25 @@ public function isFresh(): bool {} * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Gets pointer number of active row in the resultset * * @return int|null */ - public function key(): ?int {} + public function key(): ?int + { + } /** * Moves cursor to next row in the resultset */ - public function next() {} + public function next() + { + } /** * Gets row in a specific position of the resultset @@ -234,7 +261,9 @@ public function next() {} * @param mixed $index * @return bool|\Phalcon\Mvc\ModelInterface */ - public function offsetGet($index) {} + public function offsetGet($index) + { + } /** * Checks whether offset exists in the resultset @@ -242,7 +271,9 @@ public function offsetGet($index) {} * @param mixed $index * @return bool */ - public function offsetExists($index): bool {} + public function offsetExists($index): bool + { + } /** * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface @@ -250,19 +281,25 @@ public function offsetExists($index): bool {} * @param int $index * @param \Phalcon\Mvc\ModelInterface $value */ - public function offsetSet($index, $value) {} + public function offsetSet($index, $value) + { + } /** * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param mixed $offset */ - public function offsetUnset($offset) {} + public function offsetUnset($offset) + { + } /** * Rewinds resultset to its beginning */ - final public function rewind() {} + final public function rewind() + { + } /** * Changes the internal pointer to a specific position in the resultset. @@ -270,7 +307,9 @@ final public function rewind() {} * * @param mixed $position */ - final public function seek($position) {} + final public function seek($position) + { + } /** * Sets the hydration mode in the resultset @@ -278,7 +317,9 @@ final public function seek($position) {} * @param int $hydrateMode * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function setHydrateMode(int $hydrateMode): ResultsetInterface {} + public function setHydrateMode(int $hydrateMode): ResultsetInterface + { + } /** * Set if the resultset is fresh or an old one cached @@ -286,7 +327,9 @@ public function setHydrateMode(int $hydrateMode): ResultsetInterface {} * @param bool $isFresh * @return \Phalcon\Mvc\Model\ResultsetInterface */ - public function setIsFresh(bool $isFresh): ResultsetInterface {} + public function setIsFresh(bool $isFresh): ResultsetInterface + { + } /** * Updates every record in the resultset @@ -295,13 +338,16 @@ public function setIsFresh(bool $isFresh): ResultsetInterface {} * @param \Closure $conditionCallback * @return bool */ - public function update($data, \Closure $conditionCallback = null): bool {} + public function update($data, \Closure $conditionCallback = null): bool + { + } /** * Check whether internal resource has rows to fetch * * @return bool */ - public function valid(): bool {} - + public function valid(): bool + { + } } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index e97a9ddc..02ac5b9a 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -129,5 +129,4 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; - } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index fc45ac10..3efb7dc4 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -29,7 +29,9 @@ class Row implements EntityInterface, ResultInterface, ArrayAccess, JsonSerializ * * @return array */ - public function jsonSerialize(): array {} + public function jsonSerialize(): array + { + } /** * Gets a record in a specific position of the row @@ -39,7 +41,9 @@ public function jsonSerialize(): array {} * @param mixed $index * @return mixed */ - public function offsetGet($index) {} + public function offsetGet($index) + { + } /** * Checks whether offset exists in the row @@ -47,7 +51,9 @@ public function offsetGet($index) {} * @param string|int $index * @return bool */ - public function offsetExists($index): bool {} + public function offsetExists($index): bool + { + } /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface @@ -55,14 +61,18 @@ public function offsetExists($index): bool {} * @param string|int $index * @param \Phalcon\Mvc\ModelInterface $value */ - public function offsetSet($index, $value) {} + public function offsetSet($index, $value) + { + } /** * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param string|int $offset */ - public function offsetUnset($offset) {} + public function offsetUnset($offset) + { + } /** * Reads an attribute value by its name @@ -74,7 +84,9 @@ public function offsetUnset($offset) {} * @param string $attribute * @return mixed */ - public function readAttribute(string $attribute) {} + public function readAttribute(string $attribute) + { + } /** * Set the current object's state @@ -82,14 +94,18 @@ public function readAttribute(string $attribute) {} * @param int $dirtyState * @return bool|\Phalcon\Mvc\ModelInterface */ - public function setDirtyState(int $dirtyState) {} + public function setDirtyState(int $dirtyState) + { + } /** * Returns the instance as an array representation * * @return array */ - public function toArray(): array {} + public function toArray(): array + { + } /** * Writes an attribute value by its name @@ -101,6 +117,7 @@ public function toArray(): array {} * @param string $attribute * @param mixed $value */ - public function writeAttribute(string $attribute, $value) {} - + public function writeAttribute(string $attribute, $value) + { + } } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index e2997872..c2b67e46 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -89,49 +89,63 @@ class Transaction implements TransactionInterface * @param bool $autoBegin * @param string $service */ - public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') {} + public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') + { + } /** * Starts the transaction * * @return bool */ - public function begin(): bool {} + public function begin(): bool + { + } /** * Commits the transaction * * @return bool */ - public function commit(): bool {} + public function commit(): bool + { + } /** * Returns the connection related to transaction * * @return \Phalcon\Db\Adapter\AdapterInterface */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface {} + public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface + { + } /** * Returns validations messages from last save try * * @return array */ - public function getMessages(): array {} + public function getMessages(): array + { + } /** * Checks whether transaction is managed by a transaction manager * * @return bool */ - public function isManaged(): bool {} + public function isManaged(): bool + { + } /** * Checks whether internal connection is under an active transaction * * @return bool */ - public function isValid(): bool {} + public function isValid(): bool + { + } /** * Rollbacks the transaction @@ -140,35 +154,45 @@ public function isValid(): bool {} * @param \Phalcon\Mvc\ModelInterface $rollbackRecord * @return bool */ - public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool {} + public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool + { + } /** * Sets if is a reused transaction or new once * * @param bool $isNew */ - public function setIsNewTransaction(bool $isNew) {} + public function setIsNewTransaction(bool $isNew) + { + } /** * Sets flag to rollback on abort the HTTP connection * * @param bool $rollbackOnAbort */ - public function setRollbackOnAbort(bool $rollbackOnAbort) {} + public function setRollbackOnAbort(bool $rollbackOnAbort) + { + } /** * Sets object which generates rollback action * * @param \Phalcon\Mvc\ModelInterface $record */ - public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) {} + public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) + { + } /** * Sets transaction manager related to the transaction * * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) {} + public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) + { + } /** * Enables throwing exception @@ -176,6 +200,7 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @param bool $status * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function throwRollbackException(bool $status): TransactionInterface {} - + public function throwRollbackException(bool $status): TransactionInterface + { + } } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index 18183f61..26f1ae87 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -105,5 +105,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; - } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index 1520e23e..dea5c291 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -34,20 +34,25 @@ class ValidationFailed extends Exception * @param \Phalcon\Mvc\ModelInterface $model * @param Message[] $validationMessages */ - public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) {} + public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) + { + } /** * Returns the complete group of messages produced in the validation * * @return array|Message[] */ - public function getMessages(): array {} + public function getMessages(): array + { + } /** * Returns the model that generated the messages * * @return \Phalcon\Mvc\ModelInterface */ - public function getModel(): ModelInterface {} - + public function getModel(): ModelInterface + { + } } diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/mvc/model/behavior/SoftDelete.php index 5ee497c3..b87f1e4f 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/model/behavior/SoftDelete.php @@ -28,6 +28,7 @@ class SoftDelete extends Behavior * @param string $type * @param \Phalcon\Mvc\ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} - + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + { + } } diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/mvc/model/behavior/Timestampable.php index c15fff34..ed4a9c71 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/mvc/model/behavior/Timestampable.php @@ -28,11 +28,14 @@ class Timestampable extends Behavior * @param string $type * @param \Phalcon\Mvc\ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) {} + public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + { + } /** * @param array $options */ - private function getTimestamp(array $options) {} - + private function getTimestamp(array $options) + { + } } diff --git a/src/Phalcon/mvc/model/binder/BindableInterface.php b/src/Phalcon/mvc/model/binder/BindableInterface.php index 48dba9ec..6823b7ee 100644 --- a/src/Phalcon/mvc/model/binder/BindableInterface.php +++ b/src/Phalcon/mvc/model/binder/BindableInterface.php @@ -26,5 +26,4 @@ interface BindableInterface * @return string|array */ public function getModelName(); - } diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index 3381986e..4a58b82e 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -40,6 +40,7 @@ class Apcu extends MetaData * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) {} - + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) + { + } } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index 8e42cd19..a5b1e751 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -29,11 +29,14 @@ class Libmemcached extends MetaData * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + { + } /** * Flush Memcache data and resets internal meta-data in order to regenerate it */ - public function reset() {} - + public function reset() + { + } } diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index f52fe8a6..a383d9d3 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -27,7 +27,9 @@ class Memory extends MetaData * * @param array $options */ - public function __construct($options = null) {} + public function __construct($options = null) + { + } /** * Reads the meta-data from temporal memory @@ -35,7 +37,9 @@ public function __construct($options = null) {} * @param string $key * @return array|null */ - public function read(string $key): ?array {} + public function read(string $key): ?array + { + } /** * Writes the meta-data to temporal memory @@ -43,6 +47,7 @@ public function read(string $key): ?array {} * @param string $key * @param array $data */ - public function write(string $key, array $data) {} - + public function write(string $key, array $data) + { + } } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index 32dd7728..6249a178 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -43,11 +43,14 @@ class Redis extends MetaData * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) {} + public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + { + } /** * Flush Redis data and resets internal meta-data in order to regenerate it */ - public function reset() {} - + public function reset() + { + } } diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/StrategyInterface.php index 8a8814c3..6164dc93 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/StrategyInterface.php @@ -32,5 +32,4 @@ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\Di * @return array */ public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; - } diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Stream.php index 50128b68..517319ad 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -37,7 +37,9 @@ class Stream extends MetaData * * @param array $options */ - public function __construct($options = null) {} + public function __construct($options = null) + { + } /** * Reads meta-data from files @@ -45,7 +47,9 @@ public function __construct($options = null) {} * @param string $key * @return array|null */ - public function read(string $key): ?array {} + public function read(string $key): ?array + { + } /** * Writes the meta-data to files @@ -53,13 +57,16 @@ public function read(string $key): ?array {} * @param string $key * @param array $data */ - public function write(string $key, array $data) {} + public function write(string $key, array $data) + { + } /** * Throws an exception when the metadata cannot be written * * @param mixed $option */ - private function throwWriteException($option) {} - + private function throwWriteException($option) + { + } } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 4f569660..63bb2e13 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -23,7 +23,9 @@ class Annotations implements StrategyInterface * @param \Phalcon\Di\DiInterface $container * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + { + } /** * The meta-data is obtained by reading the column descriptions from the database information schema @@ -32,6 +34,7 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon * @param \Phalcon\Di\DiInterface $container * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} - + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + { + } } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index 3677fc82..a9326686 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -28,7 +28,9 @@ class Introspection implements StrategyInterface * @param \Phalcon\Di\DiInterface $container * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} + final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + { + } /** * The meta-data is obtained by reading the column descriptions from the database information schema @@ -37,6 +39,7 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon * @param \Phalcon\Di\DiInterface $container * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array {} - + final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + { + } } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index 791b9783..266a8d43 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -110,7 +110,9 @@ class Builder implements BuilderInterface, InjectionAwareInterface * @param mixed $params * @param \Phalcon\Di\DiInterface $container */ - public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) {} + public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) + { + } /** * Add a model to take part of the query @@ -132,7 +134,9 @@ public function __construct($params = null, \Phalcon\Di\DiInterface $container = * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function addFrom(string $model, string $alias = null): BuilderInterface {} + public function addFrom(string $model, string $alias = null): BuilderInterface + { + } /** * Appends a condition to the current HAVING conditions clause using a AND operator @@ -153,7 +157,9 @@ public function addFrom(string $model, string $alias = null): BuilderInterface { * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Appends a condition to the current WHERE conditions using a AND operator @@ -175,7 +181,9 @@ public function andHaving(string $conditions, array $bindParams = array(), array * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Automatically escapes identifiers but only if they need to be escaped. @@ -183,7 +191,9 @@ public function andWhere(string $conditions, array $bindParams = array(), array * @param string $identifier * @return string */ - final public function autoescape(string $identifier): string {} + final public function autoescape(string $identifier): string + { + } /** * Appends a BETWEEN condition to the current HAVING conditions clause @@ -198,7 +208,9 @@ final public function autoescape(string $identifier): string {} * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Appends a BETWEEN condition to the current WHERE conditions @@ -213,7 +225,9 @@ public function betweenHaving(string $expr, $minimum, $maximum, string $operator * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Sets the columns to be queried @@ -239,7 +253,9 @@ public function betweenWhere(string $expr, $minimum, $maximum, string $operator * @param mixed $columns * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function columns($columns): BuilderInterface {} + public function columns($columns): BuilderInterface + { + } /** * Sets SELECT DISTINCT / SELECT ALL flag @@ -252,7 +268,9 @@ public function columns($columns): BuilderInterface {} * @param mixed $distinct * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function distinct($distinct): BuilderInterface {} + public function distinct($distinct): BuilderInterface + { + } /** * Sets a FOR UPDATE clause @@ -264,7 +282,9 @@ public function distinct($distinct): BuilderInterface {} * @param bool $forUpdate * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function forUpdate(bool $forUpdate): BuilderInterface {} + public function forUpdate(bool $forUpdate): BuilderInterface + { + } /** * Sets the models who makes part of the query @@ -292,119 +312,153 @@ public function forUpdate(bool $forUpdate): BuilderInterface {} * @param mixed $models * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function from($models): BuilderInterface {} + public function from($models): BuilderInterface + { + } /** * Returns default bind params * * @return array */ - public function getBindParams(): array {} + public function getBindParams(): array + { + } /** * Returns default bind types * * @return array */ - public function getBindTypes(): array {} + public function getBindTypes(): array + { + } /** * Return the columns to be queried * * @return string|array */ - public function getColumns() {} + public function getColumns() + { + } /** * Returns the DependencyInjector container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Returns SELECT DISTINCT / SELECT ALL flag * * @return bool */ - public function getDistinct(): bool {} + public function getDistinct(): bool + { + } /** * Return the models who makes part of the query * * @return string|array */ - public function getFrom() {} + public function getFrom() + { + } /** * Returns the GROUP BY clause * * @return array */ - public function getGroupBy(): array {} + public function getGroupBy(): array + { + } /** * Return the current having clause * * @return string */ - public function getHaving(): string {} + public function getHaving(): string + { + } /** * Return join parts of the query * * @return array */ - public function getJoins(): array {} + public function getJoins(): array + { + } /** * Returns the current LIMIT clause * * @return string|array */ - public function getLimit() {} + public function getLimit() + { + } /** * Returns the models involved in the query * * @return string|array|null */ - public function getModels() {} + public function getModels() + { + } /** * Returns the current OFFSET clause * * @return int */ - public function getOffset(): int {} + public function getOffset(): int + { + } /** * Returns the set ORDER BY clause * * @return string|array */ - public function getOrderBy() {} + public function getOrderBy() + { + } /** * Returns a PHQL statement built based on the builder parameters * * @return string */ - final public function getPhql(): string {} + final public function getPhql(): string + { + } /** * Returns the query built * * @return \Phalcon\Mvc\Model\QueryInterface */ - public function getQuery(): QueryInterface {} + public function getQuery(): QueryInterface + { + } /** * Return the conditions for the query * * @return string|array */ - public function getWhere() {} + public function getWhere() + { + } /** * Sets a GROUP BY clause @@ -420,7 +474,9 @@ public function getWhere() {} * @param string|array $group * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function groupBy($group): BuilderInterface {} + public function groupBy($group): BuilderInterface + { + } /** * Sets the HAVING condition clause @@ -441,7 +497,9 @@ public function groupBy($group): BuilderInterface {} * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Appends an IN condition to the current HAVING conditions clause @@ -455,7 +513,9 @@ public function having($conditions, array $bindParams = array(), array $bindType * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Adds an INNER join to the query @@ -485,7 +545,9 @@ public function inHaving(string $expr, array $values, string $operator = Builder * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface + { + } /** * Appends an IN condition to the current WHERE conditions @@ -502,7 +564,9 @@ public function innerJoin(string $model, string $conditions = null, string $alia * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Adds an :type: join (by default type - INNER) to the query @@ -541,7 +605,9 @@ public function inWhere(string $expr, array $values, string $operator = BuilderI * @param string $type * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface {} + public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface + { + } /** * Adds a LEFT join to the query @@ -559,7 +625,9 @@ public function join(string $model, string $conditions = null, string $alias = n * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface + { + } /** * Sets a LIMIT clause, optionally an offset clause @@ -574,7 +642,9 @@ public function leftJoin(string $model, string $conditions = null, string $alias * @param mixed $offset * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function limit(int $limit, $offset = null): BuilderInterface {} + public function limit(int $limit, $offset = null): BuilderInterface + { + } /** * Appends a NOT BETWEEN condition to the current HAVING conditions clause @@ -589,7 +659,9 @@ public function limit(int $limit, $offset = null): BuilderInterface {} * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Appends a NOT BETWEEN condition to the current WHERE conditions @@ -604,7 +676,9 @@ public function notBetweenHaving(string $expr, $minimum, $maximum, string $opera * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Appends a NOT IN condition to the current HAVING conditions clause @@ -618,7 +692,9 @@ public function notBetweenWhere(string $expr, $minimum, $maximum, string $operat * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Appends a NOT IN condition to the current WHERE conditions @@ -632,7 +708,9 @@ public function notInHaving(string $expr, array $values, string $operator = Buil * @param string $operator * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface {} + public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface + { + } /** * Sets an OFFSET clause @@ -644,7 +722,9 @@ public function notInWhere(string $expr, array $values, string $operator = Build * @param int $offset * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function offset(int $offset): BuilderInterface {} + public function offset(int $offset): BuilderInterface + { + } /** * Sets an ORDER BY condition clause @@ -658,7 +738,9 @@ public function offset(int $offset): BuilderInterface {} * @param string|array $orderBy * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orderBy($orderBy): BuilderInterface {} + public function orderBy($orderBy): BuilderInterface + { + } /** * Appends a condition to the current HAVING conditions clause using an OR operator @@ -679,7 +761,9 @@ public function orderBy($orderBy): BuilderInterface {} * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Appends a condition to the current conditions using an OR operator @@ -701,7 +785,9 @@ public function orHaving(string $conditions, array $bindParams = array(), array * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Adds a RIGHT join to the query @@ -719,7 +805,9 @@ public function orWhere(string $conditions, array $bindParams = array(), array $ * @param string $alias * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface {} + public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface + { + } /** * Set default bind parameters @@ -728,7 +816,9 @@ public function rightJoin(string $model, string $conditions = null, string $alia * @param bool $merge * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface {} + public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface + { + } /** * Set default bind types @@ -737,14 +827,18 @@ public function setBindParams(array $bindParams, bool $merge = false): BuilderIn * @param bool $merge * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface {} + public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface + { + } /** * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Sets the query WHERE conditions @@ -768,7 +862,9 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface {} + public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface + { + } /** * Appends a BETWEEN condition @@ -780,7 +876,9 @@ public function where(string $conditions, array $bindParams = array(), array $bi * @param mixed $maximum * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} + protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface + { + } /** * Appends an IN condition @@ -791,7 +889,9 @@ protected function conditionBetween(string $clause, string $operator, string $ex * @param array $values * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} + protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface + { + } /** * Appends a NOT BETWEEN condition @@ -803,7 +903,9 @@ protected function conditionIn(string $clause, string $operator, string $expr, a * @param mixed $maximum * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface {} + protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface + { + } /** * Appends a NOT IN condition @@ -814,6 +916,7 @@ protected function conditionNotBetween(string $clause, string $operator, string * @param array $values * @return \Phalcon\Mvc\Model\Query\BuilderInterface */ - protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface {} - + protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface + { + } } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index e4843b4e..af87ecf0 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -353,5 +353,4 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; - } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 4c2cb267..6a72da16 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -39,6 +39,7 @@ abstract class Lang * @param string $phql * @return string */ - public static function parsePHQL(string $phql): string {} - + public static function parsePHQL(string $phql): string + { + } } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index 2c2fda24..1c9571a3 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -55,27 +55,34 @@ class Status implements StatusInterface * @param bool $success * @param \Phalcon\Mvc\ModelInterface $model */ - public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) {} + public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) + { + } /** * Returns the messages produced because of a failed operation * * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getMessages(): array {} + public function getMessages(): array + { + } /** * Returns the model that executed the action * * @return \Phalcon\Mvc\ModelInterface */ - public function getModel(): ModelInterface {} + public function getModel(): ModelInterface + { + } /** * Allows to check if the executed operation was successful * * @return bool */ - public function success(): bool {} - + public function success(): bool + { + } } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index 2bb1c34b..ba026840 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -41,5 +41,4 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; - } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 3c645df5..4b97d6a1 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -39,14 +39,18 @@ class Complex extends Resultset implements ResultsetInterface * @param \Phalcon\Db\ResultInterface $result * @param \Phalcon\Cache\Adapter\AdapterInterface $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) {} + public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + { + } /** * Returns current row in the resultset * * @return bool|ModelInterface */ - final public function current() {} + final public function current() + { + } /** * Returns a complete resultset as an array, if the resultset has a big @@ -54,20 +58,25 @@ final public function current() {} * * @return array */ - public function toArray(): array {} + public function toArray(): array + { + } /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializing a resultset will allow to only works on the rows present in the saved state * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 3b036c17..66f6cfc3 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -42,14 +42,18 @@ class Simple extends Resultset * @param \Phalcon\Cache\Adapter\AdapterInterface $cache * @param bool $keepSnapshots */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) {} + public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) + { + } /** * Returns current row in the resultset * * @return null|ModelInterface */ - final public function current(): ?ModelInterface {} + final public function current(): ?ModelInterface + { + } /** * Returns a complete resultset as an array, if the resultset has a big @@ -60,14 +64,18 @@ final public function current(): ?ModelInterface {} * @param bool $renameColumns * @return array */ - public function toArray(bool $renameColumns = true): array {} + public function toArray(bool $renameColumns = true): array + { + } /** * Serializing a resultset will dump all related rows into a big array * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializing a resultset will allow to only works on the rows present in @@ -75,6 +83,7 @@ public function serialize(): string {} * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 298969ff..5838f209 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -30,20 +30,25 @@ class Failed extends Exception * @param string $message * @param \Phalcon\Mvc\ModelInterface $record */ - public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) {} + public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) + { + } /** * Returns validation record messages which stop the transaction * * @return \Phalcon\Mvc\ModelInterface */ - public function getRecord(): ModelInterface {} + public function getRecord(): ModelInterface + { + } /** * Returns validation record messages which stop the transaction * * @return array|\Phalcon\Messages\MessageInterface[] */ - public function getRecordMessages(): array {} - + public function getRecordMessages(): array + { + } } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index 928b8c1b..94080392 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -90,17 +90,23 @@ class Manager implements ManagerInterface, InjectionAwareInterface * * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\Di\DiInterface $container = null) + { + } /** * Remove all the transactions from the manager */ - public function collectTransactions() {} + public function collectTransactions() + { + } /** * Commits active transactions within the manager */ - public function commit() {} + public function commit() + { + } /** * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once @@ -109,21 +115,27 @@ public function commit() {} * @param bool $autoBegin * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function get(bool $autoBegin = true): TransactionInterface {} + public function get(bool $autoBegin = true): TransactionInterface + { + } /** * Returns the database service used to isolate the transaction * * @return string */ - public function getDbService(): string {} + public function getDbService(): string + { + } /** * Returns the dependency injection container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Create/Returns a new transaction or an existing one @@ -131,7 +143,9 @@ public function getDI(): DiInterface {} * @param bool $autoBegin * @return \Phalcon\Mvc\Model\TransactionInterface */ - public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface {} + public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface + { + } /** * Check if the transaction manager is registering a shutdown function to @@ -139,28 +153,36 @@ public function getOrCreateTransaction(bool $autoBegin = true): TransactionInter * * @return bool */ - public function getRollbackPendent(): bool {} + public function getRollbackPendent(): bool + { + } /** * Checks whether the manager has an active transaction * * @return bool */ - public function has(): bool {} + public function has(): bool + { + } /** * Notifies the manager about a committed transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) + { + } /** * Notifies the manager about a rollbacked transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} + public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) + { + } /** * Rollbacks active transactions within the manager @@ -168,12 +190,16 @@ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transact * * @param bool $collect */ - public function rollback(bool $collect = true) {} + public function rollback(bool $collect = true) + { + } /** * Rollbacks active transactions within the manager */ - public function rollbackPendent() {} + public function rollbackPendent() + { + } /** * Sets the database service used to run the isolated transactions @@ -181,14 +207,18 @@ public function rollbackPendent() {} * @param string $service * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function setDbService(string $service): ManagerInterface {} + public function setDbService(string $service): ManagerInterface + { + } /** * Sets the dependency injection container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Set if the transaction manager must register a shutdown function to clean @@ -197,13 +227,16 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} * @param bool $rollbackPendent * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface */ - public function setRollbackPendent(bool $rollbackPendent): ManagerInterface {} + public function setRollbackPendent(bool $rollbackPendent): ManagerInterface + { + } /** * Removes transactions from the TransactionManager * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction */ - protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) {} - + protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) + { + } } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index 1f1d5235..167d04fb 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -102,5 +102,4 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; - } diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 91a1efc1..235f9b57 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -60,7 +60,9 @@ class Annotations extends Router * @param string $prefix * @return Annotations */ - public function addModuleResource(string $module, string $handler, string $prefix = null): Annotations {} + public function addModuleResource(string $module, string $handler, string $prefix = null): Annotations + { + } /** * Adds a resource to the annotations handler @@ -70,21 +72,27 @@ public function addModuleResource(string $module, string $handler, string $prefi * @param string $prefix * @return Annotations */ - public function addResource(string $handler, string $prefix = null): Annotations {} + public function addResource(string $handler, string $prefix = null): Annotations + { + } /** * Return the registered resources * * @return array */ - public function getResources(): array {} + public function getResources(): array + { + } /** * Produce the routing parameters from the rewrite information * * @param string $uri */ - public function handle(string $uri) {} + public function handle(string $uri) + { + } /** * Checks for annotations in the public methods of the controller @@ -95,7 +103,9 @@ public function handle(string $uri) {} * @param string $action * @param \Phalcon\Annotations\Annotation $annotation */ - public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) {} + public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) + { + } /** * Checks for annotations in the controller docblock @@ -103,20 +113,25 @@ public function processActionAnnotation(string $module, string $namespaceName, s * @param string $handler * @param \Phalcon\Annotations\Annotation $annotation */ - public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) {} + public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) + { + } /** * Changes the action method suffix * * @param string $actionSuffix */ - public function setActionSuffix(string $actionSuffix) {} + public function setActionSuffix(string $actionSuffix) + { + } /** * Changes the controller class suffix * * @param string $controllerSuffix */ - public function setControllerSuffix(string $controllerSuffix) {} - + public function setControllerSuffix(string $controllerSuffix) + { + } } diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index b7cc2aa5..275329f4 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -82,7 +82,9 @@ class Group implements GroupInterface * * @param mixed $paths */ - public function __construct($paths = null) {} + public function __construct($paths = null) + { + } /** * Adds a route to the router on any HTTP method @@ -96,7 +98,9 @@ public function __construct($paths = null) {} * @param mixed $httpMethods * @return RouteInterface */ - public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} + public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is CONNECT @@ -105,7 +109,9 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI * @param string|array $paths * @return RouteInterface */ - public function addConnect(string $pattern, $paths = null): RouteInterface {} + public function addConnect(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is DELETE @@ -114,7 +120,9 @@ public function addConnect(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addDelete(string $pattern, $paths = null): RouteInterface {} + public function addDelete(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is GET @@ -123,7 +131,9 @@ public function addDelete(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addGet(string $pattern, $paths = null): RouteInterface {} + public function addGet(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is HEAD @@ -132,7 +142,9 @@ public function addGet(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addHead(string $pattern, $paths = null): RouteInterface {} + public function addHead(string $pattern, $paths = null): RouteInterface + { + } /** * Add a route to the router that only match if the HTTP method is OPTIONS @@ -141,7 +153,9 @@ public function addHead(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addOptions(string $pattern, $paths = null): RouteInterface {} + public function addOptions(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PATCH @@ -150,7 +164,9 @@ public function addOptions(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addPatch(string $pattern, $paths = null): RouteInterface {} + public function addPatch(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is POST @@ -159,7 +175,9 @@ public function addPatch(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addPost(string $pattern, $paths = null): RouteInterface {} + public function addPost(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PURGE @@ -168,7 +186,9 @@ public function addPost(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addPurge(string $pattern, $paths = null): RouteInterface {} + public function addPurge(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is PUT @@ -177,7 +197,9 @@ public function addPurge(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addPut(string $pattern, $paths = null): RouteInterface {} + public function addPut(string $pattern, $paths = null): RouteInterface + { + } /** * Adds a route to the router that only match if the HTTP method is TRACE @@ -186,7 +208,9 @@ public function addPut(string $pattern, $paths = null): RouteInterface {} * @param string|array $paths * @return RouteInterface */ - public function addTrace(string $pattern, $paths = null): RouteInterface {} + public function addTrace(string $pattern, $paths = null): RouteInterface + { + } /** * Sets a callback that is called if the route is matched. @@ -196,47 +220,61 @@ public function addTrace(string $pattern, $paths = null): RouteInterface {} * @param callable $beforeMatch * @return GroupInterface */ - public function beforeMatch($beforeMatch): GroupInterface {} + public function beforeMatch($beforeMatch): GroupInterface + { + } /** * Removes all the pre-defined routes */ - public function clear() {} + public function clear() + { + } /** * Returns the 'before match' callback if any * * @return callable */ - public function getBeforeMatch() {} + public function getBeforeMatch() + { + } /** * Returns the hostname restriction * * @return string */ - public function getHostname(): string {} + public function getHostname(): string + { + } /** * Returns the common paths defined for this group * * @return array|string */ - public function getPaths() {} + public function getPaths() + { + } /** * Returns the common prefix for all the routes * * @return string */ - public function getPrefix(): string {} + public function getPrefix(): string + { + } /** * Returns the routes added to the group * * @return array|RouteInterface[] */ - public function getRoutes(): array {} + public function getRoutes(): array + { + } /** * Set a hostname restriction for all the routes in the group @@ -244,7 +282,9 @@ public function getRoutes(): array {} * @param string $hostname * @return GroupInterface */ - public function setHostname(string $hostname): GroupInterface {} + public function setHostname(string $hostname): GroupInterface + { + } /** * Set common paths for all the routes in the group @@ -252,7 +292,9 @@ public function setHostname(string $hostname): GroupInterface {} * @param mixed $paths * @return GroupInterface */ - public function setPaths($paths): GroupInterface {} + public function setPaths($paths): GroupInterface + { + } /** * Set a common uri prefix for all the routes in this group @@ -260,7 +302,9 @@ public function setPaths($paths): GroupInterface {} * @param string $prefix * @return GroupInterface */ - public function setPrefix(string $prefix): GroupInterface {} + public function setPrefix(string $prefix): GroupInterface + { + } /** * Adds a route applying the common attributes @@ -270,6 +314,7 @@ public function setPrefix(string $prefix): GroupInterface {} * @param mixed $httpMethods * @return RouteInterface */ - protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface {} - + protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface + { + } } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index 6c0c18cb..ed4f9a13 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -237,5 +237,4 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; - } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 45429c1e..7e00168c 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -52,11 +52,13 @@ class Route implements RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; - public function getId() {} + public function getId() + { + } /** * Phalcon\Mvc\Router\Route constructor @@ -65,7 +67,9 @@ public function getId() {} * @param mixed $paths * @param mixed $httpMethods */ - public function __construct(string $pattern, $paths = null, $httpMethods = null) {} + public function __construct(string $pattern, $paths = null, $httpMethods = null) + { + } /** * Sets a callback that is called if the route is matched. @@ -94,7 +98,9 @@ public function __construct(string $pattern, $paths = null, $httpMethods = null) * @param mixed $callback * @return RouteInterface */ - public function beforeMatch($callback): RouteInterface {} + public function beforeMatch($callback): RouteInterface + { + } /** * Replaces placeholders from pattern returning a valid PCRE regular expression @@ -102,7 +108,9 @@ public function beforeMatch($callback): RouteInterface {} * @param string $pattern * @return string */ - public function compilePattern(string $pattern): string {} + public function compilePattern(string $pattern): string + { + } /** * {@inheritdoc} @@ -111,7 +119,9 @@ public function compilePattern(string $pattern): string {} * @param mixed $converter * @return RouteInterface */ - public function convert(string $name, $converter): RouteInterface {} + public function convert(string $name, $converter): RouteInterface + { + } /** * Extracts parameters from a string @@ -119,91 +129,117 @@ public function convert(string $name, $converter): RouteInterface {} * @param string $pattern * @return array|bool */ - public function extractNamedParams(string $pattern) {} + public function extractNamedParams(string $pattern) + { + } /** * Returns the 'before match' callback if any * * @return callable */ - public function getBeforeMatch() {} + public function getBeforeMatch() + { + } /** * Returns the route's compiled pattern * * @return string */ - public function getCompiledPattern(): string {} + public function getCompiledPattern(): string + { + } /** * Returns the router converter * * @return array */ - public function getConverters(): array {} + public function getConverters(): array + { + } /** * Returns the group associated with the route * * @return null|GroupInterface */ - public function getGroup(): ?GroupInterface {} + public function getGroup(): ?GroupInterface + { + } /** * Returns the HTTP methods that constraint matching the route * * @return array|string */ - public function getHttpMethods() {} + public function getHttpMethods() + { + } /** * Returns the hostname restriction if any * * @return string */ - public function getHostname(): string {} + public function getHostname(): string + { + } /** * Returns the 'match' callback if any * * @return callable */ - public function getMatch() {} + public function getMatch() + { + } /** * Returns the route's name * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Returns the paths * * @return array */ - public function getPaths(): array {} + public function getPaths(): array + { + } /** * Returns the route's pattern * * @return string */ - public function getPattern(): string {} + public function getPattern(): string + { + } /** * Returns the paths using positions as keys and names as values * * @return array */ - public function getReversedPaths(): array {} + public function getReversedPaths(): array + { + } /** * Returns the route's id * * @return string */ - public function getRouteId(): string {} + public function getRouteId(): string + { + } /** * Returns routePaths @@ -211,7 +247,9 @@ public function getRouteId(): string {} * @param mixed $paths * @return array */ - public static function getRoutePaths($paths = null): array {} + public static function getRoutePaths($paths = null): array + { + } /** * Allows to set a callback to handle the request directly in the route @@ -230,7 +268,9 @@ public static function getRoutePaths($paths = null): array {} * @param mixed $callback * @return RouteInterface */ - public function match($callback): RouteInterface {} + public function match($callback): RouteInterface + { + } /** * Reconfigure the route adding a new pattern and a set of paths @@ -238,12 +278,16 @@ public function match($callback): RouteInterface {} * @param string $pattern * @param mixed $paths */ - public function reConfigure(string $pattern, $paths = null) {} + public function reConfigure(string $pattern, $paths = null) + { + } /** * Resets the internal route id generator */ - public static function reset() {} + public static function reset() + { + } /** * Sets the group associated with the route @@ -251,7 +295,9 @@ public static function reset() {} * @param GroupInterface $group * @return RouteInterface */ - public function setGroup(GroupInterface $group): RouteInterface {} + public function setGroup(GroupInterface $group): RouteInterface + { + } /** * Sets a set of HTTP methods that constraint the matching of the route (alias of via) @@ -270,7 +316,9 @@ public function setGroup(GroupInterface $group): RouteInterface {} * @param mixed $httpMethods * @return RouteInterface */ - public function setHttpMethods($httpMethods): RouteInterface {} + public function setHttpMethods($httpMethods): RouteInterface + { + } /** * Sets a hostname restriction to the route @@ -282,7 +330,9 @@ public function setHttpMethods($httpMethods): RouteInterface {} * @param string $hostname * @return RouteInterface */ - public function setHostname(string $hostname): RouteInterface {} + public function setHostname(string $hostname): RouteInterface + { + } /** * Sets the route's name @@ -299,7 +349,9 @@ public function setHostname(string $hostname): RouteInterface {} * @param string $name * @return RouteInterface */ - public function setName(string $name): RouteInterface {} + public function setName(string $name): RouteInterface + { + } /** * Set one or more HTTP methods that constraint the matching of the route @@ -318,6 +370,7 @@ public function setName(string $name): RouteInterface {} * @param mixed $httpMethods * @return RouteInterface */ - public function via($httpMethods): RouteInterface {} - + public function via($httpMethods): RouteInterface + { + } } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index 6eb49c93..91986fca 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -136,5 +136,4 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; - } diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/mvc/view/Simple.php index e13fec59..45c1f1f6 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/mvc/view/Simple.php @@ -75,14 +75,18 @@ class Simple extends Injectable implements ViewBaseInterface /** * @return array|null */ - public function getRegisteredEngines(): ?array {} + public function getRegisteredEngines(): ?array + { + } /** * Phalcon\Mvc\View\Simple constructor * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Magic method to retrieve a variable passed to the view @@ -94,7 +98,9 @@ public function __construct(array $options = array()) {} * @param string $key * @return mixed|null */ - public function __get(string $key) {} + public function __get(string $key) + { + } /** * Magic method to pass variables to the views @@ -106,28 +112,36 @@ public function __get(string $key) {} * @param string $key * @param mixed $value */ - public function __set(string $key, $value) {} + public function __set(string $key, $value) + { + } /** * Returns the path of the view that is currently rendered * * @return string */ - public function getActiveRenderPath(): string {} + public function getActiveRenderPath(): string + { + } /** * Returns output from another view stage * * @return string */ - public function getContent(): string {} + public function getContent(): string + { + } /** * Returns parameters to views * * @return array */ - public function getParamsToView(): array {} + public function getParamsToView(): array + { + } /** * Returns a parameter previously set in the view @@ -135,14 +149,18 @@ public function getParamsToView(): array {} * @param string $key * @return mixed|null */ - public function getVar(string $key) {} + public function getVar(string $key) + { + } /** * Gets views directory * * @return string */ - public function getViewsDir(): string {} + public function getViewsDir(): string + { + } /** * Renders a partial view @@ -165,7 +183,9 @@ public function getViewsDir(): string {} * @param string $partialPath * @param mixed $params */ - public function partial(string $partialPath, $params = null) {} + public function partial(string $partialPath, $params = null) + { + } /** * Register templating engines @@ -182,7 +202,9 @@ public function partial(string $partialPath, $params = null) {} * * @param array $engines */ - public function registerEngines(array $engines) {} + public function registerEngines(array $engines) + { + } /** * Renders a view @@ -191,7 +213,9 @@ public function registerEngines(array $engines) {} * @param array $params * @return string */ - public function render(string $path, array $params = array()): string {} + public function render(string $path, array $params = array()): string + { + } /** * Externally sets the view content @@ -203,7 +227,9 @@ public function render(string $path, array $params = array()): string {} * @param string $content * @return Simple */ - public function setContent(string $content): Simple {} + public function setContent(string $content): Simple + { + } /** * Adds parameters to views (alias of setVar) @@ -216,7 +242,9 @@ public function setContent(string $content): Simple {} * @param mixed $value * @return Simple */ - public function setParamToView(string $key, $value): Simple {} + public function setParamToView(string $key, $value): Simple + { + } /** * Set a single view parameter @@ -229,7 +257,9 @@ public function setParamToView(string $key, $value): Simple {} * @param mixed $value * @return Simple */ - public function setVar(string $key, $value): Simple {} + public function setVar(string $key, $value): Simple + { + } /** * Set all the render params @@ -246,14 +276,18 @@ public function setVar(string $key, $value): Simple {} * @param bool $merge * @return Simple */ - public function setVars(array $params, bool $merge = true): Simple {} + public function setVars(array $params, bool $merge = true): Simple + { + } /** * Sets views directory * * @param string $viewsDir */ - public function setViewsDir(string $viewsDir) {} + public function setViewsDir(string $viewsDir) + { + } /** * Loads registered template engines, if none are registered it will use @@ -261,7 +295,9 @@ public function setViewsDir(string $viewsDir) {} * * @return array */ - protected function loadTemplateEngines(): array {} + protected function loadTemplateEngines(): array + { + } /** * Tries to render the view with every engine registered in the component @@ -269,6 +305,7 @@ protected function loadTemplateEngines(): array {} * @param string $path * @param array $params */ - final protected function internalRender(string $path, $params) {} - + final protected function internalRender(string $path, $params) + { + } } diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php index 30ad3c5c..9436135b 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -30,21 +30,27 @@ abstract class AbstractEngine extends Injectable implements EngineInterface * @param \Phalcon\Mvc\ViewBaseInterface $view * @param \Phalcon\Di\DiInterface $container */ - public function __construct(\Phalcon\Mvc\ViewBaseInterface $view, \Phalcon\Di\DiInterface $container = null) {} + public function __construct(\Phalcon\Mvc\ViewBaseInterface $view, \Phalcon\Di\DiInterface $container = null) + { + } /** * Returns cached output on another view stage * * @return string */ - public function getContent(): string {} + public function getContent(): string + { + } /** * Returns the view component related to the adapter * * @return \Phalcon\Mvc\ViewBaseInterface */ - public function getView(): ViewBaseInterface {} + public function getView(): ViewBaseInterface + { + } /** * Renders a partial inside another view @@ -53,6 +59,7 @@ public function getView(): ViewBaseInterface {} * @param array $params * @return string */ - public function partial(string $partialPath, $params = null): string {} - + public function partial(string $partialPath, $params = null): string + { + } } diff --git a/src/Phalcon/mvc/view/engine/EngineInterface.php b/src/Phalcon/mvc/view/engine/EngineInterface.php index f7b51e8d..8842f198 100644 --- a/src/Phalcon/mvc/view/engine/EngineInterface.php +++ b/src/Phalcon/mvc/view/engine/EngineInterface.php @@ -41,5 +41,4 @@ public function partial(string $partialPath, $params = null): string; * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); - } diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index 895a8c13..8e761c7c 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -24,6 +24,7 @@ class Php extends AbstractEngine * @param mixed $params * @param bool $mustClean */ - public function render(string $path, $params, bool $mustClean = false) {} - + public function render(string $path, $params, bool $mustClean = false) + { + } } diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index 8121f646..11bd8857 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -35,7 +35,9 @@ class Volt extends AbstractEngine * @param array $arguments * @return mixed */ - public function callMacro(string $name, array $arguments = array()) {} + public function callMacro(string $name, array $arguments = array()) + { + } /** * Performs a string conversion @@ -45,21 +47,27 @@ public function callMacro(string $name, array $arguments = array()) {} * @param string $to * @return string */ - public function convertEncoding(string $text, string $from, string $to): string {} + public function convertEncoding(string $text, string $from, string $to): string + { + } /** * Returns the Volt's compiler * * @return \Phalcon\Mvc\View\Engine\Volt\Compiler */ - public function getCompiler(): Compiler {} + public function getCompiler(): Compiler + { + } /** * Return Volt's options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Checks if the needle is included in the haystack @@ -68,7 +76,9 @@ public function getOptions(): array {} * @param mixed $haystack * @return bool */ - public function isIncluded($needle, $haystack): bool {} + public function isIncluded($needle, $haystack): bool + { + } /** * Length filter. If an array/object is passed a count is performed otherwise a strlen/mb_strlen @@ -76,7 +86,9 @@ public function isIncluded($needle, $haystack): bool {} * @param mixed $item * @return int */ - public function length($item): int {} + public function length($item): int + { + } /** * Renders a view using the template engine @@ -85,14 +97,18 @@ public function length($item): int {} * @param mixed $params * @param bool $mustClean */ - public function render(string $templatePath, $params, bool $mustClean = false) {} + public function render(string $templatePath, $params, bool $mustClean = false) + { + } /** * Set Volt's options * * @param array $options */ - public function setOptions(array $options) {} + public function setOptions(array $options) + { + } /** * Extracts a slice from a string/array/traversable object value @@ -101,7 +117,9 @@ public function setOptions(array $options) {} * @param int $start * @param mixed $end */ - public function slice($value, int $start = 0, $end = null) {} + public function slice($value, int $start = 0, $end = null) + { + } /** * Sorts an array @@ -109,6 +127,7 @@ public function slice($value, int $start = 0, $end = null) {} * @param array $value * @return array */ - public function sort(array $value): array {} - + public function sort(array $value): array + { + } } diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 329578ba..81e8ebfa 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -96,7 +96,9 @@ class Compiler implements InjectionAwareInterface * * @param \Phalcon\Mvc\ViewBaseInterface $view */ - public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) {} + public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) + { + } /** * Registers a Volt's extension @@ -104,7 +106,9 @@ public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) {} * @param mixed $extension * @return Compiler */ - public function addExtension($extension): Compiler {} + public function addExtension($extension): Compiler + { + } /** * Register a new filter in the compiler @@ -113,7 +117,9 @@ public function addExtension($extension): Compiler {} * @param mixed $definition * @return Compiler */ - public function addFilter(string $name, $definition): Compiler {} + public function addFilter(string $name, $definition): Compiler + { + } /** * Register a new function in the compiler @@ -122,7 +128,9 @@ public function addFilter(string $name, $definition): Compiler {} * @param mixed $definition * @return Compiler */ - public function addFunction(string $name, $definition): Compiler {} + public function addFunction(string $name, $definition): Compiler + { + } /** * Resolves attribute reading @@ -130,7 +138,9 @@ public function addFunction(string $name, $definition): Compiler {} * @param array $expr * @return string */ - public function attributeReader(array $expr): string {} + public function attributeReader(array $expr): string + { + } /** * Compiles a template into a file applying the compiler options @@ -145,7 +155,9 @@ public function attributeReader(array $expr): string {} * @param string $templatePath * @param bool $extendsMode */ - public function compile(string $templatePath, bool $extendsMode = false) {} + public function compile(string $templatePath, bool $extendsMode = false) + { + } /** * Compiles a "autoescape" statement returning PHP code @@ -154,7 +166,9 @@ public function compile(string $templatePath, bool $extendsMode = false) {} * @param bool $extendsMode * @return string */ - public function compileAutoEscape(array $statement, bool $extendsMode): string {} + public function compileAutoEscape(array $statement, bool $extendsMode): string + { + } /** * Compiles a "cache" statement returning PHP code @@ -163,7 +177,9 @@ public function compileAutoEscape(array $statement, bool $extendsMode): string { * @param bool $extendsMode * @return string */ - public function compileCache(array $statement, bool $extendsMode = false): string {} + public function compileCache(array $statement, bool $extendsMode = false): string + { + } /** * Compiles calls to macros @@ -171,7 +187,9 @@ public function compileCache(array $statement, bool $extendsMode = false): strin * @param array $statement * @param bool $extendsMode */ - public function compileCall(array $statement, bool $extendsMode) {} + public function compileCall(array $statement, bool $extendsMode) + { + } /** * Compiles a "case"/"default" clause returning PHP code @@ -180,7 +198,9 @@ public function compileCall(array $statement, bool $extendsMode) {} * @param bool $caseClause * @return string */ - public function compileCase(array $statement, bool $caseClause = true): string {} + public function compileCase(array $statement, bool $caseClause = true): string + { + } /** * Compiles a "do" statement returning PHP code @@ -188,7 +208,9 @@ public function compileCase(array $statement, bool $caseClause = true): string { * @param array $statement * @return string */ - public function compileDo(array $statement): string {} + public function compileDo(array $statement): string + { + } /** * Compiles a {% raw %}`{{` `}}`{% endraw %} statement returning PHP code @@ -196,7 +218,9 @@ public function compileDo(array $statement): string {} * @param array $statement * @return string */ - public function compileEcho(array $statement): string {} + public function compileEcho(array $statement): string + { + } /** * Compiles a "elseif" statement returning PHP code @@ -204,7 +228,9 @@ public function compileEcho(array $statement): string {} * @param array $statement * @return string */ - public function compileElseIf(array $statement): string {} + public function compileElseIf(array $statement): string + { + } /** * Compiles a template into a file forcing the destination path @@ -221,7 +247,9 @@ public function compileElseIf(array $statement): string {} * @param bool $extendsMode * @return string|array */ - public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) {} + public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) + { + } /** * Compiles a "foreach" intermediate code representation into plain PHP code @@ -230,14 +258,18 @@ public function compileFile(string $path, string $compiledPath, bool $extendsMod * @param bool $extendsMode * @return string */ - public function compileForeach(array $statement, bool $extendsMode = false): string {} + public function compileForeach(array $statement, bool $extendsMode = false): string + { + } /** * Generates a 'forelse' PHP code * * @return string */ - public function compileForElse(): string {} + public function compileForElse(): string + { + } /** * Compiles a 'if' statement returning PHP code @@ -246,7 +278,9 @@ public function compileForElse(): string {} * @param bool $extendsMode * @return string */ - public function compileIf(array $statement, bool $extendsMode = false): string {} + public function compileIf(array $statement, bool $extendsMode = false): string + { + } /** * Compiles a 'include' statement returning PHP code @@ -254,7 +288,9 @@ public function compileIf(array $statement, bool $extendsMode = false): string { * @param array $statement * @return string */ - public function compileInclude(array $statement): string {} + public function compileInclude(array $statement): string + { + } /** * Compiles macros @@ -263,7 +299,9 @@ public function compileInclude(array $statement): string {} * @param bool $extendsMode * @return string */ - public function compileMacro(array $statement, bool $extendsMode): string {} + public function compileMacro(array $statement, bool $extendsMode): string + { + } /** * Compiles a "return" statement returning PHP code @@ -271,7 +309,9 @@ public function compileMacro(array $statement, bool $extendsMode): string {} * @param array $statement * @return string */ - public function compileReturn(array $statement): string {} + public function compileReturn(array $statement): string + { + } /** * Compiles a "set" statement returning PHP code @@ -279,7 +319,9 @@ public function compileReturn(array $statement): string {} * @param array $statement * @return string */ - public function compileSet(array $statement): string {} + public function compileSet(array $statement): string + { + } /** * Compiles a template into a string @@ -292,7 +334,9 @@ public function compileSet(array $statement): string {} * @param bool $extendsMode * @return string */ - public function compileString(string $viewCode, bool $extendsMode = false): string {} + public function compileString(string $viewCode, bool $extendsMode = false): string + { + } /** * Compiles a 'switch' statement returning PHP code @@ -301,7 +345,9 @@ public function compileString(string $viewCode, bool $extendsMode = false): stri * @param bool $extendsMode * @return string */ - public function compileSwitch(array $statement, bool $extendsMode = false): string {} + public function compileSwitch(array $statement, bool $extendsMode = false): string + { + } /** * Resolves an expression node in an AST volt tree @@ -309,7 +355,9 @@ public function compileSwitch(array $statement, bool $extendsMode = false): stri * @param array $expr * @return string */ - final public function expression(array $expr): string {} + final public function expression(array $expr): string + { + } /** * Fires an event to registered extensions @@ -318,7 +366,9 @@ final public function expression(array $expr): string {} * @param array $arguments * @return mixed */ - final public function fireExtensionEvent(string $name, $arguments = null) {} + final public function fireExtensionEvent(string $name, $arguments = null) + { + } /** * Resolves function intermediate code into PHP function calls @@ -326,42 +376,54 @@ final public function fireExtensionEvent(string $name, $arguments = null) {} * @param array $expr * @return string */ - public function functionCall(array $expr): string {} + public function functionCall(array $expr): string + { + } /** * Returns the path to the last compiled template * * @return string */ - public function getCompiledTemplatePath(): string {} + public function getCompiledTemplatePath(): string + { + } /** * Returns the internal dependency injector * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Returns the list of extensions registered in Volt * * @return array */ - public function getExtensions(): array {} + public function getExtensions(): array + { + } /** * Register the user registered filters * * @return array */ - public function getFilters(): array {} + public function getFilters(): array + { + } /** * Register the user registered functions * * @return array */ - public function getFunctions(): array {} + public function getFunctions(): array + { + } /** * Returns a compiler's option @@ -369,21 +431,27 @@ public function getFunctions(): array {} * @param string $option * @return string */ - public function getOption(string $option) {} + public function getOption(string $option) + { + } /** * Returns the compiler options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Returns the path that is currently being compiled * * @return string */ - public function getTemplatePath(): string {} + public function getTemplatePath(): string + { + } /** * Return a unique prefix to be used as prefix for compiled variables and @@ -391,7 +459,9 @@ public function getTemplatePath(): string {} * * @return string */ - public function getUniquePrefix(): string {} + public function getUniquePrefix(): string + { + } /** * Parses a Volt template returning its intermediate representation @@ -405,7 +475,9 @@ public function getUniquePrefix(): string {} * @param string $viewCode * @return array */ - public function parse(string $viewCode) {} + public function parse(string $viewCode) + { + } /** * Resolves filter intermediate code into a valid PHP expression @@ -414,14 +486,18 @@ public function parse(string $viewCode) {} * @param string $left * @return string */ - public function resolveTest(array $test, string $left): string {} + public function resolveTest(array $test, string $left): string + { + } /** * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} + public function setDI(\Phalcon\Di\DiInterface $container) + { + } /** * Sets a single compiler option @@ -429,14 +505,18 @@ public function setDI(\Phalcon\Di\DiInterface $container) {} * @param string $option * @param mixed $value */ - public function setOption(string $option, $value) {} + public function setOption(string $option, $value) + { + } /** * Sets the compiler options * * @param array $options */ - public function setOptions(array $options) {} + public function setOptions(array $options) + { + } /** * Set a unique prefix to be used as prefix for compiled variables @@ -444,7 +524,9 @@ public function setOptions(array $options) {} * @param string $prefix * @return Compiler */ - public function setUniquePrefix(string $prefix): Compiler {} + public function setUniquePrefix(string $prefix): Compiler + { + } /** * Compiles a Volt source code returning a PHP plain version @@ -453,14 +535,18 @@ public function setUniquePrefix(string $prefix): Compiler {} * @param bool $extendsMode * @return string */ - protected function compileSource(string $viewCode, bool $extendsMode = false): string {} + protected function compileSource(string $viewCode, bool $extendsMode = false): string + { + } /** * Gets the final path with VIEW * * @param string $path */ - protected function getFinalPath(string $path) {} + protected function getFinalPath(string $path) + { + } /** * Resolves filter intermediate code into PHP function calls @@ -469,7 +555,9 @@ protected function getFinalPath(string $path) {} * @param string $left * @return string */ - final protected function resolveFilter(array $filter, string $left): string {} + final protected function resolveFilter(array $filter, string $left): string + { + } /** * Traverses a statement list compiling each of its nodes @@ -478,7 +566,9 @@ final protected function resolveFilter(array $filter, string $left): string {} * @param bool $extendsMode * @return string */ - final protected function statementList(array $statements, bool $extendsMode = false): string {} + final protected function statementList(array $statements, bool $extendsMode = false): string + { + } /** * Compiles a block of statements @@ -486,6 +576,7 @@ final protected function statementList(array $statements, bool $extendsMode = fa * @param array $statements * @return string|array */ - final protected function statementListOrExtends($statements) {} - + final protected function statementListOrExtends($statements) + { + } } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 9952eaa2..6997d16c 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -28,13 +28,16 @@ class Exception extends BaseException * @param int $code * @param \Exception $previous */ - public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) {} + public function __construct(string $message = '', array $statement = array(), int $code = 0, \Exception $previous = null) + { + } /** * Gets currently parsed statement (if any). * * @return array */ - public function getStatement(): array {} - + public function getStatement(): array + { + } } diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php index b13fd582..99c31ae3 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -22,7 +22,9 @@ class PaginatorFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Factory to create an instace from a Config object @@ -50,7 +52,9 @@ public function __construct(array $services = array()) {} * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Create a new instance of the adapter @@ -59,11 +63,14 @@ public function load($config) {} * @param array $options * @return \Phalcon\Paginator\Adapter\AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index da4ac65c..77fa574b 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -35,70 +35,90 @@ class Repository implements RepositoryInterface * @param string $property * @return mixed|null */ - public function __get(string $property) {} + public function __get(string $property) + { + } /** * {@inheritdoc} * * @return array */ - public function getAliases(): array {} + public function getAliases(): array + { + } /** * {@inheritdoc} * * @return int */ - public function getCurrent(): int {} + public function getCurrent(): int + { + } /** * {@inheritdoc} * * @return int */ - public function getFirst(): int {} + public function getFirst(): int + { + } /** * {@inheritdoc} * * @return mixed */ - public function getItems() {} + public function getItems() + { + } /** * {@inheritdoc} * * @return int */ - public function getLast(): int {} + public function getLast(): int + { + } /** * {@inheritdoc} * * @return int */ - public function getLimit(): int {} + public function getLimit(): int + { + } /** * {@inheritdoc} * * @return int */ - public function getNext(): int {} + public function getNext(): int + { + } /** * {@inheritdoc} * * @return int */ - public function getPrevious(): int {} + public function getPrevious(): int + { + } /** * {@inheritdoc} * * @return int */ - public function getTotalItems(): int {} + public function getTotalItems(): int + { + } /** * {@inheritdoc} @@ -106,7 +126,9 @@ public function getTotalItems(): int {} * @param array $aliases * @return RepositoryInterface */ - public function setAliases(array $aliases): RepositoryInterface {} + public function setAliases(array $aliases): RepositoryInterface + { + } /** * {@inheritdoc} @@ -114,7 +136,9 @@ public function setAliases(array $aliases): RepositoryInterface {} * @param array $properties * @return RepositoryInterface */ - public function setProperties(array $properties): RepositoryInterface {} + public function setProperties(array $properties): RepositoryInterface + { + } /** * Gets value of property by name @@ -123,7 +147,9 @@ public function setProperties(array $properties): RepositoryInterface {} * @param mixed $defaultValue * @return mixed */ - protected function getProperty(string $property, $defaultValue = null) {} + protected function getProperty(string $property, $defaultValue = null) + { + } /** * Resolve alias property name @@ -131,6 +157,7 @@ protected function getProperty(string $property, $defaultValue = null) {} * @param string $property * @return string */ - protected function getRealNameProperty(string $property): string {} - + protected function getRealNameProperty(string $property): string + { + } } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php index 3e39d4bb..97e8c551 100644 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -122,5 +122,4 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; - } diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/paginator/adapter/AbstractAdapter.php index 05cbcfff..b8be65c2 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/paginator/adapter/AbstractAdapter.php @@ -46,14 +46,18 @@ abstract class AbstractAdapter implements AdapterInterface * * @param array $config */ - public function __construct(array $config) {} + public function __construct(array $config) + { + } /** * Get current rows limit * * @return int */ - public function getLimit(): int {} + public function getLimit(): int + { + } /** * Set the current page number @@ -61,7 +65,9 @@ public function getLimit(): int {} * @param int $page * @return Adapter */ - public function setCurrentPage(int $page): Adapter {} + public function setCurrentPage(int $page): Adapter + { + } /** * Set current rows limit @@ -69,7 +75,9 @@ public function setCurrentPage(int $page): Adapter {} * @param int $limitRows * @return Adapter */ - public function setLimit(int $limitRows): Adapter {} + public function setLimit(int $limitRows): Adapter + { + } /** * Sets current repository for pagination @@ -77,7 +85,9 @@ public function setLimit(int $limitRows): Adapter {} * @param \Phalcon\Paginator\RepositoryInterface $repository * @return Adapter */ - public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): Adapter {} + public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): Adapter + { + } /** * Gets current repository for pagination @@ -85,6 +95,7 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository * @param array $properties * @return \Phalcon\Paginator\RepositoryInterface */ - protected function getRepository(array $properties = null): RepositoryInterface {} - + protected function getRepository(array $properties = null): RepositoryInterface + { + } } diff --git a/src/Phalcon/paginator/adapter/AdapterInterface.php b/src/Phalcon/paginator/adapter/AdapterInterface.php index 947c4483..b61d977e 100644 --- a/src/Phalcon/paginator/adapter/AdapterInterface.php +++ b/src/Phalcon/paginator/adapter/AdapterInterface.php @@ -48,5 +48,4 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); - } diff --git a/src/Phalcon/paginator/adapter/Model.php b/src/Phalcon/paginator/adapter/Model.php index f6c3f1c1..1287a65d 100644 --- a/src/Phalcon/paginator/adapter/Model.php +++ b/src/Phalcon/paginator/adapter/Model.php @@ -41,6 +41,7 @@ class Model extends AbstractAdapter * * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate(): RepositoryInterface {} - + public function paginate(): RepositoryInterface + { + } } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 999c9e85..8699753d 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -44,6 +44,7 @@ class NativeArray extends AbstractAdapter * * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate(): RepositoryInterface {} - + public function paginate(): RepositoryInterface + { + } } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index e3ea076f..80bb9f86 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -54,28 +54,36 @@ class QueryBuilder extends AbstractAdapter * * @param array $config */ - public function __construct(array $config) {} + public function __construct(array $config) + { + } /** * Get the current page number * * @return int */ - public function getCurrentPage(): int {} + public function getCurrentPage(): int + { + } /** * Get query builder object * * @return \Phalcon\Mvc\Model\Query\Builder */ - public function getQueryBuilder(): Builder {} + public function getQueryBuilder(): Builder + { + } /** * Returns a slice of the resultset to show in the pagination * * @return \Phalcon\Paginator\RepositoryInterface */ - public function paginate(): RepositoryInterface {} + public function paginate(): RepositoryInterface + { + } /** * Set query builder object @@ -83,6 +91,7 @@ public function paginate(): RepositoryInterface {} * @param \Phalcon\Mvc\Model\Query\Builder $builder * @return QueryBuilder */ - public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder {} - + public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder + { + } } diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/security/Random.php index 80686906..2c582c09 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/security/Random.php @@ -101,7 +101,9 @@ class Random * @param int $len * @return string */ - public function base58(int $len = null): string {} + public function base58(int $len = null): string + { + } /** * Generates a random base62 string @@ -124,7 +126,9 @@ public function base58(int $len = null): string {} * @param int $len * @return string */ - public function base62(int $len = null): string {} + public function base62(int $len = null): string + { + } /** * Generates a random base64 string @@ -143,7 +147,9 @@ public function base62(int $len = null): string {} * @param int $len * @return string */ - public function base64(int $len = null): string {} + public function base64(int $len = null): string + { + } /** * Generates a random URL-safe base64 string @@ -168,7 +174,9 @@ public function base64(int $len = null): string {} * @param bool $padding * @return string */ - public function base64Safe(int $len = null, bool $padding = false): string {} + public function base64Safe(int $len = null, bool $padding = false): string + { + } /** * Generates a random binary string @@ -191,7 +199,9 @@ public function base64Safe(int $len = null, bool $padding = false): string {} * @param int $len * @return string */ - public function bytes(int $len = 16): string {} + public function bytes(int $len = 16): string + { + } /** * Generates a random hex string @@ -209,7 +219,9 @@ public function bytes(int $len = 16): string {} * @param int $len * @return string */ - public function hex(int $len = null): string {} + public function hex(int $len = null): string + { + } /** * Generates a random number between 0 and $len @@ -226,7 +238,9 @@ public function hex(int $len = null): string {} * @param int $len * @return int */ - public function number(int $len): int {} + public function number(int $len): int + { + } /** * Generates a v4 random UUID (Universally Unique IDentifier) @@ -251,7 +265,9 @@ public function number(int $len): int {} * @throws Exception If secure random number generator is not available or unexpected partial read * @return string */ - public function uuid(): string {} + public function uuid(): string + { + } /** * Generates a random string based on the number ($base) of characters @@ -265,6 +281,7 @@ public function uuid(): string {} * @param mixed $n * @return string */ - protected function base(string $alphabet, int $base, $n = null): string {} - + protected function base(string $alphabet, int $base, $n = null): string + { + } } diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/session/Bag.php index cff78aa8..15c57d71 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/session/Bag.php @@ -45,33 +45,43 @@ class Bag extends Collection implements InjectionAwareInterface * * @param string $name */ - public function __construct(string $name) {} + public function __construct(string $name) + { + } /** * Destroys the session bag */ - public function clear() {} + public function clear() + { + } /** * Returns the DependencyInjector container * * @return \Phalcon\Di\DiInterface */ - public function getDI(): DiInterface {} + public function getDI(): DiInterface + { + } /** * Removes a property from the internal bag * * @param array $data */ - public function init(array $data = array()) {} + public function init(array $data = array()) + { + } /** * Removes a property from the internal bag * * @param string $element */ - public function remove(string $element) {} + public function remove(string $element) + { + } /** * Sets a value in the session bag @@ -79,13 +89,16 @@ public function remove(string $element) {} * @param string $element * @param mixed $value */ - public function set(string $element, $value) {} + public function set(string $element, $value) + { + } /** * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container */ - public function setDI(\Phalcon\Di\DiInterface $container) {} - + public function setDI(\Phalcon\Di\DiInterface $container) + { + } } diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 0429b387..2a284805 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -48,7 +48,9 @@ class Manager extends AbstractInjectionAware implements ManagerInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Alias: Gets a session variable from an application context @@ -56,7 +58,9 @@ public function __construct(array $options = array()) {} * @param string $key * @return mixed */ - public function __get(string $key) {} + public function __get(string $key) + { + } /** * Alias: Check whether a session variable is set in an application context @@ -64,7 +68,9 @@ public function __get(string $key) {} * @param string $key * @return bool */ - public function __isset(string $key): bool {} + public function __isset(string $key): bool + { + } /** * Alias: Sets a session variable in an application context @@ -72,26 +78,34 @@ public function __isset(string $key): bool {} * @param string $key * @param mixed $value */ - public function __set(string $key, $value) {} + public function __set(string $key, $value) + { + } /** * Alias: Removes a session variable from an application context * * @param string $key */ - public function __unset(string $key) {} + public function __unset(string $key) + { + } /** * Destroy/end a session */ - public function destroy() {} + public function destroy() + { + } /** * Check whether the session has been started * * @return bool */ - public function exists(): bool {} + public function exists(): bool + { + } /** * Gets a session variable from an application context @@ -101,28 +115,36 @@ public function exists(): bool {} * @param bool $remove * @return mixed */ - public function get(string $key, $defaultValue = null, bool $remove = false) {} + public function get(string $key, $defaultValue = null, bool $remove = false) + { + } /** * Returns the stored session adapter * * @return \SessionHandlerInterface */ - public function getAdapter(): SessionHandlerInterface {} + public function getAdapter(): SessionHandlerInterface + { + } /** * Returns the session id * * @return string */ - public function getId(): string {} + public function getId(): string + { + } /** * Returns the name of the session * * @return string */ - public function getName(): string {} + public function getName(): string + { + } /** * Check whether a session variable is set in an application context @@ -130,14 +152,18 @@ public function getName(): string {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Get internal options * * @return array */ - public function getOptions(): array {} + public function getOptions(): array + { + } /** * Regenerates the session id using the adapter. @@ -145,14 +171,18 @@ public function getOptions(): array {} * @param mixed $deleteOldSession * @return \Phalcon\Session\ManagerInterface */ - public function regenerateId($deleteOldSession = true): ManagerInterface {} + public function regenerateId($deleteOldSession = true): ManagerInterface + { + } /** * Removes a session variable from an application context * * @param string $key */ - public function remove(string $key) {} + public function remove(string $key) + { + } /** * Sets a session variable in an application context @@ -160,7 +190,9 @@ public function remove(string $key) {} * @param string $key * @param mixed $value */ - public function set(string $key, $value) {} + public function set(string $key, $value) + { + } /** * Set the adapter for the session @@ -168,7 +200,9 @@ public function set(string $key, $value) {} * @param \SessionHandlerInterface $adapter * @return \Phalcon\Session\ManagerInterface */ - public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface {} + public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface + { + } /** * Set session Id @@ -176,7 +210,9 @@ public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface * @param string $id * @return \Phalcon\Session\ManagerInterface */ - public function setId(string $id): ManagerInterface {} + public function setId(string $id): ManagerInterface + { + } /** * Set the session name. Throw exception if the session has started @@ -189,14 +225,18 @@ public function setId(string $id): ManagerInterface {} * @param string $name * @return \Phalcon\Session\ManagerInterface */ - public function setName(string $name): ManagerInterface {} + public function setName(string $name): ManagerInterface + { + } /** * Sets session's options * * @param array $options */ - public function setOptions(array $options) {} + public function setOptions(array $options) + { + } /** * Starts the session (if headers are already sent the session will not be @@ -204,14 +244,18 @@ public function setOptions(array $options) {} * * @return bool */ - public function start(): bool {} + public function start(): bool + { + } /** * Returns the status of the current session. * * @return int */ - public function status(): int {} + public function status(): int + { + } /** * Returns the key prefixed @@ -219,6 +263,7 @@ public function status(): int {} * @param string $key * @return string */ - private function getUniqueKey(string $key): string {} - + private function getUniqueKey(string $key): string + { + } } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php index 20b0ce6d..5c964f48 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/session/ManagerInterface.php @@ -190,5 +190,4 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; - } diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/session/adapter/AbstractAdapter.php index f21ef260..975d86f6 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/session/adapter/AbstractAdapter.php @@ -27,7 +27,9 @@ abstract class AbstractAdapter implements SessionHandlerInterface * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * Destroy @@ -35,7 +37,9 @@ public function close(): bool {} * @param mixed $id * @return bool */ - public function destroy($id): bool {} + public function destroy($id): bool + { + } /** * Garbage Collector @@ -43,7 +47,9 @@ public function destroy($id): bool {} * @param mixed $maxlifetime * @return bool */ - public function gc($maxlifetime): bool {} + public function gc($maxlifetime): bool + { + } /** * Read @@ -51,7 +57,9 @@ public function gc($maxlifetime): bool {} * @param mixed $id * @return string */ - public function read($id): string {} + public function read($id): string + { + } /** * Open @@ -60,7 +68,9 @@ public function read($id): string {} * @param mixed $sessionName * @return bool */ - public function open($savePath, $sessionName): bool {} + public function open($savePath, $sessionName): bool + { + } /** * Write @@ -69,6 +79,7 @@ public function open($savePath, $sessionName): bool {} * @param mixed $data * @return bool */ - public function write($id, $data): bool {} - + public function write($id, $data): bool + { + } } diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 56c63d0f..1ad2c068 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -23,6 +23,7 @@ class Libmemcached extends AbstractAdapter * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} - + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + { + } } diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index 23834c1f..a956a3c3 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -63,14 +63,18 @@ class Noop implements SessionHandlerInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Close * * @return bool */ - public function close(): bool {} + public function close(): bool + { + } /** * Destroy @@ -78,7 +82,9 @@ public function close(): bool {} * @param mixed $id * @return bool */ - public function destroy($id): bool {} + public function destroy($id): bool + { + } /** * Garbage Collector @@ -86,7 +92,9 @@ public function destroy($id): bool {} * @param mixed $maxlifetime * @return bool */ - public function gc($maxlifetime): bool {} + public function gc($maxlifetime): bool + { + } /** * Read @@ -94,7 +102,9 @@ public function gc($maxlifetime): bool {} * @param mixed $id * @return string */ - public function read($id): string {} + public function read($id): string + { + } /** * Open @@ -103,7 +113,9 @@ public function read($id): string {} * @param mixed $sessionName * @return bool */ - public function open($savePath, $sessionName): bool {} + public function open($savePath, $sessionName): bool + { + } /** * Write @@ -112,7 +124,9 @@ public function open($savePath, $sessionName): bool {} * @param mixed $data * @return bool */ - public function write($id, $data): bool {} + public function write($id, $data): bool + { + } /** * Helper method to get the name prefixed @@ -120,6 +134,7 @@ public function write($id, $data): bool {} * @param mixed $name * @return string */ - protected function getPrefixedName($name): string {} - + protected function getPrefixedName($name): string + { + } } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 855cad32..9738fab6 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -14,7 +14,7 @@ /** * Phalcon\Session\Adapter\Redis */ - class Redis extends AbstractAdapter +class Redis extends AbstractAdapter { /** @@ -23,6 +23,7 @@ class Redis extends AbstractAdapter * @param \Phalcon\Storage\AdapterFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) {} - + public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + { + } } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php index 6d188e19..6febc697 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/session/adapter/Stream.php @@ -42,19 +42,25 @@ class Stream extends Noop /** * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * @param mixed $id * @return bool */ - public function destroy($id): bool {} + public function destroy($id): bool + { + } /** * @param mixed $maxlifetime * @return bool */ - public function gc($maxlifetime): bool {} + public function gc($maxlifetime): bool + { + } /** * Ignore the savePath and use local defined path @@ -63,19 +69,24 @@ public function gc($maxlifetime): bool {} * @param mixed $sessionName * @return bool */ - public function open($savePath, $sessionName): bool {} + public function open($savePath, $sessionName): bool + { + } /** * @param mixed $id * @return string */ - public function read($id): string {} + public function read($id): string + { + } /** * @param mixed $id * @param mixed $data * @return bool */ - public function write($id, $data): bool {} - + public function write($id, $data): bool + { + } } diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php index d997f346..642c4af5 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/storage/AdapterFactory.php @@ -28,7 +28,9 @@ class AdapterFactory extends AbstractFactory * @param \Phalcon\Storage\SerializerFactory $factory * @param array $services */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) + { + } /** * Create a new instance of the adapter @@ -37,11 +39,14 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * @param array $options * @return \Phalcon\Storage\Adapter\AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/storage/SerializerFactory.php b/src/Phalcon/storage/SerializerFactory.php index 790028a6..24357545 100644 --- a/src/Phalcon/storage/SerializerFactory.php +++ b/src/Phalcon/storage/SerializerFactory.php @@ -22,7 +22,9 @@ class SerializerFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * @param string name @@ -31,11 +33,14 @@ public function __construct(array $services = array()) {} * @param string $name * @return \Phalcon\Storage\Serializer\SerializerInterface */ - public function newInstance(string $name): SerializerInterface {} + public function newInstance(string $name): SerializerInterface + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php index e5ad17f9..e2033524 100644 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -62,19 +62,25 @@ abstract class AbstractAdapter implements AdapterInterface * * @return string */ - public function getDefaultSerializer(): string {} + public function getDefaultSerializer(): string + { + } /** * Name of the default serializer class * * @param string $defaultSerializer */ - public function setDefaultSerializer(string $defaultSerializer) {} + public function setDefaultSerializer(string $defaultSerializer) + { + } /** * @return string */ - public function getPrefix(): string {} + public function getPrefix(): string + { + } /** * Sets parameters based on options @@ -82,7 +88,9 @@ public function getPrefix(): string {} * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) {} + protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) + { + } /** * Flushes/clears the cache @@ -163,7 +171,9 @@ abstract public function set(string $key, $value, $ttl = null): bool; * @param mixed $key * @return string */ - protected function getPrefixedKey($key): string {} + protected function getPrefixedKey($key): string + { + } /** * Returns serialized data @@ -171,7 +181,9 @@ protected function getPrefixedKey($key): string {} * @param mixed $content * @return mixed */ - protected function getSerializedData($content) {} + protected function getSerializedData($content) + { + } /** * Calculates the TTL for a cache item @@ -182,7 +194,9 @@ protected function getSerializedData($content) {} * @param mixed $ttl * @return int */ - protected function getTtl($ttl): int {} + protected function getTtl($ttl): int + { + } /** * Returns unserialized data @@ -191,11 +205,14 @@ protected function getTtl($ttl): int {} * @param mixed $defaultValue * @return mixed */ - protected function getUnserializedData($content, $defaultValue = null) {} + protected function getUnserializedData($content, $defaultValue = null) + { + } /** * Initializes the serializer */ - protected function initSerializer() {} - + protected function initSerializer() + { + } } diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php index 3228aeac..62e55e69 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -97,5 +97,4 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; - } diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/storage/adapter/Apcu.php index d2aa3fdf..2c7e54a5 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/storage/adapter/Apcu.php @@ -28,14 +28,18 @@ class Apcu extends AbstractAdapter * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + { + } /** * Flushes/clears the cache * * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Decrements a stored number @@ -46,7 +50,9 @@ public function clear(): bool {} * @param int $value * @return int|bool */ - public function decrement(string $key, int $value = 1) {} + public function decrement(string $key, int $value = 1) + { + } /** * Reads data from the adapter @@ -56,7 +62,9 @@ public function decrement(string $key, int $value = 1) {} * @param string $key * @return bool */ - public function delete(string $key): bool {} + public function delete(string $key): bool + { + } /** * Reads data from the adapter @@ -67,7 +75,9 @@ public function delete(string $key): bool {} * @param mixed $defaultValue * @return mixed */ - public function get(string $key, $defaultValue = null) {} + public function get(string $key, $defaultValue = null) + { + } /** * Returns the already connected adapter or connects to the Memcached @@ -75,14 +85,18 @@ public function get(string $key, $defaultValue = null) {} * * @return mixed */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Stores data in the adapter * * @return array */ - public function getKeys(): array {} + public function getKeys(): array + { + } /** * Checks if an element exists in the cache @@ -92,7 +106,9 @@ public function getKeys(): array {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Increments a stored number @@ -103,7 +119,9 @@ public function has(string $key): bool {} * @param int $value * @return int|bool */ - public function increment(string $key, int $value = 1) {} + public function increment(string $key, int $value = 1) + { + } /** * Stores data in the adapter @@ -116,6 +134,7 @@ public function increment(string $key, int $value = 1) {} * @param mixed $ttl * @return bool */ - public function set(string $key, $value, $ttl = null): bool {} - + public function set(string $key, $value, $ttl = null): bool + { + } } diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/storage/adapter/Libmemcached.php index d0092724..5e8873c4 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/storage/adapter/Libmemcached.php @@ -30,7 +30,9 @@ class Libmemcached extends AbstractAdapter * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + { + } /** * Flushes/clears the cache @@ -38,7 +40,9 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * @throws Exception * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Decrements a stored number @@ -47,7 +51,9 @@ public function clear(): bool {} * @param int $value * @return int|bool */ - public function decrement(string $key, int $value = 1) {} + public function decrement(string $key, int $value = 1) + { + } /** * Reads data from the adapter @@ -58,7 +64,9 @@ public function decrement(string $key, int $value = 1) {} * @param string $key * @return bool */ - public function delete(string $key): bool {} + public function delete(string $key): bool + { + } /** * Reads data from the adapter @@ -70,7 +78,9 @@ public function delete(string $key): bool {} * @param mixed $defaultValue * @return mixed */ - public function get(string $key, $defaultValue = null) {} + public function get(string $key, $defaultValue = null) + { + } /** * Returns the already connected adapter or connects to the Memcached @@ -79,7 +89,9 @@ public function get(string $key, $defaultValue = null) {} * @throws Exception * @return mixed */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Stores data in the adapter @@ -87,7 +99,9 @@ public function getAdapter() {} * @throws Exception * @return array */ - public function getKeys(): array {} + public function getKeys(): array + { + } /** * Checks if an element exists in the cache @@ -98,7 +112,9 @@ public function getKeys(): array {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Increments a stored number @@ -110,7 +126,9 @@ public function has(string $key): bool {} * @param int $value * @return int|bool */ - public function increment(string $key, int $value = 1) {} + public function increment(string $key, int $value = 1) + { + } /** * Stores data in the adapter @@ -123,7 +141,9 @@ public function increment(string $key, int $value = 1) {} * @param mixed $ttl * @return bool */ - public function set(string $key, $value, $ttl = null): bool {} + public function set(string $key, $value, $ttl = null): bool + { + } /** * Checks the serializer. If it is a supported one it is set, otherwise @@ -131,6 +151,7 @@ public function set(string $key, $value, $ttl = null): bool {} * * @param Memcached $connection */ - private function setSerializer(\Memcached $connection) {} - + private function setSerializer(\Memcached $connection) + { + } } diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/storage/adapter/Memory.php index 802a60e5..2390073f 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/storage/adapter/Memory.php @@ -35,14 +35,18 @@ class Memory extends AbstractAdapter * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + { + } /** * Flushes/clears the cache * * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Decrements a stored number @@ -53,7 +57,9 @@ public function clear(): bool {} * @param int $value * @return int|bool */ - public function decrement(string $key, int $value = 1) {} + public function decrement(string $key, int $value = 1) + { + } /** * Reads data from the adapter @@ -63,7 +69,9 @@ public function decrement(string $key, int $value = 1) {} * @param string $key * @return bool */ - public function delete(string $key): bool {} + public function delete(string $key): bool + { + } /** * Reads data from the adapter @@ -74,7 +82,9 @@ public function delete(string $key): bool {} * @param mixed $defaultValue * @return mixed */ - public function get(string $key, $defaultValue = null) {} + public function get(string $key, $defaultValue = null) + { + } /** * Returns the already connected adapter or connects to the Memcached @@ -82,14 +92,18 @@ public function get(string $key, $defaultValue = null) {} * * @return mixed */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Stores data in the adapter * * @return array */ - public function getKeys(): array {} + public function getKeys(): array + { + } /** * Checks if an element exists in the cache @@ -99,7 +113,9 @@ public function getKeys(): array {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Increments a stored number @@ -110,7 +126,9 @@ public function has(string $key): bool {} * @param int $value * @return int|bool */ - public function increment(string $key, int $value = 1) {} + public function increment(string $key, int $value = 1) + { + } /** * Stores data in the adapter @@ -122,6 +140,7 @@ public function increment(string $key, int $value = 1) {} * @param mixed $ttl * @return bool */ - public function set(string $key, $value, $ttl = null): bool {} - + public function set(string $key, $value, $ttl = null): bool + { + } } diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/storage/adapter/Redis.php index 541aad14..2a304a7c 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/storage/adapter/Redis.php @@ -30,7 +30,9 @@ class Redis extends AbstractAdapter * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + { + } /** * Flushes/clears the cache @@ -38,7 +40,9 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * @throws Exception * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Decrements a stored number @@ -50,7 +54,9 @@ public function clear(): bool {} * @param int $value * @return int|bool */ - public function decrement(string $key, int $value = 1) {} + public function decrement(string $key, int $value = 1) + { + } /** * Reads data from the adapter @@ -61,7 +67,9 @@ public function decrement(string $key, int $value = 1) {} * @param string $key * @return bool */ - public function delete(string $key): bool {} + public function delete(string $key): bool + { + } /** * Reads data from the adapter @@ -73,7 +81,9 @@ public function delete(string $key): bool {} * @param mixed $defaultValue * @return mixed */ - public function get(string $key, $defaultValue = null) {} + public function get(string $key, $defaultValue = null) + { + } /** * Returns the already connected adapter or connects to the Memcached @@ -82,7 +92,9 @@ public function get(string $key, $defaultValue = null) {} * @throws Exception * @return mixed */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Stores data in the adapter @@ -90,7 +102,9 @@ public function getAdapter() {} * @throws Exception * @return array */ - public function getKeys(): array {} + public function getKeys(): array + { + } /** * Checks if an element exists in the cache @@ -101,7 +115,9 @@ public function getKeys(): array {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Increments a stored number @@ -113,7 +129,9 @@ public function has(string $key): bool {} * @param int $value * @return int|bool */ - public function increment(string $key, int $value = 1) {} + public function increment(string $key, int $value = 1) + { + } /** * Stores data in the adapter @@ -126,7 +144,9 @@ public function increment(string $key, int $value = 1) {} * @param mixed $ttl * @return bool */ - public function set(string $key, $value, $ttl = null): bool {} + public function set(string $key, $value, $ttl = null): bool + { + } /** * Checks the serializer. If it is a supported one it is set, otherwise @@ -134,6 +154,7 @@ public function set(string $key, $value, $ttl = null): bool {} * * @param \Redis $connection */ - private function setSerializer(\Redis $connection) {} - + private function setSerializer(\Redis $connection) + { + } } diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/storage/adapter/Stream.php index 9e2d6fc8..0008660d 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/storage/adapter/Stream.php @@ -39,14 +39,18 @@ class Stream extends AbstractAdapter * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) {} + public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + { + } /** * Flushes/clears the cache * * @return bool */ - public function clear(): bool {} + public function clear(): bool + { + } /** * Decrements a stored number @@ -58,7 +62,9 @@ public function clear(): bool {} * @param int $value * @return int|bool */ - public function decrement(string $key, int $value = 1) {} + public function decrement(string $key, int $value = 1) + { + } /** * Reads data from the adapter @@ -68,7 +74,9 @@ public function decrement(string $key, int $value = 1) {} * @param string $key * @return bool */ - public function delete(string $key): bool {} + public function delete(string $key): bool + { + } /** * Reads data from the adapter @@ -79,7 +87,9 @@ public function delete(string $key): bool {} * @param mixed $defaultValue * @return mixed */ - public function get(string $key, $defaultValue = null) {} + public function get(string $key, $defaultValue = null) + { + } /** * Returns the already connected adapter or connects to the Memcached @@ -87,14 +97,18 @@ public function get(string $key, $defaultValue = null) {} * * @return mixed */ - public function getAdapter() {} + public function getAdapter() + { + } /** * Stores data in the adapter * * @return array */ - public function getKeys(): array {} + public function getKeys(): array + { + } /** * Checks if an element exists in the cache and is not expired @@ -104,7 +118,9 @@ public function getKeys(): array {} * @param string $key * @return bool */ - public function has(string $key): bool {} + public function has(string $key): bool + { + } /** * Increments a stored number @@ -116,7 +132,9 @@ public function has(string $key): bool {} * @param int $value * @return int|bool */ - public function increment(string $key, int $value = 1) {} + public function increment(string $key, int $value = 1) + { + } /** * Stores data in the adapter @@ -129,7 +147,9 @@ public function increment(string $key, int $value = 1) {} * @param mixed $ttl * @return bool */ - public function set(string $key, $value, $ttl = null): bool {} + public function set(string $key, $value, $ttl = null): bool + { + } /** * Returns the folder based on the cacheDir and the prefix @@ -139,7 +159,9 @@ public function set(string $key, $value, $ttl = null): bool {} * @param string $key * @return string */ - private function getDir(string $key = ''): string {} + private function getDir(string $key = ''): string + { + } /** * Returns the full path to the file @@ -147,13 +169,17 @@ private function getDir(string $key = ''): string {} * @param string $key * @return string */ - private function getFilepath(string $key): string {} + private function getFilepath(string $key): string + { + } /** * @param string $dir * @return \Iterator */ - private function getIterator(string $dir): Iterator {} + private function getIterator(string $dir): Iterator + { + } /** * Returns if the cache has expired for this item or not @@ -163,6 +189,7 @@ private function getIterator(string $dir): Iterator {} * @param array $payload * @return bool */ - private function isExpired(array $payload): bool {} - + private function isExpired(array $payload): bool + { + } } diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/storage/serializer/AbstractSerializer.php index aaace3b8..5e81b812 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/storage/serializer/AbstractSerializer.php @@ -24,7 +24,9 @@ abstract class AbstractSerializer implements SerializerInterface * * @param mixed $data */ - public function __construct($data = null) {} + public function __construct($data = null) + { + } /** * If this returns true, then the data returns back as is @@ -32,16 +34,21 @@ public function __construct($data = null) {} * @param mixed $data * @return bool */ - protected function isSerializable($data): bool {} + protected function isSerializable($data): bool + { + } /** * @return mixed */ - public function getData() {} + public function getData() + { + } /** * @param mixed $data */ - public function setData($data) {} - + public function setData($data) + { + } } diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php index f42b5448..ca63bbba 100644 --- a/src/Phalcon/storage/serializer/Base64.php +++ b/src/Phalcon/storage/serializer/Base64.php @@ -19,13 +19,16 @@ class Base64 extends AbstractSerializer * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php index 9e0dae56..4c1da5b4 100644 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -19,13 +19,16 @@ class Igbinary extends AbstractSerializer * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php index 7b22a8ba..7681fa4f 100644 --- a/src/Phalcon/storage/serializer/Json.php +++ b/src/Phalcon/storage/serializer/Json.php @@ -19,13 +19,16 @@ class Json extends AbstractSerializer * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php index 390a6940..d7148546 100644 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -19,13 +19,16 @@ class Msgpack extends AbstractSerializer * * @return string|null */ - public function serialize(): ?string {} + public function serialize(): ?string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php index bff7f7a5..41d11ce0 100644 --- a/src/Phalcon/storage/serializer/None.php +++ b/src/Phalcon/storage/serializer/None.php @@ -19,13 +19,16 @@ class None extends AbstractSerializer * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php index 046b4ef2..2aa3fdf5 100644 --- a/src/Phalcon/storage/serializer/Php.php +++ b/src/Phalcon/storage/serializer/Php.php @@ -19,13 +19,16 @@ class Php extends AbstractSerializer * * @return string */ - public function serialize(): string {} + public function serialize(): string + { + } /** * Unserializes data * * @param mixed $data */ - public function unserialize($data) {} - + public function unserialize($data) + { + } } diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php index 5bbc9ac1..aad5ab27 100644 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -25,5 +25,4 @@ public function getData(); * @param mixed $data */ public function setData($data); - } diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index d4844f81..539de934 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -27,7 +27,9 @@ abstract class Select * @param array $data * @return string */ - public static function selectField($parameters, $data = null): string {} + public static function selectField($parameters, $data = null): string + { + } /** * Generate the OPTION tags based on an array @@ -37,7 +39,9 @@ public static function selectField($parameters, $data = null): string {} * @param string $closeOption * @return string */ - private static function optionsFromArray(array $data, $value, string $closeOption): string {} + private static function optionsFromArray(array $data, $value, string $closeOption): string + { + } /** * Generate the OPTION tags based on a resultset @@ -48,6 +52,7 @@ private static function optionsFromArray(array $data, $value, string $closeOptio * @param string $closeOption * @return string */ - private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string {} - + private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string + { + } } diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php index 00d97024..84beea80 100644 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -32,7 +32,9 @@ class InterpolatorFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Create a new instance of the adapter @@ -40,11 +42,14 @@ public function __construct(array $services = array()) {} * @param string $name * @return \Phalcon\Translate\Adapter\AdapterInterface */ - public function newInstance(string $name): AdapterInterface {} + public function newInstance(string $name): AdapterInterface + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/translate/TranslateFactory.php b/src/Phalcon/translate/TranslateFactory.php index 780522a9..a9e9b305 100644 --- a/src/Phalcon/translate/TranslateFactory.php +++ b/src/Phalcon/translate/TranslateFactory.php @@ -27,7 +27,9 @@ class TranslateFactory extends AbstractFactory * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $services */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) + { + } /** * Factory to create an instace from a Config object @@ -35,7 +37,9 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param mixed $config * @return mixed */ - public function load($config) {} + public function load($config) + { + } /** * Create a new instance of the adapter @@ -44,11 +48,14 @@ public function load($config) {} * @param array $options * @return AbstractAdapter */ - public function newInstance(string $name, array $options = array()): AbstractAdapter {} + public function newInstance(string $name, array $options = array()): AbstractAdapter + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php index 5d00f1c7..001fa671 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -35,7 +35,9 @@ abstract class AbstractAdapter implements AdapterInterface * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + { + } /** * Returns the translation string of the given key (alias of method 't') @@ -44,7 +46,9 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param array $placeholders * @return string */ - public function _(string $translateKey, $placeholders = null): string {} + public function _(string $translateKey, $placeholders = null): string + { + } /** * Check whether a translation key exists @@ -52,7 +56,9 @@ public function _(string $translateKey, $placeholders = null): string {} * @param mixed $translateKey * @return bool */ - public function offsetExists($translateKey): bool {} + public function offsetExists($translateKey): bool + { + } /** * Returns the translation related to the given key @@ -60,7 +66,9 @@ public function offsetExists($translateKey): bool {} * @param mixed $translateKey * @return mixed */ - public function offsetGet($translateKey) {} + public function offsetGet($translateKey) + { + } /** * Sets a translation value @@ -68,14 +76,18 @@ public function offsetGet($translateKey) {} * @param mixed $offset * @param string $value */ - public function offsetSet($offset, $value) {} + public function offsetSet($offset, $value) + { + } /** * Unsets a translation from the dictionary * * @param mixed $offset */ - public function offsetUnset($offset) {} + public function offsetUnset($offset) + { + } /** * Returns the translation string of the given key @@ -84,7 +96,9 @@ public function offsetUnset($offset) {} * @param array $placeholders * @return string */ - public function t(string $translateKey, $placeholders = null): string {} + public function t(string $translateKey, $placeholders = null): string + { + } /** * Replaces placeholders by the values passed @@ -93,6 +107,7 @@ public function t(string $translateKey, $placeholders = null): string {} * @param mixed $placeholders * @return string */ - protected function replacePlaceholders(string $translation, $placeholders = null): string {} - + protected function replacePlaceholders(string $translation, $placeholders = null): string + { + } } diff --git a/src/Phalcon/translate/adapter/AdapterInterface.php b/src/Phalcon/translate/adapter/AdapterInterface.php index 7c1058f4..57de10d1 100644 --- a/src/Phalcon/translate/adapter/AdapterInterface.php +++ b/src/Phalcon/translate/adapter/AdapterInterface.php @@ -44,5 +44,4 @@ public function query(string $translateKey, $placeholders = null): string; * @return string */ public function t(string $translateKey, $placeholders = null): string; - } diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 9ec2a74d..14f03d2d 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -32,7 +32,9 @@ class Csv extends AbstractAdapter implements ArrayAccess * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + { + } /** * Check whether is defined a translation key in the internal array @@ -40,7 +42,9 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param string $index * @return bool */ - public function exists(string $index): bool {} + public function exists(string $index): bool + { + } /** * Returns the translation related to the given key @@ -49,7 +53,9 @@ public function exists(string $index): bool {} * @param mixed $placeholders * @return string */ - public function query(string $index, $placeholders = null): string {} + public function query(string $index, $placeholders = null): string + { + } /** * Load translates from file @@ -59,6 +65,7 @@ public function query(string $index, $placeholders = null): string {} * @param string $delimiter * @param string $enclosure */ - private function load(string $file, int $length, string $delimiter, string $enclosure) {} - + private function load(string $file, int $length, string $delimiter, string $enclosure) + { + } } diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 0be89697..5c502b29 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -57,22 +57,30 @@ class Gettext extends AbstractAdapter implements ArrayAccess /** * @return int */ - public function getCategory(): int {} + public function getCategory(): int + { + } /** * @return string */ - public function getDefaultDomain(): string {} + public function getDefaultDomain(): string + { + } /** * @return string|array */ - public function getDirectory() {} + public function getDirectory() + { + } /** * @return string */ - public function getLocale(): string {} + public function getLocale(): string + { + } /** * Phalcon\Translate\Adapter\Gettext constructor @@ -80,7 +88,9 @@ public function getLocale(): string {} * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + { + } /** * Check whether is defined a translation key in the internal array @@ -88,7 +98,9 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param string $index * @return bool */ - public function exists(string $index): bool {} + public function exists(string $index): bool + { + } /** * The plural version of gettext(). @@ -102,7 +114,9 @@ public function exists(string $index): bool {} * @param string $domain * @return string */ - public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string {} + public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string + { + } /** * Returns the translation related to the given key. @@ -115,21 +129,27 @@ public function nquery(string $msgid1, string $msgid2, int $count, $placeholders * @param array $placeholders * @return string */ - public function query(string $index, $placeholders = null): string {} + public function query(string $index, $placeholders = null): string + { + } /** * Sets the default domain * * @return string */ - public function resetDomain(): string {} + public function resetDomain(): string + { + } /** * Sets the domain default to search within when calls are made to gettext() * * @param string $domain */ - public function setDefaultDomain(string $domain) {} + public function setDefaultDomain(string $domain) + { + } /** * Sets the path for a domain @@ -149,7 +169,9 @@ public function setDefaultDomain(string $domain) {} * * @param string|array $directory The directory path or an array of directories and domains */ - public function setDirectory($directory) {} + public function setDirectory($directory) + { + } /** * Changes the current domain (i.e. the translation file) @@ -157,7 +179,9 @@ public function setDirectory($directory) {} * @param mixed $domain * @return string */ - public function setDomain($domain): string {} + public function setDomain($domain): string + { + } /** * Sets locale information @@ -174,20 +198,25 @@ public function setDomain($domain): string {} * @param string $locale * @return string|bool */ - public function setLocale(int $category, string $locale) {} + public function setLocale(int $category, string $locale) + { + } /** * Gets default options * * @return array */ - protected function getOptionsDefault(): array {} + protected function getOptionsDefault(): array + { + } /** * Validator for constructor * * @param array $options */ - protected function prepareOptions(array $options) {} - + protected function prepareOptions(array $options) + { + } } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index 389eddb0..fead32cc 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -37,7 +37,9 @@ class NativeArray extends AbstractAdapter implements ArrayAccess * @param \Phalcon\Translate\InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) {} + public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + { + } /** * Check whether is defined a translation key in the internal array @@ -45,7 +47,9 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator * @param string $index * @return bool */ - public function exists(string $index): bool {} + public function exists(string $index): bool + { + } /** * Whenever a key is not found this medhod will be called @@ -53,7 +57,9 @@ public function exists(string $index): bool {} * @param string $index * @return string */ - public function notFound(string $index): string {} + public function notFound(string $index): string + { + } /** * Returns the translation related to the given key @@ -62,6 +68,7 @@ public function notFound(string $index): string {} * @param mixed $placeholders * @return string */ - public function query(string $index, $placeholders = null): string {} - + public function query(string $index, $placeholders = null): string + { + } } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index f5a5758d..b7051f05 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -21,6 +21,7 @@ class AssociativeArray implements InterpolatorInterface * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string {} - + public function replacePlaceholders(string $translation, array $placeholders = array()): string + { + } } diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index 64522c63..cc120f23 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -21,6 +21,7 @@ class IndexedArray implements InterpolatorInterface * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string {} - + public function replacePlaceholders(string $translation, array $placeholders = array()): string + { + } } diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php index ed96d56f..93adba8b 100644 --- a/src/Phalcon/translate/interpolator/InterpolatorInterface.php +++ b/src/Phalcon/translate/interpolator/InterpolatorInterface.php @@ -27,5 +27,4 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; - } diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/url/UrlInterface.php index 9ee891ec..140d2ca1 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/url/UrlInterface.php @@ -64,5 +64,4 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; - } diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/validation/AbstractValidator.php index 7e32fb8a..289a47a4 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/validation/AbstractValidator.php @@ -41,7 +41,9 @@ abstract class AbstractValidator implements ValidatorInterface * * @param array $options */ - public function __construct(array $options = array()) {} + public function __construct(array $options = array()) + { + } /** * Get the template message @@ -50,14 +52,18 @@ public function __construct(array $options = array()) {} * @param string $field * @return string */ - public function getTemplate(string $field = null): string {} + public function getTemplate(string $field = null): string + { + } /** * Get templates collection object * * @return array */ - public function getTemplates(): array {} + public function getTemplates(): array + { + } /** * Clear current templates and set new from an array, @@ -65,7 +71,9 @@ public function getTemplates(): array {} * @param array $templates * @return \Phalcon\Validation\ValidatorInterface */ - public function setTemplates(array $templates): ValidatorInterface {} + public function setTemplates(array $templates): ValidatorInterface + { + } /** * Set a new template message @@ -73,7 +81,9 @@ public function setTemplates(array $templates): ValidatorInterface {} * @param string $template * @return \Phalcon\Validation\ValidatorInterface */ - public function setTemplate(string $template): ValidatorInterface {} + public function setTemplate(string $template): ValidatorInterface + { + } /** * Returns an option in the validator's options @@ -83,7 +93,9 @@ public function setTemplate(string $template): ValidatorInterface {} * @param mixed $defaultValue * @return mixed */ - public function getOption(string $key, $defaultValue = null) {} + public function getOption(string $key, $defaultValue = null) + { + } /** * Checks if an option is defined @@ -91,7 +103,9 @@ public function getOption(string $key, $defaultValue = null) {} * @param string $key * @return bool */ - public function hasOption(string $key): bool {} + public function hasOption(string $key): bool + { + } /** * Sets an option in the validator @@ -99,7 +113,9 @@ public function hasOption(string $key): bool {} * @param string $key * @param mixed $value */ - public function setOption(string $key, $value) {} + public function setOption(string $key, $value) + { + } /** * Executes the validation @@ -116,7 +132,9 @@ abstract public function validate(\Phalcon\Validation $validation, $field): bool * @param string $field * @return int|null */ - protected function prepareCode(string $field): ?int {} + protected function prepareCode(string $field): ?int + { + } /** * Prepares a label for the field. @@ -125,7 +143,9 @@ protected function prepareCode(string $field): ?int {} * @param string $field * @return mixed */ - protected function prepareLabel(\Phalcon\Validation $validation, string $field) {} + protected function prepareLabel(\Phalcon\Validation $validation, string $field) + { + } /** * Create a default message by factory @@ -138,6 +158,7 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) * @param array $replacements * @return \Phalcon\Messages\Message */ - public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message {} - + public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message + { + } } diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/validation/AbstractValidatorComposite.php index d5f53f2c..fd1cc0f5 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/validation/AbstractValidatorComposite.php @@ -25,7 +25,9 @@ abstract class AbstractValidatorComposite extends AbstractValidator implements V /** * @return array */ - public function getValidators(): array {} + public function getValidators(): array + { + } /** * Executes the validation @@ -34,6 +36,7 @@ public function getValidators(): array {} * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/validation/ValidationInterface.php index f4c05ab1..4f4208bc 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/validation/ValidationInterface.php @@ -133,5 +133,4 @@ public function setLabels(array $labels); * @return \Phalcon\Messages\Messages */ public function validate($data = null, $entity = null): Messages; - } diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/validation/ValidatorCompositeInterface.php index c098626d..ff5517fe 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/validation/ValidatorCompositeInterface.php @@ -32,5 +32,4 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; - } diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/validation/ValidatorFactory.php index 2b615b48..5a9d8a04 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/validation/ValidatorFactory.php @@ -21,7 +21,9 @@ class ValidatorFactory extends AbstractFactory * * @param array $services */ - public function __construct(array $services = array()) {} + public function __construct(array $services = array()) + { + } /** * Creates a new instance @@ -29,11 +31,14 @@ public function __construct(array $services = array()) {} * @param string $name * @return mixed */ - public function newInstance(string $name) {} + public function newInstance(string $name) + { + } /** * @return array */ - protected function getAdapters(): array {} - + protected function getAdapters(): array + { + } } diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 16bdd711..110b363c 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -75,5 +75,4 @@ public function setTemplates(array $templates): ValidatorInterface; * @return ValidatorInterface */ public function setTemplate(string $template): ValidatorInterface; - } diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index 814f1936..55f5e951 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -60,6 +60,7 @@ class Alnum extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 42650863..c3ae3047 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -60,6 +60,7 @@ class Alpha extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index f41e0a38..48ab93b3 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -71,6 +71,7 @@ class Between extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index ab3860ab..5655dc60 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -70,6 +70,7 @@ class Callback extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 9c7baade..7bf794ba 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -65,7 +65,9 @@ class Confirmation extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field): bool + { + } /** * Compare strings @@ -74,6 +76,7 @@ public function validate(\Phalcon\Validation $validation, $field): bool {} * @param string $b * @return bool */ - final protected function compare(string $a, string $b): bool {} - + final protected function compare(string $a, string $b): bool + { + } } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index c5144cf6..d2bd9b83 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -60,7 +60,9 @@ class CreditCard extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field): bool + { + } /** * is a simple checksum formula used to validate a variety of identification @@ -69,6 +71,7 @@ public function validate(\Phalcon\Validation $validation, $field): bool {} * @param string $number * @return bool */ - private function verifyByLuhnAlgorithm(string $number): bool {} - + private function verifyByLuhnAlgorithm(string $number): bool + { + } } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index 52b74ff0..c952f8b9 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -65,13 +65,16 @@ class Date extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field): bool + { + } /** * @param mixed $value * @param mixed $format * @return bool */ - private function checkDate($value, $format): bool {} - + private function checkDate($value, $format): bool + { + } } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index ee134d53..602bb2f8 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -60,6 +60,7 @@ class Digit extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index be776a7d..237e041a 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -60,6 +60,7 @@ class Email extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index 8f6c3463..8b0049c2 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -71,6 +71,7 @@ class ExclusionIn extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index d1eec32e..13d86e30 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -88,6 +88,7 @@ class File extends AbstractValidatorComposite * * @param array $options */ - public function __construct(array $options = array()) {} - + public function __construct(array $options = array()) + { + } } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 240a5c71..7ad7a702 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -65,6 +65,7 @@ class Identical extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 489d383f..63ca375e 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -65,6 +65,7 @@ class InclusionIn extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 3fd9af00..b72960ab 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -83,6 +83,7 @@ class Ip extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index 7f93c397..bf7203fb 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -60,6 +60,7 @@ class Numericality extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index ea6f0a63..bd254e75 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -60,6 +60,7 @@ class PresenceOf extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index b37ea0ee..152d0f79 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -65,6 +65,7 @@ class Regex extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index 4eb2e945..e50d4c21 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -83,6 +83,7 @@ class StringLength extends AbstractValidatorComposite * * @param array $options */ - public function __construct(array $options = array()) {} - + public function __construct(array $options = array()) + { + } } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index b5e777d0..3e16b4a0 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -102,7 +102,9 @@ class Uniqueness extends AbstractCombinedFieldsValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} + public function validate(\Phalcon\Validation $validation, $field): bool + { + } /** * The column map is used in the case to get real column name @@ -111,14 +113,18 @@ public function validate(\Phalcon\Validation $validation, $field): bool {} * @param string $field * @return string */ - protected function getColumnNameReal($record, string $field): string {} + protected function getColumnNameReal($record, string $field): string + { + } /** * @param \Phalcon\Validation $validation * @param mixed $field * @return bool */ - protected function isUniqueness(\Phalcon\Validation $validation, $field): bool {} + protected function isUniqueness(\Phalcon\Validation $validation, $field): bool + { + } /** * Uniqueness method used for model @@ -127,6 +133,7 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool { * @param array $field * @param array $values */ - protected function isUniquenessModel($record, array $field, array $values) {} - + protected function isUniquenessModel($record, array $field, array $values) + { + } } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 57e3312f..0929bf8a 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -60,6 +60,7 @@ class Url extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php index de85590b..8f270d98 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -73,38 +73,50 @@ abstract class AbstractFile extends AbstractValidator /** * Empty is empty */ - public function getMessageFileEmpty() {} + public function getMessageFileEmpty() + { + } /** * Empty is empty * * @param mixed $messageFileEmpty */ - public function setMessageFileEmpty($messageFileEmpty) {} + public function setMessageFileEmpty($messageFileEmpty) + { + } /** * File exceeed the file size setted in PHP configuration */ - public function getMessageIniSize() {} + public function getMessageIniSize() + { + } /** * File exceeed the file size setted in PHP configuration * * @param mixed $messageIniSize */ - public function setMessageIniSize($messageIniSize) {} + public function setMessageIniSize($messageIniSize) + { + } /** * File is not valid */ - public function getMessageValid() {} + public function getMessageValid() + { + } /** * File is not valid * * @param mixed $messageValid */ - public function setMessageValid($messageValid) {} + public function setMessageValid($messageValid) + { + } /** * Check on empty @@ -113,7 +125,9 @@ public function setMessageValid($messageValid) {} * @param mixed $field * @return bool */ - public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool {} + public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool + { + } /** * Check upload @@ -122,7 +136,9 @@ public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bo * @param mixed $field * @return bool */ - public function checkUpload(\Phalcon\Validation $validation, $field): bool {} + public function checkUpload(\Phalcon\Validation $validation, $field): bool + { + } /** * Check if uploaded file is larger than PHP allowed size @@ -131,7 +147,9 @@ public function checkUpload(\Phalcon\Validation $validation, $field): bool {} * @param mixed $field * @return bool */ - public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool {} + public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool + { + } /** * Check if upload is empty @@ -140,7 +158,9 @@ public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): boo * @param mixed $field * @return bool */ - public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool {} + public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool + { + } /** * Check if upload is valid @@ -149,7 +169,9 @@ public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): boo * @param mixed $field * @return bool */ - public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool {} + public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool + { + } /** * Convert a string like "2.5MB" in bytes @@ -157,6 +179,7 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo * @param string $size * @return double */ - public function getFileSizeInBytes(string $size): float {} - + public function getFileSizeInBytes(string $size): float + { + } } diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php index 2d50b13e..50bb37e7 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -72,6 +72,7 @@ class MimeType extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php index b9118087..0c4eb988 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -65,6 +65,7 @@ class Equal extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php index e16aff7b..5e489a41 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -70,6 +70,7 @@ class Max extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php index dbcbdf3e..b02efcc6 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -70,6 +70,7 @@ class Min extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php index 90708201..3fd86902 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -70,6 +70,7 @@ class Equal extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php index 50474cd2..f8bdcef7 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -70,6 +70,7 @@ class Max extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php index cb5bbf5c..10c534af 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -70,6 +70,7 @@ class Min extends AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php index b68c274f..b0c386c8 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -72,6 +72,7 @@ class Max extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php index e9991752..75f8acab 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -72,6 +72,7 @@ class Min extends AbstractValidator * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool {} - + public function validate(\Phalcon\Validation $validation, $field): bool + { + } } From 0cae622eaaf8ef4783a4d5918966109dd2114125 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Tue, 24 Sep 2019 13:12:18 +0200 Subject: [PATCH 14/25] Added psalm rules --- .travis.yml | 3 +++ psalm.xml | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.travis.yml b/.travis.yml index e863ba8b..01c8e37d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,9 @@ before_install: - git config --global advice.detachedHead false - if [ -n "$GITHUB_TOKEN" ]; then composer config github-oauth.github.com "$GITHUB_TOKEN"; fi +install: + - pecl install --force psr + before_script: - travis_retry composer install --no-interaction --no-ansi --no-progress --no-suggest diff --git a/psalm.xml b/psalm.xml index 36ec92a1..59102475 100644 --- a/psalm.xml +++ b/psalm.xml @@ -19,5 +19,19 @@ + + + + + + + + + + + + + + From 1fd15af74ecb27dafae0c83d86a35af05c220dd4 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Tue, 24 Sep 2019 13:12:38 +0200 Subject: [PATCH 15/25] Show info info in travis for psalm --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 01c8e37d..e145986d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_script: - travis_retry composer install --no-interaction --no-ansi --no-progress --no-suggest script: - - vendor/bin/psalm --show-info=false + - vendor/bin/psalm - phpenv config-rm xdebug.ini || true - vendor/bin/phpcs From 62206a0ba86159cbd14d7a97e270082186a51fc1 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Tue, 24 Sep 2019 13:24:32 +0200 Subject: [PATCH 16/25] Do not report warnings as error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e145986d..b3bdb615 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: script: - vendor/bin/psalm - phpenv config-rm xdebug.ini || true - - vendor/bin/phpcs + - vendor/bin/phpcs --error-severity=0 notifications: email: false From 087ccff566e75a6b9a79a655dfa706482883c669 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Tue, 24 Sep 2019 13:32:29 +0200 Subject: [PATCH 17/25] Ignore PSR2.Classes.PropertyDeclaration.Underscore errors --- .travis.yml | 2 +- phpcs.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b3bdb615..e145986d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: script: - vendor/bin/psalm - phpenv config-rm xdebug.ini || true - - vendor/bin/phpcs --error-severity=0 + - vendor/bin/phpcs notifications: email: false diff --git a/phpcs.xml b/phpcs.xml index c3454726..55fb6a0b 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,6 +7,7 @@ + src From 9c516378eeb14e46102fb7c6539fe5ee16146a4c Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sat, 26 Oct 2019 20:07:51 +0200 Subject: [PATCH 18/25] Bumped Stubs to RC.2 --- src/Phalcon/Cache.php | 59 ++++-------- src/Phalcon/Collection.php | 28 +++--- src/Phalcon/Config.php | 17 ++-- src/Phalcon/Container.php | 16 +--- src/Phalcon/Crypt.php | 14 +-- src/Phalcon/Debug.php | 19 ++-- src/Phalcon/Di.php | 25 +++-- src/Phalcon/Escaper.php | 18 ++-- src/Phalcon/Exception.php | 14 +-- src/Phalcon/Filter.php | 14 +-- src/Phalcon/Kernel.php | 12 +-- src/Phalcon/Loader.php | 19 ++-- src/Phalcon/Logger.php | 67 ++++++++----- src/Phalcon/Registry.php | 18 ++-- src/Phalcon/Security.php | 18 ++-- src/Phalcon/Tag.php | 36 +++---- src/Phalcon/Text.php | 15 +-- src/Phalcon/Url.php | 21 ++-- src/Phalcon/Validation.php | 19 ++-- src/Phalcon/Version.php | 12 +-- src/Phalcon/acl/Component.php | 14 +-- src/Phalcon/acl/ComponentAware.php | 10 +- src/Phalcon/acl/ComponentInterface.php | 10 +- src/Phalcon/acl/Enum.php | 11 +-- src/Phalcon/acl/Exception.php | 9 -- src/Phalcon/acl/Role.php | 14 +-- src/Phalcon/acl/RoleAware.php | 10 +- src/Phalcon/acl/RoleInterface.php | 10 +- src/Phalcon/acl/adapter/AbstractAdapter.php | 14 +-- src/Phalcon/acl/adapter/AdapterInterface.php | 17 ++-- src/Phalcon/acl/adapter/Memory.php | 26 ++--- src/Phalcon/annotations/Annotation.php | 12 +-- .../annotations/AnnotationsFactory.php | 11 +-- src/Phalcon/annotations/Collection.php | 18 ++-- src/Phalcon/annotations/Exception.php | 9 -- src/Phalcon/annotations/Reader.php | 15 +-- src/Phalcon/annotations/ReaderInterface.php | 10 +- src/Phalcon/annotations/Reflection.php | 16 +--- .../annotations/adapter/AbstractAdapter.php | 18 ++-- .../annotations/adapter/AdapterInterface.php | 12 +-- src/Phalcon/annotations/adapter/Apcu.php | 17 ++-- src/Phalcon/annotations/adapter/Memory.php | 13 +-- src/Phalcon/annotations/adapter/Stream.php | 18 ++-- .../application/AbstractApplication.php | 13 +-- src/Phalcon/application/Exception.php | 9 -- src/Phalcon/assets/Asset.php | 16 +--- src/Phalcon/assets/AssetInterface.php | 10 +- src/Phalcon/assets/Collection.php | 21 ++-- src/Phalcon/assets/Exception.php | 9 -- src/Phalcon/assets/FilterInterface.php | 10 +- src/Phalcon/assets/Inline.php | 16 +--- src/Phalcon/assets/Manager.php | 23 ++--- src/Phalcon/assets/asset/Css.php | 14 +-- src/Phalcon/assets/asset/Js.php | 14 +-- src/Phalcon/assets/filters/Cssmin.php | 12 +-- src/Phalcon/assets/filters/Jsmin.php | 12 +-- src/Phalcon/assets/filters/None.php | 12 +-- src/Phalcon/assets/inline/Css.php | 14 +-- src/Phalcon/assets/inline/Js.php | 14 +-- src/Phalcon/cache/AdapterFactory.php | 17 +--- src/Phalcon/cache/CacheFactory.php | 20 ++-- .../cache/adapter/AdapterInterface.php | 13 +-- src/Phalcon/cache/adapter/Apcu.php | 15 +-- src/Phalcon/cache/adapter/Libmemcached.php | 15 +-- src/Phalcon/cache/adapter/Memory.php | 15 +-- src/Phalcon/cache/adapter/Redis.php | 15 +-- src/Phalcon/cache/adapter/Stream.php | 15 +-- src/Phalcon/cache/exception/Exception.php | 9 -- .../exception/InvalidArgumentException.php | 9 -- src/Phalcon/cli/Console.php | 14 +-- src/Phalcon/cli/Dispatcher.php | 23 ++--- src/Phalcon/cli/DispatcherInterface.php | 14 +-- src/Phalcon/cli/Router.php | 28 +++--- src/Phalcon/cli/RouterInterface.php | 10 +- src/Phalcon/cli/Task.php | 39 +++++--- src/Phalcon/cli/TaskInterface.php | 9 -- src/Phalcon/cli/console/Exception.php | 9 -- src/Phalcon/cli/dispatcher/Exception.php | 9 -- src/Phalcon/cli/router/Exception.php | 9 -- src/Phalcon/cli/router/Route.php | 32 +++---- src/Phalcon/cli/router/RouteInterface.php | 10 +- src/Phalcon/collection/Exception.php | 11 +-- src/Phalcon/collection/ReadOnly.php | 11 +-- src/Phalcon/config/ConfigFactory.php | 23 ++--- src/Phalcon/config/Exception.php | 9 -- src/Phalcon/config/adapter/Grouped.php | 13 +-- src/Phalcon/config/adapter/Ini.php | 17 +--- src/Phalcon/config/adapter/Json.php | 18 +--- src/Phalcon/config/adapter/Php.php | 18 +--- src/Phalcon/config/adapter/Yaml.php | 19 ++-- src/Phalcon/crypt/CryptInterface.php | 10 +- src/Phalcon/crypt/Exception.php | 9 -- src/Phalcon/crypt/Mismatch.php | 11 +-- src/Phalcon/db/AbstractDb.php | 16 +--- src/Phalcon/db/Column.php | 19 ++-- src/Phalcon/db/ColumnInterface.php | 10 +- src/Phalcon/db/Dialect.php | 12 +-- src/Phalcon/db/DialectInterface.php | 14 +-- src/Phalcon/db/Enum.php | 11 +-- src/Phalcon/db/Exception.php | 9 -- src/Phalcon/db/Index.php | 16 +--- src/Phalcon/db/IndexInterface.php | 10 +- src/Phalcon/db/Profiler.php | 11 +-- src/Phalcon/db/RawValue.php | 14 +-- src/Phalcon/db/Reference.php | 16 +--- src/Phalcon/db/ReferenceInterface.php | 10 +- src/Phalcon/db/ResultInterface.php | 10 +- src/Phalcon/db/adapter/AbstractAdapter.php | 21 ++-- src/Phalcon/db/adapter/AdapterInterface.php | 18 ++-- src/Phalcon/db/adapter/PdoFactory.php | 12 ++- src/Phalcon/db/adapter/pdo/AbstractPdo.php | 23 ++--- src/Phalcon/db/adapter/pdo/Mysql.php | 26 ++--- src/Phalcon/db/adapter/pdo/Postgresql.php | 21 ++-- src/Phalcon/db/adapter/pdo/Sqlite.php | 22 ++--- src/Phalcon/db/dialect/Mysql.php | 16 ++-- src/Phalcon/db/dialect/Postgresql.php | 16 ++-- src/Phalcon/db/dialect/Sqlite.php | 16 ++-- src/Phalcon/db/profiler/Item.php | 10 +- src/Phalcon/db/result/Pdo.php | 15 +-- src/Phalcon/debug/Dump.php | 16 ++-- src/Phalcon/debug/Exception.php | 9 -- src/Phalcon/di/AbstractInjectionAware.php | 16 ++-- src/Phalcon/di/DiInterface.php | 15 +-- src/Phalcon/di/Exception.php | 9 -- src/Phalcon/di/FactoryDefault.php | 12 +-- src/Phalcon/di/Injectable.php | 45 +++------ src/Phalcon/di/InjectionAwareInterface.php | 12 +-- src/Phalcon/di/Service.php | 23 ++--- src/Phalcon/di/ServiceInterface.php | 14 +-- src/Phalcon/di/ServiceProviderInterface.php | 12 +-- .../exception/ServiceResolutionException.php | 8 ++ src/Phalcon/di/factorydefault/Cli.php | 12 +-- src/Phalcon/di/service/Builder.php | 19 ++-- src/Phalcon/dispatcher/AbstractDispatcher.php | 23 ++--- .../dispatcher/DispatcherInterface.php | 14 +-- src/Phalcon/dispatcher/Exception.php | 13 +-- src/Phalcon/domain/payload/Payload.php | 22 +---- src/Phalcon/domain/payload/PayloadFactory.php | 21 +--- .../domain/payload/PayloadInterface.php | 22 +---- .../domain/payload/ReadableInterface.php | 19 +--- src/Phalcon/domain/payload/Status.php | 18 +--- .../domain/payload/WriteableInterface.php | 21 +--- src/Phalcon/escaper/EscaperInterface.php | 10 +- src/Phalcon/escaper/Exception.php | 9 -- src/Phalcon/events/Event.php | 25 ++--- src/Phalcon/events/EventInterface.php | 10 +- src/Phalcon/events/EventsAwareInterface.php | 10 +- src/Phalcon/events/Exception.php | 9 -- src/Phalcon/events/Manager.php | 26 +++-- src/Phalcon/events/ManagerInterface.php | 19 ++-- src/Phalcon/factory/AbstractFactory.php | 9 +- src/Phalcon/factory/Exception.php | 5 +- src/Phalcon/filter/Exception.php | 9 -- src/Phalcon/filter/FilterFactory.php | 13 ++- src/Phalcon/filter/FilterInterface.php | 10 +- src/Phalcon/filter/sanitize/AbsInt.php | 12 +-- src/Phalcon/filter/sanitize/Alnum.php | 12 +-- src/Phalcon/filter/sanitize/Alpha.php | 12 +-- src/Phalcon/filter/sanitize/BoolVal.php | 12 +-- src/Phalcon/filter/sanitize/Email.php | 12 +-- src/Phalcon/filter/sanitize/FloatVal.php | 12 +-- src/Phalcon/filter/sanitize/IntVal.php | 12 +-- src/Phalcon/filter/sanitize/Lower.php | 12 +-- src/Phalcon/filter/sanitize/LowerFirst.php | 12 +-- src/Phalcon/filter/sanitize/Regex.php | 12 +-- src/Phalcon/filter/sanitize/Remove.php | 12 +-- src/Phalcon/filter/sanitize/Replace.php | 12 +-- src/Phalcon/filter/sanitize/Special.php | 12 +-- src/Phalcon/filter/sanitize/SpecialFull.php | 12 +-- src/Phalcon/filter/sanitize/StringVal.php | 12 +-- src/Phalcon/filter/sanitize/Striptags.php | 12 +-- src/Phalcon/filter/sanitize/Trim.php | 12 +-- src/Phalcon/filter/sanitize/Upper.php | 12 +-- src/Phalcon/filter/sanitize/UpperFirst.php | 12 +-- src/Phalcon/filter/sanitize/UpperWords.php | 12 +-- src/Phalcon/filter/sanitize/Url.php | 12 +-- src/Phalcon/firewall/Exception.php | 9 -- .../firewall/adapter/AbstractAdapter.php | 24 ++--- src/Phalcon/firewall/adapter/Acl.php | 23 ++--- .../firewall/adapter/AdapterInterface.php | 22 ++--- src/Phalcon/firewall/adapter/Annotations.php | 22 ++--- src/Phalcon/firewall/adapter/micro/Acl.php | 19 ++-- src/Phalcon/flash/AbstractFlash.php | 23 ++--- src/Phalcon/flash/Direct.php | 12 +-- src/Phalcon/flash/Exception.php | 9 -- src/Phalcon/flash/FlashInterface.php | 10 +- src/Phalcon/flash/Session.php | 17 ++-- src/Phalcon/forms/Exception.php | 9 -- src/Phalcon/forms/Form.php | 64 ++++++------- src/Phalcon/forms/Manager.php | 16 +--- src/Phalcon/forms/element/AbstractElement.php | 21 ++-- src/Phalcon/forms/element/Check.php | 13 +-- src/Phalcon/forms/element/Date.php | 13 +-- .../forms/element/ElementInterface.php | 15 +-- src/Phalcon/forms/element/Email.php | 13 +-- src/Phalcon/forms/element/File.php | 13 +-- src/Phalcon/forms/element/Hidden.php | 13 +-- src/Phalcon/forms/element/Numeric.php | 13 +-- src/Phalcon/forms/element/Password.php | 13 +-- src/Phalcon/forms/element/Radio.php | 13 +-- src/Phalcon/forms/element/Select.php | 24 ++--- src/Phalcon/forms/element/Submit.php | 13 +-- src/Phalcon/forms/element/Text.php | 13 +-- src/Phalcon/forms/element/TextArea.php | 13 +-- src/Phalcon/helper/Arr.php | 74 +++++---------- src/Phalcon/helper/Exception.php | 9 -- src/Phalcon/helper/Fs.php | 13 +-- src/Phalcon/helper/Number.php | 12 +-- src/Phalcon/helper/Str.php | 82 ++++++---------- src/Phalcon/html/Attributes.php | 13 +-- src/Phalcon/html/Breadcrumbs.php | 12 +-- src/Phalcon/html/Exception.php | 9 -- src/Phalcon/html/TagFactory.php | 19 +--- .../html/attributes/AttributesInterface.php | 17 +--- .../html/attributes/RenderInterface.php | 17 +--- src/Phalcon/html/helper/AbstractHelper.php | 17 +--- src/Phalcon/html/helper/Anchor.php | 18 ++-- src/Phalcon/html/helper/AnchorRaw.php | 18 ++-- src/Phalcon/html/helper/Body.php | 14 +-- src/Phalcon/html/helper/Button.php | 16 +--- src/Phalcon/html/helper/Close.php | 13 +-- src/Phalcon/html/helper/Element.php | 18 ++-- src/Phalcon/html/helper/ElementRaw.php | 19 +--- src/Phalcon/html/helper/Form.php | 14 +-- src/Phalcon/html/helper/Img.php | 17 +--- src/Phalcon/html/helper/Label.php | 15 +-- src/Phalcon/html/helper/TextArea.php | 16 +--- src/Phalcon/http/Cookie.php | 19 ++-- src/Phalcon/http/CookieInterface.php | 10 +- src/Phalcon/http/Request.php | 23 +++-- src/Phalcon/http/RequestInterface.php | 13 +-- src/Phalcon/http/Response.php | 28 +++--- src/Phalcon/http/ResponseInterface.php | 13 +-- src/Phalcon/http/cookie/Exception.php | 9 -- src/Phalcon/http/message/AbstractCommon.php | 26 ++--- src/Phalcon/http/message/AbstractMessage.php | 67 ++++--------- src/Phalcon/http/message/AbstractRequest.php | 28 ++---- src/Phalcon/http/message/Request.php | 24 ++--- src/Phalcon/http/message/RequestFactory.php | 24 ++--- src/Phalcon/http/message/Response.php | 26 ++--- src/Phalcon/http/message/ResponseFactory.php | 24 ++--- src/Phalcon/http/message/ServerRequest.php | 51 ++++------ .../http/message/ServerRequestFactory.php | 86 +++++++---------- src/Phalcon/http/message/Stream.php | 33 ++----- src/Phalcon/http/message/StreamFactory.php | 25 ++--- src/Phalcon/http/message/UploadedFile.php | 34 +++---- .../http/message/UploadedFileFactory.php | 27 ++---- src/Phalcon/http/message/Uri.php | 57 ++++------- src/Phalcon/http/message/UriFactory.php | 17 +--- .../exception/InvalidArgumentException.php | 12 +-- src/Phalcon/http/message/stream/Input.php | 16 +--- src/Phalcon/http/message/stream/Memory.php | 14 +-- src/Phalcon/http/message/stream/Temp.php | 14 +-- src/Phalcon/http/request/Exception.php | 9 -- src/Phalcon/http/request/File.php | 18 ++-- src/Phalcon/http/request/FileInterface.php | 11 +-- src/Phalcon/http/response/Cookies.php | 17 ++-- .../http/response/CookiesInterface.php | 10 +- src/Phalcon/http/response/Exception.php | 9 -- src/Phalcon/http/response/Headers.php | 14 +-- .../http/response/HeadersInterface.php | 10 +- .../http/server/AbstractMiddleware.php | 12 +-- .../http/server/AbstractRequestHandler.php | 12 +-- src/Phalcon/image/Enum.php | 7 +- src/Phalcon/image/Exception.php | 5 +- src/Phalcon/image/ImageFactory.php | 12 +-- src/Phalcon/image/adapter/AbstractAdapter.php | 19 ++-- .../image/adapter/AdapterInterface.php | 10 +- src/Phalcon/image/adapter/Gd.php | 12 ++- src/Phalcon/image/adapter/Imagick.php | 29 +++--- src/Phalcon/loader/Exception.php | 9 -- src/Phalcon/logger/AdapterFactory.php | 13 +-- src/Phalcon/logger/Exception.php | 9 -- src/Phalcon/logger/Item.php | 11 +-- src/Phalcon/logger/LoggerFactory.php | 20 ++-- .../logger/adapter/AbstractAdapter.php | 18 ++-- .../logger/adapter/AdapterInterface.php | 11 +-- src/Phalcon/logger/adapter/Noop.php | 18 ++-- src/Phalcon/logger/adapter/Stream.php | 22 ++--- src/Phalcon/logger/adapter/Syslog.php | 22 ++--- .../logger/formatter/AbstractFormatter.php | 10 +- .../logger/formatter/FormatterInterface.php | 12 +-- src/Phalcon/logger/formatter/Json.php | 13 +-- src/Phalcon/logger/formatter/Line.php | 13 +-- src/Phalcon/logger/formatter/Syslog.php | 13 +-- src/Phalcon/messages/Exception.php | 11 +-- src/Phalcon/messages/Message.php | 13 +-- src/Phalcon/messages/MessageInterface.php | 12 +-- src/Phalcon/messages/Messages.php | 21 ++-- src/Phalcon/mvc/Application.php | 38 ++++---- src/Phalcon/mvc/Controller.php | 16 +--- src/Phalcon/mvc/ControllerInterface.php | 9 -- src/Phalcon/mvc/Dispatcher.php | 25 +++-- src/Phalcon/mvc/DispatcherInterface.php | 15 +-- src/Phalcon/mvc/EntityInterface.php | 10 +- src/Phalcon/mvc/Micro.php | 70 +++++++++----- src/Phalcon/mvc/Model.php | 95 +++++++++++-------- src/Phalcon/mvc/ModelInterface.php | 24 ++--- src/Phalcon/mvc/ModuleDefinitionInterface.php | 12 +-- src/Phalcon/mvc/Router.php | 17 ++-- src/Phalcon/mvc/RouterInterface.php | 12 +-- src/Phalcon/mvc/View.php | 44 ++++++--- src/Phalcon/mvc/ViewBaseInterface.php | 12 +-- src/Phalcon/mvc/ViewInterface.php | 12 +-- src/Phalcon/mvc/application/Exception.php | 9 -- .../mvc/controller/BindModelInterface.php | 10 +- src/Phalcon/mvc/dispatcher/Exception.php | 9 -- src/Phalcon/mvc/micro/Collection.php | 36 +++---- src/Phalcon/mvc/micro/CollectionInterface.php | 10 +- src/Phalcon/mvc/micro/Exception.php | 9 -- src/Phalcon/mvc/micro/LazyLoader.php | 16 +--- src/Phalcon/mvc/micro/MiddlewareInterface.php | 12 +-- src/Phalcon/mvc/model/Behavior.php | 17 ++-- src/Phalcon/mvc/model/BehaviorInterface.php | 12 +-- src/Phalcon/mvc/model/Binder.php | 17 ++-- src/Phalcon/mvc/model/BinderInterface.php | 10 +- src/Phalcon/mvc/model/Criteria.php | 19 ++-- src/Phalcon/mvc/model/CriteriaInterface.php | 20 ++-- src/Phalcon/mvc/model/Exception.php | 11 +-- src/Phalcon/mvc/model/Manager.php | 43 +++++---- src/Phalcon/mvc/model/ManagerInterface.php | 65 ++++++------- src/Phalcon/mvc/model/MetaData.php | 25 ++--- src/Phalcon/mvc/model/MetaDataInterface.php | 19 ++-- src/Phalcon/mvc/model/Query.php | 50 ++++++---- src/Phalcon/mvc/model/QueryInterface.php | 12 +-- src/Phalcon/mvc/model/Relation.php | 20 ++-- src/Phalcon/mvc/model/RelationInterface.php | 12 +-- src/Phalcon/mvc/model/ResultInterface.php | 12 +-- src/Phalcon/mvc/model/Resultset.php | 21 ++-- src/Phalcon/mvc/model/ResultsetInterface.php | 14 +-- src/Phalcon/mvc/model/Row.php | 25 ++--- src/Phalcon/mvc/model/Transaction.php | 18 ++-- .../mvc/model/TransactionInterface.php | 13 +-- src/Phalcon/mvc/model/ValidationFailed.php | 16 +--- src/Phalcon/mvc/model/behavior/SoftDelete.php | 12 +-- .../mvc/model/behavior/Timestampable.php | 13 +-- .../mvc/model/binder/BindableInterface.php | 10 +- src/Phalcon/mvc/model/metadata/Apcu.php | 18 ++-- .../mvc/model/metadata/Libmemcached.php | 15 +-- src/Phalcon/mvc/model/metadata/Memory.php | 12 +-- src/Phalcon/mvc/model/metadata/Redis.php | 17 +--- src/Phalcon/mvc/model/metadata/Stream.php | 15 +-- .../model/metadata/strategy/Annotations.php | 17 ++-- .../model/metadata/strategy/Introspection.php | 20 ++-- .../{ => strategy}/StrategyInterface.php | 9 +- src/Phalcon/mvc/model/query/Builder.php | 21 ++-- .../mvc/model/query/BuilderInterface.php | 17 +--- src/Phalcon/mvc/model/query/Lang.php | 20 ++-- src/Phalcon/mvc/model/query/Status.php | 18 ++-- .../mvc/model/query/StatusInterface.php | 11 +-- src/Phalcon/mvc/model/resultset/Complex.php | 24 ++--- src/Phalcon/mvc/model/resultset/Simple.php | 19 ++-- .../mvc/model/transaction/Exception.php | 9 -- src/Phalcon/mvc/model/transaction/Failed.php | 12 +-- src/Phalcon/mvc/model/transaction/Manager.php | 18 ++-- .../model/transaction/ManagerInterface.php | 10 +- src/Phalcon/mvc/router/Annotations.php | 13 +-- src/Phalcon/mvc/router/Exception.php | 9 -- src/Phalcon/mvc/router/Group.php | 36 +++---- src/Phalcon/mvc/router/GroupInterface.php | 16 +--- src/Phalcon/mvc/router/Route.php | 16 +--- src/Phalcon/mvc/router/RouteInterface.php | 10 +- src/Phalcon/mvc/view/Exception.php | 9 -- src/Phalcon/mvc/view/Simple.php | 48 +++++++--- .../mvc/view/engine/AbstractEngine.php | 18 +--- .../mvc/view/engine/EngineInterface.php | 13 +-- src/Phalcon/mvc/view/engine/Php.php | 12 +-- src/Phalcon/mvc/view/engine/Volt.php | 38 ++++++-- src/Phalcon/mvc/view/engine/volt/Compiler.php | 29 +++--- .../mvc/view/engine/volt/Exception.php | 14 +-- src/Phalcon/paginator/Exception.php | 9 -- src/Phalcon/paginator/PaginatorFactory.php | 21 ++-- src/Phalcon/paginator/Repository.php | 24 +++-- src/Phalcon/paginator/RepositoryInterface.php | 10 +- .../paginator/adapter/AbstractAdapter.php | 27 +++--- .../paginator/adapter/AdapterInterface.php | 10 +- src/Phalcon/paginator/adapter/Model.php | 14 +-- src/Phalcon/paginator/adapter/NativeArray.php | 14 +-- .../paginator/adapter/QueryBuilder.php | 15 +-- src/Phalcon/security/Exception.php | 9 -- src/Phalcon/security/Random.php | 14 +-- src/Phalcon/session/Bag.php | 12 +-- src/Phalcon/session/Exception.php | 9 -- src/Phalcon/session/Manager.php | 26 ++--- src/Phalcon/session/ManagerInterface.php | 11 +-- .../session/adapter/AbstractAdapter.php | 16 ++-- src/Phalcon/session/adapter/Libmemcached.php | 13 +-- src/Phalcon/session/adapter/Noop.php | 12 +-- src/Phalcon/session/adapter/Redis.php | 13 +-- src/Phalcon/session/adapter/Stream.php | 17 ++-- src/Phalcon/storage/AdapterFactory.php | 20 ++-- src/Phalcon/storage/Exception.php | 10 -- src/Phalcon/storage/SerializerFactory.php | 18 ++-- .../storage/adapter/AbstractAdapter.php | 28 +++--- .../storage/adapter/AdapterInterface.php | 12 +-- src/Phalcon/storage/adapter/Apcu.php | 39 ++++---- src/Phalcon/storage/adapter/Libmemcached.php | 47 ++++----- src/Phalcon/storage/adapter/Memory.php | 35 +++---- src/Phalcon/storage/adapter/Redis.php | 48 ++++------ src/Phalcon/storage/adapter/Stream.php | 67 +++++++------ .../storage/serializer/AbstractSerializer.php | 11 ++- src/Phalcon/storage/serializer/Base64.php | 9 +- src/Phalcon/storage/serializer/Igbinary.php | 8 +- src/Phalcon/storage/serializer/Json.php | 9 +- src/Phalcon/storage/serializer/Msgpack.php | 8 +- src/Phalcon/storage/serializer/None.php | 9 +- src/Phalcon/storage/serializer/Php.php | 10 +- .../serializer/SerializerInterface.php | 12 +-- src/Phalcon/tag/Exception.php | 9 -- src/Phalcon/tag/Select.php | 17 ++-- src/Phalcon/translate/Exception.php | 9 -- src/Phalcon/translate/InterpolatorFactory.php | 12 +-- src/Phalcon/translate/TranslateFactory.php | 18 ++-- .../translate/adapter/AbstractAdapter.php | 29 +++--- .../translate/adapter/AdapterInterface.php | 18 +--- src/Phalcon/translate/adapter/Csv.php | 19 ++-- src/Phalcon/translate/adapter/Gettext.php | 23 ++--- src/Phalcon/translate/adapter/NativeArray.php | 19 ++-- .../interpolator/AssociativeArray.php | 10 +- .../translate/interpolator/IndexedArray.php | 10 +- .../interpolator/InterpolatorInterface.php | 10 +- src/Phalcon/url/Exception.php | 9 -- src/Phalcon/url/UrlInterface.php | 10 +- .../AbstractCombinedFieldsValidator.php | 11 +-- src/Phalcon/validation/AbstractValidator.php | 24 ++--- .../validation/AbstractValidatorComposite.php | 14 +-- src/Phalcon/validation/Exception.php | 11 +-- .../validation/ValidationInterface.php | 16 ++-- .../ValidatorCompositeInterface.php | 12 +-- src/Phalcon/validation/ValidatorFactory.php | 11 ++- src/Phalcon/validation/ValidatorInterface.php | 25 ++--- src/Phalcon/validation/validator/Alnum.php | 11 +-- src/Phalcon/validation/validator/Alpha.php | 12 +-- src/Phalcon/validation/validator/Between.php | 12 +-- src/Phalcon/validation/validator/Callback.php | 13 +-- .../validation/validator/Confirmation.php | 13 +-- .../validation/validator/CreditCard.php | 12 +-- src/Phalcon/validation/validator/Date.php | 13 +-- src/Phalcon/validation/validator/Digit.php | 12 +-- src/Phalcon/validation/validator/Email.php | 12 +-- .../validation/validator/Exception.php | 11 +-- .../validation/validator/ExclusionIn.php | 13 +-- src/Phalcon/validation/validator/File.php | 20 ++-- .../validation/validator/Identical.php | 12 +-- .../validation/validator/InclusionIn.php | 13 +-- src/Phalcon/validation/validator/Ip.php | 12 +-- .../validation/validator/Numericality.php | 12 +-- .../validation/validator/PresenceOf.php | 12 +-- src/Phalcon/validation/validator/Regex.php | 12 +-- .../validation/validator/StringLength.php | 15 ++- .../validation/validator/Uniqueness.php | 18 ++-- src/Phalcon/validation/validator/Url.php | 12 +-- .../validator/file/AbstractFile.php | 32 +++---- .../validation/validator/file/MimeType.php | 17 ++-- .../validator/file/resolution/Equal.php | 12 +-- .../validator/file/resolution/Max.php | 12 +-- .../validator/file/resolution/Min.php | 12 +-- .../validation/validator/file/size/Equal.php | 12 +-- .../validation/validator/file/size/Max.php | 12 +-- .../validation/validator/file/size/Min.php | 12 +-- .../validation/validator/stringlength/Max.php | 13 +-- .../validation/validator/stringlength/Min.php | 13 +-- 462 files changed, 2644 insertions(+), 5306 deletions(-) rename src/Phalcon/mvc/model/metadata/{ => strategy}/StrategyInterface.php (90%) diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index fa7f9bf2..89a44168 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -1,24 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Exception\Exception; +use Phalcon\Cache\Exception\InvalidArgumentException; use Psr\SimpleCache\CacheInterface; +use Traversable; /** * This component offers caching capabilities for your application. * Phalcon\Cache implements PSR-16. */ -class Cache implements CacheInterface +class Cache implements \Psr\SimpleCache\CacheInterface { /** * The adapter @@ -49,7 +43,7 @@ public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $adapter) /** * Wipes clean the entire cache's keys. * - * @return bool + * @return bool True on success and false on failure. */ public function clear(): bool { @@ -62,9 +56,7 @@ public function clear(): bool * * @return bool True if the item was successfully removed. False if there was an error. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. - * @param mixed $key - * @return bool + * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. */ public function delete($key): bool { @@ -77,9 +69,7 @@ public function delete($key): bool * * @return bool True if the items were successfully removed. False if there was an error. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. - * @param mixed $keys - * @return bool + * @throws InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. */ public function deleteMultiple($keys): bool { @@ -88,14 +78,12 @@ public function deleteMultiple($keys): bool /** * Fetches a value from the cache. * - * @param mixed $default Default value to return if the key does not exist. + * @param string $key The unique key of this item in the cache. + * @param mixed $defaultValue Default value to return if the key does not exist. * * @return mixed The value of the item from the cache, or $default in case of cache miss. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. - * @param string $key The unique key of this item in the cache. - * @param mixed $defaultValue - * @return mixed + * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. */ public function get($key, $defaultValue = null) { @@ -104,14 +92,12 @@ public function get($key, $defaultValue = null) /** * Obtains multiple cache items by their unique keys. * - * @param mixed $default Default value to return for keys that do not exist. + * @param iterable $keys A list of keys that can obtained in a single operation. + * @param mixed $defaultValue Default value to return for keys that do not exist. * * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. - * @param iterable $keys A list of keys that can obtained in a single operation. - * @param mixed $defaultValue - * @return mixed + * @throws InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value. */ public function getMultiple($keys, $defaultValue = null) { @@ -124,9 +110,7 @@ public function getMultiple($keys, $defaultValue = null) * * @return bool * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. - * @param mixed $key - * @return bool + * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. */ public function has($key): bool { @@ -135,17 +119,15 @@ public function has($key): bool /** * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. * + * @param string $key The key of the item to store. + * @param mixed $value The value of the item to store. Must be serializable. * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * * @return bool True on success and false on failure. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if the $key string is not a legal value. - * @param string $key The key of the item to store. - * @param mixed $value The value of the item to store. Must be serializable. - * @param mixed $ttl - * @return bool + * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. */ public function set($key, $value, $ttl = null): bool { @@ -154,16 +136,14 @@ public function set($key, $value, $ttl = null): bool /** * Persists a set of key => value pairs in the cache, with an optional TTL. * + * @param iterable $values A list of key => value pairs for a multiple-set operation. * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * * @return bool True on success and false on failure. * - * @throws Phalcon\Cache\Exception\InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value. - * @param iterable $values A list of key => value pairs for a multiple-set operation. - * @param mixed $ttl - * @return bool + * @throws InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value. */ public function setMultiple($values, $ttl = null): bool { @@ -186,4 +166,5 @@ protected function checkKey($key) protected function checkKeys($keys) { } + } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index d19d68b1..95dbe615 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; use ArrayAccess; +use ArrayIterator; use Countable; use IteratorAggregate; use JsonSerializable; @@ -19,18 +11,18 @@ use Traversable; /** - * `Phalcon\Collection` is a supercharged object oriented array. It implements [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php), [Countable](https://www.php.net/manual/en/class.countable.php), [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate.php), [JsonSerializable](https://www.php.net/manual/en/class.jsonserializable.php), [Serializable](https://www.php.net/manual/en/class.serializable.php) + * `Phalcon\Collection` is a supercharged object oriented array. It implements: + * - [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php) + * - [Countable](https://www.php.net/manual/en/class.countable.php) + * - [IteratorAggregate](https://www.php.net/manual/en/class.iteratoraggregate.php) + * - [JsonSerializable](https://www.php.net/manual/en/class.jsonserializable.php) + * - [Serializable](https://www.php.net/manual/en/class.serializable.php) * * It can be used in any part of the application that needs collection of data * Such implementations are for instance accessing globals `$_GET`, `$_POST` * etc. */ -class Collection implements - ArrayAccess, - Countable, - IteratorAggregate, - JsonSerializable, - Serializable +class Collection implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSerializable, \Serializable { /** * @var array @@ -119,9 +111,10 @@ public function count(): int * * @param string $element * @param mixed $defaultValue + * @param string $cast * @return mixed */ - public function get(string $element, $defaultValue = null) + public function get(string $element, $defaultValue = null, string $cast = null) { } @@ -279,4 +272,5 @@ public function unserialize($serialized) protected function setData(string $element, $value) { } + } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index db171fb1..cf636df8 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -1,23 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Collection; +use Phalcon\Config\Exception; + /** * `Phalcon\Config` is designed to simplify the access to, and the use of, * configuration data within applications. It provides a nested object property * based user interface for accessing this configuration data within application * code. * - *```php + * ```php * $config = new \Phalcon\Config( * [ * "database" => [ @@ -34,7 +28,7 @@ * ], * ] * ); - *``` + * ``` */ class Config extends Collection { @@ -138,4 +132,5 @@ final protected function internalMerge(array $source, array $target): array protected function setData($element, $value) { } + } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 601c174e..41138431 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -1,26 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; -use Phalcon\Di\DiInterface; use Psr\Container\ContainerInterface; +use Phalcon\Di\DiInterface; /** * PSR-11 Wrapper for `Phalcon\Di` */ -class Container implements ContainerInterface +class Container implements \Psr\Container\ContainerInterface { /** - * @var + * @var DiInterface */ protected $container; @@ -53,4 +44,5 @@ public function get($name) public function has($name): bool { } + } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 1a814c37..6d5be468 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; use Phalcon\Crypt\CryptInterface; +use Phalcon\Crypt\Exception; +use Phalcon\Crypt\Mismatch; /** * Provides encryption capabilities to Phalcon applications. @@ -31,7 +24,7 @@ * echo $crypt->decrypt($encrypted, $key); * ``` */ -class Crypt implements CryptInterface +class Crypt implements \Phalcon\Crypt\CryptInterface { const PADDING_ANSI_X_923 = 1; @@ -405,4 +398,5 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } + } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index d2ec1830..0f7cd8bc 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -1,16 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use ErrorException; +use Phalcon\Helper\Arr; +use Phalcon\Version; +use Phalcon\Tag; +use ReflectionClass; +use ReflectionFunction; + /** * Provides debug capabilities to Phalcon applications */ @@ -32,7 +30,7 @@ class Debug /** * @var bool */ - protected static $isActive; + static protected $isActive; /** * @var bool @@ -253,4 +251,5 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } + } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 38ff5f68..183ae2e9 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -1,20 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Config; +use Phalcon\Di\Service; use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception; use Phalcon\Di\Exception\ServiceResolutionException; +use Phalcon\Config\Adapter\Php; +use Phalcon\Config\Adapter\Yaml; use Phalcon\Di\ServiceInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Di\ServiceProviderInterface; /** * Phalcon\Di is a component that implements Dependency Injection/Service @@ -34,7 +32,7 @@ * Additionally, this pattern increases testability in the code, thus making it * less prone to errors. * - *```php + * ```php * use Phalcon\Di; * use Phalcon\Http\Request; * @@ -52,9 +50,9 @@ * ); * * $request = $di->getRequest(); - *``` + * ``` */ -class Di implements DiInterface +class Di implements \Phalcon\Di\DiInterface { /** * List of registered services @@ -76,7 +74,7 @@ class Di implements DiInterface /** * Latest DI build */ - protected static $_default; + static protected $_default; /** @@ -419,4 +417,5 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition public function setShared(string $name, $definition): ServiceInterface { } + } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index fc30325e..fb0c104d 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Escaper\EscaperInterface; +use Phalcon\Escaper\Exception; /** * Phalcon\Escaper @@ -22,15 +15,15 @@ * This component only works with UTF-8. The PREG extension needs to be compiled * with UTF-8 support. * - *```php + * ```php * $escaper = new \Phalcon\Escaper(); * * $escaped = $escaper->escapeCss("font-family: "); * * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E - *``` + * ``` */ -class Escaper implements EscaperInterface +class Escaper implements \Phalcon\Escaper\EscaperInterface { /** * @var bool @@ -170,4 +163,5 @@ public function setEncoding(string $encoding) public function setHtmlQuoteType(int $quoteType) { } + } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 3e4fb7de..dd44dc5c 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; -use Throwable; - /** * Phalcon\Exception * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception implements Throwable +class Exception extends \Exception implements \Throwable { /** @@ -28,4 +17,5 @@ class Exception extends \Exception implements Throwable public static function containerServiceNotFound(string $service): string { } + } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index 68914484..55c95efb 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -1,22 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Closure; +use Phalcon\Filter\Exception; use Phalcon\Filter\FilterInterface; /** * Lazy loads, stores and exposes sanitizer objects */ -class Filter implements FilterInterface +class Filter implements \Phalcon\Filter\FilterInterface { const FILTER_ABSINT = 'absint'; @@ -177,4 +170,5 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } + } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index 7f859101..97664875 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; /** @@ -21,10 +12,11 @@ class Kernel * Produces a pre-computed hash key based on a string. This function * produces different numbers in 32bit/64bit processors * - * @param string $key * @return string + * @param string $key */ public static function preComputeHashKey(string $key) { } + } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 20e79b0b..fea947bc 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; -use Phalcon\Events\EventsAwareInterface; +use Phalcon\Loader\Exception; use Phalcon\Events\ManagerInterface; +use Phalcon\Events\EventsAwareInterface; /** * This component helps to load your project classes automatically based on some * conventions * - *```php + * ```php * use Phalcon\Loader; * * // Creates the autoloader @@ -38,9 +30,9 @@ * * // Requiring this class will automatically include file vendor/example/adapter/Some.php * $adapter = new \Example\Adapter\Some(); - *``` + * ``` */ -class Loader implements EventsAwareInterface +class Loader implements \Phalcon\Events\EventsAwareInterface { protected $checkedPath = null; @@ -289,4 +281,5 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } + } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 1bc59d09..231cfbd2 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -1,20 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Psr\Log\LoggerInterface; +use Psr\Log\InvalidArgumentException; use Phalcon\Logger\Adapter\AdapterInterface; +use Phalcon\Logger\Item; use Phalcon\Logger\Exception; -use Psr\Log\InvalidArgumentException; -use Psr\Log\LoggerInterface; /** * Phalcon\Logger @@ -23,7 +15,7 @@ * component accepts multiple adapters, working also as a multiple logger. * Phalcon\Logger implements PSR-3. * - *```php + * ```php * use Phalcon\Logger; * use Phalcon\Logger\Adapter\Stream; * @@ -47,9 +39,9 @@ * $logger * ->excludeAdapters(['manager']) * ->info('This does not go to the "manager" logger); - *``` + * ``` */ -class Logger implements LoggerInterface +class Logger implements \Psr\Log\LoggerInterface { const ALERT = 2; @@ -85,6 +77,13 @@ class Logger implements LoggerInterface */ protected $adapters = array(); + /** + * Minimum log level for the logger + * + * @var int + */ + protected $logLevel = 8; + /** * @var string */ @@ -98,6 +97,15 @@ class Logger implements LoggerInterface protected $excluded = array(); + /** + * Minimum log level for the logger + * + * @return int + */ + public function getLogLevel(): int + { + } + /** * Constructor. * @@ -112,7 +120,7 @@ public function __construct(string $name, array $adapters = array()) * Add an adapter to the stack. For processing we use FIFO * * @param string $name The name of the adapter - * @param $adapter The adapter to add to the stack + * @param AdapterInterface $adapter The adapter to add to the stack * @return Logger */ public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger @@ -188,10 +196,9 @@ public function excludeAdapters(array $adapters = array()): Logger /** * Returns an adapter from the stack * - * @param string name The name of the adapter + * @param string $name The name of the adapter * - * @throws - * @param string $name + * @throws Exception * @return \Phalcon\Logger\Adapter\AdapterInterface */ public function getAdapter(string $name): AdapterInterface @@ -201,7 +208,7 @@ public function getAdapter(string $name): AdapterInterface /** * Returns the adapter stack array * - * @return array + * @return AdapterInterface[] */ public function getAdapters(): array { @@ -252,10 +259,9 @@ public function notice($message, array $context = array()) /** * Removes an adapter from the stack * - * @param string name The name of the adapter + * @param string $name The name of the adapter * - * @throws - * @param string $name + * @throws Logger\Exception * @return Logger */ public function removeAdapter(string $name): Logger @@ -272,6 +278,16 @@ public function setAdapters(array $adapters): Logger { } + /** + * Sets the adapters stack overriding what is already there + * + * @param int $level + * @return Logger + */ + public function setLogLevel(int $level): Logger + { + } + /** * Exceptional occurrences that are not errors. * @@ -288,11 +304,9 @@ public function warning($message, array $context = array()) /** * Adds a message to each handler for processing * - * @param string message - * - * @throws * @param int $level - * @param string $message + * @param string $message * + * @throws Logger\Exception * @param array $context * @return bool */ @@ -318,4 +332,5 @@ protected function getLevels(): array private function getLevelNumber($level): int { } + } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 207cc786..6733a322 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Collection; use Traversable; /** @@ -20,7 +12,7 @@ * space. By storing the value in a registry, the same object is always * available throughout your application. * - *```php + * ```php * $registry = new \Phalcon\Registry(); * * // Set value @@ -42,7 +34,7 @@ * unset($registry->something); * // or * unset($registry["something"]); - *``` + * ``` * * In addition to ArrayAccess, Phalcon\Registry also implements Countable * (count($registry) will return the number of elements in the registry), @@ -136,9 +128,10 @@ final public function count(): int * * @param string $element * @param mixed $defaultValue + * @param string $cast * @return mixed */ - final public function get(string $element, $defaultValue = null) + final public function get(string $element, $defaultValue = null, string $cast = null) { } @@ -285,4 +278,5 @@ final public function toJson(int $options = 79): string final public function unserialize($serialized) { } + } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 23ffbbe0..cc2a9879 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -1,26 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; use Phalcon\Security\Random; -use Phalcon\Session\ManagerInterface as SessionInterface; +use Phalcon\Security\Exception; +use Phalcon\Session\ManagerInterface; /** * This component provides a set of functions to improve the security in Phalcon * applications * - *```php + * ```php * $login = $this->request->getPost("login"); * $password = $this->request->getPost("password"); * @@ -31,7 +24,7 @@ * // The password is valid * } * } - *``` + * ``` */ class Security extends AbstractInjectionAware { @@ -301,4 +294,5 @@ private function getLocalRequest(): ?RequestInterface private function getLocalSession(): ?SessionInterface { } + } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index aa5eb743..42b46d2f 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -1,18 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; use Phalcon\Di\DiInterface; use Phalcon\Escaper\EscaperInterface; +use Phalcon\Tag\Select; +use Phalcon\Tag\Exception; use Phalcon\Url\UrlInterface; /** @@ -56,40 +49,40 @@ class Tag const XHTML5 = 11; - protected static $autoEscape = true; + static protected $autoEscape = true; /** * DI Container */ - protected static $container; + static protected $container; /** * Pre-assigned values for components */ - protected static $displayValues; + static protected $displayValues; - protected static $documentAppendTitle = null; + static protected $documentAppendTitle = null; - protected static $documentPrependTitle = null; + static protected $documentPrependTitle = null; /** * HTML document title */ - protected static $documentTitle = null; + static protected $documentTitle = null; - protected static $documentTitleSeparator = null; + static protected $documentTitleSeparator = null; - protected static $documentType = 11; + static protected $documentType = 11; - protected static $escaperService = null; + static protected $escaperService = null; - protected static $urlService = null; + static protected $urlService = null; /** @@ -658,7 +651,7 @@ public static function weekField($parameters): string * @param bool $asValue * @return string */ - final protected static function inputField(string $type, $parameters, bool $asValue = false): string + static final protected function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -669,7 +662,8 @@ final protected static function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - final protected static function inputFieldChecked(string $type, $parameters): string + static final protected function inputFieldChecked(string $type, $parameters): string { } + } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 16c64802..a99b4fbe 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Helper\Str; + /** * Provides utilities to work with texts */ @@ -72,7 +65,8 @@ public static function camelize(string $text, $delimiter = null): string * @param string $separator * @param string $a * @param string $b - * @param string $...N + * @param string ...N + * @param string ...N * @return string */ public static function concat(): string @@ -277,4 +271,5 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index 991a364f..4b18ceaa 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -1,24 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Mvc\RouterInterface; +use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Url\Exception; use Phalcon\Url\UrlInterface; /** * This components helps in the generation of: URIs, URLs and Paths * - *```php + * ```php * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * @@ -30,9 +24,9 @@ * "year" => "2012", * ] * ); - *``` + * ``` */ -class Url extends AbstractInjectionAware implements UrlInterface +class Url extends AbstractInjectionAware implements \Phalcon\Url\UrlInterface { /** * @var null | string @@ -45,7 +39,7 @@ class Url extends AbstractInjectionAware implements UrlInterface protected $basePath = null; /** - * @var | null + * @var RouterInterface | null */ protected $router = null; @@ -207,4 +201,5 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } + } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index f04fa34f..3fdef9e4 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -1,24 +1,22 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; +use Phalcon\Di; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Filter\FilterInterface; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; use Phalcon\Validation\ValidationInterface; +use Phalcon\Validation\Exception; +use Phalcon\Validation\ValidatorInterface; +use Phalcon\Validation\AbstractCombinedFieldsValidator; /** * Allows to validate data using custom or built-in validators */ -class Validation extends Injectable implements ValidationInterface +class Validation extends Injectable implements \Phalcon\Validation\ValidationInterface { protected $combinedFieldsValidators; @@ -228,4 +226,5 @@ public function validate($data = null, $entity = null): Messages protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool { } + } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 1f2730eb..c8630cb2 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon; /** @@ -94,7 +85,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - final protected static function _getSpecial(int $special): string + protected final static function _getSpecial(int $special): string { } @@ -140,4 +131,5 @@ public static function getId(): string public static function getPart(int $part): string { } + } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 2f569a59..3bc345a9 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; +use Phalcon\Acl\Exception; + /** * This class defines component entity and its description */ -class Component implements ComponentInterface +class Component implements \Phalcon\Acl\ComponentInterface { /** * Component description @@ -67,4 +60,5 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/acl/ComponentAware.php b/src/Phalcon/acl/ComponentAware.php index 165249db..3539eb59 100644 --- a/src/Phalcon/acl/ComponentAware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** @@ -23,4 +14,5 @@ interface ComponentAware * @return string */ public function getComponentName(): string; + } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php index d158aa4a..b1e0960c 100644 --- a/src/Phalcon/acl/ComponentInterface.php +++ b/src/Phalcon/acl/ComponentInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** @@ -37,4 +28,5 @@ public function getName(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/acl/Enum.php b/src/Phalcon/acl/Enum.php index 9dcff0ce..bce07c38 100644 --- a/src/Phalcon/acl/Enum.php +++ b/src/Phalcon/acl/Enum.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** @@ -21,4 +12,6 @@ class Enum const DENY = 0; + + } diff --git a/src/Phalcon/acl/Exception.php b/src/Phalcon/acl/Exception.php index 38139709..f65dd278 100644 --- a/src/Phalcon/acl/Exception.php +++ b/src/Phalcon/acl/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/acl/Role.php index 589f2ba0..fe8ea30f 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/acl/Role.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; +use Phalcon\Acl\Exception; + /** * This class defines role entity and its description */ -class Role implements RoleInterface +class Role implements \Phalcon\Acl\RoleInterface { /** * Role name @@ -67,4 +60,5 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/acl/RoleAware.php b/src/Phalcon/acl/RoleAware.php index f3bad4c8..8a22a4b6 100644 --- a/src/Phalcon/acl/RoleAware.php +++ b/src/Phalcon/acl/RoleAware.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** @@ -23,4 +14,5 @@ interface RoleAware * @return string */ public function getRoleName(): string; + } diff --git a/src/Phalcon/acl/RoleInterface.php b/src/Phalcon/acl/RoleInterface.php index aef5881a..7ba84c4a 100644 --- a/src/Phalcon/acl/RoleInterface.php +++ b/src/Phalcon/acl/RoleInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl; /** @@ -37,4 +28,5 @@ public function getDescription(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/adapter/AbstractAdapter.php index 3be00202..e6cc811b 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/adapter/AbstractAdapter.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl\Adapter; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Events\EventsAwareInterface; /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Active access which the list is checking if some role can access it @@ -127,4 +118,5 @@ public function setDefaultAction(int $defaultAccess) public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/acl/adapter/AdapterInterface.php index 627c96d6..ee6cc3b9 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/acl/adapter/AdapterInterface.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl\Adapter; +use Phalcon\Acl\ComponentInterface; +use Phalcon\Acl\RoleInterface; + /** * Interface for Phalcon\Acl adapters */ @@ -126,14 +120,14 @@ public function getNoArgumentsDefaultAction(): int; /** * Return an array with every role registered in the list * - * @return array|RoleInterface[] + * @return array|\Phalcon\Acl\RoleInterface[] */ public function getRoles(): array; /** * Return an array with every component registered in the list * - * @return array|ComponentInterface[] + * @return array|\Phalcon\Acl\ComponentInterface[] */ public function getComponents(): array; @@ -179,4 +173,5 @@ public function setDefaultAction(int $defaultAccess); * @param int $defaultAccess */ public function setNoArgumentsDefaultAction(int $defaultAccess); + } diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/acl/adapter/Memory.php index 5c13d4d9..ee154893 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/acl/adapter/Memory.php @@ -1,22 +1,23 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Acl\Adapter; +use Phalcon\Acl\Adapter\AbstractAdapter; use Phalcon\Acl\Enum; +use Phalcon\Acl\Role; +use Phalcon\Acl\RoleInterface; +use Phalcon\Acl\Component; +use Phalcon\Acl\Exception; +use Phalcon\Events\Manager; +use Phalcon\Acl\RoleAware; +use Phalcon\Acl\ComponentAware; +use Phalcon\Acl\ComponentInterface; +use ReflectionFunction; /** * Manages ACL lists in memory * - *```php + * ```php * $acl = new \Phalcon\Acl\Adapter\Memory(); * * $acl->setDefaultAction( @@ -64,7 +65,7 @@ * // Grant access to public areas to both users and guests * foreach ($roles as $role) { * foreach ($publicComponents as $component => $actions) { - * $acl->allow($role->getName(), $component, "*"); + * $acl->allow($role->getName(), $component, ""); * } * } * @@ -74,7 +75,7 @@ * $acl->allow("Users", $component, $action); * } * } - *``` + * ``` */ class Memory extends AbstractAdapter { @@ -452,4 +453,5 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } + } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index 1cba64cd..a68bb788 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; +use Phalcon\Annotations\Exception; + /** * Represents a single annotation in an annotations collection */ @@ -130,4 +123,5 @@ public function hasArgument($position): bool public function numberArguments(): int { } + } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php index c7ffa06d..c4d8f337 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -1,18 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; use Phalcon\Annotations\Adapter\AbstractAdapter; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; /** * Factory to create annotations components @@ -58,4 +50,5 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } + } diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/annotations/Collection.php index 644b0662..9e081f91 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/annotations/Collection.php @@ -1,24 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; use Countable; use Iterator; +use Phalcon\Annotations\Annotation; +use Phalcon\Annotations\Exception; /** * Represents a collection of annotations. This class allows to traverse a group * of annotations easily * - *```php + * ```php * // Traverse annotations * foreach ($classAnnotations as $annotation) { * echo "Name=", $annotation->getName(), PHP_EOL; @@ -29,9 +22,9 @@ * * // Get an specific annotation in the collection * $annotation = $classAnnotations->get("Cacheable"); - *``` + * ``` */ -class Collection implements Iterator, Countable +class Collection implements \Iterator, \Countable { /** * @var array @@ -141,4 +134,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/annotations/Exception.php b/src/Phalcon/annotations/Exception.php index afb1fb02..8864d544 100644 --- a/src/Phalcon/annotations/Exception.php +++ b/src/Phalcon/annotations/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; /** diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index 7b10f361..c7595c4d 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -1,20 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; +use Phalcon\Annotations\ReaderInterface; +use ReflectionClass; + /** * Parses docblocks returning an array with the found annotations */ -class Reader implements ReaderInterface +class Reader implements \Phalcon\Annotations\ReaderInterface { /** @@ -38,4 +32,5 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } + } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index ec8824e5..5ba4b965 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; /** @@ -34,4 +25,5 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; + } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index e4fc316b..bad164f3 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations; +use Phalcon\Annotations\Collection; + /** * Allows to manipulate the annotations reflection in an OO manner * - *```php + * ```php * use Phalcon\Annotations\Reader; * use Phalcon\Annotations\Reflection; * @@ -27,7 +20,7 @@ * * // Get the annotations in the class docblock * $classAnnotations = $reflection->getClassAnnotations(); - *``` + * ``` */ class Reflection { @@ -91,4 +84,5 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } + } diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php index ac714d61..35d5a754 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -1,25 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Collection; +use Phalcon\Annotations\Adapter\AdapterInterface; use Phalcon\Annotations\Reader; -use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Exception; +use Phalcon\Annotations\Collection; use Phalcon\Annotations\Reflection; +use Phalcon\Annotations\ReaderInterface; /** * This is the base class for Phalcon\Annotations adapters */ -abstract class AbstractAdapter implements AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface { /** * @var array @@ -101,4 +94,5 @@ public function getReader(): ReaderInterface public function setReader(\Phalcon\Annotations\ReaderInterface $reader) { } + } diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/annotations/adapter/AdapterInterface.php index 41ccb129..cb354b80 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/annotations/adapter/AdapterInterface.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Reflection; use Phalcon\Annotations\Collection; use Phalcon\Annotations\ReaderInterface; -use Phalcon\Annotations\Reflection; /** * This interface must be implemented by adapters in Phalcon\Annotations @@ -76,4 +67,5 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); + } diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index e38ccb48..bd0aa686 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -1,24 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Adapter\AbstractAdapter; +use Phalcon\Annotations\Reflection; + /** * Stores the parsed annotations in APCu. This adapter is suitable for production * - *```php + * ```php * use Phalcon\Annotations\Adapter\Apcu; * * $annotations = new Apcu(); - *``` + * ``` */ class Apcu extends AbstractAdapter { @@ -62,4 +56,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data): bool { } + } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index f885747a..72578f7c 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Adapter\AbstractAdapter; +use Phalcon\Annotations\Reflection; + /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing @@ -42,4 +36,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Stream.php index 9d891971..af030a8f 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -1,20 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Adapter\AbstractAdapter; +use Phalcon\Annotations\Reflection; +use Phalcon\Annotations\Exception; + /** * Stores the parsed annotations in files. This adapter is suitable for production * - *```php + * ```php * use Phalcon\Annotations\Adapter\Stream; * * $annotations = new Stream( @@ -22,7 +17,7 @@ * "annotationsDir" => "app/cache/annotations/", * ] * ); - *``` + * ``` */ class Stream extends AbstractAdapter { @@ -60,4 +55,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index 90c5ea19..3fcc9085 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Application; +use Phalcon\Application\Exception; use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Events\EventsAwareInterface; @@ -19,7 +11,7 @@ /** * Base class for Phalcon\Cli\Console and Phalcon\Mvc\Application. */ -abstract class AbstractApplication extends Injectable implements EventsAwareInterface +abstract class AbstractApplication extends Injectable implements \Phalcon\Events\EventsAwareInterface { /** * @var DiInterface @@ -132,4 +124,5 @@ public function setDefaultModule(string $defaultModule): AbstractApplication public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/application/Exception.php b/src/Phalcon/application/Exception.php index a05cd19a..9e2d5a57 100644 --- a/src/Phalcon/application/Exception.php +++ b/src/Phalcon/application/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Application; /** diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index e35ec0f3..19892055 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -1,24 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; /** * Represents an asset asset * - *```php + * ```php * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); - *``` + * ``` */ -class Asset implements AssetInterface +class Asset implements \Phalcon\Assets\AssetInterface { /** * @var array | null @@ -306,4 +297,5 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } + } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php index aa8050da..c7bdf739 100644 --- a/src/Phalcon/assets/AssetInterface.php +++ b/src/Phalcon/assets/AssetInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; /** @@ -68,4 +59,5 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; + } diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/assets/Collection.php index fbc9a756..479cf1c9 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/assets/Collection.php @@ -1,23 +1,21 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; use Countable; use Iterator; +use Phalcon\Assets\Asset; +use Phalcon\Assets\FilterInterface; +use Phalcon\Assets\Inline; +use Phalcon\Assets\Asset\Css; +use Phalcon\Assets\Asset\Js; +use Phalcon\Assets\Inline\Js; +use Phalcon\Assets\Inline\Css; /** * Represents a collection of assets */ -class Collection implements Countable, Iterator +class Collection implements \Countable, \Iterator { /** * @var array @@ -289,10 +287,10 @@ public function addInlineJs(string $content, bool $filter = true, $attributes = /** * Adds a javascript asset to the collection * + * @param array $attributes * @param string $path * @param mixed $local * @param bool $filter - * @param array $attributes * @param string $version * @param bool $autoVersion * @return Collection @@ -493,4 +491,5 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } + } diff --git a/src/Phalcon/assets/Exception.php b/src/Phalcon/assets/Exception.php index 62e2b8f5..49148351 100644 --- a/src/Phalcon/assets/Exception.php +++ b/src/Phalcon/assets/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; /** diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index eae3f9de..e0ba66c2 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; /** @@ -24,4 +15,5 @@ interface FilterInterface * @return string */ public function filter(string $content): string; + } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index 30c391f0..f643eafd 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -1,24 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; /** * Represents an inline asset * - *```php + * ```php * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); - *``` + * ``` */ -class Inline implements AssetInterface +class Inline implements \Phalcon\Assets\AssetInterface { /** * @var array | null @@ -119,4 +110,5 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } + } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index 81db6995..9943b8fd 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -1,16 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets; +use Phalcon\Tag; +use Phalcon\Assets\Asset; +use Phalcon\Assets\Collection; +use Phalcon\Assets\Exception; +use Phalcon\Assets\Asset\Js; +use Phalcon\Assets\Asset\Css; +use Phalcon\Assets\Inline\Css; +use Phalcon\Assets\Inline\Js; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; /** @@ -255,9 +255,9 @@ public function getOptions(): array /** * Traverses a collection calling the callback to generate its HTML * - * @param \Phalcon\Assets\Collection $collection * @param callback $callback * @param string $type + * @param \Phalcon\Assets\Collection $collection * @return string|null */ public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string @@ -277,8 +277,8 @@ public function outputCss(string $collectionName = null): string /** * Traverses a collection and generate its HTML * - * @param \Phalcon\Assets\Collection $collection * @param string $type + * @param \Phalcon\Assets\Collection $collection * @return string */ public function outputInline(\Phalcon\Assets\Collection $collection, $type): string @@ -360,4 +360,5 @@ public function useImplicitOutput(bool $implicitOutput): Manager private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string { } + } diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/assets/asset/Css.php index 719e73b1..3d2e7a3a 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/assets/asset/Css.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Asset; -use Phalcon\Assets\Asset as AssetBase; +use Phalcon\Assets\Asset; /** * Represents CSS assets */ -class Css extends AssetBase +class Css extends \Phalcon\Assets\Asset { /** @@ -32,4 +23,5 @@ class Css extends AssetBase public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/assets/asset/Js.php index becb4980..12b7227c 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/assets/asset/Js.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Asset; -use Phalcon\Assets\Asset as AssetBase; +use Phalcon\Assets\Asset; /** * Represents Javascript assets */ -class Js extends AssetBase +class Js extends \Phalcon\Assets\Asset { /** @@ -32,4 +23,5 @@ class Js extends AssetBase public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/assets/filters/Cssmin.php index d7012025..5c12236b 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/assets/filters/Cssmin.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Filters; use Phalcon\Assets\FilterInterface; @@ -17,7 +8,7 @@ * Minify the css - removes comments removes newlines and line feeds keeping * removes last semicolon from last property */ -class Cssmin implements FilterInterface +class Cssmin implements \Phalcon\Assets\FilterInterface { /** @@ -30,4 +21,5 @@ class Cssmin implements FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/assets/filters/Jsmin.php index 11ac6468..e49d298f 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/assets/filters/Jsmin.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Filters; use Phalcon\Assets\FilterInterface; @@ -18,7 +9,7 @@ * be removed. Tabs will be replaced with spaces. Carriage returns will be * replaced with linefeeds. Most spaces and linefeeds will be removed. */ -class Jsmin implements FilterInterface +class Jsmin implements \Phalcon\Assets\FilterInterface { /** @@ -31,4 +22,5 @@ class Jsmin implements FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/assets/filters/None.php index 4fe7cc34..9632bc90 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/assets/filters/None.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Filters; use Phalcon\Assets\FilterInterface; @@ -16,7 +7,7 @@ /** * Returns the content without make any modification to the original source */ -class None implements FilterInterface +class None implements \Phalcon\Assets\FilterInterface { /** @@ -28,4 +19,5 @@ class None implements FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/assets/inline/Css.php index 0727ce11..0941a929 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/assets/inline/Css.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Inline; -use Phalcon\Assets\Inline as InlineBase; +use Phalcon\Assets\Inline; /** * Represents an inlined CSS */ -class Css extends InlineBase +class Css extends \Phalcon\Assets\Inline { /** @@ -29,4 +20,5 @@ class Css extends InlineBase public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/assets/inline/Js.php index 39ecc6dd..e01a92af 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/assets/inline/Js.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Assets\Inline; -use Phalcon\Assets\Inline as InlineBase; +use Phalcon\Assets\Inline; /** * Represents an inline JavaScript */ -class Js extends InlineBase +class Js extends \Phalcon\Assets\Inline { /** @@ -29,4 +20,5 @@ class Js extends InlineBase public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/cache/AdapterFactory.php index e28c8f04..426aa23b 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/cache/AdapterFactory.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache; -use Phalcon\Cache\Adapter\AbstractAdapter; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Exception\Exception; use Phalcon\Factory\AbstractFactory; use Phalcon\Storage\SerializerFactory; @@ -41,9 +33,9 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * * @param string $name * @param array $options - * @return \Phalcon\Cache\Adapter\AbstractAdapter + * @return \Phalcon\Cache\Adapter\AdapterInterface */ - public function newInstance(string $name, array $options = array()): AbstractAdapter + public function newInstance(string $name, array $options = array()): AdapterInterface { } @@ -55,4 +47,5 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } + } diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/cache/CacheFactory.php index fd0a0fe5..da3ea961 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/cache/CacheFactory.php @@ -1,17 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache; -use Phalcon\Cache\CacheInterface; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\AdapterFactory; +use Phalcon\Cache; +use Psr\SimpleCache\CacheInterface; +use Phalcon\Cache\Exception\Exception; +use Phalcon\Config; +use Phalcon\Helper\Arr; /** * Creates a new Cache class @@ -48,9 +45,10 @@ public function load($config) * * @param string $name * @param array $options - * @return \Phalcon\Cache\CacheInterface + * @return \Psr\SimpleCache\CacheInterface */ public function newInstance(string $name, array $options = array()): CacheInterface { } + } diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php index 284a2938..d62bc87d 100644 --- a/src/Phalcon/cache/adapter/AdapterInterface.php +++ b/src/Phalcon/cache/adapter/AdapterInterface.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Storage\Adapter\AdapterInterface as StorageAdapterInterface; +use Phalcon\Storage\Adapter\AdapterInterface; /** * Interface for Phalcon\Cache adapters */ -interface AdapterInterface extends StorageAdapterInterface +interface AdapterInterface extends \Phalcon\Storage\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Apcu.php b/src/Phalcon/cache/adapter/Apcu.php index cd07a9bd..7d97798d 100644 --- a/src/Phalcon/cache/adapter/Apcu.php +++ b/src/Phalcon/cache/adapter/Apcu.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Apcu as StorageApcu; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Adapter\Apcu; /** * Apcu adapter */ -class Apcu extends StorageApcu implements CacheAdapterInterface +class Apcu extends \Phalcon\Storage\Adapter\Apcu implements \Phalcon\Cache\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Libmemcached.php b/src/Phalcon/cache/adapter/Libmemcached.php index 588ec179..7345a7ec 100644 --- a/src/Phalcon/cache/adapter/Libmemcached.php +++ b/src/Phalcon/cache/adapter/Libmemcached.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Libmemcached as StorageLibmemcached; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Adapter\Libmemcached; /** * Libmemcached adapter */ -class Libmemcached extends StorageLibmemcached implements CacheAdapterInterface +class Libmemcached extends \Phalcon\Storage\Adapter\Libmemcached implements \Phalcon\Cache\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Memory.php b/src/Phalcon/cache/adapter/Memory.php index fb642281..2ce43e5c 100644 --- a/src/Phalcon/cache/adapter/Memory.php +++ b/src/Phalcon/cache/adapter/Memory.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Memory as StorageMemory; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Adapter\Memory; /** * Memory adapter */ -class Memory extends StorageMemory implements CacheAdapterInterface +class Memory extends \Phalcon\Storage\Adapter\Memory implements \Phalcon\Cache\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Redis.php b/src/Phalcon/cache/adapter/Redis.php index 6ed01117..ee7c5182 100644 --- a/src/Phalcon/cache/adapter/Redis.php +++ b/src/Phalcon/cache/adapter/Redis.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Redis as StorageRedis; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Adapter\Redis; /** * Redis adapter */ -class Redis extends StorageRedis implements CacheAdapterInterface +class Redis extends \Phalcon\Storage\Adapter\Redis implements \Phalcon\Cache\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/adapter/Stream.php b/src/Phalcon/cache/adapter/Stream.php index eb4f7865..7f671609 100644 --- a/src/Phalcon/cache/adapter/Stream.php +++ b/src/Phalcon/cache/adapter/Stream.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Storage\Adapter\Stream as StorageStream; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Adapter\Stream; /** * Stream adapter */ -class Stream extends StorageStream implements CacheAdapterInterface +class Stream extends \Phalcon\Storage\Adapter\Stream implements \Phalcon\Cache\Adapter\AdapterInterface { } diff --git a/src/Phalcon/cache/exception/Exception.php b/src/Phalcon/cache/exception/Exception.php index b9fec03b..17e8a477 100644 --- a/src/Phalcon/cache/exception/Exception.php +++ b/src/Phalcon/cache/exception/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Exception; /** diff --git a/src/Phalcon/cache/exception/InvalidArgumentException.php b/src/Phalcon/cache/exception/InvalidArgumentException.php index 819fcbea..67a5d038 100644 --- a/src/Phalcon/cache/exception/InvalidArgumentException.php +++ b/src/Phalcon/cache/exception/InvalidArgumentException.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cache\Exception; /** diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 8c1ee027..4bd0bebe 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -1,17 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; use Phalcon\Application\AbstractApplication; +use Phalcon\Cli\Router\Route; +use Phalcon\Cli\Console\Exception; +use Phalcon\Di\DiInterface; +use Phalcon\Events\ManagerInterface; /** * This component allows to create CLI applications using Phalcon @@ -49,4 +44,5 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } + } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index d641303a..0db8a627 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; -use Phalcon\Dispatcher\AbstractDispatcher as CliDispatcher; +use Phalcon\Cli\Dispatcher\Exception; +use Phalcon\Dispatcher\AbstractDispatcher; +use Phalcon\Events\ManagerInterface; +use Phalcon\Filter\FilterInterface; /** * Dispatching is the process of taking the command-line arguments, extracting @@ -35,7 +29,7 @@ * $handle = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends CliDispatcher implements DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface { /** * @var string @@ -91,9 +85,9 @@ public function getLastTask(): TaskInterface /** * Gets an option by its name or numeric index * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue * @return mixed */ public function getOption($option, $filters = null, $defaultValue = null) @@ -191,4 +185,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index e2fe0261..62b79d89 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; -use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; +use Phalcon\Dispatcher\DispatcherInterface; /** * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends DispatcherInterfaceBase +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** @@ -81,4 +72,5 @@ public function setTaskName(string $taskName); * @param string $taskSuffix */ public function setTaskSuffix(string $taskSuffix); + } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index e8cb2525..7c5a8758 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -1,17 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Cli\Router\Route; +use Phalcon\Cli\Router\Exception; +use Phalcon\Cli\Router\RouteInterface; /** * Phalcon\Cli\Router is the standard framework router. Routing is the process @@ -19,7 +14,7 @@ * determine which module, task, and action of that task should receive the * request. * - *```php + * ```php * $router = new \Phalcon\Cli\Router(); * * $router->handle( @@ -31,7 +26,7 @@ * ); * * echo $router->getTaskName(); - *``` + * ``` */ class Router extends AbstractInjectionAware { @@ -92,9 +87,9 @@ public function __construct(bool $defaultRoutes = true) * $router->add("/about", "About::main"); * ``` * - * @param string $pattern * @param string|array $paths - * @return RouteInterface + * @param string $pattern + * @return \Phalcon\Cli\Router\RouteInterface */ public function add(string $pattern, $paths = null): RouteInterface { @@ -112,7 +107,7 @@ public function getActionName(): string /** * Returns the route that matches the handled URI * - * @return RouteInterface + * @return \Phalcon\Cli\Router\RouteInterface */ public function getMatchedRoute(): RouteInterface { @@ -149,7 +144,7 @@ public function getParams(): array * Returns a route object by its id * * @param int $id - * @return bool|RouteInterface + * @return bool|\Phalcon\Cli\Router\RouteInterface */ public function getRouteById($id) { @@ -159,7 +154,7 @@ public function getRouteById($id) * Returns a route object by its name * * @param string $name - * @return bool|RouteInterface + * @return bool|\Phalcon\Cli\Router\RouteInterface */ public function getRouteByName(string $name) { @@ -248,4 +243,5 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } + } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 371d32f7..9a3dbaa9 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; use Phalcon\Cli\Router\RouteInterface; @@ -134,4 +125,5 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 78f2980f..1afcdd86 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; /** * Every command-line task should extend this class that encapsulates all the @@ -21,7 +14,7 @@ * or anything that you want. The Task class should at least have a "mainAction" * method. * - *```php + * ```php * class HelloTask extends \Phalcon\Cli\Task * { * // This action will be executed by default @@ -35,15 +28,37 @@ * * } * } - *``` + * ``` */ -class Task extends Injectable implements TaskInterface +class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface { + protected $eventsManager; + + /** * Phalcon\Cli\Task constructor */ final public function __construct() { } + + /** + * Returns the internal event manager + * + * @return null|\Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ?ManagerInterface + { + } + + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } + } diff --git a/src/Phalcon/cli/TaskInterface.php b/src/Phalcon/cli/TaskInterface.php index ae2bee57..9ceb7d69 100644 --- a/src/Phalcon/cli/TaskInterface.php +++ b/src/Phalcon/cli/TaskInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli; /** diff --git a/src/Phalcon/cli/console/Exception.php b/src/Phalcon/cli/console/Exception.php index 7045b747..09649fa2 100644 --- a/src/Phalcon/cli/console/Exception.php +++ b/src/Phalcon/cli/console/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli\Console; /** diff --git a/src/Phalcon/cli/dispatcher/Exception.php b/src/Phalcon/cli/dispatcher/Exception.php index 689dde96..d03f5450 100644 --- a/src/Phalcon/cli/dispatcher/Exception.php +++ b/src/Phalcon/cli/dispatcher/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli\Dispatcher; /** diff --git a/src/Phalcon/cli/router/Exception.php b/src/Phalcon/cli/router/Exception.php index ae874ebb..06f5a678 100644 --- a/src/Phalcon/cli/router/Exception.php +++ b/src/Phalcon/cli/router/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli\Router; /** diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 4395d76d..3ae8c801 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli\Router; +use Phalcon\Cli\Router\RouteInterface; + /** * This class represents every route added to the router */ -class Route +class Route implements \Phalcon\Cli\Router\RouteInterface { const DEFAULT_DELIMITER = ' '; @@ -32,7 +25,7 @@ class Route protected $delimiter; - protected static $delimiterPath = self::DEFAULT_DELIMITER; + static protected $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -50,12 +43,12 @@ class Route protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; /** - * @param string $pattern * @param array|string $paths + * @param string $pattern */ public function __construct(string $pattern, $paths = null) { @@ -67,7 +60,7 @@ public function __construct(string $pattern, $paths = null) * If the callback returns false the route is treated as not matched * * @param callback $callback - * @return RouteInterface + * @return \Phalcon\Cli\Router\RouteInterface */ public function beforeMatch($callback): RouteInterface { @@ -88,9 +81,9 @@ public function compilePattern(string $pattern): string * Adds a converter to perform an additional transformation for certain * parameter * - * @param string $name * @param callable $converter - * @return RouteInterface + * @param string $name + * @return \Phalcon\Cli\Router\RouteInterface */ public function convert(string $name, $converter): RouteInterface { @@ -208,8 +201,8 @@ public function getRouteId(): string /** * Reconfigure the route adding a new pattern and a set of paths * - * @param string $pattern * @param array|string $paths + * @param string $pattern */ public function reConfigure(string $pattern, $paths = null) { @@ -226,7 +219,7 @@ public static function reset() * Sets the route's description * * @param string $description - * @return RouteInterface + * @return \Phalcon\Cli\Router\RouteInterface */ public function setDescription(string $description): RouteInterface { @@ -245,9 +238,10 @@ public function setDescription(string $description): RouteInterface * ``` * * @param string $name - * @return RouteInterface + * @return \Phalcon\Cli\Router\RouteInterface */ public function setName(string $name): RouteInterface { } + } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index fbdea9e2..d5cff844 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Cli\Router; /** @@ -117,4 +108,5 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; + } diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php index 3aca3660..4236b04b 100644 --- a/src/Phalcon/collection/Exception.php +++ b/src/Phalcon/collection/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Collection; use Throwable; @@ -16,7 +7,7 @@ /** * Exceptions for the Collection object */ -class Exception extends \Phalcon\Exception implements Throwable +class Exception extends \Phalcon\Exception implements \Throwable { } diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/collection/ReadOnly.php index 522d50f9..73f500e5 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/collection/ReadOnly.php @@ -1,17 +1,9 @@ -* -* For the full copyright and license information, please view the LICENSE.txt -* file that was distributed with this source code. -*/ - namespace Phalcon\Collection; use Phalcon\Collection; +use Phalcon\Collection\Exception; /** * Phalcon\Collection\ReadOnly is a read only Collection object @@ -37,4 +29,5 @@ public function remove(string $element) public function set(string $element, $value) { } + } diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/config/ConfigFactory.php index 3e20cace..fbb4cc98 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/config/ConfigFactory.php @@ -1,23 +1,23 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config; +use Phalcon\Config; +use Phalcon\Config\Adapter\Grouped; +use Phalcon\Config\Adapter\Ini; +use Phalcon\Config\Adapter\Json; +use Phalcon\Config\Adapter\Php; +use Phalcon\Config\Adapter\Yaml; +use Phalcon\Config\Exception; use Phalcon\Factory\AbstractFactory; +use Phalcon\Factory\Exception; +use Phalcon\Helper\Arr; /** * Loads Config Adapter class using 'adapter' option, if no extension is * provided it will be added to filePath * - *```php + * ```php * use Phalcon\Config\ConfigFactory; * * $options = [ @@ -26,7 +26,7 @@ * ]; * * $config = (new ConfigFactory())->load($options); - *``` + * ``` */ class ConfigFactory extends AbstractFactory { @@ -70,4 +70,5 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/config/Exception.php b/src/Phalcon/config/Exception.php index 9d36d0e9..80954ccc 100644 --- a/src/Phalcon/config/Exception.php +++ b/src/Phalcon/config/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config; /** diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 33cb4844..f51e67cb 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; +use Phalcon\Factory\Exception; +use Phalcon\Config\ConfigFactory; /** * Reads multiple files (or arrays) and merges them all together. @@ -76,4 +70,5 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } + } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 643ad9cf..0a23b19f 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; /** * Reads ini files and converts them to Phalcon\Config objects. * * Given the next configuration file: * - *```ini + * ```ini * [database] * adapter = Mysql * host = localhost @@ -34,14 +26,14 @@ * * You can read it as follows: * - *```php + * ```php * use Phalcon\Config\Adapter\Ini; * * $config = new Ini("path/config.ini"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - *``` + * ``` * * PHP constants may also be parsed in the ini file, so if you define a constant * as an ini value before calling the constructor, the constant's value will be @@ -89,4 +81,5 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } + } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index ecb773ca..070d12dc 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -18,20 +9,20 @@ * * Given the following configuration file: * - *```json + * ```json * {"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"}} - *``` + * ``` * * You can read it as follows: * - *```php + * ```php * use Phalcon\Config\Adapter\Json; * * $config = new Json("path/config.json"); * * echo $config->phalcon->baseuri; * echo $config->models->metadata; - *``` + * ``` */ class Json extends Config { @@ -44,4 +35,5 @@ class Json extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index 0399da11..5b214eb9 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -18,7 +9,7 @@ * * Given the next configuration file: * - *```php + * ```php * "../app/views/", * ], * ]; - *``` + * ``` * * You can read it as follows: * - *```php + * ```php * use Phalcon\Config\Adapter\Php; * * $config = new Php("path/config.php"); * * echo $config->phalcon->controllersDir; * echo $config->database->username; - *``` + * ``` */ class Php extends Config { @@ -59,4 +50,5 @@ class Php extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index c586eace..c55f8df1 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -1,34 +1,26 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; /** * Reads YAML files and converts them to Phalcon\Config objects. * * Given the following configuration file: * - *```yaml + * ```yaml * phalcon: * baseuri: /phalcon/ * controllersDir: !approot /app/controllers/ * models: * metadata: memory - *``` + * ``` * * You can read it as follows: * - *```php + * ```php * define( * "APPROOT", * dirname(__DIR__) @@ -48,7 +40,7 @@ * echo $config->phalcon->controllersDir; * echo $config->phalcon->baseuri; * echo $config->models->metadata; - *``` + * ``` */ class Yaml extends Config { @@ -62,4 +54,5 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } + } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php index ce124ece..2758e631 100644 --- a/src/Phalcon/crypt/CryptInterface.php +++ b/src/Phalcon/crypt/CryptInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Crypt; /** @@ -142,4 +133,5 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; + } diff --git a/src/Phalcon/crypt/Exception.php b/src/Phalcon/crypt/Exception.php index 292e32b6..3331c991 100644 --- a/src/Phalcon/crypt/Exception.php +++ b/src/Phalcon/crypt/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Crypt; /** diff --git a/src/Phalcon/crypt/Mismatch.php b/src/Phalcon/crypt/Mismatch.php index a92c9bc8..3b3f731b 100644 --- a/src/Phalcon/crypt/Mismatch.php +++ b/src/Phalcon/crypt/Mismatch.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Crypt; /** * Exceptions thrown in Phalcon\Crypt will use this class. */ -class Mismatch extends Exception +class Mismatch extends \Phalcon\Crypt\Exception { } diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/db/AbstractDb.php index e901c5b4..ef31352b 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/db/AbstractDb.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; +use \PDO; + /** * Phalcon\Db and its related classes provide a simple SQL database interface * for Phalcon Framework. The Phalcon\Db is the basic class you use to connect @@ -24,7 +17,7 @@ * Phalcon\Db\AbstractDb is an abstract class. You only can use it with a * database adapter like Phalcon\Db\Adapter\Pdo * - *```php + * ```php * use Phalcon\Db; * use Phalcon\Db\Exception; * use Phalcon\Db\Adapter\Pdo\Mysql as MysqlConnection; @@ -41,7 +34,7 @@ * ); * * $result = $connection->query( - * "SELECT * FROM robots LIMIT 5" + * "SELECT FROM robots LIMIT 5" * ); * * $result->setFetchMode(Enum::FETCH_NUM); @@ -65,4 +58,5 @@ abstract class AbstractDb public static function setup(array $options) { } + } diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 9e1ea34e..239546c9 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -1,20 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db; +use Phalcon\Db\Exception; +use Phalcon\Db\ColumnInterface; + /** * Allows to define columns to be used on create or alter table operations * - *```php + * ```php * use Phalcon\Db\Column as Column; * * // Column definition @@ -32,9 +26,9 @@ * * // Add column to existing table * $connection->addColumn("robots", null, $column); - *``` + * ``` */ -class Column implements ColumnInterface +class Column implements \Phalcon\Db\ColumnInterface { /** * Bind Type Blob @@ -455,4 +449,5 @@ public function isPrimary(): bool public function isUnsigned(): bool { } + } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index 3339bc0a..2fc8226d 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -128,4 +119,5 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; + } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index 72a3fa01..f8ff74e3 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -1,21 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ -abstract class Dialect implements DialectInterface +abstract class Dialect implements \Phalcon\Db\DialectInterface { protected $escapeChar; @@ -511,4 +502,5 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } + } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 00d837c1..fe1061c1 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -1,16 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; +use Phalcon\Db\IndexInterface; + /** * Interface for Phalcon\Db dialects */ @@ -321,4 +316,5 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; + } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php index aa486df7..3049c8f7 100644 --- a/src/Phalcon/db/Enum.php +++ b/src/Phalcon/db/Enum.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -66,4 +57,6 @@ class Enum const FETCH_UNIQUE = 196608; + + } diff --git a/src/Phalcon/db/Exception.php b/src/Phalcon/db/Exception.php index 81791270..0f815657 100644 --- a/src/Phalcon/db/Exception.php +++ b/src/Phalcon/db/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** diff --git a/src/Phalcon/db/Index.php b/src/Phalcon/db/Index.php index f5246851..d861d538 100644 --- a/src/Phalcon/db/Index.php +++ b/src/Phalcon/db/Index.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -16,7 +7,7 @@ * to enhance database performance. An index allows the database server to find * and retrieve specific rows much faster than it could do without an index * - *```php + * ```php * // Define new unique index * $index_unique = new \Phalcon\Db\Index( * 'column_UNIQUE', @@ -38,9 +29,9 @@ * // Add index to existing table * $connection->addIndex("robots", null, $index_unique); * $connection->addIndex("robots", null, $index_primary); - *``` + * ``` */ -class Index implements IndexInterface +class Index implements \Phalcon\Db\IndexInterface { /** * Index columns @@ -101,4 +92,5 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } + } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index f7ee342d..036ed333 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -37,4 +28,5 @@ public function getName(): string; * @return string */ public function getType(): string; + } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index dd6d5e04..1c72907c 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; use Phalcon\Db\Profiler\Item; @@ -47,7 +38,6 @@ * // Set the event manager on the connection * $connection->setEventsManager($eventsManager); * - * * $sql = "SELECT buyer_name, quantity, product_name * FROM buyers LEFT JOIN products ON * buyers.pid=products.id"; @@ -153,4 +143,5 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } + } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index 87faeafe..ff3994fa 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -16,14 +7,14 @@ * * The next example shows how to use the MySQL now() function as a field value. * - *```php + * ```php * $subscriber = new Subscribers(); * * $subscriber->email = "andres@phalcon.io"; * $subscriber->createdAt = new \Phalcon\Db\RawValue("now()"); * * $subscriber->save(); - *``` + * ``` */ class RawValue { @@ -61,4 +52,5 @@ public function __toString(): string public function __construct($value) { } + } diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index 2fa59d98..6a80a29f 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** * Allows to define reference constraints on tables * - *```php + * ```php * $reference = new \Phalcon\Db\Reference( * "field_fk", * [ @@ -30,9 +21,9 @@ * ], * ] * ); - *``` + * ``` */ -class Reference implements ReferenceInterface +class Reference implements \Phalcon\Db\ReferenceInterface { /** * Local reference columns @@ -172,4 +163,5 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } + } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 42e1fb62..738157ac 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -72,4 +63,5 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; + } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index 5cf82928..a6baa4b2 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db; /** @@ -82,4 +73,5 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; + } diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index 3607f9e0..134ca6c0 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -1,18 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; use Phalcon\Db\RawValue; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; @@ -20,12 +18,12 @@ /** * Base class for Phalcon\Db adapters */ -abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Connection ID */ - protected static $connectionConsecutive = 0; + static protected $connectionConsecutive = 0; /** * Active connection ID @@ -929,4 +927,5 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } + } diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index 9791f1af..0fe826a0 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -1,18 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; +use Phalcon\Db\ResultInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; +use Phalcon\Db\ReferenceInterface; /** * Interface for Phalcon\Db adapters @@ -359,9 +354,9 @@ public function getDefaultIdValue(): RawValue; /** * Return internal PDO handler * - * @return \Pdo + * @return \PDO */ - public function getInternalHandler(): \Pdo; + public function getInternalHandler(): \PDO; /** * Returns the savepoint name to use for nested transactions @@ -630,4 +625,5 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; + } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php index fa3dcb1c..25cafc44 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -1,5 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\Result\Pdo; +use Phalcon\Db\ResultInterface; +use Phalcon\Events\ManagerInterface; /** * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect @@ -29,7 +25,7 @@ * ]; * * $connection = new Mysql($config); - *``` + * ``` */ abstract class AbstractPdo extends AbstractAdapter { @@ -41,7 +37,7 @@ abstract class AbstractPdo extends AbstractAdapter /** * PDO Handler * - * @var \Pdo + * @var \PDO */ protected $pdo; @@ -241,9 +237,9 @@ public function getErrorInfo() /** * Return internal PDO handler * - * @return \Pdo + * @return \PDO */ - public function getInternalHandler(): \Pdo + public function getInternalHandler(): \PDO { } @@ -375,4 +371,5 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; + } diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index f7d0d3bf..c871006f 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -1,22 +1,21 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; /** * Specific functions for the Mysql database system * - *```php + * ```php * use Phalcon\Db\Adapter\Pdo\Mysql; * * $config = [ @@ -28,9 +27,9 @@ * ]; * * $connection = new Mysql($config); - *``` + * ``` */ -class Mysql extends PdoAdapter +class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { /** * @var string @@ -114,4 +113,5 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 051d615e..5b431af5 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -1,18 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; use Phalcon\Db\RawValue; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; +use Throwable; /** * Specific functions for the Postgresql database system @@ -31,7 +29,7 @@ * $connection = new Postgresql($config); * ``` */ -class Postgresql extends PdoAdapter +class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { /** * @var string @@ -177,4 +175,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index a4df4f55..6701942c 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -1,18 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Adapter\Pdo\AbstractPdo; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; /** * Specific functions for the Sqlite database system @@ -27,7 +26,7 @@ * ); * ``` */ -class Sqlite extends PdoAdapter +class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { /** * @var string @@ -148,4 +147,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 10d7e3c2..4ab04ab3 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -1,17 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; +use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the MySQL RDBMS @@ -360,4 +357,5 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string { } + } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 1718e52c..8c10a7f2 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -1,17 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; +use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the PostgreSQL RDBMS @@ -331,4 +328,5 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } + } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index ea2c551a..390f1d32 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -1,17 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; use Phalcon\Db\Dialect; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; /** * Generates database specific SQL for the SQLite RDBMS @@ -354,4 +351,5 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } + } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 8e862127..0e6c60da 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Profiler; /** @@ -150,4 +141,5 @@ public function getSqlVariables(): array public function getTotalElapsedSeconds(): float { } + } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index a5ffa8f8..45f1e438 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Db\Result; use Phalcon\Db\Enum; use Phalcon\Db\ResultInterface; +use Phalcon\Db\Adapter\AdapterInterface; /** * Encapsulates the resultset internals * * ```php - * $result = $connection->query("SELECT * FROM robots ORDER BY name"); + * $result = $connection->query("SELECT FROM robots ORDER BY name"); * * $result->setFetchMode( * \Phalcon\Db\Enum::FETCH_NUM @@ -29,7 +21,7 @@ * } * ``` */ -class Pdo implements ResultInterface +class Pdo implements \Phalcon\Db\ResultInterface { protected $bindParams; @@ -235,4 +227,5 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } + } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index 0819fde4..40e10901 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -1,16 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Debug; +use Phalcon\Di; +use Reflection; +use ReflectionClass; +use ReflectionProperty; +use stdClass; + /** * Dumps information about a variable(s) * @@ -177,4 +174,5 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } + } diff --git a/src/Phalcon/debug/Exception.php b/src/Phalcon/debug/Exception.php index 9f53942f..9616f511 100644 --- a/src/Phalcon/debug/Exception.php +++ b/src/Phalcon/debug/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Debug; /** diff --git a/src/Phalcon/di/AbstractInjectionAware.php b/src/Phalcon/di/AbstractInjectionAware.php index 266c0132..adf55c9e 100644 --- a/src/Phalcon/di/AbstractInjectionAware.php +++ b/src/Phalcon/di/AbstractInjectionAware.php @@ -1,20 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; + /** * This abstract class offers common access to the DI in a class */ -abstract class AbstractInjectionAware implements InjectionAwareInterface +abstract class AbstractInjectionAware implements \Phalcon\Di\InjectionAwareInterface { /** * Dependency Injector @@ -41,4 +36,5 @@ public function getDI(): DiInterface public function setDI(\Phalcon\Di\DiInterface $container) { } + } diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/di/DiInterface.php index 9a300e26..44846e6d 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -1,22 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; use ArrayAccess; +use Phalcon\Di\ServiceInterface; /** * Interface for Phalcon\Di */ -interface DiInterface extends ArrayAccess +interface DiInterface extends \ArrayAccess { /** @@ -24,8 +16,8 @@ interface DiInterface extends ArrayAccess * Only is successful if a service hasn't been registered previously * with the same name * - * @param string $name * @param mixed $definition + * @param string $name * @param bool $shared * @return bool|\Phalcon\Di\ServiceInterface */ @@ -134,4 +126,5 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition * @return \Phalcon\Di\ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; + } diff --git a/src/Phalcon/di/Exception.php b/src/Phalcon/di/Exception.php index c9485d91..076f3444 100644 --- a/src/Phalcon/di/Exception.php +++ b/src/Phalcon/di/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; /** diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index ead1f2af..60c4460c 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Phalcon\Filter\FilterFactory; + /** * This is a variant of the standard Phalcon\Di. By default it automatically * registers all the services provided by the framework. Thanks to this, the @@ -26,4 +19,5 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } + } diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index d5096ea2..69998357 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -1,18 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Events\ManagerInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Di\Exception; use Phalcon\Session\BagInterface; /** @@ -44,7 +37,7 @@ * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ -abstract class Injectable implements InjectionAwareInterface, EventsAwareInterface +abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface { /** * Dependency Injector @@ -53,13 +46,6 @@ abstract class Injectable implements InjectionAwareInterface, EventsAwareInterfa */ protected $container; - /** - * Events Manager - * - * @var \Phalcon\Events\ManagerInterface - */ - protected $eventsManager; - /** * Magic method __get @@ -72,20 +58,21 @@ public function __get(string $propertyName) } /** - * Returns the internal dependency injector + * Magic method __isset * - * @return \Phalcon\Di\DiInterface + * @param string $name + * @return bool */ - public function getDI(): DiInterface + public function __isset(string $name): bool { } /** - * Returns the internal event manager + * Returns the internal dependency injector * - * @return null|\Phalcon\Events\ManagerInterface + * @return \Phalcon\Di\DiInterface */ - public function getEventsManager(): ?ManagerInterface + public function getDI(): DiInterface { } @@ -98,12 +85,4 @@ public function setDI(\Phalcon\Di\DiInterface $container) { } - /** - * Sets the event manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) - { - } } diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index 3b583389..dae522eb 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Phalcon\Di\DiInterface; + /** * This interface must be implemented in those classes that uses internally the * Phalcon\Di that creates them @@ -31,4 +24,5 @@ public function setDI(\Phalcon\Di\DiInterface $container); * @return \Phalcon\Di\DiInterface */ public function getDI(): DiInterface; + } diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index 83dc349b..33d80d31 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -1,31 +1,27 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Closure; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception; use Phalcon\Di\Exception\ServiceResolutionException; +use Phalcon\Di\ServiceInterface; +use Phalcon\Di\Service\Builder; /** * Represents individually a service in the services container * - *```php + * ```php * $service = new \Phalcon\Di\Service( * "request", * \Phalcon\Http\Request::class * ); * * $request = service->resolve(); - *``` + * ``` */ -class Service implements ServiceInterface +class Service implements \Phalcon\Di\ServiceInterface { protected $definition; @@ -66,8 +62,8 @@ public function getDefinition() /** * Returns a parameter in a specific position * - * @param int $position * @return array + * @param int $position */ public function getParameter(int $position) { @@ -139,4 +135,5 @@ public function setShared(bool $shared) public function setSharedInstance($sharedInstance) { } + } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index a2cbf919..39877b02 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Phalcon\Di\DiInterface; + /** * Represents a service in the services container */ @@ -27,8 +20,8 @@ public function getDefinition(); /** * Returns a parameter in a specific position * - * @param int $position * @return array + * @param int $position */ public function getParameter(int $position); @@ -77,4 +70,5 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); + } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index 327b378d..e55695f7 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di; +use Phalcon\Di\DiInterface; + /** * Should be implemented by service providers, or such components, which * register a service in the service container. @@ -44,4 +37,5 @@ interface ServiceProviderInterface * @param \Phalcon\Di\DiInterface $di */ public function register(\Phalcon\Di\DiInterface $di); + } diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php index 5bf50fe2..adb67374 100644 --- a/src/Phalcon/di/exception/ServiceResolutionException.php +++ b/src/Phalcon/di/exception/ServiceResolutionException.php @@ -1,5 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di\FactoryDefault; use Phalcon\Di\FactoryDefault; +use Phalcon\Di\Service; +use Phalcon\Filter\FilterFactory; /** * Phalcon\Di\FactoryDefault\Cli @@ -30,4 +23,5 @@ class Cli extends FactoryDefault public function __construct() { } + } diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/di/service/Builder.php index 12de4bcc..eac41917 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/di/service/Builder.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Di\Service; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception; + /** * Phalcon\Di\Service\Builder * @@ -22,10 +16,10 @@ class Builder /** * Builds a service using a complex service definition * - * @param \Phalcon\Di\DiInterface $container - * @param array $definition * @param array $parameters * @return mixed + * @param \Phalcon\Di\DiInterface $container + * @param array $definition */ public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) { @@ -34,10 +28,10 @@ public function build(\Phalcon\Di\DiInterface $container, array $definition, $pa /** * Resolves a constructor/call parameter * + * @return mixed * @param \Phalcon\Di\DiInterface $container * @param int $position * @param array $argument - * @return mixed */ private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) { @@ -53,4 +47,5 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array { } + } diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/dispatcher/AbstractDispatcher.php index ece649f6..7d102775 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/dispatcher/AbstractDispatcher.php @@ -1,19 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Dispatcher; +use Exception; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Dispatcher\DispatcherInterface; +use Phalcon\Dispatcher\Exception; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Filter\FilterInterface; +use Phalcon\Mvc\Model\Binder; use Phalcon\Mvc\Model\BinderInterface; /** @@ -21,7 +18,7 @@ * This class can't be instantiated directly, you can use it to create your own * dispatchers. */ -abstract class AbstractDispatcher extends AbstractInjectionAware implements DispatcherInterface, EventsAwareInterface +abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface { protected $activeHandler; @@ -139,7 +136,6 @@ public function callActionMethod($handler, string $actionMethod, array $params = * stopped by returning false in the exception handler. * * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. - * @return object|bool */ public function dispatch(): bool { @@ -418,9 +414,9 @@ public function setHandlerSuffix(string $handlerSuffix) * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache - * @return Dispatcher + * @return \Phalcon\Dispatcher\DispatcherInterface */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Dispatcher + public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): DispatcherInterface { } @@ -474,4 +470,5 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } + } diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php index 8c68bb73..3e670853 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Dispatcher; /** @@ -55,8 +46,8 @@ public function getHandlerSuffix(): string; /** * Gets a param by its name or numeric index * - * @param mixed $param * @param string|array $filters + * @param mixed $param * @return mixed */ public function getParam($param, $filters = null); @@ -143,8 +134,8 @@ public function setNamespaceName(string $namespaceName); /** * Set a param by its name or numeric index * - * @param mixed $param * @param mixed $value + * @param mixed $param */ public function setParam($param, $value); @@ -154,4 +145,5 @@ public function setParam($param, $value); * @param array $params */ public function setParams(array $params); + } diff --git a/src/Phalcon/dispatcher/Exception.php b/src/Phalcon/dispatcher/Exception.php index 7cd18a37..a9867c1d 100644 --- a/src/Phalcon/dispatcher/Exception.php +++ b/src/Phalcon/dispatcher/Exception.php @@ -1,18 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Dispatcher; /** - * Exceptions thrown in Phalcon\Dispatcher/* will use this class + * Exceptions thrown in Phalcon\Dispatcher/ will use this class */ class Exception extends \Phalcon\Exception { @@ -33,4 +24,6 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; + + } diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/domain/payload/Payload.php index c9902a52..d943bec6 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/domain/payload/Payload.php @@ -1,28 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; +use Phalcon\Domain\Payload\PayloadInterface; + /** * Holds the payload */ -class Payload implements PayloadInterface +class Payload implements \Phalcon\Domain\Payload\PayloadInterface { /** * Extra information @@ -154,4 +139,5 @@ public function setOutput($output): PayloadInterface public function setStatus($status): PayloadInterface { } + } diff --git a/src/Phalcon/domain/payload/PayloadFactory.php b/src/Phalcon/domain/payload/PayloadFactory.php index 89007b37..9d34be34 100644 --- a/src/Phalcon/domain/payload/PayloadFactory.php +++ b/src/Phalcon/domain/payload/PayloadFactory.php @@ -1,24 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; +use Phalcon\Domain\Payload\Payload; +use Phalcon\Domain\Payload\PayloadInterface; + /** * Factory to create payload objects */ @@ -33,4 +19,5 @@ class PayloadFactory public function newInstance(): PayloadInterface { } + } diff --git a/src/Phalcon/domain/payload/PayloadInterface.php b/src/Phalcon/domain/payload/PayloadInterface.php index 54d7c9b9..0bdd9661 100644 --- a/src/Phalcon/domain/payload/PayloadInterface.php +++ b/src/Phalcon/domain/payload/PayloadInterface.php @@ -1,28 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; +use Phalcon\Domain\Payload\ReadableInterface; +use Phalcon\Domain\Payload\WriteableInterface; + /** * This interface is used for consumers */ -interface PayloadInterface extends ReadableInterface, WriteableInterface +interface PayloadInterface extends \Phalcon\Domain\Payload\ReadableInterface, \Phalcon\Domain\Payload\WriteableInterface { } diff --git a/src/Phalcon/domain/payload/ReadableInterface.php b/src/Phalcon/domain/payload/ReadableInterface.php index 3eff75c8..53a7fd5a 100644 --- a/src/Phalcon/domain/payload/ReadableInterface.php +++ b/src/Phalcon/domain/payload/ReadableInterface.php @@ -1,22 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; /** @@ -56,8 +39,8 @@ public function getMessages(); /** * Gets arbitrary extra values produced by the domain layer. * - * @param mixed * @return mixed */ public function getExtras(); + } diff --git a/src/Phalcon/domain/payload/Status.php b/src/Phalcon/domain/payload/Status.php index 56833c73..5da2de6f 100644 --- a/src/Phalcon/domain/payload/Status.php +++ b/src/Phalcon/domain/payload/Status.php @@ -1,22 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; /** @@ -91,4 +74,5 @@ class Status final private function __construct() { } + } diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/domain/payload/WriteableInterface.php index 9bcd8261..3027bf85 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/domain/payload/WriteableInterface.php @@ -1,24 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by phalcon-api and AuraPHP - * @link https://github.com/phalcon/phalcon-api - * @license https://github.com/phalcon/phalcon-api/blob/master/LICENSE - * @link https://github.com/auraphp/Aura.Payload - * @license https://github.com/auraphp/Aura.Payload/blob/3.x/LICENSE - * - * @see Original inspiration for the https://github.com/phalcon/phalcon-api - */ - namespace Phalcon\Domain\Payload; +use Phalcon\Domain\Payload\PayloadInterface; + /** * This interface is used for consumers (write) */ @@ -39,7 +24,6 @@ public function setStatus($status): PayloadInterface; * * @param mixed $input The input received by the domain layer. * - * @param mixed $input * @return \Phalcon\Domain\Payload\PayloadInterface */ public function setInput($input): PayloadInterface; @@ -67,4 +51,5 @@ public function setMessages($messages): PayloadInterface; * @return \Phalcon\Domain\Payload\PayloadInterface */ public function setExtras($extras): PayloadInterface; + } diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/escaper/EscaperInterface.php index e419b340..784051f3 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/escaper/EscaperInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Escaper; /** @@ -79,4 +70,5 @@ public function setEncoding(string $encoding); * @param int $quoteType */ public function setHtmlQuoteType(int $quoteType); + } diff --git a/src/Phalcon/escaper/Exception.php b/src/Phalcon/escaper/Exception.php index 2fbb8c1b..75b6746a 100644 --- a/src/Phalcon/escaper/Exception.php +++ b/src/Phalcon/escaper/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Escaper; /** diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/events/Event.php index 4b399641..83e7d8f3 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/events/Event.php @@ -1,23 +1,25 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; +use Phalcon\Events\Exception; + /** * Phalcon\Events\Event * * This class offers contextual information of a fired event in the * EventsManager + * + * ```php + * Phalcon\Events\Event; + * + * $event = new Event("db:afterQuery", $this, ["data" => "mydata"], true); + * if ($event->isCancelable()) { + * $event->stop(); + * } + * ``` */ -class Event implements EventInterface +class Event implements \Phalcon\Events\EventInterface { /** * Is event cancelable? @@ -85,8 +87,8 @@ public function getType(): string /** * Phalcon\Events\Event constructor * - * @param string $type * @param object $source + * @param string $type * @param mixed $data * @param bool $cancelable */ @@ -152,4 +154,5 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } + } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index 66523896..92f60516 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; /** @@ -69,4 +60,5 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; + } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index 444133c1..dec83036 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; /** @@ -33,4 +24,5 @@ public function getEventsManager(): ?ManagerInterface; * @param ManagerInterface $eventsManager */ public function setEventsManager(ManagerInterface $eventsManager); + } diff --git a/src/Phalcon/events/Exception.php b/src/Phalcon/events/Exception.php index fa2a2045..fc0f8206 100644 --- a/src/Phalcon/events/Exception.php +++ b/src/Phalcon/events/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; /** diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index 64d63c93..147a9b84 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -1,16 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; +use Closure; +use Phalcon\Events\Event; +use SplPriorityQueue; + /** * Phalcon\Events\Manager * @@ -19,7 +14,7 @@ * can create hooks or plugins that will offer monitoring of data, manipulation, * conditional execution and much more. */ -class Manager implements ManagerInterface +class Manager implements \Phalcon\Events\ManagerInterface { const DEFAULT_PRIORITY = 100; @@ -44,8 +39,8 @@ class Manager implements ManagerInterface /** * Attach a listener to the events manager * - * @param string $eventType * @param object|callable $handler + * @param string $eventType * @param int $priority */ public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) @@ -74,8 +69,8 @@ public function collectResponses(bool $collect) /** * Detach the listener from the events manager * - * @param string $eventType * @param object $handler + * @param string $eventType */ public function detach(string $eventType, $handler) { @@ -107,11 +102,11 @@ public function enablePriorities(bool $enablePriorities) * $eventsManager->fire("db", $connection); * ``` * - * @param string $eventType * @param object $source * @param mixed $data - * @param bool $cancelable * @return mixed + * @param string $eventType + * @param bool $cancelable */ public function fire(string $eventType, $source, $data = null, bool $cancelable = true) { @@ -120,9 +115,9 @@ public function fire(string $eventType, $source, $data = null, bool $cancelable /** * Internal handler to call a queue of events * + * @return mixed * @param \SplPriorityQueue $queue * @param EventInterface $event - * @return mixed */ final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) { @@ -167,4 +162,5 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } + } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 5d934c90..7ddf377a 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Events; /** @@ -25,16 +16,16 @@ interface ManagerInterface /** * Attach a listener to the events manager * - * @param string $eventType * @param object|callable $handler + * @param string $eventType */ public function attach(string $eventType, $handler); /** * Detach the listener from the events manager * - * @param string $eventType * @param object $handler + * @param string $eventType */ public function detach(string $eventType, $handler); @@ -49,12 +40,13 @@ public function detachAll(string $type = null); * Fires an event in the events manager causing the active listeners to be * notified about it * - * @param string $eventType * @param object $source * @param mixed $data * @return mixed + * @param string $eventType + * @param bool $cancelable */ - public function fire(string $eventType, $source, $data = null); + public function fire(string $eventType, $source, $data = null, bool $cancelable = true); /** * Returns all the attached listeners of a certain type @@ -71,4 +63,5 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; + } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php index fdd06cf1..ca15053b 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/factory/AbstractFactory.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter; /** diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/filter/FilterFactory.php index e82768ad..a78d1a37 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/filter/FilterFactory.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter; /** @@ -26,4 +17,5 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); + } diff --git a/src/Phalcon/filter/sanitize/AbsInt.php b/src/Phalcon/filter/sanitize/AbsInt.php index e0c32714..8e81576a 100644 --- a/src/Phalcon/filter/sanitize/AbsInt.php +++ b/src/Phalcon/filter/sanitize/AbsInt.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class AbsInt { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Alnum.php b/src/Phalcon/filter/sanitize/Alnum.php index e1298737..e6acb75a 100644 --- a/src/Phalcon/filter/sanitize/Alnum.php +++ b/src/Phalcon/filter/sanitize/Alnum.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Alnum { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Alpha.php b/src/Phalcon/filter/sanitize/Alpha.php index c8f19dfe..65a72e6c 100644 --- a/src/Phalcon/filter/sanitize/Alpha.php +++ b/src/Phalcon/filter/sanitize/Alpha.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Alpha { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/BoolVal.php b/src/Phalcon/filter/sanitize/BoolVal.php index d3f1d980..d1c00d66 100644 --- a/src/Phalcon/filter/sanitize/BoolVal.php +++ b/src/Phalcon/filter/sanitize/BoolVal.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class BoolVal { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Email.php b/src/Phalcon/filter/sanitize/Email.php index 76c61da1..a2e43a68 100644 --- a/src/Phalcon/filter/sanitize/Email.php +++ b/src/Phalcon/filter/sanitize/Email.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Email { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/FloatVal.php b/src/Phalcon/filter/sanitize/FloatVal.php index f989740b..7b838493 100644 --- a/src/Phalcon/filter/sanitize/FloatVal.php +++ b/src/Phalcon/filter/sanitize/FloatVal.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class FloatVal { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/IntVal.php b/src/Phalcon/filter/sanitize/IntVal.php index 72662990..db75914a 100644 --- a/src/Phalcon/filter/sanitize/IntVal.php +++ b/src/Phalcon/filter/sanitize/IntVal.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class IntVal { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Lower.php b/src/Phalcon/filter/sanitize/Lower.php index 5d6b5889..74ab9e1d 100644 --- a/src/Phalcon/filter/sanitize/Lower.php +++ b/src/Phalcon/filter/sanitize/Lower.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Lower { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/LowerFirst.php b/src/Phalcon/filter/sanitize/LowerFirst.php index c19560cb..99d96acc 100644 --- a/src/Phalcon/filter/sanitize/LowerFirst.php +++ b/src/Phalcon/filter/sanitize/LowerFirst.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class LowerFirst { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Regex.php b/src/Phalcon/filter/sanitize/Regex.php index ec1117be..397c125b 100644 --- a/src/Phalcon/filter/sanitize/Regex.php +++ b/src/Phalcon/filter/sanitize/Regex.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,11 +11,12 @@ class Regex { /** - * @param mixed $input + * @param mixed $input The text to sanitize * @param mixed $pattern * @param mixed $replace */ public function __invoke($input, $pattern, $replace) { } + } diff --git a/src/Phalcon/filter/sanitize/Remove.php b/src/Phalcon/filter/sanitize/Remove.php index 8d9b24e7..d95e31b5 100644 --- a/src/Phalcon/filter/sanitize/Remove.php +++ b/src/Phalcon/filter/sanitize/Remove.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,10 +11,11 @@ class Remove { /** - * @param mixed $input + * @param mixed $input The text to sanitize * @param mixed $replace */ public function __invoke($input, $replace) { } + } diff --git a/src/Phalcon/filter/sanitize/Replace.php b/src/Phalcon/filter/sanitize/Replace.php index 60fd7558..a40b14c2 100644 --- a/src/Phalcon/filter/sanitize/Replace.php +++ b/src/Phalcon/filter/sanitize/Replace.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,11 +11,12 @@ class Replace { /** - * @param mixed $input + * @param mixed $input The text to sanitize * @param mixed $from * @param mixed $to */ public function __invoke($input, $from, $to) { } + } diff --git a/src/Phalcon/filter/sanitize/Special.php b/src/Phalcon/filter/sanitize/Special.php index 66cd7cbd..7e333cc7 100644 --- a/src/Phalcon/filter/sanitize/Special.php +++ b/src/Phalcon/filter/sanitize/Special.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Special { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/SpecialFull.php b/src/Phalcon/filter/sanitize/SpecialFull.php index ed8c7695..fb9c7efb 100644 --- a/src/Phalcon/filter/sanitize/SpecialFull.php +++ b/src/Phalcon/filter/sanitize/SpecialFull.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class SpecialFull { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/StringVal.php b/src/Phalcon/filter/sanitize/StringVal.php index 57d4601a..f168d5e4 100644 --- a/src/Phalcon/filter/sanitize/StringVal.php +++ b/src/Phalcon/filter/sanitize/StringVal.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class StringVal { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Striptags.php b/src/Phalcon/filter/sanitize/Striptags.php index 1ac2cff5..fa617220 100644 --- a/src/Phalcon/filter/sanitize/Striptags.php +++ b/src/Phalcon/filter/sanitize/Striptags.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Striptags { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Trim.php b/src/Phalcon/filter/sanitize/Trim.php index da8e2614..78092617 100644 --- a/src/Phalcon/filter/sanitize/Trim.php +++ b/src/Phalcon/filter/sanitize/Trim.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Trim { /** - * @param string $input + * @param mixed $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Upper.php b/src/Phalcon/filter/sanitize/Upper.php index 506ba986..3e9638ab 100644 --- a/src/Phalcon/filter/sanitize/Upper.php +++ b/src/Phalcon/filter/sanitize/Upper.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Upper { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/UpperFirst.php b/src/Phalcon/filter/sanitize/UpperFirst.php index d961bff5..2906ba8a 100644 --- a/src/Phalcon/filter/sanitize/UpperFirst.php +++ b/src/Phalcon/filter/sanitize/UpperFirst.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class UpperFirst { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/UpperWords.php b/src/Phalcon/filter/sanitize/UpperWords.php index cdf242bb..4782f08b 100644 --- a/src/Phalcon/filter/sanitize/UpperWords.php +++ b/src/Phalcon/filter/sanitize/UpperWords.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class UpperWords { /** - * @param string $input + * @param string $input The text to sanitize */ public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Url.php b/src/Phalcon/filter/sanitize/Url.php index d99006fa..885a8634 100644 --- a/src/Phalcon/filter/sanitize/Url.php +++ b/src/Phalcon/filter/sanitize/Url.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Filter\Sanitize; /** @@ -20,9 +11,10 @@ class Url { /** - * @param mixed $input + * @param mixed $input The text to sanitize */ public function __invoke($input) { } + } diff --git a/src/Phalcon/firewall/Exception.php b/src/Phalcon/firewall/Exception.php index aeee2ad1..dd456f15 100644 --- a/src/Phalcon/firewall/Exception.php +++ b/src/Phalcon/firewall/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall; /** diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/firewall/adapter/AbstractAdapter.php index 17d6670c..21c253f8 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/firewall/adapter/AbstractAdapter.php @@ -1,26 +1,21 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall\Adapter; use Closure; use Phalcon\Acl\Enum; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Acl\RoleAware; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Firewall\Exception; +use Phalcon\Mvc\Dispatcher; /** * Adapter for Phalcon\Firewall adapters */ -abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Storing active identity object implementing Phalcon/Acl/RoleAware @@ -42,7 +37,7 @@ abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface /** * Cache for caching access * - * @var + * @var CacheAdapterInterface */ protected $cache; @@ -158,10 +153,10 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager /** * Sets role callback to fetch role name * - * @param mixed $callback + * @param \Closure $callback * @return AdapterInterface */ - public function setRoleCallback($callback): AdapterInterface + public function setRoleCallback(\Closure $callback): AdapterInterface { } @@ -234,4 +229,5 @@ protected function saveAccessInCache(string $key, bool $access) protected function throwFirewallException(string $message, int $exceptionCode = 0): bool { } + } diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php index 4afd92b2..27821bec 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -1,16 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall\Adapter; +use Phalcon\Acl\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Events\Event; +use Phalcon\Events\ManagerInterface; +use Phalcon\Firewall\Adapter\AbstractAdapter; +use Phalcon\Firewall\Exception; +use Phalcon\Mvc\DispatcherInterface; + /** * FirewallZ for Phalcon\Application which depends on acl and dispatcher */ @@ -165,9 +165,9 @@ public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Di /** * Gets dispatcher * - * @return Dispatcher + * @return \Phalcon\Mvc\DispatcherInterface */ - public function getDispatcher(): Dispatcher + public function getDispatcher(): DispatcherInterface { } @@ -213,4 +213,5 @@ protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher protected function saveAccessInCache(string $key, bool $access) { } + } diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/firewall/adapter/AdapterInterface.php index 1e443ab7..964cbbf8 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/firewall/adapter/AdapterInterface.php @@ -1,16 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall\Adapter; +use Closure; +use Phalcon\Mvc\DispatcherInterface; +use Phalcon\Cache\Adapter\AdapterInterface; + /** * Interface for Phalcon\Mvc\Dispatcher\Firewall adapters */ @@ -26,8 +21,10 @@ public function getDefaultAccess(): int; /** * Gets role callback to fetch role name + * + * @return \Closure */ - public function getRoleCallback(); + public function getRoleCallback(): Closure; /** * Gets always resolving role option @@ -62,8 +59,9 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface; /** * Sets role callback to fetch role name * - * @param mixed $callback + * @param \Closure $callback * @return AdapterInterface */ - public function setRoleCallback($callback): AdapterInterface; + public function setRoleCallback(\Closure $callback): AdapterInterface; + } diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/firewall/adapter/Annotations.php index a9524489..49a7df98 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/firewall/adapter/Annotations.php @@ -1,16 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall\Adapter; +use Phalcon\Annotations\Adapter\AdapterInterface; +use Phalcon\Events\Event; +use Phalcon\Events\ManagerInterface; +use Phalcon\Firewall\Adapter\AbstractAdapter; +use Phalcon\Firewall\Exception; +use Phalcon\Mvc\DispatcherInterface; +use ReflectionClass; + /** * Firewall which depends on annotations and dispatcher */ @@ -82,9 +81,9 @@ public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Di /** * Gets dispatcher * - * @return Dispatcher + * @return \Phalcon\Mvc\DispatcherInterface */ - public function getDispatcher(): Dispatcher + public function getDispatcher(): DispatcherInterface { } @@ -133,4 +132,5 @@ protected function getAccessFromCache(string $key, array $originalValues = null, protected function handleAnnotation($annotation, bool $access, $role) { } + } diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/firewall/adapter/micro/Acl.php index 8feffce2..7f0fff1e 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/firewall/adapter/micro/Acl.php @@ -1,18 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Firewall\Adapter\Micro; +use Phalcon\Acl\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Events\Event; +use Phalcon\Events\ManagerInterface; use Phalcon\Firewall\Adapter\AbstractAdapter; +use Phalcon\Firewall\Exception; use Phalcon\Mvc\Micro; +use Phalcon\Mvc\Model\BinderInterface; +use Phalcon\Mvc\Router; /** * Firewall for Phalcon\Mvc\Micro which depends on ACL @@ -241,4 +241,5 @@ protected function handleRouter(\Phalcon\Mvc\Micro $micro) protected function saveAccessInCache(string $key, bool $access) { } + } diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/flash/AbstractFlash.php index cac5a834..2abac054 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/flash/AbstractFlash.php @@ -1,30 +1,24 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Flash; +use Phalcon\Di; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Escaper\EscaperInterface; -use Phalcon\Session\ManagerInterface as SessionInterface; +use Phalcon\Flash\Exception; +use Phalcon\Session\ManagerInterface; /** * Shows HTML notifications related to different circumstances. Classes can be * stylized using CSS * - *```php + * ```php * $flash->success("The record was successfully deleted"); * $flash->error("Cannot open the file"); - *``` + * ``` */ -abstract class AbstractFlash extends AbstractInjectionAware implements FlashInterface +abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\Flash\FlashInterface { /** * @var bool @@ -224,9 +218,9 @@ public function success(string $message): string * $flash->outputMessage("error", $message); * ``` * - * @param string $type * @param string|array $message * @return string|void + * @param string $type */ public function outputMessage(string $type, $message) { @@ -276,4 +270,5 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } + } diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index 9756e166..64b3052f 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Flash; +use Phalcon\Flash\AbstractFlash; + /** * This is a variant of the Phalcon\Flash that immediately outputs any message * passed to it @@ -37,4 +30,5 @@ public function message(string $type, $message): ?string public function output(bool $remove = true) { } + } diff --git a/src/Phalcon/flash/Exception.php b/src/Phalcon/flash/Exception.php index 342d796a..6a123e85 100644 --- a/src/Phalcon/flash/Exception.php +++ b/src/Phalcon/flash/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Flash; /** diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php index ba35ac75..d5516aac 100644 --- a/src/Phalcon/flash/FlashInterface.php +++ b/src/Phalcon/flash/FlashInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Flash; /** @@ -59,4 +50,5 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; + } diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/flash/Session.php index b5670697..45557ab4 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/flash/Session.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Flash; -use Phalcon\Session\ManagerInterface as SessionInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Flash\AbstractFlash; +use Phalcon\Flash\Exception; +use Phalcon\Session\ManagerInterface; /** * Temporarily stores the messages in session, then messages can be printed in @@ -94,7 +88,8 @@ protected function setSessionMessages(array $messages): array * * @return \Phalcon\Session\ManagerInterface */ - public function getSessionService(): SessionInterface + public function getSessionService(): ManagerInterface { } + } diff --git a/src/Phalcon/forms/Exception.php b/src/Phalcon/forms/Exception.php index 58b003f6..b5778926 100644 --- a/src/Phalcon/forms/Exception.php +++ b/src/Phalcon/forms/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms; /** diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/forms/Form.php index 4d331de0..7d6699b8 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/forms/Form.php @@ -1,31 +1,30 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms; use Countable; use Iterator; use Phalcon\Di\Injectable; +use Phalcon\Di\DiInterface; +use Phalcon\Filter\FilterInterface; +use Phalcon\Forms\Exception; use Phalcon\Forms\Element\ElementInterface; use Phalcon\Html\Attributes; use Phalcon\Html\Attributes\AttributesInterface; use Phalcon\Messages\Messages; +use Phalcon\Tag; +use Phalcon\Validation; +use Phalcon\Validation\ValidationInterface; /** * This component allows to build forms using an object-oriented interface */ -class Form extends Injectable implements Countable, Iterator, AttributesInterface +class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\Attributes\AttributesInterface { - - protected $attributes; + /** + * @var Attributes | null + */ + protected $attributes = null; protected $data; @@ -89,9 +88,9 @@ public function add(\Phalcon\Forms\Element\ElementInterface $element, string $po /** * Binds data to the entity * - * @param array $data * @param object $entity * @param array $whitelist + * @param array $data * @return Form */ public function bind(array $data, $entity, $whitelist = null): Form @@ -145,6 +144,15 @@ public function getAction(): string { } + /** + * Get Form attributes collection + * + * @return \Phalcon\Html\Attributes + */ + public function getAttributes(): Attributes + { + } + /** * Returns the form elements added to the form * @@ -321,8 +329,8 @@ public function rewind() /** * Sets the form's action * - * @param string $action * @return Form + * @param string $action */ public function setAction(string $action): Form { @@ -338,6 +346,16 @@ public function setEntity($entity): Form { } + /** + * Set form attributes collection + * + * @param \Phalcon\Html\Attributes $attributes + * @return \Phalcon\Html\Attributes\AttributesInterface + */ + public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface + { + } + /** * Sets an option for the form * @@ -368,22 +386,4 @@ public function valid(): bool { } - /** - * Get Form attributes collection - * - * @return \Phalcon\Html\Attributes - */ - public function getAttributes(): Attributes - { - } - - /** - * Set form attributes collection - * - * @param \Phalcon\Html\Attributes $attributes - * @return \Phalcon\Html\Attributes\AttributesInterface - */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface - { - } } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index 709b6229..b59bdfda 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms; /** @@ -23,8 +14,8 @@ class Manager /** * Creates a form registering it in the forms manager * - * @param string $name * @param object $entity + * @param string $name * @return Form */ public function create(string $name, $entity = null): Form @@ -56,9 +47,10 @@ public function has(string $name): bool * * @param string $name * @param Form $form - * @return FormManager + * @return Manager */ - public function set(string $name, Form $form): FormManager + public function set(string $name, Form $form): Manager { } + } diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/forms/element/AbstractElement.php index 5497766a..62d002c7 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -1,23 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use InvalidArgumentException; use Phalcon\Forms\Form; +use Phalcon\Forms\Exception; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; +use Phalcon\Tag; +use Phalcon\Validation\ValidatorInterface; /** * This is a base class for form elements */ -abstract class AbstractElement implements ElementInterface +abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface { protected $attributes; @@ -91,8 +87,10 @@ public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] $validators + * @param \Phalcon\Validation\ValidatorInterface[] validators * @param bool $merge + * @param array $validators + * @param \Phalcon\Validation\ValidatorInterface [] validators * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface @@ -364,4 +362,5 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } + } diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index df600585..d51919cf 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Check * @@ -28,4 +22,5 @@ class Check extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index b810d56a..0126d5c4 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Component INPUT[type=date] for forms */ @@ -26,4 +20,5 @@ class Date extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/forms/element/ElementInterface.php index e7157ea8..bbf821e5 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/forms/element/ElementInterface.php @@ -1,18 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; use Phalcon\Forms\Form; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; +use Phalcon\Validation\ValidatorInterface; /** * Interface for Phalcon\Forms\Element classes @@ -39,9 +32,10 @@ public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): /** * Adds a group of validators * + * @param \Phalcon\Validation\ValidatorInterface[] * @param array $validators * @param bool $merge - * @param \Phalcon\Validation\ValidatorInterface[] + * @param \Phalcon\Validation\ValidatorInterface [] * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface; @@ -264,4 +258,5 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; + } diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index af36265a..873a220b 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Email * @@ -28,4 +22,5 @@ class Email extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index 581e43f1..db78a619 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Component INPUT[type=file] for forms */ @@ -26,4 +20,5 @@ class File extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index c33ba0fa..2e8e1bef 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Hidden * @@ -28,4 +22,5 @@ class Hidden extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 617403ab..74e821a4 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Numeric * @@ -28,4 +22,5 @@ class Numeric extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 0d2beb78..844718d5 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Password * @@ -28,4 +22,5 @@ class Password extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index 54e2352f..f8fc85a3 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Radio * @@ -28,4 +22,5 @@ class Radio extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index eb3ba6f2..dba15a30 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -1,16 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Forms\Element\AbstractElement; +use Phalcon\Tag\Select; +use Phalcon\Forms\Element\ElementInterface; + /** * Phalcon\Forms\Element\Select * @@ -25,9 +20,9 @@ class Select extends AbstractElement /** * Phalcon\Forms\Element constructor * - * @param string $name * @param object|array $options * @param array $attributes + * @param string $name */ public function __construct(string $name, $options = null, $attributes = null) { @@ -37,9 +32,9 @@ public function __construct(string $name, $options = null, $attributes = null) * Adds an option to the current options * * @param array|string $option - * @return Element + * @return \Phalcon\Forms\Element\ElementInterface */ - public function addOption($option): Element + public function addOption($option): ElementInterface { } @@ -66,9 +61,10 @@ public function render(array $attributes = array()): string * Set the choice's options * * @param array|object $options - * @return Element + * @return \Phalcon\Forms\Element\ElementInterface */ - public function setOptions($options): Element + public function setOptions($options): ElementInterface { } + } diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index 9a5d2f34..7324adfa 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Component INPUT[type=submit] for forms */ @@ -26,4 +20,5 @@ class Submit extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index 487f59b9..745e6bb0 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Phalcon\Forms\Element\Text * @@ -28,4 +22,5 @@ class Text extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index d1e8a300..6c8eda69 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Forms\Element; +use Phalcon\Tag; +use Phalcon\Forms\Element\AbstractElement; + /** * Component TEXTAREA for forms */ @@ -26,4 +20,5 @@ class TextArea extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index a7496798..1ac05dbb 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Helper; +use Phalcon\Helper\Exception; +use stdClass; + /** * This class offers quick array functions throughout the framework */ @@ -20,11 +14,10 @@ class Arr /** * Chunks an array into smaller arrays of a specified size. * + * @param array $collection + * @param int $size * @param bool $preserveKeys * - * @param array $collection - * @param int $size - * @param bool $preserveKeys * @return array */ final public static function chunk(array $collection, int $size, bool $preserveKeys = false): array @@ -35,10 +28,9 @@ final public static function chunk(array $collection, int $size, bool $preserveK * Returns the first element of the collection. If a callable is passed, the * element returned is the first that validates true * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return mixed */ final public static function first(array $collection, $method = null) @@ -49,10 +41,9 @@ final public static function first(array $collection, $method = null) * Returns the key of the first element of the collection. If a callable * is passed, the element returned is the first that validates true * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return mixed */ final public static function firstKey(array $collection, $method = null) @@ -62,10 +53,9 @@ final public static function firstKey(array $collection, $method = null) /** * Flattens an array up to the one level depth, unless `$deep` is set to `true` * + * @param array $collection * @param bool $deep * - * @param array $collection - * @param bool $deep * @return array */ final public static function flatten(array $collection, bool $deep = false): array @@ -78,19 +68,19 @@ final public static function flatten(array $collection, bool $deep = false): arr * @param array $collection * @param mixed $index * @param mixed $defaultValue + * @param string $cast * @return mixed */ - final public static function get(array $collection, $index, $defaultValue = null) + final public static function get(array $collection, $index, $defaultValue = null, string $cast = null) { } /** * Groups the elements of an array based on the passed callable * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return array */ final public static function group(array $collection, $method): array @@ -100,11 +90,10 @@ final public static function group(array $collection, $method): array /** * Helper method to get an array element or a default * + * @param array $collection * @param mixed $index * * return bool - * @param array $collection - * @param mixed $index * @return bool */ final public static function has(array $collection, $index): bool @@ -117,7 +106,6 @@ final public static function has(array $collection, $index): bool * * @param array $collection * - * @param array $collection * @return bool */ final public static function isUnique(array $collection): bool @@ -128,11 +116,10 @@ final public static function isUnique(array $collection): bool * Returns the last element of the collection. If a callable is passed, the * element returned is the first that validates true * + * @param array $collection * @param callable $method * * return mixed - * @param array $collection - * @param mixed $method * @return mixed */ final public static function last(array $collection, $method = null) @@ -143,10 +130,9 @@ final public static function last(array $collection, $method = null) * Returns the key of the last element of the collection. If a callable is * passed, the element returned is the first that validates true * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return mixed */ final public static function lastKey(array $collection, $method = null) @@ -156,12 +142,10 @@ final public static function lastKey(array $collection, $method = null) /** * Sorts a collection of arrays or objects by key * + * @param array $collection + * @param mixed $attribute * @param string $order * - * @param array $collection - * @param mixed $attribute - * @param string $order - * @param mixed $attr * @return array */ final public static function order(array $collection, $attribute, string $order = 'asc'): array @@ -171,10 +155,9 @@ final public static function order(array $collection, $attribute, string $order /** * Retrieves all of the values for a given key: * + * @param array $collection * @param string $element * - * @param array $collection - * @param string $element * @return array */ final public static function pluck(array $collection, string $element): array @@ -184,11 +167,10 @@ final public static function pluck(array $collection, string $element): array /** * Helper method to set an array element * - * @param mixed $index - * * @param array $collection * @param mixed $value * @param mixed $index + * * @return array */ final public static function set(array $collection, $value, $index = null): array @@ -198,10 +180,9 @@ final public static function set(array $collection, $value, $index = null): arra /** * Returns a new array with n elements removed from the right. * + * @param array $collection * @param int $elements * - * @param array $collection - * @param int $elements * @return array */ final public static function sliceLeft(array $collection, int $elements = 1): array @@ -211,10 +192,9 @@ final public static function sliceLeft(array $collection, int $elements = 1): ar /** * Returns a new array with the X elements from the right * + * @param array $collection * @param int $elements * - * @param array $collection - * @param int $elements * @return array */ final public static function sliceRight(array $collection, int $elements = 1): array @@ -227,7 +207,6 @@ final public static function sliceRight(array $collection, int $elements = 1): a * * @param array $collection * - * @param array $collection * @return array */ final public static function split(array $collection): array @@ -247,10 +226,9 @@ final public static function toObject(array $collection) * Returns true if the provided function returns true for all elements of * the collection, false otherwise. * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return bool */ final public static function validateAll(array $collection, $method): bool @@ -261,10 +239,9 @@ final public static function validateAll(array $collection, $method): bool * Returns true if the provided function returns true for at least one * element fo the collection, false otherwise. * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return bool */ final public static function validateAny(array $collection, $method): bool @@ -274,10 +251,9 @@ final public static function validateAny(array $collection, $method): bool /** * Helper method to filter the collection * + * @param array $collection * @param callable $method * - * @param array $collection - * @param mixed $method * @return array */ final private static function filterCollection(array $collection, $method = null): array @@ -288,13 +264,13 @@ final private static function filterCollection(array $collection, $method = null * White list filter by key: obtain elements of an array filtering * by the keys obtained from the elements of a whitelist * - * @param array $whiteList - * * @param array $collection * @param array $whiteList + * * @return array */ final public static function whiteList(array $collection, array $whiteList): array { } + } diff --git a/src/Phalcon/helper/Exception.php b/src/Phalcon/helper/Exception.php index cd7e73f8..308a77dc 100644 --- a/src/Phalcon/helper/Exception.php +++ b/src/Phalcon/helper/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Helper; /** diff --git a/src/Phalcon/helper/Fs.php b/src/Phalcon/helper/Fs.php index 94cbfbb2..16ae71f3 100644 --- a/src/Phalcon/helper/Fs.php +++ b/src/Phalcon/helper/Fs.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Helper; /** @@ -22,13 +13,13 @@ class Fs * PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character. * see https://bugs.php.net/bug.php?id=37738 * + * @param string $uri * @param string $suffix * - * @param string $uri - * @param mixed $suffix * @return string */ final public static function basename(string $uri, $suffix = null): string { } + } diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php index 6d933a62..23301aaf 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/helper/Number.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Helper; +use Phalcon\Helper\Exception; + /** * Phalcon\Helper\number * @@ -30,4 +23,5 @@ class Number final public static function between(int $value, int $from, int $to): bool { } + } diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/helper/Str.php index 23d0a880..317241ab 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/helper/Str.php @@ -1,16 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Helper; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Exception; +use RuntimeException; + /** * This class offers quick string functions throughout the framework */ @@ -46,10 +41,9 @@ class Str * echo Str::camelize("co_co-bon_go", "_-"); // CoCoBonGo * ``` * + * @param string $text * @param mixed $delimiter * - * @param string $text - * @param mixed $delimiter * @return string */ final public static function camelize(string $text, $delimiter = null): string @@ -72,12 +66,14 @@ final public static function camelize(string $text, $delimiter = null): string * echo $str; // /tmp/folder_1/folder_2/folder_3/ * ``` * - * @param string ...N - * * @param string $separator * @param string $a * @param string $b + * @param string ...N + * * @return string + * @param string ...N + * */ final public static function concat(): string { @@ -89,8 +85,8 @@ final public static function concat(): string * * @param string $string * - * @param string $text * @return int + * @param string $text */ final public static function countVowels(string $text): int { @@ -101,13 +97,12 @@ final public static function countVowels(string $text): int * of the string. Omit the upperRest parameter to keep the rest of the * string intact, or set it to true to convert to uppercase. * + * @param string $string + * @param bool $upperRest * @param string $encoding * - * @param string $text - * @param bool $upperRest - * @param string $encoding - * @param string $string * @return string + * @param string $text */ final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string { @@ -125,7 +120,6 @@ final public static function decapitalize(string $text, bool $upperRest = false, * * @param string $file * - * @param string $file * @return string */ final public static function dirFromFile(string $file): string @@ -144,7 +138,6 @@ final public static function dirFromFile(string $file): string * * @param string $directory * - * @param string $directory * @return string */ final public static function dirSeparator(string $directory): string @@ -174,12 +167,11 @@ final public static function dirSeparator(string $directory): string * ); * ``` * - * @param string $separator - * * @param string $text * @param string $leftDelimiter * @param string $rightDelimiter * @param string $separator + * * @return string */ final public static function dynamic(string $text, string $leftDelimiter = '{', string $rightDelimiter = '}', string $separator = '|'): string @@ -197,11 +189,10 @@ final public static function dynamic(string $text, string $leftDelimiter = '{', * echo Str::endsWith("Hello", "LLO"); // true * ``` * - * @param bool $ignoreCase - * * @param string $text * @param string $end - * @param bool $ignoreCase + * @param bool $ignoreCase + * * @return bool */ final public static function endsWith(string $text, string $end, bool $ignoreCase = true): bool @@ -212,11 +203,10 @@ final public static function endsWith(string $text, string $end, bool $ignoreCas * Returns the first string there is between the strings from the * parameter start and end. * - * @param string $end - * * @param string $text * @param string $start * @param string $end + * * @return string */ final public static function firstBetween(string $text, string $start, string $end): string @@ -235,7 +225,6 @@ final public static function firstBetween(string $text, string $start, string $e * * @param string $text * - * @param string $text * @return string */ final public static function humanize(string $text): string @@ -245,10 +234,9 @@ final public static function humanize(string $text): string /** * Lets you determine whether or not a string includes another string. * - * @param string $haystack - * * @param string $needle * @param string $haystack + * * @return bool */ final public static function includes(string $needle, string $haystack): bool @@ -266,10 +254,9 @@ final public static function includes(string $needle, string $haystack): bool * echo Str::increment("a_1"); // "a_2" * ``` * - * @param string $separator - * * @param string $text * @param string $separator + * * @return string */ final public static function increment(string $text, string $separator = '_'): string @@ -280,10 +267,9 @@ final public static function increment(string $text, string $separator = '_'): s * Compare two strings and returns true if both strings are anagram, * false otherwise. * - * @param string $second - * * @param string $first * @param string $second + * * @return bool */ final public static function isAnagram(string $first, string $second): bool @@ -293,10 +279,9 @@ final public static function isAnagram(string $first, string $second): bool /** * Returns true if the given string is lower case, false otherwise. * - * @param string $encoding - * * @param string $text * @param string $encoding + * * @return bool */ final public static function isLower(string $text, string $encoding = 'UTF-8'): bool @@ -308,7 +293,6 @@ final public static function isLower(string $text, string $encoding = 'UTF-8'): * * @param string $text * - * @param string $text * @return bool */ final public static function isPalindrome(string $text): bool @@ -318,10 +302,8 @@ final public static function isPalindrome(string $text): bool /** * Returns true if the given string is upper case, false otherwise. * - * @param string encoding - * * @param string $text - * @param string $encoding + * @param string $encoding * * @return bool */ final public static function isUpper(string $text, string $encoding = 'UTF-8'): bool @@ -336,10 +318,9 @@ final public static function isUpper(string $text, string $encoding = 'UTF-8'): * echo Phalcon\Helper\Str::lower("HELLO"); // hello * ``` * - * @param string $encoding - * * @param string $text * @param string $encoding + * * @return string */ final public static function lower(string $text, string $encoding = 'UTF-8'): string @@ -356,10 +337,9 @@ final public static function lower(string $text, string $encoding = 'UTF-8'): st * echo Str::random(Str::RANDOM_ALNUM); // "aloiwkqz" * ``` * + * @param int $type * @param int $length * - * @param int $type - * @param long $length * @return string */ final public static function random(int $type = 0, int $length = 8): string @@ -379,7 +359,6 @@ final public static function random(int $type = 0, int $length = 8): string * * @param string $text * - * @param string $text * @return string */ final public static function reduceSlashes(string $text): string @@ -397,11 +376,10 @@ final public static function reduceSlashes(string $text): string * echo Str::startsWith("Hello", "he"); // true * ``` * - * @param bool $ignoreCase - * * @param string $text * @param string $start - * @param bool $ignoreCase + * @param bool $ignoreCase + * * @return bool */ final public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool @@ -418,10 +396,9 @@ final public static function startsWith(string $text, string $start, bool $ignor * echo Str::uncamelize("CocoBongo", "-"); // coco-bongo * ``` * + * @param string $text * @param mixed $delimiter * - * @param string $text - * @param mixed $delimiter * @return string */ final public static function uncamelize(string $text, $delimiter = null): string @@ -440,7 +417,6 @@ final public static function uncamelize(string $text, $delimiter = null): string * * @param string $text * - * @param string $text * @return string */ final public static function underscore(string $text): string @@ -455,13 +431,13 @@ final public static function underscore(string $text): string * echo Phalcon\Helper\Str::upper("hello"); // HELLO * ``` * - * @param string $encoding - * * @param string $text * @param string $encoding + * * @return string */ final public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/html/Attributes.php index 6fa08f92..3be816dd 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/html/Attributes.php @@ -1,23 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html; use Phalcon\Collection; use Phalcon\Html\Attributes\RenderInterface; +use Phalcon\Tag; /** * This class helps to work with HTML Attributes */ -class Attributes extends Collection implements RenderInterface +class Attributes extends Collection implements \Phalcon\Html\Attributes\RenderInterface { /** @@ -37,4 +29,5 @@ public function render(): string public function __toString(): string { } + } diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/html/Breadcrumbs.php index a9f76db7..45586642 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/html/Breadcrumbs.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html; +use Phalcon\Di\DiInterface; + /** * Phalcon\Html\Breadcrumbs * @@ -127,4 +120,5 @@ public function render(): string public function toArray(): array { } + } diff --git a/src/Phalcon/html/Exception.php b/src/Phalcon/html/Exception.php index bcb3ee05..2a33e680 100644 --- a/src/Phalcon/html/Exception.php +++ b/src/Phalcon/html/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html; /** diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php index 74c85c30..a1d9e2b3 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/html/TagFactory.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html; +use Phalcon\Escaper; use Phalcon\Escaper\EscaperInterface; use Phalcon\Factory\AbstractFactory; @@ -20,7 +12,7 @@ class TagFactory extends AbstractFactory { /** - * @var + * @var EscaperInterface */ private $escaper; @@ -36,11 +28,9 @@ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $s } /** - * @param string name - * - * @throws Exception - * @param string $name + * @param string $name * * @return mixed + * @throws Exception */ public function newInstance(string $name) { @@ -52,4 +42,5 @@ public function newInstance(string $name) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/html/attributes/AttributesInterface.php b/src/Phalcon/html/attributes/AttributesInterface.php index c54e7b59..cc82778f 100644 --- a/src/Phalcon/html/attributes/AttributesInterface.php +++ b/src/Phalcon/html/attributes/AttributesInterface.php @@ -1,22 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ namespace Phalcon\Html\Attributes; use Phalcon\Html\Attributes; /** -* Phalcon\Html\Attributes\AttributesInterface -* -* Interface Phalcon\Html\Attributes\AttributesInterface -*/ + * Phalcon\Html\Attributes\AttributesInterface + * + * Interface Phalcon\Html\Attributes\AttributesInterface + */ interface AttributesInterface { @@ -34,4 +26,5 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; + } diff --git a/src/Phalcon/html/attributes/RenderInterface.php b/src/Phalcon/html/attributes/RenderInterface.php index f801f75b..4d1574b3 100644 --- a/src/Phalcon/html/attributes/RenderInterface.php +++ b/src/Phalcon/html/attributes/RenderInterface.php @@ -1,20 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ namespace Phalcon\Html\Attributes; /** -* Phalcon\Html\Attributes\RenderInterface -* -* Interface Phalcon\Html\Attributes\RenderInterface -*/ + * Phalcon\Html\Attributes\RenderInterface + * + * Interface Phalcon\Html\Attributes\RenderInterface + */ interface RenderInterface { @@ -24,4 +16,5 @@ interface RenderInterface * @return string */ public function render(): string; + } diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/html/helper/AbstractHelper.php index 80b525f5..d2b124f0 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/html/helper/AbstractHelper.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Exception; use Phalcon\Escaper\EscaperInterface; /** @@ -21,7 +13,7 @@ abstract class AbstractHelper { /** - * @var + * @var EscaperInterface */ protected $escaper; @@ -62,10 +54,8 @@ protected function renderElement(string $tag, array $attributes = array()): stri /** * Keeps all the attributes sorted - same order all the tome * - * @param array attributes - * * @param array $overrides - * @param array $attributes + * @param array $attributes * * @return array */ protected function orderAttributes(array $overrides, array $attributes): array @@ -92,4 +82,5 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 07cd5ed0..8f85c1d0 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Anchor * @@ -20,12 +13,13 @@ class Anchor extends AbstractHelper { /** - * @param string $href - * @param string $text - * @param array $attributes + * @param string $href The href tag + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * @return string */ public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php index c2db84cc..3ac958cf 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\AnchorRaw * @@ -20,12 +13,13 @@ class AnchorRaw extends AbstractHelper { /** - * @param string $href - * @param string $text - * @param array $attributes + * @param string $href The href tag + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * @return string */ public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Body.php b/src/Phalcon/html/helper/Body.php index 509a4054..17607c87 100644 --- a/src/Phalcon/html/helper/Body.php +++ b/src/Phalcon/html/helper/Body.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Body * @@ -20,10 +13,11 @@ class Body extends AbstractHelper { /** - * @param array $attributes + * @param array $attributes Any additional attributes * @return string */ public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/html/helper/Button.php index d0f61533..ff6584ed 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/html/helper/Button.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Button * @@ -20,11 +13,12 @@ class Button extends AbstractHelper { /** - * @param string $text - * @param array $attributes + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * @return string */ public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Close.php b/src/Phalcon/html/helper/Close.php index 77260bf9..ab43610c 100644 --- a/src/Phalcon/html/helper/Close.php +++ b/src/Phalcon/html/helper/Close.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; /** @@ -16,16 +7,16 @@ * * Creates a closing tag */ -class Close extends AbstractHelper +class Close extends \Phalcon\Html\Helper\AbstractHelper { /** * @param string $tag The tag * - * @param string $tag * @return string */ public function __invoke(string $tag): string { } + } diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/html/helper/Element.php index 19bf6439..4ff90fed 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/html/helper/Element.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Address * @@ -20,12 +13,13 @@ class Element extends AbstractHelper { /** - * @param string $tag - * @param string $text - * @param array $attributes + * @param string $tag The tag name + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * @return string */ public function __invoke(string $tag, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/ElementRaw.php b/src/Phalcon/html/helper/ElementRaw.php index 7b96489a..2f2c4660 100644 --- a/src/Phalcon/html/helper/ElementRaw.php +++ b/src/Phalcon/html/helper/ElementRaw.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; use Phalcon\Html\Exception; @@ -18,19 +9,19 @@ * * Creates an element raw */ -class ElementRaw extends AbstractHelper +class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper { /** + * @param string $tag The tag for the anchor + * @param string $text The text for the anchor * @param array $attributes Any additional attributes * - * @throws Exception - * @param string $tag The tag for the anchor - * @param string $text The text for the anchor - * @param array $attributes * @return string + * @throws Exception */ public function __invoke(string $tag, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/html/helper/Form.php index 2bd7d2ea..d5ca9c74 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/html/helper/Form.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\Form * @@ -20,10 +13,11 @@ class Form extends AbstractHelper { /** - * @param array $attributes + * @param array $attributes Any additional attributes * @return string */ public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Img.php b/src/Phalcon/html/helper/Img.php index 3d77205f..21521374 100644 --- a/src/Phalcon/html/helper/Img.php +++ b/src/Phalcon/html/helper/Img.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; use Phalcon\Html\Exception; @@ -18,18 +9,18 @@ * * Creates am img tag */ -class Img extends AbstractHelper +class Img extends \Phalcon\Html\Helper\AbstractHelper { /** + * @param string $src * @param array $attributes Any additional attributes * - * @throws Exception - * @param string $src - * @param array $attributes * @return string + * @throws Exception */ public function __invoke(string $src, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Label.php b/src/Phalcon/html/helper/Label.php index 849a72ed..d58997ac 100644 --- a/src/Phalcon/html/helper/Label.php +++ b/src/Phalcon/html/helper/Label.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; use Phalcon\Html\Exception; @@ -18,17 +9,17 @@ * * Creates a label */ -class Label extends AbstractHelper +class Label extends \Phalcon\Html\Helper\AbstractHelper { /** * @param array $attributes Any additional attributes * - * @throws Exception - * @param array $attributes * @return string + * @throws Exception */ public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/html/helper/TextArea.php index e78a792e..65848997 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/html/helper/TextArea.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Html\Helper; +use Phalcon\Html\Helper\AbstractHelper; + /** * Phalcon\Html\Helper\TextArea * @@ -20,11 +13,12 @@ class TextArea extends AbstractHelper { /** - * @param string $text - * @param array $attributes + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * @return string */ public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/http/Cookie.php index de13c767..8bdcb431 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/http/Cookie.php @@ -1,22 +1,20 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Crypt\CryptInterface; +use Phalcon\Crypt\Mismatch; +use Phalcon\Filter\FilterInterface; +use Phalcon\Http\Response\Exception; +use Phalcon\Http\Cookie\Exception; +use Phalcon\Session\ManagerInterface; /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie extends AbstractInjectionAware implements CookieInterface +class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInterface { protected $domain; @@ -285,4 +283,5 @@ public function useEncryption(bool $useEncryption): CookieInterface protected function assertSignKeyIsLongEnough(string $signKey) { } + } diff --git a/src/Phalcon/http/CookieInterface.php b/src/Phalcon/http/CookieInterface.php index 9d94fd42..afbf0c44 100644 --- a/src/Phalcon/http/CookieInterface.php +++ b/src/Phalcon/http/CookieInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; /** @@ -144,4 +135,5 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; + } diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/http/Request.php index 2c83177c..74036bd7 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/http/Request.php @@ -1,18 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\ManagerInterface; use Phalcon\Filter\FilterInterface; +use Phalcon\Http\Request\File; +use Phalcon\Http\Request\FileInterface; +use Phalcon\Http\Request\Exception; +use UnexpectedValueException; +use stdClass; /** * Encapsulates request information for easy and secure access from application @@ -21,7 +19,7 @@ * The request object is a simple value object that is passed between the * dispatcher and controller classes. It packages the HTTP request environment. * - *```php + * ```php * use Phalcon\Http\Request; * * $request = new Request(); @@ -38,9 +36,9 @@ * * // An array of languages the client accepts * $request->getLanguages(); - *``` + * ``` */ -class Request extends AbstractInjectionAware implements RequestInterface +class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInterface { private $filterService; @@ -857,4 +855,5 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } + } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index ba68f5c0..55c4de2e 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; +use Phalcon\Http\Request\FileInterface; +use stdClass; + /** * Interface for Phalcon\Http\Request */ @@ -504,4 +498,5 @@ public function isSoap(): bool; * @return bool */ public function isTrace(): bool; + } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 685b4630..03ef320f 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -1,38 +1,37 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; +use DateTime; +use DateTimeZone; +use Phalcon\Di; use Phalcon\Di\DiInterface; +use Phalcon\Helper\Fs; +use Phalcon\Http\Response\Exception; +use Phalcon\Http\Response\HeadersInterface; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Url\UrlInterface; +use Phalcon\Mvc\ViewInterface; +use Phalcon\Http\Response\Headers; use Phalcon\Di\InjectionAwareInterface; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Http\Response\CookiesInterface; -use Phalcon\Http\Response\HeadersInterface; /** * Part of the HTTP cycle is return responses to the clients. * Phalcon\HTTP\Response is the Phalcon component responsible to achieve this task. * HTTP responses are usually composed by headers and body. * - *```php + * ```php * $response = new \Phalcon\Http\Response(); * * $response->setStatusCode(200, "OK"); * $response->setContent("Hello"); * * $response->send(); - *``` + * ``` */ -class Response implements ResponseInterface, InjectionAwareInterface, EventsAwareInterface +class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { protected $container; @@ -485,4 +484,5 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } + } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index 98f28a57..00b19814 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http; +use DateTime; use Phalcon\Http\Response\HeadersInterface; /** @@ -101,8 +93,8 @@ public function setContentLength(int $contentLength): ResponseInterface; /** * Sets the response content-type mime, optionally the charset * - * @param string $contentType * @param string $charset + * @param string $contentType * @return ResponseInterface */ public function setContentType(string $contentType, $charset = null): ResponseInterface; @@ -193,4 +185,5 @@ public function sendCookies(): ResponseInterface; * @return bool|ResponseInterface */ public function sendHeaders(); + } diff --git a/src/Phalcon/http/cookie/Exception.php b/src/Phalcon/http/cookie/Exception.php index 6775aefc..17582b55 100644 --- a/src/Phalcon/http/cookie/Exception.php +++ b/src/Phalcon/http/cookie/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Cookie; /** diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php index 5a878bc4..807721c2 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -1,20 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; + /** * Common methods */ @@ -24,11 +13,10 @@ abstract class AbstractCommon /** * Returns a new instance having set the parameter * + * @param mixed $element * @param string $property * - * @param mixed $element - * @param string $property - * @return object + * @return mixed */ final protected function cloneInstance($element, string $property) { @@ -47,13 +35,13 @@ final protected function checkStringParameter($element) * Checks the element passed; assigns it to the property and returns a * clone of the object back * + * @param mixed $element * @param string $property * - * @param mixed $element - * @param string $property - * @return object + * @return mixed */ final protected function processWith($element, string $property) { } + } diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/http/message/AbstractMessage.php index f62f4598..5f19448c 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/http/message/AbstractMessage.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; use Phalcon\Collection; +use Phalcon\Http\Message\AbstractCommon; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\Stream; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -28,12 +17,12 @@ abstract class AbstractMessage extends AbstractCommon /** * Gets the body of the message. * - * @var + * @var StreamInterface */ protected $body; /** - * @var + * @var Collection */ protected $headers; @@ -64,7 +53,7 @@ abstract class AbstractMessage extends AbstractCommon /** * Gets the body of the message. * - * @return + * @return StreamInterface */ public function getBody() { @@ -104,7 +93,6 @@ public function getUri() * * @param string $name * - * @param mixed $name * @return array */ public function getHeader($name): array @@ -127,7 +115,6 @@ public function getHeader($name): array * * @param string $name * - * @param mixed $name * @return string */ public function getHeaderLine($name): string @@ -166,7 +153,6 @@ public function getHeaders(): array * * @param string $name * - * @param mixed $name * @return bool */ public function hasHeader($name): bool @@ -185,11 +171,13 @@ public function hasHeader($name): bool * immutability of the message, and MUST return an instance that has the * new header and/or value. * + * @param string $name * @param string|string[] $value * - * @param string $name + * @return self * @param mixed $value - * @return object + * @param string|string [] $value + * */ public function withAddedHeader($name, $value) { @@ -206,10 +194,9 @@ public function withAddedHeader($name, $value) * * @param StreamInterface $body * + * @return self * @throws InvalidArgumentException When the body is not valid. * - * @param \Psr\Http\Message\StreamInterface $body - * @return object */ public function withBody(\Psr\Http\Message\StreamInterface $body) { @@ -226,13 +213,15 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) * immutability of the message, and MUST return an instance that has the * new and/or updated header and value. * + * @param string $name * @param string|string[] $value * + * @return self * @throws InvalidArgumentException for invalid header names or values. * - * @param string $name * @param mixed $value - * @return object + * @param string|string [] $value + * */ public function withHeader($name, $value) { @@ -250,8 +239,7 @@ public function withHeader($name, $value) * * @param string $version * - * @param mixed $version - * @return object + * @return self */ public function withProtocolVersion($version) { @@ -268,8 +256,7 @@ public function withProtocolVersion($version) * * @param string $name * - * @param mixed $name - * @return object + * @return self */ public function withoutHeader($name) { @@ -282,8 +269,7 @@ public function withoutHeader($name) * * @param Collection $collection * - * @param \Phalcon\Collection $collection - * @return \Phalcon\Collection + * @return Collection */ final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection { @@ -293,9 +279,7 @@ final protected function checkHeaderHost(\Phalcon\Collection $collection): Colle * Check the name of the header. Throw exception if not valid * * @see http://tools.ietf.org/html/rfc7230#section-3.2 - * * @param mixed $name - * @param $name */ final protected function checkHeaderName($name) { @@ -345,9 +329,7 @@ final protected function checkHeaderName($name) * backslash octets occurring within that comment. * * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 - * * @param mixed $value - * @param $value */ final protected function checkHeaderValue($value) { @@ -356,8 +338,6 @@ final protected function checkHeaderValue($value) /** * Returns the header values checked for validity * - * @param $values - * * @param mixed $values * @return array */ @@ -370,7 +350,6 @@ final protected function getHeaderValue($values): array * * @param UriInterface $uri * - * @param \Psr\Http\Message\UriInterface $uri * @return string */ final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string @@ -382,8 +361,7 @@ final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string * * @param array $headers * - * @param array $headers - * @return \Phalcon\Collection + * @return Collection */ final protected function populateHeaderCollection(array $headers): Collection { @@ -392,11 +370,10 @@ final protected function populateHeaderCollection(array $headers): Collection /** * Set a valid stream * + * @param StreamInterface|resource|string $body * @param string $mode * - * @param StreamInterface|resource|string $body - * @param string $mode - * @return \Psr\Http\Message\StreamInterface + * @return StreamInterface */ final protected function processBody($body = 'php://memory', string $mode = 'r+b'): StreamInterface { @@ -405,8 +382,6 @@ final protected function processBody($body = 'php://memory', string $mode = 'r+b /** * Sets the headers * - * @param $headers - * * @param mixed $headers * @return \Phalcon\Collection */ @@ -419,10 +394,10 @@ final protected function processHeaders($headers): Collection * * @param string $protocol * - * @param mixed $protocol * @return string */ final protected function processProtocol($protocol = ''): string { } + } diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php index d1f00345..1c23411f 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Collection; +use Phalcon\Http\Message\AbstractMessage; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\Uri; use Psr\Http\Message\UriInterface; /** @@ -99,10 +89,9 @@ public function getRequestTarget(): string * * @param string $method * + * @return object * @throws InvalidArgumentException for invalid HTTP methods. * - * @param mixed $method - * @return object */ public function withMethod($method) { @@ -125,7 +114,6 @@ public function withMethod($method) * * @param mixed $requestTarget * - * @param mixed $requestTarget * @return object */ public function withRequestTarget($requestTarget) @@ -160,10 +148,9 @@ public function withRequestTarget($requestTarget) * * @see http://tools.ietf.org/html/rfc3986#section-4.3 * + * @param UriInterface $uri * @param bool $preserveHost * - * @param UriInterface $uri - * @param mixed $preserveHost * @return object */ public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) @@ -175,7 +162,6 @@ public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = fal * * @param string $method * - * @param mixed $method * @return string */ final protected function processMethod($method = ''): string @@ -187,10 +173,10 @@ final protected function processMethod($method = ''): string * * @param UriInterface|string|null $uri * - * @param mixed $uri - * @return \Psr\Http\Message\UriInterface + * @return UriInterface */ final protected function processUri($uri): UriInterface { } + } diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/http/message/Request.php index 7c1b5225..9d7c1e17 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/http/message/Request.php @@ -1,20 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Stream\Input; +use Phalcon\Http\Message\AbstractRequest; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -22,18 +11,19 @@ /** * PSR-7 Request */ -final class Request extends AbstractRequest implements RequestInterface +final class Request extends AbstractRequest implements \Psr\Http\Message\RequestInterface { /** * Request constructor. * - * @param string $method - * @param UriInterface|string|null $uri + * @param string $method + * @param UriInterface|string|null $uri * @param StreamInterface|resource|string $body - * @param array $headers + * @param array $headers */ public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } + } diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/http/message/RequestFactory.php index 4f59948f..8f5c83fa 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/http/message/RequestFactory.php @@ -1,40 +1,28 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; -use Psr\Http\Message\RequestFactoryInterface; +use Phalcon\Http\Message\Request; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\UriInterface; /** * PSR-17 RequestFactory */ -final class RequestFactory implements RequestFactoryInterface +final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface { /** * Create a new request. * + * @param string $method * @param UriInterface|string|null $uri * - * @param string $method - * @param mixed $uri - * @return \Psr\Http\Message\RequestInterface + * @return RequestInterface */ public function createRequest(string $method, $uri): RequestInterface { } + } diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/http/message/Response.php index c4376a09..f44b0772 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/http/message/Response.php @@ -1,26 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Helper\Number; +use Phalcon\Http\Message\AbstractMessage; +use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ResponseInterface; /** * PSR-7 Response */ -final class Response extends AbstractMessage implements ResponseInterface +final class Response extends AbstractMessage implements \Psr\Http\Message\ResponseInterface { /** * Gets the response reason phrase associated with the status code. @@ -82,8 +72,8 @@ public function getStatusCode(): int * Response constructor. * * @param string $body - * @param int $code - * @param array $headers + * @param int $code + * @param array $headers */ public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) { @@ -104,10 +94,9 @@ public function __construct($body = 'php://memory', int $code = 200, array $head * @see http://tools.ietf.org/html/rfc7231#section-6 * @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * + * @param int $code * @param string $reasonPhrase * - * @param int $code - * @param mixed $reasonPhrase * @return Response */ public function withStatus($code, $reasonPhrase = ''): Response @@ -150,4 +139,5 @@ private function getPhrases(): array private function processCode($code, $phrase = '') { } + } diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/http/message/ResponseFactory.php index 2bc307a1..74103186 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/http/message/ResponseFactory.php @@ -1,42 +1,30 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; -use Psr\Http\Message\ResponseFactoryInterface; +use Phalcon\Http\Message\Response; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ResponseFactoryInterface; /** * PSR-17 ResponseFactory */ -final class ResponseFactory implements ResponseFactoryInterface +final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterface { /** * Create a new response. * + * @param int $code The HTTP status code. Defaults to 200. * @param string $reasonPhrase The reason phrase to associate with the status * code in the generated response. If none is * provided, implementations MAY use the defaults * as suggested in the HTTP specification. * - * @param int $code The HTTP status code. Defaults to 200. - * @param string $reasonPhrase - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } + } diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/http/message/ServerRequest.php index 4d1ef8d7..8eb10226 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/http/message/ServerRequest.php @@ -1,22 +1,11 @@ -* -* For the full copyright and license information, please view the LICENSE.txt -* file that was distributed with this source code. -* -* Implementation of this file has been influenced by Zend Diactoros -* @link https://github.com/zendframework/zend-diactoros -* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md -*/ - namespace Phalcon\Http\Message; use Phalcon\Collection; +use Phalcon\Http\Message\AbstractRequest; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\Stream\Input; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -25,7 +14,7 @@ /** * PSR-7 ServerRequest */ -final class ServerRequest extends AbstractRequest implements ServerRequestInterface +final class ServerRequest extends AbstractRequest implements \Psr\Http\Message\ServerRequestInterface { /** * @var Collection @@ -178,16 +167,16 @@ public function getUploadedFiles(): array /** * ServerRequest constructor. * - * @param string $method + * @param string $method * @param UriInterface|string|null $uri - * @param array $serverParams - * @param StreamInterface|string $body - * @param array $headers - * @param array $cookies - * @param array $queryParams - * @param array $uploadFiles - * @param null|array|object $parsedBody - * @param string $protocol + * @param array $serverParams + * @param StreamInterface|string $body + * @param array $headers + * @param array $cookies + * @param array $queryParams + * @param array $uploadFiles + * @param null|array|object $parsedBody + * @param string $protocol */ public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') { @@ -203,10 +192,9 @@ public function __construct(string $method = 'GET', $uri = null, array $serverPa * This method obviates the need for a hasAttribute() method, as it allows * specifying a default value to return if the attribute is not found. * + * @param string $name * @param mixed|null $defaultValue * - * @param string $name - * @param mixed $defaultValue * @return mixed */ public function getAttribute($name, $defaultValue = null) @@ -238,10 +226,9 @@ public function getAttributes(): array * immutability of the message, and MUST return an instance that has the * updated attribute. * + * @param string $name * @param mixed $value * - * @param string $name - * @param mixed $value * @return ServerRequest */ public function withAttribute($name, $value): ServerRequest @@ -264,7 +251,6 @@ public function withAttribute($name, $value): ServerRequest * * @param array $cookies * - * @param array $cookies * @return ServerRequest */ public function withCookieParams(array $cookies): ServerRequest @@ -295,10 +281,9 @@ public function withCookieParams(array $cookies): ServerRequest * * @param array|object|null $data * + * @return ServerRequest * @throws InvalidArgumentException if an unsupported argument type is provided. * - * @param mixed $data - * @return ServerRequest */ public function withParsedBody($data): ServerRequest { @@ -324,7 +309,6 @@ public function withParsedBody($data): ServerRequest * * @param array $query * - * @param array $query * @return ServerRequest */ public function withQueryParams(array $query): ServerRequest @@ -340,10 +324,9 @@ public function withQueryParams(array $query): ServerRequest * * @param array $uploadedFiles * + * @return ServerRequest * @throws InvalidArgumentException if an invalid structure is provided. * - * @param array $uploadedFiles - * @return ServerRequest */ public function withUploadedFiles(array $uploadedFiles): ServerRequest { @@ -361,7 +344,6 @@ public function withUploadedFiles(array $uploadedFiles): ServerRequest * * @param string $name * - * @param mixed $name * @return ServerRequest */ public function withoutAttribute($name): ServerRequest @@ -376,4 +358,5 @@ public function withoutAttribute($name): ServerRequest private function checkUploadedFiles(array $files) { } + } diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php index 1df04b28..bb63e5bb 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -1,31 +1,22 @@ -* -* For the full copyright and license information, please view the LICENSE.txt -* file that was distributed with this source code. -* -* Implementation of this file has been influenced by Zend Diactoros -* @link https://github.com/zendframework/zend-diactoros -* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md -*/ - namespace Phalcon\Http\Message; use Phalcon\Collection; +use Phalcon\Helper\Arr; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\ServerRequest; +use Phalcon\Http\Message\UploadedFile; +use Phalcon\Http\Message\Uri; use Psr\Http\Message\ServerRequestFactoryInterface; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UriInterface; +use Psr\Http\Message\UploadedFileInterface; /** * PSR-17 ServerRequestFactory */ -class ServerRequestFactory implements ServerRequestFactoryInterface +class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInterface { /** @@ -47,10 +38,7 @@ class ServerRequestFactory implements ServerRequestFactoryInterface * which to seed the generated * request instance. * - * @param string $method - * @param mixed $uri - * @param array $serverParams - * @return \Psr\Http\Message\ServerRequestInterface + * @return ServerRequestInterface */ public function createServerRequest(string $method, $uri, array $serverParams = array()): ServerRequestInterface { @@ -62,18 +50,14 @@ public function createServerRequest(string $method, $uri, array $serverParams = * If any argument is not supplied, the corresponding superglobal value will * be used. * - * The ServerRequest created is then passed to the fromServer() method in - * order to marshal the request URI and headers. - * + * @param array $server $_SERVER superglobal + * @param array $get $_GET superglobal + * @param array $post $_POST superglobal + * @param array $cookies $_COOKIE superglobal * @param array $files $_FILES superglobal * + * @return ServerRequest * @see fromServer() - * @param array $server $_SERVER superglobal - * @param array $get $_GET superglobal - * @param array $post $_POST superglobal - * @param array $cookies $_COOKIE superglobal - * @param array $files - * @return \Phalcon\Http\Message\ServerRequest */ public function load(array $server = null, array $get = null, array $post = null, array $cookies = null, array $files = null): ServerRequest { @@ -91,10 +75,9 @@ protected function getHeaders() /** * Calculates the host and port from the headers or the server superglobal * + * @param Collection $server * @param Collection $headers * - * @param Collection $server - * @param \Phalcon\Collection $headers * @return array */ private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collection $headers): array @@ -106,7 +89,6 @@ private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collecti * * @param string $host * - * @param string $host * @return array */ private function calculateUriHostFromHeader(string $host): array @@ -119,7 +101,6 @@ private function calculateUriHostFromHeader(string $host): array * * @param Collection $server * - * @param \Phalcon\Collection $server * @return string */ private function calculateUriPath(\Phalcon\Collection $server): string @@ -131,7 +112,6 @@ private function calculateUriPath(\Phalcon\Collection $server): string * * @param Collection $server * - * @param \Phalcon\Collection $server * @return string */ private function calculateUriQuery(\Phalcon\Collection $server): string @@ -141,10 +121,9 @@ private function calculateUriQuery(\Phalcon\Collection $server): string /** * Calculates the scheme from the server variables * + * @param Collection $server * @param Collection $headers * - * @param Collection $server - * @param \Phalcon\Collection $headers * @return string */ private function calculateUriScheme(\Phalcon\Collection $server, \Phalcon\Collection $headers): string @@ -171,8 +150,6 @@ private function checkNullArray($source, array $super): array * @return UploadedFile * * @throws InvalidArgumentException If one of the elements is missing - * @param array $file - * @return \Phalcon\Http\Message\UploadedFile */ private function createUploadedFile(array $file): UploadedFile { @@ -181,12 +158,11 @@ private function createUploadedFile(array $file): UploadedFile /** * Returns a header * + * @param Collection $headers + * @param string $name * @param mixed|null $defaultValue * - * @param Collection $headers - * @param string $name - * @param mixed $defaultValue - * @return mixed + * @return mixed|string */ private function getHeader(\Phalcon\Collection $headers, string $name, $defaultValue = null) { @@ -199,8 +175,6 @@ private function getHeader(\Phalcon\Collection $headers, string $name, $defaultV * * @return array key/value cookie pairs. * - * @param string $cookieHeader - * @return array */ private function parseCookieHeader(string $cookieHeader): array { @@ -211,13 +185,23 @@ private function parseCookieHeader(string $cookieHeader): array * * @param Collection $server * - * @param \Phalcon\Collection $server - * @return \Phalcon\Collection + * @return Collection */ private function parseHeaders(\Phalcon\Collection $server): Collection { } + /** + * Parse the $_SERVER array amd check the server protocol. Raise an + * + * @param Collection $server The server variables + * + * @return string + */ + private function parseProtocol(\Phalcon\Collection $server): string + { + } + /** * Parse the $_SERVER array amd return it back after looking for the * authorization header @@ -225,8 +209,7 @@ private function parseHeaders(\Phalcon\Collection $server): Collection * @param array $server Either verbatim, or with an added * HTTP_AUTHORIZATION header. * - * @param array $server - * @return \Phalcon\Collection + * @return Collection */ private function parseServer(array $server): Collection { @@ -238,8 +221,7 @@ private function parseServer(array $server): Collection * * @param array $files * - * @param array $files - * @return \Phalcon\Collection + * @return Collection */ private function parseUploadedFiles(array $files): Collection { @@ -248,13 +230,13 @@ private function parseUploadedFiles(array $files): Collection /** * Calculates the Uri from the server superglobal or the headers * + * @param Collection $server * @param Collection $headers * - * @param Collection $server - * @param \Phalcon\Collection $headers - * @return \Phalcon\Http\Message\Uri + * @return Uri */ private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri { } + } diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/http/message/Stream.php index 22b0fd73..31518982 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/http/message/Stream.php @@ -1,26 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Helper\Arr; +use Exception; use Psr\Http\Message\StreamInterface; +use RuntimeException; /** * PSR-7 Stream */ -class Stream implements StreamInterface +class Stream implements \Psr\Http\Message\StreamInterface { /** * @var resource | null @@ -32,16 +22,11 @@ class Stream implements StreamInterface */ protected $stream; - /** - * @var bool - */ - protected $warning = false; - /** * Stream constructor. * - * @param mixed $stream + * @param mixed $stream * @param string $mode */ public function __construct($stream, string $mode = 'rb') @@ -85,7 +70,7 @@ public function close() * * After the stream has been detached, the stream is in an unusable state. * - * @return resource|null + * @return resource | null */ public function detach() { @@ -117,7 +102,6 @@ public function getContents(): string * * @param mixed|null $key * - * @param mixed $key * @return array|mixed|null */ public function getMetadata($key = null) @@ -165,7 +149,6 @@ public function isWritable(): bool * * @param int $length * - * @param mixed $length * @return string */ public function read($length): string @@ -195,7 +178,7 @@ public function seek($offset, $whence = 0) /** * Sets the stream - existing instance * - * @param mixed $stream + * @param mixed $stream * @param string $mode */ public function setStream($stream, string $mode = 'rb') @@ -216,7 +199,6 @@ public function tell(): int * * @param string $data * - * @param mixed $data * @return int */ public function write($data): int @@ -250,4 +232,5 @@ private function checkSeekable() private function checkWritable() { } + } diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/http/message/StreamFactory.php index da6b8b0c..41b548ea 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/http/message/StreamFactory.php @@ -1,27 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Stream; +use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; /** * PSR-17 StreamFactory */ -final class StreamFactory implements StreamFactoryInterface +final class StreamFactory implements \Psr\Http\Message\StreamFactoryInterface { /** @@ -31,8 +20,7 @@ final class StreamFactory implements StreamFactoryInterface * * @param string $content String content with which to populate the stream. * - * @param string $content - * @return \Psr\Http\Message\StreamInterface + * @return StreamInterface */ public function createStream(string $content = ''): StreamInterface { @@ -51,9 +39,7 @@ public function createStream(string $content = ''): StreamInterface * @param string $mode The mode with which to open the underlying * filename/stream. * - * @param string $filename - * @param string $mode - * @return \Psr\Http\Message\StreamInterface + * @return StreamInterface */ public function createStreamFromFile(string $filename, string $mode = 'r+b'): StreamInterface { @@ -70,4 +56,5 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St public function createStreamFromResource($phpResource): StreamInterface { } + } diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/http/message/UploadedFile.php index 7a8a81fc..f401119f 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/http/message/UploadedFile.php @@ -1,21 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Helper\Number; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\Stream; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; use RuntimeException; @@ -23,7 +14,7 @@ /** * PSR-7 UploadedFile */ -final class UploadedFile implements UploadedFileInterface +final class UploadedFile implements \Psr\Http\Message\UploadedFileInterface { /** * If the file has already been moved, we hold that status here @@ -169,10 +160,10 @@ public function getSize(): ?int * UploadedFile constructor. * * @param StreamInterface|string|null $stream - * @param int|null $size - * @param int $error - * @param string|null $clientFilename - * @param string|null $clientMediaType + * @param int|null $size + * @param int $error + * @param string|null $clientFilename + * @param string|null $clientMediaType */ public function __construct($stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null) { @@ -190,8 +181,8 @@ public function __construct($stream, int $size = null, int $error = 0, string $c * If the moveTo() method has been called previously, this method MUST * raise an exception. * + * @return StreamInterface Stream representation of the uploaded file. * @throws RuntimeException in cases when no stream is available or can be created. - * @return mixed */ public function getStream() { @@ -230,7 +221,6 @@ public function getStream() * @throws InvalidArgumentException if the $targetPath specified is invalid. * @throws RuntimeException on any error during the move operation, or on * the second or subsequent call to the method. - * @param mixed $targetPath */ public function moveTo($targetPath) { @@ -249,7 +239,7 @@ private function checkError(int $error) * Checks the passed error code and if not in the range throws an exception * * @param StreamInterface|resource|string $stream - * @param int $error + * @param int $error */ private function checkStream($stream, int $error) { @@ -260,7 +250,6 @@ private function checkStream($stream, int $error) * * @param int $error * - * @param int $error * @return string */ private function getErrorDescription(int $error): string @@ -275,4 +264,5 @@ private function getErrorDescription(int $error): string private function storeFile(string $targetPath) { } + } diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/http/message/UploadedFileFactory.php index 8234c89c..5d58410f 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/http/message/UploadedFileFactory.php @@ -1,28 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Http\Message\UploadedFile; use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileFactoryInterface; use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; /** * PSR-17 UploadedFileFactory */ -final class UploadedFileFactory implements UploadedFileFactoryInterface +final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactoryInterface { /** @@ -36,17 +24,16 @@ final class UploadedFileFactory implements UploadedFileFactoryInterface * * @param StreamInterface $stream The underlying stream representing the * uploaded file content. + * @param int $size The size of the file in bytes. + * @param int $error The PHP file upload error. + * @param string $clientFilename The filename as provided by the client, if any. * @param string $clientMediaType The media type as provided by the client, if any. * * @throws \InvalidArgumentException If the file resource is not readable. - * @param \Psr\Http\Message\StreamInterface $stream - * @param int $size The size of the file in bytes. - * @param int $error The PHP file upload error. - * @param string $clientFilename The filename as provided by the client, if any. - * @param string $clientMediaType * @return \Psr\Http\Message\UploadedFileInterface */ public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } + } diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/http/message/Uri.php index 74833d9d..0245153b 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/http/message/Uri.php @@ -1,27 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\AbstractCommon; use Psr\Http\Message\UriInterface; /** * PSR-7 Uri */ -final class Uri extends AbstractCommon implements UriInterface +final class Uri extends AbstractCommon implements \Psr\Http\Message\UriInterface { /** * Returns the fragment of the URL @@ -213,7 +203,7 @@ public function getAuthority(): string * The trailing "@" character is not part of the user information and MUST * NOT be added. * - * @return string + * @return string The URI user information, in "username[:password]" format. */ public function getUserInfo(): string { @@ -232,7 +222,6 @@ public function getUserInfo(): string * * @param string $fragment * - * @param mixed $fragment * @return Uri */ public function withFragment($fragment): Uri @@ -259,9 +248,8 @@ public function withFragment($fragment): Uri * * @param string $path * - * @throws InvalidArgumentException for invalid paths. - * @param mixed $path * @return Uri + * @throws InvalidArgumentException for invalid paths. */ public function withPath($path): Uri { @@ -281,9 +269,8 @@ public function withPath($path): Uri * * @param int|null $port * - * @throws InvalidArgumentException for invalid ports. - * @param mixed $port * @return Uri + * @throws InvalidArgumentException for invalid ports. */ public function withPort($port): Uri { @@ -302,9 +289,8 @@ public function withPort($port): Uri * * @param string $query * - * @throws InvalidArgumentException for invalid query strings. - * @param mixed $query * @return Uri + * @throws InvalidArgumentException for invalid query strings. */ public function withQuery($query): Uri { @@ -323,10 +309,9 @@ public function withQuery($query): Uri * * @param string $scheme * + * @return Uri * @throws InvalidArgumentException for invalid schemes. * @throws InvalidArgumentException for unsupported schemes. - * @param mixed $scheme - * @return Uri */ public function withScheme($scheme): Uri { @@ -335,10 +320,9 @@ public function withScheme($scheme): Uri /** * Return an instance with the specified user information. * + * @param string $user * @param string|null $password * - * @param string $user - * @param mixed $password * @return Uri */ public function withUserInfo($user, $password = null): Uri @@ -355,10 +339,9 @@ public function withUserInfo($user, $password = null): Uri * * @param string $host * + * @return Uri * @throws InvalidArgumentException for invalid hostnames. * - * @param mixed $host - * @return Uri */ public function withHost($host): Uri { @@ -368,11 +351,10 @@ public function withHost($host): Uri * If the value passed is empty it returns it prefixed and suffixed with * the passed parameters * - * @param string $suffix - * * @param string $value * @param string $prefix * @param string $suffix + * * @return string */ private function checkValue(string $value, string $prefix = '', string $suffix = ''): string @@ -394,7 +376,6 @@ private function checkValue(string $value, string $prefix = '', string $suffix = * * @param string $fragment * - * @param string $fragment * @return string */ private function filterFragment(string $fragment): string @@ -426,8 +407,7 @@ private function filterFragment(string $fragment): string * * @param string $path * - * @param string $path - * @return string + * @return string The URI path. */ private function filterPath(string $path): string { @@ -436,10 +416,9 @@ private function filterPath(string $path): string /** * Checks the port. If it is a standard one (80,443) then it returns null * - * @param $port + * @param int|null $port * - * @param mixed $port - * @return int + * @return int|null */ private function filterPort($port): int { @@ -464,8 +443,7 @@ private function filterPort($port): int * * @param string $query * - * @param string $query - * @return string + * @return string The URI query string. */ private function filterQuery(string $query): string { @@ -476,7 +454,6 @@ private function filterQuery(string $query): string * * @param string $scheme * - * @param string $scheme * @return string */ private function filterScheme(string $scheme): string @@ -486,10 +463,10 @@ private function filterScheme(string $scheme): string /** * @param string $element * - * @param string $element * @return array */ private function splitQueryValue(string $element): array { } + } diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/http/message/UriFactory.php index 568410a1..affe126f 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/http/message/UriFactory.php @@ -1,27 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message; use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface; +use Phalcon\Http\Message\Uri; /** * PSR-17 UriFactory */ -final class UriFactory implements UriFactoryInterface +final class UriFactory implements \Psr\Http\Message\UriFactoryInterface { /** @@ -34,4 +22,5 @@ final class UriFactory implements UriFactoryInterface public function createUri(string $uri = ''): UriInterface { } + } diff --git a/src/Phalcon/http/message/exception/InvalidArgumentException.php b/src/Phalcon/http/message/exception/InvalidArgumentException.php index 91f77fc1..d4a8f6ba 100644 --- a/src/Phalcon/http/message/exception/InvalidArgumentException.php +++ b/src/Phalcon/http/message/exception/InvalidArgumentException.php @@ -1,4 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -70,7 +57,6 @@ public function __toString(): string * * @param int $length * - * @param int $length * @return string */ public function getContents(int $length = -1): string @@ -91,10 +77,10 @@ public function isWritable(): bool * * @param int $length * - * @param mixed $length * @return string */ public function read($length): string { } + } diff --git a/src/Phalcon/http/message/stream/Memory.php b/src/Phalcon/http/message/stream/Memory.php index d064f585..42e6f127 100644 --- a/src/Phalcon/http/message/stream/Memory.php +++ b/src/Phalcon/http/message/stream/Memory.php @@ -1,18 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -35,4 +22,5 @@ class Memory extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/http/message/stream/Temp.php b/src/Phalcon/http/message/stream/Temp.php index a741f786..49c23084 100644 --- a/src/Phalcon/http/message/stream/Temp.php +++ b/src/Phalcon/http/message/stream/Temp.php @@ -1,18 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - * - * Implementation of this file has been influenced by Zend Diactoros - * @link https://github.com/zendframework/zend-diactoros - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md - */ - namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -35,4 +22,5 @@ class Temp extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/http/request/Exception.php b/src/Phalcon/http/request/Exception.php index 31fe7927..9e91a792 100644 --- a/src/Phalcon/http/request/Exception.php +++ b/src/Phalcon/http/request/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Request; /** diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/http/request/File.php index 29566fd4..231d2e45 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/http/request/File.php @@ -1,22 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Request; +use Phalcon\Http\Request\FileInterface; + /** * Phalcon\Http\Request\File * * Provides OO wrappers to the $_FILES superglobal * - *```php + * ```php * use Phalcon\Mvc\Controller; * * class PostsController extends Controller @@ -32,9 +25,9 @@ * } * } * } - *``` + * ``` */ -class File implements FileInterface +class File implements \Phalcon\Http\Request\FileInterface { /** * @var string|null @@ -162,4 +155,5 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } + } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 63f39b41..69f37a10 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Request; /** * Phalcon\Http\Request\FileInterface * * Interface for Phalcon\Http\Request\File - * */ interface FileInterface { @@ -63,4 +53,5 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; + } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 16798e8c..460d2193 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -1,18 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Response; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\CookieInterface; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Http\Cookie\Exception; /** * Phalcon\Http\Response\Cookies @@ -53,7 +47,7 @@ * * // The `$key' MUST be at least 32 characters long and generated using a * // cryptographically secure pseudo random generator. - * $key = "#1dj8$=dp?.ak//j1V$~%*0XaK\xb1\x8d\xa9\x98\x054t7w!z%C*F-Jk\x98\x05\\\x5c"; + * $key = "#1dj8$=dp?.ak//j1V$~%0XaK\xb1\x8d\xa9\x98\x054t7w!z%CF-Jk\x98\x05\\\x5c"; * * $cookies->setSignKey($key); * @@ -62,7 +56,7 @@ * ); * ``` */ -class Cookies extends AbstractInjectionAware implements CookiesInterface +class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\CookiesInterface { protected $cookies = array(); @@ -217,4 +211,5 @@ public function setSignKey(string $signKey = null): CookieInterface public function useEncryption(bool $useEncryption): CookiesInterface { } + } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index 841d459e..ea1910f3 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Response; use Phalcon\Http\CookieInterface; @@ -88,4 +79,5 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; + } diff --git a/src/Phalcon/http/response/Exception.php b/src/Phalcon/http/response/Exception.php index ab723a39..fd5fcc03 100644 --- a/src/Phalcon/http/response/Exception.php +++ b/src/Phalcon/http/response/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Response; /** diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 26de8a59..91bc27d8 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -1,22 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Response; +use Phalcon\Http\Response\HeadersInterface; + /** * Phalcon\Http\Response\Headers * * This class is a bag to manage the response headers */ -class Headers implements HeadersInterface +class Headers implements \Phalcon\Http\Response\HeadersInterface { protected $headers = array(); @@ -97,4 +90,5 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } + } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index 8a7e218e..a2b439a8 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Response; /** @@ -61,4 +52,5 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); + } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php index 264df34b..d031fdc2 100644 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Server; use Psr\Http\Message\ResponseInterface; @@ -23,7 +14,7 @@ * by acting on the request, generating the response, or forwarding the * request to a subsequent middleware and possibly acting on its response. */ -abstract class AbstractMiddleware implements MiddlewareInterface +abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterface { /** @@ -38,4 +29,5 @@ abstract class AbstractMiddleware implements MiddlewareInterface * @return \Psr\Http\Message\ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; + } diff --git a/src/Phalcon/http/server/AbstractRequestHandler.php b/src/Phalcon/http/server/AbstractRequestHandler.php index 8fb30df7..7e4b2131 100644 --- a/src/Phalcon/http/server/AbstractRequestHandler.php +++ b/src/Phalcon/http/server/AbstractRequestHandler.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Http\Server; use Psr\Http\Message\ResponseInterface; @@ -21,7 +12,7 @@ * An HTTP request handler process an HTTP request in order to produce an * HTTP response. */ -abstract class AbstractRequestHandler implements RequestHandlerInterface +abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandlerInterface { /** @@ -33,4 +24,5 @@ abstract class AbstractRequestHandler implements RequestHandlerInterface * @return \Psr\Http\Message\ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; + } diff --git a/src/Phalcon/image/Enum.php b/src/Phalcon/image/Enum.php index deab9c3d..fcd64fb1 100644 --- a/src/Phalcon/image/Enum.php +++ b/src/Phalcon/image/Enum.php @@ -1,5 +1,7 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Image; +use Phalcon\Config; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; use Phalcon\Image\Adapter\AdapterInterface; /** @@ -58,4 +51,5 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } + } diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/image/adapter/AbstractAdapter.php index 9738f830..7fa4b048 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/image/adapter/AbstractAdapter.php @@ -1,27 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Image\Adapter; use Phalcon\Image\Enum; +use Phalcon\Image\Exception; /** * Phalcon\Image\Adapter * * All image adapters must use this class */ -abstract class AbstractAdapter implements AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { - protected static $checked = false; + static protected $checked = false; protected $file; @@ -159,8 +151,8 @@ public function flip(int $direction): AdapterInterface * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. * @return AbstractAdapter @@ -283,4 +275,5 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } + } diff --git a/src/Phalcon/image/adapter/AdapterInterface.php b/src/Phalcon/image/adapter/AdapterInterface.php index 0422bf22..a938d689 100644 --- a/src/Phalcon/image/adapter/AdapterInterface.php +++ b/src/Phalcon/image/adapter/AdapterInterface.php @@ -1,5 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Image\Adapter; -use Imagick as ImagicNative; +use Phalcon\Image\Enum; +use Phalcon\Image\Adapter\AbstractAdapter; +use Phalcon\Image\Exception; /** * Phalcon\Image\Adapter\Imagick * * Image manipulation support. Allows images to be resized, cropped, etc. * - *```php + * ```php * $image = new \Phalcon\Image\Adapter\Imagick("upload/test.jpg"); * * $image->resize(200, 200)->rotate(90)->crop(100, 100); * * if ($image->save()) { * echo "success"; + * * } - *``` + * ``` */ class Imagick extends AbstractAdapter { - protected static $checked = false; + static protected $checked = false; - protected static $version = 0; + static protected $version = 0; /** @@ -69,7 +63,7 @@ public static function check(): bool * * @return \Imagick */ - public function getInternalImInstance(): ImagicNative + public function getInternalImInstance(): \Imagick { } @@ -130,8 +124,8 @@ protected function processFlip(int $direction) * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ @@ -245,4 +239,5 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } + } diff --git a/src/Phalcon/loader/Exception.php b/src/Phalcon/loader/Exception.php index aa24bf20..c8bdf86b 100644 --- a/src/Phalcon/loader/Exception.php +++ b/src/Phalcon/loader/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Loader; /** diff --git a/src/Phalcon/logger/AdapterFactory.php b/src/Phalcon/logger/AdapterFactory.php index 1b27539a..4027925b 100644 --- a/src/Phalcon/logger/AdapterFactory.php +++ b/src/Phalcon/logger/AdapterFactory.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger; /** diff --git a/src/Phalcon/logger/Item.php b/src/Phalcon/logger/Item.php index a1d741cf..33d11398 100644 --- a/src/Phalcon/logger/Item.php +++ b/src/Phalcon/logger/Item.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger; /** * Phalcon\Logger\Item * * Represents each item in a logging transaction - * */ class Item { @@ -104,4 +94,5 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } + } diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php index eb09ef52..6b00d2ed 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/logger/LoggerFactory.php @@ -1,20 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger; +use Phalcon\Config; +use Phalcon\Helper\Arr; use Phalcon\Logger; +use Phalcon\Logger\AdapterFactory; /** - * PhalconNG\Logger\LoggerFactory + * Phalcon\Logger\LoggerFactory * * Logger factory */ @@ -46,13 +40,13 @@ public function load($config) /** * Returns a Logger object * + * @param string $name * @param array $adapters * - * @param string $name - * @param array $adapters - * @return \Phalcon\Logger + * @return Logger */ public function newInstance(string $name, array $adapters = array()): Logger { } + } diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/logger/adapter/AbstractAdapter.php index 8fd0ae1b..4ba13c80 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/logger/adapter/AbstractAdapter.php @@ -1,5 +1,13 @@ + * @var FormatterInterface */ protected $formatter; @@ -120,4 +123,5 @@ public function rollback(): AdapterInterface public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } + } diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php index 271da4f5..a0d86989 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Adapter; use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; /** * Phalcon\Logger\AdapterInterface @@ -78,4 +70,5 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; + } diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 8a3942f6..16a4309e 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -1,31 +1,24 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Adapter\Noop * * Adapter to store logs in plain text files * - *```php + * ```php * $logger = new \Phalcon\Logger\Adapter\Noop(); * * $logger->log(\Phalcon\Logger::ERROR, "This is an error"); * $logger->error("This is another error"); * * $logger->close(); - *``` + * ``` */ -class Noop extends AbstractAdapter +class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter { /** @@ -45,4 +38,5 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 20845ab0..ea45f4a0 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -1,22 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Adapter; +use Phalcon\Logger\Exception; +use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; +use UnexpectedValueException; + /** * Phalcon\Logger\Adapter\Stream * * Adapter to store logs in plain text files * - *```php + * ```php * $logger = new \Phalcon\Logger\Adapter\Stream("app/logs/test.log"); * * $logger->log("This is a message"); @@ -24,9 +21,9 @@ * $logger->error("This is another error"); * * $logger->close(); - *``` + * ``` */ -class Stream extends AbstractAdapter +class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter { /** * Stream handler resource @@ -93,4 +90,5 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index 07983548..a6b7ec83 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -1,16 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Adapter; +use LogicException; +use Phalcon\Helper\Arr; +use Phalcon\Logger; +use Phalcon\Logger\Adapter; +use Phalcon\Logger\Exception; +use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Adapter\Syslog * @@ -32,9 +31,9 @@ * $logger->log("This is a message"); * $logger->log(Logger::ERROR, "This is an error"); * $logger->error("This is another error"); - *``` + * ``` */ -class Syslog extends AbstractAdapter +class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter { /** * Name of the default formatter class @@ -101,4 +100,5 @@ public function process(\Phalcon\Logger\Item $item) private function logLevelToSyslog(string $level): int { } + } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php index 7f38d5d2..1d5398ff 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -1,5 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\FormatterInterface * @@ -26,4 +19,5 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); + } diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index 763eb1b7..2634cff6 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Formatter\AbstractFormatter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Formatter\Json * @@ -62,4 +56,5 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index 6de4eb39..85e90ba5 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Formatter; use Phalcon\Logger\Formatter\Formatter; +use Phalcon\Logger\Item; /** * Phalcon\Logger\Formatter\Line * * Formats messages using an one-line string */ -class Line extends AbstractFormatter +class Line extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Default date format @@ -90,4 +82,5 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 9f81ae7a..4b2543b0 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Formatter\AbstractFormatter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Formatter\Syslog * @@ -28,4 +22,5 @@ class Syslog extends AbstractFormatter public function format(\Phalcon\Logger\Item $item): array { } + } diff --git a/src/Phalcon/messages/Exception.php b/src/Phalcon/messages/Exception.php index f1cab232..bca86886 100644 --- a/src/Phalcon/messages/Exception.php +++ b/src/Phalcon/messages/Exception.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Messages; /** * Phalcon\Validation\Exception * - * Exceptions thrown in Phalcon\Messages\* classes will use this class + * Exceptions thrown in Phalcon\Messages\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index f71cefa1..c68ea866 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Messages; use JsonSerializable; +use Phalcon\Messages\MessageInterface; /** * Phalcon\Messages\Message * * Stores a message from various components */ -class Message implements MessageInterface, JsonSerializable +class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable { /** * @var int @@ -161,4 +153,5 @@ public function setMetaData(array $metaData): MessageInterface public function setType(string $type): MessageInterface { } + } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php index f3cf57b1..84b7c7e6 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/messages/MessageInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Messages; +use Phalcon\Messages\Message; + /** * Phalcon\Messages\MessageInterface * @@ -100,4 +93,5 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; + } diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/messages/Messages.php index a19585b4..c4ff4e69 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/messages/Messages.php @@ -1,25 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Messages; use ArrayAccess; use Countable; use Iterator; use JsonSerializable; +use Phalcon\Messages\Message; +use Phalcon\Messages\Exception; +use Phalcon\Messages\MessageInterface; /** * Represents a collection of messages */ -class Messages implements ArrayAccess, Countable, Iterator, JsonSerializable +class Messages implements \ArrayAccess, \Countable, \Iterator, \JsonSerializable { /** * @var int @@ -63,7 +57,9 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message) * $messages->appendMessages($messagesArray); * ``` * - * @param \Phalcon\Messages\MessageInterface[] $messages + * @param \Phalcon\Messages\MessageInterface[] messages + * @param mixed $messages + * @param \Phalcon\Messages\MessageInterface [] messages */ public function appendMessages($messages) { @@ -167,8 +163,8 @@ public function offsetGet($index) * $messages[0] = new \Phalcon\Messages\Message("This is a message"); * ``` * - * @param mixed $index * @param \Phalcon\Messages\Message $message + * @param mixed $index */ public function offsetSet($index, $message) { @@ -202,4 +198,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 0547ac58..c6cd9c99 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -1,17 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Closure; use Phalcon\Application\AbstractApplication; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ViewInterface; +use Phalcon\Mvc\RouterInterface; +use Phalcon\Http\ResponseInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\DispatcherInterface; +use Phalcon\Mvc\Application\Exception; +use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Mvc\ModuleDefinitionInterface; /** * Phalcon\Mvc\Application @@ -20,23 +21,23 @@ * every component needed and integrating it with the rest to allow the MVC * pattern to operate as desired. * - *```php + * ```php * use Phalcon\Mvc\Application; * * class MyApp extends Application * { - * /** - * * Register the services here to make them general or register - * * in the ModuleDefinition to make them module-specific - * *\/ + * / + * Register the services here to make them general or register + * in the ModuleDefinition to make them module-specific + * \/ * protected function registerServices() * { * * } * - * /** - * * This method registers all the modules in the application - * *\/ + * / + * This method registers all the modules in the application + * \/ * public function main() * { * $this->registerModules( @@ -57,7 +58,7 @@ * $application = new MyApp(); * * $application->main(); - *``` + * ``` */ class Application extends AbstractApplication { @@ -111,4 +112,5 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } + } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index 7d24b930..fa83767b 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; use Phalcon\Di\Injectable; @@ -24,7 +15,7 @@ * interrogating the models for data, and passing that data on to the views for * presentation. * - *```php + * ```php * - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; /** diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index 60825b0d..39486ecd 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -1,17 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; -use Phalcon\Dispatcher\AbstractDispatcher as BaseDispatcher; +use Phalcon\Mvc\DispatcherInterface; +use Phalcon\Mvc\Dispatcher\Exception; +use Phalcon\Events\ManagerInterface; +use Phalcon\Http\ResponseInterface; +use Phalcon\Mvc\ControllerInterface; +use Phalcon\Dispatcher\AbstractDispatcher; /** * Dispatching is the process of taking the request object, extracting the @@ -19,7 +15,7 @@ * in it, and then instantiating a controller and calling an action of that * controller. * - *```php + * ```php * $di = new \Phalcon\Di(); * * $dispatcher = new \Phalcon\Mvc\Dispatcher(); @@ -31,9 +27,9 @@ * $dispatcher->setParams([]); * * $controller = $dispatcher->dispatch(); - *``` + * ``` */ -class Dispatcher extends BaseDispatcher implements DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface { protected $defaultAction = 'index'; @@ -104,7 +100,7 @@ class Dispatcher extends BaseDispatcher implements DispatcherInterface * * @param array $forward */ - public function forward($forward) + public function forward(array $forward) { } @@ -217,4 +213,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index 01a9f151..191b5bb9 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -1,24 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; -use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; +use Phalcon\Mvc\ControllerInterface; +use Phalcon\Dispatcher\DispatcherInterface; /** * Phalcon\Mvc\DispatcherInterface * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends DispatcherInterfaceBase +interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface { /** @@ -62,4 +54,5 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); + } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index a58fe248..c8eecd35 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; /** @@ -34,4 +25,5 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); + } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index d6b7ae9d..c9a2cab1 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -1,21 +1,25 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; use ArrayAccess; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Mvc\Controller; +use Phalcon\Di\FactoryDefault; +use Phalcon\Mvc\Micro\Exception; use Phalcon\Di\ServiceInterface; +use Phalcon\Mvc\Micro\Collection; +use Phalcon\Mvc\Micro\LazyLoader; +use Phalcon\Http\ResponseInterface; use Phalcon\Mvc\Model\BinderInterface; use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Micro\MiddlewareInterface; +use Phalcon\Mvc\Micro\CollectionInterface; +use Throwable; /** * Phalcon\Mvc\Micro @@ -25,7 +29,7 @@ * application. Micro applications are suitable to small applications, APIs and * prototypes in a practical way. * - *```php + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $app->get( @@ -36,9 +40,9 @@ * ); * * $app->handle("/say/welcome/Phalcon"); - *``` + * ``` */ -class Micro extends Injectable implements ArrayAccess +class Micro extends Injectable implements \ArrayAccess, \Phalcon\Events\EventsAwareInterface { protected $activeHandler; @@ -59,6 +63,9 @@ class Micro extends Injectable implements ArrayAccess protected $errorHandler; + protected $eventsManager; + + protected $finishHandlers = array(); @@ -125,8 +132,8 @@ public function before($handler): Micro /** * Maps a route to a handler that only matches if the HTTP method is DELETE * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function delete(string $routePattern, $handler): RouteInterface @@ -157,8 +164,8 @@ public function finish($handler): Micro /** * Maps a route to a handler that only matches if the HTTP method is GET * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function get(string $routePattern, $handler): RouteInterface @@ -183,6 +190,24 @@ public function getBoundModels(): array { } + /** + * Returns the internal event manager + * + * @return null|\Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ?ManagerInterface + { + } + + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } + /** * Returns the internal handlers attached to the application * @@ -222,8 +247,8 @@ public function getRouter(): RouterInterface /** * Obtains a service from the DI * - * @param string $serviceName * @return object + * @param string $serviceName */ public function getService(string $serviceName) { @@ -232,8 +257,8 @@ public function getService(string $serviceName) /** * Obtains a shared service from the DI * - * @param string $serviceName * @return mixed + * @param string $serviceName */ public function getSharedService(string $serviceName) { @@ -262,8 +287,8 @@ public function hasService(string $serviceName): bool /** * Maps a route to a handler that only matches if the HTTP method is HEAD * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function head(string $routePattern, $handler): RouteInterface @@ -273,8 +298,8 @@ public function head(string $routePattern, $handler): RouteInterface /** * Maps a route to a handler without any HTTP method constraint * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function map(string $routePattern, $handler): RouteInterface @@ -358,8 +383,8 @@ public function offsetUnset($alias) /** * Maps a route to a handler that only matches if the HTTP method is OPTIONS * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function options(string $routePattern, $handler): RouteInterface @@ -369,8 +394,8 @@ public function options(string $routePattern, $handler): RouteInterface /** * Maps a route to a handler that only matches if the HTTP method is PATCH * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function patch(string $routePattern, $handler): RouteInterface @@ -380,8 +405,8 @@ public function patch(string $routePattern, $handler): RouteInterface /** * Maps a route to a handler that only matches if the HTTP method is POST * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function post(string $routePattern, $handler): RouteInterface @@ -391,8 +416,8 @@ public function post(string $routePattern, $handler): RouteInterface /** * Maps a route to a handler that only matches if the HTTP method is PUT * - * @param string $routePattern * @param callable $handler + * @param string $routePattern * @return \Phalcon\Mvc\Router\RouteInterface */ public function put(string $routePattern, $handler): RouteInterface @@ -467,4 +492,5 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } + } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index 08f52a26..e83f19b3 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -1,26 +1,39 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ namespace Phalcon\Mvc; use JsonSerializable; use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Db\Column; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\RawValue; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Events\ManagerInterface as EventsManagerInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Messages\Message; +use Phalcon\Messages\MessageInterface; +use Phalcon\Mvc\Model\BehaviorInterface; +use Phalcon\Mvc\Model\Criteria; use Phalcon\Mvc\Model\CriteriaInterface; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\ManagerInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\Query; -use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\Model\QueryInterface; use Phalcon\Mvc\Model\ResultInterface; +use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\TransactionInterface; +use Phalcon\Mvc\Model\ValidationFailed; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Validation\ValidationInterface; use Serializable; /** @@ -60,7 +73,7 @@ * } * ``` */ -abstract class Model extends AbstractInjectionAware implements EntityInterface, ModelInterface, ResultInterface, Serializable, JsonSerializable +abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable { const DIRTY_STATE_DETACHED = 2; @@ -148,9 +161,10 @@ final public function __construct($data = null, \Phalcon\Di\DiInterface $contain /** * Handles method calls when a method is not implemented * + * @return mixed + * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments - * @return mixed */ public function __call(string $method, array $arguments) { @@ -159,9 +173,10 @@ public function __call(string $method, array $arguments) /** * Handles method calls when a static method is not implemented * + * @return mixed + * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments - * @return mixed */ public static function __callStatic(string $method, array $arguments) { @@ -171,8 +186,8 @@ public static function __callStatic(string $method, array $arguments) * Magic method to get related records using the relation alias as a * property * - * @param string $property * @return mixed + * @param string $property */ public function __get(string $property) { @@ -191,8 +206,8 @@ public function __isset(string $property): bool /** * Magic method to assign values to the the model * - * @param string $property * @param mixed $value + * @param string $property */ public function __set(string $property, $value) { @@ -302,9 +317,9 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * ); * ``` * - * @param array $data - * @param array $whiteList * @param array $dataColumnMap array to transform keys of data to another + * @param array $whiteList + * @param array $data * @return \Phalcon\Mvc\ModelInterface */ public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface @@ -381,8 +396,8 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * ``` * * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base - * @param array $data * @param array $columnMap + * @param array $data * @param int $dirtyState * @param bool $keepSnapshots * @return \Phalcon\Mvc\ModelInterface @@ -394,10 +409,10 @@ public static function cloneResultMap($base, array $data, $columnMap, int $dirty /** * Returns an hydrated result based on the data and the column map * - * @param array $data * @param array $columnMap - * @param int $hydrationMode * @return mixed + * @param array $data + * @param int $hydrationMode */ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) { @@ -419,7 +434,7 @@ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydra * ``` * * @param array $parameters - * @return int + * @return mixed */ public static function count($parameters = null): int { @@ -886,9 +901,9 @@ final public function getReadConnectionService(): string /** * Returns related records based on defined relations * - * @param string $alias * @param array $arguments * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param string $alias */ public function getRelated(string $alias, $arguments = null) { @@ -1249,8 +1264,8 @@ public function setOldSnapshotData(array $data, $columnMap = null) * This method is used internally to set snapshot data when the model was * set up to keep snapshot data * - * @param array $data * @param array $columnMap + * @param array $data */ public function setSnapshotData(array $data, $columnMap = null) { @@ -1445,10 +1460,10 @@ final protected function _checkForeignKeysReverseRestrict(): bool /** * Sends a pre-build INSERT SQL statement to the relational database system * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @param string|array $table * @param bool|string $identityField + * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @return bool */ protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool @@ -1458,9 +1473,9 @@ protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, /** * Sends a pre-build UPDATE SQL statement to the relational database system * + * @param string|array $table * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param string|array $table * @return bool */ protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool @@ -1479,23 +1494,24 @@ protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phal } /** - * Returns related records defined relations depending on the method name + * Returns related records defined relations depending on the method name. + * Returns false if the relation is non-existent. * * @param string $modelName * @param string $method - * @param array $arguments - * @return mixed + * @param array $arguments * + * @return ResultsetInterface|ModelInterface|bool|null */ - protected function _getRelatedRecords(string $modelName, string $method, $arguments) + protected function _getRelatedRecords(string $modelName, string $method, array $arguments) { } /** * Generate a PHQL SELECT statement for an aggregate * + * @param array $parameters * @param string $functionName * @param string $alias - * @param array $parameters * @return \Phalcon\Mvc\Model\ResultsetInterface */ protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface @@ -1505,11 +1521,11 @@ protected static function _groupResult(string $functionName, string $alias, $par /** * Try to check if the query must invoke a finder * + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool * @param string $method * @param array $arguments - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool */ - final protected static function _invokeFinder(string $method, array $arguments) + protected final static function _invokeFinder(string $method, array $arguments) { } @@ -1539,8 +1555,10 @@ protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool /** * Saves related records that must be stored prior to save the master record * + * @param \Phalcon\Mvc\ModelInterface[] related * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related + * @param mixed $related + * @param \Phalcon\Mvc\ModelInterface [] related * @return bool */ protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool @@ -1561,8 +1579,10 @@ protected function _postSave(bool $success, bool $exists): bool /** * Save the related records assigned in the has-one/has-many relations * + * @param Phalcon\Mvc\ModelInterface[] related * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param \Phalcon\Mvc\ModelInterface[] $related + * @param mixed $related + * @param Phalcon\Mvc\ModelInterface [] related * @return bool */ protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool @@ -1688,12 +1708,12 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * ``` * * @param string|array $fields - * @param string $intermediateModel * @param string|array $intermediateFields * @param string|array $intermediateReferencedFields - * @param string $referenceModel * @param string|array $referencedFields * @param array $options + * @param string $intermediateModel + * @param string $referenceModel * @return \Phalcon\Mvc\Model\Relation */ protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation @@ -1946,4 +1966,5 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } + } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index 05b904e3..b2096bac 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -1,19 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ namespace Phalcon\Mvc; use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\TransactionInterface; /** * Phalcon\Mvc\ModelInterface @@ -34,10 +29,10 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode /** * Assigns values to a model from an array * + * @param array $columnMap * @param array $data * @param mixed $whiteList * @param mixed $dataColumnMap - * @param array $columnMap * @return ModelInterface */ public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface; @@ -65,19 +60,19 @@ public static function cloneResult(ModelInterface $base, array $data, int $dirty * Assigns values to a model from an array returning a new model * * @param \Phalcon\Mvc\Model $base - * @param array $data * @param array $columnMap + * @return \Phalcon\Mvc\Model result + * @param array $data * @param int $dirtyState * @param bool $keepSnapshots - * @return ModelInterface */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; /** * Returns an hydrated result based on the data and the column map * - * @param array $data * @param array $columnMap + * @param array $data * @param int $hydrationMode */ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode); @@ -188,9 +183,9 @@ public function getReadConnectionService(): string; /** * Returns related records based on defined relations * - * @param string $alias * @param array $arguments * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param string $alias */ public function getRelated(string $alias, $arguments = null); @@ -290,8 +285,8 @@ public function setReadConnectionService(string $connectionService); * Sets the record's snapshot data. This method is used internally to set * snapshot data when the model was set up to keep snapshot data * - * @param array $data * @param array $columnMap + * @param array $data */ public function setSnapshotData(array $data, $columnMap = null); @@ -340,4 +335,5 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; + } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index df3d8fa4..54881cbf 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Phalcon\Di\DiInterface; + /** * Phalcon\Mvc\ModuleDefinitionInterface * @@ -32,4 +25,5 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); + } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index 4a6b37f0..f227b85e 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -1,19 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Http\RequestInterface; +use Phalcon\Mvc\Router\Exception; +use Phalcon\Mvc\Router\GroupInterface; +use Phalcon\Mvc\Router\Route; use Phalcon\Mvc\Router\RouteInterface; /** @@ -44,7 +40,7 @@ * echo $router->getControllerName(); * ``` */ -class Router extends AbstractInjectionAware implements RouterInterface, EventsAwareInterface +class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { const POSITION_FIRST = 0; @@ -575,4 +571,5 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } + } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index b654ef7c..4b9f5e9f 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Phalcon\Mvc\Router; use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Mvc\Router\GroupInterface; /** * Interface for Phalcon\Mvc\Router @@ -259,4 +252,5 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index 5062da17..0c550c3e 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -1,17 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Events\ManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; +use Phalcon\Mvc\View\Exception; +use Phalcon\Mvc\ViewInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Mvc\View\Engine\Php; /** * Phalcon\Mvc\View @@ -39,7 +39,7 @@ * echo $view->getContent(); * ``` */ -class View extends Injectable implements ViewInterface +class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface { /** * Render Level: To the action view @@ -99,6 +99,9 @@ class View extends Injectable implements ViewInterface protected $engines = false; + protected $eventsManager; + + protected $layout; @@ -321,6 +324,15 @@ public function getControllerName(): string { } + /** + * Returns the internal event manager + * + * @return null|\Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ?ManagerInterface + { + } + /** * Returns the name of the main view * @@ -405,10 +417,10 @@ public function getPartialsDir(): string * ); * ``` * + * @param mixed $configCallback * @param string $controllerName * @param string $actionName * @param array $params - * @param mixed $configCallback * @return string */ public function getRender(string $controllerName, string $actionName, array $params = array(), $configCallback = null): string @@ -576,6 +588,15 @@ public function setContent(string $content): View { } + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } + /** * Change the layout to be used instead of using the name of the latest * controller name @@ -800,4 +821,5 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } + } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index 866d04aa..a1cce654 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; +use Phalcon\Cache\Adapter\AdapterInterface; + /** * Phalcon\Mvc\ViewInterface * @@ -78,4 +71,5 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); + } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index cd544276..c27c5ca3 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc; /** @@ -16,7 +7,7 @@ * * Interface for Phalcon\Mvc\View */ -interface ViewInterface extends ViewBaseInterface +interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface { /** @@ -204,4 +195,5 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); + } diff --git a/src/Phalcon/mvc/application/Exception.php b/src/Phalcon/mvc/application/Exception.php index fb7728b6..09fd0a89 100644 --- a/src/Phalcon/mvc/application/Exception.php +++ b/src/Phalcon/mvc/application/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Application; /** diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 53afd7f8..84e98de1 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Controller; /** @@ -25,4 +16,5 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; + } diff --git a/src/Phalcon/mvc/dispatcher/Exception.php b/src/Phalcon/mvc/dispatcher/Exception.php index 48f203a3..b7f06862 100644 --- a/src/Phalcon/mvc/dispatcher/Exception.php +++ b/src/Phalcon/mvc/dispatcher/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Dispatcher; /** diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 789316f7..08aa0968 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Micro; /** @@ -16,7 +7,7 @@ * * Groups Micro-Mvc handlers as controllers * - *```php + * ```php * $app = new \Phalcon\Mvc\Micro(); * * $collection = new Collection(); @@ -28,9 +19,9 @@ * $collection->get("/posts/edit/{id}", "edit"); * * $app->mount($collection); - *``` + * ``` */ -class Collection implements CollectionInterface +class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { protected $handler; @@ -48,8 +39,8 @@ class Collection implements CollectionInterface /** * Maps a route to a handler that only matches if the HTTP method is DELETE. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -60,8 +51,8 @@ public function delete(string $routePattern, $handler, string $name = null): Col /** * Maps a route to a handler that only matches if the HTTP method is GET. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -99,8 +90,8 @@ public function getPrefix(): string /** * Maps a route to a handler that only matches if the HTTP method is HEAD. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -120,8 +111,8 @@ public function isLazy(): bool /** * Maps a route to a handler. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -141,9 +132,9 @@ public function map(string $routePattern, $handler, string $name = null): Collec * ); * ``` * - * @param string $routePattern * @param callable $handler * @param string|array $method + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -155,8 +146,8 @@ public function mapVia(string $routePattern, $handler, $method, string $name = n * Maps a route to a handler that only matches if the HTTP method is * OPTIONS. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -167,8 +158,8 @@ public function options(string $routePattern, $handler, string $name = null): Co /** * Maps a route to a handler that only matches if the HTTP method is PATCH. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -179,8 +170,8 @@ public function patch(string $routePattern, $handler, string $name = null): Coll /** * Maps a route to a handler that only matches if the HTTP method is POST. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -191,8 +182,8 @@ public function post(string $routePattern, $handler, string $name = null): Colle /** * Maps a route to a handler that only matches if the HTTP method is PUT. * - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name * @return CollectionInterface */ @@ -235,11 +226,12 @@ public function setPrefix(string $prefix): CollectionInterface * Internal function to add a handler to the group. * * @param string|array $method - * @param string $routePattern * @param callable|string $handler + * @param string $routePattern * @param string $name */ protected function addMap($method, string $routePattern, $handler, string $name) { } + } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index 4dd0c4eb..8254ccc9 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Micro; /** @@ -151,4 +142,5 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; + } diff --git a/src/Phalcon/mvc/micro/Exception.php b/src/Phalcon/mvc/micro/Exception.php index 8348ef66..cd352fc1 100644 --- a/src/Phalcon/mvc/micro/Exception.php +++ b/src/Phalcon/mvc/micro/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Micro; /** diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index aba652f2..99880fd8 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Micro; +use Phalcon\Mvc\Model\BinderInterface; + /** * Phalcon\Mvc\Micro\LazyLoader * @@ -42,12 +35,13 @@ public function __construct(string $definition) /** * Calling __call method * - * @param string $method * @param array $arguments - * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @return mixed + * @param string $method + * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder */ public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) { } + } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index f6ed8ad3..553ab07a 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Micro; +use Phalcon\Mvc\Micro; + /** * Allows to implement Phalcon\Mvc\Micro middleware in classes */ @@ -23,4 +16,5 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); + } diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 0e36aa61..810c61bf 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -1,22 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\BehaviorInterface; + /** * Phalcon\Mvc\Model\Behavior * * This is an optional base class for ORM behaviors */ -abstract class Behavior implements BehaviorInterface +abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface { /** * @var array @@ -36,8 +30,8 @@ public function __construct(array $options = array()) /** * Returns the behavior options related to an event * - * @param string $eventName * @return array + * @param string $eventName */ protected function getOptions(string $eventName = null) { @@ -73,4 +67,5 @@ protected function mustTakeAction(string $eventName): bool public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 54681fc8..c2713fb4 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\BehaviorInterface * @@ -35,4 +28,5 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); + } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index 111a76f4..4454abe5 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -1,24 +1,20 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Closure; +use Phalcon\Mvc\Controller\BindModelInterface; +use Phalcon\Mvc\Model\Binder\BindableInterface; use Phalcon\Cache\Adapter\AdapterInterface; +use ReflectionFunction; +use ReflectionMethod; /** * Phalcon\Mvc\Model\Binding * * This is an class for binding models into params for handler */ -class Binder implements BinderInterface +class Binder implements \Phalcon\Mvc\Model\BinderInterface { /** * Array for storing active bound models @@ -133,4 +129,5 @@ protected function getParamsFromReflection($handler, array $params, string $cach public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface { } + } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index a000a0bf..a0321410 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use Phalcon\Cache\Adapter\AdapterInterface; @@ -53,4 +44,5 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; + } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index d6527a48..f02a1442 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -1,18 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Di; +use Phalcon\Db\Column; use Phalcon\Di\DiInterface; +use Phalcon\Mvc\Model\Exception; use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\CriteriaInterface; +use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; /** @@ -32,7 +28,7 @@ * ->execute(); * ``` */ -class Criteria implements CriteriaInterface, InjectionAwareInterface +class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; @@ -463,7 +459,7 @@ public function getConditions(): ?string * limit was set without an offset, an array with 'number' and 'offset' keys * if an offset was set with the limit, or null if limit has not been set. * - * @return string|null + * @return int|array|null */ public function getLimit(): ?string { @@ -538,4 +534,5 @@ public function createBuilder(): BuilderInterface public function execute(): ResultsetInterface { } + } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index 229a7e0a..c6cf3a65 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Di\DiInterface; + /** * Phalcon\Mvc\Model\CriteriaInterface * @@ -22,9 +15,9 @@ interface CriteriaInterface /** * Appends a condition to the current conditions using an AND operator * - * @param string $conditions * @param array $bindParams * @param array $bindTypes + * @param string $conditions * @return CriteriaInterface */ public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; @@ -36,9 +29,9 @@ public function andWhere(string $conditions, $bindParams = null, $bindTypes = nu * $criteria->betweenWhere("price", 100.25, 200.50); * ``` * - * @param string $expr * @param mixed $minimum * @param mixed $maximum + * @param string $expr * @return CriteriaInterface */ public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; @@ -252,9 +245,9 @@ public function limit(int $limit, int $offset = 0): CriteriaInterface; * $criteria->notBetweenWhere("price", 100.25, 200.50); * ``` * - * @param string $expr * @param mixed $minimum * @param mixed $maximum + * @param string $expr * @return CriteriaInterface */ public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface; @@ -283,9 +276,9 @@ public function orderBy(string $orderColumns): CriteriaInterface; /** * Appends a condition to the current conditions using an OR operator * - * @param string $conditions * @param array $bindParams * @param array $bindTypes + * @param string $conditions * @return CriteriaInterface */ public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface; @@ -331,4 +324,5 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; + } diff --git a/src/Phalcon/mvc/model/Exception.php b/src/Phalcon/mvc/model/Exception.php index ce4b4f4f..61bfb83a 100644 --- a/src/Phalcon/mvc/model/Exception.php +++ b/src/Phalcon/mvc/model/Exception.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; /** * Phalcon\Mvc\Model\Exception * - * Exceptions thrown in Phalcon\Mvc\Model\* classes will use this class + * Exceptions thrown in Phalcon\Mvc\Model\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index c8491f41..f9525c5e 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -1,23 +1,23 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; -use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; +use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\ManagerInterface; use Phalcon\Di\InjectionAwareInterface; use Phalcon\Events\EventsAwareInterface; -use Phalcon\Events\ManagerInterface as EventsManagerInterface; +use Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\Model\Query\Builder; use Phalcon\Mvc\Model\Query\BuilderInterface; -use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\BehaviorInterface; +use Phalcon\Events\ManagerInterface; /** * Phalcon\Mvc\Model\Manager @@ -44,7 +44,7 @@ * $robot = new Robots($di); * ``` */ -class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareInterface +class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { protected $aliases = array(); @@ -511,11 +511,11 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool /** * Setup a 1-1 relation between two models * + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface @@ -525,11 +525,11 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r /** * Setup a relation reverse many to one between two models * + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface @@ -539,11 +539,11 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string /** * Setup a relation 1-n between two models * + * @param mixed $referencedFields + * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel - * @param mixed $referencedFields - * @param array $options * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface @@ -553,14 +553,14 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ /** * Setups a relation n-m between two models * - * @param \Phalcon\Mvc\ModelInterface $model * @param string $fields - * @param string $intermediateModel * @param string $intermediateFields * @param string $intermediateReferencedFields - * @param string $referencedModel * @param string $referencedFields * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $intermediateModel + * @param string $referencedModel * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface @@ -636,11 +636,11 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a /** * Helper method to query records based on a relation definition * + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param \Phalcon\Mvc\Model\RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -840,4 +840,5 @@ public function getLastQuery(): QueryInterface public function __destruct() { } + } diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index db9719b9..97281f76 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -1,19 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Mvc\Model\Query\BuilderInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\BehaviorInterface; +use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\Model\QueryInterface; /** * Phalcon\Mvc\Model\ManagerInterface @@ -34,11 +28,11 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod /** * Setup a relation reverse 1-1 between two models * - * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields - * @param string $referencedModel * @param mixed $referencedFields * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $referencedModel * @return \Phalcon\Mvc\Model\RelationInterface */ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -46,11 +40,11 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string /** * Setup a relation 1-n between two models * - * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields - * @param string $referencedModel * @param mixed $referencedFields * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $referencedModel * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -58,11 +52,11 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ /** * Setup a 1-1 relation between two models * - * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields - * @param string $referencedModel * @param mixed $referencedFields * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $referencedModel * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -70,14 +64,14 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r /** * Setups a relation n-m between two models * - * @param \Phalcon\Mvc\ModelInterface $model * @param string $fields - * @param string $intermediateModel * @param string $intermediateFields * @param string $intermediateReferencedFields - * @param string $referencedModel * @param string $referencedFields * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $intermediateModel + * @param string $referencedModel * @return \Phalcon\Mvc\Model\RelationInterface */ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -101,8 +95,8 @@ public function createQuery(string $phql): QueryInterface; /** * Creates a Phalcon\Mvc\Model\Query and execute it * - * @param string $phql * @param array $placeholders + * @param string $phql * @return \Phalcon\Mvc\Model\QueryInterface */ public function executeQuery(string $phql, $placeholders = null): QueryInterface; @@ -154,11 +148,11 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets belongsTo related records from a model * - * @param string $modelName - * @param string $modelRelation - * @param ModelInterface $record + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|ResultsetInterface */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -174,11 +168,11 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets hasMany related records from a model * - * @param string $modelName - * @param string $modelRelation - * @param ModelInterface $record + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|ResultsetInterface */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -210,11 +204,11 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets belongsTo related records from a model * - * @param string $modelName - * @param string $modelRelation - * @param ModelInterface $record + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|\Phalcon\Mvc\ModelInterface */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -277,11 +271,11 @@ public function getRelationByAlias(string $modelName, string $alias); /** * Helper method to query records based on a relation definition * + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param \Phalcon\Mvc\Model\RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -386,10 +380,10 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * This method expects that the endpoint listeners/behaviors returns true * meaning that a least one is implemented * - * @param \Phalcon\Mvc\ModelInterface $model - * @param string $eventName * @param array $data * @return bool + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $eventName */ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); @@ -449,4 +443,5 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param bool $dynamicUpdate */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); + } diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/mvc/model/MetaData.php index 085cdbe1..1cedeeae 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/mvc/model/MetaData.php @@ -1,20 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\MetaData\StrategyInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\MetaData\Strategy\Introspection; +use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\MetaData @@ -36,7 +30,7 @@ * print_r($attributes); * ``` */ -abstract class MetaData implements InjectionAwareInterface, MetaDataInterface +abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface { const MODELS_ATTRIBUTES = 0; @@ -368,7 +362,7 @@ public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array /** * Return the strategy to obtain the meta-data * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @return \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface */ public function getStrategy(): StrategyInterface { @@ -573,9 +567,9 @@ public function setDI(\Phalcon\Di\DiInterface $container) /** * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy) + public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy) { } @@ -632,4 +626,5 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t private function throwWriteException($option) { } + } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index d450ce5b..e30e329c 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\Model\MetaData\StrategyInterface; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; /** * Phalcon\Mvc\Model\MetaDataInterface @@ -136,7 +128,7 @@ public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** * Return the strategy to obtain the meta-data * - * @return \Phalcon\Mvc\Model\MetaData\StrategyInterface + * @return \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface */ public function getStrategy(): StrategyInterface; @@ -238,9 +230,9 @@ public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $inde /** * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy + * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strategy); + public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy); /** * Writes meta-data to the adapter @@ -249,4 +241,5 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\StrategyInterface $strat * @param array $data */ public function write(string $key, array $data); + } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index 843be4b3..397106ca 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -1,29 +1,36 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Db\Column; +use Phalcon\Db\RawValue; +use Phalcon\Db\ResultInterface; use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\Query\StatusInterface; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\Model\Row; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\ManagerInterface; +use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\Model\Query\Status; +use Phalcon\Mvc\Model\Resultset\Complex; +use Phalcon\Mvc\Model\Query\StatusInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Resultset\Simple; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\TransactionInterface; +use Phalcon\Db\DialectInterface; +use Phalcon\Mvc\Model\Query\Lang; /** * Phalcon\Mvc\Model\Query * * This class takes a PHQL intermediate representation and executes it. * - *```php - * $phql = "SELECT c.price*0.16 AS taxes, c.* FROM Cars AS c JOIN Brands AS b + * ```php + * $phql = "SELECT c.price0.16 AS taxes, c. FROM Cars AS c JOIN Brands AS b * WHERE b.name = :name: ORDER BY c.name"; * * $result = $manager->executeQuery( @@ -46,7 +53,7 @@ * // $di needs to have the service "db" registered for this to work * $di = Phalcon\Di\FactoryDefault::getDefault(); * - * $phql = 'SELECT * FROM robot'; + * $phql = 'SELECT FROM robot'; * * $myTransaction = new Transaction($di); * $myTransaction->begin(); @@ -65,9 +72,9 @@ * * $queryWithOutTransaction = new Query($phql, $di); * $resultWithOutEntries = $queryWithTransaction->execute(); - *``` + * ``` */ -class Query implements QueryInterface, InjectionAwareInterface +class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { const TYPE_DELETE = 303; @@ -148,7 +155,7 @@ class Query implements QueryInterface, InjectionAwareInterface protected $uniqueRow; - protected static $_irPhqlCache; + static protected $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -286,9 +293,9 @@ final protected function _getSelectColumn(array $column): array /** * Resolves a table in a SELECT statement checking if the model exists * + * @return string * @param \Phalcon\Mvc\Model\ManagerInterface $manager * @param array $qualifiedName - * @return string */ final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) { @@ -318,8 +325,8 @@ final protected function _getJoinType(array $join): string /** * Resolves joins involving has-one/belongs-to/has-many relations * - * @param string $joinType * @param string $joinSource + * @param string $joinType * @param string $modelAlias * @param string $joinAlias * @param \Phalcon\Mvc\Model\RelationInterface $relation @@ -332,8 +339,8 @@ final protected function _getSingleJoin(string $joinType, $joinSource, string $m /** * Resolves joins involving many-to-many relations * - * @param string $joinType * @param string $joinSource + * @param string $joinType * @param string $modelAlias * @param string $joinAlias * @param \Phalcon\Mvc\Model\RelationInterface $relation @@ -514,9 +521,9 @@ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, /** * Executes a parsed PHQL statement * + * @return mixed * @param array $bindParams * @param array $bindTypes - * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()) { @@ -694,4 +701,5 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface { } + } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 8cce6248..9ac7210c 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; @@ -32,9 +23,9 @@ public function cache(array $cacheOptions): QueryInterface; /** * Executes a parsed PHQL statement * + * @return mixed * @param array $bindParams * @param array $bindTypes - * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()); @@ -123,4 +114,5 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; + } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index b7c4a10e..8719aaa2 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -1,22 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\RelationInterface; + /** * Phalcon\Mvc\Model\Relation * * This class represents a relationship between two models */ -class Relation implements RelationInterface +class Relation implements \Phalcon\Mvc\Model\RelationInterface { const ACTION_CASCADE = 2; @@ -70,10 +63,10 @@ class Relation implements RelationInterface /** * Phalcon\Mvc\Model\Relation constructor * - * @param int $type - * @param string $referencedModel * @param string|array $fields * @param string|array $referencedFields + * @param int $type + * @param string $referencedModel * @param array $options */ public function __construct(int $type, string $referencedModel, $fields, $referencedFields, array $options = array()) @@ -211,10 +204,11 @@ public function isReusable(): bool * Sets the intermediate model data for has--through relations * * @param string|array $intermediateFields - * @param string $intermediateModel * @param string $intermediateReferencedFields + * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } + } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index a0e757fe..c3c45f6a 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; /** @@ -122,8 +113,9 @@ public function isThrough(): bool; * Sets the intermediate model dat for has--through relations * * @param string|array $intermediateFields - * @param string $intermediateModel * @param string|array $intermediateReferencedFields + * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); + } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 8849286e..72ace62e 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ResultInterface * @@ -26,4 +19,5 @@ interface ResultInterface * @return bool|\Phalcon\Mvc\ModelInterface */ public function setDirtyState(int $dirtyState); + } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index b2a70358..ee659f7e 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -1,22 +1,20 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use ArrayAccess; +use Closure; use Countable; use Iterator; use JsonSerializable; -use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Db\Enum; +use Phalcon\Messages\MessageInterface; +use Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Serializer\SerializerInterface; use SeekableIterator; use Serializable; @@ -61,7 +59,7 @@ * } * ``` */ -abstract class Resultset implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable +abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { const HYDRATE_ARRAYS = 1; @@ -350,4 +348,5 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } + } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index 02ac5b9a..277f0120 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -1,18 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; +use Closure; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Cache\Adapter\AdapterInterface; /** * Phalcon\Mvc\Model\ResultsetInterface @@ -129,4 +122,5 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; + } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 3efb7dc4..dd0ec110 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -1,19 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use ArrayAccess; use JsonSerializable; use Phalcon\Mvc\EntityInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\ResultInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\Row @@ -21,7 +15,7 @@ * This component allows Phalcon\Mvc\Model to return rows without an associated entity. * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. */ -class Row implements EntityInterface, ResultInterface, ArrayAccess, JsonSerializable +class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable { /** @@ -36,10 +30,8 @@ public function jsonSerialize(): array /** * Gets a record in a specific position of the row * - * @param string|int index - * - * @param mixed $index - * @return mixed + * @param string|int $index * + * @return string|Phalcon\Mvc\ModelInterface */ public function offsetGet($index) { @@ -81,8 +73,8 @@ public function offsetUnset($offset) * echo $robot->readAttribute("name"); * ``` * - * @param string $attribute * @return mixed + * @param string $attribute */ public function readAttribute(string $attribute) { @@ -114,10 +106,11 @@ public function toArray(): array * $robot->writeAttribute("name", "Rosey"); * ``` * - * @param string $attribute * @param mixed $value + * @param string $attribute */ public function writeAttribute(string $attribute, $value) { } + } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index c2b67e46..ac23ffee 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -1,16 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Transaction\Failed; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; +use Phalcon\Mvc\Model\TransactionInterface; + /** * Phalcon\Mvc\Model\Transaction * @@ -55,7 +52,7 @@ * } * ``` */ -class Transaction implements TransactionInterface +class Transaction implements \Phalcon\Mvc\Model\TransactionInterface { protected $activeTransaction = false; @@ -203,4 +200,5 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte public function throwRollbackException(bool $status): TransactionInterface { } + } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index 26f1ae87..219a5083 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; + /** * Phalcon\Mvc\Model\TransactionInterface * @@ -105,4 +99,5 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; + } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index dea5c291..2c4348fa 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; @@ -19,7 +10,7 @@ * This exception is generated when a model fails to save a record * Phalcon\Mvc\Model must be set up to have this behavior */ -class ValidationFailed extends Exception +class ValidationFailed extends \Phalcon\Mvc\Model\Exception { protected $messages; @@ -31,8 +22,10 @@ class ValidationFailed extends Exception /** * Phalcon\Mvc\Model\ValidationFailed constructor * + * @param Message[] validationMessages * @param \Phalcon\Mvc\ModelInterface $model - * @param Message[] $validationMessages + * @param array $validationMessages + * @param Message [] validationMessages */ public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) { @@ -55,4 +48,5 @@ public function getMessages(): array public function getModel(): ModelInterface { } + } diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/mvc/model/behavior/SoftDelete.php index b87f1e4f..97f62675 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/model/behavior/SoftDelete.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\SoftDelete @@ -31,4 +24,5 @@ class SoftDelete extends Behavior public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/mvc/model/behavior/Timestampable.php index ed4a9c71..ef8242d0 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/mvc/model/behavior/Timestampable.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Behavior; +use Closure; +use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\Timestampable @@ -38,4 +32,5 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } + } diff --git a/src/Phalcon/mvc/model/binder/BindableInterface.php b/src/Phalcon/mvc/model/binder/BindableInterface.php index 6823b7ee..48208879 100644 --- a/src/Phalcon/mvc/model/binder/BindableInterface.php +++ b/src/Phalcon/mvc/model/binder/BindableInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Binder; /** @@ -26,4 +17,5 @@ interface BindableInterface * @return string|array */ public function getModelName(); + } diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index 4a58b82e..125c295f 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Apcu @@ -22,14 +15,14 @@ * * You can query the meta-data by printing apcu_fetch('$PMM$') or apcu_fetch('$PMM$my-app-id') * - *```php + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Apcu( * [ * "prefix" => "my-app-id", * "lifetime" => 86400, * ] * ); - *``` + * ``` */ class Apcu extends MetaData { @@ -37,10 +30,11 @@ class Apcu extends MetaData /** * Phalcon\Mvc\Model\MetaData\Apcu constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options + * @param \Phalcon\Cache\AdapterFactory $factory */ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) { } + } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index a5b1e751..ac52ed02 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Libmemcached @@ -26,8 +20,8 @@ class Libmemcached extends MetaData /** * Phalcon\Mvc\Model\MetaData\Libmemcached constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options + * @param \Phalcon\Cache\AdapterFactory $factory */ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) { @@ -39,4 +33,5 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } + } diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index a383d9d3..46c1fa84 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -1,23 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Memory * * Stores model meta-data in memory. Data will be erased when the request finishes - * */ class Memory extends MetaData { @@ -50,4 +41,5 @@ public function read(string $key): ?array public function write(string $key, array $data) { } + } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index 6249a178..f65f4dc9 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Redis @@ -20,7 +12,7 @@ * * By default meta-data is stored for 48 hours (172800 seconds) * - *```php + * ```php * use Phalcon\Mvc\Model\MetaData\Redis; * * $metaData = new Redis( @@ -32,7 +24,7 @@ * "index" => 2, * ] * ); - *``` + * ``` */ class Redis extends MetaData { @@ -40,8 +32,8 @@ class Redis extends MetaData /** * Phalcon\Mvc\Model\MetaData\Redis constructor * - * @param \Phalcon\Cache\AdapterFactory $factory * @param array $options + * @param \Phalcon\Cache\AdapterFactory $factory */ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) { @@ -53,4 +45,5 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } + } diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Stream.php index 517319ad..424d11d1 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -1,30 +1,22 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Stream * * Stores model meta-data in PHP files. * - *```php + * ```php * $metaData = new \Phalcon\Mvc\Model\MetaData\Files( * [ * "metaDataDir" => "app/cache/metadata/", * ] * ); - *``` + * ``` */ class Stream extends MetaData { @@ -69,4 +61,5 @@ public function write(string $key, array $data) private function throwWriteException($option) { } + } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 63bb2e13..9a471d7c 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -1,5 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\MetaData\Strategy; -use Phalcon\Mvc\Model\MetaData\StrategyInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Db\Column; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; /** * Phalcon\Mvc\Model\MetaData\Strategy\Introspection * * Queries the table meta-data in order to introspect the model's metadata */ -class Introspection implements StrategyInterface +class Introspection implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface { /** @@ -42,4 +39,5 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } + } diff --git a/src/Phalcon/mvc/model/metadata/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php similarity index 90% rename from src/Phalcon/mvc/model/metadata/StrategyInterface.php rename to src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php index 6164dc93..f229b89d 100644 --- a/src/Phalcon/mvc/model/metadata/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Query; +use Phalcon\Di; +use Phalcon\Db\Column; use Phalcon\Di\DiInterface; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\Model\Exception; use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; /** * Phalcon\Mvc\Model\Query\Builder * * Helps to create PHQL queries using an OO interface * - *```php + * ```php * $params = [ * "models" => [ * Users::class, @@ -49,9 +45,9 @@ * ]; * * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); - *``` + * ``` */ -class Builder implements BuilderInterface, InjectionAwareInterface +class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; @@ -919,4 +915,5 @@ protected function conditionNotBetween(string $clause, string $operator, string protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } + } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index af87ecf0..a7a307bb 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Query; use Phalcon\Mvc\Model\QueryInterface; @@ -49,9 +40,9 @@ public function andWhere(string $conditions, array $bindParams = array(), array /** * Appends a BETWEEN condition to the current conditions * - * @param string $expr * @param mixed $minimum * @param mixed $maximum + * @param string $expr * @param string $operator * @return BuilderInterface */ @@ -238,7 +229,6 @@ public function inWhere(string $expr, array $values, string $operator = BuilderI * @param string $model * @param string $conditions * @param string $alias - * @param string $type * @return BuilderInterface */ public function join(string $model, string $conditions = null, string $alias = null): BuilderInterface; @@ -256,8 +246,8 @@ public function leftJoin(string $model, string $conditions = null, string $alias /** * Sets a LIMIT clause * - * @param int $limit * @param int $offset + * @param int $limit * @return BuilderInterface */ public function limit(int $limit, $offset = null): BuilderInterface; @@ -272,9 +262,9 @@ public function getModels(); /** * Appends a NOT BETWEEN condition to the current conditions * - * @param string $expr * @param mixed $minimum * @param mixed $maximum + * @param string $expr * @param string $operator * @return BuilderInterface */ @@ -353,4 +343,5 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 6a72da16..6e5f1ed7 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Query; /** @@ -25,8 +16,10 @@ * parser with a very low memory footprint that is also thread-safe. * * ```php - * $intermediate = Phalcon\Mvc\Model\Query\Lang::parsePHQL( - * "SELECT r.* FROM Robots r LIMIT 10" + * use Phalcon\Mvc\Model\Query\Lang; + * + * $intermediate = Lang::parsePHQL( + * "SELECT r. FROM Robots r LIMIT 10" * ); * ``` */ @@ -37,9 +30,10 @@ abstract class Lang * Parses a PHQL statement returning an intermediate representation (IR) * * @param string $phql - * @return string + * @return array */ - public static function parsePHQL(string $phql): string + public static function parsePHQL(string $phql): array { } + } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index 1c9571a3..bc0997e7 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Query; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Query\StatusInterface; /** * Phalcon\Mvc\Model\Query\Status @@ -21,7 +14,7 @@ * information and the related messages produced by the * model which finally executes the operations when it fails * - *```php + * ```php * $phql = "UPDATE Robots SET name = :name:, type = :type:, year = :year: WHERE id = :id:"; * * $status = $app->modelsManager->executeQuery( @@ -38,9 +31,9 @@ * if ($status->success()) { * echo "OK"; * } - *``` + * ``` */ -class Status implements StatusInterface +class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { protected $model; @@ -85,4 +78,5 @@ public function getModel(): ModelInterface public function success(): bool { } + } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index ba026840..27efbfe9 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Query; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** @@ -41,4 +33,5 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; + } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 4b97d6a1..3a4ca8f7 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -1,18 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Db\ResultInterface; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Row; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Storage\Serializer\SerializerInterface; +use stdClass; /** * Phalcon\Mvc\Model\Resultset\Complex @@ -20,7 +21,7 @@ * Complex resultsets may include complete objects and scalar values. * This class builds every complex row as it is required */ -class Complex extends Resultset implements ResultsetInterface +class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface { protected $columnTypes; @@ -46,7 +47,7 @@ public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = /** * Returns current row in the resultset * - * @return bool|ModelInterface + * @return bool|\Phalcon\Mvc\ModelInterface */ final public function current() { @@ -79,4 +80,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 66f6cfc3..4c3fa90b 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -1,17 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Phalcon\Mvc\Model\Resultset\Simple @@ -49,7 +47,7 @@ public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\ /** * Returns current row in the resultset * - * @return null|ModelInterface + * @return null|\Phalcon\Mvc\ModelInterface */ final public function current(): ?ModelInterface { @@ -86,4 +84,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/mvc/model/transaction/Exception.php b/src/Phalcon/mvc/model/transaction/Exception.php index 422ef152..51ec8b7d 100644 --- a/src/Phalcon/mvc/model/transaction/Exception.php +++ b/src/Phalcon/mvc/model/transaction/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Transaction; /** diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index 5838f209..e4978581 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Transaction\Exception; /** * Phalcon\Mvc\Model\Transaction\Failed @@ -51,4 +44,5 @@ public function getRecord(): ModelInterface public function getRecordMessages(): array { } + } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index 94080392..fc880ef4 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -1,18 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Di; use Phalcon\Di\DiInterface; use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; +use Phalcon\Mvc\Model\Transaction\Exception; +use Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\Model\TransactionInterface; /** @@ -60,9 +55,9 @@ * } catch (Failed $e) { * echo "Failed, reason: ", $e->getMessage(); * } - *``` + * ``` */ -class Manager implements ManagerInterface, InjectionAwareInterface +class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { protected $container; @@ -239,4 +234,5 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) { } + } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index 167d04fb..f081fefa 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\Model\TransactionInterface; @@ -102,4 +93,5 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; + } diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 235f9b57..7c5a8f28 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Router; +use Phalcon\Annotations\Annotation; +use Phalcon\Mvc\Router\Exception; /** * Phalcon\Mvc\Router\Annotations @@ -134,4 +128,5 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } + } diff --git a/src/Phalcon/mvc/router/Exception.php b/src/Phalcon/mvc/router/Exception.php index 55e57855..6811d962 100644 --- a/src/Phalcon/mvc/router/Exception.php +++ b/src/Phalcon/mvc/router/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; /** diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index 275329f4..4b8cf75b 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; /** @@ -16,7 +7,7 @@ * * Helper class to create a group of routes with common attributes * - *```php + * ```php * $router = new \Phalcon\Mvc\Router(); * * //Create a group with a common module and controller @@ -57,9 +48,9 @@ * * //Add the group to the router * $router->mount($blog); - *``` + * ``` */ -class Group implements GroupInterface +class Group implements \Phalcon\Mvc\Router\GroupInterface { protected $beforeMatch; @@ -105,8 +96,8 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI /** * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface @@ -116,8 +107,8 @@ public function addConnect(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is DELETE * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface @@ -127,8 +118,8 @@ public function addDelete(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is GET * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface @@ -138,8 +129,8 @@ public function addGet(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is HEAD * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface @@ -149,8 +140,8 @@ public function addHead(string $pattern, $paths = null): RouteInterface /** * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface @@ -160,8 +151,8 @@ public function addOptions(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PATCH * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface @@ -171,8 +162,8 @@ public function addPatch(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is POST * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface @@ -182,8 +173,8 @@ public function addPost(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PURGE * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface @@ -193,8 +184,8 @@ public function addPurge(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PUT * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface @@ -204,8 +195,8 @@ public function addPut(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is TRACE * - * @param string $pattern * @param string|array $paths + * @param string $pattern * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface @@ -317,4 +308,5 @@ public function setPrefix(string $prefix): GroupInterface protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } + } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index ed4f9a13..b4b07758 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; +use Phalcon\Mvc\Router\RouteInterface; + /** * Phalcon\Mvc\Router\GroupInterface * - *```php + * ```php * $router = new \Phalcon\Mvc\Router(); * * // Create a group with a common module and controller @@ -55,7 +48,7 @@ * * // Add the group to the router * $router->mount($blog); - *``` + * ``` */ interface GroupInterface { @@ -237,4 +230,5 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; + } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index 7e00168c..e3d4e02a 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -1,22 +1,15 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; +use Phalcon\Mvc\Router\Exception; + /** * Phalcon\Mvc\Router\Route * * This class represents every route added to the router */ -class Route implements RouteInterface +class Route implements \Phalcon\Mvc\Router\RouteInterface { protected $beforeMatch; @@ -52,7 +45,7 @@ class Route implements RouteInterface protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; @@ -373,4 +366,5 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } + } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index 91986fca..0baf83d1 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\Router; /** @@ -136,4 +127,5 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; + } diff --git a/src/Phalcon/mvc/view/Exception.php b/src/Phalcon/mvc/view/Exception.php index dd0c0c4c..7ee9726e 100644 --- a/src/Phalcon/mvc/view/Exception.php +++ b/src/Phalcon/mvc/view/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View; /** diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/mvc/view/Simple.php index 45c1f1f6..9c674535 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/mvc/view/Simple.php @@ -1,25 +1,25 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; +use Phalcon\Mvc\View\Exception; use Phalcon\Mvc\ViewBaseInterface; +use Phalcon\Mvc\View\Engine\EngineInterface; +use Phalcon\Mvc\View\Engine\Php; /** * Phalcon\Mvc\View\Simple * * This component allows to render views without hierarchical levels * - *```php + * ```php * use Phalcon\Mvc\View\Simple as View; * * $view = new View(); @@ -39,9 +39,9 @@ * "parameter" => $here, * ] * ); - *``` + * ``` */ -class Simple extends Injectable implements ViewBaseInterface +class Simple extends Injectable implements \Phalcon\Mvc\ViewBaseInterface, \Phalcon\Events\EventsAwareInterface { protected $activeRenderPath; @@ -55,6 +55,9 @@ class Simple extends Injectable implements ViewBaseInterface protected $engines = false; + protected $eventsManager; + + protected $options; @@ -134,6 +137,15 @@ public function getContent(): string { } + /** + * Returns the internal event manager + * + * @return null|\Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ?ManagerInterface + { + } + /** * Returns parameters to views * @@ -231,6 +243,15 @@ public function setContent(string $content): Simple { } + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } + /** * Adds parameters to views (alias of setVar) * @@ -302,10 +323,11 @@ protected function loadTemplateEngines(): array /** * Tries to render the view with every engine registered in the component * - * @param string $path * @param array $params + * @param string $path */ final protected function internalRender(string $path, $params) { } + } diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php index 9436135b..299e55a9 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Mvc\ViewBaseInterface; @@ -18,7 +10,7 @@ * All the template engine adapters must inherit this class. This provides * basic interfacing between the engine and the Phalcon\Mvc\View component. */ -abstract class AbstractEngine extends Injectable implements EngineInterface +abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface { protected $view; @@ -55,11 +47,11 @@ public function getView(): ViewBaseInterface /** * Renders a partial inside another view * - * @param string $partialPath * @param array $params - * @return string + * @param string $partialPath */ - public function partial(string $partialPath, $params = null): string + public function partial(string $partialPath, $params = null) { } + } diff --git a/src/Phalcon/mvc/view/engine/EngineInterface.php b/src/Phalcon/mvc/view/engine/EngineInterface.php index 8842f198..28526844 100644 --- a/src/Phalcon/mvc/view/engine/EngineInterface.php +++ b/src/Phalcon/mvc/view/engine/EngineInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine; /** @@ -29,9 +20,8 @@ public function getContent(): string; * * @param string $partialPath * @param mixed $params - * @return string */ - public function partial(string $partialPath, $params = null): string; + public function partial(string $partialPath, $params = null); /** * Renders a view using the template engine @@ -41,4 +31,5 @@ public function partial(string $partialPath, $params = null): string; * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); + } diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index 8e761c7c..4cfdd15f 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine; +use Phalcon\Mvc\View\Engine\AbstractEngine; + /** * Adapter to use PHP itself as templating engine */ @@ -27,4 +20,5 @@ class Php extends AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } + } diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index 11bd8857..20b4523e 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -1,27 +1,26 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\DiInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\View\Engine\AbstractEngine; use Phalcon\Mvc\View\Engine\Volt\Compiler; +use Phalcon\Mvc\View\Exception; /** * Designer friendly and fast template engine for PHP written in Zephir/C */ -class Volt extends AbstractEngine +class Volt extends AbstractEngine implements \Phalcon\Events\EventsAwareInterface { protected $compiler; + protected $eventsManager; + + protected $macros; @@ -60,6 +59,15 @@ public function getCompiler(): Compiler { } + /** + * Returns the internal event manager + * + * @return null|\Phalcon\Events\ManagerInterface + */ + public function getEventsManager(): ?ManagerInterface + { + } + /** * Return Volt's options * @@ -101,6 +109,15 @@ public function render(string $templatePath, $params, bool $mustClean = false) { } + /** + * Sets the events manager + * + * @param \Phalcon\Events\ManagerInterface $eventsManager + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + { + } + /** * Set Volt's options * @@ -130,4 +147,5 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } + } diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 81e8ebfa..8b994f99 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -1,31 +1,25 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine\Volt; +use Closure; use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ViewBaseInterface; use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\View\Engine\Volt\Exception; /** * This class reads and compiles Volt templates into PHP plain code * - *```php + * ```php * $compiler = new \Phalcon\Mvc\View\Engine\Volt\Compiler(); * * $compiler->compile("views/partials/header.volt"); * * require $compiler->getCompiledTemplatePath(); - *``` + * ``` */ -class Compiler implements InjectionAwareInterface +class Compiler implements \Phalcon\Di\InjectionAwareInterface { protected $autoescape = false; @@ -242,10 +236,10 @@ public function compileElseIf(array $statement): string * ); * ``` * + * @return string|array * @param string $path * @param string $compiledPath * @param bool $extendsMode - * @return string|array */ public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) { @@ -362,9 +356,9 @@ final public function expression(array $expr): string /** * Fires an event to registered extensions * - * @param string $name * @param array $arguments * @return mixed + * @param string $name */ final public function fireExtensionEvent(string $name, $arguments = null) { @@ -428,8 +422,8 @@ public function getFunctions(): array /** * Returns a compiler's option * - * @param string $option * @return string + * @param string $option */ public function getOption(string $option) { @@ -472,8 +466,8 @@ public function getUniquePrefix(): string * ); * ``` * - * @param string $viewCode * @return array + * @param string $viewCode */ public function parse(string $viewCode) { @@ -502,8 +496,8 @@ public function setDI(\Phalcon\Di\DiInterface $container) /** * Sets a single compiler option * - * @param string $option * @param mixed $value + * @param string $option */ public function setOption(string $option, $value) { @@ -579,4 +573,5 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } + } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 6997d16c..95fc5552 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -1,22 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Mvc\View\Engine\Volt; -use Phalcon\Mvc\View\Exception as BaseException; +use Phalcon\Mvc\View\Exception; /** * Class for exceptions thrown by Phalcon\Mvc\View */ -class Exception extends BaseException +class Exception extends \Phalcon\Mvc\View\Exception { protected $statement; @@ -40,4 +31,5 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } + } diff --git a/src/Phalcon/paginator/Exception.php b/src/Phalcon/paginator/Exception.php index 181a13a5..031cfb36 100644 --- a/src/Phalcon/paginator/Exception.php +++ b/src/Phalcon/paginator/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator; /** diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php index 99c31ae3..8b434eb3 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -1,5 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator; +use JsonSerializable; +use Phalcon\Helper\Arr; + /** * Phalcon\Paginator\Repository * * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements RepositoryInterface +class Repository implements \Phalcon\Paginator\RepositoryInterface, \JsonSerializable { /** * @var array @@ -120,6 +114,15 @@ public function getTotalItems(): int { } + /** + * See [jsonSerialize](https://php.net/manual/en/jsonserializable.jsonserialize.php) + * + * @return array + */ + public function jsonSerialize(): array + { + } + /** * {@inheritdoc} * @@ -160,4 +163,5 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } + } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php index 97e8c551..94b41503 100644 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator; /** @@ -122,4 +113,5 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; + } diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/paginator/adapter/AbstractAdapter.php index b8be65c2..aaaa015f 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/paginator/adapter/AbstractAdapter.php @@ -1,22 +1,16 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\Exception; +use Phalcon\Paginator\Repository; use Phalcon\Paginator\RepositoryInterface; +use Phalcon\Paginator\Adapter\AdapterInterface; /** * Phalcon\Paginator\Adapter\AbstractAdapter */ -abstract class AbstractAdapter implements AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInterface { /** * Configuration of paginator @@ -63,9 +57,9 @@ public function getLimit(): int * Set the current page number * * @param int $page - * @return Adapter + * @return \Phalcon\Paginator\Adapter\AdapterInterface */ - public function setCurrentPage(int $page): Adapter + public function setCurrentPage(int $page): AdapterInterface { } @@ -73,9 +67,9 @@ public function setCurrentPage(int $page): Adapter * Set current rows limit * * @param int $limitRows - * @return Adapter + * @return \Phalcon\Paginator\Adapter\AdapterInterface */ - public function setLimit(int $limitRows): Adapter + public function setLimit(int $limitRows): AdapterInterface { } @@ -83,9 +77,9 @@ public function setLimit(int $limitRows): Adapter * Sets current repository for pagination * * @param \Phalcon\Paginator\RepositoryInterface $repository - * @return Adapter + * @return \Phalcon\Paginator\Adapter\AdapterInterface */ - public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): Adapter + public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): AdapterInterface { } @@ -98,4 +92,5 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository protected function getRepository(array $properties = null): RepositoryInterface { } + } diff --git a/src/Phalcon/paginator/adapter/AdapterInterface.php b/src/Phalcon/paginator/adapter/AdapterInterface.php index b61d977e..73410d01 100644 --- a/src/Phalcon/paginator/adapter/AdapterInterface.php +++ b/src/Phalcon/paginator/adapter/AdapterInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator\Adapter; use Phalcon\Paginator\RepositoryInterface; @@ -48,4 +39,5 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); + } diff --git a/src/Phalcon/paginator/adapter/Model.php b/src/Phalcon/paginator/adapter/Model.php index 1287a65d..ce0797c6 100644 --- a/src/Phalcon/paginator/adapter/Model.php +++ b/src/Phalcon/paginator/adapter/Model.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\Exception; +use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; /** @@ -31,7 +24,7 @@ * ); * * $paginate = $paginator->paginate(); - *``` + * ``` */ class Model extends AbstractAdapter { @@ -44,4 +37,5 @@ class Model extends AbstractAdapter public function paginate(): RepositoryInterface { } + } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 8699753d..63aa233e 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\Exception; +use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; /** @@ -34,7 +27,7 @@ * "page" => $currentPage, * ] * ); - *``` + * ``` */ class NativeArray extends AbstractAdapter { @@ -47,4 +40,5 @@ class NativeArray extends AbstractAdapter public function paginate(): RepositoryInterface { } + } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index 80bb9f86..d8a55459 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -1,18 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Paginator\Adapter; +use Phalcon\Db\Enum; use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; +use Phalcon\Paginator\Exception; /** * Phalcon\Paginator\Adapter\QueryBuilder @@ -34,7 +28,7 @@ * "page" => 1, * ] * ); - *``` + * ``` */ class QueryBuilder extends AbstractAdapter { @@ -94,4 +88,5 @@ public function paginate(): RepositoryInterface public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder { } + } diff --git a/src/Phalcon/security/Exception.php b/src/Phalcon/security/Exception.php index c4732477..c13eabd7 100644 --- a/src/Phalcon/security/Exception.php +++ b/src/Phalcon/security/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Security; /** diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/security/Random.php index 2c582c09..c7c782b3 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/security/Random.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Security; /** @@ -25,7 +16,7 @@ * - Generating random passwords for new user accounts * - Encryption systems * - *```php + * ```php * $random = new \Phalcon\Security\Random(); * * // Random binary string @@ -70,7 +61,7 @@ * echo $random->base58(); // Umjxqf7ZPwh765yR * echo $random->base58(24); // qoXcgmw4A9dys26HaNEdCRj9 * echo $random->base58(7); // 774SJD3vgP - *``` + * ``` * * This class partially borrows SecureRandom library from Ruby * @@ -284,4 +275,5 @@ public function uuid(): string protected function base(string $alphabet, int $base, $n = null): string { } + } diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/session/Bag.php index 15c57d71..9a913e35 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/session/Bag.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ namespace Phalcon\Session; use Phalcon\Collection; +use Phalcon\Di; use Phalcon\Di\DiInterface; use Phalcon\Di\InjectionAwareInterface; @@ -28,7 +21,7 @@ * $user->age = 22; * ``` */ -class Bag extends Collection implements InjectionAwareInterface +class Bag extends Collection implements \Phalcon\Di\InjectionAwareInterface { private $container; @@ -101,4 +94,5 @@ public function set(string $element, $value) public function setDI(\Phalcon\Di\DiInterface $container) { } + } diff --git a/src/Phalcon/session/Exception.php b/src/Phalcon/session/Exception.php index 8d4fc6dd..3bff6887 100644 --- a/src/Phalcon/session/Exception.php +++ b/src/Phalcon/session/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session; /** diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index 2a284805..c19e6018 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -1,29 +1,24 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session; use InvalidArgumentException; -use Phalcon\DI\AbstractInjectionAware; +use RuntimeException; use SessionHandlerInterface; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Di\DiInterface; +use Phalcon\Helper\Arr; +use Phalcon\Session\ManagerInterface; /** * Phalcon\Session\Manager * * Session manager class */ -class Manager extends AbstractInjectionAware implements ManagerInterface +class Manager extends AbstractInjectionAware implements \Phalcon\Session\ManagerInterface { /** - * @var |null + * @var SessionHandlerInterface|null */ private $adapter = null; @@ -218,12 +213,10 @@ public function setId(string $id): ManagerInterface * Set the session name. Throw exception if the session has started * and do not allow poop names * - * @param string name - * + * @param string $name * * @throws InvalidArgumentException * - * @param string $name - * @return \Phalcon\Session\ManagerInterface + * @return Manager */ public function setName(string $name): ManagerInterface { @@ -266,4 +259,5 @@ public function status(): int private function getUniqueKey(string $key): string { } + } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php index 5c964f48..f3527130 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/session/ManagerInterface.php @@ -1,17 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session; use InvalidArgumentException; +use RuntimeException; use SessionHandlerInterface; /** @@ -190,4 +182,5 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; + } diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/session/adapter/AbstractAdapter.php index 975d86f6..e806bef9 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/session/adapter/AbstractAdapter.php @@ -1,5 +1,10 @@ + * @var AdapterInterface */ protected $adapter; @@ -82,4 +81,5 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } + } diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 1ad2c068..76e79919 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session\Adapter; +use Phalcon\Storage\AdapterFactory; +use Phalcon\Session\Adapter\AbstractAdapter; + /** * Phalcon\Session\Adapter\Libmemcached */ @@ -26,4 +20,5 @@ class Libmemcached extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index a956a3c3..4ed25e69 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session\Adapter; use SessionHandlerInterface; @@ -29,7 +20,7 @@ * $session->setAdapter(new Noop()); * ``` */ -class Noop implements SessionHandlerInterface +class Noop implements \SessionHandlerInterface { /** * The connection of some adapters @@ -137,4 +128,5 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } + } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 9738fab6..df8dd3eb 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session\Adapter; +use Phalcon\Storage\AdapterFactory; +use Phalcon\Session\Adapter\AbstractAdapter; + /** * Phalcon\Session\Adapter\Redis */ @@ -26,4 +20,5 @@ class Redis extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php index 6febc697..ea2dc826 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/session/adapter/Stream.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Phalcon\Session\Adapter; +use Phalcon\Helper\Str; +use Phalcon\Session\Exception; + /** * Phalcon\Session\Adapter\Stream * @@ -31,7 +25,7 @@ * $session->setAdapter($files); * ``` */ -class Stream extends Noop +class Stream extends \Phalcon\Session\Adapter\Noop { /** * @var string @@ -65,9 +59,9 @@ public function gc($maxlifetime): bool /** * Ignore the savePath and use local defined path * + * @return bool * @param mixed $savePath * @param mixed $sessionName - * @return bool */ public function open($savePath, $sessionName): bool { @@ -89,4 +83,5 @@ public function read($id): string public function write($id, $data): bool { } + } diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php index 642c4af5..1e828831 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/storage/AdapterFactory.php @@ -1,5 +1,12 @@ + * @var SerializerFactory */ private $serializerFactory; @@ -37,9 +38,9 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * * @param string $name * @param array $options - * @return \Phalcon\Storage\Adapter\AbstractAdapter + * @return \Phalcon\Storage\Adapter\AdapterInterface */ - public function newInstance(string $name, array $options = array()): AbstractAdapter + public function newInstance(string $name, array $options = array()): AdapterInterface { } @@ -49,4 +50,5 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } + } diff --git a/src/Phalcon/storage/Exception.php b/src/Phalcon/storage/Exception.php index 49c63fe6..e699f6fa 100644 --- a/src/Phalcon/storage/Exception.php +++ b/src/Phalcon/storage/Exception.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage; /** * Phalcon\Storage\Exception * * Exceptions thrown in Phalcon\Storage will use this class - * */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/storage/SerializerFactory.php b/src/Phalcon/storage/SerializerFactory.php index 24357545..f9705f0d 100644 --- a/src/Phalcon/storage/SerializerFactory.php +++ b/src/Phalcon/storage/SerializerFactory.php @@ -1,5 +1,10 @@ + * @var SerializerInterface */ protected $serializer; /** * Serializer Factory * - * @var + * @var SerializerFactory */ protected $serializerFactory; @@ -190,9 +192,8 @@ protected function getSerializedData($content) * * @param DateInterval|int|null $ttl * - * @throws Exception - * @param mixed $ttl * @return int + * @throws Exception */ protected function getTtl($ttl): int { @@ -215,4 +216,5 @@ protected function getUnserializedData($content, $defaultValue = null) protected function initSerializer() { } + } diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php index 62e55e69..7cf8f08f 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; +use Phalcon\Storage\Serializer\SerializerInterface; + /** * Interface for Phalcon\Logger adapters */ @@ -97,4 +90,5 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; + } diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/storage/adapter/Apcu.php index 2c7e54a5..27bb0abd 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/storage/adapter/Apcu.php @@ -1,16 +1,14 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; +use APCuIterator; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Adapter\AbstractAdapter; +use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; + /** * Apcu adapter */ @@ -44,11 +42,10 @@ public function clear(): bool /** * Decrements a stored number * + * @param string $key * @param int $value * - * @param string $key - * @param int $value - * @return int|bool + * @return bool|int */ public function decrement(string $key, int $value = 1) { @@ -59,7 +56,6 @@ public function decrement(string $key, int $value = 1) * * @param string $key * - * @param string $key * @return bool */ public function delete(string $key): bool @@ -69,10 +65,9 @@ public function delete(string $key): bool /** * Reads data from the adapter * + * @param string $key * @param null $defaultValue * - * @param string $key - * @param mixed $defaultValue * @return mixed */ public function get(string $key, $defaultValue = null) @@ -103,7 +98,6 @@ public function getKeys(): array * * @param string $key * - * @param string $key * @return bool */ public function has(string $key): bool @@ -113,11 +107,10 @@ public function has(string $key): bool /** * Increments a stored number * + * @param string $key * @param int $value * - * @param string $key - * @param int $value - * @return int|bool + * @return bool|int */ public function increment(string $key, int $value = 1) { @@ -126,15 +119,15 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * + * @param string $key + * @param mixed $value * @param null $ttl * - * @throws \Exception - * @param string $key - * @param mixed $value - * @param mixed $ttl * @return bool + * @throws \Exception */ public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/storage/adapter/Libmemcached.php index 5e8873c4..8aba2f8a 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/storage/adapter/Libmemcached.php @@ -1,17 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Libmemcached adapter @@ -27,8 +22,8 @@ class Libmemcached extends AbstractAdapter /** * Libmemcached constructor. * - * @param \Phalcon\Storage\SerializerFactory $factory * @param array $options + * @param \Phalcon\Storage\SerializerFactory $factory */ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) { @@ -37,8 +32,8 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, /** * Flushes/clears the cache * - * @throws Exception * @return bool + * @throws Exception */ public function clear(): bool { @@ -60,9 +55,8 @@ public function decrement(string $key, int $value = 1) * * @param string $key * - * @throws Exception - * @param string $key * @return bool + * @throws Exception */ public function delete(string $key): bool { @@ -71,12 +65,11 @@ public function delete(string $key): bool /** * Reads data from the adapter * + * @param string $key * @param null $defaultValue * - * @throws Exception - * @param string $key - * @param mixed $defaultValue * @return mixed + * @throws Exception */ public function get(string $key, $defaultValue = null) { @@ -86,8 +79,8 @@ public function get(string $key, $defaultValue = null) * Returns the already connected adapter or connects to the Memcached * server(s) * + * @return \Memcached * @throws Exception - * @return mixed */ public function getAdapter() { @@ -96,8 +89,8 @@ public function getAdapter() /** * Stores data in the adapter * - * @throws Exception * @return array + * @throws Exception */ public function getKeys(): array { @@ -108,9 +101,8 @@ public function getKeys(): array * * @param string $key * - * @throws Exception - * @param string $key * @return bool + * @throws Exception */ public function has(string $key): bool { @@ -119,12 +111,11 @@ public function has(string $key): bool /** * Increments a stored number * + * @param string $key * @param int $value * + * @return bool|int * @throws Exception - * @param string $key - * @param int $value - * @return int|bool */ public function increment(string $key, int $value = 1) { @@ -133,13 +124,12 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * + * @param string $key + * @param mixed $value * @param null $ttl * - * @throws Exception - * @param string $key - * @param mixed $value - * @param mixed $ttl * @return bool + * @throws Exception */ public function set(string $key, $value, $ttl = null): bool { @@ -149,9 +139,10 @@ public function set(string $key, $value, $ttl = null): bool * Checks the serializer. If it is a supported one it is set, otherwise * the custom one is set. * - * @param Memcached $connection + * @param \Memcached $connection */ private function setSerializer(\Memcached $connection) { } + } diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/storage/adapter/Memory.php index 2390073f..91d6d1cc 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/storage/adapter/Memory.php @@ -1,17 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; use Phalcon\Collection; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Adapter\AbstractAdapter; +use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Memory adapter @@ -51,11 +47,10 @@ public function clear(): bool /** * Decrements a stored number * + * @param string $key * @param int $value * - * @param string $key - * @param int $value - * @return int|bool + * @return bool|int */ public function decrement(string $key, int $value = 1) { @@ -66,7 +61,6 @@ public function decrement(string $key, int $value = 1) * * @param string $key * - * @param string $key * @return bool */ public function delete(string $key): bool @@ -76,10 +70,9 @@ public function delete(string $key): bool /** * Reads data from the adapter * + * @param string $key * @param mixed|null $defaultValue * - * @param string $key - * @param mixed $defaultValue * @return mixed */ public function get(string $key, $defaultValue = null) @@ -110,7 +103,6 @@ public function getKeys(): array * * @param string $key * - * @param string $key * @return bool */ public function has(string $key): bool @@ -120,11 +112,10 @@ public function has(string $key): bool /** * Increments a stored number * + * @param string $key * @param int $value * - * @param string $key - * @param int $value - * @return int|bool + * @return bool|int */ public function increment(string $key, int $value = 1) { @@ -133,14 +124,14 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * + * @param string $key + * @param mixed $value * @param null $ttl * - * @param string $key - * @param mixed $value - * @param mixed $ttl * @return bool */ public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/storage/adapter/Redis.php index 2a304a7c..f89f2645 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/storage/adapter/Redis.php @@ -1,17 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Redis adapter @@ -37,8 +32,8 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, /** * Flushes/clears the cache * - * @throws Exception * @return bool + * @throws Exception */ public function clear(): bool { @@ -47,12 +42,11 @@ public function clear(): bool /** * Decrements a stored number * + * @param string $key * @param int $value * + * @return bool|int * @throws Exception - * @param string $key - * @param int $value - * @return int|bool */ public function decrement(string $key, int $value = 1) { @@ -63,9 +57,8 @@ public function decrement(string $key, int $value = 1) * * @param string $key * - * @throws Exception - * @param string $key * @return bool + * @throws Exception */ public function delete(string $key): bool { @@ -74,12 +67,11 @@ public function delete(string $key): bool /** * Reads data from the adapter * + * @param string $key * @param null $defaultValue * - * @throws Exception - * @param string $key - * @param mixed $defaultValue * @return mixed + * @throws Exception */ public function get(string $key, $defaultValue = null) { @@ -89,8 +81,8 @@ public function get(string $key, $defaultValue = null) * Returns the already connected adapter or connects to the Memcached * server(s) * + * @return mixed|\Redis * @throws Exception - * @return mixed */ public function getAdapter() { @@ -99,8 +91,8 @@ public function getAdapter() /** * Stores data in the adapter * - * @throws Exception * @return array + * @throws Exception */ public function getKeys(): array { @@ -111,9 +103,8 @@ public function getKeys(): array * * @param string $key * - * @throws Exception - * @param string $key * @return bool + * @throws Exception */ public function has(string $key): bool { @@ -122,12 +113,11 @@ public function has(string $key): bool /** * Increments a stored number * + * @param string $key * @param int $value * + * @return bool|int * @throws Exception - * @param string $key - * @param int $value - * @return int|bool */ public function increment(string $key, int $value = 1) { @@ -136,13 +126,12 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * + * @param string $key + * @param mixed $value * @param null $ttl * - * @throws Exception - * @param string $key - * @param mixed $value - * @param mixed $ttl * @return bool + * @throws Exception */ public function set(string $key, $value, $ttl = null): bool { @@ -157,4 +146,5 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } + } diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/storage/adapter/Stream.php index 0008660d..1971594e 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/storage/adapter/Stream.php @@ -1,18 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Storage\Adapter; +use FilesystemIterator; use Iterator; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; +use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; /** * Stream adapter @@ -22,13 +21,18 @@ class Stream extends AbstractAdapter /** * @var string */ - protected $cacheDir = ''; + protected $storageDir = ''; /** * @var array */ protected $options = array(); + /** + * @var bool + */ + private $warning = false; + /** * Stream constructor. @@ -37,7 +41,6 @@ class Stream extends AbstractAdapter * * @throws Exception * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options */ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) { @@ -55,12 +58,11 @@ public function clear(): bool /** * Decrements a stored number * + * @param string $key * @param int $value * + * @return bool|int * @throws \Exception - * @param string $key - * @param int $value - * @return int|bool */ public function decrement(string $key, int $value = 1) { @@ -71,7 +73,6 @@ public function decrement(string $key, int $value = 1) * * @param string $key * - * @param string $key * @return bool */ public function delete(string $key): bool @@ -81,11 +82,10 @@ public function delete(string $key): bool /** * Reads data from the adapter * + * @param string $key * @param null $defaultValue * - * @param string $key - * @param mixed $defaultValue - * @return mixed + * @return mixed|null */ public function get(string $key, $defaultValue = null) { @@ -115,7 +115,6 @@ public function getKeys(): array * * @param string $key * - * @param string $key * @return bool */ public function has(string $key): bool @@ -125,12 +124,11 @@ public function has(string $key): bool /** * Increments a stored number * + * @param string $key * @param int $value * + * @return bool|int * @throws \Exception - * @param string $key - * @param int $value - * @return int|bool */ public function increment(string $key, int $value = 1) { @@ -139,24 +137,22 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * + * @param string $key + * @param mixed $value * @param null $ttl * - * @throws \Exception - * @param string $key - * @param mixed $value - * @param mixed $ttl * @return bool + * @throws \Exception */ public function set(string $key, $value, $ttl = null): bool { } /** - * Returns the folder based on the cacheDir and the prefix + * Returns the folder based on the storageDir and the prefix * * @param string $key * - * @param string $key * @return string */ private function getDir(string $key = ''): string @@ -174,6 +170,8 @@ private function getFilepath(string $key): string } /** + * Returns an iterator for the directory contents + * * @param string $dir * @return \Iterator */ @@ -181,15 +179,26 @@ private function getIterator(string $dir): Iterator { } + /** + * Gets the file contents and returns an array or an error if something + * went wrong + * + * @param string $filepath + * @return array + */ + private function getPayload(string $filepath): array + { + } + /** * Returns if the cache has expired for this item or not * * @param array $payload * - * @param array $payload * @return bool */ private function isExpired(array $payload): bool { } + } diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/storage/serializer/AbstractSerializer.php index 5e81b812..70fb6b8f 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/storage/serializer/AbstractSerializer.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Tag; /** diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 539de934..f87b8bdb 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -1,16 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Tag; +use Phalcon\Tag\Exception; +use Phalcon\Tag; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Mvc\Model\ResultsetInterface; + /** * Phalcon\Tag\Select * @@ -46,8 +42,8 @@ private static function optionsFromArray(array $data, $value, string $closeOptio /** * Generate the OPTION tags based on a resultset * - * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset * @param array $using + * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset * @param mixed $value * @param string $closeOption * @return string @@ -55,4 +51,5 @@ private static function optionsFromArray(array $data, $value, string $closeOptio private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string { } + } diff --git a/src/Phalcon/translate/Exception.php b/src/Phalcon/translate/Exception.php index 17785ee2..5e18d0a1 100644 --- a/src/Phalcon/translate/Exception.php +++ b/src/Phalcon/translate/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate; /** diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php index 84beea80..35171fe5 100644 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Adapter; +use Phalcon\Helper\Arr; +use Phalcon\Translate\Exception; +use Phalcon\Translate\Adapter\AdapterInterface; use Phalcon\Translate\InterpolatorFactory; /** @@ -18,7 +12,7 @@ * * Base class for Phalcon\Translate adapters */ -abstract class AbstractAdapter implements AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInterface { /** * @var string @@ -42,11 +36,11 @@ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator /** * Returns the translation string of the given key (alias of method 't') * - * @param string $translateKey * @param array $placeholders + * @param string $translateKey * @return string */ - public function _(string $translateKey, $placeholders = null): string + public function _(string $translateKey, array $placeholders = array()): string { } @@ -73,8 +67,8 @@ public function offsetGet($translateKey) /** * Sets a translation value * - * @param mixed $offset * @param string $value + * @param mixed $offset */ public function offsetSet($offset, $value) { @@ -92,11 +86,11 @@ public function offsetUnset($offset) /** * Returns the translation string of the given key * - * @param string $translateKey * @param array $placeholders + * @param string $translateKey * @return string */ - public function t(string $translateKey, $placeholders = null): string + public function t(string $translateKey, array $placeholders = array()): string { } @@ -104,10 +98,11 @@ public function t(string $translateKey, $placeholders = null): string * Replaces placeholders by the values passed * * @param string $translation - * @param mixed $placeholders + * @param array $placeholders * @return string */ - protected function replacePlaceholders(string $translation, $placeholders = null): string + protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/translate/adapter/AdapterInterface.php b/src/Phalcon/translate/adapter/AdapterInterface.php index 57de10d1..748dbfc3 100644 --- a/src/Phalcon/translate/adapter/AdapterInterface.php +++ b/src/Phalcon/translate/adapter/AdapterInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Adapter; /** @@ -30,18 +21,19 @@ public function exists(string $index): bool; /** * Returns the translation related to the given key * - * @param string $translateKey * @param array $placeholders + * @param string $translateKey * @return string */ - public function query(string $translateKey, $placeholders = null): string; + public function query(string $translateKey, array $placeholders = array()): string; /** * Returns the translation string of the given key * - * @param string $translateKey * @param array $placeholders + * @param string $translateKey * @return string */ - public function t(string $translateKey, $placeholders = null): string; + public function t(string $translateKey, array $placeholders = array()): string; + } diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 14f03d2d..6ca609e5 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -1,24 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Adapter; use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\Adapter\AbstractAdapter; +use Phalcon\Translate\InterpolatorFactory; /** * Phalcon\Translate\Adapter\Csv * * Allows to define translation lists using CSV file */ -class Csv extends AbstractAdapter implements ArrayAccess +class Csv extends AbstractAdapter implements \ArrayAccess { /** * @var array @@ -50,10 +44,10 @@ public function exists(string $index): bool * Returns the translation related to the given key * * @param string $index - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function query(string $index, $placeholders = null): string + public function query(string $index, array $placeholders = array()): string { } @@ -68,4 +62,5 @@ public function query(string $index, $placeholders = null): string private function load(string $file, int $length, string $delimiter, string $enclosure) { } + } diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 5c502b29..29ba4a98 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Adapter; use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\Adapter\AbstractAdapter; +use Phalcon\Translate\InterpolatorFactory; /** * Phalcon\Translate\Adapter\Gettext @@ -31,7 +25,7 @@ * * Allows translate using gettext */ -class Gettext extends AbstractAdapter implements ArrayAccess +class Gettext extends AbstractAdapter implements \ArrayAccess { /** * @var int @@ -110,11 +104,11 @@ public function exists(string $index): bool * @param string $msgid1 * @param string $msgid2 * @param int $count - * @param mixed $placeholders + * @param array $placeholders * @param string $domain * @return string */ - public function nquery(string $msgid1, string $msgid2, int $count, $placeholders = null, string $domain = null): string + public function nquery(string $msgid1, string $msgid2, int $count, array $placeholders = array(), string $domain = null): string { } @@ -125,11 +119,11 @@ public function nquery(string $msgid1, string $msgid2, int $count, $placeholders * $translator->query("你好 %name%!", ["name" => "Phalcon"]); * ``` * - * @param string $index * @param array $placeholders + * @param string $index * @return string */ - public function query(string $index, $placeholders = null): string + public function query(string $index, array $placeholders = array()): string { } @@ -219,4 +213,5 @@ protected function getOptionsDefault(): array protected function prepareOptions(array $options) { } + } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index fead32cc..b95b97d7 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -1,24 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Adapter; use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\Adapter\AbstractAdapter; +use Phalcon\Translate\InterpolatorFactory; /** * Phalcon\Translate\Adapter\NativeArray * * Allows to define translation lists using PHP arrays */ -class NativeArray extends AbstractAdapter implements ArrayAccess +class NativeArray extends AbstractAdapter implements \ArrayAccess { /** * @var array @@ -65,10 +59,11 @@ public function notFound(string $index): string * Returns the translation related to the given key * * @param string $index - * @param mixed $placeholders + * @param array $placeholders * @return string */ - public function query(string $index, $placeholders = null): string + public function query(string $index, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index b7051f05..b18e1177 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -1,5 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Translate\Interpolator; /** @@ -27,4 +18,5 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; + } diff --git a/src/Phalcon/url/Exception.php b/src/Phalcon/url/Exception.php index c7990195..806bb1bb 100644 --- a/src/Phalcon/url/Exception.php +++ b/src/Phalcon/url/Exception.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Url; /** diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/url/UrlInterface.php index 140d2ca1..e67b5ed5 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/url/UrlInterface.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Url; /** @@ -64,4 +55,5 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; + } diff --git a/src/Phalcon/validation/AbstractCombinedFieldsValidator.php b/src/Phalcon/validation/AbstractCombinedFieldsValidator.php index 27026224..1ac58d5c 100644 --- a/src/Phalcon/validation/AbstractCombinedFieldsValidator.php +++ b/src/Phalcon/validation/AbstractCombinedFieldsValidator.php @@ -1,20 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; /** * This is a base class for combined fields validators */ -abstract class AbstractCombinedFieldsValidator extends AbstractValidator +abstract class AbstractCombinedFieldsValidator extends \Phalcon\Validation\AbstractValidator { } diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/validation/AbstractValidator.php index 289a47a4..59e317ab 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/validation/AbstractValidator.php @@ -1,22 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; +use Phalcon\Collection; +use Phalcon\Helper\Arr; use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\Exception; +use Phalcon\Validation\ValidatorInterface; /** * This is a base class for validators */ -abstract class AbstractValidator implements ValidatorInterface +abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface { /** * Message template @@ -48,9 +44,9 @@ public function __construct(array $options = array()) /** * Get the template message * + * @return string * @throw InvalidArgumentException When the field does not exists * @param string $field - * @return string */ public function getTemplate(string $field = null): string { @@ -68,8 +64,8 @@ public function getTemplates(): array /** * Clear current templates and set new from an array, * + * @return ValidatorInterface * @param array $templates - * @return \Phalcon\Validation\ValidatorInterface */ public function setTemplates(array $templates): ValidatorInterface { @@ -78,8 +74,8 @@ public function setTemplates(array $templates): ValidatorInterface /** * Set a new template message * + * @return ValidatorInterface * @param string $template - * @return \Phalcon\Validation\ValidatorInterface */ public function setTemplate(string $template): ValidatorInterface { @@ -156,9 +152,9 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) * @param \Phalcon\Validation $validation * @param mixed $field * @param array $replacements - * @return \Phalcon\Messages\Message */ public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message { } + } diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/validation/AbstractValidatorComposite.php index fd1cc0f5..32992942 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/validation/AbstractValidatorComposite.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; +use Phalcon\Validation; + /** * This is a base class for combined fields validators */ -abstract class AbstractValidatorComposite extends AbstractValidator implements ValidatorCompositeInterface +abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements \Phalcon\Validation\ValidatorCompositeInterface { /** * @var array @@ -39,4 +32,5 @@ public function getValidators(): array public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/Exception.php b/src/Phalcon/validation/Exception.php index 2d69169b..24ac4a6b 100644 --- a/src/Phalcon/validation/Exception.php +++ b/src/Phalcon/validation/Exception.php @@ -1,18 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; /** - * Exceptions thrown in Phalcon\Validation\* classes will use this class + * Exceptions thrown in Phalcon\Validation\ classes will use this class */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/validation/ValidationInterface.php index 4f4208bc..246d3ea0 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/validation/ValidationInterface.php @@ -1,17 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; +use Phalcon\Di\Injectable; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; +use Phalcon\Validation\Exception; +use Phalcon\Validation\ValidatorInterface; /** * Interface for the Phalcon\Validation component @@ -112,8 +107,8 @@ public function rules(string $field, array $validators): ValidationInterface; /** * Adds filters to the field * - * @param string $field * @param array|string $filters + * @param string $field * @return ValidationInterface */ public function setFilters(string $field, $filters): ValidationInterface; @@ -133,4 +128,5 @@ public function setLabels(array $labels); * @return \Phalcon\Messages\Messages */ public function validate($data = null, $entity = null): Messages; + } diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/validation/ValidatorCompositeInterface.php index ff5517fe..880c9f5e 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/validation/ValidatorCompositeInterface.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; +use Phalcon\Validation; + /** * This is a base class for combined fields validators */ @@ -32,4 +25,5 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; + } diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/validation/ValidatorFactory.php index 5a9d8a04..978fd037 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/validation/ValidatorFactory.php @@ -1,5 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation; +use Phalcon\Collection; +use Phalcon\Validation; + /** * Interface for Phalcon\Validation\AbstractValidator */ @@ -21,35 +15,35 @@ interface ValidatorInterface * Returns an option in the validator's options * Returns null if the option hasn't set * + * @return mixed * @param string $key * @param mixed $defaultValue - * @return mixed */ public function getOption(string $key, $defaultValue = null); /** * Checks if an option is defined * + * @return boolean * @param string $key - * @return bool */ public function hasOption(string $key): bool; /** * Executes the validation * + * @return boolean * @param \Phalcon\Validation $validation * @param mixed $field - * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; /** * Get the template message * + * @return string * @throw InvalidArgumentException When the field does not exists * @param string $field - * @return string */ public function getTemplate(string $field): string; @@ -63,16 +57,17 @@ public function getTemplates(): array; /** * Clear current template and set new from an array, * - * @param array $templates * @return ValidatorInterface + * @param array $templates */ public function setTemplates(array $templates): ValidatorInterface; /** * Set a new temlate message * - * @param string $template * @return ValidatorInterface + * @param string $template */ public function setTemplate(string $template): ValidatorInterface; + } diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index 55f5e951..a4b7d94c 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -1,16 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +55,5 @@ class Alnum extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index c3ae3047..6c499b4b 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class Alpha extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 48ab93b3..5a9ecbec 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -74,4 +67,5 @@ class Between extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 5655dc60..02a9be2e 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\ValidatorInterface; use Phalcon\Validation\AbstractValidator; /** @@ -73,4 +67,5 @@ class Callback extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 7bf794ba..2d289fbd 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\Exception; use Phalcon\Validation\AbstractValidator; /** @@ -79,4 +73,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } + } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index d2bd9b83..ed89d3d5 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -74,4 +67,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } + } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index c952f8b9..4e07f977 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -1,16 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use DateTime; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -77,4 +71,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } + } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 602bb2f8..f7144ecf 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class Digit extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 237e041a..c6abf1b3 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class Email extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Exception.php b/src/Phalcon/validation/validator/Exception.php index 3307bc9b..240b1809 100644 --- a/src/Phalcon/validation/validator/Exception.php +++ b/src/Phalcon/validation/validator/Exception.php @@ -1,18 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; /** - * Exceptions thrown in Phalcon\Validation\Validator\* classes will use this + * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this * class */ class Exception extends \Phalcon\Exception diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index 8b0049c2..21abdbc1 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Check if a value is not included into a list of values @@ -74,4 +68,5 @@ class ExclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index 13d86e30..224e120a 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -1,17 +1,18 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Helper\Arr; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidatorComposite; +use Phalcon\Validation\Validator\File\MimeType; +use Phalcon\Validation\Validator\File\Resolution\Equal; +use Phalcon\Validation\Validator\File\Resolution\Max; +use Phalcon\Validation\Validator\File\Resolution\Min; +use Phalcon\Validation\Validator\File\Size\Equal; +use Phalcon\Validation\Validator\File\Size\Max; +use Phalcon\Validation\Validator\File\Size\Min; /** * Checks if a value has a correct file @@ -91,4 +92,5 @@ class File extends AbstractValidatorComposite public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 7ad7a702..6daeff5d 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -68,4 +61,5 @@ class Identical extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 63ca375e..4291f368 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Check if a value is included into a list of values @@ -68,4 +62,5 @@ class InclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index b72960ab..cc5ca5e2 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -1,17 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Messages\Message; /** * Check for IP addresses @@ -86,4 +79,5 @@ class Ip extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index bf7203fb..cc697601 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class Numericality extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index bd254e75..97edb6b3 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class PresenceOf extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index 152d0f79..fdce9c4a 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -68,4 +61,5 @@ class Regex extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index e50d4c21..0c25974a 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -1,17 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation\AbstractValidator; use Phalcon\Validation\AbstractValidatorComposite; +use Phalcon\Validation\Validator\StringLength\Max; +use Phalcon\Validation\Validator\StringLength\Min; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum and minimum constraints @@ -86,4 +82,5 @@ class StringLength extends AbstractValidatorComposite public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index 3e16b4a0..cd4e2c00 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -1,20 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Validation; use Phalcon\Validation\AbstractCombinedFieldsValidator; - -//use Phalcon\Mvc\CollectionInterface; -//use Phalcon\Mvc\Collection; +use Phalcon\Validation\Exception; /** * Check that a field is unique in the related table @@ -136,4 +129,5 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } + } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 0929bf8a..efd86cc8 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -63,4 +56,5 @@ class Url extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php index 8f270d98..cd25e3a4 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -121,8 +114,8 @@ public function setMessageValid($messageValid) /** * Check on empty * - * @param Valiation $validation - * @param mixed $field + * @param Validation $validation + * @param string $field * @return bool */ public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool @@ -132,7 +125,7 @@ public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bo /** * Check upload * - * @param Valiation $validation + * @param Validation $validation * @param mixed $field * @return bool */ @@ -143,9 +136,9 @@ public function checkUpload(\Phalcon\Validation $validation, $field): bool /** * Check if uploaded file is larger than PHP allowed size * - * @param Valiation $validation + * @param Validation $validation * @param mixed $field - * @return bool + * @return boolean */ public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool { @@ -154,9 +147,9 @@ public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): boo /** * Check if upload is empty * - * @param Valiation $validation + * @param Validation $validation * @param mixed $field - * @return bool + * @return boolean */ public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool { @@ -165,9 +158,9 @@ public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): boo /** * Check if upload is valid * - * @param Valiation $validation + * @param Validation $validation * @param mixed $field - * @return bool + * @return boolean */ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool { @@ -177,9 +170,10 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo * Convert a string like "2.5MB" in bytes * * @param string $size - * @return double + * @return float */ public function getFileSizeInBytes(string $size): float { } + } diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php index 50bb37e7..d8102f27 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -1,16 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File; +use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\Exception; +use Phalcon\Validation\Validator\File\AbstractFile; + /** * Checks if a value has a correct file mime type * @@ -68,11 +64,12 @@ class MimeType extends AbstractFile /** * Executes the validation * - * @param Valiation $validation + * @param Validation $validation * @param mixed $field * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php index 0c4eb988..3828cdc3 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -68,4 +61,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php index 5e489a41..441d4b70 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,4 +66,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php index b02efcc6..210d13f9 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,4 +66,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php index 3fd86902..f58deb17 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,4 +66,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php index f8bdcef7..1b17e49d 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,4 +66,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php index 10c534af..609af4c5 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -1,16 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -73,4 +66,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php index b0c386c8..8c6e14cb 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum constraints @@ -75,4 +69,5 @@ class Max extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php index 75f8acab..e2170e62 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -1,17 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified minimum constraints @@ -75,4 +69,5 @@ class Min extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } From 83f30e5d0cf5b9ee66ee2aaa9639346bd81e7df1 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sat, 26 Oct 2019 22:04:02 +0200 Subject: [PATCH 19/25] Optimized import fo fix errors Fixed return type docblock --- src/Phalcon/Cache.php | 2 -- src/Phalcon/Collection.php | 6 ----- src/Phalcon/Config.php | 3 --- src/Phalcon/Container.php | 1 - src/Phalcon/Crypt.php | 2 -- src/Phalcon/Debug.php | 7 ----- src/Phalcon/Di.php | 8 ------ src/Phalcon/Escaper.php | 4 --- src/Phalcon/Filter.php | 4 --- src/Phalcon/Loader.php | 2 -- src/Phalcon/Logger.php | 3 --- src/Phalcon/Registry.php | 1 - src/Phalcon/Security.php | 3 --- src/Phalcon/Tag.php | 2 -- src/Phalcon/Text.php | 2 -- src/Phalcon/Url.php | 3 --- src/Phalcon/Validation.php | 7 ----- src/Phalcon/acl/Component.php | 2 -- src/Phalcon/acl/Role.php | 2 -- src/Phalcon/acl/adapter/AbstractAdapter.php | 1 - src/Phalcon/acl/adapter/AdapterInterface.php | 3 --- src/Phalcon/acl/adapter/Memory.php | 10 ------- src/Phalcon/annotations/Annotation.php | 2 -- .../annotations/AnnotationsFactory.php | 1 - src/Phalcon/annotations/Collection.php | 5 ---- src/Phalcon/annotations/Reader.php | 3 --- src/Phalcon/annotations/Reflection.php | 2 -- .../annotations/adapter/AbstractAdapter.php | 6 ++--- .../annotations/adapter/AdapterInterface.php | 2 +- src/Phalcon/annotations/adapter/Apcu.php | 3 --- src/Phalcon/annotations/adapter/Memory.php | 3 --- src/Phalcon/annotations/adapter/Stream.php | 4 --- .../application/AbstractApplication.php | 2 -- src/Phalcon/assets/Collection.php | 10 ------- src/Phalcon/assets/Manager.php | 9 ------- src/Phalcon/assets/asset/Css.php | 2 -- src/Phalcon/assets/asset/Js.php | 2 -- src/Phalcon/assets/filters/Cssmin.php | 2 -- src/Phalcon/assets/filters/Jsmin.php | 2 -- src/Phalcon/assets/filters/None.php | 2 -- src/Phalcon/assets/inline/Css.php | 2 -- src/Phalcon/assets/inline/Js.php | 2 -- src/Phalcon/cache/AdapterFactory.php | 1 - src/Phalcon/cache/CacheFactory.php | 6 ----- .../cache/adapter/AdapterInterface.php | 2 -- src/Phalcon/cache/adapter/Apcu.php | 3 --- src/Phalcon/cache/adapter/Libmemcached.php | 3 --- src/Phalcon/cache/adapter/Memory.php | 3 --- src/Phalcon/cache/adapter/Redis.php | 3 --- src/Phalcon/cache/adapter/Stream.php | 3 --- src/Phalcon/cli/Console.php | 4 --- src/Phalcon/cli/Dispatcher.php | 5 ---- src/Phalcon/cli/DispatcherInterface.php | 2 -- src/Phalcon/cli/Router.php | 5 +--- src/Phalcon/cli/Task.php | 1 - src/Phalcon/cli/router/Route.php | 2 -- src/Phalcon/collection/Exception.php | 2 -- src/Phalcon/collection/ReadOnly.php | 1 - src/Phalcon/config/ConfigFactory.php | 9 ------- src/Phalcon/config/adapter/Grouped.php | 3 --- src/Phalcon/config/adapter/Ini.php | 1 - src/Phalcon/config/adapter/Yaml.php | 1 - src/Phalcon/db/AbstractDb.php | 2 -- src/Phalcon/db/Column.php | 3 --- src/Phalcon/db/DialectInterface.php | 4 --- src/Phalcon/db/adapter/AbstractAdapter.php | 8 ------ src/Phalcon/db/adapter/AdapterInterface.php | 4 --- src/Phalcon/db/adapter/PdoFactory.php | 2 -- src/Phalcon/db/adapter/pdo/AbstractPdo.php | 5 ---- src/Phalcon/db/adapter/pdo/Mysql.php | 10 ------- src/Phalcon/db/adapter/pdo/Postgresql.php | 8 ------ src/Phalcon/db/adapter/pdo/Sqlite.php | 9 ------- src/Phalcon/db/dialect/Mysql.php | 6 ----- src/Phalcon/db/dialect/Postgresql.php | 6 ----- src/Phalcon/db/dialect/Sqlite.php | 6 ----- src/Phalcon/db/result/Pdo.php | 2 -- src/Phalcon/debug/Dump.php | 6 ----- src/Phalcon/di/AbstractInjectionAware.php | 4 --- src/Phalcon/di/DiInterface.php | 3 --- src/Phalcon/di/FactoryDefault.php | 2 -- src/Phalcon/di/Injectable.php | 4 --- src/Phalcon/di/InjectionAwareInterface.php | 2 -- src/Phalcon/di/Service.php | 7 ----- src/Phalcon/di/ServiceInterface.php | 2 -- src/Phalcon/di/ServiceProviderInterface.php | 2 -- .../exception/ServiceResolutionException.php | 2 -- src/Phalcon/di/factorydefault/Cli.php | 2 -- src/Phalcon/di/service/Builder.php | 3 --- src/Phalcon/dispatcher/AbstractDispatcher.php | 7 ----- src/Phalcon/domain/payload/Payload.php | 2 -- src/Phalcon/domain/payload/PayloadFactory.php | 3 --- .../domain/payload/PayloadInterface.php | 3 --- .../domain/payload/WriteableInterface.php | 2 -- src/Phalcon/events/Event.php | 2 -- src/Phalcon/events/Manager.php | 4 --- src/Phalcon/factory/AbstractFactory.php | 3 --- src/Phalcon/filter/FilterFactory.php | 3 --- .../firewall/adapter/AbstractAdapter.php | 2 +- src/Phalcon/firewall/adapter/Acl.php | 7 ----- .../firewall/adapter/AdapterInterface.php | 2 -- src/Phalcon/firewall/adapter/Annotations.php | 6 ----- src/Phalcon/firewall/adapter/micro/Acl.php | 9 ------- src/Phalcon/flash/AbstractFlash.php | 4 --- src/Phalcon/flash/Direct.php | 2 -- src/Phalcon/flash/Session.php | 3 --- src/Phalcon/forms/Form.php | 8 ------ src/Phalcon/forms/element/AbstractElement.php | 5 ---- src/Phalcon/forms/element/Check.php | 3 --- src/Phalcon/forms/element/Date.php | 3 --- .../forms/element/ElementInterface.php | 2 -- src/Phalcon/forms/element/Email.php | 3 --- src/Phalcon/forms/element/File.php | 3 --- src/Phalcon/forms/element/Hidden.php | 3 --- src/Phalcon/forms/element/Numeric.php | 3 --- src/Phalcon/forms/element/Password.php | 3 --- src/Phalcon/forms/element/Radio.php | 3 --- src/Phalcon/forms/element/Select.php | 4 --- src/Phalcon/forms/element/Submit.php | 3 --- src/Phalcon/forms/element/Text.php | 3 --- src/Phalcon/forms/element/TextArea.php | 3 --- src/Phalcon/helper/Arr.php | 3 --- src/Phalcon/helper/Number.php | 2 -- src/Phalcon/helper/Str.php | 4 --- src/Phalcon/html/Attributes.php | 2 -- src/Phalcon/html/Breadcrumbs.php | 2 -- src/Phalcon/html/TagFactory.php | 1 - src/Phalcon/html/helper/AbstractHelper.php | 1 - src/Phalcon/html/helper/Anchor.php | 2 -- src/Phalcon/html/helper/AnchorRaw.php | 2 -- src/Phalcon/html/helper/Body.php | 2 -- src/Phalcon/html/helper/Button.php | 2 -- src/Phalcon/html/helper/Element.php | 2 -- src/Phalcon/html/helper/Form.php | 2 -- src/Phalcon/html/helper/TextArea.php | 2 -- src/Phalcon/http/Cookie.php | 7 ----- src/Phalcon/http/Request.php | 7 ----- src/Phalcon/http/RequestInterface.php | 3 --- src/Phalcon/http/Response.php | 14 ++-------- src/Phalcon/http/ResponseInterface.php | 1 - src/Phalcon/http/message/AbstractCommon.php | 2 -- src/Phalcon/http/message/AbstractMessage.php | 2 -- src/Phalcon/http/message/AbstractRequest.php | 3 --- src/Phalcon/http/message/Request.php | 2 -- src/Phalcon/http/message/RequestFactory.php | 3 +-- src/Phalcon/http/message/Response.php | 3 --- src/Phalcon/http/message/ResponseFactory.php | 3 +-- src/Phalcon/http/message/ServerRequest.php | 2 -- .../http/message/ServerRequestFactory.php | 6 +---- src/Phalcon/http/message/Stream.php | 3 --- src/Phalcon/http/message/StreamFactory.php | 2 -- src/Phalcon/http/message/UploadedFile.php | 4 --- .../http/message/UploadedFileFactory.php | 3 +-- src/Phalcon/http/message/Uri.php | 3 --- src/Phalcon/http/message/UriFactory.php | 1 - .../exception/InvalidArgumentException.php | 2 -- src/Phalcon/http/request/File.php | 2 -- src/Phalcon/http/response/Cookies.php | 3 --- src/Phalcon/http/response/Headers.php | 2 -- src/Phalcon/image/ImageFactory.php | 2 -- src/Phalcon/image/adapter/AbstractAdapter.php | 1 - src/Phalcon/image/adapter/Gd.php | 4 --- src/Phalcon/image/adapter/Imagick.php | 4 --- src/Phalcon/logger/LoggerFactory.php | 3 --- .../logger/adapter/AbstractAdapter.php | 4 --- .../logger/adapter/AdapterInterface.php | 1 - src/Phalcon/logger/adapter/Noop.php | 2 -- src/Phalcon/logger/adapter/Stream.php | 6 ----- src/Phalcon/logger/adapter/Syslog.php | 8 ------ .../logger/formatter/AbstractFormatter.php | 2 -- .../logger/formatter/FormatterInterface.php | 2 -- src/Phalcon/logger/formatter/Json.php | 3 --- src/Phalcon/logger/formatter/Line.php | 1 - src/Phalcon/logger/formatter/Syslog.php | 3 --- src/Phalcon/messages/Message.php | 3 --- src/Phalcon/messages/MessageInterface.php | 2 -- src/Phalcon/messages/Messages.php | 8 ------ src/Phalcon/mvc/Application.php | 10 ------- src/Phalcon/mvc/Dispatcher.php | 7 ----- src/Phalcon/mvc/DispatcherInterface.php | 3 --- src/Phalcon/mvc/Micro.php | 15 +---------- src/Phalcon/mvc/Model.php | 27 +------------------ src/Phalcon/mvc/ModelInterface.php | 3 --- src/Phalcon/mvc/ModuleDefinitionInterface.php | 2 -- src/Phalcon/mvc/Router.php | 6 ----- src/Phalcon/mvc/RouterInterface.php | 2 -- src/Phalcon/mvc/View.php | 8 ------ src/Phalcon/mvc/ViewBaseInterface.php | 2 -- src/Phalcon/mvc/micro/LazyLoader.php | 2 -- src/Phalcon/mvc/micro/MiddlewareInterface.php | 2 -- src/Phalcon/mvc/model/Behavior.php | 3 --- src/Phalcon/mvc/model/BehaviorInterface.php | 2 -- src/Phalcon/mvc/model/Binder.php | 5 ---- src/Phalcon/mvc/model/Criteria.php | 8 +----- src/Phalcon/mvc/model/CriteriaInterface.php | 2 -- src/Phalcon/mvc/model/Manager.php | 17 +++--------- src/Phalcon/mvc/model/ManagerInterface.php | 5 +--- src/Phalcon/mvc/model/MetaData.php | 5 ---- src/Phalcon/mvc/model/MetaDataInterface.php | 1 - src/Phalcon/mvc/model/Query.php | 19 +------------ src/Phalcon/mvc/model/Relation.php | 2 -- src/Phalcon/mvc/model/ResultInterface.php | 2 -- src/Phalcon/mvc/model/Resultset.php | 15 +---------- src/Phalcon/mvc/model/ResultsetInterface.php | 4 +-- src/Phalcon/mvc/model/Row.php | 7 ----- src/Phalcon/mvc/model/Transaction.php | 6 ----- .../mvc/model/TransactionInterface.php | 3 --- src/Phalcon/mvc/model/behavior/SoftDelete.php | 2 -- .../mvc/model/behavior/Timestampable.php | 3 --- src/Phalcon/mvc/model/metadata/Apcu.php | 2 -- .../mvc/model/metadata/Libmemcached.php | 3 --- src/Phalcon/mvc/model/metadata/Memory.php | 1 - src/Phalcon/mvc/model/metadata/Redis.php | 1 - src/Phalcon/mvc/model/metadata/Stream.php | 1 - .../model/metadata/strategy/Annotations.php | 7 ----- .../model/metadata/strategy/Introspection.php | 8 ------ .../metadata/strategy/StrategyInterface.php | 3 --- src/Phalcon/mvc/model/query/Builder.php | 6 ----- src/Phalcon/mvc/model/query/Status.php | 2 -- .../mvc/model/query/StatusInterface.php | 1 - src/Phalcon/mvc/model/resultset/Complex.php | 11 -------- src/Phalcon/mvc/model/resultset/Simple.php | 6 ----- src/Phalcon/mvc/model/transaction/Failed.php | 2 -- src/Phalcon/mvc/model/transaction/Manager.php | 5 ---- src/Phalcon/mvc/router/Annotations.php | 3 --- src/Phalcon/mvc/router/GroupInterface.php | 2 -- src/Phalcon/mvc/router/Route.php | 2 -- src/Phalcon/mvc/view/Simple.php | 9 ------- .../mvc/view/engine/AbstractEngine.php | 1 - src/Phalcon/mvc/view/engine/Php.php | 2 -- src/Phalcon/mvc/view/engine/Volt.php | 4 --- src/Phalcon/mvc/view/engine/volt/Compiler.php | 4 --- .../mvc/view/engine/volt/Exception.php | 4 +-- src/Phalcon/paginator/PaginatorFactory.php | 3 +-- src/Phalcon/paginator/Repository.php | 3 --- .../paginator/adapter/AbstractAdapter.php | 3 --- src/Phalcon/paginator/adapter/Model.php | 2 -- src/Phalcon/paginator/adapter/NativeArray.php | 2 -- .../paginator/adapter/QueryBuilder.php | 3 --- src/Phalcon/session/Bag.php | 2 -- src/Phalcon/session/Manager.php | 6 +---- src/Phalcon/session/ManagerInterface.php | 1 - .../session/adapter/AbstractAdapter.php | 1 - src/Phalcon/session/adapter/Libmemcached.php | 3 --- src/Phalcon/session/adapter/Noop.php | 2 -- src/Phalcon/session/adapter/Redis.php | 3 --- src/Phalcon/session/adapter/Stream.php | 3 --- src/Phalcon/storage/AdapterFactory.php | 2 -- .../storage/adapter/AbstractAdapter.php | 5 +--- .../storage/adapter/AdapterInterface.php | 2 -- src/Phalcon/storage/adapter/Apcu.php | 7 ----- src/Phalcon/storage/adapter/Libmemcached.php | 4 --- src/Phalcon/storage/adapter/Memory.php | 5 ---- src/Phalcon/storage/adapter/Redis.php | 4 --- src/Phalcon/storage/adapter/Stream.php | 8 ------ .../storage/serializer/AbstractSerializer.php | 3 --- src/Phalcon/storage/serializer/Base64.php | 3 --- src/Phalcon/storage/serializer/Igbinary.php | 2 -- src/Phalcon/storage/serializer/Json.php | 3 --- src/Phalcon/storage/serializer/Msgpack.php | 2 -- src/Phalcon/storage/serializer/None.php | 3 --- src/Phalcon/storage/serializer/Php.php | 4 --- .../serializer/SerializerInterface.php | 2 -- src/Phalcon/tag/Select.php | 5 ---- src/Phalcon/translate/TranslateFactory.php | 3 --- .../translate/adapter/AbstractAdapter.php | 3 --- src/Phalcon/translate/adapter/Csv.php | 5 ---- src/Phalcon/translate/adapter/Gettext.php | 5 ---- src/Phalcon/translate/adapter/NativeArray.php | 5 ---- .../interpolator/AssociativeArray.php | 2 -- .../translate/interpolator/IndexedArray.php | 2 -- src/Phalcon/validation/AbstractValidator.php | 5 ---- .../validation/AbstractValidatorComposite.php | 2 -- .../validation/ValidationInterface.php | 4 --- .../ValidatorCompositeInterface.php | 2 -- src/Phalcon/validation/ValidatorFactory.php | 1 - src/Phalcon/validation/ValidatorInterface.php | 3 --- src/Phalcon/validation/validator/Alnum.php | 1 - src/Phalcon/validation/validator/Alpha.php | 2 -- src/Phalcon/validation/validator/Between.php | 2 -- src/Phalcon/validation/validator/Callback.php | 3 --- .../validation/validator/Confirmation.php | 3 --- .../validation/validator/CreditCard.php | 2 -- src/Phalcon/validation/validator/Date.php | 3 --- src/Phalcon/validation/validator/Digit.php | 2 -- src/Phalcon/validation/validator/Email.php | 2 -- .../validation/validator/ExclusionIn.php | 3 --- src/Phalcon/validation/validator/File.php | 10 ------- .../validation/validator/Identical.php | 2 -- .../validation/validator/InclusionIn.php | 3 --- src/Phalcon/validation/validator/Ip.php | 2 -- .../validation/validator/Numericality.php | 2 -- .../validation/validator/PresenceOf.php | 2 -- src/Phalcon/validation/validator/Regex.php | 2 -- .../validation/validator/StringLength.php | 5 ---- .../validation/validator/Uniqueness.php | 5 ---- src/Phalcon/validation/validator/Url.php | 2 -- .../validator/file/AbstractFile.php | 1 - .../validation/validator/file/MimeType.php | 3 --- .../validator/file/resolution/Equal.php | 2 -- .../validator/file/resolution/Max.php | 2 -- .../validator/file/resolution/Min.php | 2 -- .../validation/validator/file/size/Equal.php | 2 -- .../validation/validator/file/size/Max.php | 2 -- .../validation/validator/file/size/Min.php | 2 -- .../validation/validator/stringlength/Max.php | 3 --- .../validation/validator/stringlength/Min.php | 3 --- 306 files changed, 26 insertions(+), 1092 deletions(-) diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index 89a44168..e680bfd8 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -3,10 +3,8 @@ namespace Phalcon; use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Cache\Exception\Exception; use Phalcon\Cache\Exception\InvalidArgumentException; use Psr\SimpleCache\CacheInterface; -use Traversable; /** * This component offers caching capabilities for your application. diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index 95dbe615..b6389b32 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -2,12 +2,6 @@ namespace Phalcon; -use ArrayAccess; -use ArrayIterator; -use Countable; -use IteratorAggregate; -use JsonSerializable; -use Serializable; use Traversable; /** diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index cf636df8..54b9b5ee 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -2,9 +2,6 @@ namespace Phalcon; -use Phalcon\Collection; -use Phalcon\Config\Exception; - /** * `Phalcon\Config` is designed to simplify the access to, and the use of, * configuration data within applications. It provides a nested object property diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 41138431..682790d0 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -2,7 +2,6 @@ namespace Phalcon; -use Psr\Container\ContainerInterface; use Phalcon\Di\DiInterface; /** diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 6d5be468..1e8fba6c 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -3,8 +3,6 @@ namespace Phalcon; use Phalcon\Crypt\CryptInterface; -use Phalcon\Crypt\Exception; -use Phalcon\Crypt\Mismatch; /** * Provides encryption capabilities to Phalcon applications. diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 0f7cd8bc..8176e61f 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -2,13 +2,6 @@ namespace Phalcon; -use ErrorException; -use Phalcon\Helper\Arr; -use Phalcon\Version; -use Phalcon\Tag; -use ReflectionClass; -use ReflectionFunction; - /** * Provides debug capabilities to Phalcon applications */ diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 183ae2e9..e3ba7bca 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -2,17 +2,9 @@ namespace Phalcon; -use Phalcon\Config; -use Phalcon\Di\Service; use Phalcon\Di\DiInterface; -use Phalcon\Di\Exception; -use Phalcon\Di\Exception\ServiceResolutionException; -use Phalcon\Config\Adapter\Php; -use Phalcon\Config\Adapter\Yaml; use Phalcon\Di\ServiceInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Di\ServiceProviderInterface; /** * Phalcon\Di is a component that implements Dependency Injection/Service diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index fb0c104d..b4b81f61 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -2,10 +2,6 @@ namespace Phalcon; -use Phalcon\Di\DiInterface; -use Phalcon\Escaper\EscaperInterface; -use Phalcon\Escaper\Exception; - /** * Phalcon\Escaper * diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index 55c95efb..af1d47eb 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -2,10 +2,6 @@ namespace Phalcon; -use Closure; -use Phalcon\Filter\Exception; -use Phalcon\Filter\FilterInterface; - /** * Lazy loads, stores and exposes sanitizer objects */ diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index fea947bc..5b8c36c5 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -2,9 +2,7 @@ namespace Phalcon; -use Phalcon\Loader\Exception; use Phalcon\Events\ManagerInterface; -use Phalcon\Events\EventsAwareInterface; /** * This component helps to load your project classes automatically based on some diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 231cfbd2..94f4c4b9 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -2,10 +2,7 @@ namespace Phalcon; -use Psr\Log\LoggerInterface; -use Psr\Log\InvalidArgumentException; use Phalcon\Logger\Adapter\AdapterInterface; -use Phalcon\Logger\Item; use Phalcon\Logger\Exception; /** diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 6733a322..8908b38c 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -2,7 +2,6 @@ namespace Phalcon; -use Phalcon\Collection; use Traversable; /** diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index cc2a9879..72385801 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -2,12 +2,9 @@ namespace Phalcon; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; use Phalcon\Security\Random; -use Phalcon\Security\Exception; -use Phalcon\Session\ManagerInterface; /** * This component provides a set of functions to improve the security in Phalcon diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 42b46d2f..29dfc532 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -4,8 +4,6 @@ use Phalcon\Di\DiInterface; use Phalcon\Escaper\EscaperInterface; -use Phalcon\Tag\Select; -use Phalcon\Tag\Exception; use Phalcon\Url\UrlInterface; /** diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index a99b4fbe..3856fa28 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -2,8 +2,6 @@ namespace Phalcon; -use Phalcon\Helper\Str; - /** * Provides utilities to work with texts */ diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index 4b18ceaa..8cb01ae2 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -2,11 +2,8 @@ namespace Phalcon; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Mvc\RouterInterface; -use Phalcon\Mvc\Router\RouteInterface; -use Phalcon\Url\Exception; use Phalcon\Url\UrlInterface; /** diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index 3fdef9e4..9480ffe7 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -2,16 +2,9 @@ namespace Phalcon; -use Phalcon\Di; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; -use Phalcon\Filter\FilterInterface; -use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; use Phalcon\Validation\ValidationInterface; -use Phalcon\Validation\Exception; -use Phalcon\Validation\ValidatorInterface; -use Phalcon\Validation\AbstractCombinedFieldsValidator; /** * Allows to validate data using custom or built-in validators diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index 3bc345a9..af42828c 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -2,8 +2,6 @@ namespace Phalcon\Acl; -use Phalcon\Acl\Exception; - /** * This class defines component entity and its description */ diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/acl/Role.php index fe8ea30f..32174e12 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/acl/Role.php @@ -2,8 +2,6 @@ namespace Phalcon\Acl; -use Phalcon\Acl\Exception; - /** * This class defines role entity and its description */ diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/adapter/AbstractAdapter.php index e6cc811b..d1d265b7 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/adapter/AbstractAdapter.php @@ -3,7 +3,6 @@ namespace Phalcon\Acl\Adapter; use Phalcon\Events\ManagerInterface; -use Phalcon\Events\EventsAwareInterface; /** * Adapter for Phalcon\Acl adapters diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/acl/adapter/AdapterInterface.php index ee6cc3b9..76530327 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/acl/adapter/AdapterInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Acl\Adapter; -use Phalcon\Acl\ComponentInterface; -use Phalcon\Acl\RoleInterface; - /** * Interface for Phalcon\Acl adapters */ diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/acl/adapter/Memory.php index ee154893..32402257 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/acl/adapter/Memory.php @@ -2,17 +2,7 @@ namespace Phalcon\Acl\Adapter; -use Phalcon\Acl\Adapter\AbstractAdapter; use Phalcon\Acl\Enum; -use Phalcon\Acl\Role; -use Phalcon\Acl\RoleInterface; -use Phalcon\Acl\Component; -use Phalcon\Acl\Exception; -use Phalcon\Events\Manager; -use Phalcon\Acl\RoleAware; -use Phalcon\Acl\ComponentAware; -use Phalcon\Acl\ComponentInterface; -use ReflectionFunction; /** * Manages ACL lists in memory diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index a68bb788..73c32ac7 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -2,8 +2,6 @@ namespace Phalcon\Annotations; -use Phalcon\Annotations\Exception; - /** * Represents a single annotation in an annotations collection */ diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php index c4d8f337..48c8ebdd 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -4,7 +4,6 @@ use Phalcon\Annotations\Adapter\AbstractAdapter; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * Factory to create annotations components diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/annotations/Collection.php index 9e081f91..89818e02 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/annotations/Collection.php @@ -2,11 +2,6 @@ namespace Phalcon\Annotations; -use Countable; -use Iterator; -use Phalcon\Annotations\Annotation; -use Phalcon\Annotations\Exception; - /** * Represents a collection of annotations. This class allows to traverse a group * of annotations easily diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index c7595c4d..b085d963 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -2,9 +2,6 @@ namespace Phalcon\Annotations; -use Phalcon\Annotations\ReaderInterface; -use ReflectionClass; - /** * Parses docblocks returning an array with the found annotations */ diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index bad164f3..ae86841f 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -2,8 +2,6 @@ namespace Phalcon\Annotations; -use Phalcon\Annotations\Collection; - /** * Allows to manipulate the annotations reflection in an OO manner * diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php index 35d5a754..f1750128 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -2,12 +2,10 @@ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Adapter\AdapterInterface; -use Phalcon\Annotations\Reader; -use Phalcon\Annotations\Exception; use Phalcon\Annotations\Collection; -use Phalcon\Annotations\Reflection; +use Phalcon\Annotations\Reader; use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Reflection; /** * This is the base class for Phalcon\Annotations adapters diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/annotations/adapter/AdapterInterface.php index cb354b80..31895549 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/annotations/adapter/AdapterInterface.php @@ -2,9 +2,9 @@ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Reflection; use Phalcon\Annotations\Collection; use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Reflection; /** * This interface must be implemented by adapters in Phalcon\Annotations diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index bd0aa686..d191f10b 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -2,9 +2,6 @@ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Adapter\AbstractAdapter; -use Phalcon\Annotations\Reflection; - /** * Stores the parsed annotations in APCu. This adapter is suitable for production * diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index 72578f7c..f0b7a267 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -2,9 +2,6 @@ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Adapter\AbstractAdapter; -use Phalcon\Annotations\Reflection; - /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Stream.php index af030a8f..d61b8780 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -2,10 +2,6 @@ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Adapter\AbstractAdapter; -use Phalcon\Annotations\Reflection; -use Phalcon\Annotations\Exception; - /** * Stores the parsed annotations in files. This adapter is suitable for production * diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index 3fcc9085..64da7660 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -2,10 +2,8 @@ namespace Phalcon\Application; -use Phalcon\Application\Exception; use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/assets/Collection.php index 479cf1c9..69ad96e2 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/assets/Collection.php @@ -2,16 +2,6 @@ namespace Phalcon\Assets; -use Countable; -use Iterator; -use Phalcon\Assets\Asset; -use Phalcon\Assets\FilterInterface; -use Phalcon\Assets\Inline; -use Phalcon\Assets\Asset\Css; -use Phalcon\Assets\Asset\Js; -use Phalcon\Assets\Inline\Js; -use Phalcon\Assets\Inline\Css; - /** * Represents a collection of assets */ diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index 9943b8fd..6d5b66bb 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -2,15 +2,6 @@ namespace Phalcon\Assets; -use Phalcon\Tag; -use Phalcon\Assets\Asset; -use Phalcon\Assets\Collection; -use Phalcon\Assets\Exception; -use Phalcon\Assets\Asset\Js; -use Phalcon\Assets\Asset\Css; -use Phalcon\Assets\Inline\Css; -use Phalcon\Assets\Inline\Js; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; /** diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/assets/asset/Css.php index 3d2e7a3a..bfc4313a 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/assets/asset/Css.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Asset; -use Phalcon\Assets\Asset; - /** * Represents CSS assets */ diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/assets/asset/Js.php index 12b7227c..7d1032e2 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/assets/asset/Js.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Asset; -use Phalcon\Assets\Asset; - /** * Represents Javascript assets */ diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/assets/filters/Cssmin.php index 5c12236b..4964b7f8 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/assets/filters/Cssmin.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Filters; -use Phalcon\Assets\FilterInterface; - /** * Minify the css - removes comments removes newlines and line feeds keeping * removes last semicolon from last property diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/assets/filters/Jsmin.php index e49d298f..9f5356cd 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/assets/filters/Jsmin.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Filters; -use Phalcon\Assets\FilterInterface; - /** * Deletes the characters which are insignificant to JavaScript. Comments will * be removed. Tabs will be replaced with spaces. Carriage returns will be diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/assets/filters/None.php index 9632bc90..eea54d58 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/assets/filters/None.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Filters; -use Phalcon\Assets\FilterInterface; - /** * Returns the content without make any modification to the original source */ diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/assets/inline/Css.php index 0941a929..a6f2a205 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/assets/inline/Css.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Inline; -use Phalcon\Assets\Inline; - /** * Represents an inlined CSS */ diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/assets/inline/Js.php index e01a92af..c8b04f72 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/assets/inline/Js.php @@ -2,8 +2,6 @@ namespace Phalcon\Assets\Inline; -use Phalcon\Assets\Inline; - /** * Represents an inline JavaScript */ diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/cache/AdapterFactory.php index 426aa23b..73e79832 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/cache/AdapterFactory.php @@ -3,7 +3,6 @@ namespace Phalcon\Cache; use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Cache\Exception\Exception; use Phalcon\Factory\AbstractFactory; use Phalcon\Storage\SerializerFactory; diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/cache/CacheFactory.php index da3ea961..13c5d0c9 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/cache/CacheFactory.php @@ -2,13 +2,7 @@ namespace Phalcon\Cache; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Cache\AdapterFactory; -use Phalcon\Cache; use Psr\SimpleCache\CacheInterface; -use Phalcon\Cache\Exception\Exception; -use Phalcon\Config; -use Phalcon\Helper\Arr; /** * Creates a new Cache class diff --git a/src/Phalcon/cache/adapter/AdapterInterface.php b/src/Phalcon/cache/adapter/AdapterInterface.php index d62bc87d..0acab0d8 100644 --- a/src/Phalcon/cache/adapter/AdapterInterface.php +++ b/src/Phalcon/cache/adapter/AdapterInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Storage\Adapter\AdapterInterface; - /** * Interface for Phalcon\Cache adapters */ diff --git a/src/Phalcon/cache/adapter/Apcu.php b/src/Phalcon/cache/adapter/Apcu.php index 7d97798d..30224f78 100644 --- a/src/Phalcon/cache/adapter/Apcu.php +++ b/src/Phalcon/cache/adapter/Apcu.php @@ -2,9 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Adapter\Apcu; - /** * Apcu adapter */ diff --git a/src/Phalcon/cache/adapter/Libmemcached.php b/src/Phalcon/cache/adapter/Libmemcached.php index 7345a7ec..964d2fd7 100644 --- a/src/Phalcon/cache/adapter/Libmemcached.php +++ b/src/Phalcon/cache/adapter/Libmemcached.php @@ -2,9 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Adapter\Libmemcached; - /** * Libmemcached adapter */ diff --git a/src/Phalcon/cache/adapter/Memory.php b/src/Phalcon/cache/adapter/Memory.php index 2ce43e5c..9b80800e 100644 --- a/src/Phalcon/cache/adapter/Memory.php +++ b/src/Phalcon/cache/adapter/Memory.php @@ -2,9 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Adapter\Memory; - /** * Memory adapter */ diff --git a/src/Phalcon/cache/adapter/Redis.php b/src/Phalcon/cache/adapter/Redis.php index ee7c5182..ec116325 100644 --- a/src/Phalcon/cache/adapter/Redis.php +++ b/src/Phalcon/cache/adapter/Redis.php @@ -2,9 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Adapter\Redis; - /** * Redis adapter */ diff --git a/src/Phalcon/cache/adapter/Stream.php b/src/Phalcon/cache/adapter/Stream.php index 7f671609..23c3c1e3 100644 --- a/src/Phalcon/cache/adapter/Stream.php +++ b/src/Phalcon/cache/adapter/Stream.php @@ -2,9 +2,6 @@ namespace Phalcon\Cache\Adapter; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Adapter\Stream; - /** * Stream adapter */ diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 4bd0bebe..77acfe2a 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -3,10 +3,6 @@ namespace Phalcon\Cli; use Phalcon\Application\AbstractApplication; -use Phalcon\Cli\Router\Route; -use Phalcon\Cli\Console\Exception; -use Phalcon\Di\DiInterface; -use Phalcon\Events\ManagerInterface; /** * This component allows to create CLI applications using Phalcon diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index 0db8a627..de74a5b5 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -2,11 +2,6 @@ namespace Phalcon\Cli; -use Phalcon\Cli\Dispatcher\Exception; -use Phalcon\Dispatcher\AbstractDispatcher; -use Phalcon\Events\ManagerInterface; -use Phalcon\Filter\FilterInterface; - /** * Dispatching is the process of taking the command-line arguments, extracting * the module name, task name, action name, and optional parameters contained in diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index 62b79d89..eed77c38 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Cli; -use Phalcon\Dispatcher\DispatcherInterface; - /** * Interface for Phalcon\Cli\Dispatcher */ diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index 7c5a8758..bd5fa234 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -2,11 +2,8 @@ namespace Phalcon\Cli; -use Phalcon\Di\DiInterface; -use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Cli\Router\Route; -use Phalcon\Cli\Router\Exception; use Phalcon\Cli\Router\RouteInterface; +use Phalcon\Di\AbstractInjectionAware; /** * Phalcon\Cli\Router is the standard framework router. Routing is the process diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index 1afcdd86..dd399c74 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -3,7 +3,6 @@ namespace Phalcon\Cli; use Phalcon\Di\Injectable; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 3ae8c801..42fc9a52 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -2,8 +2,6 @@ namespace Phalcon\Cli\Router; -use Phalcon\Cli\Router\RouteInterface; - /** * This class represents every route added to the router */ diff --git a/src/Phalcon/collection/Exception.php b/src/Phalcon/collection/Exception.php index 4236b04b..8137be78 100644 --- a/src/Phalcon/collection/Exception.php +++ b/src/Phalcon/collection/Exception.php @@ -2,8 +2,6 @@ namespace Phalcon\Collection; -use Throwable; - /** * Exceptions for the Collection object */ diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/collection/ReadOnly.php index 73f500e5..9cdb2eb2 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/collection/ReadOnly.php @@ -3,7 +3,6 @@ namespace Phalcon\Collection; use Phalcon\Collection; -use Phalcon\Collection\Exception; /** * Phalcon\Collection\ReadOnly is a read only Collection object diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/config/ConfigFactory.php index fbb4cc98..ac5cce55 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/config/ConfigFactory.php @@ -2,16 +2,7 @@ namespace Phalcon\Config; -use Phalcon\Config; -use Phalcon\Config\Adapter\Grouped; -use Phalcon\Config\Adapter\Ini; -use Phalcon\Config\Adapter\Json; -use Phalcon\Config\Adapter\Php; -use Phalcon\Config\Adapter\Yaml; -use Phalcon\Config\Exception; use Phalcon\Factory\AbstractFactory; -use Phalcon\Factory\Exception; -use Phalcon\Helper\Arr; /** * Loads Config Adapter class using 'adapter' option, if no extension is diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index f51e67cb..83d53cbf 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -3,9 +3,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Config\Exception; -use Phalcon\Factory\Exception; -use Phalcon\Config\ConfigFactory; /** * Reads multiple files (or arrays) and merges them all together. diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 0a23b19f..27de2d5e 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -3,7 +3,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Config\Exception; /** * Reads ini files and converts them to Phalcon\Config objects. diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index c55f8df1..fe22659f 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -3,7 +3,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Config\Exception; /** * Reads YAML files and converts them to Phalcon\Config objects. diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/db/AbstractDb.php index ef31352b..faf5d492 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/db/AbstractDb.php @@ -2,8 +2,6 @@ namespace Phalcon\Db; -use \PDO; - /** * Phalcon\Db and its related classes provide a simple SQL database interface * for Phalcon Framework. The Phalcon\Db is the basic class you use to connect diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 239546c9..5bc4457f 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -2,9 +2,6 @@ namespace Phalcon\Db; -use Phalcon\Db\Exception; -use Phalcon\Db\ColumnInterface; - /** * Allows to define columns to be used on create or alter table operations * diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index fe1061c1..0e8e587d 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -2,10 +2,6 @@ namespace Phalcon\Db; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\ReferenceInterface; -use Phalcon\Db\IndexInterface; - /** * Interface for Phalcon\Db dialects */ diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index 134ca6c0..e768f3c9 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -3,16 +3,8 @@ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; -use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; -use Phalcon\Db\Exception; -use Phalcon\Db\Index; -use Phalcon\Db\IndexInterface; -use Phalcon\Db\Reference; -use Phalcon\Db\ReferenceInterface; use Phalcon\Db\RawValue; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index 0fe826a0..33611efd 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -3,11 +3,7 @@ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; -use Phalcon\Db\ResultInterface; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; -use Phalcon\Db\ReferenceInterface; /** * Interface for Phalcon\Db adapters diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php index 25cafc44..ce2bc323 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -2,9 +2,7 @@ namespace Phalcon\Db\Adapter; -use Phalcon\Db\Adapter\AbstractAdapter; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php index 3b778040..a923ff6d 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -3,11 +3,6 @@ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; -use Phalcon\Db\Column; -use Phalcon\Db\Exception; -use Phalcon\Db\Result\Pdo; -use Phalcon\Db\ResultInterface; -use Phalcon\Events\ManagerInterface; /** * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index c871006f..e2b967c7 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -2,16 +2,6 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo; -use Phalcon\Db\Column; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\Enum; -use Phalcon\Db\Exception; -use Phalcon\Db\Index; -use Phalcon\Db\IndexInterface; -use Phalcon\Db\Reference; -use Phalcon\Db\ReferenceInterface; - /** * Specific functions for the Mysql database system * diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index 5b431af5..c1452061 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -2,15 +2,7 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo; -use Phalcon\Db\Column; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\Enum; -use Phalcon\Db\Exception; use Phalcon\Db\RawValue; -use Phalcon\Db\Reference; -use Phalcon\Db\ReferenceInterface; -use Throwable; /** * Specific functions for the Postgresql database system diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index 6701942c..a1b4c2b8 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -2,16 +2,7 @@ namespace Phalcon\Db\Adapter\Pdo; -use Phalcon\Db\Adapter\Pdo\AbstractPdo; -use Phalcon\Db\Column; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\Enum; -use Phalcon\Db\Exception; -use Phalcon\Db\Index; -use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; -use Phalcon\Db\Reference; -use Phalcon\Db\ReferenceInterface; /** * Specific functions for the Sqlite database system diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 4ab04ab3..0b004487 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -3,12 +3,6 @@ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; -use Phalcon\Db\Column; -use Phalcon\Db\Exception; -use Phalcon\Db\IndexInterface; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\ReferenceInterface; -use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the MySQL RDBMS diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 8c10a7f2..4f1b43f5 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -3,12 +3,6 @@ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; -use Phalcon\Db\Column; -use Phalcon\Db\Exception; -use Phalcon\Db\IndexInterface; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\ReferenceInterface; -use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the PostgreSQL RDBMS diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index 390f1d32..e7b4cca5 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -2,13 +2,7 @@ namespace Phalcon\Db\Dialect; -use Phalcon\Db\Column; -use Phalcon\Db\Exception; -use Phalcon\Db\IndexInterface; use Phalcon\Db\Dialect; -use Phalcon\Db\DialectInterface; -use Phalcon\Db\ColumnInterface; -use Phalcon\Db\ReferenceInterface; /** * Generates database specific SQL for the SQLite RDBMS diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 45f1e438..3bd03566 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -3,8 +3,6 @@ namespace Phalcon\Db\Result; use Phalcon\Db\Enum; -use Phalcon\Db\ResultInterface; -use Phalcon\Db\Adapter\AdapterInterface; /** * Encapsulates the resultset internals diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index 40e10901..f2ae8f6d 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -2,12 +2,6 @@ namespace Phalcon\Debug; -use Phalcon\Di; -use Reflection; -use ReflectionClass; -use ReflectionProperty; -use stdClass; - /** * Dumps information about a variable(s) * diff --git a/src/Phalcon/di/AbstractInjectionAware.php b/src/Phalcon/di/AbstractInjectionAware.php index adf55c9e..3a7790bb 100644 --- a/src/Phalcon/di/AbstractInjectionAware.php +++ b/src/Phalcon/di/AbstractInjectionAware.php @@ -2,10 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; - /** * This abstract class offers common access to the DI in a class */ diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/di/DiInterface.php index 44846e6d..d1995d31 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Di; -use ArrayAccess; -use Phalcon\Di\ServiceInterface; - /** * Interface for Phalcon\Di */ diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index 60c4460c..7b75437b 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -2,8 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Filter\FilterFactory; - /** * This is a variant of the standard Phalcon\Di. By default it automatically * registers all the services provided by the framework. Thanks to this, the diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index 69998357..55b12a8e 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -2,10 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Di\Exception; use Phalcon\Session\BagInterface; /** diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index dae522eb..d12064ac 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Di\DiInterface; - /** * This interface must be implemented in those classes that uses internally the * Phalcon\Di that creates them diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index 33d80d31..81e5032b 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -2,13 +2,6 @@ namespace Phalcon\Di; -use Closure; -use Phalcon\Di\DiInterface; -use Phalcon\Di\Exception; -use Phalcon\Di\Exception\ServiceResolutionException; -use Phalcon\Di\ServiceInterface; -use Phalcon\Di\Service\Builder; - /** * Represents individually a service in the services container * diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index 39877b02..90647806 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Di\DiInterface; - /** * Represents a service in the services container */ diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index e55695f7..e61eaedb 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Di; -use Phalcon\Di\DiInterface; - /** * Should be implemented by service providers, or such components, which * register a service in the service container. diff --git a/src/Phalcon/di/exception/ServiceResolutionException.php b/src/Phalcon/di/exception/ServiceResolutionException.php index adb67374..15c7d6b3 100644 --- a/src/Phalcon/di/exception/ServiceResolutionException.php +++ b/src/Phalcon/di/exception/ServiceResolutionException.php @@ -2,8 +2,6 @@ namespace Phalcon\Di\Exception; -use Phalcon\Di\Exception\ServiceResolutionException; - /** * Phalcon\Di\Exception\ServiceResolutionException */ diff --git a/src/Phalcon/di/factorydefault/Cli.php b/src/Phalcon/di/factorydefault/Cli.php index 907b9c3d..0b7bad40 100644 --- a/src/Phalcon/di/factorydefault/Cli.php +++ b/src/Phalcon/di/factorydefault/Cli.php @@ -3,8 +3,6 @@ namespace Phalcon\Di\FactoryDefault; use Phalcon\Di\FactoryDefault; -use Phalcon\Di\Service; -use Phalcon\Filter\FilterFactory; /** * Phalcon\Di\FactoryDefault\Cli diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/di/service/Builder.php index eac41917..d83b465b 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/di/service/Builder.php @@ -2,9 +2,6 @@ namespace Phalcon\Di\Service; -use Phalcon\Di\DiInterface; -use Phalcon\Di\Exception; - /** * Phalcon\Di\Service\Builder * diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/dispatcher/AbstractDispatcher.php index 7d102775..b092ff52 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/dispatcher/AbstractDispatcher.php @@ -2,15 +2,8 @@ namespace Phalcon\Dispatcher; -use Exception; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Dispatcher\DispatcherInterface; -use Phalcon\Dispatcher\Exception; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Filter\FilterInterface; -use Phalcon\Mvc\Model\Binder; use Phalcon\Mvc\Model\BinderInterface; /** diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/domain/payload/Payload.php index d943bec6..b3117f15 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/domain/payload/Payload.php @@ -2,8 +2,6 @@ namespace Phalcon\Domain\Payload; -use Phalcon\Domain\Payload\PayloadInterface; - /** * Holds the payload */ diff --git a/src/Phalcon/domain/payload/PayloadFactory.php b/src/Phalcon/domain/payload/PayloadFactory.php index 9d34be34..739ac257 100644 --- a/src/Phalcon/domain/payload/PayloadFactory.php +++ b/src/Phalcon/domain/payload/PayloadFactory.php @@ -2,9 +2,6 @@ namespace Phalcon\Domain\Payload; -use Phalcon\Domain\Payload\Payload; -use Phalcon\Domain\Payload\PayloadInterface; - /** * Factory to create payload objects */ diff --git a/src/Phalcon/domain/payload/PayloadInterface.php b/src/Phalcon/domain/payload/PayloadInterface.php index 0bdd9661..11b00467 100644 --- a/src/Phalcon/domain/payload/PayloadInterface.php +++ b/src/Phalcon/domain/payload/PayloadInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Domain\Payload; -use Phalcon\Domain\Payload\ReadableInterface; -use Phalcon\Domain\Payload\WriteableInterface; - /** * This interface is used for consumers */ diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/domain/payload/WriteableInterface.php index 3027bf85..cf737f0c 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/domain/payload/WriteableInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Domain\Payload; -use Phalcon\Domain\Payload\PayloadInterface; - /** * This interface is used for consumers (write) */ diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/events/Event.php index 83e7d8f3..6e8b3142 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/events/Event.php @@ -2,8 +2,6 @@ namespace Phalcon\Events; -use Phalcon\Events\Exception; - /** * Phalcon\Events\Event * diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index 147a9b84..5aa8fa91 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -2,10 +2,6 @@ namespace Phalcon\Events; -use Closure; -use Phalcon\Events\Event; -use SplPriorityQueue; - /** * Phalcon\Events\Manager * diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php index ca15053b..31396f92 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/factory/AbstractFactory.php @@ -2,9 +2,6 @@ namespace Phalcon\Factory; -use Phalcon\Config; -use Phalcon\Factory\Exception; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/filter/FilterFactory.php index a78d1a37..690c108f 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/filter/FilterFactory.php @@ -2,9 +2,6 @@ namespace Phalcon\Filter; -use Phalcon\Filter; -use Phalcon\Filter\FilterInterface; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/firewall/adapter/AbstractAdapter.php index 21c253f8..3807da09 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/firewall/adapter/AbstractAdapter.php @@ -5,7 +5,7 @@ use Closure; use Phalcon\Acl\Enum; use Phalcon\Acl\RoleAware; -use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; use Phalcon\Di\DiInterface; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php index 27821bec..ec36390f 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -2,13 +2,6 @@ namespace Phalcon\Firewall\Adapter; -use Phalcon\Acl\Adapter\AdapterInterface; -use Phalcon\Di; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Events\Event; -use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Adapter\AbstractAdapter; -use Phalcon\Firewall\Exception; use Phalcon\Mvc\DispatcherInterface; /** diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/firewall/adapter/AdapterInterface.php index 964cbbf8..d38b6148 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/firewall/adapter/AdapterInterface.php @@ -3,8 +3,6 @@ namespace Phalcon\Firewall\Adapter; use Closure; -use Phalcon\Mvc\DispatcherInterface; -use Phalcon\Cache\Adapter\AdapterInterface; /** * Interface for Phalcon\Mvc\Dispatcher\Firewall adapters diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/firewall/adapter/Annotations.php index 49a7df98..9424746c 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/firewall/adapter/Annotations.php @@ -2,13 +2,7 @@ namespace Phalcon\Firewall\Adapter; -use Phalcon\Annotations\Adapter\AdapterInterface; -use Phalcon\Events\Event; -use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Adapter\AbstractAdapter; -use Phalcon\Firewall\Exception; use Phalcon\Mvc\DispatcherInterface; -use ReflectionClass; /** * Firewall which depends on annotations and dispatcher diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/firewall/adapter/micro/Acl.php index 7f0fff1e..72483f90 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/firewall/adapter/micro/Acl.php @@ -2,17 +2,8 @@ namespace Phalcon\Firewall\Adapter\Micro; -use Phalcon\Acl\Adapter\AdapterInterface; -use Phalcon\Di; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Di\DiInterface; -use Phalcon\Events\Event; -use Phalcon\Events\ManagerInterface; use Phalcon\Firewall\Adapter\AbstractAdapter; -use Phalcon\Firewall\Exception; use Phalcon\Mvc\Micro; -use Phalcon\Mvc\Model\BinderInterface; -use Phalcon\Mvc\Router; /** * Firewall for Phalcon\Mvc\Micro which depends on ACL diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/flash/AbstractFlash.php index 2abac054..f48a7fd8 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/flash/AbstractFlash.php @@ -2,12 +2,8 @@ namespace Phalcon\Flash; -use Phalcon\Di; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Escaper\EscaperInterface; -use Phalcon\Flash\Exception; -use Phalcon\Session\ManagerInterface; /** * Shows HTML notifications related to different circumstances. Classes can be diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index 64b3052f..e70ffb0e 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -2,8 +2,6 @@ namespace Phalcon\Flash; -use Phalcon\Flash\AbstractFlash; - /** * This is a variant of the Phalcon\Flash that immediately outputs any message * passed to it diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/flash/Session.php index 45557ab4..ccf30cea 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/flash/Session.php @@ -2,9 +2,6 @@ namespace Phalcon\Flash; -use Phalcon\Di\DiInterface; -use Phalcon\Flash\AbstractFlash; -use Phalcon\Flash\Exception; use Phalcon\Session\ManagerInterface; /** diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/forms/Form.php index 7d6699b8..d9a105a6 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/forms/Form.php @@ -2,19 +2,11 @@ namespace Phalcon\Forms; -use Countable; -use Iterator; use Phalcon\Di\Injectable; -use Phalcon\Di\DiInterface; -use Phalcon\Filter\FilterInterface; -use Phalcon\Forms\Exception; use Phalcon\Forms\Element\ElementInterface; use Phalcon\Html\Attributes; use Phalcon\Html\Attributes\AttributesInterface; use Phalcon\Messages\Messages; -use Phalcon\Tag; -use Phalcon\Validation; -use Phalcon\Validation\ValidationInterface; /** * This component allows to build forms using an object-oriented interface diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/forms/element/AbstractElement.php index 62d002c7..903f45be 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -2,13 +2,8 @@ namespace Phalcon\Forms\Element; -use InvalidArgumentException; use Phalcon\Forms\Form; -use Phalcon\Forms\Exception; -use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; -use Phalcon\Tag; -use Phalcon\Validation\ValidatorInterface; /** * This is a base class for form elements diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index d51919cf..2cf1e024 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Check * diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index 0126d5c4..8d37a028 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Component INPUT[type=date] for forms */ diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/forms/element/ElementInterface.php index bbf821e5..a8c29101 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/forms/element/ElementInterface.php @@ -3,9 +3,7 @@ namespace Phalcon\Forms\Element; use Phalcon\Forms\Form; -use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; -use Phalcon\Validation\ValidatorInterface; /** * Interface for Phalcon\Forms\Element classes diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index 873a220b..96d70d99 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Email * diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index db78a619..a50e054e 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Component INPUT[type=file] for forms */ diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index 2e8e1bef..29558220 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Hidden * diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 74e821a4..1f8b48eb 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Numeric * diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 844718d5..49f3b795 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Password * diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index f8fc85a3..6d9e0af4 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Radio * diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index dba15a30..92c05612 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -2,10 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Forms\Element\AbstractElement; -use Phalcon\Tag\Select; -use Phalcon\Forms\Element\ElementInterface; - /** * Phalcon\Forms\Element\Select * diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index 7324adfa..c64cd2a6 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Component INPUT[type=submit] for forms */ diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index 745e6bb0..b0f55d39 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Phalcon\Forms\Element\Text * diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index 6c8eda69..cf43c71c 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -2,9 +2,6 @@ namespace Phalcon\Forms\Element; -use Phalcon\Tag; -use Phalcon\Forms\Element\AbstractElement; - /** * Component TEXTAREA for forms */ diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index 1ac05dbb..1dc7e540 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -2,9 +2,6 @@ namespace Phalcon\Helper; -use Phalcon\Helper\Exception; -use stdClass; - /** * This class offers quick array functions throughout the framework */ diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php index 23301aaf..d2696d15 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/helper/Number.php @@ -2,8 +2,6 @@ namespace Phalcon\Helper; -use Phalcon\Helper\Exception; - /** * Phalcon\Helper\number * diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/helper/Str.php index 317241ab..0e9a456d 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/helper/Str.php @@ -2,10 +2,6 @@ namespace Phalcon\Helper; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Exception; -use RuntimeException; - /** * This class offers quick string functions throughout the framework */ diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/html/Attributes.php index 3be816dd..48665f8b 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/html/Attributes.php @@ -3,8 +3,6 @@ namespace Phalcon\Html; use Phalcon\Collection; -use Phalcon\Html\Attributes\RenderInterface; -use Phalcon\Tag; /** * This class helps to work with HTML Attributes diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/html/Breadcrumbs.php index 45586642..86463993 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/html/Breadcrumbs.php @@ -2,8 +2,6 @@ namespace Phalcon\Html; -use Phalcon\Di\DiInterface; - /** * Phalcon\Html\Breadcrumbs * diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php index a1d9e2b3..eb7953c5 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/html/TagFactory.php @@ -2,7 +2,6 @@ namespace Phalcon\Html; -use Phalcon\Escaper; use Phalcon\Escaper\EscaperInterface; use Phalcon\Factory\AbstractFactory; diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/html/helper/AbstractHelper.php index d2b124f0..24ddf7e6 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/html/helper/AbstractHelper.php @@ -2,7 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Exception; use Phalcon\Escaper\EscaperInterface; /** diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 8f85c1d0..1d90510a 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Anchor * diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php index 3ac958cf..c6a1932b 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\AnchorRaw * diff --git a/src/Phalcon/html/helper/Body.php b/src/Phalcon/html/helper/Body.php index 17607c87..de69a86e 100644 --- a/src/Phalcon/html/helper/Body.php +++ b/src/Phalcon/html/helper/Body.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Body * diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/html/helper/Button.php index ff6584ed..22406cde 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/html/helper/Button.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Button * diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/html/helper/Element.php index 4ff90fed..76046df0 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/html/helper/Element.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Address * diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/html/helper/Form.php index d5ca9c74..54a991f1 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/html/helper/Form.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\Form * diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/html/helper/TextArea.php index 65848997..8acf5742 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/html/helper/TextArea.php @@ -2,8 +2,6 @@ namespace Phalcon\Html\Helper; -use Phalcon\Html\Helper\AbstractHelper; - /** * Phalcon\Html\Helper\TextArea * diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/http/Cookie.php index 8bdcb431..d739fe0c 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/http/Cookie.php @@ -2,14 +2,7 @@ namespace Phalcon\Http; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Crypt\CryptInterface; -use Phalcon\Crypt\Mismatch; -use Phalcon\Filter\FilterInterface; -use Phalcon\Http\Response\Exception; -use Phalcon\Http\Cookie\Exception; -use Phalcon\Session\ManagerInterface; /** * Provide OO wrappers to manage a HTTP cookie. diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/http/Request.php index 74036bd7..e32b6c38 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/http/Request.php @@ -2,15 +2,8 @@ namespace Phalcon\Http; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Events\ManagerInterface; use Phalcon\Filter\FilterInterface; -use Phalcon\Http\Request\File; -use Phalcon\Http\Request\FileInterface; -use Phalcon\Http\Request\Exception; -use UnexpectedValueException; -use stdClass; /** * Encapsulates request information for easy and secure access from application diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 55c4de2e..38b703ea 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Http; -use Phalcon\Http\Request\FileInterface; -use stdClass; - /** * Interface for Phalcon\Http\Request */ diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 03ef320f..12dfc8ef 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -2,20 +2,10 @@ namespace Phalcon\Http; -use DateTime; -use DateTimeZone; -use Phalcon\Di; use Phalcon\Di\DiInterface; -use Phalcon\Helper\Fs; -use Phalcon\Http\Response\Exception; -use Phalcon\Http\Response\HeadersInterface; -use Phalcon\Http\Response\CookiesInterface; -use Phalcon\Url\UrlInterface; -use Phalcon\Mvc\ViewInterface; -use Phalcon\Http\Response\Headers; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Http\Response\HeadersInterface; /** * Part of the HTTP cycle is return responses to the clients. diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index 00b19814..3506a696 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -2,7 +2,6 @@ namespace Phalcon\Http; -use DateTime; use Phalcon\Http\Response\HeadersInterface; /** diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php index 807721c2..9d853ab1 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Exception\InvalidArgumentException; - /** * Common methods */ diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/http/message/AbstractMessage.php index 5f19448c..b87d0870 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/http/message/AbstractMessage.php @@ -3,9 +3,7 @@ namespace Phalcon\Http\Message; use Phalcon\Collection; -use Phalcon\Http\Message\AbstractCommon; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\Stream; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php index 1c23411f..b90e6d15 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -2,10 +2,7 @@ namespace Phalcon\Http\Message; -use Phalcon\Collection; -use Phalcon\Http\Message\AbstractMessage; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\Uri; use Psr\Http\Message\UriInterface; /** diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/http/message/Request.php index 9d7c1e17..289aabd5 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/http/message/Request.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Stream\Input; -use Phalcon\Http\Message\AbstractRequest; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/http/message/RequestFactory.php index 8f5c83fa..34305845 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/http/message/RequestFactory.php @@ -2,9 +2,8 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Request; -use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; /** diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/http/message/Response.php index f44b0772..808c760f 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/http/message/Response.php @@ -2,9 +2,6 @@ namespace Phalcon\Http\Message; -use Phalcon\Helper\Number; -use Phalcon\Http\Message\AbstractMessage; -use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ResponseInterface; /** diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/http/message/ResponseFactory.php index 74103186..4707ee3e 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/http/message/ResponseFactory.php @@ -2,9 +2,8 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Response; -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ResponseInterface; /** * PSR-17 ResponseFactory diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/http/message/ServerRequest.php index 8eb10226..55e7970e 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/http/message/ServerRequest.php @@ -3,9 +3,7 @@ namespace Phalcon\Http\Message; use Phalcon\Collection; -use Phalcon\Http\Message\AbstractRequest; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\Stream\Input; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php index bb63e5bb..67f6f51f 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -3,15 +3,11 @@ namespace Phalcon\Http\Message; use Phalcon\Collection; -use Phalcon\Helper\Arr; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\ServerRequest; -use Phalcon\Http\Message\UploadedFile; -use Phalcon\Http\Message\Uri; use Psr\Http\Message\ServerRequestFactoryInterface; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UriInterface; use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriInterface; /** * PSR-17 ServerRequestFactory diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/http/message/Stream.php index 31518982..67736b60 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/http/message/Stream.php @@ -2,10 +2,7 @@ namespace Phalcon\Http\Message; -use Phalcon\Helper\Arr; -use Exception; use Psr\Http\Message\StreamInterface; -use RuntimeException; /** * PSR-7 Stream diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/http/message/StreamFactory.php index 41b548ea..60c8cc2a 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/http/message/StreamFactory.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\Stream; -use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/http/message/UploadedFile.php index f401119f..b55dd5dc 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/http/message/UploadedFile.php @@ -2,11 +2,7 @@ namespace Phalcon\Http\Message; -use Phalcon\Helper\Number; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\Stream; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; use RuntimeException; diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/http/message/UploadedFileFactory.php index 5d58410f..ab9752fe 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/http/message/UploadedFileFactory.php @@ -2,10 +2,9 @@ namespace Phalcon\Http\Message; -use Phalcon\Http\Message\UploadedFile; use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; /** * PSR-17 UploadedFileFactory diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/http/message/Uri.php index 0245153b..2383c16e 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/http/message/Uri.php @@ -2,10 +2,7 @@ namespace Phalcon\Http\Message; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; -use Phalcon\Http\Message\AbstractCommon; use Psr\Http\Message\UriInterface; /** diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/http/message/UriFactory.php index affe126f..d42587c7 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/http/message/UriFactory.php @@ -4,7 +4,6 @@ use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface; -use Phalcon\Http\Message\Uri; /** * PSR-17 UriFactory diff --git a/src/Phalcon/http/message/exception/InvalidArgumentException.php b/src/Phalcon/http/message/exception/InvalidArgumentException.php index d4a8f6ba..a2ebf36c 100644 --- a/src/Phalcon/http/message/exception/InvalidArgumentException.php +++ b/src/Phalcon/http/message/exception/InvalidArgumentException.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Message\Exception; -use Throwable; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/http/request/File.php index 231d2e45..7e042032 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/http/request/File.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Request; -use Phalcon\Http\Request\FileInterface; - /** * Phalcon\Http\Request\File * diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 460d2193..efc67a51 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -2,11 +2,8 @@ namespace Phalcon\Http\Response; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\CookieInterface; -use Phalcon\Http\Response\CookiesInterface; -use Phalcon\Http\Cookie\Exception; /** * Phalcon\Http\Response\Cookies diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index 91bc27d8..abb21da9 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -2,8 +2,6 @@ namespace Phalcon\Http\Response; -use Phalcon\Http\Response\HeadersInterface; - /** * Phalcon\Http\Response\Headers * diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php index 3432dcc5..a3b9df97 100644 --- a/src/Phalcon/image/ImageFactory.php +++ b/src/Phalcon/image/ImageFactory.php @@ -2,9 +2,7 @@ namespace Phalcon\Image; -use Phalcon\Config; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; use Phalcon\Image\Adapter\AdapterInterface; /** diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/image/adapter/AbstractAdapter.php index 7fa4b048..5ce3311a 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/image/adapter/AbstractAdapter.php @@ -3,7 +3,6 @@ namespace Phalcon\Image\Adapter; use Phalcon\Image\Enum; -use Phalcon\Image\Exception; /** * Phalcon\Image\Adapter diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index 07d646fd..a82dd39c 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -2,10 +2,6 @@ namespace Phalcon\Image\Adapter; -use Phalcon\Image\Enum; -use Phalcon\Image\Adapter\AbstractAdapter; -use Phalcon\Image\Exception; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 20d7b815..27e65bda 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -2,10 +2,6 @@ namespace Phalcon\Image\Adapter; -use Phalcon\Image\Enum; -use Phalcon\Image\Adapter\AbstractAdapter; -use Phalcon\Image\Exception; - /** * Phalcon\Image\Adapter\Imagick * diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php index 6b00d2ed..47b541c8 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/logger/LoggerFactory.php @@ -2,10 +2,7 @@ namespace Phalcon\Logger; -use Phalcon\Config; -use Phalcon\Helper\Arr; use Phalcon\Logger; -use Phalcon\Logger\AdapterFactory; /** * Phalcon\Logger\LoggerFactory diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/logger/adapter/AbstractAdapter.php index 4ba13c80..d9409e48 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/logger/adapter/AbstractAdapter.php @@ -2,11 +2,7 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger; -use Phalcon\Logger\Adapter\AdapterInterface; -use Phalcon\Logger\Exception; use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php index a0d86989..ad3c9c30 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -3,7 +3,6 @@ namespace Phalcon\Logger\Adapter; use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; /** * Phalcon\Logger\AdapterInterface diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index 16a4309e..deb3c209 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -2,8 +2,6 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Noop * diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index ea45f4a0..948c2c85 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -2,12 +2,6 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Logger\Adapter; -use Phalcon\Logger\Exception; -use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; -use UnexpectedValueException; - /** * Phalcon\Logger\Adapter\Stream * diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index a6b7ec83..eafc5bb7 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -2,14 +2,6 @@ namespace Phalcon\Logger\Adapter; -use LogicException; -use Phalcon\Helper\Arr; -use Phalcon\Logger; -use Phalcon\Logger\Adapter; -use Phalcon\Logger\Exception; -use Phalcon\Logger\Formatter\FormatterInterface; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Adapter\Syslog * diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php index 1d5398ff..e302fe8b 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -2,8 +2,6 @@ namespace Phalcon\Logger\Formatter; -use Phalcon\Logger; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/logger/formatter/FormatterInterface.php b/src/Phalcon/logger/formatter/FormatterInterface.php index 3d63ffe1..0aaf8bd2 100644 --- a/src/Phalcon/logger/formatter/FormatterInterface.php +++ b/src/Phalcon/logger/formatter/FormatterInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Logger\Formatter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\FormatterInterface * diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index 2634cff6..51ac45ae 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -2,9 +2,6 @@ namespace Phalcon\Logger\Formatter; -use Phalcon\Logger\Formatter\AbstractFormatter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Formatter\Json * diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index 85e90ba5..d2eeaea4 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -3,7 +3,6 @@ namespace Phalcon\Logger\Formatter; use Phalcon\Logger\Formatter\Formatter; -use Phalcon\Logger\Item; /** * Phalcon\Logger\Formatter\Line diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 4b2543b0..71f34d2a 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -2,9 +2,6 @@ namespace Phalcon\Logger\Formatter; -use Phalcon\Logger\Formatter\AbstractFormatter; -use Phalcon\Logger\Item; - /** * Phalcon\Logger\Formatter\Syslog * diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index c68ea866..df13faea 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -2,9 +2,6 @@ namespace Phalcon\Messages; -use JsonSerializable; -use Phalcon\Messages\MessageInterface; - /** * Phalcon\Messages\Message * diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php index 84b7c7e6..550abcfa 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/messages/MessageInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Messages; -use Phalcon\Messages\Message; - /** * Phalcon\Messages\MessageInterface * diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/messages/Messages.php index c4ff4e69..014efcae 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/messages/Messages.php @@ -2,14 +2,6 @@ namespace Phalcon\Messages; -use ArrayAccess; -use Countable; -use Iterator; -use JsonSerializable; -use Phalcon\Messages\Message; -use Phalcon\Messages\Exception; -use Phalcon\Messages\MessageInterface; - /** * Represents a collection of messages */ diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index c6cd9c99..992b3cf1 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -2,17 +2,7 @@ namespace Phalcon\Mvc; -use Closure; use Phalcon\Application\AbstractApplication; -use Phalcon\Di\DiInterface; -use Phalcon\Mvc\ViewInterface; -use Phalcon\Mvc\RouterInterface; -use Phalcon\Http\ResponseInterface; -use Phalcon\Events\ManagerInterface; -use Phalcon\Mvc\DispatcherInterface; -use Phalcon\Mvc\Application\Exception; -use Phalcon\Mvc\Router\RouteInterface; -use Phalcon\Mvc\ModuleDefinitionInterface; /** * Phalcon\Mvc\Application diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index 39486ecd..fb4b14e8 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -2,13 +2,6 @@ namespace Phalcon\Mvc; -use Phalcon\Mvc\DispatcherInterface; -use Phalcon\Mvc\Dispatcher\Exception; -use Phalcon\Events\ManagerInterface; -use Phalcon\Http\ResponseInterface; -use Phalcon\Mvc\ControllerInterface; -use Phalcon\Dispatcher\AbstractDispatcher; - /** * Dispatching is the process of taking the request object, extracting the * module name, controller name, action name, and optional parameters contained diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index 191b5bb9..3019e142 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Mvc; -use Phalcon\Mvc\ControllerInterface; -use Phalcon\Dispatcher\DispatcherInterface; - /** * Phalcon\Mvc\DispatcherInterface * diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index c9a2cab1..b03bbd2a 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -2,24 +2,11 @@ namespace Phalcon\Mvc; -use ArrayAccess; -use Closure; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; -use Phalcon\Mvc\Controller; -use Phalcon\Di\FactoryDefault; -use Phalcon\Mvc\Micro\Exception; use Phalcon\Di\ServiceInterface; -use Phalcon\Mvc\Micro\Collection; -use Phalcon\Mvc\Micro\LazyLoader; -use Phalcon\Http\ResponseInterface; +use Phalcon\Events\ManagerInterface; use Phalcon\Mvc\Model\BinderInterface; use Phalcon\Mvc\Router\RouteInterface; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Events\ManagerInterface; -use Phalcon\Mvc\Micro\MiddlewareInterface; -use Phalcon\Mvc\Micro\CollectionInterface; -use Throwable; /** * Phalcon\Mvc\Micro diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index e83f19b3..d830dfc8 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -2,39 +2,14 @@ namespace Phalcon\Mvc; -use JsonSerializable; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Db\Column; -use Phalcon\Db\DialectInterface; -use Phalcon\Db\Enum; -use Phalcon\Db\RawValue; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Events\ManagerInterface; -use Phalcon\Helper\Arr; -use Phalcon\Messages\Message; -use Phalcon\Messages\MessageInterface; -use Phalcon\Mvc\Model\BehaviorInterface; -use Phalcon\Mvc\Model\Criteria; use Phalcon\Mvc\Model\CriteriaInterface; -use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\ManagerInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\Query; -use Phalcon\Mvc\Model\Query\Builder; -use Phalcon\Mvc\Model\Query\BuilderInterface; -use Phalcon\Mvc\Model\QueryInterface; -use Phalcon\Mvc\Model\ResultInterface; -use Phalcon\Mvc\Model\Resultset; -use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\Relation; -use Phalcon\Mvc\Model\RelationInterface; -use Phalcon\Mvc\Model\TransactionInterface; -use Phalcon\Mvc\Model\ValidationFailed; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Validation\ValidationInterface; -use Serializable; +use Phalcon\Mvc\Model\ResultsetInterface; /** * Phalcon\Mvc\Model diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index b2096bac..36d21548 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -3,12 +3,9 @@ namespace Phalcon\Mvc; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Di\DiInterface; -use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\ResultsetInterface; -use Phalcon\Mvc\Model\TransactionInterface; /** * Phalcon\Mvc\ModelInterface diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index 54881cbf..fe59a300 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc; -use Phalcon\Di\DiInterface; - /** * Phalcon\Mvc\ModuleDefinitionInterface * diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index f227b85e..af0f47dd 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -2,14 +2,8 @@ namespace Phalcon\Mvc; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Http\RequestInterface; -use Phalcon\Mvc\Router\Exception; -use Phalcon\Mvc\Router\GroupInterface; -use Phalcon\Mvc\Router\Route; use Phalcon\Mvc\Router\RouteInterface; /** diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index 4b9f5e9f..3cae5db4 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -2,9 +2,7 @@ namespace Phalcon\Mvc; -use Phalcon\Mvc\Router; use Phalcon\Mvc\Router\RouteInterface; -use Phalcon\Mvc\Router\GroupInterface; /** * Interface for Phalcon\Mvc\Router diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index 0c550c3e..740183b5 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -2,16 +2,8 @@ namespace Phalcon\Mvc; -use Closure; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Events\ManagerInterface; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; -use Phalcon\Mvc\View\Exception; -use Phalcon\Mvc\ViewInterface; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Mvc\View\Engine\Php; /** * Phalcon\Mvc\View diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index a1cce654..a88fca68 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc; -use Phalcon\Cache\Adapter\AdapterInterface; - /** * Phalcon\Mvc\ViewInterface * diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index 99880fd8..30ea8868 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Micro; -use Phalcon\Mvc\Model\BinderInterface; - /** * Phalcon\Mvc\Micro\LazyLoader * diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index 553ab07a..daa73549 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Micro; -use Phalcon\Mvc\Micro; - /** * Allows to implement Phalcon\Mvc\Micro middleware in classes */ diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 810c61bf..8540cc60 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -2,9 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\BehaviorInterface; - /** * Phalcon\Mvc\Model\Behavior * diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index c2713fb4..77ed3cc6 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; - /** * Phalcon\Mvc\Model\BehaviorInterface * diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index 4454abe5..5028f77c 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -2,12 +2,7 @@ namespace Phalcon\Mvc\Model; -use Closure; -use Phalcon\Mvc\Controller\BindModelInterface; -use Phalcon\Mvc\Model\Binder\BindableInterface; use Phalcon\Cache\Adapter\AdapterInterface; -use ReflectionFunction; -use ReflectionMethod; /** * Phalcon\Mvc\Model\Binding diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index f02a1442..757aee59 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -2,13 +2,7 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Di; -use Phalcon\Db\Column; use Phalcon\Di\DiInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\CriteriaInterface; -use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; /** @@ -459,7 +453,7 @@ public function getConditions(): ?string * limit was set without an offset, an array with 'number' and 'offset' keys * if an offset was set with the limit, or null if limit has not been set. * - * @return int|array|null + * @return string|null */ public function getLimit(): ?string { diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index c6cf3a65..80a6f15d 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Di\DiInterface; - /** * Phalcon\Mvc\Model\CriteriaInterface * diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index f9525c5e..d98d4157 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -2,22 +2,11 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Di\DiInterface; -use Phalcon\Mvc\Model\Relation; -use Phalcon\Mvc\Model\RelationInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\ModelInterface; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Mvc\Model\ResultsetInterface; -use Phalcon\Mvc\Model\ManagerInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Mvc\Model\Query; -use Phalcon\Mvc\Model\QueryInterface; -use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Di\DiInterface; +use Phalcon\Events\ManagerInterface as EventsManagerInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; -use Phalcon\Mvc\Model\BehaviorInterface; -use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\Manager diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index 97281f76..f9138275 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -3,11 +3,8 @@ namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\BehaviorInterface; -use Phalcon\Mvc\Model\RelationInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; -use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\ManagerInterface diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/mvc/model/MetaData.php index 1cedeeae..4822a1ec 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/mvc/model/MetaData.php @@ -2,13 +2,8 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\Model\MetaData\Strategy\Introspection; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; -use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\MetaData diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index e30e329c..eea0df3e 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -2,7 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; /** diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index 397106ca..f0a5b215 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -2,27 +2,10 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Db\Column; -use Phalcon\Db\RawValue; -use Phalcon\Db\ResultInterface; use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; -use Phalcon\Helper\Arr; -use Phalcon\Mvc\Model\Row; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\Model\ManagerInterface; -use Phalcon\Mvc\Model\QueryInterface; -use Phalcon\Mvc\Model\Query\Status; -use Phalcon\Mvc\Model\Resultset\Complex; use Phalcon\Mvc\Model\Query\StatusInterface; -use Phalcon\Mvc\Model\ResultsetInterface; -use Phalcon\Mvc\Model\Resultset\Simple; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\RelationInterface; -use Phalcon\Mvc\Model\TransactionInterface; -use Phalcon\Db\DialectInterface; -use Phalcon\Mvc\Model\Query\Lang; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\Query diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index 8719aaa2..ec914296 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\Model\RelationInterface; - /** * Phalcon\Mvc\Model\Relation * diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 72ace62e..9ba8f10b 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; - /** * Phalcon\Mvc\Model\ResultInterface * diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index ee659f7e..c9e8c416 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -2,21 +2,8 @@ namespace Phalcon\Mvc\Model; -use ArrayAccess; -use Closure; -use Countable; -use Iterator; -use JsonSerializable; -use Phalcon\Db\Enum; -use Phalcon\Messages\MessageInterface; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Storage\Serializer\SerializerInterface; -use SeekableIterator; -use Serializable; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\Resultset diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index 277f0120..d9448f08 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -2,10 +2,8 @@ namespace Phalcon\Mvc\Model; -use Closure; -use Phalcon\Messages\MessageInterface; -use Phalcon\Mvc\ModelInterface; use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\ResultsetInterface diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index dd0ec110..1d768b98 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -2,13 +2,6 @@ namespace Phalcon\Mvc\Model; -use ArrayAccess; -use JsonSerializable; -use Phalcon\Mvc\EntityInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\Model\ResultInterface; -use Phalcon\Mvc\ModelInterface; - /** * Phalcon\Mvc\Model\Row * diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index ac23ffee..2b1b124c 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -2,12 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Di\DiInterface; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Transaction\Failed; -use Phalcon\Mvc\Model\Transaction\ManagerInterface; -use Phalcon\Mvc\Model\TransactionInterface; - /** * Phalcon\Mvc\Model\Transaction * diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index 219a5083..da437029 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Transaction\ManagerInterface; - /** * Phalcon\Mvc\Model\TransactionInterface * diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/mvc/model/behavior/SoftDelete.php index 97f62675..4a75fb86 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/model/behavior/SoftDelete.php @@ -2,9 +2,7 @@ namespace Phalcon\Mvc\Model\Behavior; -use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; -use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\SoftDelete diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/mvc/model/behavior/Timestampable.php index ef8242d0..14bb9034 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/mvc/model/behavior/Timestampable.php @@ -2,10 +2,7 @@ namespace Phalcon\Mvc\Model\Behavior; -use Closure; -use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; -use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\Timestampable diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index 125c295f..afadb39b 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -3,8 +3,6 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Apcu diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index ac52ed02..9117318d 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -2,10 +2,7 @@ namespace Phalcon\Mvc\Model\MetaData; -use Phalcon\Helper\Arr; -use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\MetaData; -use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Libmemcached diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index 46c1fa84..b6f86087 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -3,7 +3,6 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; -use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Memory diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index f65f4dc9..a8139c10 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -3,7 +3,6 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; -use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Redis diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Stream.php index 424d11d1..0db905df 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -3,7 +3,6 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; -use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Stream diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 9a471d7c..47b0bd5a 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -2,13 +2,6 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; -use Phalcon\Di\DiInterface; -use Phalcon\Db\Column; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\MetaData; -use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; -use Phalcon\Mvc\Model\Exception; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index fdc72e79..a5800990 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -2,14 +2,6 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; -use Phalcon\Di\DiInterface; -use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Db\Column; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Mvc\Model\MetaData; -use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; - /** * Phalcon\Mvc\Model\MetaData\Strategy\Introspection * diff --git a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php index f229b89d..1be70b21 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Mvc\Model\MetaData\Strategy; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Di\DiInterface; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index 48582740..b32077d7 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -2,14 +2,8 @@ namespace Phalcon\Mvc\Model\Query; -use Phalcon\Di; -use Phalcon\Db\Column; use Phalcon\Di\DiInterface; -use Phalcon\Helper\Arr; -use Phalcon\Mvc\Model\Exception; -use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\QueryInterface; -use Phalcon\Mvc\Model\Query\BuilderInterface; /** * Phalcon\Mvc\Model\Query\Builder diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index bc0997e7..60fb2039 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -2,9 +2,7 @@ namespace Phalcon\Mvc\Model\Query; -use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Query\StatusInterface; /** * Phalcon\Mvc\Model\Query\Status diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index 27efbfe9..fcea5a8b 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -2,7 +2,6 @@ namespace Phalcon\Mvc\Model\Query; -use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 3a4ca8f7..40da46b1 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -2,18 +2,7 @@ namespace Phalcon\Mvc\Model\Resultset; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Db\ResultInterface; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; -use Phalcon\Mvc\Model\ResultsetInterface; -use Phalcon\Mvc\Model\Row; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Storage\Serializer\SerializerInterface; -use stdClass; /** * Phalcon\Mvc\Model\Resultset\Complex diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index 4c3fa90b..eafacb10 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -2,14 +2,8 @@ namespace Phalcon\Mvc\Model\Resultset; -use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\ModelInterface; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Phalcon\Mvc\Model\Resultset\Simple diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index e4978581..f58e2159 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -2,9 +2,7 @@ namespace Phalcon\Mvc\Model\Transaction; -use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\Model\Transaction\Exception; /** * Phalcon\Mvc\Model\Transaction\Failed diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index fc880ef4..80b26ac7 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -2,12 +2,7 @@ namespace Phalcon\Mvc\Model\Transaction; -use Phalcon\Di; use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\Model\Transaction\ManagerInterface; -use Phalcon\Mvc\Model\Transaction\Exception; -use Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\Model\TransactionInterface; /** diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 7c5a8f28..3c939af1 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -2,10 +2,7 @@ namespace Phalcon\Mvc\Router; -use Phalcon\Di\DiInterface; use Phalcon\Mvc\Router; -use Phalcon\Annotations\Annotation; -use Phalcon\Mvc\Router\Exception; /** * Phalcon\Mvc\Router\Annotations diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index b4b07758..33d59115 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Router; -use Phalcon\Mvc\Router\RouteInterface; - /** * Phalcon\Mvc\Router\GroupInterface * diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index e3d4e02a..b47b0db0 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\Router; -use Phalcon\Mvc\Router\Exception; - /** * Phalcon\Mvc\Router\Route * diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/mvc/view/Simple.php index 9c674535..c5d8ab5c 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/mvc/view/Simple.php @@ -2,17 +2,8 @@ namespace Phalcon\Mvc\View; -use Closure; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; -use Phalcon\Mvc\View\Exception; -use Phalcon\Mvc\ViewBaseInterface; -use Phalcon\Mvc\View\Engine\EngineInterface; -use Phalcon\Mvc\View\Engine\Php; /** * Phalcon\Mvc\View\Simple diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php index 299e55a9..dadd9bab 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -2,7 +2,6 @@ namespace Phalcon\Mvc\View\Engine; -use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Mvc\ViewBaseInterface; diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index 4cfdd15f..f1eb2e5f 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -2,8 +2,6 @@ namespace Phalcon\Mvc\View\Engine; -use Phalcon\Mvc\View\Engine\AbstractEngine; - /** * Adapter to use PHP itself as templating engine */ diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index 20b4523e..f02f178c 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -2,12 +2,8 @@ namespace Phalcon\Mvc\View\Engine; -use Phalcon\Di\DiInterface; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Mvc\View\Engine\AbstractEngine; use Phalcon\Mvc\View\Engine\Volt\Compiler; -use Phalcon\Mvc\View\Exception; /** * Designer friendly and fast template engine for PHP written in Zephir/C diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 8b994f99..15bb2038 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -2,11 +2,7 @@ namespace Phalcon\Mvc\View\Engine\Volt; -use Closure; use Phalcon\Di\DiInterface; -use Phalcon\Mvc\ViewBaseInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Mvc\View\Engine\Volt\Exception; /** * This class reads and compiles Volt templates into PHP plain code diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index 95fc5552..efc6bc20 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -2,12 +2,12 @@ namespace Phalcon\Mvc\View\Engine\Volt; -use Phalcon\Mvc\View\Exception; +use Phalcon\Mvc\View\Exception as BaseException; /** * Class for exceptions thrown by Phalcon\Mvc\View */ -class Exception extends \Phalcon\Mvc\View\Exception +class Exception extends BaseException { protected $statement; diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php index 8b434eb3..fa63b1a2 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -2,9 +2,8 @@ namespace Phalcon\Paginator; -use Phalcon\Paginator\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; +use Phalcon\Paginator\Adapter\AdapterInterface; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index c2104bfc..323eb2c8 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -2,9 +2,6 @@ namespace Phalcon\Paginator; -use JsonSerializable; -use Phalcon\Helper\Arr; - /** * Phalcon\Paginator\Repository * diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/paginator/adapter/AbstractAdapter.php index aaaa015f..29eae036 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/paginator/adapter/AbstractAdapter.php @@ -2,10 +2,7 @@ namespace Phalcon\Paginator\Adapter; -use Phalcon\Paginator\Exception; -use Phalcon\Paginator\Repository; use Phalcon\Paginator\RepositoryInterface; -use Phalcon\Paginator\Adapter\AdapterInterface; /** * Phalcon\Paginator\Adapter\AbstractAdapter diff --git a/src/Phalcon/paginator/adapter/Model.php b/src/Phalcon/paginator/adapter/Model.php index ce0797c6..d829cdf3 100644 --- a/src/Phalcon/paginator/adapter/Model.php +++ b/src/Phalcon/paginator/adapter/Model.php @@ -2,8 +2,6 @@ namespace Phalcon\Paginator\Adapter; -use Phalcon\Paginator\Exception; -use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; /** diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 63aa233e..4efd8617 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -2,8 +2,6 @@ namespace Phalcon\Paginator\Adapter; -use Phalcon\Paginator\Exception; -use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; /** diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index d8a55459..7c6a7ac0 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -2,11 +2,8 @@ namespace Phalcon\Paginator\Adapter; -use Phalcon\Db\Enum; use Phalcon\Mvc\Model\Query\Builder; -use Phalcon\Paginator\Adapter\AbstractAdapter; use Phalcon\Paginator\RepositoryInterface; -use Phalcon\Paginator\Exception; /** * Phalcon\Paginator\Adapter\QueryBuilder diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/session/Bag.php index 9a913e35..dde60d01 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/session/Bag.php @@ -3,9 +3,7 @@ namespace Phalcon\Session; use Phalcon\Collection; -use Phalcon\Di; use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; /** * Phalcon\Session\Bag diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index c19e6018..a844db65 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -3,12 +3,8 @@ namespace Phalcon\Session; use InvalidArgumentException; -use RuntimeException; -use SessionHandlerInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Di\DiInterface; -use Phalcon\Helper\Arr; -use Phalcon\Session\ManagerInterface; +use SessionHandlerInterface; /** * Phalcon\Session\Manager diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php index f3527130..c654990e 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/session/ManagerInterface.php @@ -3,7 +3,6 @@ namespace Phalcon\Session; use InvalidArgumentException; -use RuntimeException; use SessionHandlerInterface; /** diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/session/adapter/AbstractAdapter.php index e806bef9..9360162f 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/session/adapter/AbstractAdapter.php @@ -3,7 +3,6 @@ namespace Phalcon\Session\Adapter; use Phalcon\Storage\Adapter\AdapterInterface; -use SessionHandlerInterface; /** * This file is part of the Phalcon. diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 76e79919..87c51ebf 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -2,9 +2,6 @@ namespace Phalcon\Session\Adapter; -use Phalcon\Storage\AdapterFactory; -use Phalcon\Session\Adapter\AbstractAdapter; - /** * Phalcon\Session\Adapter\Libmemcached */ diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index 4ed25e69..39f90f92 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -2,8 +2,6 @@ namespace Phalcon\Session\Adapter; -use SessionHandlerInterface; - /** * Phalcon\Session\Adapter\Noop * diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index df8dd3eb..15dbcbb0 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -2,9 +2,6 @@ namespace Phalcon\Session\Adapter; -use Phalcon\Storage\AdapterFactory; -use Phalcon\Session\Adapter\AbstractAdapter; - /** * Phalcon\Session\Adapter\Redis */ diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php index ea2dc826..b7e68132 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/session/adapter/Stream.php @@ -2,9 +2,6 @@ namespace Phalcon\Session\Adapter; -use Phalcon\Helper\Str; -use Phalcon\Session\Exception; - /** * Phalcon\Session\Adapter\Stream * diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php index 1e828831..2a4c9420 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/storage/AdapterFactory.php @@ -3,9 +3,7 @@ namespace Phalcon\Storage; use Phalcon\Factory\AbstractFactory; -use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Adapter\AdapterInterface; -use Phalcon\Storage\SerializerFactory; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php index 0e15c398..3f8a3d98 100644 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -3,12 +3,9 @@ namespace Phalcon\Storage\Adapter; use DateInterval; -use DateTime; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Adapter\AdapterInterface; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; use Phalcon\Storage\Serializer\SerializerInterface; +use Phalcon\Storage\SerializerFactory; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php index 7cf8f08f..a7f35523 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Storage\Adapter; -use Phalcon\Storage\Serializer\SerializerInterface; - /** * Interface for Phalcon\Logger adapters */ diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/storage/adapter/Apcu.php index 27bb0abd..b4d60d72 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/storage/adapter/Apcu.php @@ -2,13 +2,6 @@ namespace Phalcon\Storage\Adapter; -use APCuIterator; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Adapter\AbstractAdapter; -use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; - /** * Apcu adapter */ diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/storage/adapter/Libmemcached.php index 8aba2f8a..babf6205 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/storage/adapter/Libmemcached.php @@ -2,11 +2,7 @@ namespace Phalcon\Storage\Adapter; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Libmemcached adapter diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/storage/adapter/Memory.php index 91d6d1cc..c2aa28b0 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/storage/adapter/Memory.php @@ -3,11 +3,6 @@ namespace Phalcon\Storage\Adapter; use Phalcon\Collection; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Adapter\AbstractAdapter; -use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Memory adapter diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/storage/adapter/Redis.php index f89f2645..21c96133 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/storage/adapter/Redis.php @@ -2,11 +2,7 @@ namespace Phalcon\Storage\Adapter; -use Phalcon\Helper\Arr; -use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; /** * Redis adapter diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/storage/adapter/Stream.php index 1971594e..4151c3cc 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/storage/adapter/Stream.php @@ -2,16 +2,8 @@ namespace Phalcon\Storage\Adapter; -use FilesystemIterator; use Iterator; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Str; -use Phalcon\Storage\Adapter\AbstractAdapter; use Phalcon\Storage\Exception; -use Phalcon\Storage\SerializerFactory; -use Phalcon\Storage\Serializer\SerializerInterface; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; /** * Stream adapter diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/storage/serializer/AbstractSerializer.php index 70fb6b8f..d81e734d 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/storage/serializer/AbstractSerializer.php @@ -2,9 +2,6 @@ namespace Phalcon\Storage\Serializer; -use Phalcon\Storage\Exception; -use Phalcon\Storage\Serializer\SerializerInterface; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php index 6f7b135c..67b662fb 100644 --- a/src/Phalcon/storage/serializer/Base64.php +++ b/src/Phalcon/storage/serializer/Base64.php @@ -2,9 +2,6 @@ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; -use Phalcon\Storage\Serializer\AbstractSerializer; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php index 098b2c32..18c5e581 100644 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -2,8 +2,6 @@ namespace Phalcon\Storage\Serializer; -use Phalcon\Storage\Serializer\AbstractSerializer; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php index eb75703d..03406141 100644 --- a/src/Phalcon/storage/serializer/Json.php +++ b/src/Phalcon/storage/serializer/Json.php @@ -2,9 +2,6 @@ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; -use Phalcon\Storage\Serializer\AbstractSerializer; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php index cb45afdd..54d03c8f 100644 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -2,8 +2,6 @@ namespace Phalcon\Storage\Serializer; -use Phalcon\Storage\Serializer\AbstractSerializer; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php index 97584820..36e121e1 100644 --- a/src/Phalcon/storage/serializer/None.php +++ b/src/Phalcon/storage/serializer/None.php @@ -2,9 +2,6 @@ namespace Phalcon\Storage\Serializer; -use Phalcon\Storage\Serializer\AbstractSerializer; -use InvalidArgumentException; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php index f7f32e7c..2ddd36be 100644 --- a/src/Phalcon/storage/serializer/Php.php +++ b/src/Phalcon/storage/serializer/Php.php @@ -2,10 +2,6 @@ namespace Phalcon\Storage\Serializer; -use InvalidArgumentException; -use Phalcon\Storage\Exception; -use Phalcon\Storage\Serializer\AbstractSerializer; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php index 00f0d0cf..8d733b48 100644 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Storage\Serializer; -use Serializable; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index f87b8bdb..94ca10d9 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -2,11 +2,6 @@ namespace Phalcon\Tag; -use Phalcon\Tag\Exception; -use Phalcon\Tag; -use Phalcon\Escaper\EscaperInterface; -use Phalcon\Mvc\Model\ResultsetInterface; - /** * Phalcon\Tag\Select * diff --git a/src/Phalcon/translate/TranslateFactory.php b/src/Phalcon/translate/TranslateFactory.php index ec4c2854..c4b4da98 100644 --- a/src/Phalcon/translate/TranslateFactory.php +++ b/src/Phalcon/translate/TranslateFactory.php @@ -2,10 +2,7 @@ namespace Phalcon\Translate; -use Phalcon\Config; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; -use Phalcon\Translate\InterpolatorFactory; use Phalcon\Translate\Adapter\AdapterInterface; /** diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php index 6b4d3381..3b9e7ba3 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -2,9 +2,6 @@ namespace Phalcon\Translate\Adapter; -use Phalcon\Helper\Arr; -use Phalcon\Translate\Exception; -use Phalcon\Translate\Adapter\AdapterInterface; use Phalcon\Translate\InterpolatorFactory; /** diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 6ca609e5..5a1ce803 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -2,11 +2,6 @@ namespace Phalcon\Translate\Adapter; -use ArrayAccess; -use Phalcon\Translate\Exception; -use Phalcon\Translate\Adapter\AbstractAdapter; -use Phalcon\Translate\InterpolatorFactory; - /** * Phalcon\Translate\Adapter\Csv * diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 29ba4a98..52cf5d2a 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -2,11 +2,6 @@ namespace Phalcon\Translate\Adapter; -use ArrayAccess; -use Phalcon\Translate\Exception; -use Phalcon\Translate\Adapter\AbstractAdapter; -use Phalcon\Translate\InterpolatorFactory; - /** * Phalcon\Translate\Adapter\Gettext * diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index b95b97d7..76a70ccf 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -2,11 +2,6 @@ namespace Phalcon\Translate\Adapter; -use ArrayAccess; -use Phalcon\Translate\Exception; -use Phalcon\Translate\Adapter\AbstractAdapter; -use Phalcon\Translate\InterpolatorFactory; - /** * Phalcon\Translate\Adapter\NativeArray * diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index b18e1177..2666724d 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -2,8 +2,6 @@ namespace Phalcon\Translate\Interpolator; -use Phalcon\Translate\Interpolator\InterpolatorInterface; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index 64641853..b9c7f3c7 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -2,8 +2,6 @@ namespace Phalcon\Translate\Interpolator; -use Phalcon\Translate\Interpolator\InterpolatorInterface; - /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/validation/AbstractValidator.php index 59e317ab..9028834e 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/validation/AbstractValidator.php @@ -2,12 +2,7 @@ namespace Phalcon\Validation; -use Phalcon\Collection; -use Phalcon\Helper\Arr; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Exception; -use Phalcon\Validation\ValidatorInterface; /** * This is a base class for validators diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/validation/AbstractValidatorComposite.php index 32992942..a78ef5e2 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/validation/AbstractValidatorComposite.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation; -use Phalcon\Validation; - /** * This is a base class for combined fields validators */ diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/validation/ValidationInterface.php index 246d3ea0..c874fe26 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/validation/ValidationInterface.php @@ -2,11 +2,7 @@ namespace Phalcon\Validation; -use Phalcon\Di\Injectable; -use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; -use Phalcon\Validation\Exception; -use Phalcon\Validation\ValidatorInterface; /** * Interface for the Phalcon\Validation component diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/validation/ValidatorCompositeInterface.php index 880c9f5e..7798b58b 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/validation/ValidatorCompositeInterface.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation; -use Phalcon\Validation; - /** * This is a base class for combined fields validators */ diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/validation/ValidatorFactory.php index 978fd037..95e5ca1b 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/validation/ValidatorFactory.php @@ -3,7 +3,6 @@ namespace Phalcon\Validation; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index 60263bc1..ec192dcf 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -2,9 +2,6 @@ namespace Phalcon\Validation; -use Phalcon\Collection; -use Phalcon\Validation; - /** * Interface for Phalcon\Validation\AbstractValidator */ diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index a4b7d94c..093344c8 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -2,7 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 6c499b4b..403f8658 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 5a9ecbec..2f84550b 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 02a9be2e..712ac062 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -2,9 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\ValidatorInterface; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index 2d289fbd..f81d5ebe 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -2,9 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Exception; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index ed89d3d5..4028f411 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index 4e07f977..f40c4065 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -2,9 +2,6 @@ namespace Phalcon\Validation\Validator; -use DateTime; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index f7144ecf..bd1d2c3b 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index c6abf1b3..f70b51cb 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index 21abdbc1..ebeebbd3 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -2,10 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Check if a value is not included into a list of values diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index 224e120a..d43d2447 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -2,17 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Helper\Arr; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidatorComposite; -use Phalcon\Validation\Validator\File\MimeType; -use Phalcon\Validation\Validator\File\Resolution\Equal; -use Phalcon\Validation\Validator\File\Resolution\Max; -use Phalcon\Validation\Validator\File\Resolution\Min; -use Phalcon\Validation\Validator\File\Size\Equal; -use Phalcon\Validation\Validator\File\Size\Max; -use Phalcon\Validation\Validator\File\Size\Min; /** * Checks if a value has a correct file diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 6daeff5d..4d8d5bce 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 4291f368..1b7f3b1a 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -2,10 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Check if a value is included into a list of values diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index cc5ca5e2..2d2f6540 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -2,9 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Messages\Message; /** * Check for IP addresses diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index cc697601..6bc8defa 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index 97edb6b3..8f1348c9 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index fdce9c4a..997f75e9 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index 0c25974a..a1f62149 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -2,12 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation\AbstractValidator; use Phalcon\Validation\AbstractValidatorComposite; -use Phalcon\Validation\Validator\StringLength\Max; -use Phalcon\Validation\Validator\StringLength\Min; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum and minimum constraints diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index cd4e2c00..d023f486 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -2,12 +2,7 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Validation; use Phalcon\Validation\AbstractCombinedFieldsValidator; -use Phalcon\Validation\Exception; /** * Check that a field is unique in the related table diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index efd86cc8..086626cc 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php index cd25e3a4..629fbf86 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -2,7 +2,6 @@ namespace Phalcon\Validation\Validator\File; -use Phalcon\Messages\Message; use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php index d8102f27..85f42aa9 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -2,10 +2,7 @@ namespace Phalcon\Validation\Validator\File; -use Phalcon\Messages\Message; use Phalcon\Validation; -use Phalcon\Validation\Exception; -use Phalcon\Validation\Validator\File\AbstractFile; /** * Checks if a value has a correct file mime type diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php index 3828cdc3..3ded3092 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Resolution; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php index 441d4b70..aa3f5623 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Resolution; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php index 210d13f9..bd0caee3 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Resolution; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php index f58deb17..3dbcd702 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php index 1b17e49d..9c4459bb 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php index 609af4c5..e241f58f 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -2,8 +2,6 @@ namespace Phalcon\Validation\Validator\File\Size; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php index 8c6e14cb..d9848924 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -2,10 +2,7 @@ namespace Phalcon\Validation\Validator\StringLength; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum constraints diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php index e2170e62..28091a84 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -2,10 +2,7 @@ namespace Phalcon\Validation\Validator\StringLength; -use Phalcon\Messages\Message; -use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; /** * Validates that a string has the specified minimum constraints From d81dea03e247168ed8d567b9d25bd63f06ba29a0 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sat, 26 Oct 2019 22:15:47 +0200 Subject: [PATCH 20/25] Styling fixes --- src/Phalcon/Cache.php | 19 +++++------ src/Phalcon/Collection.php | 1 - src/Phalcon/Config.php | 1 - src/Phalcon/Container.php | 1 - src/Phalcon/Crypt.php | 5 ++- src/Phalcon/Debug.php | 3 +- src/Phalcon/Di.php | 3 +- src/Phalcon/Escaper.php | 1 - src/Phalcon/Exception.php | 1 - src/Phalcon/Filter.php | 1 - src/Phalcon/Kernel.php | 3 +- src/Phalcon/Loader.php | 1 - src/Phalcon/Logger.php | 7 ++-- src/Phalcon/Registry.php | 1 - src/Phalcon/Security.php | 1 - src/Phalcon/Tag.php | 25 +++++++------- src/Phalcon/Text.php | 1 - src/Phalcon/Url.php | 1 - src/Phalcon/Validation.php | 2 -- src/Phalcon/Version.php | 3 +- src/Phalcon/acl/Component.php | 1 - src/Phalcon/acl/ComponentAware.php | 1 - src/Phalcon/acl/ComponentInterface.php | 1 - src/Phalcon/acl/Enum.php | 2 -- src/Phalcon/acl/Role.php | 1 - src/Phalcon/acl/RoleAware.php | 1 - src/Phalcon/acl/RoleInterface.php | 1 - src/Phalcon/acl/adapter/AbstractAdapter.php | 1 - src/Phalcon/acl/adapter/AdapterInterface.php | 1 - src/Phalcon/acl/adapter/Memory.php | 1 - src/Phalcon/annotations/Annotation.php | 1 - .../annotations/AnnotationsFactory.php | 1 - src/Phalcon/annotations/Collection.php | 1 - src/Phalcon/annotations/Reader.php | 1 - src/Phalcon/annotations/ReaderInterface.php | 1 - src/Phalcon/annotations/Reflection.php | 1 - .../annotations/adapter/AbstractAdapter.php | 1 - .../annotations/adapter/AdapterInterface.php | 1 - src/Phalcon/annotations/adapter/Apcu.php | 1 - src/Phalcon/annotations/adapter/Memory.php | 1 - src/Phalcon/annotations/adapter/Stream.php | 1 - .../application/AbstractApplication.php | 1 - src/Phalcon/assets/Asset.php | 1 - src/Phalcon/assets/AssetInterface.php | 1 - src/Phalcon/assets/Collection.php | 1 - src/Phalcon/assets/FilterInterface.php | 1 - src/Phalcon/assets/Inline.php | 1 - src/Phalcon/assets/Manager.php | 1 - src/Phalcon/assets/asset/Css.php | 1 - src/Phalcon/assets/asset/Js.php | 1 - src/Phalcon/assets/filters/Cssmin.php | 1 - src/Phalcon/assets/filters/Jsmin.php | 1 - src/Phalcon/assets/filters/None.php | 1 - src/Phalcon/assets/inline/Css.php | 1 - src/Phalcon/assets/inline/Js.php | 1 - src/Phalcon/cache/AdapterFactory.php | 1 - src/Phalcon/cache/CacheFactory.php | 1 - src/Phalcon/cli/Console.php | 1 - src/Phalcon/cli/Dispatcher.php | 7 ++-- src/Phalcon/cli/DispatcherInterface.php | 1 - src/Phalcon/cli/Router.php | 1 - src/Phalcon/cli/RouterInterface.php | 1 - src/Phalcon/cli/Task.php | 1 - src/Phalcon/cli/router/Route.php | 5 ++- src/Phalcon/cli/router/RouteInterface.php | 1 - src/Phalcon/collection/ReadOnly.php | 1 - src/Phalcon/config/ConfigFactory.php | 1 - src/Phalcon/config/adapter/Grouped.php | 1 - src/Phalcon/config/adapter/Ini.php | 1 - src/Phalcon/config/adapter/Json.php | 1 - src/Phalcon/config/adapter/Php.php | 1 - src/Phalcon/config/adapter/Yaml.php | 1 - src/Phalcon/crypt/CryptInterface.php | 1 - src/Phalcon/db/AbstractDb.php | 1 - src/Phalcon/db/Column.php | 1 - src/Phalcon/db/ColumnInterface.php | 1 - src/Phalcon/db/Dialect.php | 1 - src/Phalcon/db/DialectInterface.php | 1 - src/Phalcon/db/Enum.php | 2 -- src/Phalcon/db/Index.php | 1 - src/Phalcon/db/IndexInterface.php | 1 - src/Phalcon/db/Profiler.php | 1 - src/Phalcon/db/RawValue.php | 1 - src/Phalcon/db/Reference.php | 1 - src/Phalcon/db/ReferenceInterface.php | 1 - src/Phalcon/db/ResultInterface.php | 1 - src/Phalcon/db/adapter/AbstractAdapter.php | 3 +- src/Phalcon/db/adapter/AdapterInterface.php | 1 - src/Phalcon/db/adapter/PdoFactory.php | 1 - src/Phalcon/db/adapter/pdo/AbstractPdo.php | 1 - src/Phalcon/db/adapter/pdo/Mysql.php | 1 - src/Phalcon/db/adapter/pdo/Postgresql.php | 1 - src/Phalcon/db/adapter/pdo/Sqlite.php | 1 - src/Phalcon/db/dialect/Mysql.php | 1 - src/Phalcon/db/dialect/Postgresql.php | 1 - src/Phalcon/db/dialect/Sqlite.php | 1 - src/Phalcon/db/profiler/Item.php | 1 - src/Phalcon/db/result/Pdo.php | 1 - src/Phalcon/debug/Dump.php | 1 - src/Phalcon/di/AbstractInjectionAware.php | 1 - src/Phalcon/di/DiInterface.php | 1 - src/Phalcon/di/FactoryDefault.php | 1 - src/Phalcon/di/Injectable.php | 1 - src/Phalcon/di/InjectionAwareInterface.php | 1 - src/Phalcon/di/Service.php | 3 +- src/Phalcon/di/ServiceInterface.php | 3 +- src/Phalcon/di/ServiceProviderInterface.php | 1 - src/Phalcon/di/factorydefault/Cli.php | 1 - src/Phalcon/di/service/Builder.php | 5 ++- src/Phalcon/dispatcher/AbstractDispatcher.php | 3 +- .../dispatcher/DispatcherInterface.php | 1 - src/Phalcon/dispatcher/Exception.php | 2 -- src/Phalcon/domain/payload/Payload.php | 1 - src/Phalcon/domain/payload/PayloadFactory.php | 1 - .../domain/payload/ReadableInterface.php | 1 - src/Phalcon/domain/payload/Status.php | 1 - .../domain/payload/WriteableInterface.php | 1 - src/Phalcon/escaper/EscaperInterface.php | 1 - src/Phalcon/events/Event.php | 1 - src/Phalcon/events/EventInterface.php | 1 - src/Phalcon/events/EventsAwareInterface.php | 1 - src/Phalcon/events/Manager.php | 5 ++- src/Phalcon/events/ManagerInterface.php | 3 +- src/Phalcon/factory/AbstractFactory.php | 1 - src/Phalcon/filter/FilterFactory.php | 1 - src/Phalcon/filter/FilterInterface.php | 1 - src/Phalcon/filter/sanitize/AbsInt.php | 1 - src/Phalcon/filter/sanitize/Alnum.php | 1 - src/Phalcon/filter/sanitize/Alpha.php | 1 - src/Phalcon/filter/sanitize/BoolVal.php | 1 - src/Phalcon/filter/sanitize/Email.php | 1 - src/Phalcon/filter/sanitize/FloatVal.php | 1 - src/Phalcon/filter/sanitize/IntVal.php | 1 - src/Phalcon/filter/sanitize/Lower.php | 1 - src/Phalcon/filter/sanitize/LowerFirst.php | 1 - src/Phalcon/filter/sanitize/Regex.php | 1 - src/Phalcon/filter/sanitize/Remove.php | 1 - src/Phalcon/filter/sanitize/Replace.php | 1 - src/Phalcon/filter/sanitize/Special.php | 1 - src/Phalcon/filter/sanitize/SpecialFull.php | 1 - src/Phalcon/filter/sanitize/StringVal.php | 1 - src/Phalcon/filter/sanitize/Striptags.php | 1 - src/Phalcon/filter/sanitize/Trim.php | 1 - src/Phalcon/filter/sanitize/Upper.php | 1 - src/Phalcon/filter/sanitize/UpperFirst.php | 1 - src/Phalcon/filter/sanitize/UpperWords.php | 1 - src/Phalcon/filter/sanitize/Url.php | 1 - .../firewall/adapter/AbstractAdapter.php | 6 ---- src/Phalcon/firewall/adapter/Acl.php | 1 - .../firewall/adapter/AdapterInterface.php | 1 - src/Phalcon/firewall/adapter/Annotations.php | 1 - src/Phalcon/firewall/adapter/micro/Acl.php | 1 - src/Phalcon/flash/AbstractFlash.php | 3 +- src/Phalcon/flash/Direct.php | 1 - src/Phalcon/flash/FlashInterface.php | 1 - src/Phalcon/flash/Session.php | 1 - src/Phalcon/forms/Form.php | 3 +- src/Phalcon/forms/Manager.php | 1 - src/Phalcon/forms/element/AbstractElement.php | 1 - src/Phalcon/forms/element/Check.php | 1 - src/Phalcon/forms/element/Date.php | 1 - .../forms/element/ElementInterface.php | 1 - src/Phalcon/forms/element/Email.php | 1 - src/Phalcon/forms/element/File.php | 1 - src/Phalcon/forms/element/Hidden.php | 1 - src/Phalcon/forms/element/Numeric.php | 1 - src/Phalcon/forms/element/Password.php | 1 - src/Phalcon/forms/element/Radio.php | 1 - src/Phalcon/forms/element/Select.php | 1 - src/Phalcon/forms/element/Submit.php | 1 - src/Phalcon/forms/element/Text.php | 1 - src/Phalcon/forms/element/TextArea.php | 1 - src/Phalcon/helper/Arr.php | 33 +++++++++---------- src/Phalcon/helper/Fs.php | 1 - src/Phalcon/helper/Number.php | 1 - src/Phalcon/helper/Str.php | 17 +++++----- src/Phalcon/html/Attributes.php | 1 - src/Phalcon/html/Breadcrumbs.php | 1 - src/Phalcon/html/TagFactory.php | 1 - .../html/attributes/AttributesInterface.php | 1 - .../html/attributes/RenderInterface.php | 1 - src/Phalcon/html/helper/AbstractHelper.php | 1 - src/Phalcon/html/helper/Anchor.php | 1 - src/Phalcon/html/helper/AnchorRaw.php | 1 - src/Phalcon/html/helper/Body.php | 1 - src/Phalcon/html/helper/Button.php | 1 - src/Phalcon/html/helper/Close.php | 1 - src/Phalcon/html/helper/Element.php | 1 - src/Phalcon/html/helper/ElementRaw.php | 7 ++-- src/Phalcon/html/helper/Form.php | 1 - src/Phalcon/html/helper/Img.php | 3 +- src/Phalcon/html/helper/Label.php | 1 - src/Phalcon/html/helper/TextArea.php | 1 - src/Phalcon/http/Cookie.php | 7 ++-- src/Phalcon/http/CookieInterface.php | 1 - src/Phalcon/http/Request.php | 1 - src/Phalcon/http/RequestInterface.php | 1 - src/Phalcon/http/Response.php | 1 - src/Phalcon/http/ResponseInterface.php | 1 - src/Phalcon/http/message/AbstractCommon.php | 5 ++- src/Phalcon/http/message/AbstractMessage.php | 15 ++++----- src/Phalcon/http/message/AbstractRequest.php | 3 +- src/Phalcon/http/message/Request.php | 7 ++-- src/Phalcon/http/message/RequestFactory.php | 3 +- src/Phalcon/http/message/Response.php | 7 ++-- src/Phalcon/http/message/ResponseFactory.php | 3 +- src/Phalcon/http/message/ServerRequest.php | 25 +++++++------- .../http/message/ServerRequestFactory.php | 17 +++++----- src/Phalcon/http/message/Stream.php | 5 ++- src/Phalcon/http/message/StreamFactory.php | 3 +- src/Phalcon/http/message/UploadedFile.php | 11 +++---- .../http/message/UploadedFileFactory.php | 11 +++---- src/Phalcon/http/message/Uri.php | 3 +- src/Phalcon/http/message/UriFactory.php | 1 - src/Phalcon/http/message/stream/Input.php | 7 ++-- src/Phalcon/http/message/stream/Memory.php | 1 - src/Phalcon/http/message/stream/Temp.php | 1 - src/Phalcon/http/request/File.php | 1 - src/Phalcon/http/request/FileInterface.php | 1 - src/Phalcon/http/response/Cookies.php | 3 +- .../http/response/CookiesInterface.php | 1 - src/Phalcon/http/response/Headers.php | 1 - .../http/response/HeadersInterface.php | 1 - .../http/server/AbstractMiddleware.php | 1 - .../http/server/AbstractRequestHandler.php | 1 - src/Phalcon/image/Enum.php | 2 -- src/Phalcon/image/ImageFactory.php | 1 - src/Phalcon/image/adapter/AbstractAdapter.php | 7 ++-- .../image/adapter/AdapterInterface.php | 1 - src/Phalcon/image/adapter/Gd.php | 3 +- src/Phalcon/image/adapter/Imagick.php | 9 +++-- src/Phalcon/logger/AdapterFactory.php | 1 - src/Phalcon/logger/Item.php | 2 -- src/Phalcon/logger/LoggerFactory.php | 3 +- .../logger/adapter/AbstractAdapter.php | 1 - .../logger/adapter/AdapterInterface.php | 1 - src/Phalcon/logger/adapter/Noop.php | 1 - src/Phalcon/logger/adapter/Stream.php | 1 - src/Phalcon/logger/adapter/Syslog.php | 1 - .../logger/formatter/AbstractFormatter.php | 1 - .../logger/formatter/FormatterInterface.php | 1 - src/Phalcon/logger/formatter/Json.php | 1 - src/Phalcon/logger/formatter/Line.php | 1 - src/Phalcon/logger/formatter/Syslog.php | 1 - src/Phalcon/messages/Message.php | 1 - src/Phalcon/messages/MessageInterface.php | 1 - src/Phalcon/messages/Messages.php | 1 - src/Phalcon/mvc/Application.php | 1 - src/Phalcon/mvc/Controller.php | 1 - src/Phalcon/mvc/Dispatcher.php | 1 - src/Phalcon/mvc/DispatcherInterface.php | 1 - src/Phalcon/mvc/EntityInterface.php | 1 - src/Phalcon/mvc/Micro.php | 5 ++- src/Phalcon/mvc/Model.php | 22 ++++++------- src/Phalcon/mvc/ModelInterface.php | 5 ++- src/Phalcon/mvc/ModuleDefinitionInterface.php | 1 - src/Phalcon/mvc/Router.php | 2 -- src/Phalcon/mvc/RouterInterface.php | 1 - src/Phalcon/mvc/View.php | 2 -- src/Phalcon/mvc/ViewBaseInterface.php | 1 - src/Phalcon/mvc/ViewInterface.php | 1 - .../mvc/controller/BindModelInterface.php | 1 - src/Phalcon/mvc/micro/Collection.php | 1 - src/Phalcon/mvc/micro/CollectionInterface.php | 1 - src/Phalcon/mvc/micro/LazyLoader.php | 4 +-- src/Phalcon/mvc/micro/MiddlewareInterface.php | 1 - src/Phalcon/mvc/model/Behavior.php | 3 +- src/Phalcon/mvc/model/BehaviorInterface.php | 1 - src/Phalcon/mvc/model/Binder.php | 1 - src/Phalcon/mvc/model/BinderInterface.php | 1 - src/Phalcon/mvc/model/Criteria.php | 1 - src/Phalcon/mvc/model/CriteriaInterface.php | 1 - src/Phalcon/mvc/model/Manager.php | 3 +- src/Phalcon/mvc/model/ManagerInterface.php | 29 ++++++++-------- src/Phalcon/mvc/model/MetaData.php | 1 - src/Phalcon/mvc/model/MetaDataInterface.php | 1 - src/Phalcon/mvc/model/Query.php | 7 ++-- src/Phalcon/mvc/model/QueryInterface.php | 3 +- src/Phalcon/mvc/model/Relation.php | 1 - src/Phalcon/mvc/model/RelationInterface.php | 1 - src/Phalcon/mvc/model/ResultInterface.php | 1 - src/Phalcon/mvc/model/Resultset.php | 1 - src/Phalcon/mvc/model/ResultsetInterface.php | 1 - src/Phalcon/mvc/model/Row.php | 3 +- src/Phalcon/mvc/model/Transaction.php | 1 - .../mvc/model/TransactionInterface.php | 1 - src/Phalcon/mvc/model/ValidationFailed.php | 1 - src/Phalcon/mvc/model/behavior/SoftDelete.php | 1 - .../mvc/model/behavior/Timestampable.php | 1 - .../mvc/model/binder/BindableInterface.php | 1 - src/Phalcon/mvc/model/metadata/Apcu.php | 1 - .../mvc/model/metadata/Libmemcached.php | 1 - src/Phalcon/mvc/model/metadata/Memory.php | 1 - src/Phalcon/mvc/model/metadata/Redis.php | 1 - src/Phalcon/mvc/model/metadata/Stream.php | 1 - .../model/metadata/strategy/Annotations.php | 1 - .../model/metadata/strategy/Introspection.php | 1 - .../metadata/strategy/StrategyInterface.php | 3 +- src/Phalcon/mvc/model/query/Builder.php | 1 - .../mvc/model/query/BuilderInterface.php | 1 - src/Phalcon/mvc/model/query/Lang.php | 1 - src/Phalcon/mvc/model/query/Status.php | 1 - .../mvc/model/query/StatusInterface.php | 1 - src/Phalcon/mvc/model/resultset/Complex.php | 1 - src/Phalcon/mvc/model/resultset/Simple.php | 1 - src/Phalcon/mvc/model/transaction/Failed.php | 1 - src/Phalcon/mvc/model/transaction/Manager.php | 1 - .../model/transaction/ManagerInterface.php | 1 - src/Phalcon/mvc/router/Annotations.php | 1 - src/Phalcon/mvc/router/Group.php | 1 - src/Phalcon/mvc/router/GroupInterface.php | 1 - src/Phalcon/mvc/router/Route.php | 4 +-- src/Phalcon/mvc/router/RouteInterface.php | 1 - src/Phalcon/mvc/view/Simple.php | 1 - .../mvc/view/engine/AbstractEngine.php | 1 - .../mvc/view/engine/EngineInterface.php | 1 - src/Phalcon/mvc/view/engine/Php.php | 1 - src/Phalcon/mvc/view/engine/Volt.php | 1 - src/Phalcon/mvc/view/engine/volt/Compiler.php | 9 +++-- .../mvc/view/engine/volt/Exception.php | 1 - src/Phalcon/paginator/PaginatorFactory.php | 1 - src/Phalcon/paginator/Repository.php | 1 - src/Phalcon/paginator/RepositoryInterface.php | 1 - .../paginator/adapter/AbstractAdapter.php | 1 - .../paginator/adapter/AdapterInterface.php | 1 - src/Phalcon/paginator/adapter/Model.php | 1 - src/Phalcon/paginator/adapter/NativeArray.php | 1 - .../paginator/adapter/QueryBuilder.php | 1 - src/Phalcon/security/Random.php | 21 ++++++------ src/Phalcon/session/Bag.php | 1 - src/Phalcon/session/Manager.php | 3 +- src/Phalcon/session/ManagerInterface.php | 3 +- .../session/adapter/AbstractAdapter.php | 1 - src/Phalcon/session/adapter/Libmemcached.php | 1 - src/Phalcon/session/adapter/Noop.php | 1 - src/Phalcon/session/adapter/Redis.php | 1 - src/Phalcon/session/adapter/Stream.php | 3 +- src/Phalcon/storage/AdapterFactory.php | 1 - src/Phalcon/storage/SerializerFactory.php | 1 - .../storage/adapter/AbstractAdapter.php | 1 - .../storage/adapter/AdapterInterface.php | 1 - src/Phalcon/storage/adapter/Apcu.php | 11 +++---- src/Phalcon/storage/adapter/Libmemcached.php | 9 +++-- src/Phalcon/storage/adapter/Memory.php | 11 +++---- src/Phalcon/storage/adapter/Redis.php | 11 +++---- src/Phalcon/storage/adapter/Stream.php | 13 ++++---- .../storage/serializer/AbstractSerializer.php | 1 - src/Phalcon/storage/serializer/Base64.php | 1 - src/Phalcon/storage/serializer/Igbinary.php | 1 - src/Phalcon/storage/serializer/Json.php | 1 - src/Phalcon/storage/serializer/Msgpack.php | 1 - src/Phalcon/storage/serializer/None.php | 1 - src/Phalcon/storage/serializer/Php.php | 1 - .../serializer/SerializerInterface.php | 1 - src/Phalcon/tag/Select.php | 1 - src/Phalcon/translate/InterpolatorFactory.php | 1 - src/Phalcon/translate/TranslateFactory.php | 1 - .../translate/adapter/AbstractAdapter.php | 1 - .../translate/adapter/AdapterInterface.php | 1 - src/Phalcon/translate/adapter/Csv.php | 1 - src/Phalcon/translate/adapter/Gettext.php | 1 - src/Phalcon/translate/adapter/NativeArray.php | 1 - .../interpolator/AssociativeArray.php | 1 - .../translate/interpolator/IndexedArray.php | 1 - .../interpolator/InterpolatorInterface.php | 1 - src/Phalcon/url/UrlInterface.php | 1 - src/Phalcon/validation/AbstractValidator.php | 13 ++++---- .../validation/AbstractValidatorComposite.php | 1 - .../validation/ValidationInterface.php | 1 - .../ValidatorCompositeInterface.php | 1 - src/Phalcon/validation/ValidatorFactory.php | 1 - src/Phalcon/validation/ValidatorInterface.php | 13 ++++---- src/Phalcon/validation/validator/Alnum.php | 1 - src/Phalcon/validation/validator/Alpha.php | 1 - src/Phalcon/validation/validator/Between.php | 1 - src/Phalcon/validation/validator/Callback.php | 1 - .../validation/validator/Confirmation.php | 1 - .../validation/validator/CreditCard.php | 1 - src/Phalcon/validation/validator/Date.php | 1 - src/Phalcon/validation/validator/Digit.php | 1 - src/Phalcon/validation/validator/Email.php | 1 - .../validation/validator/ExclusionIn.php | 1 - src/Phalcon/validation/validator/File.php | 1 - .../validation/validator/Identical.php | 1 - .../validation/validator/InclusionIn.php | 1 - src/Phalcon/validation/validator/Ip.php | 1 - .../validation/validator/Numericality.php | 1 - .../validation/validator/PresenceOf.php | 1 - src/Phalcon/validation/validator/Regex.php | 1 - .../validation/validator/StringLength.php | 1 - .../validation/validator/Uniqueness.php | 1 - src/Phalcon/validation/validator/Url.php | 1 - .../validator/file/AbstractFile.php | 1 - .../validation/validator/file/MimeType.php | 1 - .../validator/file/resolution/Equal.php | 1 - .../validator/file/resolution/Max.php | 1 - .../validator/file/resolution/Min.php | 1 - .../validation/validator/file/size/Equal.php | 1 - .../validation/validator/file/size/Max.php | 1 - .../validation/validator/file/size/Min.php | 1 - .../validation/validator/stringlength/Max.php | 1 - .../validation/validator/stringlength/Min.php | 1 - 402 files changed, 234 insertions(+), 652 deletions(-) diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index e680bfd8..40cd8611 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -76,8 +76,8 @@ public function deleteMultiple($keys): bool /** * Fetches a value from the cache. * - * @param string $key The unique key of this item in the cache. - * @param mixed $defaultValue Default value to return if the key does not exist. + * @param string $key The unique key of this item in the cache. + * @param mixed $defaultValue Default value to return if the key does not exist. * * @return mixed The value of the item from the cache, or $default in case of cache miss. * @@ -90,8 +90,8 @@ public function get($key, $defaultValue = null) /** * Obtains multiple cache items by their unique keys. * - * @param iterable $keys A list of keys that can obtained in a single operation. - * @param mixed $defaultValue Default value to return for keys that do not exist. + * @param iterable $keys A list of keys that can obtained in a single operation. + * @param mixed $defaultValue Default value to return for keys that do not exist. * * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. * @@ -117,9 +117,9 @@ public function has($key): bool /** * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. * - * @param string $key The key of the item to store. - * @param mixed $value The value of the item to store. Must be serializable. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param string $key The key of the item to store. + * @param mixed $value The value of the item to store. Must be serializable. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -134,8 +134,8 @@ public function set($key, $value, $ttl = null): bool /** * Persists a set of key => value pairs in the cache, with an optional TTL. * - * @param iterable $values A list of key => value pairs for a multiple-set operation. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -164,5 +164,4 @@ protected function checkKey($key) protected function checkKeys($keys) { } - } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index b6389b32..0047e935 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -266,5 +266,4 @@ public function unserialize($serialized) protected function setData(string $element, $value) { } - } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index 54b9b5ee..aef376b8 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -129,5 +129,4 @@ final protected function internalMerge(array $source, array $target): array protected function setData($element, $value) { } - } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 682790d0..45d76bd2 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -43,5 +43,4 @@ public function get($name) public function has($name): bool { } - } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 1e8fba6c..ba879ba2 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -156,11 +156,11 @@ public function decrypt(string $text, string $key = null): string /** * Decrypt a text that is coded as a base64 string. * - * @throws \Phalcon\Crypt\Mismatch * @param string $text * @param mixed $key * @param bool $safe * @return string + * @throws \Phalcon\Crypt\Mismatch */ public function decryptBase64(string $text, $key = null, bool $safe = false): string { @@ -284,9 +284,9 @@ public function setCipher(string $cipher): CryptInterface /** * Set the name of hashing algorithm. * - * @throws \Phalcon\Crypt\Exception * @param string $hashAlgo * @return \Phalcon\Crypt\CryptInterface + * @throws \Phalcon\Crypt\Exception */ public function setHashAlgo(string $hashAlgo): CryptInterface { @@ -396,5 +396,4 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } - } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 8176e61f..a6203126 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -23,7 +23,7 @@ class Debug /** * @var bool */ - static protected $isActive; + protected static $isActive; /** * @var bool @@ -244,5 +244,4 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } - } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index e3ba7bca..4ae0d207 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -66,7 +66,7 @@ class Di implements \Phalcon\Di\DiInterface /** * Latest DI build */ - static protected $_default; + protected static $_default; /** @@ -409,5 +409,4 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition public function setShared(string $name, $definition): ServiceInterface { } - } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index b4b81f61..5e8c1236 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -159,5 +159,4 @@ public function setEncoding(string $encoding) public function setHtmlQuoteType(int $quoteType) { } - } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index dd44dc5c..2c453056 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -17,5 +17,4 @@ class Exception extends \Exception implements \Throwable public static function containerServiceNotFound(string $service): string { } - } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index af1d47eb..93fff9a7 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -166,5 +166,4 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } - } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index 97664875..dbca3b84 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -12,11 +12,10 @@ class Kernel * Produces a pre-computed hash key based on a string. This function * produces different numbers in 32bit/64bit processors * - * @return string * @param string $key + * @return string */ public static function preComputeHashKey(string $key) { } - } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 5b8c36c5..62055867 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -279,5 +279,4 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } - } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 94f4c4b9..85dda5f1 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -195,8 +195,8 @@ public function excludeAdapters(array $adapters = array()): Logger * * @param string $name The name of the adapter * - * @throws Exception * @return \Phalcon\Logger\Adapter\AdapterInterface + * @throws Exception */ public function getAdapter(string $name): AdapterInterface { @@ -258,8 +258,8 @@ public function notice($message, array $context = array()) * * @param string $name The name of the adapter * - * @throws Logger\Exception * @return Logger + * @throws Logger\Exception */ public function removeAdapter(string $name): Logger { @@ -303,9 +303,9 @@ public function warning($message, array $context = array()) * * @param int $level * @param string $message * - * @throws Logger\Exception * @param array $context * @return bool + * @throws Logger\Exception */ protected function addMessage(int $level, string $message, array $context = array()): bool { @@ -329,5 +329,4 @@ protected function getLevels(): array private function getLevelNumber($level): int { } - } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 8908b38c..e5234f64 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -277,5 +277,4 @@ final public function toJson(int $options = 79): string final public function unserialize($serialized) { } - } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 72385801..eb791bf6 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -291,5 +291,4 @@ private function getLocalRequest(): ?RequestInterface private function getLocalSession(): ?SessionInterface { } - } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 29dfc532..c4b1e65b 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -47,40 +47,40 @@ class Tag const XHTML5 = 11; - static protected $autoEscape = true; + protected static $autoEscape = true; /** * DI Container */ - static protected $container; + protected static $container; /** * Pre-assigned values for components */ - static protected $displayValues; + protected static $displayValues; - static protected $documentAppendTitle = null; + protected static $documentAppendTitle = null; - static protected $documentPrependTitle = null; + protected static $documentPrependTitle = null; /** * HTML document title */ - static protected $documentTitle = null; + protected static $documentTitle = null; - static protected $documentTitleSeparator = null; + protected static $documentTitleSeparator = null; - static protected $documentType = 11; + protected static $documentType = 11; - static protected $escaperService = null; + protected static $escaperService = null; - static protected $urlService = null; + protected static $urlService = null; /** @@ -649,7 +649,7 @@ public static function weekField($parameters): string * @param bool $asValue * @return string */ - static final protected function inputField(string $type, $parameters, bool $asValue = false): string + final protected static function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -660,8 +660,7 @@ static final protected function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - static final protected function inputFieldChecked(string $type, $parameters): string + final protected static function inputFieldChecked(string $type, $parameters): string { } - } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 3856fa28..e5971794 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -269,5 +269,4 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index 8cb01ae2..b5786583 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -198,5 +198,4 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } - } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index 9480ffe7..99644012 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -36,7 +36,6 @@ class Validation extends Injectable implements \Phalcon\Validation\ValidationInt protected $values; - public function getData() { } @@ -219,5 +218,4 @@ public function validate($data = null, $entity = null): Messages protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool { } - } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index c8630cb2..237ed367 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -85,7 +85,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - protected final static function _getSpecial(int $special): string + final protected static function _getSpecial(int $special): string { } @@ -131,5 +131,4 @@ public static function getId(): string public static function getPart(int $part): string { } - } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/acl/Component.php index af42828c..8f068fd1 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/acl/Component.php @@ -58,5 +58,4 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/acl/ComponentAware.php b/src/Phalcon/acl/ComponentAware.php index 3539eb59..412164f1 100644 --- a/src/Phalcon/acl/ComponentAware.php +++ b/src/Phalcon/acl/ComponentAware.php @@ -14,5 +14,4 @@ interface ComponentAware * @return string */ public function getComponentName(): string; - } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/acl/ComponentInterface.php index b1e0960c..2a98bb5b 100644 --- a/src/Phalcon/acl/ComponentInterface.php +++ b/src/Phalcon/acl/ComponentInterface.php @@ -28,5 +28,4 @@ public function getName(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/acl/Enum.php b/src/Phalcon/acl/Enum.php index bce07c38..a81e1a28 100644 --- a/src/Phalcon/acl/Enum.php +++ b/src/Phalcon/acl/Enum.php @@ -12,6 +12,4 @@ class Enum const DENY = 0; - - } diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/acl/Role.php index 32174e12..563e1dc0 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/acl/Role.php @@ -58,5 +58,4 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/acl/RoleAware.php b/src/Phalcon/acl/RoleAware.php index 8a22a4b6..b568a8bf 100644 --- a/src/Phalcon/acl/RoleAware.php +++ b/src/Phalcon/acl/RoleAware.php @@ -14,5 +14,4 @@ interface RoleAware * @return string */ public function getRoleName(): string; - } diff --git a/src/Phalcon/acl/RoleInterface.php b/src/Phalcon/acl/RoleInterface.php index 7ba84c4a..0d22ff31 100644 --- a/src/Phalcon/acl/RoleInterface.php +++ b/src/Phalcon/acl/RoleInterface.php @@ -28,5 +28,4 @@ public function getDescription(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/acl/adapter/AbstractAdapter.php index d1d265b7..96992459 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/acl/adapter/AbstractAdapter.php @@ -117,5 +117,4 @@ public function setDefaultAction(int $defaultAccess) public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/acl/adapter/AdapterInterface.php index 76530327..bd8a7852 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/acl/adapter/AdapterInterface.php @@ -170,5 +170,4 @@ public function setDefaultAction(int $defaultAccess); * @param int $defaultAccess */ public function setNoArgumentsDefaultAction(int $defaultAccess); - } diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/acl/adapter/Memory.php index 32402257..21231cb4 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/acl/adapter/Memory.php @@ -443,5 +443,4 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } - } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/annotations/Annotation.php index 73c32ac7..3e108679 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/annotations/Annotation.php @@ -121,5 +121,4 @@ public function hasArgument($position): bool public function numberArguments(): int { } - } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/annotations/AnnotationsFactory.php index 48c8ebdd..1879fbe6 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/annotations/AnnotationsFactory.php @@ -49,5 +49,4 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } - } diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/annotations/Collection.php index 89818e02..fbe9063f 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/annotations/Collection.php @@ -129,5 +129,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/annotations/Reader.php index b085d963..d9e3f689 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/annotations/Reader.php @@ -29,5 +29,4 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } - } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/annotations/ReaderInterface.php index 5ba4b965..0d319b13 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/annotations/ReaderInterface.php @@ -25,5 +25,4 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; - } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/annotations/Reflection.php index ae86841f..5d73a94b 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/annotations/Reflection.php @@ -82,5 +82,4 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } - } diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/annotations/adapter/AbstractAdapter.php index f1750128..a1c84925 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/annotations/adapter/AbstractAdapter.php @@ -92,5 +92,4 @@ public function getReader(): ReaderInterface public function setReader(\Phalcon\Annotations\ReaderInterface $reader) { } - } diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/annotations/adapter/AdapterInterface.php index 31895549..e316bb87 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/annotations/adapter/AdapterInterface.php @@ -67,5 +67,4 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); - } diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/annotations/adapter/Apcu.php index d191f10b..434ce2e9 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/annotations/adapter/Apcu.php @@ -53,5 +53,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data): bool { } - } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/annotations/adapter/Memory.php index f0b7a267..1a70e83b 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/annotations/adapter/Memory.php @@ -33,5 +33,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } - } diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/annotations/adapter/Stream.php index d61b8780..6ef35cde 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/annotations/adapter/Stream.php @@ -51,5 +51,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } - } diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/application/AbstractApplication.php index 64da7660..52f5e994 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/application/AbstractApplication.php @@ -122,5 +122,4 @@ public function setDefaultModule(string $defaultModule): AbstractApplication public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/assets/Asset.php index 19892055..b65b304b 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/assets/Asset.php @@ -297,5 +297,4 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } - } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/assets/AssetInterface.php index c7bdf739..44bbc9ea 100644 --- a/src/Phalcon/assets/AssetInterface.php +++ b/src/Phalcon/assets/AssetInterface.php @@ -59,5 +59,4 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; - } diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/assets/Collection.php index 69ad96e2..e81ae5af 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/assets/Collection.php @@ -481,5 +481,4 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } - } diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/assets/FilterInterface.php index e0ba66c2..f933b5ed 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/assets/FilterInterface.php @@ -15,5 +15,4 @@ interface FilterInterface * @return string */ public function filter(string $content): string; - } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/assets/Inline.php index f643eafd..6cffc46d 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/assets/Inline.php @@ -110,5 +110,4 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } - } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/assets/Manager.php index 6d5b66bb..e618f536 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/assets/Manager.php @@ -351,5 +351,4 @@ public function useImplicitOutput(bool $implicitOutput): Manager private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string { } - } diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/assets/asset/Css.php index bfc4313a..4ee16acd 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/assets/asset/Css.php @@ -21,5 +21,4 @@ class Css extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/assets/asset/Js.php index 7d1032e2..07e78f19 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/assets/asset/Js.php @@ -21,5 +21,4 @@ class Js extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/assets/filters/Cssmin.php index 4964b7f8..fe03b48b 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/assets/filters/Cssmin.php @@ -19,5 +19,4 @@ class Cssmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/assets/filters/Jsmin.php index 9f5356cd..691af3bf 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/assets/filters/Jsmin.php @@ -20,5 +20,4 @@ class Jsmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/assets/filters/None.php index eea54d58..7b07ff7f 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/assets/filters/None.php @@ -17,5 +17,4 @@ class None implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/assets/inline/Css.php index a6f2a205..ed9f6c35 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/assets/inline/Css.php @@ -18,5 +18,4 @@ class Css extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/assets/inline/Js.php index c8b04f72..3606be6b 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/assets/inline/Js.php @@ -18,5 +18,4 @@ class Js extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/cache/AdapterFactory.php index 73e79832..04895e44 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/cache/AdapterFactory.php @@ -46,5 +46,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/cache/CacheFactory.php index 13c5d0c9..27f02fc5 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/cache/CacheFactory.php @@ -44,5 +44,4 @@ public function load($config) public function newInstance(string $name, array $options = array()): CacheInterface { } - } diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/cli/Console.php index 77acfe2a..82bfad9a 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/cli/Console.php @@ -40,5 +40,4 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } - } diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/cli/Dispatcher.php index de74a5b5..47179b40 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/cli/Dispatcher.php @@ -80,9 +80,9 @@ public function getLastTask(): TaskInterface /** * Gets an option by its name or numeric index * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue * @return mixed */ public function getOption($option, $filters = null, $defaultValue = null) @@ -180,5 +180,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/cli/DispatcherInterface.php index eed77c38..58ca9c1f 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/cli/DispatcherInterface.php @@ -70,5 +70,4 @@ public function setTaskName(string $taskName); * @param string $taskSuffix */ public function setTaskSuffix(string $taskSuffix); - } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/cli/Router.php index bd5fa234..a6956eff 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/cli/Router.php @@ -240,5 +240,4 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } - } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/cli/RouterInterface.php index 9a3dbaa9..5f2f0ba6 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/cli/RouterInterface.php @@ -125,5 +125,4 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/cli/Task.php index dd399c74..8fe41590 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/cli/Task.php @@ -59,5 +59,4 @@ public function getEventsManager(): ?ManagerInterface public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/cli/router/Route.php index 42fc9a52..8ff80394 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/cli/router/Route.php @@ -23,7 +23,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $delimiter; - static protected $delimiterPath = self::DEFAULT_DELIMITER; + protected static $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -41,7 +41,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; /** @@ -241,5 +241,4 @@ public function setDescription(string $description): RouteInterface public function setName(string $name): RouteInterface { } - } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/cli/router/RouteInterface.php index d5cff844..f87e2b98 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/cli/router/RouteInterface.php @@ -108,5 +108,4 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; - } diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/collection/ReadOnly.php index 9cdb2eb2..d5709a3c 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/collection/ReadOnly.php @@ -28,5 +28,4 @@ public function remove(string $element) public function set(string $element, $value) { } - } diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/config/ConfigFactory.php index ac5cce55..c26fcb48 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/config/ConfigFactory.php @@ -61,5 +61,4 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/config/adapter/Grouped.php index 83d53cbf..46564c81 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/config/adapter/Grouped.php @@ -67,5 +67,4 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } - } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/config/adapter/Ini.php index 27de2d5e..79a0f125 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/config/adapter/Ini.php @@ -80,5 +80,4 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } - } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/config/adapter/Json.php index 070d12dc..b2df23b3 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/config/adapter/Json.php @@ -35,5 +35,4 @@ class Json extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/config/adapter/Php.php index 5b214eb9..c1e91821 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/config/adapter/Php.php @@ -50,5 +50,4 @@ class Php extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/config/adapter/Yaml.php index fe22659f..f545b2a2 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/config/adapter/Yaml.php @@ -53,5 +53,4 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } - } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/crypt/CryptInterface.php index 2758e631..7248875f 100644 --- a/src/Phalcon/crypt/CryptInterface.php +++ b/src/Phalcon/crypt/CryptInterface.php @@ -133,5 +133,4 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; - } diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/db/AbstractDb.php index faf5d492..d99eee40 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/db/AbstractDb.php @@ -56,5 +56,4 @@ abstract class AbstractDb public static function setup(array $options) { } - } diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/db/Column.php index 5bc4457f..f8fb568d 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/db/Column.php @@ -446,5 +446,4 @@ public function isPrimary(): bool public function isUnsigned(): bool { } - } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/db/ColumnInterface.php index 2fc8226d..d76627d2 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/db/ColumnInterface.php @@ -119,5 +119,4 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; - } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/db/Dialect.php index f8ff74e3..1644f7dd 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/db/Dialect.php @@ -502,5 +502,4 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } - } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/db/DialectInterface.php index 0e8e587d..5fc159d5 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/db/DialectInterface.php @@ -312,5 +312,4 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; - } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/db/Enum.php index 3049c8f7..6c105d89 100644 --- a/src/Phalcon/db/Enum.php +++ b/src/Phalcon/db/Enum.php @@ -57,6 +57,4 @@ class Enum const FETCH_UNIQUE = 196608; - - } diff --git a/src/Phalcon/db/Index.php b/src/Phalcon/db/Index.php index d861d538..f80a22bd 100644 --- a/src/Phalcon/db/Index.php +++ b/src/Phalcon/db/Index.php @@ -92,5 +92,4 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } - } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/db/IndexInterface.php index 036ed333..38d385a8 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/db/IndexInterface.php @@ -28,5 +28,4 @@ public function getName(): string; * @return string */ public function getType(): string; - } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index 1c72907c..9c3aa351 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -143,5 +143,4 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } - } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/db/RawValue.php index ff3994fa..e89199da 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/db/RawValue.php @@ -52,5 +52,4 @@ public function __toString(): string public function __construct($value) { } - } diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/db/Reference.php index 6a80a29f..8d88dc19 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/db/Reference.php @@ -163,5 +163,4 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } - } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/db/ReferenceInterface.php index 738157ac..056b8049 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/db/ReferenceInterface.php @@ -63,5 +63,4 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; - } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/db/ResultInterface.php index a6baa4b2..7ce90cb1 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/db/ResultInterface.php @@ -73,5 +73,4 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; - } diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/db/adapter/AbstractAdapter.php index e768f3c9..f4891771 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/db/adapter/AbstractAdapter.php @@ -15,7 +15,7 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, /** * Connection ID */ - static protected $connectionConsecutive = 0; + protected static $connectionConsecutive = 0; /** * Active connection ID @@ -919,5 +919,4 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } - } diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/db/adapter/AdapterInterface.php index 33611efd..cc9e7e03 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/db/adapter/AdapterInterface.php @@ -621,5 +621,4 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; - } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/db/adapter/PdoFactory.php index ce2bc323..d24a0621 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/db/adapter/PdoFactory.php @@ -53,5 +53,4 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } - } diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/db/adapter/pdo/AbstractPdo.php index a923ff6d..053c10bd 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/db/adapter/pdo/AbstractPdo.php @@ -366,5 +366,4 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; - } diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/db/adapter/pdo/Mysql.php index e2b967c7..53e1b091 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/db/adapter/pdo/Mysql.php @@ -103,5 +103,4 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/db/adapter/pdo/Postgresql.php index c1452061..40012014 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/db/adapter/pdo/Postgresql.php @@ -167,5 +167,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/db/adapter/pdo/Sqlite.php index a1b4c2b8..f0243b91 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/db/adapter/pdo/Sqlite.php @@ -138,5 +138,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/db/dialect/Mysql.php index 0b004487..0a35e0ef 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/db/dialect/Mysql.php @@ -351,5 +351,4 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string { } - } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/db/dialect/Postgresql.php index 4f1b43f5..99a4f307 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/db/dialect/Postgresql.php @@ -322,5 +322,4 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } - } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/db/dialect/Sqlite.php index e7b4cca5..5ac53f17 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/db/dialect/Sqlite.php @@ -345,5 +345,4 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } - } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/db/profiler/Item.php index 0e6c60da..e4244b58 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/db/profiler/Item.php @@ -141,5 +141,4 @@ public function getSqlVariables(): array public function getTotalElapsedSeconds(): float { } - } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/db/result/Pdo.php index 3bd03566..c7f012c7 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/db/result/Pdo.php @@ -225,5 +225,4 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } - } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/debug/Dump.php index f2ae8f6d..cc2fbf6a 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/debug/Dump.php @@ -168,5 +168,4 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } - } diff --git a/src/Phalcon/di/AbstractInjectionAware.php b/src/Phalcon/di/AbstractInjectionAware.php index 3a7790bb..bdb18ca2 100644 --- a/src/Phalcon/di/AbstractInjectionAware.php +++ b/src/Phalcon/di/AbstractInjectionAware.php @@ -32,5 +32,4 @@ public function getDI(): DiInterface public function setDI(\Phalcon\Di\DiInterface $container) { } - } diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/di/DiInterface.php index d1995d31..9f170fce 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/di/DiInterface.php @@ -123,5 +123,4 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition * @return \Phalcon\Di\ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; - } diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/di/FactoryDefault.php index 7b75437b..3478549d 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/di/FactoryDefault.php @@ -17,5 +17,4 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } - } diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/di/Injectable.php index 55b12a8e..f7382c65 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/di/Injectable.php @@ -80,5 +80,4 @@ public function getDI(): DiInterface public function setDI(\Phalcon\Di\DiInterface $container) { } - } diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/di/InjectionAwareInterface.php index d12064ac..3bf3ec3b 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/di/InjectionAwareInterface.php @@ -22,5 +22,4 @@ public function setDI(\Phalcon\Di\DiInterface $container); * @return \Phalcon\Di\DiInterface */ public function getDI(): DiInterface; - } diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/di/Service.php index 81e5032b..3de49845 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/di/Service.php @@ -55,8 +55,8 @@ public function getDefinition() /** * Returns a parameter in a specific position * - * @return array * @param int $position + * @return array */ public function getParameter(int $position) { @@ -128,5 +128,4 @@ public function setShared(bool $shared) public function setSharedInstance($sharedInstance) { } - } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/di/ServiceInterface.php index 90647806..7771819c 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/di/ServiceInterface.php @@ -18,8 +18,8 @@ public function getDefinition(); /** * Returns a parameter in a specific position * - * @return array * @param int $position + * @return array */ public function getParameter(int $position); @@ -68,5 +68,4 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); - } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/di/ServiceProviderInterface.php index e61eaedb..6756aa83 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/di/ServiceProviderInterface.php @@ -35,5 +35,4 @@ interface ServiceProviderInterface * @param \Phalcon\Di\DiInterface $di */ public function register(\Phalcon\Di\DiInterface $di); - } diff --git a/src/Phalcon/di/factorydefault/Cli.php b/src/Phalcon/di/factorydefault/Cli.php index 0b7bad40..f7c4b2d3 100644 --- a/src/Phalcon/di/factorydefault/Cli.php +++ b/src/Phalcon/di/factorydefault/Cli.php @@ -21,5 +21,4 @@ class Cli extends FactoryDefault public function __construct() { } - } diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/di/service/Builder.php index d83b465b..2886678e 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/di/service/Builder.php @@ -14,9 +14,9 @@ class Builder * Builds a service using a complex service definition * * @param array $parameters - * @return mixed * @param \Phalcon\Di\DiInterface $container * @param array $definition + * @return mixed */ public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) { @@ -25,10 +25,10 @@ public function build(\Phalcon\Di\DiInterface $container, array $definition, $pa /** * Resolves a constructor/call parameter * - * @return mixed * @param \Phalcon\Di\DiInterface $container * @param int $position * @param array $argument + * @return mixed */ private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) { @@ -44,5 +44,4 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array { } - } diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/dispatcher/AbstractDispatcher.php index b092ff52..ec2af170 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/dispatcher/AbstractDispatcher.php @@ -146,8 +146,8 @@ public function dispatch(): bool * ); * ``` * - * @throws \Phalcon\Exception * @param array $forward + * @throws \Phalcon\Exception */ public function forward(array $forward) { @@ -463,5 +463,4 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } - } diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/dispatcher/DispatcherInterface.php index 3e670853..c8ff6675 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/dispatcher/DispatcherInterface.php @@ -145,5 +145,4 @@ public function setParam($param, $value); * @param array $params */ public function setParams(array $params); - } diff --git a/src/Phalcon/dispatcher/Exception.php b/src/Phalcon/dispatcher/Exception.php index a9867c1d..cad099de 100644 --- a/src/Phalcon/dispatcher/Exception.php +++ b/src/Phalcon/dispatcher/Exception.php @@ -24,6 +24,4 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; - - } diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/domain/payload/Payload.php index b3117f15..8be33d5e 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/domain/payload/Payload.php @@ -137,5 +137,4 @@ public function setOutput($output): PayloadInterface public function setStatus($status): PayloadInterface { } - } diff --git a/src/Phalcon/domain/payload/PayloadFactory.php b/src/Phalcon/domain/payload/PayloadFactory.php index 739ac257..9c93b0df 100644 --- a/src/Phalcon/domain/payload/PayloadFactory.php +++ b/src/Phalcon/domain/payload/PayloadFactory.php @@ -16,5 +16,4 @@ class PayloadFactory public function newInstance(): PayloadInterface { } - } diff --git a/src/Phalcon/domain/payload/ReadableInterface.php b/src/Phalcon/domain/payload/ReadableInterface.php index 53a7fd5a..cac33ff9 100644 --- a/src/Phalcon/domain/payload/ReadableInterface.php +++ b/src/Phalcon/domain/payload/ReadableInterface.php @@ -42,5 +42,4 @@ public function getMessages(); * @return mixed */ public function getExtras(); - } diff --git a/src/Phalcon/domain/payload/Status.php b/src/Phalcon/domain/payload/Status.php index 5da2de6f..6d3b632c 100644 --- a/src/Phalcon/domain/payload/Status.php +++ b/src/Phalcon/domain/payload/Status.php @@ -74,5 +74,4 @@ class Status final private function __construct() { } - } diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/domain/payload/WriteableInterface.php index cf737f0c..08bbd422 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/domain/payload/WriteableInterface.php @@ -49,5 +49,4 @@ public function setMessages($messages): PayloadInterface; * @return \Phalcon\Domain\Payload\PayloadInterface */ public function setExtras($extras): PayloadInterface; - } diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/escaper/EscaperInterface.php index 784051f3..282aa24c 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/escaper/EscaperInterface.php @@ -70,5 +70,4 @@ public function setEncoding(string $encoding); * @param int $quoteType */ public function setHtmlQuoteType(int $quoteType); - } diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/events/Event.php index 6e8b3142..87441b61 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/events/Event.php @@ -152,5 +152,4 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } - } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/events/EventInterface.php index 92f60516..8ac004c0 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/events/EventInterface.php @@ -60,5 +60,4 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; - } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/events/EventsAwareInterface.php index dec83036..971d263e 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/events/EventsAwareInterface.php @@ -24,5 +24,4 @@ public function getEventsManager(): ?ManagerInterface; * @param ManagerInterface $eventsManager */ public function setEventsManager(ManagerInterface $eventsManager); - } diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/events/Manager.php index 5aa8fa91..ed672b84 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/events/Manager.php @@ -100,9 +100,9 @@ public function enablePriorities(bool $enablePriorities) * * @param object $source * @param mixed $data - * @return mixed * @param string $eventType * @param bool $cancelable + * @return mixed */ public function fire(string $eventType, $source, $data = null, bool $cancelable = true) { @@ -111,9 +111,9 @@ public function fire(string $eventType, $source, $data = null, bool $cancelable /** * Internal handler to call a queue of events * - * @return mixed * @param \SplPriorityQueue $queue * @param EventInterface $event + * @return mixed */ final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) { @@ -158,5 +158,4 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } - } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/events/ManagerInterface.php index 7ddf377a..bad1e4bb 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/events/ManagerInterface.php @@ -42,9 +42,9 @@ public function detachAll(string $type = null); * * @param object $source * @param mixed $data - * @return mixed * @param string $eventType * @param bool $cancelable + * @return mixed */ public function fire(string $eventType, $source, $data = null, bool $cancelable = true); @@ -63,5 +63,4 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; - } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/factory/AbstractFactory.php index 31396f92..7c7a381f 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/factory/AbstractFactory.php @@ -57,5 +57,4 @@ abstract protected function getAdapters(): array; protected function init(array $services = array()) { } - } diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/filter/FilterFactory.php index 690c108f..e79b82ae 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/filter/FilterFactory.php @@ -29,5 +29,4 @@ public function newInstance(): FilterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/filter/FilterInterface.php index 067ba31c..ffa0fea8 100644 --- a/src/Phalcon/filter/FilterInterface.php +++ b/src/Phalcon/filter/FilterInterface.php @@ -17,5 +17,4 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); - } diff --git a/src/Phalcon/filter/sanitize/AbsInt.php b/src/Phalcon/filter/sanitize/AbsInt.php index 8e81576a..8cceb179 100644 --- a/src/Phalcon/filter/sanitize/AbsInt.php +++ b/src/Phalcon/filter/sanitize/AbsInt.php @@ -16,5 +16,4 @@ class AbsInt public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/Alnum.php b/src/Phalcon/filter/sanitize/Alnum.php index e6acb75a..533abeff 100644 --- a/src/Phalcon/filter/sanitize/Alnum.php +++ b/src/Phalcon/filter/sanitize/Alnum.php @@ -16,5 +16,4 @@ class Alnum public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/Alpha.php b/src/Phalcon/filter/sanitize/Alpha.php index 65a72e6c..5c4a764b 100644 --- a/src/Phalcon/filter/sanitize/Alpha.php +++ b/src/Phalcon/filter/sanitize/Alpha.php @@ -16,5 +16,4 @@ class Alpha public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/BoolVal.php b/src/Phalcon/filter/sanitize/BoolVal.php index d1c00d66..d3d4708c 100644 --- a/src/Phalcon/filter/sanitize/BoolVal.php +++ b/src/Phalcon/filter/sanitize/BoolVal.php @@ -16,5 +16,4 @@ class BoolVal public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/Email.php b/src/Phalcon/filter/sanitize/Email.php index a2e43a68..6efc92fa 100644 --- a/src/Phalcon/filter/sanitize/Email.php +++ b/src/Phalcon/filter/sanitize/Email.php @@ -16,5 +16,4 @@ class Email public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/FloatVal.php b/src/Phalcon/filter/sanitize/FloatVal.php index 7b838493..916a7c04 100644 --- a/src/Phalcon/filter/sanitize/FloatVal.php +++ b/src/Phalcon/filter/sanitize/FloatVal.php @@ -16,5 +16,4 @@ class FloatVal public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/IntVal.php b/src/Phalcon/filter/sanitize/IntVal.php index db75914a..98445ffc 100644 --- a/src/Phalcon/filter/sanitize/IntVal.php +++ b/src/Phalcon/filter/sanitize/IntVal.php @@ -16,5 +16,4 @@ class IntVal public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/Lower.php b/src/Phalcon/filter/sanitize/Lower.php index 74ab9e1d..19aaad22 100644 --- a/src/Phalcon/filter/sanitize/Lower.php +++ b/src/Phalcon/filter/sanitize/Lower.php @@ -16,5 +16,4 @@ class Lower public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/LowerFirst.php b/src/Phalcon/filter/sanitize/LowerFirst.php index 99d96acc..70f5a0bc 100644 --- a/src/Phalcon/filter/sanitize/LowerFirst.php +++ b/src/Phalcon/filter/sanitize/LowerFirst.php @@ -16,5 +16,4 @@ class LowerFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/Regex.php b/src/Phalcon/filter/sanitize/Regex.php index 397c125b..f7aa7910 100644 --- a/src/Phalcon/filter/sanitize/Regex.php +++ b/src/Phalcon/filter/sanitize/Regex.php @@ -18,5 +18,4 @@ class Regex public function __invoke($input, $pattern, $replace) { } - } diff --git a/src/Phalcon/filter/sanitize/Remove.php b/src/Phalcon/filter/sanitize/Remove.php index d95e31b5..a556ef0f 100644 --- a/src/Phalcon/filter/sanitize/Remove.php +++ b/src/Phalcon/filter/sanitize/Remove.php @@ -17,5 +17,4 @@ class Remove public function __invoke($input, $replace) { } - } diff --git a/src/Phalcon/filter/sanitize/Replace.php b/src/Phalcon/filter/sanitize/Replace.php index a40b14c2..6117afa9 100644 --- a/src/Phalcon/filter/sanitize/Replace.php +++ b/src/Phalcon/filter/sanitize/Replace.php @@ -18,5 +18,4 @@ class Replace public function __invoke($input, $from, $to) { } - } diff --git a/src/Phalcon/filter/sanitize/Special.php b/src/Phalcon/filter/sanitize/Special.php index 7e333cc7..fe890c36 100644 --- a/src/Phalcon/filter/sanitize/Special.php +++ b/src/Phalcon/filter/sanitize/Special.php @@ -16,5 +16,4 @@ class Special public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/SpecialFull.php b/src/Phalcon/filter/sanitize/SpecialFull.php index fb9c7efb..04564d3a 100644 --- a/src/Phalcon/filter/sanitize/SpecialFull.php +++ b/src/Phalcon/filter/sanitize/SpecialFull.php @@ -16,5 +16,4 @@ class SpecialFull public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/StringVal.php b/src/Phalcon/filter/sanitize/StringVal.php index f168d5e4..db0866a0 100644 --- a/src/Phalcon/filter/sanitize/StringVal.php +++ b/src/Phalcon/filter/sanitize/StringVal.php @@ -16,5 +16,4 @@ class StringVal public function __invoke($input) { } - } diff --git a/src/Phalcon/filter/sanitize/Striptags.php b/src/Phalcon/filter/sanitize/Striptags.php index fa617220..72f8bf05 100644 --- a/src/Phalcon/filter/sanitize/Striptags.php +++ b/src/Phalcon/filter/sanitize/Striptags.php @@ -16,5 +16,4 @@ class Striptags public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/Trim.php b/src/Phalcon/filter/sanitize/Trim.php index 78092617..c325fc47 100644 --- a/src/Phalcon/filter/sanitize/Trim.php +++ b/src/Phalcon/filter/sanitize/Trim.php @@ -16,5 +16,4 @@ class Trim public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/Upper.php b/src/Phalcon/filter/sanitize/Upper.php index 3e9638ab..3baed094 100644 --- a/src/Phalcon/filter/sanitize/Upper.php +++ b/src/Phalcon/filter/sanitize/Upper.php @@ -16,5 +16,4 @@ class Upper public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/UpperFirst.php b/src/Phalcon/filter/sanitize/UpperFirst.php index 2906ba8a..afbc238b 100644 --- a/src/Phalcon/filter/sanitize/UpperFirst.php +++ b/src/Phalcon/filter/sanitize/UpperFirst.php @@ -16,5 +16,4 @@ class UpperFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/UpperWords.php b/src/Phalcon/filter/sanitize/UpperWords.php index 4782f08b..8f24dc60 100644 --- a/src/Phalcon/filter/sanitize/UpperWords.php +++ b/src/Phalcon/filter/sanitize/UpperWords.php @@ -16,5 +16,4 @@ class UpperWords public function __invoke(string $input) { } - } diff --git a/src/Phalcon/filter/sanitize/Url.php b/src/Phalcon/filter/sanitize/Url.php index 885a8634..ac80afde 100644 --- a/src/Phalcon/filter/sanitize/Url.php +++ b/src/Phalcon/filter/sanitize/Url.php @@ -16,5 +16,4 @@ class Url public function __invoke($input) { } - } diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/firewall/adapter/AbstractAdapter.php index 3807da09..5f9c0c44 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/firewall/adapter/AbstractAdapter.php @@ -4,13 +4,8 @@ use Closure; use Phalcon\Acl\Enum; -use Phalcon\Acl\RoleAware; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Di\DiInterface; -use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Exception; -use Phalcon\Mvc\Dispatcher; /** * Adapter for Phalcon\Firewall adapters @@ -229,5 +224,4 @@ protected function saveAccessInCache(string $key, bool $access) protected function throwFirewallException(string $message, int $exceptionCode = 0): bool { } - } diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/firewall/adapter/Acl.php index ec36390f..c45de4ce 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/firewall/adapter/Acl.php @@ -206,5 +206,4 @@ protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher protected function saveAccessInCache(string $key, bool $access) { } - } diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/firewall/adapter/AdapterInterface.php index d38b6148..24eed8aa 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/firewall/adapter/AdapterInterface.php @@ -61,5 +61,4 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface; * @return AdapterInterface */ public function setRoleCallback(\Closure $callback): AdapterInterface; - } diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/firewall/adapter/Annotations.php index 9424746c..610d81f0 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/firewall/adapter/Annotations.php @@ -126,5 +126,4 @@ protected function getAccessFromCache(string $key, array $originalValues = null, protected function handleAnnotation($annotation, bool $access, $role) { } - } diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/firewall/adapter/micro/Acl.php index 72483f90..bc3227c6 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/firewall/adapter/micro/Acl.php @@ -232,5 +232,4 @@ protected function handleRouter(\Phalcon\Mvc\Micro $micro) protected function saveAccessInCache(string $key, bool $access) { } - } diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/flash/AbstractFlash.php index f48a7fd8..e37abb3a 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/flash/AbstractFlash.php @@ -215,8 +215,8 @@ public function success(string $message): string * ``` * * @param string|array $message - * @return string|void * @param string $type + * @return string|void */ public function outputMessage(string $type, $message) { @@ -266,5 +266,4 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } - } diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/flash/Direct.php index e70ffb0e..92ba9061 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/flash/Direct.php @@ -28,5 +28,4 @@ public function message(string $type, $message): ?string public function output(bool $remove = true) { } - } diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/flash/FlashInterface.php index d5516aac..b5161398 100644 --- a/src/Phalcon/flash/FlashInterface.php +++ b/src/Phalcon/flash/FlashInterface.php @@ -50,5 +50,4 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; - } diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/flash/Session.php index ccf30cea..9a36708b 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/flash/Session.php @@ -88,5 +88,4 @@ protected function setSessionMessages(array $messages): array public function getSessionService(): ManagerInterface { } - } diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/forms/Form.php index d9a105a6..18cdb99d 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/forms/Form.php @@ -321,8 +321,8 @@ public function rewind() /** * Sets the form's action * - * @return Form * @param string $action + * @return Form */ public function setAction(string $action): Form { @@ -377,5 +377,4 @@ public function setUserOptions(array $options): Form public function valid(): bool { } - } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/forms/Manager.php index b59bdfda..42aeafcc 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/forms/Manager.php @@ -52,5 +52,4 @@ public function has(string $name): bool public function set(string $name, Form $form): Manager { } - } diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/forms/element/AbstractElement.php index 903f45be..9bae5d4a 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/forms/element/AbstractElement.php @@ -357,5 +357,4 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } - } diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/forms/element/Check.php index 2cf1e024..68472d21 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/forms/element/Check.php @@ -19,5 +19,4 @@ class Check extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/forms/element/Date.php index 8d37a028..56000b1b 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/forms/element/Date.php @@ -17,5 +17,4 @@ class Date extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/forms/element/ElementInterface.php index a8c29101..fbde7685 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/forms/element/ElementInterface.php @@ -256,5 +256,4 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; - } diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/forms/element/Email.php index 96d70d99..d008a2a0 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/forms/element/Email.php @@ -19,5 +19,4 @@ class Email extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/forms/element/File.php index a50e054e..89f91f29 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/forms/element/File.php @@ -17,5 +17,4 @@ class File extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/forms/element/Hidden.php index 29558220..8821861c 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/forms/element/Hidden.php @@ -19,5 +19,4 @@ class Hidden extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/forms/element/Numeric.php index 1f8b48eb..2a348713 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/forms/element/Numeric.php @@ -19,5 +19,4 @@ class Numeric extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/forms/element/Password.php index 49f3b795..23f775ed 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/forms/element/Password.php @@ -19,5 +19,4 @@ class Password extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/forms/element/Radio.php index 6d9e0af4..1a6b4e25 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/forms/element/Radio.php @@ -19,5 +19,4 @@ class Radio extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/forms/element/Select.php index 92c05612..4c2c5c4c 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/forms/element/Select.php @@ -62,5 +62,4 @@ public function render(array $attributes = array()): string public function setOptions($options): ElementInterface { } - } diff --git a/src/Phalcon/forms/element/Submit.php b/src/Phalcon/forms/element/Submit.php index c64cd2a6..d5070038 100644 --- a/src/Phalcon/forms/element/Submit.php +++ b/src/Phalcon/forms/element/Submit.php @@ -17,5 +17,4 @@ class Submit extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/forms/element/Text.php index b0f55d39..32aeaf71 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/forms/element/Text.php @@ -19,5 +19,4 @@ class Text extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/forms/element/TextArea.php b/src/Phalcon/forms/element/TextArea.php index cf43c71c..458c6c79 100644 --- a/src/Phalcon/forms/element/TextArea.php +++ b/src/Phalcon/forms/element/TextArea.php @@ -17,5 +17,4 @@ class TextArea extends AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/helper/Arr.php index 1dc7e540..70f8dd5a 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/helper/Arr.php @@ -12,8 +12,8 @@ class Arr * Chunks an array into smaller arrays of a specified size. * * @param array $collection - * @param int $size - * @param bool $preserveKeys + * @param int $size + * @param bool $preserveKeys * * @return array */ @@ -25,7 +25,7 @@ final public static function chunk(array $collection, int $size, bool $preserveK * Returns the first element of the collection. If a callable is passed, the * element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -38,7 +38,7 @@ final public static function first(array $collection, $method = null) * Returns the key of the first element of the collection. If a callable * is passed, the element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -51,7 +51,7 @@ final public static function firstKey(array $collection, $method = null) * Flattens an array up to the one level depth, unless `$deep` is set to `true` * * @param array $collection - * @param bool $deep + * @param bool $deep * * @return array */ @@ -75,7 +75,7 @@ final public static function get(array $collection, $index, $defaultValue = null /** * Groups the elements of an array based on the passed callable * - * @param array $collection + * @param array $collection * @param callable $method * * @return array @@ -113,7 +113,7 @@ final public static function isUnique(array $collection): bool * Returns the last element of the collection. If a callable is passed, the * element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * return mixed @@ -127,7 +127,7 @@ final public static function last(array $collection, $method = null) * Returns the key of the last element of the collection. If a callable is * passed, the element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -139,8 +139,8 @@ final public static function lastKey(array $collection, $method = null) /** * Sorts a collection of arrays or objects by key * - * @param array $collection - * @param mixed $attribute + * @param array $collection + * @param mixed $attribute * @param string $order * * @return array @@ -152,7 +152,7 @@ final public static function order(array $collection, $attribute, string $order /** * Retrieves all of the values for a given key: * - * @param array $collection + * @param array $collection * @param string $element * * @return array @@ -178,7 +178,7 @@ final public static function set(array $collection, $value, $index = null): arra * Returns a new array with n elements removed from the right. * * @param array $collection - * @param int $elements + * @param int $elements * * @return array */ @@ -190,7 +190,7 @@ final public static function sliceLeft(array $collection, int $elements = 1): ar * Returns a new array with the X elements from the right * * @param array $collection - * @param int $elements + * @param int $elements * * @return array */ @@ -223,7 +223,7 @@ final public static function toObject(array $collection) * Returns true if the provided function returns true for all elements of * the collection, false otherwise. * - * @param array $collection + * @param array $collection * @param callable $method * * @return bool @@ -236,7 +236,7 @@ final public static function validateAll(array $collection, $method): bool * Returns true if the provided function returns true for at least one * element fo the collection, false otherwise. * - * @param array $collection + * @param array $collection * @param callable $method * * @return bool @@ -248,7 +248,7 @@ final public static function validateAny(array $collection, $method): bool /** * Helper method to filter the collection * - * @param array $collection + * @param array $collection * @param callable $method * * @return array @@ -269,5 +269,4 @@ final private static function filterCollection(array $collection, $method = null final public static function whiteList(array $collection, array $whiteList): array { } - } diff --git a/src/Phalcon/helper/Fs.php b/src/Phalcon/helper/Fs.php index 16ae71f3..04e5c383 100644 --- a/src/Phalcon/helper/Fs.php +++ b/src/Phalcon/helper/Fs.php @@ -21,5 +21,4 @@ class Fs final public static function basename(string $uri, $suffix = null): string { } - } diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/helper/Number.php index d2696d15..63d21e47 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/helper/Number.php @@ -21,5 +21,4 @@ class Number final public static function between(int $value, int $from, int $to): bool { } - } diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/helper/Str.php index 0e9a456d..60e6890a 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/helper/Str.php @@ -38,7 +38,7 @@ class Str * ``` * * @param string $text - * @param mixed $delimiter + * @param mixed $delimiter * * @return string */ @@ -67,9 +67,9 @@ final public static function camelize(string $text, $delimiter = null): string * @param string $b * @param string ...N * - * @return string * @param string ...N * + * @return string */ final public static function concat(): string { @@ -81,8 +81,8 @@ final public static function concat(): string * * @param string $string * - * @return int * @param string $text + * @return int */ final public static function countVowels(string $text): int { @@ -94,11 +94,11 @@ final public static function countVowels(string $text): int * string intact, or set it to true to convert to uppercase. * * @param string $string - * @param bool $upperRest + * @param bool $upperRest * @param string $encoding * - * @return string * @param string $text + * @return string */ final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string { @@ -187,7 +187,7 @@ final public static function dynamic(string $text, string $leftDelimiter = '{', * * @param string $text * @param string $end - * @param bool $ignoreCase + * @param bool $ignoreCase * * @return bool */ @@ -374,7 +374,7 @@ final public static function reduceSlashes(string $text): string * * @param string $text * @param string $start - * @param bool $ignoreCase + * @param bool $ignoreCase * * @return bool */ @@ -393,7 +393,7 @@ final public static function startsWith(string $text, string $start, bool $ignor * ``` * * @param string $text - * @param mixed $delimiter + * @param mixed $delimiter * * @return string */ @@ -435,5 +435,4 @@ final public static function underscore(string $text): string final public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/html/Attributes.php index 48665f8b..b15686e8 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/html/Attributes.php @@ -27,5 +27,4 @@ public function render(): string public function __toString(): string { } - } diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/html/Breadcrumbs.php index 86463993..be4e59a9 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/html/Breadcrumbs.php @@ -118,5 +118,4 @@ public function render(): string public function toArray(): array { } - } diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/html/TagFactory.php index eb7953c5..161d4ecf 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/html/TagFactory.php @@ -41,5 +41,4 @@ public function newInstance(string $name) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/html/attributes/AttributesInterface.php b/src/Phalcon/html/attributes/AttributesInterface.php index cc82778f..10d1db1d 100644 --- a/src/Phalcon/html/attributes/AttributesInterface.php +++ b/src/Phalcon/html/attributes/AttributesInterface.php @@ -26,5 +26,4 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; - } diff --git a/src/Phalcon/html/attributes/RenderInterface.php b/src/Phalcon/html/attributes/RenderInterface.php index 4d1574b3..1b94eb49 100644 --- a/src/Phalcon/html/attributes/RenderInterface.php +++ b/src/Phalcon/html/attributes/RenderInterface.php @@ -16,5 +16,4 @@ interface RenderInterface * @return string */ public function render(): string; - } diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/html/helper/AbstractHelper.php index 24ddf7e6..3e4d856f 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/html/helper/AbstractHelper.php @@ -81,5 +81,4 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/html/helper/Anchor.php index 1d90510a..70ad18aa 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/html/helper/Anchor.php @@ -19,5 +19,4 @@ class Anchor extends AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/html/helper/AnchorRaw.php index c6a1932b..27555b04 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/html/helper/AnchorRaw.php @@ -19,5 +19,4 @@ class AnchorRaw extends AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Body.php b/src/Phalcon/html/helper/Body.php index de69a86e..9dc0319b 100644 --- a/src/Phalcon/html/helper/Body.php +++ b/src/Phalcon/html/helper/Body.php @@ -17,5 +17,4 @@ class Body extends AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/html/helper/Button.php index 22406cde..56b8eca9 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/html/helper/Button.php @@ -18,5 +18,4 @@ class Button extends AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Close.php b/src/Phalcon/html/helper/Close.php index ab43610c..5e4d0e78 100644 --- a/src/Phalcon/html/helper/Close.php +++ b/src/Phalcon/html/helper/Close.php @@ -18,5 +18,4 @@ class Close extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag): string { } - } diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/html/helper/Element.php index 76046df0..92d66641 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/html/helper/Element.php @@ -19,5 +19,4 @@ class Element extends AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/ElementRaw.php b/src/Phalcon/html/helper/ElementRaw.php index 2f2c4660..7ca8a390 100644 --- a/src/Phalcon/html/helper/ElementRaw.php +++ b/src/Phalcon/html/helper/ElementRaw.php @@ -13,9 +13,9 @@ class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper { /** - * @param string $tag The tag for the anchor - * @param string $text The text for the anchor - * @param array $attributes Any additional attributes + * @param string $tag The tag for the anchor + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes * * @return string * @throws Exception @@ -23,5 +23,4 @@ class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/html/helper/Form.php index 54a991f1..341db284 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/html/helper/Form.php @@ -17,5 +17,4 @@ class Form extends AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Img.php b/src/Phalcon/html/helper/Img.php index 21521374..1fa5ed79 100644 --- a/src/Phalcon/html/helper/Img.php +++ b/src/Phalcon/html/helper/Img.php @@ -14,7 +14,7 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper /** * @param string $src - * @param array $attributes Any additional attributes + * @param array $attributes Any additional attributes * * @return string * @throws Exception @@ -22,5 +22,4 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $src, array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/Label.php b/src/Phalcon/html/helper/Label.php index d58997ac..c6b67169 100644 --- a/src/Phalcon/html/helper/Label.php +++ b/src/Phalcon/html/helper/Label.php @@ -21,5 +21,4 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/html/helper/TextArea.php index 8acf5742..ba570df0 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/html/helper/TextArea.php @@ -18,5 +18,4 @@ class TextArea extends AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/http/Cookie.php index d739fe0c..bf5ffb55 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/http/Cookie.php @@ -238,10 +238,10 @@ public function setSecure(bool $secure): CookieInterface * * Use NULL to disable cookie signing. * - * @see \Phalcon\Security\Random - * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey * @return CookieInterface + * @throws \Phalcon\Http\Cookie\Exception + * @see \Phalcon\Security\Random */ public function setSignKey(string $signKey = null): CookieInterface { @@ -270,11 +270,10 @@ public function useEncryption(bool $useEncryption): CookieInterface /** * Assert the cookie's key is enough long. * - * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey + * @throws \Phalcon\Http\Cookie\Exception */ protected function assertSignKeyIsLongEnough(string $signKey) { } - } diff --git a/src/Phalcon/http/CookieInterface.php b/src/Phalcon/http/CookieInterface.php index afbf0c44..8d2386f2 100644 --- a/src/Phalcon/http/CookieInterface.php +++ b/src/Phalcon/http/CookieInterface.php @@ -135,5 +135,4 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; - } diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/http/Request.php index e32b6c38..a8f767ee 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/http/Request.php @@ -848,5 +848,4 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } - } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/http/RequestInterface.php index 38b703ea..d15b3a93 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/http/RequestInterface.php @@ -495,5 +495,4 @@ public function isSoap(): bool; * @return bool */ public function isTrace(): bool; - } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/http/Response.php index 12dfc8ef..a25698f6 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/http/Response.php @@ -474,5 +474,4 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } - } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/http/ResponseInterface.php index 3506a696..8d6ba4e4 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/http/ResponseInterface.php @@ -184,5 +184,4 @@ public function sendCookies(): ResponseInterface; * @return bool|ResponseInterface */ public function sendHeaders(); - } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/http/message/AbstractCommon.php index 9d853ab1..61a4e2a7 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/http/message/AbstractCommon.php @@ -11,7 +11,7 @@ abstract class AbstractCommon /** * Returns a new instance having set the parameter * - * @param mixed $element + * @param mixed $element * @param string $property * * @return mixed @@ -33,7 +33,7 @@ final protected function checkStringParameter($element) * Checks the element passed; assigns it to the property and returns a * clone of the object back * - * @param mixed $element + * @param mixed $element * @param string $property * * @return mixed @@ -41,5 +41,4 @@ final protected function checkStringParameter($element) final protected function processWith($element, string $property) { } - } diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/http/message/AbstractMessage.php index b87d0870..861c686d 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/http/message/AbstractMessage.php @@ -169,13 +169,13 @@ public function hasHeader($name): bool * immutability of the message, and MUST return an instance that has the * new header and/or value. * - * @param string $name + * @param string $name * @param string|string[] $value * - * @return self * @param mixed $value * @param string|string [] $value * + * @return self */ public function withAddedHeader($name, $value) { @@ -211,15 +211,15 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) * immutability of the message, and MUST return an instance that has the * new and/or updated header and value. * - * @param string $name + * @param string $name * @param string|string[] $value * - * @return self - * @throws InvalidArgumentException for invalid header names or values. - * * @param mixed $value * @param string|string [] $value * + * @return self + * @throws InvalidArgumentException for invalid header names or values. + * */ public function withHeader($name, $value) { @@ -369,7 +369,7 @@ final protected function populateHeaderCollection(array $headers): Collection * Set a valid stream * * @param StreamInterface|resource|string $body - * @param string $mode + * @param string $mode * * @return StreamInterface */ @@ -397,5 +397,4 @@ final protected function processHeaders($headers): Collection final protected function processProtocol($protocol = ''): string { } - } diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/http/message/AbstractRequest.php index b90e6d15..cf69d995 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/http/message/AbstractRequest.php @@ -146,7 +146,7 @@ public function withRequestTarget($requestTarget) * @see http://tools.ietf.org/html/rfc3986#section-4.3 * * @param UriInterface $uri - * @param bool $preserveHost + * @param bool $preserveHost * * @return object */ @@ -175,5 +175,4 @@ final protected function processMethod($method = ''): string final protected function processUri($uri): UriInterface { } - } diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/http/message/Request.php index 289aabd5..7033576c 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/http/message/Request.php @@ -15,13 +15,12 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request /** * Request constructor. * - * @param string $method - * @param UriInterface|string|null $uri + * @param string $method + * @param UriInterface|string|null $uri * @param StreamInterface|resource|string $body - * @param array $headers + * @param array $headers */ public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } - } diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/http/message/RequestFactory.php index 34305845..f5f626f2 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/http/message/RequestFactory.php @@ -15,7 +15,7 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface /** * Create a new request. * - * @param string $method + * @param string $method * @param UriInterface|string|null $uri * * @return RequestInterface @@ -23,5 +23,4 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface public function createRequest(string $method, $uri): RequestInterface { } - } diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/http/message/Response.php index 808c760f..c82cf0f7 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/http/message/Response.php @@ -69,8 +69,8 @@ public function getStatusCode(): int * Response constructor. * * @param string $body - * @param int $code - * @param array $headers + * @param int $code + * @param array $headers */ public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) { @@ -91,7 +91,7 @@ public function __construct($body = 'php://memory', int $code = 200, array $head * @see http://tools.ietf.org/html/rfc7231#section-6 * @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * - * @param int $code + * @param int $code * @param string $reasonPhrase * * @return Response @@ -136,5 +136,4 @@ private function getPhrases(): array private function processCode($code, $phrase = '') { } - } diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/http/message/ResponseFactory.php index 4707ee3e..91b3541a 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/http/message/ResponseFactory.php @@ -14,7 +14,7 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac /** * Create a new response. * - * @param int $code The HTTP status code. Defaults to 200. + * @param int $code The HTTP status code. Defaults to 200. * @param string $reasonPhrase The reason phrase to associate with the status * code in the generated response. If none is * provided, implementations MAY use the defaults @@ -25,5 +25,4 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } - } diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/http/message/ServerRequest.php index 55e7970e..5f62b6e8 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/http/message/ServerRequest.php @@ -165,16 +165,16 @@ public function getUploadedFiles(): array /** * ServerRequest constructor. * - * @param string $method + * @param string $method * @param UriInterface|string|null $uri - * @param array $serverParams - * @param StreamInterface|string $body - * @param array $headers - * @param array $cookies - * @param array $queryParams - * @param array $uploadFiles - * @param null|array|object $parsedBody - * @param string $protocol + * @param array $serverParams + * @param StreamInterface|string $body + * @param array $headers + * @param array $cookies + * @param array $queryParams + * @param array $uploadFiles + * @param null|array|object $parsedBody + * @param string $protocol */ public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') { @@ -190,8 +190,8 @@ public function __construct(string $method = 'GET', $uri = null, array $serverPa * This method obviates the need for a hasAttribute() method, as it allows * specifying a default value to return if the attribute is not found. * - * @param string $name - * @param mixed|null $defaultValue + * @param string $name + * @param mixed|null $defaultValue * * @return mixed */ @@ -225,7 +225,7 @@ public function getAttributes(): array * updated attribute. * * @param string $name - * @param mixed $value + * @param mixed $value * * @return ServerRequest */ @@ -356,5 +356,4 @@ public function withoutAttribute($name): ServerRequest private function checkUploadedFiles(array $files) { } - } diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/http/message/ServerRequestFactory.php index 67f6f51f..5bc42c35 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/http/message/ServerRequestFactory.php @@ -23,14 +23,14 @@ class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInte * no attempt is made to determine the HTTP method or URI, which must be * provided explicitly. * - * @param string $method The HTTP method associated with + * @param string $method The HTTP method associated with * the request. - * @param UriInterface|string $uri The URI associated with the + * @param UriInterface|string $uri The URI associated with the * request. If the value is a * string, the factory MUST create * a UriInterface instance based * on it. - * @param array $serverParams Array of SAPI parameters with + * @param array $serverParams Array of SAPI parameters with * which to seed the generated * request instance. * @@ -46,11 +46,11 @@ public function createServerRequest(string $method, $uri, array $serverParams = * If any argument is not supplied, the corresponding superglobal value will * be used. * - * @param array $server $_SERVER superglobal - * @param array $get $_GET superglobal - * @param array $post $_POST superglobal + * @param array $server $_SERVER superglobal + * @param array $get $_GET superglobal + * @param array $post $_POST superglobal * @param array $cookies $_COOKIE superglobal - * @param array $files $_FILES superglobal + * @param array $files $_FILES superglobal * * @return ServerRequest * @see fromServer() @@ -155,7 +155,7 @@ private function createUploadedFile(array $file): UploadedFile * Returns a header * * @param Collection $headers - * @param string $name + * @param string $name * @param mixed|null $defaultValue * * @return mixed|string @@ -234,5 +234,4 @@ private function parseUploadedFiles(array $files): Collection private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri { } - } diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/http/message/Stream.php index 67736b60..2a44a4f0 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/http/message/Stream.php @@ -23,7 +23,7 @@ class Stream implements \Psr\Http\Message\StreamInterface /** * Stream constructor. * - * @param mixed $stream + * @param mixed $stream * @param string $mode */ public function __construct($stream, string $mode = 'rb') @@ -175,7 +175,7 @@ public function seek($offset, $whence = 0) /** * Sets the stream - existing instance * - * @param mixed $stream + * @param mixed $stream * @param string $mode */ public function setStream($stream, string $mode = 'rb') @@ -229,5 +229,4 @@ private function checkSeekable() private function checkWritable() { } - } diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/http/message/StreamFactory.php index 60c8cc2a..ee5921f9 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/http/message/StreamFactory.php @@ -34,7 +34,7 @@ public function createStream(string $content = ''): StreamInterface * * @param string $filename The filename or stream URI to use as basis of * stream. - * @param string $mode The mode with which to open the underlying + * @param string $mode The mode with which to open the underlying * filename/stream. * * @return StreamInterface @@ -54,5 +54,4 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St public function createStreamFromResource($phpResource): StreamInterface { } - } diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/http/message/UploadedFile.php index b55dd5dc..fa61d185 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/http/message/UploadedFile.php @@ -156,10 +156,10 @@ public function getSize(): ?int * UploadedFile constructor. * * @param StreamInterface|string|null $stream - * @param int|null $size - * @param int $error - * @param string|null $clientFilename - * @param string|null $clientMediaType + * @param int|null $size + * @param int $error + * @param string|null $clientFilename + * @param string|null $clientMediaType */ public function __construct($stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null) { @@ -235,7 +235,7 @@ private function checkError(int $error) * Checks the passed error code and if not in the range throws an exception * * @param StreamInterface|resource|string $stream - * @param int $error + * @param int $error */ private function checkStream($stream, int $error) { @@ -260,5 +260,4 @@ private function getErrorDescription(int $error): string private function storeFile(string $targetPath) { } - } diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/http/message/UploadedFileFactory.php index ab9752fe..fe2c233e 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/http/message/UploadedFileFactory.php @@ -21,12 +21,12 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory * @link http://php.net/manual/features.file-upload.post-method.php * @link http://php.net/manual/features.file-upload.errors.php * - * @param StreamInterface $stream The underlying stream representing the + * @param StreamInterface $stream The underlying stream representing the * uploaded file content. - * @param int $size The size of the file in bytes. - * @param int $error The PHP file upload error. - * @param string $clientFilename The filename as provided by the client, if any. - * @param string $clientMediaType The media type as provided by the client, if any. + * @param int $size The size of the file in bytes. + * @param int $error The PHP file upload error. + * @param string $clientFilename The filename as provided by the client, if any. + * @param string $clientMediaType The media type as provided by the client, if any. * * @throws \InvalidArgumentException If the file resource is not readable. * @return \Psr\Http\Message\UploadedFileInterface @@ -34,5 +34,4 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } - } diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/http/message/Uri.php index 2383c16e..ab67acd2 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/http/message/Uri.php @@ -317,7 +317,7 @@ public function withScheme($scheme): Uri /** * Return an instance with the specified user information. * - * @param string $user + * @param string $user * @param string|null $password * * @return Uri @@ -465,5 +465,4 @@ private function filterScheme(string $scheme): string private function splitQueryValue(string $element): array { } - } diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/http/message/UriFactory.php index d42587c7..e3ba04cf 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/http/message/UriFactory.php @@ -21,5 +21,4 @@ final class UriFactory implements \Psr\Http\Message\UriFactoryInterface public function createUri(string $uri = ''): UriInterface { } - } diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/http/message/stream/Input.php index 209f8511..88c39025 100644 --- a/src/Phalcon/http/message/stream/Input.php +++ b/src/Phalcon/http/message/stream/Input.php @@ -52,12 +52,12 @@ public function __toString(): string /** * Returns the remaining contents in a string * - * @throws RuntimeException if unable to read. - * @throws RuntimeException if error occurs while reading. - * * @param int $length * * @return string + * @throws RuntimeException if unable to read. + * @throws RuntimeException if error occurs while reading. + * */ public function getContents(int $length = -1): string { @@ -82,5 +82,4 @@ public function isWritable(): bool public function read($length): string { } - } diff --git a/src/Phalcon/http/message/stream/Memory.php b/src/Phalcon/http/message/stream/Memory.php index 42e6f127..f325bf53 100644 --- a/src/Phalcon/http/message/stream/Memory.php +++ b/src/Phalcon/http/message/stream/Memory.php @@ -22,5 +22,4 @@ class Memory extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/http/message/stream/Temp.php b/src/Phalcon/http/message/stream/Temp.php index 49c23084..8f9b6650 100644 --- a/src/Phalcon/http/message/stream/Temp.php +++ b/src/Phalcon/http/message/stream/Temp.php @@ -22,5 +22,4 @@ class Temp extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/http/request/File.php index 7e042032..e3fc6ff0 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/http/request/File.php @@ -153,5 +153,4 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } - } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/http/request/FileInterface.php index 69f37a10..8353aca4 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/http/request/FileInterface.php @@ -53,5 +53,4 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; - } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index efc67a51..a08fb7e8 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -191,9 +191,9 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * * Use NULL to disable cookie signing. * - * @see \Phalcon\Security\Random * @param string $signKey * @return \Phalcon\Http\CookieInterface + * @see \Phalcon\Security\Random */ public function setSignKey(string $signKey = null): CookieInterface { @@ -208,5 +208,4 @@ public function setSignKey(string $signKey = null): CookieInterface public function useEncryption(bool $useEncryption): CookiesInterface { } - } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/http/response/CookiesInterface.php index ea1910f3..63093998 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/http/response/CookiesInterface.php @@ -79,5 +79,4 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; - } diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/http/response/Headers.php index abb21da9..47b88b13 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/http/response/Headers.php @@ -88,5 +88,4 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } - } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/http/response/HeadersInterface.php index a2b439a8..0e178f64 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/http/response/HeadersInterface.php @@ -52,5 +52,4 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); - } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/http/server/AbstractMiddleware.php index d031fdc2..1dd1de4b 100644 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ b/src/Phalcon/http/server/AbstractMiddleware.php @@ -29,5 +29,4 @@ abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterfac * @return \Psr\Http\Message\ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; - } diff --git a/src/Phalcon/http/server/AbstractRequestHandler.php b/src/Phalcon/http/server/AbstractRequestHandler.php index 7e4b2131..9d08bce7 100644 --- a/src/Phalcon/http/server/AbstractRequestHandler.php +++ b/src/Phalcon/http/server/AbstractRequestHandler.php @@ -24,5 +24,4 @@ abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandler * @return \Psr\Http\Message\ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; - } diff --git a/src/Phalcon/image/Enum.php b/src/Phalcon/image/Enum.php index fcd64fb1..2a1a2ca5 100644 --- a/src/Phalcon/image/Enum.php +++ b/src/Phalcon/image/Enum.php @@ -38,6 +38,4 @@ class Enum const VERTICAL = 12; - - } diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/image/ImageFactory.php index a3b9df97..a1c1fb96 100644 --- a/src/Phalcon/image/ImageFactory.php +++ b/src/Phalcon/image/ImageFactory.php @@ -49,5 +49,4 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } - } diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/image/adapter/AbstractAdapter.php index 5ce3311a..253757e4 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/image/adapter/AbstractAdapter.php @@ -12,7 +12,7 @@ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { - static protected $checked = false; + protected static $checked = false; protected $file; @@ -150,8 +150,8 @@ public function flip(int $direction): AdapterInterface * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. * @return AbstractAdapter @@ -274,5 +274,4 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } - } diff --git a/src/Phalcon/image/adapter/AdapterInterface.php b/src/Phalcon/image/adapter/AdapterInterface.php index a938d689..d6c1dd93 100644 --- a/src/Phalcon/image/adapter/AdapterInterface.php +++ b/src/Phalcon/image/adapter/AdapterInterface.php @@ -117,5 +117,4 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; - } diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/image/adapter/Gd.php index a82dd39c..01ed1339 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/image/adapter/Gd.php @@ -13,7 +13,7 @@ class Gd extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; /** @@ -171,5 +171,4 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/image/adapter/Imagick.php index 27e65bda..41cf51c9 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/image/adapter/Imagick.php @@ -21,10 +21,10 @@ class Imagick extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; - static protected $version = 0; + protected static $version = 0; /** @@ -120,8 +120,8 @@ protected function processFlip(int $direction) * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ @@ -235,5 +235,4 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/logger/AdapterFactory.php b/src/Phalcon/logger/AdapterFactory.php index 4027925b..690af95f 100644 --- a/src/Phalcon/logger/AdapterFactory.php +++ b/src/Phalcon/logger/AdapterFactory.php @@ -43,5 +43,4 @@ public function newInstance(string $name, string $fileName, array $options = arr protected function getAdapters(): array { } - } diff --git a/src/Phalcon/logger/Item.php b/src/Phalcon/logger/Item.php index 33d11398..0b66a8ff 100644 --- a/src/Phalcon/logger/Item.php +++ b/src/Phalcon/logger/Item.php @@ -41,7 +41,6 @@ class Item protected $type; - public function getContext() { } @@ -94,5 +93,4 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } - } diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/logger/LoggerFactory.php index 47b541c8..99c61357 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/logger/LoggerFactory.php @@ -38,12 +38,11 @@ public function load($config) * Returns a Logger object * * @param string $name - * @param array $adapters + * @param array $adapters * * @return Logger */ public function newInstance(string $name, array $adapters = array()): Logger { } - } diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/logger/adapter/AbstractAdapter.php index d9409e48..3fe967ae 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/logger/adapter/AbstractAdapter.php @@ -119,5 +119,4 @@ public function rollback(): AdapterInterface public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } - } diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/logger/adapter/AdapterInterface.php index ad3c9c30..b93635a8 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/logger/adapter/AdapterInterface.php @@ -69,5 +69,4 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; - } diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/logger/adapter/Noop.php index deb3c209..bf2b4978 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/logger/adapter/Noop.php @@ -36,5 +36,4 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } - } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/logger/adapter/Stream.php index 948c2c85..c61052d7 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/logger/adapter/Stream.php @@ -84,5 +84,4 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } - } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/logger/adapter/Syslog.php index eafc5bb7..382cf89e 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/logger/adapter/Syslog.php @@ -92,5 +92,4 @@ public function process(\Phalcon\Logger\Item $item) private function logLevelToSyslog(string $level): int { } - } diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/logger/formatter/AbstractFormatter.php index e302fe8b..5b00a527 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/logger/formatter/AbstractFormatter.php @@ -23,5 +23,4 @@ abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterI public function interpolate(string $message, $context = null) { } - } diff --git a/src/Phalcon/logger/formatter/FormatterInterface.php b/src/Phalcon/logger/formatter/FormatterInterface.php index 0aaf8bd2..bf4239f3 100644 --- a/src/Phalcon/logger/formatter/FormatterInterface.php +++ b/src/Phalcon/logger/formatter/FormatterInterface.php @@ -17,5 +17,4 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); - } diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/logger/formatter/Json.php index 51ac45ae..18029e00 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/logger/formatter/Json.php @@ -53,5 +53,4 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') public function format(\Phalcon\Logger\Item $item): string { } - } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/logger/formatter/Line.php index d2eeaea4..9f516272 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/logger/formatter/Line.php @@ -81,5 +81,4 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin public function format(\Phalcon\Logger\Item $item): string { } - } diff --git a/src/Phalcon/logger/formatter/Syslog.php b/src/Phalcon/logger/formatter/Syslog.php index 71f34d2a..377c89eb 100644 --- a/src/Phalcon/logger/formatter/Syslog.php +++ b/src/Phalcon/logger/formatter/Syslog.php @@ -19,5 +19,4 @@ class Syslog extends AbstractFormatter public function format(\Phalcon\Logger\Item $item): array { } - } diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/messages/Message.php index df13faea..7f1ac8b6 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/messages/Message.php @@ -150,5 +150,4 @@ public function setMetaData(array $metaData): MessageInterface public function setType(string $type): MessageInterface { } - } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/messages/MessageInterface.php index 550abcfa..4eb1cdba 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/messages/MessageInterface.php @@ -91,5 +91,4 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; - } diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/messages/Messages.php index 014efcae..230bc5af 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/messages/Messages.php @@ -190,5 +190,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/mvc/Application.php index 992b3cf1..a0bb0045 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/mvc/Application.php @@ -102,5 +102,4 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } - } diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/mvc/Controller.php index fa83767b..bf38986f 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/mvc/Controller.php @@ -53,5 +53,4 @@ abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerI final public function __construct() { } - } diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/mvc/Dispatcher.php index fb4b14e8..3d851dec 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/mvc/Dispatcher.php @@ -206,5 +206,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/mvc/DispatcherInterface.php index 3019e142..61c4366e 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/mvc/DispatcherInterface.php @@ -51,5 +51,4 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); - } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/mvc/EntityInterface.php index c8eecd35..1d14a5df 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/mvc/EntityInterface.php @@ -25,5 +25,4 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); - } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/mvc/Micro.php index b03bbd2a..fe66be93 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/mvc/Micro.php @@ -234,8 +234,8 @@ public function getRouter(): RouterInterface /** * Obtains a service from the DI * - * @return object * @param string $serviceName + * @return object */ public function getService(string $serviceName) { @@ -244,8 +244,8 @@ public function getService(string $serviceName) /** * Obtains a shared service from the DI * - * @return mixed * @param string $serviceName + * @return mixed */ public function getSharedService(string $serviceName) { @@ -479,5 +479,4 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } - } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index d830dfc8..130ed03a 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -117,7 +117,6 @@ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\Enti protected $uniqueTypes; - public function getTransaction() { } @@ -136,10 +135,10 @@ final public function __construct($data = null, \Phalcon\Di\DiInterface $contain /** * Handles method calls when a method is not implemented * - * @return mixed - * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments + * @return mixed + * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist */ public function __call(string $method, array $arguments) { @@ -148,10 +147,10 @@ public function __call(string $method, array $arguments) /** * Handles method calls when a static method is not implemented * - * @return mixed - * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments + * @return mixed + * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist */ public static function __callStatic(string $method, array $arguments) { @@ -161,8 +160,8 @@ public static function __callStatic(string $method, array $arguments) * Magic method to get related records using the relation alias as a * property * - * @return mixed * @param string $property + * @return mixed */ public function __get(string $property) { @@ -385,9 +384,9 @@ public static function cloneResultMap($base, array $data, $columnMap, int $dirty * Returns an hydrated result based on the data and the column map * * @param array $columnMap - * @return mixed * @param array $data * @param int $hydrationMode + * @return mixed */ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) { @@ -877,8 +876,8 @@ final public function getReadConnectionService(): string * Returns related records based on defined relations * * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ public function getRelated(string $alias, $arguments = null) { @@ -1496,11 +1495,11 @@ protected static function _groupResult(string $functionName, string $alias, $par /** * Try to check if the query must invoke a finder * - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool * @param string $method * @param array $arguments + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool */ - protected final static function _invokeFinder(string $method, array $arguments) + final protected static function _invokeFinder(string $method, array $arguments) { } @@ -1554,7 +1553,7 @@ protected function _postSave(bool $success, bool $exists): bool /** * Save the related records assigned in the has-one/has-many relations * - * @param Phalcon\Mvc\ModelInterface[] related + * @param Phalcon\Mvc\ModelInterface[] related * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @param mixed $related * @param Phalcon\Mvc\ModelInterface [] related @@ -1941,5 +1940,4 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } - } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/mvc/ModelInterface.php index 36d21548..91ccf067 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/mvc/ModelInterface.php @@ -58,10 +58,10 @@ public static function cloneResult(ModelInterface $base, array $data, int $dirty * * @param \Phalcon\Mvc\Model $base * @param array $columnMap - * @return \Phalcon\Mvc\Model result * @param array $data * @param int $dirtyState * @param bool $keepSnapshots + * @return \Phalcon\Mvc\Model result */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; @@ -181,8 +181,8 @@ public function getReadConnectionService(): string; * Returns related records based on defined relations * * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false */ public function getRelated(string $alias, $arguments = null); @@ -332,5 +332,4 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; - } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/mvc/ModuleDefinitionInterface.php index fe59a300..04605ce1 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/mvc/ModuleDefinitionInterface.php @@ -23,5 +23,4 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); - } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/mvc/Router.php index af0f47dd..6054ff5c 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/mvc/Router.php @@ -103,7 +103,6 @@ class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterf protected $wasMatched = false; - public function getKeyRouteNames() { } @@ -565,5 +564,4 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } - } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/mvc/RouterInterface.php index 3cae5db4..7ab02262 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/mvc/RouterInterface.php @@ -250,5 +250,4 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/mvc/View.php index 740183b5..ea069d7d 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/mvc/View.php @@ -133,7 +133,6 @@ class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Ev protected $viewParams = array(); - public function getCurrentRenderLevel() { } @@ -813,5 +812,4 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } - } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/mvc/ViewBaseInterface.php index a88fca68..0495848b 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/mvc/ViewBaseInterface.php @@ -69,5 +69,4 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); - } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/mvc/ViewInterface.php index c27c5ca3..94305bb5 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/mvc/ViewInterface.php @@ -195,5 +195,4 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); - } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/mvc/controller/BindModelInterface.php index 84e98de1..7df463ff 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/mvc/controller/BindModelInterface.php @@ -16,5 +16,4 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; - } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/mvc/micro/Collection.php index 08aa0968..ff9801d6 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/mvc/micro/Collection.php @@ -233,5 +233,4 @@ public function setPrefix(string $prefix): CollectionInterface protected function addMap($method, string $routePattern, $handler, string $name) { } - } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/mvc/micro/CollectionInterface.php index 8254ccc9..878f6c72 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/mvc/micro/CollectionInterface.php @@ -142,5 +142,4 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; - } diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/mvc/micro/LazyLoader.php index 30ea8868..ab704b4f 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/mvc/micro/LazyLoader.php @@ -16,7 +16,6 @@ class LazyLoader protected $definition; - public function getDefinition() { } @@ -34,12 +33,11 @@ public function __construct(string $definition) * Calling __call method * * @param array $arguments - * @return mixed * @param string $method * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder + * @return mixed */ public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) { } - } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/mvc/micro/MiddlewareInterface.php index daa73549..e3fe446c 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/mvc/micro/MiddlewareInterface.php @@ -14,5 +14,4 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); - } diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/mvc/model/Behavior.php index 8540cc60..a22c6289 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/mvc/model/Behavior.php @@ -27,8 +27,8 @@ public function __construct(array $options = array()) /** * Returns the behavior options related to an event * - * @return array * @param string $eventName + * @return array */ protected function getOptions(string $eventName = null) { @@ -64,5 +64,4 @@ protected function mustTakeAction(string $eventName): bool public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } - } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/mvc/model/BehaviorInterface.php index 77ed3cc6..a6a61047 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/mvc/model/BehaviorInterface.php @@ -26,5 +26,4 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); - } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/mvc/model/Binder.php index 5028f77c..243ee36a 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/mvc/model/Binder.php @@ -124,5 +124,4 @@ protected function getParamsFromReflection($handler, array $params, string $cach public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface { } - } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/mvc/model/BinderInterface.php index a0321410..8ce5d24a 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/mvc/model/BinderInterface.php @@ -44,5 +44,4 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; - } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/mvc/model/Criteria.php index 757aee59..0eebabeb 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/mvc/model/Criteria.php @@ -528,5 +528,4 @@ public function createBuilder(): BuilderInterface public function execute(): ResultsetInterface { } - } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/mvc/model/CriteriaInterface.php index 80a6f15d..09adbbdb 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/mvc/model/CriteriaInterface.php @@ -322,5 +322,4 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; - } diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/mvc/model/Manager.php index d98d4157..99d4af9e 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/mvc/model/Manager.php @@ -625,11 +625,11 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param \Phalcon\Mvc\Model\RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -829,5 +829,4 @@ public function getLastQuery(): QueryInterface public function __destruct() { } - } diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/mvc/model/ManagerInterface.php index f9138275..04b666e8 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/mvc/model/ManagerInterface.php @@ -145,11 +145,11 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets belongsTo related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|ResultsetInterface */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -165,11 +165,11 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets hasMany related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|ResultsetInterface */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -201,11 +201,11 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets belongsTo related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method + * @param ModelInterface $record + * @param string|null $method * @return bool|\Phalcon\Mvc\ModelInterface */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -268,11 +268,11 @@ public function getRelationByAlias(string $modelName, string $alias); /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param \Phalcon\Mvc\Model\RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -378,9 +378,9 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * meaning that a least one is implemented * * @param array $data - * @return bool * @param \Phalcon\Mvc\ModelInterface $model * @param string $eventName + * @return bool */ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); @@ -440,5 +440,4 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @param bool $dynamicUpdate */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); - } diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/mvc/model/MetaData.php index 4822a1ec..60d9f426 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/mvc/model/MetaData.php @@ -621,5 +621,4 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t private function throwWriteException($option) { } - } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/mvc/model/MetaDataInterface.php index eea0df3e..3818ede4 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/mvc/model/MetaDataInterface.php @@ -240,5 +240,4 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @param array $data */ public function write(string $key, array $data); - } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/mvc/model/Query.php index f0a5b215..bb8ffd26 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/mvc/model/Query.php @@ -138,7 +138,7 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA protected $uniqueRow; - static protected $_irPhqlCache; + protected static $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -276,9 +276,9 @@ final protected function _getSelectColumn(array $column): array /** * Resolves a table in a SELECT statement checking if the model exists * - * @return string * @param \Phalcon\Mvc\Model\ManagerInterface $manager * @param array $qualifiedName + * @return string */ final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) { @@ -504,9 +504,9 @@ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, /** * Executes a parsed PHQL statement * - * @return mixed * @param array $bindParams * @param array $bindTypes + * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()) { @@ -684,5 +684,4 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface { } - } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/mvc/model/QueryInterface.php index 9ac7210c..83e2d6a6 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/mvc/model/QueryInterface.php @@ -23,9 +23,9 @@ public function cache(array $cacheOptions): QueryInterface; /** * Executes a parsed PHQL statement * - * @return mixed * @param array $bindParams * @param array $bindTypes + * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()); @@ -114,5 +114,4 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; - } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/mvc/model/Relation.php index ec914296..655e4598 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/mvc/model/Relation.php @@ -208,5 +208,4 @@ public function isReusable(): bool public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } - } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/mvc/model/RelationInterface.php index c3c45f6a..f8c565d0 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/mvc/model/RelationInterface.php @@ -117,5 +117,4 @@ public function isThrough(): bool; * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); - } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/mvc/model/ResultInterface.php index 9ba8f10b..58bdb6d5 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/mvc/model/ResultInterface.php @@ -17,5 +17,4 @@ interface ResultInterface * @return bool|\Phalcon\Mvc\ModelInterface */ public function setDirtyState(int $dirtyState); - } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/mvc/model/Resultset.php index c9e8c416..b4e6fbc3 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/mvc/model/Resultset.php @@ -335,5 +335,4 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } - } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/mvc/model/ResultsetInterface.php index d9448f08..f95ac27c 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/mvc/model/ResultsetInterface.php @@ -120,5 +120,4 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; - } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/mvc/model/Row.php index 1d768b98..6c8eae16 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/mvc/model/Row.php @@ -66,8 +66,8 @@ public function offsetUnset($offset) * echo $robot->readAttribute("name"); * ``` * - * @return mixed * @param string $attribute + * @return mixed */ public function readAttribute(string $attribute) { @@ -105,5 +105,4 @@ public function toArray(): array public function writeAttribute(string $attribute, $value) { } - } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/mvc/model/Transaction.php index 2b1b124c..4ab0dc7d 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/mvc/model/Transaction.php @@ -194,5 +194,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte public function throwRollbackException(bool $status): TransactionInterface { } - } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/mvc/model/TransactionInterface.php index da437029..2499aebe 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/mvc/model/TransactionInterface.php @@ -96,5 +96,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; - } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/mvc/model/ValidationFailed.php index 2c4348fa..200baf2c 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/mvc/model/ValidationFailed.php @@ -48,5 +48,4 @@ public function getMessages(): array public function getModel(): ModelInterface { } - } diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/mvc/model/behavior/SoftDelete.php index 4a75fb86..53c93099 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/mvc/model/behavior/SoftDelete.php @@ -22,5 +22,4 @@ class SoftDelete extends Behavior public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } - } diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/mvc/model/behavior/Timestampable.php index 14bb9034..e6eb4f72 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/mvc/model/behavior/Timestampable.php @@ -29,5 +29,4 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } - } diff --git a/src/Phalcon/mvc/model/binder/BindableInterface.php b/src/Phalcon/mvc/model/binder/BindableInterface.php index 48208879..d0b643e6 100644 --- a/src/Phalcon/mvc/model/binder/BindableInterface.php +++ b/src/Phalcon/mvc/model/binder/BindableInterface.php @@ -17,5 +17,4 @@ interface BindableInterface * @return string|array */ public function getModelName(); - } diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/mvc/model/metadata/Apcu.php index afadb39b..612da494 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/mvc/model/metadata/Apcu.php @@ -34,5 +34,4 @@ class Apcu extends MetaData public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) { } - } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/mvc/model/metadata/Libmemcached.php index 9117318d..fcd40dc2 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/mvc/model/metadata/Libmemcached.php @@ -30,5 +30,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/mvc/model/metadata/Memory.php index b6f86087..456302dd 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/mvc/model/metadata/Memory.php @@ -40,5 +40,4 @@ public function read(string $key): ?array public function write(string $key, array $data) { } - } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/mvc/model/metadata/Redis.php index a8139c10..0a72aa37 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/mvc/model/metadata/Redis.php @@ -44,5 +44,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/mvc/model/metadata/Stream.php index 0db905df..97092b45 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/mvc/model/metadata/Stream.php @@ -60,5 +60,4 @@ public function write(string $key, array $data) private function throwWriteException($option) { } - } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php index 47b0bd5a..8b941252 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Annotations.php @@ -34,5 +34,4 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } - } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php index a5800990..d1974e36 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/mvc/model/metadata/strategy/Introspection.php @@ -31,5 +31,4 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } - } diff --git a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php index 1be70b21..57a22db3 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php +++ b/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php @@ -16,10 +16,10 @@ interface StrategyInterface /** * Read the model's column map, this can't be inferred * - * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Di\DiInterface $container * @return array + * @todo Not implemented */ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; @@ -31,5 +31,4 @@ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\Di * @return array */ public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; - } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/mvc/model/query/Builder.php index b32077d7..6fec223c 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/mvc/model/query/Builder.php @@ -909,5 +909,4 @@ protected function conditionNotBetween(string $clause, string $operator, string protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } - } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/mvc/model/query/BuilderInterface.php index a7a307bb..1b77025f 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/mvc/model/query/BuilderInterface.php @@ -343,5 +343,4 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; - } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/mvc/model/query/Lang.php index 6e5f1ed7..4f574562 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/mvc/model/query/Lang.php @@ -35,5 +35,4 @@ abstract class Lang public static function parsePHQL(string $phql): array { } - } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/mvc/model/query/Status.php index 60fb2039..027decdf 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/mvc/model/query/Status.php @@ -76,5 +76,4 @@ public function getModel(): ModelInterface public function success(): bool { } - } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/mvc/model/query/StatusInterface.php index fcea5a8b..a333a915 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/mvc/model/query/StatusInterface.php @@ -32,5 +32,4 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; - } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/mvc/model/resultset/Complex.php index 40da46b1..cc90a156 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/mvc/model/resultset/Complex.php @@ -69,5 +69,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/mvc/model/resultset/Simple.php index eafacb10..1cd3e083 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/mvc/model/resultset/Simple.php @@ -78,5 +78,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/mvc/model/transaction/Failed.php index f58e2159..21c32947 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/mvc/model/transaction/Failed.php @@ -42,5 +42,4 @@ public function getRecord(): ModelInterface public function getRecordMessages(): array { } - } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/mvc/model/transaction/Manager.php index 80b26ac7..70953823 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/mvc/model/transaction/Manager.php @@ -229,5 +229,4 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) { } - } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/mvc/model/transaction/ManagerInterface.php index f081fefa..fc07bdbc 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/mvc/model/transaction/ManagerInterface.php @@ -93,5 +93,4 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; - } diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/mvc/router/Annotations.php index 3c939af1..565a5564 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/mvc/router/Annotations.php @@ -125,5 +125,4 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } - } diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/mvc/router/Group.php index 4b8cf75b..b1a49f19 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/mvc/router/Group.php @@ -308,5 +308,4 @@ public function setPrefix(string $prefix): GroupInterface protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } - } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/mvc/router/GroupInterface.php index 33d59115..c504e20c 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/mvc/router/GroupInterface.php @@ -228,5 +228,4 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; - } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/mvc/router/Route.php index b47b0db0..7eb8bf76 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/mvc/router/Route.php @@ -43,8 +43,7 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; - + protected static $uniqueId = 0; public function getId() @@ -364,5 +363,4 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } - } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/mvc/router/RouteInterface.php index 0baf83d1..39e2d5cf 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/mvc/router/RouteInterface.php @@ -127,5 +127,4 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; - } diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/mvc/view/Simple.php index c5d8ab5c..9a93d03b 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/mvc/view/Simple.php @@ -320,5 +320,4 @@ protected function loadTemplateEngines(): array final protected function internalRender(string $path, $params) { } - } diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/mvc/view/engine/AbstractEngine.php index dadd9bab..b67caa74 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/mvc/view/engine/AbstractEngine.php @@ -52,5 +52,4 @@ public function getView(): ViewBaseInterface public function partial(string $partialPath, $params = null) { } - } diff --git a/src/Phalcon/mvc/view/engine/EngineInterface.php b/src/Phalcon/mvc/view/engine/EngineInterface.php index 28526844..7f0d981f 100644 --- a/src/Phalcon/mvc/view/engine/EngineInterface.php +++ b/src/Phalcon/mvc/view/engine/EngineInterface.php @@ -31,5 +31,4 @@ public function partial(string $partialPath, $params = null); * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); - } diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/mvc/view/engine/Php.php index f1eb2e5f..0e6d1a5a 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/mvc/view/engine/Php.php @@ -18,5 +18,4 @@ class Php extends AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } - } diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/mvc/view/engine/Volt.php index f02f178c..d4e83800 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/mvc/view/engine/Volt.php @@ -143,5 +143,4 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } - } diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/mvc/view/engine/volt/Compiler.php index 15bb2038..8c89fc49 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/mvc/view/engine/volt/Compiler.php @@ -232,10 +232,10 @@ public function compileElseIf(array $statement): string * ); * ``` * - * @return string|array * @param string $path * @param string $compiledPath * @param bool $extendsMode + * @return string|array */ public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) { @@ -353,8 +353,8 @@ final public function expression(array $expr): string * Fires an event to registered extensions * * @param array $arguments - * @return mixed * @param string $name + * @return mixed */ final public function fireExtensionEvent(string $name, $arguments = null) { @@ -418,8 +418,8 @@ public function getFunctions(): array /** * Returns a compiler's option * - * @return string * @param string $option + * @return string */ public function getOption(string $option) { @@ -462,8 +462,8 @@ public function getUniquePrefix(): string * ); * ``` * - * @return array * @param string $viewCode + * @return array */ public function parse(string $viewCode) { @@ -569,5 +569,4 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } - } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/mvc/view/engine/volt/Exception.php index efc6bc20..915f73b0 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/mvc/view/engine/volt/Exception.php @@ -31,5 +31,4 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } - } diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/paginator/PaginatorFactory.php index fa63b1a2..598bfcd6 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/paginator/PaginatorFactory.php @@ -72,5 +72,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/paginator/Repository.php index 323eb2c8..14a0eadf 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/paginator/Repository.php @@ -160,5 +160,4 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } - } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/paginator/RepositoryInterface.php index 94b41503..7eeac3db 100644 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ b/src/Phalcon/paginator/RepositoryInterface.php @@ -113,5 +113,4 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; - } diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/paginator/adapter/AbstractAdapter.php index 29eae036..6dfb374e 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/paginator/adapter/AbstractAdapter.php @@ -89,5 +89,4 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository protected function getRepository(array $properties = null): RepositoryInterface { } - } diff --git a/src/Phalcon/paginator/adapter/AdapterInterface.php b/src/Phalcon/paginator/adapter/AdapterInterface.php index 73410d01..b577dc1e 100644 --- a/src/Phalcon/paginator/adapter/AdapterInterface.php +++ b/src/Phalcon/paginator/adapter/AdapterInterface.php @@ -39,5 +39,4 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); - } diff --git a/src/Phalcon/paginator/adapter/Model.php b/src/Phalcon/paginator/adapter/Model.php index d829cdf3..0b51d673 100644 --- a/src/Phalcon/paginator/adapter/Model.php +++ b/src/Phalcon/paginator/adapter/Model.php @@ -35,5 +35,4 @@ class Model extends AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/paginator/adapter/NativeArray.php index 4efd8617..b3e7fe96 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/paginator/adapter/NativeArray.php @@ -38,5 +38,4 @@ class NativeArray extends AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/paginator/adapter/QueryBuilder.php index 7c6a7ac0..9d95c134 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/paginator/adapter/QueryBuilder.php @@ -85,5 +85,4 @@ public function paginate(): RepositoryInterface public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder { } - } diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/security/Random.php index c7c782b3..08449196 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/security/Random.php @@ -86,11 +86,11 @@ class Random * echo $random->base58(); // 4kUgL2pdQMSCQtjE * ``` * - * @see \Phalcon\Security\Random:base64 - * @link https://en.wikipedia.org/wiki/Base58 - * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read + * @link https://en.wikipedia.org/wiki/Base58 + * @see \Phalcon\Security\Random:base64 */ public function base58(int $len = null): string { @@ -112,10 +112,10 @@ public function base58(int $len = null): string * echo $random->base62(); // z0RkwHfh8ErDM1xw * ``` * - * @see \Phalcon\Security\Random:base58 - * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read + * @see \Phalcon\Security\Random:base58 */ public function base62(int $len = null): string { @@ -134,9 +134,9 @@ public function base62(int $len = null): string * echo $random->base64(12); // 3rcq39QzGK9fUqh8 * ``` * - * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read */ public function base64(int $len = null): string { @@ -186,9 +186,9 @@ public function base64Safe(int $len = null, bool $padding = false): string * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" * ``` * - * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read */ public function bytes(int $len = 16): string { @@ -206,9 +206,9 @@ public function bytes(int $len = 16): string * echo $random->hex(10); // a29f470508d5ccb8e289 * ``` * - * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read */ public function hex(int $len = null): string { @@ -225,9 +225,9 @@ public function hex(int $len = null): string * echo $random->number(16); // 8 * ``` * - * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 * @param int $len * @return int + * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 */ public function number(int $len): int { @@ -266,14 +266,13 @@ public function uuid(): string * * If $n is not specified, 16 is assumed. It may be larger in future. * - * @throws Exception If secure random number generator is not available or unexpected partial read * @param string $alphabet * @param int $base * @param mixed $n * @return string + * @throws Exception If secure random number generator is not available or unexpected partial read */ protected function base(string $alphabet, int $base, $n = null): string { } - } diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/session/Bag.php index dde60d01..14ae6175 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/session/Bag.php @@ -92,5 +92,4 @@ public function set(string $element, $value) public function setDI(\Phalcon\Di\DiInterface $container) { } - } diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/session/Manager.php index a844db65..83df12cc 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/session/Manager.php @@ -210,9 +210,9 @@ public function setId(string $id): ManagerInterface * and do not allow poop names * * @param string $name * + * @return Manager * @throws InvalidArgumentException * - * @return Manager */ public function setName(string $name): ManagerInterface { @@ -255,5 +255,4 @@ public function status(): int private function getUniqueKey(string $key): string { } - } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/session/ManagerInterface.php index c654990e..2d0e35b5 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/session/ManagerInterface.php @@ -146,9 +146,9 @@ public function setId(string $id): ManagerInterface; * Set the session name. Throw exception if the session has started * and do not allow poop names * - * @throws InvalidArgumentException * @param string $name * @return ManagerInterface + * @throws InvalidArgumentException */ public function setName(string $name): ManagerInterface; @@ -181,5 +181,4 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; - } diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/session/adapter/AbstractAdapter.php index 9360162f..7b73851e 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/session/adapter/AbstractAdapter.php @@ -80,5 +80,4 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } - } diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/session/adapter/Libmemcached.php index 87c51ebf..7ebded2f 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/session/adapter/Libmemcached.php @@ -17,5 +17,4 @@ class Libmemcached extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/session/adapter/Noop.php index 39f90f92..d324e104 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/session/adapter/Noop.php @@ -126,5 +126,4 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } - } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/session/adapter/Redis.php index 15dbcbb0..12df0d78 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/session/adapter/Redis.php @@ -17,5 +17,4 @@ class Redis extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/session/adapter/Stream.php index b7e68132..8ab1e0bf 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/session/adapter/Stream.php @@ -56,9 +56,9 @@ public function gc($maxlifetime): bool /** * Ignore the savePath and use local defined path * - * @return bool * @param mixed $savePath * @param mixed $sessionName + * @return bool */ public function open($savePath, $sessionName): bool { @@ -80,5 +80,4 @@ public function read($id): string public function write($id, $data): bool { } - } diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/storage/AdapterFactory.php index 2a4c9420..dd7887d1 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/storage/AdapterFactory.php @@ -48,5 +48,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/storage/SerializerFactory.php b/src/Phalcon/storage/SerializerFactory.php index f9705f0d..a2d1ccd9 100644 --- a/src/Phalcon/storage/SerializerFactory.php +++ b/src/Phalcon/storage/SerializerFactory.php @@ -40,5 +40,4 @@ public function newInstance(string $name): SerializerInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/storage/adapter/AbstractAdapter.php index 3f8a3d98..94256425 100644 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ b/src/Phalcon/storage/adapter/AbstractAdapter.php @@ -213,5 +213,4 @@ protected function getUnserializedData($content, $defaultValue = null) protected function initSerializer() { } - } diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/storage/adapter/AdapterInterface.php index a7f35523..5e182da4 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/storage/adapter/AdapterInterface.php @@ -88,5 +88,4 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; - } diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/storage/adapter/Apcu.php index b4d60d72..48c4b88b 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/storage/adapter/Apcu.php @@ -36,7 +36,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -59,7 +59,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed */ @@ -101,7 +101,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -113,8 +113,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws \Exception @@ -122,5 +122,4 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/storage/adapter/Libmemcached.php index babf6205..0ea8caee 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/storage/adapter/Libmemcached.php @@ -62,7 +62,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed * @throws Exception @@ -108,7 +108,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -121,8 +121,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws Exception @@ -140,5 +140,4 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Memcached $connection) { } - } diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/storage/adapter/Memory.php index c2aa28b0..10c77db9 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/storage/adapter/Memory.php @@ -43,7 +43,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -65,7 +65,7 @@ public function delete(string $key): bool /** * Reads data from the adapter * - * @param string $key + * @param string $key * @param mixed|null $defaultValue * * @return mixed @@ -108,7 +108,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -120,13 +120,12 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool */ public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/storage/adapter/Redis.php index 21c96133..e110d1a2 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/storage/adapter/Redis.php @@ -39,7 +39,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -64,7 +64,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed * @throws Exception @@ -110,7 +110,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -123,8 +123,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws Exception @@ -142,5 +142,4 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } - } diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/storage/adapter/Stream.php index 4151c3cc..6279bd5e 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/storage/adapter/Stream.php @@ -31,8 +31,8 @@ class Stream extends AbstractAdapter * * @param array $options * - * @throws Exception * @param \Phalcon\Storage\SerializerFactory $factory + * @throws Exception */ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) { @@ -51,7 +51,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws \Exception @@ -75,7 +75,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed|null */ @@ -117,7 +117,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws \Exception @@ -130,8 +130,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws \Exception @@ -192,5 +192,4 @@ private function getPayload(string $filepath): array private function isExpired(array $payload): bool { } - } diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/storage/serializer/AbstractSerializer.php index d81e734d..205118eb 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/storage/serializer/AbstractSerializer.php @@ -50,5 +50,4 @@ public function getData() public function setData($data) { } - } diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/storage/serializer/Base64.php index 67b662fb..ac8ebb63 100644 --- a/src/Phalcon/storage/serializer/Base64.php +++ b/src/Phalcon/storage/serializer/Base64.php @@ -30,5 +30,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/storage/serializer/Igbinary.php index 18c5e581..5ae29919 100644 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ b/src/Phalcon/storage/serializer/Igbinary.php @@ -30,5 +30,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/storage/serializer/Json.php index 03406141..98601157 100644 --- a/src/Phalcon/storage/serializer/Json.php +++ b/src/Phalcon/storage/serializer/Json.php @@ -30,5 +30,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/storage/serializer/Msgpack.php index 54d03c8f..7b5cc9f0 100644 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ b/src/Phalcon/storage/serializer/Msgpack.php @@ -30,5 +30,4 @@ public function serialize(): ?string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/storage/serializer/None.php index 36e121e1..4887eb92 100644 --- a/src/Phalcon/storage/serializer/None.php +++ b/src/Phalcon/storage/serializer/None.php @@ -30,5 +30,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/storage/serializer/Php.php index 2ddd36be..07a289c5 100644 --- a/src/Phalcon/storage/serializer/Php.php +++ b/src/Phalcon/storage/serializer/Php.php @@ -30,5 +30,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/storage/serializer/SerializerInterface.php index 8d733b48..e70bde5d 100644 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ b/src/Phalcon/storage/serializer/SerializerInterface.php @@ -22,5 +22,4 @@ public function getData(); * @param mixed $data */ public function setData($data); - } diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/tag/Select.php index 94ca10d9..4d7fbcef 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/tag/Select.php @@ -46,5 +46,4 @@ private static function optionsFromArray(array $data, $value, string $closeOptio private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string { } - } diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/translate/InterpolatorFactory.php index 35171fe5..2b8f0d68 100644 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ b/src/Phalcon/translate/InterpolatorFactory.php @@ -51,5 +51,4 @@ public function newInstance(string $name): AdapterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/translate/TranslateFactory.php b/src/Phalcon/translate/TranslateFactory.php index c4b4da98..bb89fff5 100644 --- a/src/Phalcon/translate/TranslateFactory.php +++ b/src/Phalcon/translate/TranslateFactory.php @@ -58,5 +58,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/translate/adapter/AbstractAdapter.php index 3b9e7ba3..61eb811a 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/translate/adapter/AbstractAdapter.php @@ -101,5 +101,4 @@ public function t(string $translateKey, array $placeholders = array()): string protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/translate/adapter/AdapterInterface.php b/src/Phalcon/translate/adapter/AdapterInterface.php index 748dbfc3..d3e246e6 100644 --- a/src/Phalcon/translate/adapter/AdapterInterface.php +++ b/src/Phalcon/translate/adapter/AdapterInterface.php @@ -35,5 +35,4 @@ public function query(string $translateKey, array $placeholders = array()): stri * @return string */ public function t(string $translateKey, array $placeholders = array()): string; - } diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/translate/adapter/Csv.php index 5a1ce803..42cf4523 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/translate/adapter/Csv.php @@ -57,5 +57,4 @@ public function query(string $index, array $placeholders = array()): string private function load(string $file, int $length, string $delimiter, string $enclosure) { } - } diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/translate/adapter/Gettext.php index 52cf5d2a..9c4cfd96 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/translate/adapter/Gettext.php @@ -208,5 +208,4 @@ protected function getOptionsDefault(): array protected function prepareOptions(array $options) { } - } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/translate/adapter/NativeArray.php index 76a70ccf..b61536af 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/translate/adapter/NativeArray.php @@ -60,5 +60,4 @@ public function notFound(string $index): string public function query(string $index, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/translate/interpolator/AssociativeArray.php index 2666724d..f38fa2ff 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/translate/interpolator/AssociativeArray.php @@ -23,5 +23,4 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/translate/interpolator/IndexedArray.php index b9c7f3c7..d1bf80ab 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/translate/interpolator/IndexedArray.php @@ -23,5 +23,4 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/translate/interpolator/InterpolatorInterface.php b/src/Phalcon/translate/interpolator/InterpolatorInterface.php index 4adb6a41..81c5972a 100644 --- a/src/Phalcon/translate/interpolator/InterpolatorInterface.php +++ b/src/Phalcon/translate/interpolator/InterpolatorInterface.php @@ -18,5 +18,4 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; - } diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/url/UrlInterface.php index e67b5ed5..c7d6b3a6 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/url/UrlInterface.php @@ -55,5 +55,4 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; - } diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/validation/AbstractValidator.php index 9028834e..1a0bc25b 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/validation/AbstractValidator.php @@ -39,9 +39,9 @@ public function __construct(array $options = array()) /** * Get the template message * + * @param string $field * @return string * @throw InvalidArgumentException When the field does not exists - * @param string $field */ public function getTemplate(string $field = null): string { @@ -59,8 +59,8 @@ public function getTemplates(): array /** * Clear current templates and set new from an array, * - * @return ValidatorInterface * @param array $templates + * @return ValidatorInterface */ public function setTemplates(array $templates): ValidatorInterface { @@ -69,8 +69,8 @@ public function setTemplates(array $templates): ValidatorInterface /** * Set a new template message * - * @return ValidatorInterface * @param string $template + * @return ValidatorInterface */ public function setTemplate(string $template): ValidatorInterface { @@ -141,15 +141,14 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) /** * Create a default message by factory * - * @return Message - * - * @throw Exception * @param \Phalcon\Validation $validation * @param mixed $field * @param array $replacements + * @return Message + * + * @throw Exception */ public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message { } - } diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/validation/AbstractValidatorComposite.php index a78ef5e2..842ec995 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/validation/AbstractValidatorComposite.php @@ -30,5 +30,4 @@ public function getValidators(): array public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/validation/ValidationInterface.php index c874fe26..260f0862 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/validation/ValidationInterface.php @@ -124,5 +124,4 @@ public function setLabels(array $labels); * @return \Phalcon\Messages\Messages */ public function validate($data = null, $entity = null): Messages; - } diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/validation/ValidatorCompositeInterface.php index 7798b58b..602bef4d 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/validation/ValidatorCompositeInterface.php @@ -23,5 +23,4 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; - } diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/validation/ValidatorFactory.php index 95e5ca1b..955bd259 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/validation/ValidatorFactory.php @@ -40,5 +40,4 @@ public function newInstance(string $name) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/validation/ValidatorInterface.php index ec192dcf..f1848f02 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/validation/ValidatorInterface.php @@ -12,35 +12,35 @@ interface ValidatorInterface * Returns an option in the validator's options * Returns null if the option hasn't set * - * @return mixed * @param string $key * @param mixed $defaultValue + * @return mixed */ public function getOption(string $key, $defaultValue = null); /** * Checks if an option is defined * - * @return boolean * @param string $key + * @return boolean */ public function hasOption(string $key): bool; /** * Executes the validation * - * @return boolean * @param \Phalcon\Validation $validation * @param mixed $field + * @return boolean */ public function validate(\Phalcon\Validation $validation, $field): bool; /** * Get the template message * + * @param string $field * @return string * @throw InvalidArgumentException When the field does not exists - * @param string $field */ public function getTemplate(string $field): string; @@ -54,17 +54,16 @@ public function getTemplates(): array; /** * Clear current template and set new from an array, * - * @return ValidatorInterface * @param array $templates + * @return ValidatorInterface */ public function setTemplates(array $templates): ValidatorInterface; /** * Set a new temlate message * - * @return ValidatorInterface * @param string $template + * @return ValidatorInterface */ public function setTemplate(string $template): ValidatorInterface; - } diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index 093344c8..c42de8bd 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -54,5 +54,4 @@ class Alnum extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 403f8658..890bd985 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -54,5 +54,4 @@ class Alpha extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 2f84550b..8c59ea02 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -65,5 +65,4 @@ class Between extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index 712ac062..d9ed74af 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -64,5 +64,4 @@ class Callback extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index f81d5ebe..294f6d93 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -70,5 +70,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } - } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index 4028f411..bfc588b7 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -65,5 +65,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } - } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index f40c4065..538b51c1 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -68,5 +68,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } - } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index bd1d2c3b..c09dc3cc 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -54,5 +54,4 @@ class Digit extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index f70b51cb..1b537ecb 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -54,5 +54,4 @@ class Email extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index ebeebbd3..4933c82a 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -65,5 +65,4 @@ class ExclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index d43d2447..9aef43c4 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -82,5 +82,4 @@ class File extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index 4d8d5bce..b3299ff1 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -59,5 +59,4 @@ class Identical extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 1b7f3b1a..05a1c725 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -59,5 +59,4 @@ class InclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/validation/validator/Ip.php index 2d2f6540..ccfddd67 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/validation/validator/Ip.php @@ -77,5 +77,4 @@ class Ip extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index 6bc8defa..d991fcb4 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -54,5 +54,4 @@ class Numericality extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index 8f1348c9..c0002357 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -54,5 +54,4 @@ class PresenceOf extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index 997f75e9..c25b6ecf 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -59,5 +59,4 @@ class Regex extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index a1f62149..b3b7a984 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -77,5 +77,4 @@ class StringLength extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index d023f486..dd3b39cf 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -124,5 +124,4 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } - } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 086626cc..3872318a 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -54,5 +54,4 @@ class Url extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/validation/validator/file/AbstractFile.php index 629fbf86..a787dddc 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/validation/validator/file/AbstractFile.php @@ -174,5 +174,4 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } - } diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/validation/validator/file/MimeType.php index 85f42aa9..777c08be 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/validation/validator/file/MimeType.php @@ -68,5 +68,4 @@ class MimeType extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/validation/validator/file/resolution/Equal.php index 3ded3092..8c266d16 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/validation/validator/file/resolution/Equal.php @@ -59,5 +59,4 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/validation/validator/file/resolution/Max.php index aa3f5623..af9715d6 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/validation/validator/file/resolution/Max.php @@ -64,5 +64,4 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/validation/validator/file/resolution/Min.php index bd0caee3..75e48df5 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/validation/validator/file/resolution/Min.php @@ -64,5 +64,4 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/validation/validator/file/size/Equal.php index 3dbcd702..852b0144 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/validation/validator/file/size/Equal.php @@ -64,5 +64,4 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/validation/validator/file/size/Max.php index 9c4459bb..7465186a 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/validation/validator/file/size/Max.php @@ -64,5 +64,4 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/validation/validator/file/size/Min.php index e241f58f..01383b3b 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/validation/validator/file/size/Min.php @@ -64,5 +64,4 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/validation/validator/stringlength/Max.php index d9848924..6dfb16a1 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/validation/validator/stringlength/Max.php @@ -66,5 +66,4 @@ class Max extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/validation/validator/stringlength/Min.php index 28091a84..5c77a755 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/validation/validator/stringlength/Min.php @@ -66,5 +66,4 @@ class Min extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } From c313f0e61179e78298b7588c3fbf97d846d2d981 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Mon, 18 Nov 2019 12:21:55 +0100 Subject: [PATCH 21/25] Updated stubs to RC.3 --- .../Adapter}/AbstractAdapter.php | 14 +- .../Adapter}/AdapterInterface.php | 17 ++- .../{acl/adapter => Acl/Adapter}/Memory.php | 19 ++- src/Phalcon/{acl => Acl}/Component.php | 10 +- src/Phalcon/{acl => Acl}/ComponentAware.php | 8 ++ .../{acl => Acl}/ComponentInterface.php | 8 ++ src/Phalcon/Acl/Enum.php | 24 ++++ src/Phalcon/{factory => Acl}/Exception.php | 10 +- src/Phalcon/{acl => Acl}/Role.php | 10 +- src/Phalcon/{acl => Acl}/RoleAware.php | 8 ++ src/Phalcon/{acl => Acl}/RoleInterface.php | 8 ++ .../Adapter}/AbstractAdapter.php | 18 ++- .../Adapter}/AdapterInterface.php | 16 ++- .../adapter => Annotations/Adapter}/Apcu.php | 12 +- .../Adapter}/Memory.php | 13 +- .../Adapter}/Stream.php | 13 +- .../Annotation.php | 8 ++ .../AnnotationsFactory.php | 14 +- .../Collection.php | 20 ++- src/Phalcon/Annotations/Exception.php | 18 +++ .../{annotations => Annotations}/Reader.php | 10 +- .../ReaderInterface.php | 8 ++ .../Reflection.php | 14 +- .../AbstractApplication.php | 11 +- src/Phalcon/Application/Exception.php | 18 +++ src/Phalcon/{assets => Assets}/Asset.php | 10 +- .../{assets/asset => Assets/Asset}/Css.php | 8 ++ .../{assets/asset => Assets/Asset}/Js.php | 8 ++ .../{assets => Assets}/AssetInterface.php | 8 ++ src/Phalcon/{assets => Assets}/Collection.php | 22 ++- src/Phalcon/Assets/Exception.php | 18 +++ .../{assets => Assets}/FilterInterface.php | 8 ++ .../filters => Assets/Filters}/Cssmin.php | 8 ++ .../filters => Assets/Filters}/Jsmin.php | 8 ++ .../filters => Assets/Filters}/None.php | 8 ++ src/Phalcon/{assets => Assets}/Inline.php | 10 +- .../{assets/inline => Assets/Inline}/Css.php | 8 ++ .../{assets/inline => Assets/Inline}/Js.php | 8 ++ src/Phalcon/{assets => Assets}/Manager.php | 42 +++--- src/Phalcon/Cache.php | 30 ++-- .../Cache/Adapter/AdapterInterface.php | 20 +++ src/Phalcon/Cache/Adapter/Apcu.php | 20 +++ src/Phalcon/Cache/Adapter/Libmemcached.php | 20 +++ src/Phalcon/Cache/Adapter/Memory.php | 20 +++ src/Phalcon/Cache/Adapter/Redis.php | 20 +++ src/Phalcon/Cache/Adapter/Stream.php | 20 +++ .../{cache => Cache}/AdapterFactory.php | 10 +- src/Phalcon/{cache => Cache}/CacheFactory.php | 14 +- src/Phalcon/Cache/Exception/Exception.php | 18 +++ .../Exception/InvalidArgumentException.php | 18 +++ src/Phalcon/{cli => Cli}/Console.php | 8 ++ src/Phalcon/Cli/Console/Exception.php | 18 +++ src/Phalcon/{cli => Cli}/Dispatcher.php | 20 ++- src/Phalcon/Cli/Dispatcher/Exception.php | 18 +++ .../{cli => Cli}/DispatcherInterface.php | 16 ++- src/Phalcon/{cli => Cli}/Router.php | 19 ++- src/Phalcon/Cli/Router/Exception.php | 18 +++ .../{cli/router => Cli/Router}/Route.php | 26 +++- .../router => Cli/Router}/RouteInterface.php | 11 ++ src/Phalcon/{cli => Cli}/RouterInterface.php | 22 ++- src/Phalcon/{cli => Cli}/Task.php | 13 +- src/Phalcon/Cli/TaskInterface.php | 18 +++ src/Phalcon/Collection.php | 36 ++++- src/Phalcon/Collection/Exception.php | 18 +++ .../{collection => Collection}/ReadOnly.php | 10 ++ src/Phalcon/Config.php | 9 ++ .../adapter => Config/Adapter}/Grouped.php | 8 ++ .../adapter => Config/Adapter}/Ini.php | 8 ++ .../adapter => Config/Adapter}/Json.php | 8 ++ .../adapter => Config/Adapter}/Php.php | 8 ++ .../adapter => Config/Adapter}/Yaml.php | 8 ++ .../{config => Config}/ConfigFactory.php | 8 ++ src/Phalcon/Config/Exception.php | 18 +++ src/Phalcon/Container.php | 8 ++ src/Phalcon/Crypt.php | 32 +++-- .../{crypt => Crypt}/CryptInterface.php | 8 ++ src/Phalcon/Crypt/Exception.php | 18 +++ src/Phalcon/Crypt/Mismatch.php | 18 +++ src/Phalcon/{db => Db}/AbstractDb.php | 9 ++ .../Adapter}/AbstractAdapter.php | 27 ++-- .../Adapter}/AdapterInterface.php | 20 ++- .../pdo => Db/Adapter/Pdo}/AbstractPdo.php | 10 +- .../adapter/pdo => Db/Adapter/Pdo}/Mysql.php | 14 +- .../pdo => Db/Adapter/Pdo}/Postgresql.php | 14 +- .../adapter/pdo => Db/Adapter/Pdo}/Sqlite.php | 16 ++- .../{db/adapter => Db/Adapter}/PdoFactory.php | 16 ++- src/Phalcon/{db => Db}/Column.php | 10 +- src/Phalcon/{db => Db}/ColumnInterface.php | 8 ++ src/Phalcon/{db => Db}/Dialect.php | 10 +- .../{db/dialect => Db/Dialect}/Mysql.php | 8 ++ .../{db/dialect => Db/Dialect}/Postgresql.php | 8 ++ .../{db/dialect => Db/Dialect}/Sqlite.php | 8 ++ src/Phalcon/{db => Db}/DialectInterface.php | 34 +++-- src/Phalcon/{db => Db}/Enum.php | 9 ++ src/Phalcon/{image => Db}/Exception.php | 10 +- src/Phalcon/{db => Db}/Index.php | 10 +- src/Phalcon/{db => Db}/IndexInterface.php | 8 ++ src/Phalcon/{db => Db}/Profiler.php | 14 +- .../{db/profiler => Db/Profiler}/Item.php | 14 +- src/Phalcon/{db => Db}/RawValue.php | 8 ++ src/Phalcon/{db => Db}/Reference.php | 10 +- src/Phalcon/{db => Db}/ReferenceInterface.php | 8 ++ src/Phalcon/{db/result => Db/Result}/Pdo.php | 9 ++ src/Phalcon/{db => Db}/ResultInterface.php | 8 ++ src/Phalcon/Debug.php | 13 +- src/Phalcon/{debug => Debug}/Dump.php | 8 ++ src/Phalcon/Debug/Exception.php | 18 +++ src/Phalcon/Di.php | 40 ++++-- src/Phalcon/Di/AbstractInjectionAware.php | 44 ++++++ src/Phalcon/{di => Di}/DiInterface.php | 30 ++-- src/Phalcon/Di/Exception.php | 18 +++ .../Exception/ServiceResolutionException.php | 18 +++ src/Phalcon/{di => Di}/FactoryDefault.php | 8 ++ .../FactoryDefault}/Cli.php | 8 ++ src/Phalcon/{di => Di}/Injectable.php | 17 ++- .../{di => Di}/InjectionAwareInterface.php | 15 +- src/Phalcon/{di => Di}/Service.php | 21 ++- .../{di/service => Di/Service}/Builder.php | 12 +- src/Phalcon/{di => Di}/ServiceInterface.php | 14 +- .../{di => Di}/ServiceProviderInterface.php | 13 +- .../AbstractDispatcher.php | 32 ++++- .../DispatcherInterface.php | 18 +++ .../{dispatcher => Dispatcher}/Exception.php | 9 ++ .../payload => Domain/Payload}/Payload.php | 20 ++- src/Phalcon/Domain/Payload/PayloadFactory.php | 27 ++++ .../Domain/Payload/PayloadInterface.php | 18 +++ .../Payload}/ReadableInterface.php | 8 ++ .../payload => Domain/Payload}/Status.php | 8 ++ .../Payload}/WriteableInterface.php | 18 ++- src/Phalcon/Escaper.php | 11 ++ .../{escaper => Escaper}/EscaperInterface.php | 10 ++ src/Phalcon/Escaper/Exception.php | 18 +++ src/Phalcon/{events => Events}/Event.php | 10 +- .../{events => Events}/EventInterface.php | 8 ++ .../EventsAwareInterface.php | 11 +- src/Phalcon/Events/Exception.php | 20 +++ src/Phalcon/{events => Events}/Manager.php | 19 ++- .../{events => Events}/ManagerInterface.php | 13 +- src/Phalcon/Exception.php | 10 +- .../{factory => Factory}/AbstractFactory.php | 10 ++ src/Phalcon/Factory/Exception.php | 23 +++ src/Phalcon/Filter.php | 10 ++ src/Phalcon/Filter/Exception.php | 20 +++ .../{filter => Filter}/FilterFactory.php | 10 +- .../{filter => Filter}/FilterInterface.php | 8 ++ .../sanitize => Filter/Sanitize}/AbsInt.php | 8 ++ .../sanitize => Filter/Sanitize}/Alnum.php | 8 ++ .../sanitize => Filter/Sanitize}/Alpha.php | 8 ++ .../sanitize => Filter/Sanitize}/BoolVal.php | 8 ++ .../sanitize => Filter/Sanitize}/Email.php | 8 ++ .../sanitize => Filter/Sanitize}/FloatVal.php | 8 ++ .../sanitize => Filter/Sanitize}/IntVal.php | 8 ++ .../sanitize => Filter/Sanitize}/Lower.php | 8 ++ .../Sanitize}/LowerFirst.php | 8 ++ .../sanitize => Filter/Sanitize}/Regex.php | 8 ++ .../sanitize => Filter/Sanitize}/Remove.php | 8 ++ .../sanitize => Filter/Sanitize}/Replace.php | 8 ++ .../sanitize => Filter/Sanitize}/Special.php | 8 ++ .../Sanitize}/SpecialFull.php | 8 ++ .../Sanitize}/StringVal.php | 8 ++ .../Sanitize}/Striptags.php | 8 ++ .../sanitize => Filter/Sanitize}/Trim.php | 8 ++ .../sanitize => Filter/Sanitize}/Upper.php | 8 ++ .../Sanitize}/UpperFirst.php | 8 ++ .../Sanitize}/UpperWords.php | 8 ++ .../sanitize => Filter/Sanitize}/Url.php | 8 ++ .../Adapter}/AbstractAdapter.php | 18 ++- .../adapter => Firewall/Adapter}/Acl.php | 13 +- .../Adapter}/AdapterInterface.php | 11 +- .../Adapter}/Annotations.php | 12 +- .../micro => Firewall/Adapter/Micro}/Acl.php | 11 +- src/Phalcon/Firewall/Exception.php | 18 +++ .../{flash => Flash}/AbstractFlash.php | 17 ++- src/Phalcon/{flash => Flash}/Direct.php | 11 +- src/Phalcon/Flash/Exception.php | 18 +++ .../{flash => Flash}/FlashInterface.php | 8 ++ src/Phalcon/{flash => Flash}/Session.php | 15 +- .../Element}/AbstractElement.php | 16 ++- .../element => Forms/Element}/Check.php | 10 +- .../{forms/element => Forms/Element}/Date.php | 10 +- .../Element}/ElementInterface.php | 14 +- .../element => Forms/Element}/Email.php | 10 +- .../{forms/element => Forms/Element}/File.php | 10 +- .../element => Forms/Element}/Hidden.php | 10 +- .../element => Forms/Element}/Numeric.php | 10 +- .../element => Forms/Element}/Password.php | 10 +- .../element => Forms/Element}/Radio.php | 10 +- .../element => Forms/Element}/Select.php | 14 +- src/Phalcon/Forms/Element/Submit.php | 28 ++++ .../{forms/element => Forms/Element}/Text.php | 10 +- src/Phalcon/Forms/Element/TextArea.php | 28 ++++ src/Phalcon/Forms/Exception.php | 18 +++ src/Phalcon/{forms => Forms}/Form.php | 28 ++-- src/Phalcon/{forms => Forms}/Manager.php | 8 ++ src/Phalcon/{helper => Helper}/Arr.php | 40 +++--- src/Phalcon/Helper/Exception.php | 18 +++ src/Phalcon/{helper => Helper}/Fs.php | 8 ++ src/Phalcon/{helper => Helper}/Number.php | 8 ++ src/Phalcon/{helper => Helper}/Str.php | 24 ++-- src/Phalcon/{html => Html}/Attributes.php | 8 ++ .../Attributes}/AttributesInterface.php | 10 +- .../Attributes}/RenderInterface.php | 8 ++ src/Phalcon/{html => Html}/Breadcrumbs.php | 11 ++ src/Phalcon/Html/Exception.php | 20 +++ .../helper => Html/Helper}/AbstractHelper.php | 8 ++ .../{html/helper => Html/Helper}/Anchor.php | 10 +- .../helper => Html/Helper}/AnchorRaw.php | 10 +- src/Phalcon/Html/Helper/Body.php | 28 ++++ .../{html/helper => Html/Helper}/Button.php | 10 +- .../{html/helper => Html/Helper}/Close.php | 8 ++ .../{html/helper => Html/Helper}/Element.php | 10 +- src/Phalcon/Html/Helper/ElementRaw.php | 34 +++++ .../{html/helper => Html/Helper}/Form.php | 10 +- .../{html/helper => Html/Helper}/Img.php | 10 +- .../{html/helper => Html/Helper}/Label.php | 8 ++ .../{html/helper => Html/Helper}/TextArea.php | 10 +- src/Phalcon/Html/Link/EvolvableLink.php | 102 ++++++++++++++ .../Html/Link/EvolvableLinkProvider.php | 53 +++++++ src/Phalcon/Html/Link/Link.php | 119 ++++++++++++++++ src/Phalcon/Html/Link/LinkProvider.php | 74 ++++++++++ src/Phalcon/Html/Link/Serializer/Header.php | 30 ++++ .../Link/Serializer/SerializerInterface.php | 26 ++++ src/Phalcon/{html => Html}/TagFactory.php | 8 ++ src/Phalcon/{http => Http}/Cookie.php | 17 ++- src/Phalcon/Http/Cookie/Exception.php | 20 +++ .../{http => Http}/CookieInterface.php | 8 ++ .../Message}/AbstractCommon.php | 13 +- .../Message}/AbstractMessage.php | 32 +++-- .../Message}/AbstractRequest.php | 14 +- .../Exception}/InvalidArgumentException.php | 7 + .../message => Http/Message}/Request.php | 14 +- .../Message}/RequestFactory.php | 10 +- .../message => Http/Message}/Response.php | 17 ++- .../Message}/ResponseFactory.php | 10 +- .../Message}/ServerRequest.php | 35 +++-- .../Message}/ServerRequestFactory.php | 24 ++-- .../{http/message => Http/Message}/Stream.php | 26 +++- .../stream => Http/Message/Stream}/Input.php | 14 +- .../stream => Http/Message/Stream}/Memory.php | 8 ++ .../stream => Http/Message/Stream}/Temp.php | 8 ++ .../Message}/StreamFactory.php | 12 +- .../message => Http/Message}/UploadedFile.php | 22 ++- .../Message}/UploadedFileFactory.php | 20 ++- .../{http/message => Http/Message}/Uri.php | 12 +- .../message => Http/Message}/UriFactory.php | 10 +- src/Phalcon/{http => Http}/Request.php | 37 +++-- src/Phalcon/Http/Request/Exception.php | 20 +++ .../{http/request => Http/Request}/File.php | 10 +- .../Request}/FileInterface.php | 8 ++ .../{http => Http}/RequestInterface.php | 26 +++- src/Phalcon/{http => Http}/Response.php | 22 ++- .../response => Http/Response}/Cookies.php | 22 ++- .../Response}/CookiesInterface.php | 10 +- src/Phalcon/Http/Response/Exception.php | 20 +++ .../response => Http/Response}/Headers.php | 16 ++- .../Response}/HeadersInterface.php | 8 ++ .../{http => Http}/ResponseInterface.php | 12 +- .../Server}/AbstractMiddleware.php | 10 +- .../Server}/AbstractRequestHandler.php | 10 +- .../Adapter}/AbstractAdapter.php | 16 ++- .../Adapter}/AdapterInterface.php | 8 ++ .../{image/adapter => Image/Adapter}/Gd.php | 12 +- .../adapter => Image/Adapter}/Imagick.php | 18 ++- src/Phalcon/{image => Image}/Enum.php | 9 ++ src/Phalcon/Image/Exception.php | 23 +++ src/Phalcon/{image => Image}/ImageFactory.php | 12 +- src/Phalcon/Kernel.php | 10 +- src/Phalcon/Loader.php | 13 +- src/Phalcon/Loader/Exception.php | 20 +++ src/Phalcon/Logger.php | 23 ++- .../Adapter}/AbstractAdapter.php | 23 ++- .../Adapter}/AdapterInterface.php | 11 +- .../adapter => Logger/Adapter}/Noop.php | 9 ++ .../adapter => Logger/Adapter}/Stream.php | 9 ++ .../adapter => Logger/Adapter}/Syslog.php | 11 +- .../{logger => Logger}/AdapterFactory.php | 10 +- src/Phalcon/Logger/Exception.php | 20 +++ .../Formatter}/AbstractFormatter.php | 10 +- .../Formatter}/FormatterInterface.php | 8 ++ .../formatter => Logger/Formatter}/Json.php | 10 +- .../formatter => Logger/Formatter}/Line.php | 10 +- src/Phalcon/{logger => Logger}/Item.php | 13 +- .../{logger => Logger}/LoggerFactory.php | 18 ++- src/Phalcon/Messages/Exception.php | 20 +++ .../{messages => Messages}/Message.php | 20 ++- .../MessageInterface.php | 8 ++ .../{messages => Messages}/Messages.php | 20 ++- src/Phalcon/{mvc => Mvc}/Application.php | 10 +- src/Phalcon/Mvc/Application/Exception.php | 20 +++ src/Phalcon/{mvc => Mvc}/Controller.php | 10 +- .../Controller}/BindModelInterface.php | 8 ++ src/Phalcon/Mvc/ControllerInterface.php | 20 +++ src/Phalcon/{mvc => Mvc}/Dispatcher.php | 15 +- src/Phalcon/Mvc/Dispatcher/Exception.php | 20 +++ .../{mvc => Mvc}/DispatcherInterface.php | 16 ++- src/Phalcon/{mvc => Mvc}/EntityInterface.php | 8 ++ src/Phalcon/{mvc => Mvc}/Micro.php | 38 +++-- .../{mvc/micro => Mvc/Micro}/Collection.php | 10 +- .../Micro}/CollectionInterface.php | 8 ++ src/Phalcon/Mvc/Micro/Exception.php | 18 +++ .../{mvc/micro => Mvc/Micro}/LazyLoader.php | 11 +- .../Micro}/MiddlewareInterface.php | 8 ++ src/Phalcon/{mvc => Mvc}/Model.php | 128 ++++++++++++----- .../{mvc/model => Mvc/Model}/Behavior.php | 12 +- .../Model/Behavior}/SoftDelete.php | 8 ++ .../Model/Behavior}/Timestampable.php | 8 ++ .../model => Mvc/Model}/BehaviorInterface.php | 8 ++ .../{mvc/model => Mvc/Model}/Binder.php | 12 +- .../Model/Binder}/BindableInterface.php | 8 ++ .../model => Mvc/Model}/BinderInterface.php | 10 +- .../{mvc/model => Mvc/Model}/Criteria.php | 67 +++++---- .../model => Mvc/Model}/CriteriaInterface.php | 8 ++ src/Phalcon/Mvc/Model/Exception.php | 20 +++ .../{mvc/model => Mvc/Model}/Manager.php | 129 +++++++++++++---- .../model => Mvc/Model}/ManagerInterface.php | 131 ++++++++++++------ .../{mvc/model => Mvc/Model}/MetaData.php | 29 +++- .../metadata => Mvc/Model/MetaData}/Apcu.php | 8 ++ .../Model/MetaData}/Libmemcached.php | 10 ++ .../Model/MetaData}/Memory.php | 9 ++ .../metadata => Mvc/Model/MetaData}/Redis.php | 10 ++ .../Model/MetaData/Strategy/Annotations.php} | 17 ++- .../MetaData/Strategy/Introspection.php} | 15 +- .../MetaData/Strategy}/StrategyInterface.php | 10 +- .../Model/MetaData}/Stream.php | 10 ++ .../model => Mvc/Model}/MetaDataInterface.php | 16 ++- .../{mvc/model => Mvc/Model}/Query.php | 75 +++++----- .../query => Mvc/Model/Query}/Builder.php | 81 ++++++----- .../Model/Query}/BuilderInterface.php | 10 +- .../model/query => Mvc/Model/Query}/Lang.php | 8 ++ .../query => Mvc/Model/Query}/Status.php | 14 +- .../Model/Query}/StatusInterface.php | 12 +- .../model => Mvc/Model}/QueryInterface.php | 12 +- .../{mvc/model => Mvc/Model}/Relation.php | 10 +- .../model => Mvc/Model}/RelationInterface.php | 8 ++ .../model => Mvc/Model}/ResultInterface.php | 10 +- .../{mvc/model => Mvc/Model}/Resultset.php | 33 +++-- .../Model/Resultset}/Complex.php | 11 +- .../Model/Resultset}/Simple.php | 11 +- .../Model}/ResultsetInterface.php | 18 ++- src/Phalcon/{mvc/model => Mvc/Model}/Row.php | 17 ++- .../{mvc/model => Mvc/Model}/Transaction.php | 14 +- .../Model/Transaction}/Exception.php | 7 + .../Model/Transaction}/Failed.php | 14 +- .../Model/Transaction}/Manager.php | 29 +++- .../Model/Transaction}/ManagerInterface.php | 17 ++- .../Model}/TransactionInterface.php | 12 ++ .../model => Mvc/Model}/ValidationFailed.php | 12 +- src/Phalcon/{mvc => Mvc}/ModelInterface.php | 33 +++-- .../ModuleDefinitionInterface.php | 8 ++ src/Phalcon/{mvc => Mvc}/Router.php | 47 ++++--- .../router => Mvc/Router}/Annotations.php | 9 ++ src/Phalcon/Mvc/Router/Exception.php | 20 +++ .../{mvc/router => Mvc/Router}/Group.php | 16 ++- .../router => Mvc/Router}/GroupInterface.php | 36 +++-- .../{mvc/router => Mvc/Router}/Route.php | 22 ++- .../router => Mvc/Router}/RouteInterface.php | 11 ++ src/Phalcon/{mvc => Mvc}/RouterInterface.php | 41 ++++-- src/Phalcon/{mvc => Mvc}/View.php | 20 ++- .../View/Engine}/AbstractEngine.php | 13 +- .../View/Engine}/EngineInterface.php | 9 ++ .../view/engine => Mvc/View/Engine}/Php.php | 10 +- .../view/engine => Mvc/View/Engine}/Volt.php | 15 +- .../View/Engine/Volt}/Compiler.php | 19 ++- .../View/Engine/Volt}/Exception.php | 12 +- src/Phalcon/Mvc/View/Exception.php | 20 +++ src/Phalcon/{mvc/view => Mvc/View}/Simple.php | 11 +- .../{mvc => Mvc}/ViewBaseInterface.php | 8 ++ src/Phalcon/{mvc => Mvc}/ViewInterface.php | 12 +- .../Adapter}/AbstractAdapter.php | 18 ++- .../Adapter}/AdapterInterface.php | 10 +- src/Phalcon/Paginator/Adapter/Model.php | 90 ++++++++++++ .../Adapter}/NativeArray.php | 12 +- .../Adapter}/QueryBuilder.php | 14 +- src/Phalcon/Paginator/Exception.php | 20 +++ .../PaginatorFactory.php | 12 +- .../{paginator => Paginator}/Repository.php | 10 +- .../RepositoryInterface.php | 8 ++ src/Phalcon/Registry.php | 22 ++- src/Phalcon/Security.php | 15 +- src/Phalcon/Security/Exception.php | 20 +++ src/Phalcon/{security => Security}/Random.php | 28 ++-- .../Adapter}/AbstractAdapter.php | 8 ++ .../Adapter}/Libmemcached.php | 10 +- .../adapter => Session/Adapter}/Noop.php | 8 ++ .../adapter => Session/Adapter}/Redis.php | 10 +- .../adapter => Session/Adapter}/Stream.php | 10 +- src/Phalcon/{session => Session}/Bag.php | 16 ++- src/Phalcon/Session/Exception.php | 20 +++ src/Phalcon/{session => Session}/Manager.php | 27 +++- .../{session => Session}/ManagerInterface.php | 19 ++- .../Adapter}/AbstractAdapter.php | 12 +- .../Adapter}/AdapterInterface.php | 8 ++ .../adapter => Storage/Adapter}/Apcu.php | 25 ++-- .../Adapter}/Libmemcached.php | 18 ++- .../adapter => Storage/Adapter}/Memory.php | 25 ++-- .../adapter => Storage/Adapter}/Redis.php | 22 ++- .../adapter => Storage/Adapter}/Stream.php | 29 ++-- .../{storage => Storage}/AdapterFactory.php | 14 +- src/Phalcon/Storage/Exception.php | 20 +++ .../Serializer}/AbstractSerializer.php | 11 +- .../Serializer}/Base64.php | 11 +- .../Serializer}/Igbinary.php | 11 +- .../Serializer}/Json.php | 11 +- .../Serializer}/Msgpack.php | 11 +- .../Serializer}/None.php | 11 +- .../serializer => Storage/Serializer}/Php.php | 11 +- .../Serializer}/SerializerInterface.php | 9 ++ .../SerializerFactory.php | 8 ++ src/Phalcon/Tag.php | 51 ++++--- src/Phalcon/Tag/Exception.php | 20 +++ src/Phalcon/{tag => Tag}/Select.php | 8 ++ src/Phalcon/Text.php | 8 ++ .../Adapter}/AbstractAdapter.php | 12 +- .../Adapter}/AdapterInterface.php | 8 ++ .../adapter => Translate/Adapter}/Csv.php | 11 +- .../adapter => Translate/Adapter}/Gettext.php | 13 +- .../Adapter}/NativeArray.php | 10 +- src/Phalcon/Translate/Exception.php | 20 +++ .../Interpolator/AssociativeArray.php | 34 +++++ .../Interpolator}/IndexedArray.php | 10 +- .../Interpolator/InterpolatorInterface.php} | 19 +-- .../InterpolatorFactory.php | 10 +- .../TranslateFactory.php | 14 +- src/Phalcon/Url.php | 14 +- src/Phalcon/Url/Exception.php | 20 +++ src/Phalcon/{url => Url}/UrlInterface.php | 8 ++ src/Phalcon/Validation.php | 27 ++-- .../AbstractCombinedFieldsValidator.php | 18 +++ .../AbstractValidator.php | 23 ++- .../AbstractValidatorComposite.php | 10 +- src/Phalcon/Validation/Exception.php | 18 +++ .../ValidationInterface.php | 21 ++- .../Validator}/Alnum.php | 8 ++ .../Validator}/Alpha.php | 8 ++ .../Validator}/Between.php | 8 ++ .../Validator}/Callback.php | 8 ++ .../Validator}/Confirmation.php | 8 ++ .../Validator}/CreditCard.php | 8 ++ .../Validator}/Date.php | 8 ++ .../Validator}/Digit.php | 8 ++ .../Validator}/Email.php | 8 ++ .../Validation/Validator/Exception.php | 19 +++ .../Validator}/ExclusionIn.php | 8 ++ .../Validator}/File.php | 8 ++ .../Validator/File}/AbstractFile.php | 8 ++ .../Validator/File}/MimeType.php | 10 +- .../Validator/File/Resolution}/Equal.php | 8 ++ .../Validator/File/Resolution}/Max.php | 8 ++ .../Validator/File/Resolution}/Min.php | 8 ++ .../Validator/File/Size}/Equal.php | 8 ++ .../Validator/File/Size}/Max.php | 8 ++ .../Validator/File/Size}/Min.php | 8 ++ .../Validator}/Identical.php | 8 ++ .../Validator}/InclusionIn.php | 8 ++ .../validator => Validation/Validator}/Ip.php | 8 ++ .../Validator}/Numericality.php | 8 ++ .../Validator}/PresenceOf.php | 8 ++ .../Validator}/Regex.php | 8 ++ .../Validator}/StringLength.php | 8 ++ .../Validator/StringLength}/Max.php | 8 ++ .../Validator/StringLength}/Min.php | 8 ++ .../Validator}/Uniqueness.php | 8 ++ .../Validator}/Url.php | 8 ++ .../ValidatorCompositeInterface.php | 8 ++ .../ValidatorFactory.php | 13 +- .../ValidatorInterface.php | 20 ++- src/Phalcon/Version.php | 10 +- src/Phalcon/acl/Enum.php | 15 -- src/Phalcon/acl/Exception.php | 11 -- src/Phalcon/annotations/Exception.php | 11 -- src/Phalcon/application/Exception.php | 11 -- src/Phalcon/assets/Exception.php | 11 -- .../cache/adapter/AdapterInterface.php | 11 -- src/Phalcon/cache/adapter/Apcu.php | 11 -- src/Phalcon/cache/adapter/Libmemcached.php | 11 -- src/Phalcon/cache/adapter/Memory.php | 11 -- src/Phalcon/cache/adapter/Redis.php | 11 -- src/Phalcon/cache/adapter/Stream.php | 11 -- src/Phalcon/cache/exception/Exception.php | 11 -- .../exception/InvalidArgumentException.php | 11 -- src/Phalcon/cli/TaskInterface.php | 11 -- src/Phalcon/cli/console/Exception.php | 11 -- src/Phalcon/cli/dispatcher/Exception.php | 11 -- src/Phalcon/cli/router/Exception.php | 11 -- src/Phalcon/collection/Exception.php | 11 -- src/Phalcon/config/Exception.php | 11 -- src/Phalcon/crypt/Exception.php | 11 -- src/Phalcon/crypt/Mismatch.php | 11 -- src/Phalcon/db/Exception.php | 11 -- src/Phalcon/debug/Exception.php | 11 -- src/Phalcon/di/AbstractInjectionAware.php | 35 ----- src/Phalcon/di/Exception.php | 11 -- .../exception/ServiceResolutionException.php | 11 -- src/Phalcon/domain/payload/PayloadFactory.php | 19 --- .../domain/payload/PayloadInterface.php | 11 -- src/Phalcon/escaper/Exception.php | 11 -- src/Phalcon/events/Exception.php | 13 -- src/Phalcon/filter/Exception.php | 13 -- src/Phalcon/firewall/Exception.php | 11 -- src/Phalcon/flash/Exception.php | 11 -- src/Phalcon/forms/Exception.php | 11 -- src/Phalcon/forms/element/Submit.php | 20 --- src/Phalcon/forms/element/TextArea.php | 20 --- src/Phalcon/helper/Exception.php | 11 -- src/Phalcon/html/Exception.php | 13 -- src/Phalcon/html/helper/Body.php | 20 --- src/Phalcon/html/helper/ElementRaw.php | 26 ---- src/Phalcon/http/cookie/Exception.php | 13 -- src/Phalcon/http/request/Exception.php | 13 -- src/Phalcon/http/response/Exception.php | 13 -- src/Phalcon/loader/Exception.php | 13 -- src/Phalcon/logger/Exception.php | 13 -- src/Phalcon/logger/formatter/Syslog.php | 22 --- src/Phalcon/messages/Exception.php | 13 -- src/Phalcon/mvc/ControllerInterface.php | 13 -- src/Phalcon/mvc/application/Exception.php | 13 -- src/Phalcon/mvc/dispatcher/Exception.php | 13 -- src/Phalcon/mvc/micro/Exception.php | 11 -- src/Phalcon/mvc/model/Exception.php | 13 -- src/Phalcon/mvc/router/Exception.php | 13 -- src/Phalcon/mvc/view/Exception.php | 13 -- src/Phalcon/paginator/Exception.php | 13 -- src/Phalcon/paginator/adapter/Model.php | 38 ----- src/Phalcon/security/Exception.php | 13 -- src/Phalcon/session/Exception.php | 13 -- src/Phalcon/storage/Exception.php | 13 -- src/Phalcon/tag/Exception.php | 13 -- src/Phalcon/translate/Exception.php | 13 -- .../interpolator/InterpolatorInterface.php | 21 --- src/Phalcon/url/Exception.php | 13 -- .../AbstractCombinedFieldsValidator.php | 11 -- src/Phalcon/validation/Exception.php | 11 -- .../validation/validator/Exception.php | 12 -- 533 files changed, 6515 insertions(+), 1899 deletions(-) rename src/Phalcon/{acl/adapter => Acl/Adapter}/AbstractAdapter.php (83%) rename src/Phalcon/{acl/adapter => Acl/Adapter}/AdapterInterface.php (92%) rename src/Phalcon/{acl/adapter => Acl/Adapter}/Memory.php (96%) rename src/Phalcon/{acl => Acl}/Component.php (75%) rename src/Phalcon/{acl => Acl}/ComponentAware.php (53%) rename src/Phalcon/{acl => Acl}/ComponentInterface.php (67%) create mode 100644 src/Phalcon/Acl/Enum.php rename src/Phalcon/{factory => Acl}/Exception.php (66%) rename src/Phalcon/{acl => Acl}/Role.php (75%) rename src/Phalcon/{acl => Acl}/RoleAware.php (52%) rename src/Phalcon/{acl => Acl}/RoleInterface.php (66%) rename src/Phalcon/{annotations/adapter => Annotations/Adapter}/AbstractAdapter.php (81%) rename src/Phalcon/{annotations/adapter => Annotations/Adapter}/AdapterInterface.php (82%) rename src/Phalcon/{annotations/adapter => Annotations/Adapter}/Apcu.php (75%) rename src/Phalcon/{annotations/adapter => Annotations/Adapter}/Memory.php (63%) rename src/Phalcon/{annotations/adapter => Annotations/Adapter}/Stream.php (73%) rename src/Phalcon/{annotations => Annotations}/Annotation.php (89%) rename src/Phalcon/{annotations => Annotations}/AnnotationsFactory.php (71%) rename src/Phalcon/{annotations => Annotations}/Collection.php (86%) create mode 100644 src/Phalcon/Annotations/Exception.php rename src/Phalcon/{annotations => Annotations}/Reader.php (68%) rename src/Phalcon/{annotations => Annotations}/ReaderInterface.php (73%) rename src/Phalcon/{annotations => Annotations}/Reflection.php (83%) rename src/Phalcon/{application => Application}/AbstractApplication.php (90%) create mode 100644 src/Phalcon/Application/Exception.php rename src/Phalcon/{assets => Assets}/Asset.php (94%) rename src/Phalcon/{assets/asset => Assets/Asset}/Css.php (70%) rename src/Phalcon/{assets/asset => Assets/Asset}/Js.php (70%) rename src/Phalcon/{assets => Assets}/AssetInterface.php (83%) rename src/Phalcon/{assets => Assets}/Collection.php (94%) create mode 100644 src/Phalcon/Assets/Exception.php rename src/Phalcon/{assets => Assets}/FilterInterface.php (58%) rename src/Phalcon/{assets/filters => Assets/Filters}/Cssmin.php (67%) rename src/Phalcon/{assets/filters => Assets/Filters}/Jsmin.php (71%) rename src/Phalcon/{assets/filters => Assets/Filters}/None.php (61%) rename src/Phalcon/{assets => Assets}/Inline.php (86%) rename src/Phalcon/{assets/inline => Assets/Inline}/Css.php (62%) rename src/Phalcon/{assets/inline => Assets/Inline}/Js.php (63%) rename src/Phalcon/{assets => Assets}/Manager.php (86%) create mode 100644 src/Phalcon/Cache/Adapter/AdapterInterface.php create mode 100644 src/Phalcon/Cache/Adapter/Apcu.php create mode 100644 src/Phalcon/Cache/Adapter/Libmemcached.php create mode 100644 src/Phalcon/Cache/Adapter/Memory.php create mode 100644 src/Phalcon/Cache/Adapter/Redis.php create mode 100644 src/Phalcon/Cache/Adapter/Stream.php rename src/Phalcon/{cache => Cache}/AdapterFactory.php (78%) rename src/Phalcon/{cache => Cache}/CacheFactory.php (65%) create mode 100644 src/Phalcon/Cache/Exception/Exception.php create mode 100644 src/Phalcon/Cache/Exception/InvalidArgumentException.php rename src/Phalcon/{cli => Cli}/Console.php (77%) create mode 100644 src/Phalcon/Cli/Console/Exception.php rename src/Phalcon/{cli => Cli}/Dispatcher.php (88%) create mode 100644 src/Phalcon/Cli/Dispatcher/Exception.php rename src/Phalcon/{cli => Cli}/DispatcherInterface.php (75%) rename src/Phalcon/{cli => Cli}/Router.php (91%) create mode 100644 src/Phalcon/Cli/Router/Exception.php rename src/Phalcon/{cli/router => Cli/Router}/Route.php (87%) rename src/Phalcon/{cli/router => Cli/Router}/RouteInterface.php (88%) rename src/Phalcon/{cli => Cli}/RouterInterface.php (84%) rename src/Phalcon/{cli => Cli}/Task.php (74%) create mode 100644 src/Phalcon/Cli/TaskInterface.php create mode 100644 src/Phalcon/Collection/Exception.php rename src/Phalcon/{collection => Collection}/ReadOnly.php (65%) rename src/Phalcon/{config/adapter => Config/Adapter}/Grouped.php (85%) rename src/Phalcon/{config/adapter => Config/Adapter}/Ini.php (88%) rename src/Phalcon/{config/adapter => Config/Adapter}/Json.php (74%) rename src/Phalcon/{config/adapter => Config/Adapter}/Php.php (81%) rename src/Phalcon/{config/adapter => Config/Adapter}/Yaml.php (81%) rename src/Phalcon/{config => Config}/ConfigFactory.php (83%) create mode 100644 src/Phalcon/Config/Exception.php rename src/Phalcon/{crypt => Crypt}/CryptInterface.php (92%) create mode 100644 src/Phalcon/Crypt/Exception.php create mode 100644 src/Phalcon/Crypt/Mismatch.php rename src/Phalcon/{db => Db}/AbstractDb.php (85%) rename src/Phalcon/{db/adapter => Db/Adapter}/AbstractAdapter.php (97%) rename src/Phalcon/{db/adapter => Db/Adapter}/AdapterInterface.php (97%) rename src/Phalcon/{db/adapter/pdo => Db/Adapter/Pdo}/AbstractPdo.php (96%) rename src/Phalcon/{db/adapter/pdo => Db/Adapter/Pdo}/Mysql.php (87%) rename src/Phalcon/{db/adapter/pdo => Db/Adapter/Pdo}/Postgresql.php (92%) rename src/Phalcon/{db/adapter/pdo => Db/Adapter/Pdo}/Sqlite.php (89%) rename src/Phalcon/{db/adapter => Db/Adapter}/PdoFactory.php (72%) rename src/Phalcon/{db => Db}/Column.php (96%) rename src/Phalcon/{db => Db}/ColumnInterface.php (90%) rename src/Phalcon/{db => Db}/Dialect.php (97%) rename src/Phalcon/{db/dialect => Db/Dialect}/Mysql.php (97%) rename src/Phalcon/{db/dialect => Db/Dialect}/Postgresql.php (97%) rename src/Phalcon/{db/dialect => Db/Dialect}/Sqlite.php (97%) rename src/Phalcon/{db => Db}/DialectInterface.php (90%) rename src/Phalcon/{db => Db}/Enum.php (72%) rename src/Phalcon/{image => Db}/Exception.php (65%) rename src/Phalcon/{db => Db}/Index.php (85%) rename src/Phalcon/{db => Db}/IndexInterface.php (67%) rename src/Phalcon/{db => Db}/Profiler.php (91%) rename src/Phalcon/{db/profiler => Db/Profiler}/Item.php (89%) rename src/Phalcon/{db => Db}/RawValue.php (80%) rename src/Phalcon/{db => Db}/Reference.php (89%) rename src/Phalcon/{db => Db}/ReferenceInterface.php (83%) rename src/Phalcon/{db/result => Db/Result}/Pdo.php (95%) rename src/Phalcon/{db => Db}/ResultInterface.php (89%) rename src/Phalcon/{debug => Debug}/Dump.php (93%) create mode 100644 src/Phalcon/Debug/Exception.php create mode 100644 src/Phalcon/Di/AbstractInjectionAware.php rename src/Phalcon/{di => Di}/DiInterface.php (81%) create mode 100644 src/Phalcon/Di/Exception.php create mode 100644 src/Phalcon/Di/Exception/ServiceResolutionException.php rename src/Phalcon/{di => Di}/FactoryDefault.php (66%) rename src/Phalcon/{di/factorydefault => Di/FactoryDefault}/Cli.php (70%) rename src/Phalcon/{di => Di}/Injectable.php (85%) rename src/Phalcon/{di => Di}/InjectionAwareInterface.php (50%) rename src/Phalcon/{di => Di}/Service.php (81%) rename src/Phalcon/{di/service => Di/Service}/Builder.php (82%) rename src/Phalcon/{di => Di}/ServiceInterface.php (79%) rename src/Phalcon/{di => Di}/ServiceProviderInterface.php (67%) rename src/Phalcon/{dispatcher => Dispatcher}/AbstractDispatcher.php (92%) rename src/Phalcon/{dispatcher => Dispatcher}/DispatcherInterface.php (87%) rename src/Phalcon/{dispatcher => Dispatcher}/Exception.php (63%) rename src/Phalcon/{domain/payload => Domain/Payload}/Payload.php (79%) create mode 100644 src/Phalcon/Domain/Payload/PayloadFactory.php create mode 100644 src/Phalcon/Domain/Payload/PayloadInterface.php rename src/Phalcon/{domain/payload => Domain/Payload}/ReadableInterface.php (77%) rename src/Phalcon/{domain/payload => Domain/Payload}/Status.php (80%) rename src/Phalcon/{domain/payload => Domain/Payload}/WriteableInterface.php (75%) rename src/Phalcon/{escaper => Escaper}/EscaperInterface.php (85%) create mode 100644 src/Phalcon/Escaper/Exception.php rename src/Phalcon/{events => Events}/Event.php (89%) rename src/Phalcon/{events => Events}/EventInterface.php (82%) rename src/Phalcon/{events => Events}/EventsAwareInterface.php (65%) create mode 100644 src/Phalcon/Events/Exception.php rename src/Phalcon/{events => Events}/Manager.php (89%) rename src/Phalcon/{events => Events}/ManagerInterface.php (85%) rename src/Phalcon/{factory => Factory}/AbstractFactory.php (80%) create mode 100644 src/Phalcon/Factory/Exception.php create mode 100644 src/Phalcon/Filter/Exception.php rename src/Phalcon/{filter => Filter}/FilterFactory.php (68%) rename src/Phalcon/{filter => Filter}/FilterInterface.php (64%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/AbsInt.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Alnum.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Alpha.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/BoolVal.php (52%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Email.php (52%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/FloatVal.php (52%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/IntVal.php (52%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Lower.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/LowerFirst.php (54%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Regex.php (59%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Remove.php (57%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Replace.php (59%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Special.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/SpecialFull.php (57%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/StringVal.php (52%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Striptags.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Trim.php (55%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Upper.php (53%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/UpperFirst.php (54%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/UpperWords.php (57%) rename src/Phalcon/{filter/sanitize => Filter/Sanitize}/Url.php (51%) rename src/Phalcon/{firewall/adapter => Firewall/Adapter}/AbstractAdapter.php (90%) rename src/Phalcon/{firewall/adapter => Firewall/Adapter}/Acl.php (92%) rename src/Phalcon/{firewall/adapter => Firewall/Adapter}/AdapterInterface.php (83%) rename src/Phalcon/{firewall/adapter => Firewall/Adapter}/Annotations.php (89%) rename src/Phalcon/{firewall/adapter/micro => Firewall/Adapter/Micro}/Acl.php (94%) create mode 100644 src/Phalcon/Firewall/Exception.php rename src/Phalcon/{flash => Flash}/AbstractFlash.php (93%) rename src/Phalcon/{flash => Flash}/Direct.php (63%) create mode 100644 src/Phalcon/Flash/Exception.php rename src/Phalcon/{flash => Flash}/FlashInterface.php (81%) rename src/Phalcon/{flash => Flash}/Session.php (82%) rename src/Phalcon/{forms/element => Forms/Element}/AbstractElement.php (94%) rename src/Phalcon/{forms/element => Forms/Element}/Check.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/Date.php (50%) rename src/Phalcon/{forms/element => Forms/Element}/ElementInterface.php (95%) rename src/Phalcon/{forms/element => Forms/Element}/Email.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/File.php (50%) rename src/Phalcon/{forms/element => Forms/Element}/Hidden.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/Numeric.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/Password.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/Radio.php (53%) rename src/Phalcon/{forms/element => Forms/Element}/Select.php (75%) create mode 100644 src/Phalcon/Forms/Element/Submit.php rename src/Phalcon/{forms/element => Forms/Element}/Text.php (52%) create mode 100644 src/Phalcon/Forms/Element/TextArea.php create mode 100644 src/Phalcon/Forms/Exception.php rename src/Phalcon/{forms => Forms}/Form.php (93%) rename src/Phalcon/{forms => Forms}/Manager.php (79%) rename src/Phalcon/{helper => Helper}/Arr.php (88%) create mode 100644 src/Phalcon/Helper/Exception.php rename src/Phalcon/{helper => Helper}/Fs.php (70%) rename src/Phalcon/{helper => Helper}/Number.php (64%) rename src/Phalcon/{helper => Helper}/Str.php (96%) rename src/Phalcon/{html => Html}/Attributes.php (67%) rename src/Phalcon/{html/attributes => Html/Attributes}/AttributesInterface.php (68%) rename src/Phalcon/{html/attributes => Html/Attributes}/RenderInterface.php (57%) rename src/Phalcon/{html => Html}/Breadcrumbs.php (89%) create mode 100644 src/Phalcon/Html/Exception.php rename src/Phalcon/{html/helper => Html/Helper}/AbstractHelper.php (88%) rename src/Phalcon/{html/helper => Html/Helper}/Anchor.php (58%) rename src/Phalcon/{html/helper => Html/Helper}/AnchorRaw.php (58%) create mode 100644 src/Phalcon/Html/Helper/Body.php rename src/Phalcon/{html/helper => Html/Helper}/Button.php (55%) rename src/Phalcon/{html/helper => Html/Helper}/Close.php (57%) rename src/Phalcon/{html/helper => Html/Helper}/Element.php (58%) create mode 100644 src/Phalcon/Html/Helper/ElementRaw.php rename src/Phalcon/{html/helper => Html/Helper}/Form.php (50%) rename src/Phalcon/{html/helper => Html/Helper}/Img.php (56%) rename src/Phalcon/{html/helper => Html/Helper}/Label.php (63%) rename src/Phalcon/{html/helper => Html/Helper}/TextArea.php (55%) create mode 100644 src/Phalcon/Html/Link/EvolvableLink.php create mode 100644 src/Phalcon/Html/Link/EvolvableLinkProvider.php create mode 100644 src/Phalcon/Html/Link/Link.php create mode 100644 src/Phalcon/Html/Link/LinkProvider.php create mode 100644 src/Phalcon/Html/Link/Serializer/Header.php create mode 100644 src/Phalcon/Html/Link/Serializer/SerializerInterface.php rename src/Phalcon/{html => Html}/TagFactory.php (77%) rename src/Phalcon/{http => Http}/Cookie.php (94%) create mode 100644 src/Phalcon/Http/Cookie/Exception.php rename src/Phalcon/{http => Http}/CookieInterface.php (92%) rename src/Phalcon/{http/message => Http/Message}/AbstractCommon.php (71%) rename src/Phalcon/{http/message => Http/Message}/AbstractMessage.php (95%) rename src/Phalcon/{http/message => Http/Message}/AbstractRequest.php (92%) rename src/Phalcon/{http/message/exception => Http/Message/Exception}/InvalidArgumentException.php (62%) rename src/Phalcon/{http/message => Http/Message}/Request.php (56%) rename src/Phalcon/{http/message => Http/Message}/RequestFactory.php (64%) rename src/Phalcon/{http/message => Http/Message}/Response.php (90%) rename src/Phalcon/{http/message => Http/Message}/ResponseFactory.php (71%) rename src/Phalcon/{http/message => Http/Message}/ServerRequest.php (92%) rename src/Phalcon/{http/message => Http/Message}/ServerRequestFactory.php (89%) rename src/Phalcon/{http/message => Http/Message}/Stream.php (89%) rename src/Phalcon/{http/message/stream => Http/Message/Stream}/Input.php (88%) rename src/Phalcon/{http/message/stream => Http/Message/Stream}/Memory.php (67%) rename src/Phalcon/{http/message/stream => Http/Message/Stream}/Temp.php (67%) rename src/Phalcon/{http/message => Http/Message}/StreamFactory.php (81%) rename src/Phalcon/{http/message => Http/Message}/UploadedFile.php (92%) rename src/Phalcon/{http/message => Http/Message}/UploadedFileFactory.php (58%) rename src/Phalcon/{http/message => Http/Message}/Uri.php (97%) rename src/Phalcon/{http/message => Http/Message}/UriFactory.php (63%) rename src/Phalcon/{http => Http}/Request.php (96%) create mode 100644 src/Phalcon/Http/Request/Exception.php rename src/Phalcon/{http/request => Http/Request}/File.php (90%) rename src/Phalcon/{http/request => Http/Request}/FileInterface.php (83%) rename src/Phalcon/{http => Http}/RequestInterface.php (96%) rename src/Phalcon/{http => Http}/Response.php (94%) rename src/Phalcon/{http/response => Http/Response}/Cookies.php (90%) rename src/Phalcon/{http/response => Http/Response}/CookiesInterface.php (88%) create mode 100644 src/Phalcon/Http/Response/Exception.php rename src/Phalcon/{http/response => Http/Response}/Headers.php (79%) rename src/Phalcon/{http/response => Http/Response}/HeadersInterface.php (82%) rename src/Phalcon/{http => Http}/ResponseInterface.php (93%) rename src/Phalcon/{http/server => Http/Server}/AbstractMiddleware.php (81%) rename src/Phalcon/{http/server => Http/Server}/AbstractRequestHandler.php (73%) rename src/Phalcon/{image/adapter => Image/Adapter}/AbstractAdapter.php (92%) rename src/Phalcon/{image/adapter => Image/Adapter}/AdapterInterface.php (93%) rename src/Phalcon/{image/adapter => Image/Adapter}/Gd.php (90%) rename src/Phalcon/{image/adapter => Image/Adapter}/Imagick.php (91%) rename src/Phalcon/{image => Image}/Enum.php (68%) create mode 100644 src/Phalcon/Image/Exception.php rename src/Phalcon/{image => Image}/ImageFactory.php (75%) create mode 100644 src/Phalcon/Loader/Exception.php rename src/Phalcon/{logger/adapter => Logger/Adapter}/AbstractAdapter.php (80%) rename src/Phalcon/{logger/adapter => Logger/Adapter}/AdapterInterface.php (84%) rename src/Phalcon/{logger/adapter => Logger/Adapter}/Noop.php (73%) rename src/Phalcon/{logger/adapter => Logger/Adapter}/Stream.php (85%) rename src/Phalcon/{logger/adapter => Logger/Adapter}/Syslog.php (85%) rename src/Phalcon/{logger => Logger}/AdapterFactory.php (78%) create mode 100644 src/Phalcon/Logger/Exception.php rename src/Phalcon/{logger/formatter => Logger/Formatter}/AbstractFormatter.php (64%) rename src/Phalcon/{logger/formatter => Logger/Formatter}/FormatterInterface.php (62%) rename src/Phalcon/{logger/formatter => Logger/Formatter}/Json.php (76%) rename src/Phalcon/{logger/formatter => Logger/Formatter}/Line.php (86%) rename src/Phalcon/{logger => Logger}/Item.php (82%) rename src/Phalcon/{logger => Logger}/LoggerFactory.php (57%) create mode 100644 src/Phalcon/Messages/Exception.php rename src/Phalcon/{messages => Messages}/Message.php (83%) rename src/Phalcon/{messages => Messages}/MessageInterface.php (88%) rename src/Phalcon/{messages => Messages}/Messages.php (88%) rename src/Phalcon/{mvc => Mvc}/Application.php (90%) create mode 100644 src/Phalcon/Mvc/Application/Exception.php rename src/Phalcon/{mvc => Mvc}/Controller.php (78%) rename src/Phalcon/{mvc/controller => Mvc/Controller}/BindModelInterface.php (59%) create mode 100644 src/Phalcon/Mvc/ControllerInterface.php rename src/Phalcon/{mvc => Mvc}/Dispatcher.php (92%) create mode 100644 src/Phalcon/Mvc/Dispatcher/Exception.php rename src/Phalcon/{mvc => Mvc}/DispatcherInterface.php (70%) rename src/Phalcon/{mvc => Mvc}/EntityInterface.php (70%) rename src/Phalcon/{mvc => Mvc}/Micro.php (93%) rename src/Phalcon/{mvc/micro => Mvc/Micro}/Collection.php (94%) rename src/Phalcon/{mvc/micro => Mvc/Micro}/CollectionInterface.php (94%) create mode 100644 src/Phalcon/Mvc/Micro/Exception.php rename src/Phalcon/{mvc/micro => Mvc/Micro}/LazyLoader.php (76%) rename src/Phalcon/{mvc/micro => Mvc/Micro}/MiddlewareInterface.php (56%) rename src/Phalcon/{mvc => Mvc}/Model.php (94%) rename src/Phalcon/{mvc/model => Mvc/Model}/Behavior.php (82%) rename src/Phalcon/{mvc/model/behavior => Mvc/Model/Behavior}/SoftDelete.php (69%) rename src/Phalcon/{mvc/model/behavior => Mvc/Model/Behavior}/Timestampable.php (73%) rename src/Phalcon/{mvc/model => Mvc/Model}/BehaviorInterface.php (75%) rename src/Phalcon/{mvc/model => Mvc/Model}/Binder.php (89%) rename src/Phalcon/{mvc/model/binder => Mvc/Model/Binder}/BindableInterface.php (60%) rename src/Phalcon/{mvc/model => Mvc/Model}/BinderInterface.php (79%) rename src/Phalcon/{mvc/model => Mvc/Model}/Criteria.php (87%) rename src/Phalcon/{mvc/model => Mvc/Model}/CriteriaInterface.php (97%) create mode 100644 src/Phalcon/Mvc/Model/Exception.php rename src/Phalcon/{mvc/model => Mvc/Model}/Manager.php (87%) rename src/Phalcon/{mvc/model => Mvc/Model}/ManagerInterface.php (80%) rename src/Phalcon/{mvc/model => Mvc/Model}/MetaData.php (95%) rename src/Phalcon/{mvc/model/metadata => Mvc/Model/MetaData}/Apcu.php (78%) rename src/Phalcon/{mvc/model/metadata => Mvc/Model/MetaData}/Libmemcached.php (73%) rename src/Phalcon/{mvc/model/metadata => Mvc/Model/MetaData}/Memory.php (75%) rename src/Phalcon/{mvc/model/metadata => Mvc/Model/MetaData}/Redis.php (78%) rename src/Phalcon/{mvc/model/metadata/strategy/Introspection.php => Mvc/Model/MetaData/Strategy/Annotations.php} (59%) rename src/Phalcon/{mvc/model/metadata/strategy/Annotations.php => Mvc/Model/MetaData/Strategy/Introspection.php} (78%) rename src/Phalcon/{mvc/model/metadata/strategy => Mvc/Model/MetaData/Strategy}/StrategyInterface.php (81%) rename src/Phalcon/{mvc/model/metadata => Mvc/Model/MetaData}/Stream.php (80%) rename src/Phalcon/{mvc/model => Mvc/Model}/MetaDataInterface.php (95%) rename src/Phalcon/{mvc/model => Mvc/Model}/Query.php (88%) rename src/Phalcon/{mvc/model/query => Mvc/Model/Query}/Builder.php (90%) rename src/Phalcon/{mvc/model/query => Mvc/Model/Query}/BuilderInterface.php (97%) rename src/Phalcon/{mvc/model/query => Mvc/Model/Query}/Lang.php (82%) rename src/Phalcon/{mvc/model/query => Mvc/Model/Query}/Status.php (81%) rename src/Phalcon/{mvc/model/query => Mvc/Model/Query}/StatusInterface.php (68%) rename src/Phalcon/{mvc/model => Mvc/Model}/QueryInterface.php (91%) rename src/Phalcon/{mvc/model => Mvc/Model}/Relation.php (92%) rename src/Phalcon/{mvc/model => Mvc/Model}/RelationInterface.php (91%) rename src/Phalcon/{mvc/model => Mvc/Model}/ResultInterface.php (57%) rename src/Phalcon/{mvc/model => Mvc/Model}/Resultset.php (89%) rename src/Phalcon/{mvc/model/resultset => Mvc/Model/Resultset}/Complex.php (86%) rename src/Phalcon/{mvc/model/resultset => Mvc/Model/Resultset}/Simple.php (87%) rename src/Phalcon/{mvc/model => Mvc/Model}/ResultsetInterface.php (88%) rename src/Phalcon/{mvc/model => Mvc/Model}/Row.php (83%) rename src/Phalcon/{mvc/model => Mvc/Model}/Transaction.php (92%) rename src/Phalcon/{mvc/model/transaction => Mvc/Model/Transaction}/Exception.php (50%) rename src/Phalcon/{mvc/model/transaction => Mvc/Model/Transaction}/Failed.php (70%) rename src/Phalcon/{mvc/model/transaction => Mvc/Model/Transaction}/Manager.php (88%) rename src/Phalcon/{mvc/model/transaction => Mvc/Model/Transaction}/ManagerInterface.php (86%) rename src/Phalcon/{mvc/model => Mvc/Model}/TransactionInterface.php (88%) rename src/Phalcon/{mvc/model => Mvc/Model}/ValidationFailed.php (78%) rename src/Phalcon/{mvc => Mvc}/ModelInterface.php (94%) rename src/Phalcon/{mvc => Mvc}/ModuleDefinitionInterface.php (72%) rename src/Phalcon/{mvc => Mvc}/Router.php (92%) rename src/Phalcon/{mvc/router => Mvc/Router}/Annotations.php (92%) create mode 100644 src/Phalcon/Mvc/Router/Exception.php rename src/Phalcon/{mvc/router => Mvc/Router}/Group.php (94%) rename src/Phalcon/{mvc/router => Mvc/Router}/GroupInterface.php (89%) rename src/Phalcon/{mvc/router => Mvc/Router}/Route.php (93%) rename src/Phalcon/{mvc/router => Mvc/Router}/RouteInterface.php (91%) rename src/Phalcon/{mvc => Mvc}/RouterInterface.php (88%) rename src/Phalcon/{mvc => Mvc}/View.php (97%) rename src/Phalcon/{mvc/view/engine => Mvc/View/Engine}/AbstractEngine.php (74%) rename src/Phalcon/{mvc/view/engine => Mvc/View/Engine}/EngineInterface.php (73%) rename src/Phalcon/{mvc/view/engine => Mvc/View/Engine}/Php.php (55%) rename src/Phalcon/{mvc/view/engine => Mvc/View/Engine}/Volt.php (86%) rename src/Phalcon/{mvc/view/engine/volt => Mvc/View/Engine/Volt}/Compiler.php (97%) rename src/Phalcon/{mvc/view/engine/volt => Mvc/View/Engine/Volt}/Exception.php (66%) create mode 100644 src/Phalcon/Mvc/View/Exception.php rename src/Phalcon/{mvc/view => Mvc/View}/Simple.php (95%) rename src/Phalcon/{mvc => Mvc}/ViewBaseInterface.php (86%) rename src/Phalcon/{mvc => Mvc}/ViewInterface.php (93%) rename src/Phalcon/{paginator/adapter => Paginator/Adapter}/AbstractAdapter.php (78%) rename src/Phalcon/{paginator/adapter => Paginator/Adapter}/AdapterInterface.php (73%) create mode 100644 src/Phalcon/Paginator/Adapter/Model.php rename src/Phalcon/{paginator/adapter => Paginator/Adapter}/NativeArray.php (71%) rename src/Phalcon/{paginator/adapter => Paginator/Adapter}/QueryBuilder.php (81%) create mode 100644 src/Phalcon/Paginator/Exception.php rename src/Phalcon/{paginator => Paginator}/PaginatorFactory.php (84%) rename src/Phalcon/{paginator => Paginator}/Repository.php (88%) rename src/Phalcon/{paginator => Paginator}/RepositoryInterface.php (90%) create mode 100644 src/Phalcon/Security/Exception.php rename src/Phalcon/{security => Security}/Random.php (97%) rename src/Phalcon/{session/adapter => Session/Adapter}/AbstractAdapter.php (85%) rename src/Phalcon/{session/adapter => Session/Adapter}/Libmemcached.php (53%) rename src/Phalcon/{session/adapter => Session/Adapter}/Noop.php (89%) rename src/Phalcon/{session/adapter => Session/Adapter}/Redis.php (53%) rename src/Phalcon/{session/adapter => Session/Adapter}/Stream.php (85%) rename src/Phalcon/{session => Session}/Bag.php (81%) create mode 100644 src/Phalcon/Session/Exception.php rename src/Phalcon/{session => Session}/Manager.php (88%) rename src/Phalcon/{session => Session}/ManagerInterface.php (90%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/AbstractAdapter.php (92%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/AdapterInterface.php (88%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/Apcu.php (79%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/Libmemcached.php (85%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/Memory.php (80%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/Redis.php (84%) rename src/Phalcon/{storage/adapter => Storage/Adapter}/Stream.php (86%) rename src/Phalcon/{storage => Storage}/AdapterFactory.php (69%) create mode 100644 src/Phalcon/Storage/Exception.php rename src/Phalcon/{storage/serializer => Storage/Serializer}/AbstractSerializer.php (71%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/Base64.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/Igbinary.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/Json.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/Msgpack.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/None.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/Php.php (62%) rename src/Phalcon/{storage/serializer => Storage/Serializer}/SerializerInterface.php (66%) rename src/Phalcon/{storage => Storage}/SerializerFactory.php (78%) create mode 100644 src/Phalcon/Tag/Exception.php rename src/Phalcon/{tag => Tag}/Select.php (82%) rename src/Phalcon/{translate/adapter => Translate/Adapter}/AbstractAdapter.php (85%) rename src/Phalcon/{translate/adapter => Translate/Adapter}/AdapterInterface.php (79%) rename src/Phalcon/{translate/adapter => Translate/Adapter}/Csv.php (78%) rename src/Phalcon/{translate/adapter => Translate/Adapter}/Gettext.php (91%) rename src/Phalcon/{translate/adapter => Translate/Adapter}/NativeArray.php (79%) create mode 100644 src/Phalcon/Translate/Exception.php create mode 100644 src/Phalcon/Translate/Interpolator/AssociativeArray.php rename src/Phalcon/{translate/interpolator => Translate/Interpolator}/IndexedArray.php (64%) rename src/Phalcon/{translate/interpolator/AssociativeArray.php => Translate/Interpolator/InterpolatorInterface.php} (68%) rename src/Phalcon/{translate => Translate}/InterpolatorFactory.php (78%) rename src/Phalcon/{translate => Translate}/TranslateFactory.php (72%) create mode 100644 src/Phalcon/Url/Exception.php rename src/Phalcon/{url => Url}/UrlInterface.php (84%) create mode 100644 src/Phalcon/Validation/AbstractCombinedFieldsValidator.php rename src/Phalcon/{validation => Validation}/AbstractValidator.php (90%) rename src/Phalcon/{validation => Validation}/AbstractValidatorComposite.php (64%) create mode 100644 src/Phalcon/Validation/Exception.php rename src/Phalcon/{validation => Validation}/ValidationInterface.php (82%) rename src/Phalcon/{validation/validator => Validation/Validator}/Alnum.php (84%) rename src/Phalcon/{validation/validator => Validation/Validator}/Alpha.php (83%) rename src/Phalcon/{validation/validator => Validation/Validator}/Between.php (87%) rename src/Phalcon/{validation/validator => Validation/Validator}/Callback.php (87%) rename src/Phalcon/{validation/validator => Validation/Validator}/Confirmation.php (87%) rename src/Phalcon/{validation/validator => Validation/Validator}/CreditCard.php (86%) rename src/Phalcon/{validation/validator => Validation/Validator}/Date.php (86%) rename src/Phalcon/{validation/validator => Validation/Validator}/Digit.php (82%) rename src/Phalcon/{validation/validator => Validation/Validator}/Email.php (83%) create mode 100644 src/Phalcon/Validation/Validator/Exception.php rename src/Phalcon/{validation/validator => Validation/Validator}/ExclusionIn.php (86%) rename src/Phalcon/{validation/validator => Validation/Validator}/File.php (91%) rename src/Phalcon/{validation/validator/file => Validation/Validator/File}/AbstractFile.php (94%) rename src/Phalcon/{validation/validator/file => Validation/Validator/File}/MimeType.php (83%) rename src/Phalcon/{validation/validator/file/resolution => Validation/Validator/File/Resolution}/Equal.php (86%) rename src/Phalcon/{validation/validator/file/resolution => Validation/Validator/File/Resolution}/Max.php (87%) rename src/Phalcon/{validation/validator/file/resolution => Validation/Validator/File/Resolution}/Min.php (87%) rename src/Phalcon/{validation/validator/file/size => Validation/Validator/File/Size}/Equal.php (86%) rename src/Phalcon/{validation/validator/file/size => Validation/Validator/File/Size}/Max.php (86%) rename src/Phalcon/{validation/validator/file/size => Validation/Validator/File/Size}/Min.php (86%) rename src/Phalcon/{validation/validator => Validation/Validator}/Identical.php (85%) rename src/Phalcon/{validation/validator => Validation/Validator}/InclusionIn.php (85%) rename src/Phalcon/{validation/validator => Validation/Validator}/Ip.php (90%) rename src/Phalcon/{validation/validator => Validation/Validator}/Numericality.php (82%) rename src/Phalcon/{validation/validator => Validation/Validator}/PresenceOf.php (82%) rename src/Phalcon/{validation/validator => Validation/Validator}/Regex.php (86%) rename src/Phalcon/{validation/validator => Validation/Validator}/StringLength.php (90%) rename src/Phalcon/{validation/validator/stringlength => Validation/Validator/StringLength}/Max.php (87%) rename src/Phalcon/{validation/validator/stringlength => Validation/Validator/StringLength}/Min.php (87%) rename src/Phalcon/{validation/validator => Validation/Validator}/Uniqueness.php (92%) rename src/Phalcon/{validation/validator => Validation/Validator}/Url.php (82%) rename src/Phalcon/{validation => Validation}/ValidatorCompositeInterface.php (68%) rename src/Phalcon/{validation => Validation}/ValidatorFactory.php (65%) rename src/Phalcon/{validation => Validation}/ValidatorInterface.php (87%) delete mode 100644 src/Phalcon/acl/Enum.php delete mode 100644 src/Phalcon/acl/Exception.php delete mode 100644 src/Phalcon/annotations/Exception.php delete mode 100644 src/Phalcon/application/Exception.php delete mode 100644 src/Phalcon/assets/Exception.php delete mode 100644 src/Phalcon/cache/adapter/AdapterInterface.php delete mode 100644 src/Phalcon/cache/adapter/Apcu.php delete mode 100644 src/Phalcon/cache/adapter/Libmemcached.php delete mode 100644 src/Phalcon/cache/adapter/Memory.php delete mode 100644 src/Phalcon/cache/adapter/Redis.php delete mode 100644 src/Phalcon/cache/adapter/Stream.php delete mode 100644 src/Phalcon/cache/exception/Exception.php delete mode 100644 src/Phalcon/cache/exception/InvalidArgumentException.php delete mode 100644 src/Phalcon/cli/TaskInterface.php delete mode 100644 src/Phalcon/cli/console/Exception.php delete mode 100644 src/Phalcon/cli/dispatcher/Exception.php delete mode 100644 src/Phalcon/cli/router/Exception.php delete mode 100644 src/Phalcon/collection/Exception.php delete mode 100644 src/Phalcon/config/Exception.php delete mode 100644 src/Phalcon/crypt/Exception.php delete mode 100644 src/Phalcon/crypt/Mismatch.php delete mode 100644 src/Phalcon/db/Exception.php delete mode 100644 src/Phalcon/debug/Exception.php delete mode 100644 src/Phalcon/di/AbstractInjectionAware.php delete mode 100644 src/Phalcon/di/Exception.php delete mode 100644 src/Phalcon/di/exception/ServiceResolutionException.php delete mode 100644 src/Phalcon/domain/payload/PayloadFactory.php delete mode 100644 src/Phalcon/domain/payload/PayloadInterface.php delete mode 100644 src/Phalcon/escaper/Exception.php delete mode 100644 src/Phalcon/events/Exception.php delete mode 100644 src/Phalcon/filter/Exception.php delete mode 100644 src/Phalcon/firewall/Exception.php delete mode 100644 src/Phalcon/flash/Exception.php delete mode 100644 src/Phalcon/forms/Exception.php delete mode 100644 src/Phalcon/forms/element/Submit.php delete mode 100644 src/Phalcon/forms/element/TextArea.php delete mode 100644 src/Phalcon/helper/Exception.php delete mode 100644 src/Phalcon/html/Exception.php delete mode 100644 src/Phalcon/html/helper/Body.php delete mode 100644 src/Phalcon/html/helper/ElementRaw.php delete mode 100644 src/Phalcon/http/cookie/Exception.php delete mode 100644 src/Phalcon/http/request/Exception.php delete mode 100644 src/Phalcon/http/response/Exception.php delete mode 100644 src/Phalcon/loader/Exception.php delete mode 100644 src/Phalcon/logger/Exception.php delete mode 100644 src/Phalcon/logger/formatter/Syslog.php delete mode 100644 src/Phalcon/messages/Exception.php delete mode 100644 src/Phalcon/mvc/ControllerInterface.php delete mode 100644 src/Phalcon/mvc/application/Exception.php delete mode 100644 src/Phalcon/mvc/dispatcher/Exception.php delete mode 100644 src/Phalcon/mvc/micro/Exception.php delete mode 100644 src/Phalcon/mvc/model/Exception.php delete mode 100644 src/Phalcon/mvc/router/Exception.php delete mode 100644 src/Phalcon/mvc/view/Exception.php delete mode 100644 src/Phalcon/paginator/Exception.php delete mode 100644 src/Phalcon/paginator/adapter/Model.php delete mode 100644 src/Phalcon/security/Exception.php delete mode 100644 src/Phalcon/session/Exception.php delete mode 100644 src/Phalcon/storage/Exception.php delete mode 100644 src/Phalcon/tag/Exception.php delete mode 100644 src/Phalcon/translate/Exception.php delete mode 100644 src/Phalcon/translate/interpolator/InterpolatorInterface.php delete mode 100644 src/Phalcon/url/Exception.php delete mode 100644 src/Phalcon/validation/AbstractCombinedFieldsValidator.php delete mode 100644 src/Phalcon/validation/Exception.php delete mode 100644 src/Phalcon/validation/validator/Exception.php diff --git a/src/Phalcon/acl/adapter/AbstractAdapter.php b/src/Phalcon/Acl/Adapter/AbstractAdapter.php similarity index 83% rename from src/Phalcon/acl/adapter/AbstractAdapter.php rename to src/Phalcon/Acl/Adapter/AbstractAdapter.php index 96992459..70abf468 100644 --- a/src/Phalcon/acl/adapter/AbstractAdapter.php +++ b/src/Phalcon/Acl/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl\Adapter; use Phalcon\Events\ManagerInterface; @@ -7,7 +14,7 @@ /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Active access which the list is checking if some role can access it @@ -94,7 +101,7 @@ public function getDefaultAction(): int /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -104,6 +111,7 @@ public function getEventsManager(): ManagerInterface * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) * * @param int $defaultAccess + * @return void */ public function setDefaultAction(int $defaultAccess) { @@ -113,8 +121,10 @@ public function setDefaultAction(int $defaultAccess) * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/acl/adapter/AdapterInterface.php b/src/Phalcon/Acl/Adapter/AdapterInterface.php similarity index 92% rename from src/Phalcon/acl/adapter/AdapterInterface.php rename to src/Phalcon/Acl/Adapter/AdapterInterface.php index bd8a7852..0dba54ab 100644 --- a/src/Phalcon/acl/adapter/AdapterInterface.php +++ b/src/Phalcon/Acl/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl\Adapter; /** @@ -55,6 +62,7 @@ public function addComponentAccess(string $componentName, $accessList): bool; * @param string $componentName * @param mixed $access * @param mixed $func + * @return void */ public function allow(string $roleName, string $componentName, $access, $func = null); @@ -65,6 +73,7 @@ public function allow(string $roleName, string $componentName, $access, $func = * @param string $componentName * @param mixed $access * @param mixed $func + * @return void */ public function deny(string $roleName, string $componentName, $access, $func = null); @@ -73,6 +82,7 @@ public function deny(string $roleName, string $componentName, $access, $func = n * * @param string $componentName * @param mixed $accessList + * @return void */ public function dropComponentAccess(string $componentName, $accessList); @@ -117,14 +127,14 @@ public function getNoArgumentsDefaultAction(): int; /** * Return an array with every role registered in the list * - * @return array|\Phalcon\Acl\RoleInterface[] + * @return array */ public function getRoles(): array; /** * Return an array with every component registered in the list * - * @return array|\Phalcon\Acl\ComponentInterface[] + * @return array */ public function getComponents(): array; @@ -159,6 +169,7 @@ public function isRole(string $roleName): bool; * Sets the default access level (Phalcon\Ac\Enuml::ALLOW or Phalcon\Acl\Enum::DENY) * * @param int $defaultAccess + * @return void */ public function setDefaultAction(int $defaultAccess); @@ -168,6 +179,8 @@ public function setDefaultAction(int $defaultAccess); * accessKey * * @param int $defaultAccess + * @return void */ public function setNoArgumentsDefaultAction(int $defaultAccess); + } diff --git a/src/Phalcon/acl/adapter/Memory.php b/src/Phalcon/Acl/Adapter/Memory.php similarity index 96% rename from src/Phalcon/acl/adapter/Memory.php rename to src/Phalcon/Acl/Adapter/Memory.php index 21231cb4..04f635ce 100644 --- a/src/Phalcon/acl/adapter/Memory.php +++ b/src/Phalcon/Acl/Adapter/Memory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl\Adapter; use Phalcon\Acl\Enum; @@ -67,7 +74,7 @@ * } * ``` */ -class Memory extends AbstractAdapter +class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter { /** * Access @@ -298,6 +305,7 @@ public function addRole($role, $accessInherits = null): bool * @param string $componentName * @param mixed $access * @param mixed $func + * @return void */ public function allow(string $roleName, string $componentName, $access, $func = null) { @@ -324,6 +332,7 @@ public function allow(string $roleName, string $componentName, $access, $func = * @param string $componentName * @param mixed $access * @param mixed $func + * @return void */ public function deny(string $roleName, string $componentName, $access, $func = null) { @@ -334,6 +343,7 @@ public function deny(string $roleName, string $componentName, $access, $func = n * * @param string $componentName * @param mixed $accessList + * @return void */ public function dropComponentAccess(string $componentName, $accessList) { @@ -352,7 +362,7 @@ public function getNoArgumentsDefaultAction(): int /** * Return an array with every role registered in the list * - * @return array|\Phalcon\Acl\RoleInterface[] + * @return array */ public function getRoles(): array { @@ -361,7 +371,7 @@ public function getRoles(): array /** * Return an array with every component registered in the list * - * @return array|\Phalcon\Acl\ComponentInterface[] + * @return array */ public function getComponents(): array { @@ -414,6 +424,7 @@ public function isComponent(string $componentName): bool * accessKey * * @param int $defaultAccess + * @return void */ public function setNoArgumentsDefaultAction(int $defaultAccess) { @@ -427,6 +438,7 @@ public function setNoArgumentsDefaultAction(int $defaultAccess) * @param mixed $access * @param mixed $action * @param mixed $func + * @return void */ private function allowOrDeny(string $roleName, string $componentName, $access, $action, $func = null) { @@ -443,4 +455,5 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } + } diff --git a/src/Phalcon/acl/Component.php b/src/Phalcon/Acl/Component.php similarity index 75% rename from src/Phalcon/acl/Component.php rename to src/Phalcon/Acl/Component.php index 8f068fd1..6f7a986d 100644 --- a/src/Phalcon/acl/Component.php +++ b/src/Phalcon/Acl/Component.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** * This class defines component entity and its description */ -class Component implements \Phalcon\Acl\ComponentInterface +class Component implements Phalcon\Acl\ComponentInterface { /** * Component description @@ -58,4 +65,5 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/acl/ComponentAware.php b/src/Phalcon/Acl/ComponentAware.php similarity index 53% rename from src/Phalcon/acl/ComponentAware.php rename to src/Phalcon/Acl/ComponentAware.php index 412164f1..37b68783 100644 --- a/src/Phalcon/acl/ComponentAware.php +++ b/src/Phalcon/Acl/ComponentAware.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** @@ -14,4 +21,5 @@ interface ComponentAware * @return string */ public function getComponentName(): string; + } diff --git a/src/Phalcon/acl/ComponentInterface.php b/src/Phalcon/Acl/ComponentInterface.php similarity index 67% rename from src/Phalcon/acl/ComponentInterface.php rename to src/Phalcon/Acl/ComponentInterface.php index 2a98bb5b..92284e37 100644 --- a/src/Phalcon/acl/ComponentInterface.php +++ b/src/Phalcon/Acl/ComponentInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** @@ -28,4 +35,5 @@ public function getName(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/Acl/Enum.php b/src/Phalcon/Acl/Enum.php new file mode 100644 index 00000000..31c3e271 --- /dev/null +++ b/src/Phalcon/Acl/Enum.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Acl; + +/** + * Constants for Phalcon\Acl\Adapter adapters + */ +class Enum +{ + + const ALLOW = 1; + + + const DENY = 0; + + +} diff --git a/src/Phalcon/factory/Exception.php b/src/Phalcon/Acl/Exception.php similarity index 66% rename from src/Phalcon/factory/Exception.php rename to src/Phalcon/Acl/Exception.php index 05f51397..2f61c57f 100644 --- a/src/Phalcon/factory/Exception.php +++ b/src/Phalcon/Acl/Exception.php @@ -1,15 +1,17 @@ * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ +namespace Phalcon\Acl; + +/** + * Class for exceptions thrown by Phalcon\Acl + */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/acl/Role.php b/src/Phalcon/Acl/Role.php similarity index 75% rename from src/Phalcon/acl/Role.php rename to src/Phalcon/Acl/Role.php index 563e1dc0..b127b2c7 100644 --- a/src/Phalcon/acl/Role.php +++ b/src/Phalcon/Acl/Role.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** * This class defines role entity and its description */ -class Role implements \Phalcon\Acl\RoleInterface +class Role implements Phalcon\Acl\RoleInterface { /** * Role name @@ -58,4 +65,5 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/acl/RoleAware.php b/src/Phalcon/Acl/RoleAware.php similarity index 52% rename from src/Phalcon/acl/RoleAware.php rename to src/Phalcon/Acl/RoleAware.php index b568a8bf..2f1a3fb9 100644 --- a/src/Phalcon/acl/RoleAware.php +++ b/src/Phalcon/Acl/RoleAware.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** @@ -14,4 +21,5 @@ interface RoleAware * @return string */ public function getRoleName(): string; + } diff --git a/src/Phalcon/acl/RoleInterface.php b/src/Phalcon/Acl/RoleInterface.php similarity index 66% rename from src/Phalcon/acl/RoleInterface.php rename to src/Phalcon/Acl/RoleInterface.php index 0d22ff31..edfc723a 100644 --- a/src/Phalcon/acl/RoleInterface.php +++ b/src/Phalcon/Acl/RoleInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Acl; /** @@ -28,4 +35,5 @@ public function getDescription(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/annotations/adapter/AbstractAdapter.php b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php similarity index 81% rename from src/Phalcon/annotations/adapter/AbstractAdapter.php rename to src/Phalcon/Annotations/Adapter/AbstractAdapter.php index a1c84925..42b046a9 100644 --- a/src/Phalcon/annotations/adapter/AbstractAdapter.php +++ b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations\Adapter; use Phalcon\Annotations\Collection; @@ -10,7 +17,7 @@ /** * This is the base class for Phalcon\Annotations adapters */ -abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Annotations\Adapter\AdapterInterface { /** * @var array @@ -27,7 +34,7 @@ abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterIn * Parses or retrieves all the annotations found in a class * * @param mixed $className - * @return \Phalcon\Annotations\Reflection + * @return Reflection */ public function get($className): Reflection { @@ -38,7 +45,7 @@ public function get($className): Reflection * * @param string $className * @param string $methodName - * @return \Phalcon\Annotations\Collection + * @return Collection */ public function getMethod(string $className, string $methodName): Collection { @@ -59,7 +66,7 @@ public function getMethods(string $className): array * * @param string $className * @param string $propertyName - * @return \Phalcon\Annotations\Collection + * @return Collection */ public function getProperty(string $className, string $propertyName): Collection { @@ -78,7 +85,7 @@ public function getProperties(string $className): array /** * Returns the annotation reader * - * @return \Phalcon\Annotations\ReaderInterface + * @return ReaderInterface */ public function getReader(): ReaderInterface { @@ -92,4 +99,5 @@ public function getReader(): ReaderInterface public function setReader(\Phalcon\Annotations\ReaderInterface $reader) { } + } diff --git a/src/Phalcon/annotations/adapter/AdapterInterface.php b/src/Phalcon/Annotations/Adapter/AdapterInterface.php similarity index 82% rename from src/Phalcon/annotations/adapter/AdapterInterface.php rename to src/Phalcon/Annotations/Adapter/AdapterInterface.php index e316bb87..ca7dbadc 100644 --- a/src/Phalcon/annotations/adapter/AdapterInterface.php +++ b/src/Phalcon/Annotations/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations\Adapter; use Phalcon\Annotations\Collection; @@ -16,7 +23,7 @@ interface AdapterInterface * Parses or retrieves all the annotations found in a class * * @param string $className - * @return \Phalcon\Annotations\Reflection + * @return Reflection */ public function get(string $className): Reflection; @@ -25,7 +32,7 @@ public function get(string $className): Reflection; * * @param string $className * @param string $methodName - * @return \Phalcon\Annotations\Collection + * @return Collection */ public function getMethod(string $className, string $methodName): Collection; @@ -42,7 +49,7 @@ public function getMethods(string $className): array; * * @param string $className * @param string $propertyName - * @return \Phalcon\Annotations\Collection + * @return Collection */ public function getProperty(string $className, string $propertyName): Collection; @@ -57,7 +64,7 @@ public function getProperties(string $className): array; /** * Returns the annotation reader * - * @return \Phalcon\Annotations\ReaderInterface + * @return ReaderInterface */ public function getReader(): ReaderInterface; @@ -67,4 +74,5 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); + } diff --git a/src/Phalcon/annotations/adapter/Apcu.php b/src/Phalcon/Annotations/Adapter/Apcu.php similarity index 75% rename from src/Phalcon/annotations/adapter/Apcu.php rename to src/Phalcon/Annotations/Adapter/Apcu.php index 434ce2e9..a34bb2d2 100644 --- a/src/Phalcon/annotations/adapter/Apcu.php +++ b/src/Phalcon/Annotations/Adapter/Apcu.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations\Adapter; /** @@ -11,7 +18,7 @@ * $annotations = new Apcu(); * ``` */ -class Apcu extends AbstractAdapter +class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter { /** * @var string @@ -37,7 +44,7 @@ public function __construct(array $options = array()) * Reads parsed annotations from APCu * * @param string $key - * @return bool|\Phalcon\Annotations\Reflection + * @return mixed */ public function read(string $key) { @@ -53,4 +60,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data): bool { } + } diff --git a/src/Phalcon/annotations/adapter/Memory.php b/src/Phalcon/Annotations/Adapter/Memory.php similarity index 63% rename from src/Phalcon/annotations/adapter/Memory.php rename to src/Phalcon/Annotations/Adapter/Memory.php index 1a70e83b..ed7d5e6a 100644 --- a/src/Phalcon/annotations/adapter/Memory.php +++ b/src/Phalcon/Annotations/Adapter/Memory.php @@ -1,12 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations\Adapter; /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing */ -class Memory extends AbstractAdapter +class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter { /** * @var mixed @@ -18,7 +25,7 @@ class Memory extends AbstractAdapter * Reads parsed annotations from memory * * @param string $key - * @return bool|\Phalcon\Annotations\Reflection + * @return mixed */ public function read(string $key) { @@ -29,8 +36,10 @@ public function read(string $key) * * @param string $key * @param \Phalcon\Annotations\Reflection $data + * @return void */ public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/annotations/adapter/Stream.php b/src/Phalcon/Annotations/Adapter/Stream.php similarity index 73% rename from src/Phalcon/annotations/adapter/Stream.php rename to src/Phalcon/Annotations/Adapter/Stream.php index 6ef35cde..56ff5b87 100644 --- a/src/Phalcon/annotations/adapter/Stream.php +++ b/src/Phalcon/Annotations/Adapter/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations\Adapter; /** @@ -15,7 +22,7 @@ * ); * ``` */ -class Stream extends AbstractAdapter +class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter { /** * @var string @@ -36,7 +43,7 @@ public function __construct(array $options = array()) * Reads parsed annotations from files * * @param string $key - * @return bool|int|\Phalcon\Annotations\Reflection + * @return mixed */ public function read(string $key) { @@ -47,8 +54,10 @@ public function read(string $key) * * @param string $key * @param \Phalcon\Annotations\Reflection $data + * @return void */ public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/annotations/Annotation.php b/src/Phalcon/Annotations/Annotation.php similarity index 89% rename from src/Phalcon/annotations/Annotation.php rename to src/Phalcon/Annotations/Annotation.php index 3e108679..9ef3dd5c 100644 --- a/src/Phalcon/annotations/Annotation.php +++ b/src/Phalcon/Annotations/Annotation.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; /** @@ -121,4 +128,5 @@ public function hasArgument($position): bool public function numberArguments(): int { } + } diff --git a/src/Phalcon/annotations/AnnotationsFactory.php b/src/Phalcon/Annotations/AnnotationsFactory.php similarity index 71% rename from src/Phalcon/annotations/AnnotationsFactory.php rename to src/Phalcon/Annotations/AnnotationsFactory.php index 1879fbe6..1775f423 100644 --- a/src/Phalcon/annotations/AnnotationsFactory.php +++ b/src/Phalcon/Annotations/AnnotationsFactory.php @@ -1,8 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; -use Phalcon\Annotations\Adapter\AbstractAdapter; +use Phalcon\Annotations\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; /** @@ -35,9 +42,9 @@ public function load($config) * * @param string $name * @param array $options - * @return \Phalcon\Annotations\Adapter\AbstractAdapter + * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AbstractAdapter + public function newInstance(string $name, array $options = array()): AdapterInterface { } @@ -49,4 +56,5 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } + } diff --git a/src/Phalcon/annotations/Collection.php b/src/Phalcon/Annotations/Collection.php similarity index 86% rename from src/Phalcon/annotations/Collection.php rename to src/Phalcon/Annotations/Collection.php index fbe9063f..5f58c604 100644 --- a/src/Phalcon/annotations/Collection.php +++ b/src/Phalcon/Annotations/Collection.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; /** @@ -53,7 +60,7 @@ public function count(): int /** * Returns the current annotation in the iterator * - * @return bool|\Phalcon\Annotations\Annotation + * @return mixed */ public function current() { @@ -63,7 +70,7 @@ public function current() * Returns the first annotation that match a name * * @param string $name - * @return \Phalcon\Annotations\Annotation + * @return Annotation */ public function get(string $name): Annotation { @@ -73,7 +80,7 @@ public function get(string $name): Annotation * Returns all the annotations that match a name * * @param string $name - * @return array|\Phalcon\Annotations\Annotation[] + * @return array */ public function getAll(string $name): array { @@ -82,7 +89,7 @@ public function getAll(string $name): array /** * Returns the internal annotations as an array * - * @return array|\Phalcon\Annotations\Annotation[] + * @return array */ public function getAnnotations(): array { @@ -109,6 +116,8 @@ public function key(): int /** * Moves the internal iteration pointer to the next position + * + * @return void */ public function next() { @@ -116,6 +125,8 @@ public function next() /** * Rewinds the internal iterator + * + * @return void */ public function rewind() { @@ -129,4 +140,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/Annotations/Exception.php b/src/Phalcon/Annotations/Exception.php new file mode 100644 index 00000000..cb1aad5b --- /dev/null +++ b/src/Phalcon/Annotations/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations; + +/** + * Class for exceptions thrown by Phalcon\Annotations + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/annotations/Reader.php b/src/Phalcon/Annotations/Reader.php similarity index 68% rename from src/Phalcon/annotations/Reader.php rename to src/Phalcon/Annotations/Reader.php index d9e3f689..5552bc46 100644 --- a/src/Phalcon/annotations/Reader.php +++ b/src/Phalcon/Annotations/Reader.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; /** * Parses docblocks returning an array with the found annotations */ -class Reader implements \Phalcon\Annotations\ReaderInterface +class Reader implements Phalcon\Annotations\ReaderInterface { /** @@ -29,4 +36,5 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } + } diff --git a/src/Phalcon/annotations/ReaderInterface.php b/src/Phalcon/Annotations/ReaderInterface.php similarity index 73% rename from src/Phalcon/annotations/ReaderInterface.php rename to src/Phalcon/Annotations/ReaderInterface.php index 0d319b13..a8cc3f42 100644 --- a/src/Phalcon/annotations/ReaderInterface.php +++ b/src/Phalcon/Annotations/ReaderInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; /** @@ -25,4 +32,5 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; + } diff --git a/src/Phalcon/annotations/Reflection.php b/src/Phalcon/Annotations/Reflection.php similarity index 83% rename from src/Phalcon/annotations/Reflection.php rename to src/Phalcon/Annotations/Reflection.php index 5d73a94b..00ddc477 100644 --- a/src/Phalcon/annotations/Reflection.php +++ b/src/Phalcon/Annotations/Reflection.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Annotations; /** @@ -49,7 +56,7 @@ public function __construct(array $reflectionData = array()) /** * Returns the annotations found in the class docblock * - * @return bool|\Phalcon\Annotations\Collection + * @return mixed */ public function getClassAnnotations() { @@ -58,7 +65,7 @@ public function getClassAnnotations() /** * Returns the annotations found in the methods' docblocks * - * @return array|bool|\Phalcon\Annotations\Collection[] + * @return array|bool */ public function getMethodsAnnotations() { @@ -67,7 +74,7 @@ public function getMethodsAnnotations() /** * Returns the annotations found in the properties' docblocks * - * @return array|bool|\Phalcon\Annotations\Collection[] + * @return array|bool */ public function getPropertiesAnnotations() { @@ -82,4 +89,5 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } + } diff --git a/src/Phalcon/application/AbstractApplication.php b/src/Phalcon/Application/AbstractApplication.php similarity index 90% rename from src/Phalcon/application/AbstractApplication.php rename to src/Phalcon/Application/AbstractApplication.php index 52f5e994..6cf9b5d4 100644 --- a/src/Phalcon/application/AbstractApplication.php +++ b/src/Phalcon/Application/AbstractApplication.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Application; use Phalcon\Di\DiInterface; @@ -53,7 +60,7 @@ public function getDefaultModule(): string /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -118,8 +125,10 @@ public function setDefaultModule(string $defaultModule): AbstractApplication * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/Application/Exception.php b/src/Phalcon/Application/Exception.php new file mode 100644 index 00000000..dd402a69 --- /dev/null +++ b/src/Phalcon/Application/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Application; + +/** + * Exceptions thrown in Phalcon\Application class will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/assets/Asset.php b/src/Phalcon/Assets/Asset.php similarity index 94% rename from src/Phalcon/assets/Asset.php rename to src/Phalcon/Assets/Asset.php index b65b304b..b9604235 100644 --- a/src/Phalcon/assets/Asset.php +++ b/src/Phalcon/Assets/Asset.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; /** @@ -9,7 +16,7 @@ * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); * ``` */ -class Asset implements \Phalcon\Assets\AssetInterface +class Asset implements Phalcon\Assets\AssetInterface { /** * @var array | null @@ -297,4 +304,5 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } + } diff --git a/src/Phalcon/assets/asset/Css.php b/src/Phalcon/Assets/Asset/Css.php similarity index 70% rename from src/Phalcon/assets/asset/Css.php rename to src/Phalcon/Assets/Asset/Css.php index 4ee16acd..d3cdc4e1 100644 --- a/src/Phalcon/assets/asset/Css.php +++ b/src/Phalcon/Assets/Asset/Css.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Asset; /** @@ -21,4 +28,5 @@ class Css extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/assets/asset/Js.php b/src/Phalcon/Assets/Asset/Js.php similarity index 70% rename from src/Phalcon/assets/asset/Js.php rename to src/Phalcon/Assets/Asset/Js.php index 07e78f19..7f795ede 100644 --- a/src/Phalcon/assets/asset/Js.php +++ b/src/Phalcon/Assets/Asset/Js.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Asset; /** @@ -21,4 +28,5 @@ class Js extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/assets/AssetInterface.php b/src/Phalcon/Assets/AssetInterface.php similarity index 83% rename from src/Phalcon/assets/AssetInterface.php rename to src/Phalcon/Assets/AssetInterface.php index 44bbc9ea..b43c3ac9 100644 --- a/src/Phalcon/assets/AssetInterface.php +++ b/src/Phalcon/Assets/AssetInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; /** @@ -59,4 +66,5 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; + } diff --git a/src/Phalcon/assets/Collection.php b/src/Phalcon/Assets/Collection.php similarity index 94% rename from src/Phalcon/assets/Collection.php rename to src/Phalcon/Assets/Collection.php index e81ae5af..430013f2 100644 --- a/src/Phalcon/assets/Collection.php +++ b/src/Phalcon/Assets/Collection.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; /** @@ -233,20 +240,20 @@ public function addCss(string $path, $local = null, bool $filter = true, $attrib /** * Adds a filter to the collection * - * @param \Phalcon\Assets\FilterInterface $filter + * @param FilterInterface $filter * @return Collection */ - public function addFilter(\Phalcon\Assets\FilterInterface $filter): Collection + public function addFilter(FilterInterface $filter): Collection { } /** * Adds an inline code to the collection * - * @param \Phalcon\Assets\Inline $code + * @param Inline $code * @return Collection */ - public function addInline(\Phalcon\Assets\Inline $code): Collection + public function addInline(Inline $code): Collection { } @@ -301,7 +308,7 @@ public function count(): int /** * Returns the current asset in the iterator * - * @return \Phalcon\Assets\Asset + * @return Asset */ public function current(): Asset { @@ -371,6 +378,8 @@ public function key(): int /** * Moves the internal iteration pointer to the next position + * + * @return void */ public function next() { @@ -378,6 +387,8 @@ public function next() /** * Rewinds the internal iterator + * + * @return void */ public function rewind() { @@ -481,4 +492,5 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } + } diff --git a/src/Phalcon/Assets/Exception.php b/src/Phalcon/Assets/Exception.php new file mode 100644 index 00000000..6ec2c5b5 --- /dev/null +++ b/src/Phalcon/Assets/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Assets; + +/** + * Exceptions thrown in Phalcon\Assets will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/assets/FilterInterface.php b/src/Phalcon/Assets/FilterInterface.php similarity index 58% rename from src/Phalcon/assets/FilterInterface.php rename to src/Phalcon/Assets/FilterInterface.php index f933b5ed..9fdbdef2 100644 --- a/src/Phalcon/assets/FilterInterface.php +++ b/src/Phalcon/Assets/FilterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; /** @@ -15,4 +22,5 @@ interface FilterInterface * @return string */ public function filter(string $content): string; + } diff --git a/src/Phalcon/assets/filters/Cssmin.php b/src/Phalcon/Assets/Filters/Cssmin.php similarity index 67% rename from src/Phalcon/assets/filters/Cssmin.php rename to src/Phalcon/Assets/Filters/Cssmin.php index fe03b48b..8bfc92fa 100644 --- a/src/Phalcon/assets/filters/Cssmin.php +++ b/src/Phalcon/Assets/Filters/Cssmin.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Filters; /** @@ -19,4 +26,5 @@ class Cssmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/filters/Jsmin.php b/src/Phalcon/Assets/Filters/Jsmin.php similarity index 71% rename from src/Phalcon/assets/filters/Jsmin.php rename to src/Phalcon/Assets/Filters/Jsmin.php index 691af3bf..822c0515 100644 --- a/src/Phalcon/assets/filters/Jsmin.php +++ b/src/Phalcon/Assets/Filters/Jsmin.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Filters; /** @@ -20,4 +27,5 @@ class Jsmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/filters/None.php b/src/Phalcon/Assets/Filters/None.php similarity index 61% rename from src/Phalcon/assets/filters/None.php rename to src/Phalcon/Assets/Filters/None.php index 7b07ff7f..85509aed 100644 --- a/src/Phalcon/assets/filters/None.php +++ b/src/Phalcon/Assets/Filters/None.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Filters; /** @@ -17,4 +24,5 @@ class None implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/assets/Inline.php b/src/Phalcon/Assets/Inline.php similarity index 86% rename from src/Phalcon/assets/Inline.php rename to src/Phalcon/Assets/Inline.php index 6cffc46d..ea47a56b 100644 --- a/src/Phalcon/assets/Inline.php +++ b/src/Phalcon/Assets/Inline.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; /** @@ -9,7 +16,7 @@ * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); * ``` */ -class Inline implements \Phalcon\Assets\AssetInterface +class Inline implements Phalcon\Assets\AssetInterface { /** * @var array | null @@ -110,4 +117,5 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } + } diff --git a/src/Phalcon/assets/inline/Css.php b/src/Phalcon/Assets/Inline/Css.php similarity index 62% rename from src/Phalcon/assets/inline/Css.php rename to src/Phalcon/Assets/Inline/Css.php index ed9f6c35..f1920e72 100644 --- a/src/Phalcon/assets/inline/Css.php +++ b/src/Phalcon/Assets/Inline/Css.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Inline; /** @@ -18,4 +25,5 @@ class Css extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/assets/inline/Js.php b/src/Phalcon/Assets/Inline/Js.php similarity index 63% rename from src/Phalcon/assets/inline/Js.php rename to src/Phalcon/Assets/Inline/Js.php index 3606be6b..6d332d4b 100644 --- a/src/Phalcon/assets/inline/Js.php +++ b/src/Phalcon/Assets/Inline/Js.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets\Inline; /** @@ -18,4 +25,5 @@ class Js extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/assets/Manager.php b/src/Phalcon/Assets/Manager.php similarity index 86% rename from src/Phalcon/assets/Manager.php rename to src/Phalcon/Assets/Manager.php index e618f536..5ffeb528 100644 --- a/src/Phalcon/assets/Manager.php +++ b/src/Phalcon/Assets/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Assets; use Phalcon\Di\AbstractInjectionAware; @@ -45,10 +52,10 @@ public function __construct(array $options = array()) * ); * ``` * - * @param \Phalcon\Assets\Asset $asset + * @param Asset $asset * @return Manager */ - public function addAsset(\Phalcon\Assets\Asset $asset): Manager + public function addAsset(Asset $asset): Manager { } @@ -63,10 +70,10 @@ public function addAsset(\Phalcon\Assets\Asset $asset): Manager * ``` * * @param string $type - * @param \Phalcon\Assets\Asset $asset + * @param Asset $asset * @return Manager */ - public function addAssetByType(string $type, \Phalcon\Assets\Asset $asset): Manager + public function addAssetByType(string $type, Asset $asset): Manager { } @@ -159,7 +166,7 @@ public function addJs(string $path, $local = true, bool $filter = true, $attribu * Creates/Returns a collection of assets * * @param string $name - * @return \Phalcon\Assets\Collection + * @return Collection */ public function collection(string $name): Collection { @@ -201,7 +208,7 @@ public function exists(string $id): bool * ``` * * @param string $id - * @return \Phalcon\Assets\Collection + * @return Collection */ public function get(string $id): Collection { @@ -210,7 +217,7 @@ public function get(string $id): Collection /** * Returns existing collections in the manager * - * @return array|\Phalcon\Assets\Collection[] + * @return array */ public function getCollections(): array { @@ -219,7 +226,7 @@ public function getCollections(): array /** * Returns the CSS collection of assets * - * @return \Phalcon\Assets\Collection + * @return Collection */ public function getCss(): Collection { @@ -228,7 +235,7 @@ public function getCss(): Collection /** * Returns the CSS collection of assets * - * @return \Phalcon\Assets\Collection + * @return Collection */ public function getJs(): Collection { @@ -248,10 +255,10 @@ public function getOptions(): array * * @param callback $callback * @param string $type - * @param \Phalcon\Assets\Collection $collection + * @param Collection $collection * @return string|null */ - public function output(\Phalcon\Assets\Collection $collection, $callback, $type): ?string + public function output(Collection $collection, $callback, $type): ?string { } @@ -269,10 +276,10 @@ public function outputCss(string $collectionName = null): string * Traverses a collection and generate its HTML * * @param string $type - * @param \Phalcon\Assets\Collection $collection + * @param Collection $collection * @return string */ - public function outputInline(\Phalcon\Assets\Collection $collection, $type): string + public function outputInline(Collection $collection, $type): string { } @@ -314,10 +321,10 @@ public function outputJs(string $collectionName = null): string * ``` * * @param string $id - * @param \Phalcon\Assets\Collection $collection + * @param Collection $collection * @return Manager */ - public function set(string $id, \Phalcon\Assets\Collection $collection): Manager + public function set(string $id, Collection $collection): Manager { } @@ -344,11 +351,12 @@ public function useImplicitOutput(bool $implicitOutput): Manager /** * Returns the prefixed path * - * @param \Phalcon\Assets\Collection $collection + * @param Collection $collection * @param string $path * @return string */ - private function getPrefixedPath(\Phalcon\Assets\Collection $collection, string $path): string + private function getPrefixedPath(Collection $collection, string $path): string { } + } diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index 40cd8611..0540bd23 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Cache\Adapter\AdapterInterface; @@ -23,7 +30,7 @@ class Cache implements \Psr\SimpleCache\CacheInterface /** * The adapter * - * @return AdapterInterface + * @return mixed */ public function getAdapter() { @@ -76,8 +83,8 @@ public function deleteMultiple($keys): bool /** * Fetches a value from the cache. * - * @param string $key The unique key of this item in the cache. - * @param mixed $defaultValue Default value to return if the key does not exist. + * @param string $key The unique key of this item in the cache. + * @param mixed $defaultValue Default value to return if the key does not exist. * * @return mixed The value of the item from the cache, or $default in case of cache miss. * @@ -90,8 +97,8 @@ public function get($key, $defaultValue = null) /** * Obtains multiple cache items by their unique keys. * - * @param iterable $keys A list of keys that can obtained in a single operation. - * @param mixed $defaultValue Default value to return for keys that do not exist. + * @param iterable $keys A list of keys that can obtained in a single operation. + * @param mixed $defaultValue Default value to return for keys that do not exist. * * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. * @@ -117,9 +124,9 @@ public function has($key): bool /** * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. * - * @param string $key The key of the item to store. - * @param mixed $value The value of the item to store. Must be serializable. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param string $key The key of the item to store. + * @param mixed $value The value of the item to store. Must be serializable. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -134,8 +141,8 @@ public function set($key, $value, $ttl = null): bool /** * Persists a set of key => value pairs in the cache, with an optional TTL. * - * @param iterable $values A list of key => value pairs for a multiple-set operation. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -151,6 +158,7 @@ public function setMultiple($values, $ttl = null): bool * Checks the key. If it contains invalid characters an exception is thrown * * @param mixed $key + * @return void */ protected function checkKey($key) { @@ -160,8 +168,10 @@ protected function checkKey($key) * Checks the key. If it contains invalid characters an exception is thrown * * @param mixed $keys + * @return void */ protected function checkKeys($keys) { } + } diff --git a/src/Phalcon/Cache/Adapter/AdapterInterface.php b/src/Phalcon/Cache/Adapter/AdapterInterface.php new file mode 100644 index 00000000..d22f7ece --- /dev/null +++ b/src/Phalcon/Cache/Adapter/AdapterInterface.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Storage\Adapter\AdapterInterface as StorageAdapterInterface; + +/** + * Interface for Phalcon\Cache adapters + */ +interface AdapterInterface extends StorageAdapterInterface +{ + +} diff --git a/src/Phalcon/Cache/Adapter/Apcu.php b/src/Phalcon/Cache/Adapter/Apcu.php new file mode 100644 index 00000000..01481ad0 --- /dev/null +++ b/src/Phalcon/Cache/Adapter/Apcu.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; + +/** + * Apcu adapter + */ +class Apcu extends \Phalcon\Storage\Adapter\Apcu implements CacheAdapterInterface +{ + +} diff --git a/src/Phalcon/Cache/Adapter/Libmemcached.php b/src/Phalcon/Cache/Adapter/Libmemcached.php new file mode 100644 index 00000000..43526134 --- /dev/null +++ b/src/Phalcon/Cache/Adapter/Libmemcached.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; + +/** + * Libmemcached adapter + */ +class Libmemcached extends \Phalcon\Storage\Adapter\Libmemcached implements CacheAdapterInterface +{ + +} diff --git a/src/Phalcon/Cache/Adapter/Memory.php b/src/Phalcon/Cache/Adapter/Memory.php new file mode 100644 index 00000000..4cbe2d5e --- /dev/null +++ b/src/Phalcon/Cache/Adapter/Memory.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; + +/** + * Memory adapter + */ +class Memory extends \Phalcon\Storage\Adapter\Memory implements CacheAdapterInterface +{ + +} diff --git a/src/Phalcon/Cache/Adapter/Redis.php b/src/Phalcon/Cache/Adapter/Redis.php new file mode 100644 index 00000000..c3c8ce7a --- /dev/null +++ b/src/Phalcon/Cache/Adapter/Redis.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; + +/** + * Redis adapter + */ +class Redis extends \Phalcon\Storage\Adapter\Redis implements CacheAdapterInterface +{ + +} diff --git a/src/Phalcon/Cache/Adapter/Stream.php b/src/Phalcon/Cache/Adapter/Stream.php new file mode 100644 index 00000000..7002ae87 --- /dev/null +++ b/src/Phalcon/Cache/Adapter/Stream.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Adapter; + +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; + +/** + * Stream adapter + */ +class Stream extends \Phalcon\Storage\Adapter\Stream implements CacheAdapterInterface +{ + +} diff --git a/src/Phalcon/cache/AdapterFactory.php b/src/Phalcon/Cache/AdapterFactory.php similarity index 78% rename from src/Phalcon/cache/AdapterFactory.php rename to src/Phalcon/Cache/AdapterFactory.php index 04895e44..79bf2e3c 100644 --- a/src/Phalcon/cache/AdapterFactory.php +++ b/src/Phalcon/Cache/AdapterFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cache; use Phalcon\Cache\Adapter\AdapterInterface; @@ -32,7 +39,7 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * * @param string $name * @param array $options - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface { @@ -46,4 +53,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/cache/CacheFactory.php b/src/Phalcon/Cache/CacheFactory.php similarity index 65% rename from src/Phalcon/cache/CacheFactory.php rename to src/Phalcon/Cache/CacheFactory.php index 27f02fc5..18e85bb2 100644 --- a/src/Phalcon/cache/CacheFactory.php +++ b/src/Phalcon/Cache/CacheFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cache; use Psr\SimpleCache\CacheInterface; @@ -18,9 +25,9 @@ class CacheFactory /** * Constructor * - * @param \Phalcon\Cache\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory) + public function __construct(AdapterFactory $factory) { } @@ -39,9 +46,10 @@ public function load($config) * * @param string $name * @param array $options - * @return \Psr\SimpleCache\CacheInterface + * @return CacheInterface */ public function newInstance(string $name, array $options = array()): CacheInterface { } + } diff --git a/src/Phalcon/Cache/Exception/Exception.php b/src/Phalcon/Cache/Exception/Exception.php new file mode 100644 index 00000000..f86ea319 --- /dev/null +++ b/src/Phalcon/Cache/Exception/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Exception; + +/** + * Exceptions thrown in Phalcon\Cache will use this class + */ +class Exception extends \Phalcon\Exception implements Psr\SimpleCache\CacheException +{ + +} diff --git a/src/Phalcon/Cache/Exception/InvalidArgumentException.php b/src/Phalcon/Cache/Exception/InvalidArgumentException.php new file mode 100644 index 00000000..c317d6d3 --- /dev/null +++ b/src/Phalcon/Cache/Exception/InvalidArgumentException.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cache\Exception; + +/** + * Exceptions thrown in Phalcon\Cache will use this class + */ +class InvalidArgumentException extends \Phalcon\Exception implements Psr\SimpleCache\InvalidArgumentException +{ + +} diff --git a/src/Phalcon/cli/Console.php b/src/Phalcon/Cli/Console.php similarity index 77% rename from src/Phalcon/cli/Console.php rename to src/Phalcon/Cli/Console.php index 82bfad9a..13506d43 100644 --- a/src/Phalcon/cli/Console.php +++ b/src/Phalcon/Cli/Console.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; use Phalcon\Application\AbstractApplication; @@ -40,4 +47,5 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } + } diff --git a/src/Phalcon/Cli/Console/Exception.php b/src/Phalcon/Cli/Console/Exception.php new file mode 100644 index 00000000..6cbea0f4 --- /dev/null +++ b/src/Phalcon/Cli/Console/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cli\Console; + +/** + * Exceptions thrown in Phalcon\Cli\Console will use this class + */ +class Exception extends \Phalcon\Application\Exception +{ + +} diff --git a/src/Phalcon/cli/Dispatcher.php b/src/Phalcon/Cli/Dispatcher.php similarity index 88% rename from src/Phalcon/cli/Dispatcher.php rename to src/Phalcon/Cli/Dispatcher.php index 47179b40..ba8d3160 100644 --- a/src/Phalcon/cli/Dispatcher.php +++ b/src/Phalcon/Cli/Dispatcher.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; /** @@ -24,7 +31,7 @@ * $handle = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements Phalcon\Cli\DispatcherInterface { /** * @var string @@ -80,9 +87,9 @@ public function getLastTask(): TaskInterface /** * Gets an option by its name or numeric index * - * @param mixed $option - * @param string|array $filters - * @param mixed $defaultValue + * @param mixed $option + * @param string|array $filters + * @param mixed $defaultValue * @return mixed */ public function getOption($option, $filters = null, $defaultValue = null) @@ -130,6 +137,7 @@ public function hasOption($option): bool * Sets the default task name * * @param string $taskName + * @return void */ public function setDefaultTask(string $taskName) { @@ -139,6 +147,7 @@ public function setDefaultTask(string $taskName) * Set the options to be dispatched * * @param array $options + * @return void */ public function setOptions(array $options) { @@ -148,6 +157,7 @@ public function setOptions(array $options) * Sets the task name to be dispatched * * @param string $taskName + * @return void */ public function setTaskName(string $taskName) { @@ -157,6 +167,7 @@ public function setTaskName(string $taskName) * Sets the default task suffix * * @param string $taskSuffix + * @return void */ public function setTaskSuffix(string $taskSuffix) { @@ -180,4 +191,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/Cli/Dispatcher/Exception.php b/src/Phalcon/Cli/Dispatcher/Exception.php new file mode 100644 index 00000000..592e140f --- /dev/null +++ b/src/Phalcon/Cli/Dispatcher/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cli\Dispatcher; + +/** + * Exceptions thrown in Phalcon\Cli\Dispatcher will use this class + */ +class Exception extends \Phalcon\Dispatcher\Exception +{ + +} diff --git a/src/Phalcon/cli/DispatcherInterface.php b/src/Phalcon/Cli/DispatcherInterface.php similarity index 75% rename from src/Phalcon/cli/DispatcherInterface.php rename to src/Phalcon/Cli/DispatcherInterface.php index 58ca9c1f..dc877448 100644 --- a/src/Phalcon/cli/DispatcherInterface.php +++ b/src/Phalcon/Cli/DispatcherInterface.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; +use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; + /** * Interface for Phalcon\Cli\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends DispatcherInterfaceBase { /** @@ -47,6 +56,7 @@ public function getTaskSuffix(): string; * Sets the default task name * * @param string $taskName + * @return void */ public function setDefaultTask(string $taskName); @@ -54,6 +64,7 @@ public function setDefaultTask(string $taskName); * Set the options to be dispatched * * @param array $options + * @return void */ public function setOptions(array $options); @@ -61,6 +72,7 @@ public function setOptions(array $options); * Sets the task name to be dispatched * * @param string $taskName + * @return void */ public function setTaskName(string $taskName); @@ -68,6 +80,8 @@ public function setTaskName(string $taskName); * Sets the default task suffix * * @param string $taskSuffix + * @return void */ public function setTaskSuffix(string $taskSuffix); + } diff --git a/src/Phalcon/cli/Router.php b/src/Phalcon/Cli/Router.php similarity index 91% rename from src/Phalcon/cli/Router.php rename to src/Phalcon/Cli/Router.php index a6956eff..fb84ba98 100644 --- a/src/Phalcon/cli/Router.php +++ b/src/Phalcon/Cli/Router.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; use Phalcon\Cli\Router\RouteInterface; @@ -86,7 +93,7 @@ public function __construct(bool $defaultRoutes = true) * * @param string|array $paths * @param string $pattern - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function add(string $pattern, $paths = null): RouteInterface { @@ -104,7 +111,7 @@ public function getActionName(): string /** * Returns the route that matches the handled URI * - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function getMatchedRoute(): RouteInterface { @@ -141,7 +148,7 @@ public function getParams(): array * Returns a route object by its id * * @param int $id - * @return bool|\Phalcon\Cli\Router\RouteInterface + * @return mixed */ public function getRouteById($id) { @@ -151,7 +158,7 @@ public function getRouteById($id) * Returns a route object by its name * * @param string $name - * @return bool|\Phalcon\Cli\Router\RouteInterface + * @return mixed */ public function getRouteByName(string $name) { @@ -160,7 +167,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array|\Phalcon\Cli\Router\Route[] + * @return array */ public function getRoutes(): array { @@ -227,6 +234,7 @@ public function setDefaults(array $defaults): Router * Sets the default controller name * * @param string $taskName + * @return void */ public function setDefaultTask(string $taskName) { @@ -240,4 +248,5 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } + } diff --git a/src/Phalcon/Cli/Router/Exception.php b/src/Phalcon/Cli/Router/Exception.php new file mode 100644 index 00000000..4b4bc526 --- /dev/null +++ b/src/Phalcon/Cli/Router/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cli\Router; + +/** + * Exceptions thrown in Phalcon\Cli\Router will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/cli/router/Route.php b/src/Phalcon/Cli/Router/Route.php similarity index 87% rename from src/Phalcon/cli/router/Route.php rename to src/Phalcon/Cli/Router/Route.php index 8ff80394..e9120f83 100644 --- a/src/Phalcon/cli/router/Route.php +++ b/src/Phalcon/Cli/Router/Route.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli\Router; /** * This class represents every route added to the router */ -class Route implements \Phalcon\Cli\Router\RouteInterface +class Route implements Phalcon\Cli\Router\RouteInterface { const DEFAULT_DELIMITER = ' '; @@ -23,7 +30,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $delimiter; - protected static $delimiterPath = self::DEFAULT_DELIMITER; + static protected $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -41,7 +48,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; /** @@ -58,7 +65,7 @@ public function __construct(string $pattern, $paths = null) * If the callback returns false the route is treated as not matched * * @param callback $callback - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function beforeMatch($callback): RouteInterface { @@ -81,7 +88,7 @@ public function compilePattern(string $pattern): string * * @param callable $converter * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function convert(string $name, $converter): RouteInterface { @@ -91,6 +98,7 @@ public function convert(string $name, $converter): RouteInterface * Set the routing delimiter * * @param string $delimiter + * @return void */ public static function delimiter(string $delimiter = null) { @@ -201,6 +209,7 @@ public function getRouteId(): string * * @param array|string $paths * @param string $pattern + * @return void */ public function reConfigure(string $pattern, $paths = null) { @@ -208,6 +217,8 @@ public function reConfigure(string $pattern, $paths = null) /** * Resets the internal route id generator + * + * @return void */ public static function reset() { @@ -217,7 +228,7 @@ public static function reset() * Sets the route's description * * @param string $description - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function setDescription(string $description): RouteInterface { @@ -236,9 +247,10 @@ public function setDescription(string $description): RouteInterface * ``` * * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function setName(string $name): RouteInterface { } + } diff --git a/src/Phalcon/cli/router/RouteInterface.php b/src/Phalcon/Cli/Router/RouteInterface.php similarity index 88% rename from src/Phalcon/cli/router/RouteInterface.php rename to src/Phalcon/Cli/Router/RouteInterface.php index f87e2b98..7730db7d 100644 --- a/src/Phalcon/cli/router/RouteInterface.php +++ b/src/Phalcon/Cli/Router/RouteInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli\Router; /** @@ -85,11 +92,14 @@ public function getRouteId(): string; * * @param string $pattern * @param mixed $paths + * @return void */ public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator + * + * @return void */ public static function reset(); @@ -108,4 +118,5 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; + } diff --git a/src/Phalcon/cli/RouterInterface.php b/src/Phalcon/Cli/RouterInterface.php similarity index 84% rename from src/Phalcon/cli/RouterInterface.php rename to src/Phalcon/Cli/RouterInterface.php index 5f2f0ba6..f304abec 100644 --- a/src/Phalcon/cli/RouterInterface.php +++ b/src/Phalcon/Cli/RouterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; use Phalcon\Cli\Router\RouteInterface; @@ -15,7 +22,7 @@ interface RouterInterface * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function add(string $pattern, $paths = null): RouteInterface; @@ -29,7 +36,7 @@ public function getActionName(): string; /** * Returns the route that matches the handled URI * - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function getMatchedRoute(): RouteInterface; @@ -58,7 +65,7 @@ public function getParams(): array; * Returns a route object by its id * * @param mixed $id - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function getRouteById($id): RouteInterface; @@ -66,14 +73,14 @@ public function getRouteById($id): RouteInterface; * Returns a route object by its name * * @param string $name - * @return \Phalcon\Cli\Router\RouteInterface + * @return RouteInterface */ public function getRouteByName(string $name): RouteInterface; /** * Return all the routes defined in the router * - * @return array|\Phalcon\Cli\Router\RouteInterface[] + * @return array */ public function getRoutes(): array; @@ -95,6 +102,7 @@ public function handle($arguments = null); * Sets the default action name * * @param string $actionName + * @return void */ public function setDefaultAction(string $actionName); @@ -102,6 +110,7 @@ public function setDefaultAction(string $actionName); * Sets the name of the default module * * @param string $moduleName + * @return void */ public function setDefaultModule(string $moduleName); @@ -109,6 +118,7 @@ public function setDefaultModule(string $moduleName); * Sets an array of default paths * * @param array $defaults + * @return void */ public function setDefaults(array $defaults); @@ -116,6 +126,7 @@ public function setDefaults(array $defaults); * Sets the default task name * * @param string $taskName + * @return void */ public function setDefaultTask(string $taskName); @@ -125,4 +136,5 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/cli/Task.php b/src/Phalcon/Cli/Task.php similarity index 74% rename from src/Phalcon/cli/Task.php rename to src/Phalcon/Cli/Task.php index 8fe41590..a727cac9 100644 --- a/src/Phalcon/cli/Task.php +++ b/src/Phalcon/Cli/Task.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Cli; use Phalcon\Di\Injectable; @@ -29,7 +36,7 @@ * } * ``` */ -class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface +class Task extends Injectable implements Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface { protected $eventsManager; @@ -45,7 +52,7 @@ final public function __construct() /** * Returns the internal event manager * - * @return null|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface { @@ -55,8 +62,10 @@ public function getEventsManager(): ?ManagerInterface * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/Cli/TaskInterface.php b/src/Phalcon/Cli/TaskInterface.php new file mode 100644 index 00000000..9b469f64 --- /dev/null +++ b/src/Phalcon/Cli/TaskInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Cli; + +/** + * Interface for task handlers + */ +interface TaskInterface +{ + +} diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index 0047e935..bbeb32f6 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Traversable; @@ -69,6 +76,7 @@ public function __isset(string $element): bool * * @param string $element * @param mixed $value + * @return void */ public function __set(string $element, $value) { @@ -78,6 +86,7 @@ public function __set(string $element, $value) * Magic unset to remove an element from the collection * * @param string $element + * @return void */ public function __unset(string $element) { @@ -85,6 +94,8 @@ public function __unset(string $element) /** * Clears the internal collection + * + * @return void */ public function clear() { @@ -115,12 +126,27 @@ public function get(string $element, $defaultValue = null, string $cast = null) /** * Returns the iterator of the class * - * @return \Traversable + * @return Traversable */ public function getIterator(): Traversable { } + /** + * @param bool $insensitive + * @return array + */ + public function getKeys(bool $insensitive = true): array + { + } + + /** + * @return array + */ + public function getValues(): array + { + } + /** * Get the element from the collection * @@ -135,6 +161,7 @@ public function has(string $element): bool * Initialize internal array * * @param array $data + * @return void */ public function init(array $data = array()) { @@ -177,6 +204,7 @@ public function offsetGet($element) * * @param mixed $element * @param mixed $value + * @return void */ public function offsetSet($element, $value) { @@ -187,6 +215,7 @@ public function offsetSet($element, $value) * See [offsetUnset](https://php.net/manual/en/arrayaccess.offsetunset.php) * * @param mixed $element + * @return void */ public function offsetUnset($element) { @@ -196,6 +225,7 @@ public function offsetUnset($element) * Delete the element from the collection * * @param string $element + * @return void */ public function remove(string $element) { @@ -206,6 +236,7 @@ public function remove(string $element) * * @param string $element * @param mixed $value + * @return void */ public function set(string $element, $value) { @@ -252,6 +283,7 @@ public function toJson(int $options = 79): string * See [unserialize](https://php.net/manual/en/serializable.unserialize.php) * * @param mixed $serialized + * @return void */ public function unserialize($serialized) { @@ -262,8 +294,10 @@ public function unserialize($serialized) * * @param string $element * @param mixed $value + * @return void */ protected function setData(string $element, $value) { } + } diff --git a/src/Phalcon/Collection/Exception.php b/src/Phalcon/Collection/Exception.php new file mode 100644 index 00000000..5b84c7ed --- /dev/null +++ b/src/Phalcon/Collection/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Collection; + +/** + * Exceptions for the Collection object + */ +class Exception extends \Phalcon\Exception implements \Throwable +{ + +} diff --git a/src/Phalcon/collection/ReadOnly.php b/src/Phalcon/Collection/ReadOnly.php similarity index 65% rename from src/Phalcon/collection/ReadOnly.php rename to src/Phalcon/Collection/ReadOnly.php index d5709a3c..cc06d071 100644 --- a/src/Phalcon/collection/ReadOnly.php +++ b/src/Phalcon/Collection/ReadOnly.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Collection; use Phalcon\Collection; @@ -14,6 +21,7 @@ class ReadOnly extends Collection * Delete the element from the collection * * @param string $element + * @return void */ public function remove(string $element) { @@ -24,8 +32,10 @@ public function remove(string $element) * * @param string $element * @param mixed $value + * @return void */ public function set(string $element, $value) { } + } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index aef376b8..e5531b65 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -125,8 +132,10 @@ final protected function internalMerge(array $source, array $target): array * * @param mixed $element * @param mixed $value + * @return void */ protected function setData($element, $value) { } + } diff --git a/src/Phalcon/config/adapter/Grouped.php b/src/Phalcon/Config/Adapter/Grouped.php similarity index 85% rename from src/Phalcon/config/adapter/Grouped.php rename to src/Phalcon/Config/Adapter/Grouped.php index 46564c81..0fb590f0 100644 --- a/src/Phalcon/config/adapter/Grouped.php +++ b/src/Phalcon/Config/Adapter/Grouped.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -67,4 +74,5 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } + } diff --git a/src/Phalcon/config/adapter/Ini.php b/src/Phalcon/Config/Adapter/Ini.php similarity index 88% rename from src/Phalcon/config/adapter/Ini.php rename to src/Phalcon/Config/Adapter/Ini.php index 79a0f125..1f859292 100644 --- a/src/Phalcon/config/adapter/Ini.php +++ b/src/Phalcon/Config/Adapter/Ini.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -80,4 +87,5 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } + } diff --git a/src/Phalcon/config/adapter/Json.php b/src/Phalcon/Config/Adapter/Json.php similarity index 74% rename from src/Phalcon/config/adapter/Json.php rename to src/Phalcon/Config/Adapter/Json.php index b2df23b3..c4feb76a 100644 --- a/src/Phalcon/config/adapter/Json.php +++ b/src/Phalcon/Config/Adapter/Json.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -35,4 +42,5 @@ class Json extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/config/adapter/Php.php b/src/Phalcon/Config/Adapter/Php.php similarity index 81% rename from src/Phalcon/config/adapter/Php.php rename to src/Phalcon/Config/Adapter/Php.php index c1e91821..f94da213 100644 --- a/src/Phalcon/config/adapter/Php.php +++ b/src/Phalcon/Config/Adapter/Php.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -50,4 +57,5 @@ class Php extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/config/adapter/Yaml.php b/src/Phalcon/Config/Adapter/Yaml.php similarity index 81% rename from src/Phalcon/config/adapter/Yaml.php rename to src/Phalcon/Config/Adapter/Yaml.php index f545b2a2..d290eab0 100644 --- a/src/Phalcon/config/adapter/Yaml.php +++ b/src/Phalcon/Config/Adapter/Yaml.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config\Adapter; use Phalcon\Config; @@ -53,4 +60,5 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } + } diff --git a/src/Phalcon/config/ConfigFactory.php b/src/Phalcon/Config/ConfigFactory.php similarity index 83% rename from src/Phalcon/config/ConfigFactory.php rename to src/Phalcon/Config/ConfigFactory.php index c26fcb48..ed023eb7 100644 --- a/src/Phalcon/config/ConfigFactory.php +++ b/src/Phalcon/Config/ConfigFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Config; use Phalcon\Factory\AbstractFactory; @@ -61,4 +68,5 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Config/Exception.php b/src/Phalcon/Config/Exception.php new file mode 100644 index 00000000..64615c1c --- /dev/null +++ b/src/Phalcon/Config/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Config; + +/** + * Exceptions thrown in Phalcon\Config will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 45d76bd2..36e22a2e 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\DiInterface; @@ -43,4 +50,5 @@ public function get($name) public function has($name): bool { } + } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index ba879ba2..d23d17bf 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Crypt\CryptInterface; @@ -156,11 +163,11 @@ public function decrypt(string $text, string $key = null): string /** * Decrypt a text that is coded as a base64 string. * + * @throws \Phalcon\Crypt\Mismatch * @param string $text * @param mixed $key * @param bool $safe * @return string - * @throws \Phalcon\Crypt\Mismatch */ public function decryptBase64(string $text, $key = null, bool $safe = false): string { @@ -243,7 +250,7 @@ public function getKey(): string /** * @param string $tag - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setAuthTag(string $tag): CryptInterface { @@ -251,7 +258,7 @@ public function setAuthTag(string $tag): CryptInterface /** * @param string $data - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setAuthData(string $data): CryptInterface { @@ -259,7 +266,7 @@ public function setAuthData(string $data): CryptInterface /** * @param int $length - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setAuthTagLength(int $length): CryptInterface { @@ -275,7 +282,7 @@ public function setAuthTagLength(int $length): CryptInterface * algorithm for current openssl library version. * * @param string $cipher - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setCipher(string $cipher): CryptInterface { @@ -284,9 +291,9 @@ public function setCipher(string $cipher): CryptInterface /** * Set the name of hashing algorithm. * - * @param string $hashAlgo - * @return \Phalcon\Crypt\CryptInterface * @throws \Phalcon\Crypt\Exception + * @param string $hashAlgo + * @return CryptInterface */ public function setHashAlgo(string $hashAlgo): CryptInterface { @@ -308,7 +315,7 @@ public function setHashAlgo(string $hashAlgo): CryptInterface * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" * * @param string $key - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setKey(string $key): CryptInterface { @@ -318,7 +325,7 @@ public function setKey(string $key): CryptInterface * Changes the padding scheme used. * * @param int $scheme - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface { @@ -328,7 +335,7 @@ public function setPadding(int $scheme): CryptInterface * Sets if the calculating message digest must used. * * @param bool $useSigning - * @return \Phalcon\Crypt\CryptInterface + * @return CryptInterface */ public function useSigning(bool $useSigning): CryptInterface { @@ -338,6 +345,7 @@ public function useSigning(bool $useSigning): CryptInterface * Assert the cipher is available. * * @param string $cipher + * @return void */ protected function assertCipherIsAvailable(string $cipher) { @@ -347,6 +355,7 @@ protected function assertCipherIsAvailable(string $cipher) * Assert the hash algorithm is available. * * @param string $hashAlgo + * @return void */ protected function assertHashAlgorithmAvailable(string $hashAlgo) { @@ -364,6 +373,8 @@ protected function getIvLength(string $cipher): int /** * Initialize available cipher algorithms. + * + * @return void */ protected function initializeAvailableCiphers() { @@ -396,4 +407,5 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } + } diff --git a/src/Phalcon/crypt/CryptInterface.php b/src/Phalcon/Crypt/CryptInterface.php similarity index 92% rename from src/Phalcon/crypt/CryptInterface.php rename to src/Phalcon/Crypt/CryptInterface.php index 7248875f..5f30daa2 100644 --- a/src/Phalcon/crypt/CryptInterface.php +++ b/src/Phalcon/Crypt/CryptInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Crypt; /** @@ -133,4 +140,5 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; + } diff --git a/src/Phalcon/Crypt/Exception.php b/src/Phalcon/Crypt/Exception.php new file mode 100644 index 00000000..c3b74384 --- /dev/null +++ b/src/Phalcon/Crypt/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Crypt; + +/** + * Exceptions thrown in Phalcon\Crypt use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Crypt/Mismatch.php b/src/Phalcon/Crypt/Mismatch.php new file mode 100644 index 00000000..e747b732 --- /dev/null +++ b/src/Phalcon/Crypt/Mismatch.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Crypt; + +/** + * Exceptions thrown in Phalcon\Crypt will use this class. + */ +class Mismatch extends \Phalcon\Crypt\Exception +{ + +} diff --git a/src/Phalcon/db/AbstractDb.php b/src/Phalcon/Db/AbstractDb.php similarity index 85% rename from src/Phalcon/db/AbstractDb.php rename to src/Phalcon/Db/AbstractDb.php index d99eee40..f98e83b0 100644 --- a/src/Phalcon/db/AbstractDb.php +++ b/src/Phalcon/Db/AbstractDb.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -52,8 +59,10 @@ abstract class AbstractDb * Enables/disables options in the Database component * * @param array $options + * @return void */ public static function setup(array $options) { } + } diff --git a/src/Phalcon/db/adapter/AbstractAdapter.php b/src/Phalcon/Db/Adapter/AbstractAdapter.php similarity index 97% rename from src/Phalcon/db/adapter/AbstractAdapter.php rename to src/Phalcon/Db/Adapter/AbstractAdapter.php index f4891771..46ede959 100644 --- a/src/Phalcon/db/adapter/AbstractAdapter.php +++ b/src/Phalcon/Db/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; @@ -10,12 +17,12 @@ /** * Base class for Phalcon\Db adapters */ -abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Connection ID */ - protected static $connectionConsecutive = 0; + static protected $connectionConsecutive = 0; /** * Active connection ID @@ -240,7 +247,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array */ public function describeIndexes(string $table, string $schema = null): array { @@ -257,7 +264,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array */ public function describeReferences(string $table, string $schema = null): array { @@ -504,7 +511,7 @@ public function getConnectionId(): string * ); * ``` * - * @return \Phalcon\Db\RawValue + * @return RawValue */ public function getDefaultIdValue(): RawValue { @@ -529,7 +536,7 @@ public function getDefaultIdValue(): RawValue * ); * ``` * - * @return \Phalcon\Db\RawValue + * @return RawValue */ public function getDefaultValue(): RawValue { @@ -547,7 +554,7 @@ public function getDescriptor(): array /** * Returns internal dialect instance * - * @return \Phalcon\Db\DialectInterface + * @return DialectInterface */ public function getDialect(): DialectInterface { @@ -556,7 +563,7 @@ public function getDialect(): DialectInterface /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -742,6 +749,7 @@ public function rollbackSavepoint(string $name): bool * Sets the event manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -760,7 +768,7 @@ public function setDialect(\Phalcon\Db\DialectInterface $dialect) * Set if nested transactions should use savepoints * * @param bool $nestedTransactionsWithSavepoints - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function setNestedTransactionsWithSavepoints(bool $nestedTransactionsWithSavepoints): AdapterInterface { @@ -919,4 +927,5 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } + } diff --git a/src/Phalcon/db/adapter/AdapterInterface.php b/src/Phalcon/Db/Adapter/AdapterInterface.php similarity index 97% rename from src/Phalcon/db/adapter/AdapterInterface.php rename to src/Phalcon/Db/Adapter/AdapterInterface.php index cc9e7e03..693d5d1c 100644 --- a/src/Phalcon/db/adapter/AdapterInterface.php +++ b/src/Phalcon/Db/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; @@ -136,7 +143,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array */ public function describeColumns(string $table, string $schema = null): array; @@ -145,7 +152,7 @@ public function describeColumns(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array */ public function describeIndexes(string $table, string $schema = null): array; @@ -154,7 +161,7 @@ public function describeIndexes(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array */ public function describeReferences(string $table, string $schema = null): array; @@ -329,7 +336,7 @@ public function getDescriptor(): array; /** * Returns internal dialect instance * - * @return \Phalcon\Db\DialectInterface + * @return DialectInterface */ public function getDialect(): DialectInterface; @@ -343,7 +350,7 @@ public function getDialectType(): string; /** * Return the default identity value to insert in an identity column * - * @return \Phalcon\Db\RawValue + * @return RawValue */ public function getDefaultIdValue(): RawValue; @@ -497,7 +504,7 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlStatement * @param mixed $placeholders * @param mixed $dataTypes - * @return bool|\Phalcon\Db\ResultInterface + * @return mixed */ public function query(string $sqlStatement, $placeholders = null, $dataTypes = null); @@ -621,4 +628,5 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; + } diff --git a/src/Phalcon/db/adapter/pdo/AbstractPdo.php b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php similarity index 96% rename from src/Phalcon/db/adapter/pdo/AbstractPdo.php rename to src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php index 053c10bd..349ee165 100644 --- a/src/Phalcon/db/adapter/pdo/AbstractPdo.php +++ b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; @@ -344,7 +351,7 @@ public function prepare(string $sqlStatement): \PDOStatement * @param string $sqlStatement * @param mixed $bindParams * @param mixed $bindTypes - * @return bool|\Phalcon\Db\ResultInterface + * @return mixed */ public function query(string $sqlStatement, $bindParams = null, $bindTypes = null) { @@ -366,4 +373,5 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; + } diff --git a/src/Phalcon/db/adapter/pdo/Mysql.php b/src/Phalcon/Db/Adapter/Pdo/Mysql.php similarity index 87% rename from src/Phalcon/db/adapter/pdo/Mysql.php rename to src/Phalcon/Db/Adapter/Pdo/Mysql.php index 53e1b091..2c98b823 100644 --- a/src/Phalcon/db/adapter/pdo/Mysql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Mysql.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter\Pdo; /** @@ -55,7 +62,7 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array */ public function describeColumns(string $table, string $schema = null): array { @@ -72,7 +79,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array */ public function describeIndexes(string $table, string $schema = null): array { @@ -89,7 +96,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array */ public function describeReferences(string $table, string $schema = null): array { @@ -103,4 +110,5 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/adapter/pdo/Postgresql.php b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php similarity index 92% rename from src/Phalcon/db/adapter/pdo/Postgresql.php rename to src/Phalcon/Db/Adapter/Pdo/Postgresql.php index 40012014..7742e96a 100644 --- a/src/Phalcon/db/adapter/pdo/Postgresql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\RawValue; @@ -77,7 +84,7 @@ public function createTable(string $tableName, string $schemaName, array $defini * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array */ public function describeColumns(string $table, string $schema = null): array { @@ -94,7 +101,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array */ public function describeReferences(string $table, string $schema = null): array { @@ -120,7 +127,7 @@ public function describeReferences(string $table, string $schema = null): array * ); * ``` * - * @return \Phalcon\Db\RawValue + * @return RawValue */ public function getDefaultIdValue(): RawValue { @@ -167,4 +174,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/adapter/pdo/Sqlite.php b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php similarity index 89% rename from src/Phalcon/db/adapter/pdo/Sqlite.php rename to src/Phalcon/Db/Adapter/Pdo/Sqlite.php index f0243b91..d787d148 100644 --- a/src/Phalcon/db/adapter/pdo/Sqlite.php +++ b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\RawValue; @@ -61,7 +68,7 @@ public function connect(array $descriptor = null): bool * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array */ public function describeColumns(string $table, string $schema = null): array { @@ -78,7 +85,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array */ public function describeIndexes(string $table, string $schema = null): array { @@ -89,7 +96,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array */ public function describeReferences(string $table, string $schema = null): array { @@ -114,7 +121,7 @@ public function describeReferences(string $table, string $schema = null): array * ); * ``` * - * @return \Phalcon\Db\RawValue + * @return RawValue */ public function getDefaultValue(): RawValue { @@ -138,4 +145,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/db/adapter/PdoFactory.php b/src/Phalcon/Db/Adapter/PdoFactory.php similarity index 72% rename from src/Phalcon/db/adapter/PdoFactory.php rename to src/Phalcon/Db/Adapter/PdoFactory.php index d24a0621..f2f06b3c 100644 --- a/src/Phalcon/db/adapter/PdoFactory.php +++ b/src/Phalcon/Db/Adapter/PdoFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Adapter; use Phalcon\Factory\AbstractFactory; @@ -28,9 +35,9 @@ public function __construct(array $services = array()) * Factory to create an instace from a Config object * * @param mixed $config - * @return mixed + * @return AdapterInterface */ - public function load($config) + public function load($config): AdapterInterface { } @@ -39,9 +46,9 @@ public function load($config) * * @param string $name * @param array $options - * @return \Phalcon\Db\Adapter\AbstractAdapter + * @return AdapterInterface */ - public function newInstance(string $name, array $options = array()): AbstractAdapter + public function newInstance(string $name, array $options = array()): AdapterInterface { } @@ -53,4 +60,5 @@ public function newInstance(string $name, array $options = array()): AbstractAda protected function getAdapters(): array { } + } diff --git a/src/Phalcon/db/Column.php b/src/Phalcon/Db/Column.php similarity index 96% rename from src/Phalcon/db/Column.php rename to src/Phalcon/Db/Column.php index f8fb568d..b2134888 100644 --- a/src/Phalcon/db/Column.php +++ b/src/Phalcon/Db/Column.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -25,7 +32,7 @@ * $connection->addColumn("robots", null, $column); * ``` */ -class Column implements \Phalcon\Db\ColumnInterface +class Column implements Phalcon\Db\ColumnInterface { /** * Bind Type Blob @@ -446,4 +453,5 @@ public function isPrimary(): bool public function isUnsigned(): bool { } + } diff --git a/src/Phalcon/db/ColumnInterface.php b/src/Phalcon/Db/ColumnInterface.php similarity index 90% rename from src/Phalcon/db/ColumnInterface.php rename to src/Phalcon/Db/ColumnInterface.php index d76627d2..4dde08e8 100644 --- a/src/Phalcon/db/ColumnInterface.php +++ b/src/Phalcon/Db/ColumnInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -119,4 +126,5 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; + } diff --git a/src/Phalcon/db/Dialect.php b/src/Phalcon/Db/Dialect.php similarity index 97% rename from src/Phalcon/db/Dialect.php rename to src/Phalcon/Db/Dialect.php index 1644f7dd..a81d79c5 100644 --- a/src/Phalcon/db/Dialect.php +++ b/src/Phalcon/Db/Dialect.php @@ -1,12 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ -abstract class Dialect implements \Phalcon\Db\DialectInterface +abstract class Dialect implements Phalcon\Db\DialectInterface { protected $escapeChar; @@ -502,4 +509,5 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } + } diff --git a/src/Phalcon/db/dialect/Mysql.php b/src/Phalcon/Db/Dialect/Mysql.php similarity index 97% rename from src/Phalcon/db/dialect/Mysql.php rename to src/Phalcon/Db/Dialect/Mysql.php index 0a35e0ef..7f099f5e 100644 --- a/src/Phalcon/db/dialect/Mysql.php +++ b/src/Phalcon/Db/Dialect/Mysql.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; @@ -351,4 +358,5 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string { } + } diff --git a/src/Phalcon/db/dialect/Postgresql.php b/src/Phalcon/Db/Dialect/Postgresql.php similarity index 97% rename from src/Phalcon/db/dialect/Postgresql.php rename to src/Phalcon/Db/Dialect/Postgresql.php index 99a4f307..342c20b4 100644 --- a/src/Phalcon/db/dialect/Postgresql.php +++ b/src/Phalcon/Db/Dialect/Postgresql.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; @@ -322,4 +329,5 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } + } diff --git a/src/Phalcon/db/dialect/Sqlite.php b/src/Phalcon/Db/Dialect/Sqlite.php similarity index 97% rename from src/Phalcon/db/dialect/Sqlite.php rename to src/Phalcon/Db/Dialect/Sqlite.php index 5ac53f17..a436f2de 100644 --- a/src/Phalcon/db/dialect/Sqlite.php +++ b/src/Phalcon/Db/Dialect/Sqlite.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; @@ -345,4 +352,5 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } + } diff --git a/src/Phalcon/db/DialectInterface.php b/src/Phalcon/Db/DialectInterface.php similarity index 90% rename from src/Phalcon/db/DialectInterface.php rename to src/Phalcon/Db/DialectInterface.php index 5fc159d5..208f30ee 100644 --- a/src/Phalcon/db/DialectInterface.php +++ b/src/Phalcon/Db/DialectInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -13,40 +20,40 @@ interface DialectInterface * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string; + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): string; /** * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string; + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): string; /** * Generates SQL to add an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): string; /** * Generates SQL to add the primary key to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string; + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): string; /** * Generate SQL to create a new savepoint @@ -172,10 +179,10 @@ public function forUpdate(string $sqlQuery): string; /** * Gets the column name in RDBMS * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; + public function getColumnDefinition(ColumnInterface $column): string; /** * Gets a list of columns @@ -225,11 +232,11 @@ public function listTables(string $schemaName = null): string; * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string; + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): string; /** * Registers custom SQL functions @@ -312,4 +319,5 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; + } diff --git a/src/Phalcon/db/Enum.php b/src/Phalcon/Db/Enum.php similarity index 72% rename from src/Phalcon/db/Enum.php rename to src/Phalcon/Db/Enum.php index 6c105d89..d826fa71 100644 --- a/src/Phalcon/db/Enum.php +++ b/src/Phalcon/Db/Enum.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -57,4 +64,6 @@ class Enum const FETCH_UNIQUE = 196608; + + } diff --git a/src/Phalcon/image/Exception.php b/src/Phalcon/Db/Exception.php similarity index 65% rename from src/Phalcon/image/Exception.php rename to src/Phalcon/Db/Exception.php index 16aca798..059b85db 100644 --- a/src/Phalcon/image/Exception.php +++ b/src/Phalcon/Db/Exception.php @@ -1,15 +1,17 @@ * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ +namespace Phalcon\Db; + +/** + * Exceptions thrown in Phalcon\Db will use this class + */ class Exception extends \Phalcon\Exception { diff --git a/src/Phalcon/db/Index.php b/src/Phalcon/Db/Index.php similarity index 85% rename from src/Phalcon/db/Index.php rename to src/Phalcon/Db/Index.php index f80a22bd..f64d51c5 100644 --- a/src/Phalcon/db/Index.php +++ b/src/Phalcon/Db/Index.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -31,7 +38,7 @@ * $connection->addIndex("robots", null, $index_primary); * ``` */ -class Index implements \Phalcon\Db\IndexInterface +class Index implements Phalcon\Db\IndexInterface { /** * Index columns @@ -92,4 +99,5 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } + } diff --git a/src/Phalcon/db/IndexInterface.php b/src/Phalcon/Db/IndexInterface.php similarity index 67% rename from src/Phalcon/db/IndexInterface.php rename to src/Phalcon/Db/IndexInterface.php index 38d385a8..f1a7074c 100644 --- a/src/Phalcon/db/IndexInterface.php +++ b/src/Phalcon/Db/IndexInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -28,4 +35,5 @@ public function getName(): string; * @return string */ public function getType(): string; + } diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/Db/Profiler.php similarity index 91% rename from src/Phalcon/db/Profiler.php rename to src/Phalcon/Db/Profiler.php index 9c3aa351..60c783a5 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/Db/Profiler.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; use Phalcon\Db\Profiler\Item; @@ -81,7 +88,7 @@ class Profiler /** * Returns the last profile executed in the profiler * - * @return \Phalcon\Db\Profiler\Item + * @return Item */ public function getLastProfile(): Item { @@ -99,7 +106,7 @@ public function getNumberTotalStatements(): int /** * Returns the total time in seconds spent by the profiles * - * @return double + * @return float */ public function getTotalElapsedSeconds(): float { @@ -108,7 +115,7 @@ public function getTotalElapsedSeconds(): float /** * Returns all the processed profiles * - * @return array|\Phalcon\Db\Profiler\Item[] + * @return array */ public function getProfiles(): array { @@ -143,4 +150,5 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } + } diff --git a/src/Phalcon/db/profiler/Item.php b/src/Phalcon/Db/Profiler/Item.php similarity index 89% rename from src/Phalcon/db/profiler/Item.php rename to src/Phalcon/Db/Profiler/Item.php index e4244b58..24610248 100644 --- a/src/Phalcon/db/profiler/Item.php +++ b/src/Phalcon/Db/Profiler/Item.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Profiler; /** @@ -55,7 +62,7 @@ public function setFinalTime(float $finalTime) /** * Timestamp when the profile ended * - * @return double + * @return float */ public function getFinalTime(): float { @@ -73,7 +80,7 @@ public function setInitialTime(float $initialTime) /** * Timestamp when the profile started * - * @return double + * @return float */ public function getInitialTime(): float { @@ -136,9 +143,10 @@ public function getSqlVariables(): array /** * Returns the total time in seconds spent by the profile * - * @return double + * @return float */ public function getTotalElapsedSeconds(): float { } + } diff --git a/src/Phalcon/db/RawValue.php b/src/Phalcon/Db/RawValue.php similarity index 80% rename from src/Phalcon/db/RawValue.php rename to src/Phalcon/Db/RawValue.php index e89199da..27a98c78 100644 --- a/src/Phalcon/db/RawValue.php +++ b/src/Phalcon/Db/RawValue.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -52,4 +59,5 @@ public function __toString(): string public function __construct($value) { } + } diff --git a/src/Phalcon/db/Reference.php b/src/Phalcon/Db/Reference.php similarity index 89% rename from src/Phalcon/db/Reference.php rename to src/Phalcon/Db/Reference.php index 8d88dc19..50eb11bf 100644 --- a/src/Phalcon/db/Reference.php +++ b/src/Phalcon/Db/Reference.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -23,7 +30,7 @@ * ); * ``` */ -class Reference implements \Phalcon\Db\ReferenceInterface +class Reference implements Phalcon\Db\ReferenceInterface { /** * Local reference columns @@ -163,4 +170,5 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } + } diff --git a/src/Phalcon/db/ReferenceInterface.php b/src/Phalcon/Db/ReferenceInterface.php similarity index 83% rename from src/Phalcon/db/ReferenceInterface.php rename to src/Phalcon/Db/ReferenceInterface.php index 056b8049..9e2a3bf1 100644 --- a/src/Phalcon/db/ReferenceInterface.php +++ b/src/Phalcon/Db/ReferenceInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -63,4 +70,5 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; + } diff --git a/src/Phalcon/db/result/Pdo.php b/src/Phalcon/Db/Result/Pdo.php similarity index 95% rename from src/Phalcon/db/result/Pdo.php rename to src/Phalcon/Db/Result/Pdo.php index c7f012c7..3552dc33 100644 --- a/src/Phalcon/db/result/Pdo.php +++ b/src/Phalcon/Db/Result/Pdo.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db\Result; use Phalcon\Db\Enum; @@ -82,6 +89,7 @@ public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \P * ``` * * @param long $number + * @return void */ public function dataSeek(int $number) { @@ -225,4 +233,5 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } + } diff --git a/src/Phalcon/db/ResultInterface.php b/src/Phalcon/Db/ResultInterface.php similarity index 89% rename from src/Phalcon/db/ResultInterface.php rename to src/Phalcon/Db/ResultInterface.php index 7ce90cb1..93923545 100644 --- a/src/Phalcon/db/ResultInterface.php +++ b/src/Phalcon/Db/ResultInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Db; /** @@ -73,4 +80,5 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; + } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index a6203126..368851a6 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -23,7 +30,7 @@ class Debug /** * @var bool */ - protected static $isActive; + static protected $isActive; /** * @var bool @@ -95,6 +102,8 @@ public function getVersion(): string /** * Halts the request showing a backtrace + * + * @return void */ public function halt() { @@ -147,6 +156,7 @@ public function onUncaughtException(\Exception $exception): bool * @param mixed $file * @param mixed $line * @param mixed $context + * @return void */ public function onUncaughtLowSeverity($severity, $message, $file, $line, $context) { @@ -244,4 +254,5 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } + } diff --git a/src/Phalcon/debug/Dump.php b/src/Phalcon/Debug/Dump.php similarity index 93% rename from src/Phalcon/debug/Dump.php rename to src/Phalcon/Debug/Dump.php index cc2fbf6a..9eb9eed7 100644 --- a/src/Phalcon/debug/Dump.php +++ b/src/Phalcon/Debug/Dump.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Debug; /** @@ -168,4 +175,5 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } + } diff --git a/src/Phalcon/Debug/Exception.php b/src/Phalcon/Debug/Exception.php new file mode 100644 index 00000000..9b59519b --- /dev/null +++ b/src/Phalcon/Debug/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Debug; + +/** + * Exceptions thrown in Phalcon\Debug will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index 4ae0d207..c5d7ac56 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\DiInterface; @@ -66,7 +73,7 @@ class Di implements \Phalcon\Di\DiInterface /** * Latest DI build */ - protected static $_default; + static protected $_default; /** @@ -95,7 +102,7 @@ public function __call(string $method, array $arguments = array()) * @param string $name * @param mixed $definition * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return mixed */ public function attempt(string $name, $definition, bool $shared = false) { @@ -115,7 +122,7 @@ public function get(string $name, $parameters = null) /** * Return the latest DI created * - * @return null|\Phalcon\Di\DiInterface + * @return mixed */ public static function getDefault(): ?DiInterface { @@ -124,7 +131,7 @@ public static function getDefault(): ?DiInterface /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getInternalEventsManager(): ManagerInterface { @@ -144,7 +151,7 @@ public function getRaw(string $name) * Returns a Phalcon\Di\Service instance * * @param string $name - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function getService(string $name): ServiceInterface { @@ -153,7 +160,7 @@ public function getService(string $name): ServiceInterface /** * Return the services registered in the DI * - * @return array|\Phalcon\Di\ServiceInterface[] + * @return array */ public function getServices(): array { @@ -174,9 +181,10 @@ public function getShared(string $name, $parameters = null) /** * Loads services from a Config object. * - * @param \Phalcon\Config $config + * @param Config $config + * @return void */ - protected function loadFromConfig(\Phalcon\Config $config) + protected function loadFromConfig(Config $config) { } @@ -212,6 +220,7 @@ protected function loadFromConfig(\Phalcon\Config $config) * * @link https://docs.phalcon.io/en/latest/reference/di.html * @param string $filePath + * @return void */ public function loadFromPhp(string $filePath) { @@ -251,6 +260,7 @@ public function loadFromPhp(string $filePath) * @link https://docs.phalcon.io/en/latest/reference/di.html * @param string $filePath * @param array $callbacks + * @return void */ public function loadFromYaml(string $filePath, array $callbacks = null) { @@ -299,6 +309,7 @@ public function offsetExists($name): bool * * @param mixed $name * @param mixed $definition + * @return void */ public function offsetSet($name, $definition) { @@ -308,6 +319,7 @@ public function offsetSet($name, $definition) * Removes a service from the services container using the array syntax * * @param mixed $name + * @return void */ public function offsetUnset($name) { @@ -335,6 +347,7 @@ public function offsetUnset($name) * ``` * * @param \Phalcon\Di\ServiceProviderInterface $provider + * @return void */ public function register(\Phalcon\Di\ServiceProviderInterface $provider) { @@ -345,6 +358,7 @@ public function register(\Phalcon\Di\ServiceProviderInterface $provider) * It also removes any shared instance created for the service * * @param string $name + * @return void */ public function remove(string $name) { @@ -352,6 +366,8 @@ public function remove(string $name) /** * Resets the internal default DI + * + * @return void */ public static function reset() { @@ -363,7 +379,7 @@ public static function reset() * @param string $name * @param mixed $definition * @param bool $shared - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function set(string $name, $definition, bool $shared = false): ServiceInterface { @@ -374,6 +390,7 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * methods * * @param \Phalcon\Di\DiInterface $container + * @return void */ public static function setDefault(\Phalcon\Di\DiInterface $container) { @@ -393,7 +410,7 @@ public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $event * * @param string $name * @param \Phalcon\Di\ServiceInterface $rawDefinition - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface { @@ -404,9 +421,10 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition * * @param string $name * @param mixed $definition - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface { } + } diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Phalcon/Di/AbstractInjectionAware.php new file mode 100644 index 00000000..0ff55e59 --- /dev/null +++ b/src/Phalcon/Di/AbstractInjectionAware.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Di; + +/** + * This abstract class offers common access to the DI in a class + */ +abstract class AbstractInjectionAware implements Phalcon\Di\InjectionAwareInterface +{ + /** + * Dependency Injector + * + * @var DiInterface + */ + protected $container; + + + /** + * Returns the internal dependency injector + * + * @return DiInterface + */ + public function getDI(): DiInterface + { + } + + /** + * Sets the dependency injector + * + * @param DiInterface $container + * @return void + */ + public function setDI(DiInterface $container) + { + } + +} diff --git a/src/Phalcon/di/DiInterface.php b/src/Phalcon/Di/DiInterface.php similarity index 81% rename from src/Phalcon/di/DiInterface.php rename to src/Phalcon/Di/DiInterface.php index 9f170fce..2cdcc2ce 100644 --- a/src/Phalcon/di/DiInterface.php +++ b/src/Phalcon/Di/DiInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -16,7 +23,7 @@ interface DiInterface extends \ArrayAccess * @param mixed $definition * @param string $name * @param bool $shared - * @return bool|\Phalcon\Di\ServiceInterface + * @return mixed */ public function attempt(string $name, $definition, bool $shared = false); @@ -32,7 +39,7 @@ public function get(string $name, $parameters = null); /** * Return the last DI created * - * @return null|DiInterface + * @return mixed */ public static function getDefault(): ?DiInterface; @@ -48,14 +55,14 @@ public function getRaw(string $name); * Returns the corresponding Phalcon\Di\Service instance for a service * * @param string $name - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function getService(string $name): ServiceInterface; /** * Return the services registered in the DI * - * @return array|\Phalcon\Di\ServiceInterface[] + * @return array */ public function getServices(): array; @@ -80,11 +87,14 @@ public function has(string $name): bool; * Removes a service in the services container * * @param string $name + * @return void */ public function remove(string $name); /** * Resets the internal default DI + * + * @return void */ public static function reset(); @@ -94,7 +104,7 @@ public static function reset(); * @param string $name * @param mixed $definition * @param bool $shared - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function set(string $name, $definition, bool $shared = false): ServiceInterface; @@ -103,6 +113,7 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * methods * * @param DiInterface $container + * @return void */ public static function setDefault(DiInterface $container); @@ -110,17 +121,18 @@ public static function setDefault(DiInterface $container); * Sets a service using a raw Phalcon\Di\Service definition * * @param string $name - * @param \Phalcon\Di\ServiceInterface $rawDefinition - * @return \Phalcon\Di\ServiceInterface + * @param ServiceInterface $rawDefinition + * @return ServiceInterface */ - public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface; + public function setRaw(string $name, ServiceInterface $rawDefinition): ServiceInterface; /** * Registers an "always shared" service in the services container * * @param string $name * @param mixed $definition - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; + } diff --git a/src/Phalcon/Di/Exception.php b/src/Phalcon/Di/Exception.php new file mode 100644 index 00000000..6b048c47 --- /dev/null +++ b/src/Phalcon/Di/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Di; + +/** + * Exceptions thrown in Phalcon\Di will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Di/Exception/ServiceResolutionException.php b/src/Phalcon/Di/Exception/ServiceResolutionException.php new file mode 100644 index 00000000..bee2d1e1 --- /dev/null +++ b/src/Phalcon/Di/Exception/ServiceResolutionException.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Di\Exception; + +/** + * Phalcon\Di\Exception\ServiceResolutionException + */ +class ServiceResolutionException extends \Phalcon\Di\Exception +{ + +} diff --git a/src/Phalcon/di/FactoryDefault.php b/src/Phalcon/Di/FactoryDefault.php similarity index 66% rename from src/Phalcon/di/FactoryDefault.php rename to src/Phalcon/Di/FactoryDefault.php index 3478549d..5ef10181 100644 --- a/src/Phalcon/di/FactoryDefault.php +++ b/src/Phalcon/Di/FactoryDefault.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -17,4 +24,5 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } + } diff --git a/src/Phalcon/di/factorydefault/Cli.php b/src/Phalcon/Di/FactoryDefault/Cli.php similarity index 70% rename from src/Phalcon/di/factorydefault/Cli.php rename to src/Phalcon/Di/FactoryDefault/Cli.php index f7c4b2d3..2536e2aa 100644 --- a/src/Phalcon/di/factorydefault/Cli.php +++ b/src/Phalcon/Di/FactoryDefault/Cli.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di\FactoryDefault; use Phalcon\Di\FactoryDefault; @@ -21,4 +28,5 @@ class Cli extends FactoryDefault public function __construct() { } + } diff --git a/src/Phalcon/di/Injectable.php b/src/Phalcon/Di/Injectable.php similarity index 85% rename from src/Phalcon/di/Injectable.php rename to src/Phalcon/Di/Injectable.php index f7382c65..3ddbd7b7 100644 --- a/src/Phalcon/di/Injectable.php +++ b/src/Phalcon/Di/Injectable.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; use Phalcon\Session\BagInterface; @@ -33,7 +40,7 @@ * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ -abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface +abstract class Injectable implements Phalcon\Di\InjectionAwareInterface { /** * Dependency Injector @@ -66,7 +73,7 @@ public function __isset(string $name): bool /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -75,9 +82,11 @@ public function getDI(): DiInterface /** * Sets the dependency injector * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container + * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } + } diff --git a/src/Phalcon/di/InjectionAwareInterface.php b/src/Phalcon/Di/InjectionAwareInterface.php similarity index 50% rename from src/Phalcon/di/InjectionAwareInterface.php rename to src/Phalcon/Di/InjectionAwareInterface.php index 3bf3ec3b..72cd4198 100644 --- a/src/Phalcon/di/InjectionAwareInterface.php +++ b/src/Phalcon/Di/InjectionAwareInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -12,14 +19,16 @@ interface InjectionAwareInterface /** * Sets the dependency injector * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container + * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container); + public function setDI(DiInterface $container); /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface; + } diff --git a/src/Phalcon/di/Service.php b/src/Phalcon/Di/Service.php similarity index 81% rename from src/Phalcon/di/Service.php rename to src/Phalcon/Di/Service.php index 3de49845..3fb77b6a 100644 --- a/src/Phalcon/di/Service.php +++ b/src/Phalcon/Di/Service.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -14,7 +21,7 @@ * $request = service->resolve(); * ``` */ -class Service implements \Phalcon\Di\ServiceInterface +class Service implements Phalcon\Di\ServiceInterface { protected $definition; @@ -55,8 +62,8 @@ public function getDefinition() /** * Returns a parameter in a specific position * - * @param int $position * @return array + * @param int $position */ public function getParameter(int $position) { @@ -84,10 +91,10 @@ public function isShared(): bool * Resolves the service * * @param array $parameters - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return mixed */ - public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null) + public function resolve($parameters = null, DiInterface $container = null) { } @@ -95,6 +102,7 @@ public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = * Set the service definition * * @param mixed $definition + * @return void */ public function setDefinition($definition) { @@ -105,7 +113,7 @@ public function setDefinition($definition) * * @param int $position * @param array $parameter - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function setParameter(int $position, array $parameter): ServiceInterface { @@ -115,6 +123,7 @@ public function setParameter(int $position, array $parameter): ServiceInterface * Sets if the service is shared or not * * @param bool $shared + * @return void */ public function setShared(bool $shared) { @@ -124,8 +133,10 @@ public function setShared(bool $shared) * Sets/Resets the shared instance related to the service * * @param mixed $sharedInstance + * @return void */ public function setSharedInstance($sharedInstance) { } + } diff --git a/src/Phalcon/di/service/Builder.php b/src/Phalcon/Di/Service/Builder.php similarity index 82% rename from src/Phalcon/di/service/Builder.php rename to src/Phalcon/Di/Service/Builder.php index 2886678e..57fffd66 100644 --- a/src/Phalcon/di/service/Builder.php +++ b/src/Phalcon/Di/Service/Builder.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di\Service; /** @@ -14,9 +21,9 @@ class Builder * Builds a service using a complex service definition * * @param array $parameters + * @return mixed * @param \Phalcon\Di\DiInterface $container * @param array $definition - * @return mixed */ public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) { @@ -25,10 +32,10 @@ public function build(\Phalcon\Di\DiInterface $container, array $definition, $pa /** * Resolves a constructor/call parameter * + * @return mixed * @param \Phalcon\Di\DiInterface $container * @param int $position * @param array $argument - * @return mixed */ private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) { @@ -44,4 +51,5 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array { } + } diff --git a/src/Phalcon/di/ServiceInterface.php b/src/Phalcon/Di/ServiceInterface.php similarity index 79% rename from src/Phalcon/di/ServiceInterface.php rename to src/Phalcon/Di/ServiceInterface.php index 7771819c..31af1fe3 100644 --- a/src/Phalcon/di/ServiceInterface.php +++ b/src/Phalcon/Di/ServiceInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -18,8 +25,8 @@ public function getDefinition(); /** * Returns a parameter in a specific position * - * @param int $position * @return array + * @param int $position */ public function getParameter(int $position); @@ -41,10 +48,10 @@ public function isShared(): bool; * Resolves the service * * @param array $parameters - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return mixed */ - public function resolve($parameters = null, \Phalcon\Di\DiInterface $container = null); + public function resolve($parameters = null, DiInterface $container = null); /** * Set the service definition @@ -68,4 +75,5 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); + } diff --git a/src/Phalcon/di/ServiceProviderInterface.php b/src/Phalcon/Di/ServiceProviderInterface.php similarity index 67% rename from src/Phalcon/di/ServiceProviderInterface.php rename to src/Phalcon/Di/ServiceProviderInterface.php index 6756aa83..bde1316f 100644 --- a/src/Phalcon/di/ServiceProviderInterface.php +++ b/src/Phalcon/Di/ServiceProviderInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Di; /** @@ -32,7 +39,9 @@ interface ServiceProviderInterface /** * Registers a service provider. * - * @param \Phalcon\Di\DiInterface $di + * @param DiInterface $di + * @return void */ - public function register(\Phalcon\Di\DiInterface $di); + public function register(DiInterface $di); + } diff --git a/src/Phalcon/dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php similarity index 92% rename from src/Phalcon/dispatcher/AbstractDispatcher.php rename to src/Phalcon/Dispatcher/AbstractDispatcher.php index ec2af170..e8033256 100644 --- a/src/Phalcon/dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Dispatcher; use Phalcon\Di\AbstractInjectionAware; @@ -11,7 +18,7 @@ * This class can't be instantiated directly, you can use it to create your own * dispatchers. */ -abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractDispatcher extends AbstractInjectionAware implements Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface { protected $activeHandler; @@ -146,8 +153,9 @@ public function dispatch(): bool * ); * ``` * - * @param array $forward * @throws \Phalcon\Exception + * @param array $forward + * @return void */ public function forward(array $forward) { @@ -212,7 +220,7 @@ public function getDefaultNamespace(): string /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -230,7 +238,7 @@ public function getHandlerSuffix(): string /** * Gets model binder * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @return mixed */ public function getModelBinder(): ?BinderInterface { @@ -299,6 +307,7 @@ public function isFinished(): bool * Sets the action name to be dispatched * * @param string $actionName + * @return void */ public function setActionName(string $actionName) { @@ -308,6 +317,7 @@ public function setActionName(string $actionName) * Sets the default action name * * @param string $actionName + * @return void */ public function setDefaultAction(string $actionName) { @@ -317,6 +327,7 @@ public function setDefaultAction(string $actionName) * Sets the default namespace * * @param string $namespaceName + * @return void */ public function setDefaultNamespace(string $namespaceName) { @@ -336,6 +347,7 @@ public function getHandlerClass(): string * * @param mixed $param * @param mixed $value + * @return void */ public function setParam($param, $value) { @@ -345,6 +357,7 @@ public function setParam($param, $value) * Sets action params to be dispatched * * @param array $params + * @return void */ public function setParams(array $params) { @@ -354,6 +367,7 @@ public function setParams(array $params) * Sets the latest returned value by an action manually * * @param mixed $value + * @return void */ public function setReturnedValue($value) { @@ -363,6 +377,7 @@ public function setReturnedValue($value) * Sets the default action suffix * * @param string $actionSuffix + * @return void */ public function setActionSuffix(string $actionSuffix) { @@ -372,6 +387,7 @@ public function setActionSuffix(string $actionSuffix) * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -381,6 +397,7 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * Sets the default suffix for the handler * * @param string $handlerSuffix + * @return void */ public function setHandlerSuffix(string $handlerSuffix) { @@ -407,7 +424,7 @@ public function setHandlerSuffix(string $handlerSuffix) * * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder * @param mixed $cache - * @return \Phalcon\Dispatcher\DispatcherInterface + * @return DispatcherInterface */ public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): DispatcherInterface { @@ -417,6 +434,7 @@ public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, * Sets the module where the controller is (only informative) * * @param string $moduleName + * @return void */ public function setModuleName(string $moduleName) { @@ -426,6 +444,7 @@ public function setModuleName(string $moduleName) * Sets the namespace where the controller class is * * @param string $namespaceName + * @return void */ public function setNamespaceName(string $namespaceName) { @@ -451,6 +470,8 @@ public function wasForwarded(): bool /** * Set empty properties to their defaults (where defaults are available) + * + * @return void */ protected function resolveEmptyProperties() { @@ -463,4 +484,5 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } + } diff --git a/src/Phalcon/dispatcher/DispatcherInterface.php b/src/Phalcon/Dispatcher/DispatcherInterface.php similarity index 87% rename from src/Phalcon/dispatcher/DispatcherInterface.php rename to src/Phalcon/Dispatcher/DispatcherInterface.php index c8ff6675..952c39e1 100644 --- a/src/Phalcon/dispatcher/DispatcherInterface.php +++ b/src/Phalcon/Dispatcher/DispatcherInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Dispatcher; /** @@ -19,6 +26,7 @@ public function dispatch(): bool; * Forwards the execution flow to another controller/action * * @param array $forward + * @return void */ public function forward(array $forward); @@ -86,6 +94,7 @@ public function isFinished(): bool; * Sets the action name to be dispatched * * @param string $actionName + * @return void */ public function setActionName(string $actionName); @@ -93,6 +102,7 @@ public function setActionName(string $actionName); * Sets the default action suffix * * @param string $actionSuffix + * @return void */ public function setActionSuffix(string $actionSuffix); @@ -100,6 +110,7 @@ public function setActionSuffix(string $actionSuffix); * Sets the default action name * * @param string $actionName + * @return void */ public function setDefaultAction(string $actionName); @@ -107,6 +118,7 @@ public function setDefaultAction(string $actionName); * Sets the default namespace * * @param string $defaultNamespace + * @return void */ public function setDefaultNamespace(string $defaultNamespace); @@ -114,6 +126,7 @@ public function setDefaultNamespace(string $defaultNamespace); * Sets the default suffix for the handler * * @param string $handlerSuffix + * @return void */ public function setHandlerSuffix(string $handlerSuffix); @@ -121,6 +134,7 @@ public function setHandlerSuffix(string $handlerSuffix); * Sets the module name which the application belongs to * * @param string $moduleName + * @return void */ public function setModuleName(string $moduleName); @@ -128,6 +142,7 @@ public function setModuleName(string $moduleName); * Sets the namespace which the controller belongs to * * @param string $namespaceName + * @return void */ public function setNamespaceName(string $namespaceName); @@ -136,6 +151,7 @@ public function setNamespaceName(string $namespaceName); * * @param mixed $value * @param mixed $param + * @return void */ public function setParam($param, $value); @@ -143,6 +159,8 @@ public function setParam($param, $value); * Sets action params to be dispatched * * @param array $params + * @return void */ public function setParams(array $params); + } diff --git a/src/Phalcon/dispatcher/Exception.php b/src/Phalcon/Dispatcher/Exception.php similarity index 63% rename from src/Phalcon/dispatcher/Exception.php rename to src/Phalcon/Dispatcher/Exception.php index cad099de..fb0da6ee 100644 --- a/src/Phalcon/dispatcher/Exception.php +++ b/src/Phalcon/Dispatcher/Exception.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Dispatcher; /** @@ -24,4 +31,6 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; + + } diff --git a/src/Phalcon/domain/payload/Payload.php b/src/Phalcon/Domain/Payload/Payload.php similarity index 79% rename from src/Phalcon/domain/payload/Payload.php rename to src/Phalcon/Domain/Payload/Payload.php index 8be33d5e..70ea8595 100644 --- a/src/Phalcon/domain/payload/Payload.php +++ b/src/Phalcon/Domain/Payload/Payload.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Domain\Payload; /** * Holds the payload */ -class Payload implements \Phalcon\Domain\Payload\PayloadInterface +class Payload implements Phalcon\Domain\Payload\PayloadInterface { /** * Extra information @@ -92,7 +99,7 @@ public function getOutput() * Sets arbitrary extra domain information. * * @param mixed $extras - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setExtras($extras): PayloadInterface { @@ -102,7 +109,7 @@ public function setExtras($extras): PayloadInterface * Sets the domain input. * * @param mixed $input - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setInput($input): PayloadInterface { @@ -112,7 +119,7 @@ public function setInput($input): PayloadInterface * Sets the domain messages. * * @param mixed $messages - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setMessages($messages): PayloadInterface { @@ -122,7 +129,7 @@ public function setMessages($messages): PayloadInterface * Sets the domain output. * * @param mixed $output - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setOutput($output): PayloadInterface { @@ -132,9 +139,10 @@ public function setOutput($output): PayloadInterface * Sets the payload status. * * @param mixed $status - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setStatus($status): PayloadInterface { } + } diff --git a/src/Phalcon/Domain/Payload/PayloadFactory.php b/src/Phalcon/Domain/Payload/PayloadFactory.php new file mode 100644 index 00000000..518657a0 --- /dev/null +++ b/src/Phalcon/Domain/Payload/PayloadFactory.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Domain\Payload; + +/** + * Factory to create payload objects + */ +class PayloadFactory +{ + + /** + * Instantiate a new object + * + * @return PayloadInterface + */ + public function newInstance(): PayloadInterface + { + } + +} diff --git a/src/Phalcon/Domain/Payload/PayloadInterface.php b/src/Phalcon/Domain/Payload/PayloadInterface.php new file mode 100644 index 00000000..ebd39d11 --- /dev/null +++ b/src/Phalcon/Domain/Payload/PayloadInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Domain\Payload; + +/** + * This interface is used for consumers + */ +interface PayloadInterface extends Phalcon\Domain\Payload\ReadableInterface, Phalcon\Domain\Payload\WriteableInterface +{ + +} diff --git a/src/Phalcon/domain/payload/ReadableInterface.php b/src/Phalcon/Domain/Payload/ReadableInterface.php similarity index 77% rename from src/Phalcon/domain/payload/ReadableInterface.php rename to src/Phalcon/Domain/Payload/ReadableInterface.php index cac33ff9..0e3fbad3 100644 --- a/src/Phalcon/domain/payload/ReadableInterface.php +++ b/src/Phalcon/Domain/Payload/ReadableInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Domain\Payload; /** @@ -42,4 +49,5 @@ public function getMessages(); * @return mixed */ public function getExtras(); + } diff --git a/src/Phalcon/domain/payload/Status.php b/src/Phalcon/Domain/Payload/Status.php similarity index 80% rename from src/Phalcon/domain/payload/Status.php rename to src/Phalcon/Domain/Payload/Status.php index 6d3b632c..03f52886 100644 --- a/src/Phalcon/domain/payload/Status.php +++ b/src/Phalcon/Domain/Payload/Status.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Domain\Payload; /** @@ -74,4 +81,5 @@ class Status final private function __construct() { } + } diff --git a/src/Phalcon/domain/payload/WriteableInterface.php b/src/Phalcon/Domain/Payload/WriteableInterface.php similarity index 75% rename from src/Phalcon/domain/payload/WriteableInterface.php rename to src/Phalcon/Domain/Payload/WriteableInterface.php index 08bbd422..0228bb9e 100644 --- a/src/Phalcon/domain/payload/WriteableInterface.php +++ b/src/Phalcon/Domain/Payload/WriteableInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Domain\Payload; /** @@ -12,7 +19,7 @@ interface WriteableInterface * Sets the status of this payload. * * @param mixed $status The status for this payload. - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setStatus($status): PayloadInterface; @@ -22,7 +29,7 @@ public function setStatus($status): PayloadInterface; * * @param mixed $input The input received by the domain layer. * - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setInput($input): PayloadInterface; @@ -30,7 +37,7 @@ public function setInput($input): PayloadInterface; * Sets the output produced from the domain layer. * * @param mixed $output The output produced from the domain layer. - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setOutput($output): PayloadInterface; @@ -38,7 +45,7 @@ public function setOutput($output): PayloadInterface; * Sets the messages produced by the domain layer. * * @param mixed $messages The messages produced by the domain layer. - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setMessages($messages): PayloadInterface; @@ -46,7 +53,8 @@ public function setMessages($messages): PayloadInterface; * Sets arbitrary extra values produced by the domain layer. * * @param mixed $extras Arbitrary extra values produced by the domain layer. - * @return \Phalcon\Domain\Payload\PayloadInterface + * @return PayloadInterface */ public function setExtras($extras): PayloadInterface; + } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index 5e8c1236..eb891448 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -129,6 +136,7 @@ final public function normalizeEncoding(string $str): string * ``` * * @param bool $doubleEncode + * @return void */ public function setDoubleEncode(bool $doubleEncode) { @@ -142,6 +150,7 @@ public function setDoubleEncode(bool $doubleEncode) * ``` * * @param string $encoding + * @return void */ public function setEncoding(string $encoding) { @@ -155,8 +164,10 @@ public function setEncoding(string $encoding) * ``` * * @param int $quoteType + * @return void */ public function setHtmlQuoteType(int $quoteType) { } + } diff --git a/src/Phalcon/escaper/EscaperInterface.php b/src/Phalcon/Escaper/EscaperInterface.php similarity index 85% rename from src/Phalcon/escaper/EscaperInterface.php rename to src/Phalcon/Escaper/EscaperInterface.php index 282aa24c..d067a4d3 100644 --- a/src/Phalcon/escaper/EscaperInterface.php +++ b/src/Phalcon/Escaper/EscaperInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Escaper; /** @@ -61,6 +68,7 @@ public function getEncoding(): string; * Sets the encoding to be used by the escaper * * @param string $encoding + * @return void */ public function setEncoding(string $encoding); @@ -68,6 +76,8 @@ public function setEncoding(string $encoding); * Sets the HTML quoting type for htmlspecialchars * * @param int $quoteType + * @return void */ public function setHtmlQuoteType(int $quoteType); + } diff --git a/src/Phalcon/Escaper/Exception.php b/src/Phalcon/Escaper/Exception.php new file mode 100644 index 00000000..6e3b8bd3 --- /dev/null +++ b/src/Phalcon/Escaper/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Escaper; + +/** + * Exceptions thrown in Phalcon\Escaper will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/events/Event.php b/src/Phalcon/Events/Event.php similarity index 89% rename from src/Phalcon/events/Event.php rename to src/Phalcon/Events/Event.php index 87441b61..3166c89e 100644 --- a/src/Phalcon/events/Event.php +++ b/src/Phalcon/Events/Event.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Events; /** @@ -17,7 +24,7 @@ * } * ``` */ -class Event implements \Phalcon\Events\EventInterface +class Event implements Phalcon\Events\EventInterface { /** * Is event cancelable? @@ -152,4 +159,5 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } + } diff --git a/src/Phalcon/events/EventInterface.php b/src/Phalcon/Events/EventInterface.php similarity index 82% rename from src/Phalcon/events/EventInterface.php rename to src/Phalcon/Events/EventInterface.php index 8ac004c0..02ed6dd1 100644 --- a/src/Phalcon/events/EventInterface.php +++ b/src/Phalcon/Events/EventInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Events; /** @@ -60,4 +67,5 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; + } diff --git a/src/Phalcon/events/EventsAwareInterface.php b/src/Phalcon/Events/EventsAwareInterface.php similarity index 65% rename from src/Phalcon/events/EventsAwareInterface.php rename to src/Phalcon/Events/EventsAwareInterface.php index 971d263e..aa0509f4 100644 --- a/src/Phalcon/events/EventsAwareInterface.php +++ b/src/Phalcon/Events/EventsAwareInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Events; /** @@ -14,7 +21,7 @@ interface EventsAwareInterface /** * Returns the internal event manager * - * @return null|ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface; @@ -22,6 +29,8 @@ public function getEventsManager(): ?ManagerInterface; * Sets the events manager * * @param ManagerInterface $eventsManager + * @return void */ public function setEventsManager(ManagerInterface $eventsManager); + } diff --git a/src/Phalcon/Events/Exception.php b/src/Phalcon/Events/Exception.php new file mode 100644 index 00000000..fe8199d5 --- /dev/null +++ b/src/Phalcon/Events/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Events; + +/** + * Phalcon\Events\Exception + * + * Exceptions thrown in Phalcon\Events will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/events/Manager.php b/src/Phalcon/Events/Manager.php similarity index 89% rename from src/Phalcon/events/Manager.php rename to src/Phalcon/Events/Manager.php index ed672b84..612b43c4 100644 --- a/src/Phalcon/events/Manager.php +++ b/src/Phalcon/Events/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Events; /** @@ -10,7 +17,7 @@ * can create hooks or plugins that will offer monitoring of data, manipulation, * conditional execution and much more. */ -class Manager implements \Phalcon\Events\ManagerInterface +class Manager implements Phalcon\Events\ManagerInterface { const DEFAULT_PRIORITY = 100; @@ -38,6 +45,7 @@ class Manager implements \Phalcon\Events\ManagerInterface * @param object|callable $handler * @param string $eventType * @param int $priority + * @return void */ public function attach(string $eventType, $handler, int $priority = self::DEFAULT_PRIORITY) { @@ -57,6 +65,7 @@ public function arePrioritiesEnabled(): bool * by every registered listener in a single fire * * @param bool $collect + * @return void */ public function collectResponses(bool $collect) { @@ -67,6 +76,7 @@ public function collectResponses(bool $collect) * * @param object $handler * @param string $eventType + * @return void */ public function detach(string $eventType, $handler) { @@ -76,6 +86,7 @@ public function detach(string $eventType, $handler) * Removes all events from the EventsManager * * @param string $type + * @return void */ public function detachAll(string $type = null) { @@ -85,6 +96,7 @@ public function detachAll(string $type = null) * Set if priorities are enabled in the EventsManager * * @param bool $enablePriorities + * @return void */ public function enablePriorities(bool $enablePriorities) { @@ -100,9 +112,9 @@ public function enablePriorities(bool $enablePriorities) * * @param object $source * @param mixed $data + * @return mixed * @param string $eventType * @param bool $cancelable - * @return mixed */ public function fire(string $eventType, $source, $data = null, bool $cancelable = true) { @@ -111,9 +123,9 @@ public function fire(string $eventType, $source, $data = null, bool $cancelable /** * Internal handler to call a queue of events * + * @return mixed * @param \SplPriorityQueue $queue * @param EventInterface $event - * @return mixed */ final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) { @@ -158,4 +170,5 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } + } diff --git a/src/Phalcon/events/ManagerInterface.php b/src/Phalcon/Events/ManagerInterface.php similarity index 85% rename from src/Phalcon/events/ManagerInterface.php rename to src/Phalcon/Events/ManagerInterface.php index bad1e4bb..e6ba4fbe 100644 --- a/src/Phalcon/events/ManagerInterface.php +++ b/src/Phalcon/Events/ManagerInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Events; /** @@ -18,6 +25,7 @@ interface ManagerInterface * * @param object|callable $handler * @param string $eventType + * @return void */ public function attach(string $eventType, $handler); @@ -26,6 +34,7 @@ public function attach(string $eventType, $handler); * * @param object $handler * @param string $eventType + * @return void */ public function detach(string $eventType, $handler); @@ -33,6 +42,7 @@ public function detach(string $eventType, $handler); * Removes all events from the EventsManager * * @param string $type + * @return void */ public function detachAll(string $type = null); @@ -42,9 +52,9 @@ public function detachAll(string $type = null); * * @param object $source * @param mixed $data + * @return mixed * @param string $eventType * @param bool $cancelable - * @return mixed */ public function fire(string $eventType, $source, $data = null, bool $cancelable = true); @@ -63,4 +73,5 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; + } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 2c453056..ac2afe29 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -7,7 +14,7 @@ * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception implements \Throwable +class Exception extends \Exception implements Throwable { /** @@ -17,4 +24,5 @@ class Exception extends \Exception implements \Throwable public static function containerServiceNotFound(string $service): string { } + } diff --git a/src/Phalcon/factory/AbstractFactory.php b/src/Phalcon/Factory/AbstractFactory.php similarity index 80% rename from src/Phalcon/factory/AbstractFactory.php rename to src/Phalcon/Factory/AbstractFactory.php index 7c7a381f..bace4908 100644 --- a/src/Phalcon/factory/AbstractFactory.php +++ b/src/Phalcon/Factory/AbstractFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Factory; /** @@ -27,6 +34,7 @@ abstract class AbstractFactory * Checks if a service exists and throws an exception * * @param string $name + * @return void */ protected function checkService(string $name) { @@ -53,8 +61,10 @@ abstract protected function getAdapters(): array; * AdapterFactory constructor. * * @param array $services + * @return void */ protected function init(array $services = array()) { } + } diff --git a/src/Phalcon/Factory/Exception.php b/src/Phalcon/Factory/Exception.php new file mode 100644 index 00000000..7561e49a --- /dev/null +++ b/src/Phalcon/Factory/Exception.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Factory; + +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index 93fff9a7..4af061d9 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -129,6 +136,7 @@ public function sanitize($value, $sanitizers, bool $noRecursive = false) * * @param string $name * @param callable $service + * @return void */ public function set(string $name, $service) { @@ -138,6 +146,7 @@ public function set(string $name, $service) * Loads the objects in the internal mapper array * * @param array $mapper + * @return void */ protected function init(array $mapper) { @@ -166,4 +175,5 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } + } diff --git a/src/Phalcon/Filter/Exception.php b/src/Phalcon/Filter/Exception.php new file mode 100644 index 00000000..d1dd3b40 --- /dev/null +++ b/src/Phalcon/Filter/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Filter; + +/** + * Phalcon\Filter\Exception + * + * Exceptions thrown in Phalcon\Filter will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/filter/FilterFactory.php b/src/Phalcon/Filter/FilterFactory.php similarity index 68% rename from src/Phalcon/filter/FilterFactory.php rename to src/Phalcon/Filter/FilterFactory.php index e79b82ae..69735a20 100644 --- a/src/Phalcon/filter/FilterFactory.php +++ b/src/Phalcon/Filter/FilterFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter; /** @@ -17,7 +24,7 @@ class FilterFactory * Returns a Locator object with all the helpers defined in anonynous * functions * - * @return \Phalcon\Filter\FilterInterface + * @return FilterInterface */ public function newInstance(): FilterInterface { @@ -29,4 +36,5 @@ public function newInstance(): FilterInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/filter/FilterInterface.php b/src/Phalcon/Filter/FilterInterface.php similarity index 64% rename from src/Phalcon/filter/FilterInterface.php rename to src/Phalcon/Filter/FilterInterface.php index ffa0fea8..a455a176 100644 --- a/src/Phalcon/filter/FilterInterface.php +++ b/src/Phalcon/Filter/FilterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter; /** @@ -17,4 +24,5 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); + } diff --git a/src/Phalcon/filter/sanitize/AbsInt.php b/src/Phalcon/Filter/Sanitize/AbsInt.php similarity index 53% rename from src/Phalcon/filter/sanitize/AbsInt.php rename to src/Phalcon/Filter/Sanitize/AbsInt.php index 8cceb179..5b155476 100644 --- a/src/Phalcon/filter/sanitize/AbsInt.php +++ b/src/Phalcon/Filter/Sanitize/AbsInt.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class AbsInt public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Alnum.php b/src/Phalcon/Filter/Sanitize/Alnum.php similarity index 53% rename from src/Phalcon/filter/sanitize/Alnum.php rename to src/Phalcon/Filter/Sanitize/Alnum.php index 533abeff..29516b2e 100644 --- a/src/Phalcon/filter/sanitize/Alnum.php +++ b/src/Phalcon/Filter/Sanitize/Alnum.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Alnum public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Alpha.php b/src/Phalcon/Filter/Sanitize/Alpha.php similarity index 53% rename from src/Phalcon/filter/sanitize/Alpha.php rename to src/Phalcon/Filter/Sanitize/Alpha.php index 5c4a764b..65c9ad74 100644 --- a/src/Phalcon/filter/sanitize/Alpha.php +++ b/src/Phalcon/Filter/Sanitize/Alpha.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Alpha public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/BoolVal.php b/src/Phalcon/Filter/Sanitize/BoolVal.php similarity index 52% rename from src/Phalcon/filter/sanitize/BoolVal.php rename to src/Phalcon/Filter/Sanitize/BoolVal.php index d3d4708c..09aa4364 100644 --- a/src/Phalcon/filter/sanitize/BoolVal.php +++ b/src/Phalcon/Filter/Sanitize/BoolVal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class BoolVal public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Email.php b/src/Phalcon/Filter/Sanitize/Email.php similarity index 52% rename from src/Phalcon/filter/sanitize/Email.php rename to src/Phalcon/Filter/Sanitize/Email.php index 6efc92fa..5dfab0c8 100644 --- a/src/Phalcon/filter/sanitize/Email.php +++ b/src/Phalcon/Filter/Sanitize/Email.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Email public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/FloatVal.php b/src/Phalcon/Filter/Sanitize/FloatVal.php similarity index 52% rename from src/Phalcon/filter/sanitize/FloatVal.php rename to src/Phalcon/Filter/Sanitize/FloatVal.php index 916a7c04..6341decf 100644 --- a/src/Phalcon/filter/sanitize/FloatVal.php +++ b/src/Phalcon/Filter/Sanitize/FloatVal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class FloatVal public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/IntVal.php b/src/Phalcon/Filter/Sanitize/IntVal.php similarity index 52% rename from src/Phalcon/filter/sanitize/IntVal.php rename to src/Phalcon/Filter/Sanitize/IntVal.php index 98445ffc..1583ff87 100644 --- a/src/Phalcon/filter/sanitize/IntVal.php +++ b/src/Phalcon/Filter/Sanitize/IntVal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class IntVal public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Lower.php b/src/Phalcon/Filter/Sanitize/Lower.php similarity index 53% rename from src/Phalcon/filter/sanitize/Lower.php rename to src/Phalcon/Filter/Sanitize/Lower.php index 19aaad22..a61fa1c6 100644 --- a/src/Phalcon/filter/sanitize/Lower.php +++ b/src/Phalcon/Filter/Sanitize/Lower.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Lower public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/LowerFirst.php b/src/Phalcon/Filter/Sanitize/LowerFirst.php similarity index 54% rename from src/Phalcon/filter/sanitize/LowerFirst.php rename to src/Phalcon/Filter/Sanitize/LowerFirst.php index 70f5a0bc..d331cf11 100644 --- a/src/Phalcon/filter/sanitize/LowerFirst.php +++ b/src/Phalcon/Filter/Sanitize/LowerFirst.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class LowerFirst public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Regex.php b/src/Phalcon/Filter/Sanitize/Regex.php similarity index 59% rename from src/Phalcon/filter/sanitize/Regex.php rename to src/Phalcon/Filter/Sanitize/Regex.php index f7aa7910..8817613c 100644 --- a/src/Phalcon/filter/sanitize/Regex.php +++ b/src/Phalcon/Filter/Sanitize/Regex.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -18,4 +25,5 @@ class Regex public function __invoke($input, $pattern, $replace) { } + } diff --git a/src/Phalcon/filter/sanitize/Remove.php b/src/Phalcon/Filter/Sanitize/Remove.php similarity index 57% rename from src/Phalcon/filter/sanitize/Remove.php rename to src/Phalcon/Filter/Sanitize/Remove.php index a556ef0f..1c7a90e5 100644 --- a/src/Phalcon/filter/sanitize/Remove.php +++ b/src/Phalcon/Filter/Sanitize/Remove.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -17,4 +24,5 @@ class Remove public function __invoke($input, $replace) { } + } diff --git a/src/Phalcon/filter/sanitize/Replace.php b/src/Phalcon/Filter/Sanitize/Replace.php similarity index 59% rename from src/Phalcon/filter/sanitize/Replace.php rename to src/Phalcon/Filter/Sanitize/Replace.php index 6117afa9..05a72069 100644 --- a/src/Phalcon/filter/sanitize/Replace.php +++ b/src/Phalcon/Filter/Sanitize/Replace.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -18,4 +25,5 @@ class Replace public function __invoke($input, $from, $to) { } + } diff --git a/src/Phalcon/filter/sanitize/Special.php b/src/Phalcon/Filter/Sanitize/Special.php similarity index 53% rename from src/Phalcon/filter/sanitize/Special.php rename to src/Phalcon/Filter/Sanitize/Special.php index fe890c36..33735f44 100644 --- a/src/Phalcon/filter/sanitize/Special.php +++ b/src/Phalcon/Filter/Sanitize/Special.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Special public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/SpecialFull.php b/src/Phalcon/Filter/Sanitize/SpecialFull.php similarity index 57% rename from src/Phalcon/filter/sanitize/SpecialFull.php rename to src/Phalcon/Filter/Sanitize/SpecialFull.php index 04564d3a..5170dfb7 100644 --- a/src/Phalcon/filter/sanitize/SpecialFull.php +++ b/src/Phalcon/Filter/Sanitize/SpecialFull.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class SpecialFull public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/StringVal.php b/src/Phalcon/Filter/Sanitize/StringVal.php similarity index 52% rename from src/Phalcon/filter/sanitize/StringVal.php rename to src/Phalcon/Filter/Sanitize/StringVal.php index db0866a0..798afafc 100644 --- a/src/Phalcon/filter/sanitize/StringVal.php +++ b/src/Phalcon/Filter/Sanitize/StringVal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class StringVal public function __invoke($input) { } + } diff --git a/src/Phalcon/filter/sanitize/Striptags.php b/src/Phalcon/Filter/Sanitize/Striptags.php similarity index 53% rename from src/Phalcon/filter/sanitize/Striptags.php rename to src/Phalcon/Filter/Sanitize/Striptags.php index 72f8bf05..94588b4a 100644 --- a/src/Phalcon/filter/sanitize/Striptags.php +++ b/src/Phalcon/Filter/Sanitize/Striptags.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Striptags public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Trim.php b/src/Phalcon/Filter/Sanitize/Trim.php similarity index 55% rename from src/Phalcon/filter/sanitize/Trim.php rename to src/Phalcon/Filter/Sanitize/Trim.php index c325fc47..73b27c53 100644 --- a/src/Phalcon/filter/sanitize/Trim.php +++ b/src/Phalcon/Filter/Sanitize/Trim.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Trim public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Upper.php b/src/Phalcon/Filter/Sanitize/Upper.php similarity index 53% rename from src/Phalcon/filter/sanitize/Upper.php rename to src/Phalcon/Filter/Sanitize/Upper.php index 3baed094..b6232b24 100644 --- a/src/Phalcon/filter/sanitize/Upper.php +++ b/src/Phalcon/Filter/Sanitize/Upper.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Upper public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/UpperFirst.php b/src/Phalcon/Filter/Sanitize/UpperFirst.php similarity index 54% rename from src/Phalcon/filter/sanitize/UpperFirst.php rename to src/Phalcon/Filter/Sanitize/UpperFirst.php index afbc238b..29abcedd 100644 --- a/src/Phalcon/filter/sanitize/UpperFirst.php +++ b/src/Phalcon/Filter/Sanitize/UpperFirst.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class UpperFirst public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/UpperWords.php b/src/Phalcon/Filter/Sanitize/UpperWords.php similarity index 57% rename from src/Phalcon/filter/sanitize/UpperWords.php rename to src/Phalcon/Filter/Sanitize/UpperWords.php index 8f24dc60..1a7a72e5 100644 --- a/src/Phalcon/filter/sanitize/UpperWords.php +++ b/src/Phalcon/Filter/Sanitize/UpperWords.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class UpperWords public function __invoke(string $input) { } + } diff --git a/src/Phalcon/filter/sanitize/Url.php b/src/Phalcon/Filter/Sanitize/Url.php similarity index 51% rename from src/Phalcon/filter/sanitize/Url.php rename to src/Phalcon/Filter/Sanitize/Url.php index ac80afde..fdd131c4 100644 --- a/src/Phalcon/filter/sanitize/Url.php +++ b/src/Phalcon/Filter/Sanitize/Url.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Filter\Sanitize; /** @@ -16,4 +23,5 @@ class Url public function __invoke($input) { } + } diff --git a/src/Phalcon/firewall/adapter/AbstractAdapter.php b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php similarity index 90% rename from src/Phalcon/firewall/adapter/AbstractAdapter.php rename to src/Phalcon/Firewall/Adapter/AbstractAdapter.php index 5f9c0c44..a11986ca 100644 --- a/src/Phalcon/firewall/adapter/AbstractAdapter.php +++ b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Firewall\Adapter; use Closure; @@ -10,7 +17,7 @@ /** * Adapter for Phalcon\Firewall adapters */ -abstract class AbstractAdapter implements \Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Storing active identity object implementing Phalcon/Acl/RoleAware @@ -92,7 +99,7 @@ public function getDefaultAccess(): int /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -101,7 +108,7 @@ public function getEventsManager(): ManagerInterface /** * Gets role callback to fetch role name * - * @return \Closure + * @return Closure */ public function getRoleCallback(): Closure { @@ -140,6 +147,7 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -159,6 +167,7 @@ public function setRoleCallback(\Closure $callback): AdapterInterface * Sets always resolving role option * * @param bool $alwaysResolvingRole + * @return void */ public function setAlwaysResolvingRole(bool $alwaysResolvingRole) { @@ -166,6 +175,7 @@ public function setAlwaysResolvingRole(bool $alwaysResolvingRole) /** * @param \Phalcon\Di\DiInterface $container + * @return void */ protected function callRoleCallback(\Phalcon\Di\DiInterface $container) { @@ -209,6 +219,7 @@ protected function fireEventOrThrowException($role, string $actionName, string $ * * @param string $key * @param bool $access + * @return void */ protected function saveAccessInCache(string $key, bool $access) { @@ -224,4 +235,5 @@ protected function saveAccessInCache(string $key, bool $access) protected function throwFirewallException(string $message, int $exceptionCode = 0): bool { } + } diff --git a/src/Phalcon/firewall/adapter/Acl.php b/src/Phalcon/Firewall/Adapter/Acl.php similarity index 92% rename from src/Phalcon/firewall/adapter/Acl.php rename to src/Phalcon/Firewall/Adapter/Acl.php index c45de4ce..df37cfc6 100644 --- a/src/Phalcon/firewall/adapter/Acl.php +++ b/src/Phalcon/Firewall/Adapter/Acl.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Firewall\Adapter; use Phalcon\Mvc\DispatcherInterface; @@ -7,7 +14,7 @@ /** * FirewallZ for Phalcon\Application which depends on acl and dispatcher */ -class Acl extends AbstractAdapter +class Acl extends \Phalcon\Firewall\Adapter\AbstractAdapter { /** * Acl service name @@ -158,7 +165,7 @@ public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Di /** * Gets dispatcher * - * @return \Phalcon\Mvc\DispatcherInterface + * @return DispatcherInterface */ public function getDispatcher(): DispatcherInterface { @@ -202,8 +209,10 @@ protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher /** * @param string $key * @param bool $access + * @return void */ protected function saveAccessInCache(string $key, bool $access) { } + } diff --git a/src/Phalcon/firewall/adapter/AdapterInterface.php b/src/Phalcon/Firewall/Adapter/AdapterInterface.php similarity index 83% rename from src/Phalcon/firewall/adapter/AdapterInterface.php rename to src/Phalcon/Firewall/Adapter/AdapterInterface.php index 24eed8aa..efd297f1 100644 --- a/src/Phalcon/firewall/adapter/AdapterInterface.php +++ b/src/Phalcon/Firewall/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Firewall\Adapter; use Closure; @@ -20,7 +27,7 @@ public function getDefaultAccess(): int; /** * Gets role callback to fetch role name * - * @return \Closure + * @return Closure */ public function getRoleCallback(): Closure; @@ -35,6 +42,7 @@ public function isAlwaysResolvingRole(): bool; * Sets always resolving role option * * @param bool $alwaysResolvingRole + * @return void */ public function setAlwaysResolvingRole(bool $alwaysResolvingRole); @@ -61,4 +69,5 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface; * @return AdapterInterface */ public function setRoleCallback(\Closure $callback): AdapterInterface; + } diff --git a/src/Phalcon/firewall/adapter/Annotations.php b/src/Phalcon/Firewall/Adapter/Annotations.php similarity index 89% rename from src/Phalcon/firewall/adapter/Annotations.php rename to src/Phalcon/Firewall/Adapter/Annotations.php index 610d81f0..5eb9cb40 100644 --- a/src/Phalcon/firewall/adapter/Annotations.php +++ b/src/Phalcon/Firewall/Adapter/Annotations.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Firewall\Adapter; use Phalcon\Mvc\DispatcherInterface; @@ -7,7 +14,7 @@ /** * Firewall which depends on annotations and dispatcher */ -class Annotations extends AbstractAdapter +class Annotations extends \Phalcon\Firewall\Adapter\AbstractAdapter { /** * Number of active active arguments in active annotation @@ -75,7 +82,7 @@ public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Di /** * Gets dispatcher * - * @return \Phalcon\Mvc\DispatcherInterface + * @return DispatcherInterface */ public function getDispatcher(): DispatcherInterface { @@ -126,4 +133,5 @@ protected function getAccessFromCache(string $key, array $originalValues = null, protected function handleAnnotation($annotation, bool $access, $role) { } + } diff --git a/src/Phalcon/firewall/adapter/micro/Acl.php b/src/Phalcon/Firewall/Adapter/Micro/Acl.php similarity index 94% rename from src/Phalcon/firewall/adapter/micro/Acl.php rename to src/Phalcon/Firewall/Adapter/Micro/Acl.php index bc3227c6..7d013d6a 100644 --- a/src/Phalcon/firewall/adapter/micro/Acl.php +++ b/src/Phalcon/Firewall/Adapter/Micro/Acl.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Firewall\Adapter\Micro; use Phalcon\Firewall\Adapter\AbstractAdapter; @@ -181,7 +188,7 @@ public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Mi /** * Gets micro * - * @return \Phalcon\Mvc\Micro + * @return Micro */ public function getMicro(): Micro { @@ -228,8 +235,10 @@ protected function handleRouter(\Phalcon\Mvc\Micro $micro) /** * @param string $key * @param bool $access + * @return void */ protected function saveAccessInCache(string $key, bool $access) { } + } diff --git a/src/Phalcon/Firewall/Exception.php b/src/Phalcon/Firewall/Exception.php new file mode 100644 index 00000000..df1a6c70 --- /dev/null +++ b/src/Phalcon/Firewall/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Firewall; + +/** + * Exceptions thrown in Phalcon\Firewall will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/flash/AbstractFlash.php b/src/Phalcon/Flash/AbstractFlash.php similarity index 93% rename from src/Phalcon/flash/AbstractFlash.php rename to src/Phalcon/Flash/AbstractFlash.php index e37abb3a..2d234c8c 100644 --- a/src/Phalcon/flash/AbstractFlash.php +++ b/src/Phalcon/Flash/AbstractFlash.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Flash; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Escaper\EscaperInterface; +use Phalcon\Session\ManagerInterface as SessionInterface; /** * Shows HTML notifications related to different circumstances. Classes can be @@ -14,7 +22,7 @@ * $flash->error("Cannot open the file"); * ``` */ -abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\Flash\FlashInterface +abstract class AbstractFlash extends AbstractInjectionAware implements Phalcon\Flash\FlashInterface { /** * @var bool @@ -90,6 +98,8 @@ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \ /** * Clears accumulated messages when implicit flush is disabled + * + * @return void */ public function clear() { @@ -112,7 +122,7 @@ public function error(string $message): string /** * Returns the Escaper Service * - * @return \Phalcon\Escaper\EscaperInterface + * @return EscaperInterface */ public function getEscaperService(): EscaperInterface { @@ -215,8 +225,8 @@ public function success(string $message): string * ``` * * @param string|array $message - * @param string $type * @return string|void + * @param string $type */ public function outputMessage(string $type, $message) { @@ -266,4 +276,5 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } + } diff --git a/src/Phalcon/flash/Direct.php b/src/Phalcon/Flash/Direct.php similarity index 63% rename from src/Phalcon/flash/Direct.php rename to src/Phalcon/Flash/Direct.php index 92ba9061..af28ca9c 100644 --- a/src/Phalcon/flash/Direct.php +++ b/src/Phalcon/Flash/Direct.php @@ -1,12 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Flash; /** * This is a variant of the Phalcon\Flash that immediately outputs any message * passed to it */ -class Direct extends AbstractFlash +class Direct extends \Phalcon\Flash\AbstractFlash { /** @@ -24,8 +31,10 @@ public function message(string $type, $message): ?string * Prints the messages accumulated in the flasher * * @param bool $remove + * @return void */ public function output(bool $remove = true) { } + } diff --git a/src/Phalcon/Flash/Exception.php b/src/Phalcon/Flash/Exception.php new file mode 100644 index 00000000..cc2e3fea --- /dev/null +++ b/src/Phalcon/Flash/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Flash; + +/** + * Exceptions thrown in Phalcon\Flash will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/flash/FlashInterface.php b/src/Phalcon/Flash/FlashInterface.php similarity index 81% rename from src/Phalcon/flash/FlashInterface.php rename to src/Phalcon/Flash/FlashInterface.php index b5161398..5ef00ebd 100644 --- a/src/Phalcon/flash/FlashInterface.php +++ b/src/Phalcon/Flash/FlashInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Flash; /** @@ -50,4 +57,5 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; + } diff --git a/src/Phalcon/flash/Session.php b/src/Phalcon/Flash/Session.php similarity index 82% rename from src/Phalcon/flash/Session.php rename to src/Phalcon/Flash/Session.php index 9a36708b..dea4c208 100644 --- a/src/Phalcon/flash/Session.php +++ b/src/Phalcon/Flash/Session.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Flash; use Phalcon\Session\ManagerInterface; @@ -8,11 +15,13 @@ * Temporarily stores the messages in session, then messages can be printed in * the next request */ -class Session extends AbstractFlash +class Session extends \Phalcon\Flash\AbstractFlash { /** * Clear messages in the session messenger + * + * @return void */ public function clear() { @@ -54,6 +63,7 @@ public function message(string $type, string $message): ?string * Prints the messages in the session flasher * * @param bool $remove + * @return void */ public function output(bool $remove = true) { @@ -83,9 +93,10 @@ protected function setSessionMessages(array $messages): array /** * Returns the Session Service * - * @return \Phalcon\Session\ManagerInterface + * @return ManagerInterface */ public function getSessionService(): ManagerInterface { } + } diff --git a/src/Phalcon/forms/element/AbstractElement.php b/src/Phalcon/Forms/Element/AbstractElement.php similarity index 94% rename from src/Phalcon/forms/element/AbstractElement.php rename to src/Phalcon/Forms/Element/AbstractElement.php index 9bae5d4a..4a7f9445 100644 --- a/src/Phalcon/forms/element/AbstractElement.php +++ b/src/Phalcon/Forms/Element/AbstractElement.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; use Phalcon\Forms\Form; @@ -8,7 +15,7 @@ /** * This is a base class for form elements */ -abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface +abstract class AbstractElement implements Phalcon\Forms\Element\ElementInterface { protected $attributes; @@ -152,7 +159,7 @@ public function getFilters() /** * Returns the parent form to the element * - * @return \Phalcon\Forms\Form + * @return Form */ public function getForm(): Form { @@ -171,7 +178,7 @@ public function getLabel(): string * Returns the messages that belongs to the element * The element needs to be attached to a form * - * @return \Phalcon\Messages\Messages + * @return Messages */ public function getMessages(): Messages { @@ -209,7 +216,7 @@ public function getUserOptions(): array /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array */ public function getValidators(): array { @@ -357,4 +364,5 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } + } diff --git a/src/Phalcon/forms/element/Check.php b/src/Phalcon/Forms/Element/Check.php similarity index 53% rename from src/Phalcon/forms/element/Check.php rename to src/Phalcon/Forms/Element/Check.php index 68472d21..0f5ae153 100644 --- a/src/Phalcon/forms/element/Check.php +++ b/src/Phalcon/Forms/Element/Check.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=check] for forms */ -class Check extends AbstractElement +class Check extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Check extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Date.php b/src/Phalcon/Forms/Element/Date.php similarity index 50% rename from src/Phalcon/forms/element/Date.php rename to src/Phalcon/Forms/Element/Date.php index 56000b1b..d7a24ed8 100644 --- a/src/Phalcon/forms/element/Date.php +++ b/src/Phalcon/Forms/Element/Date.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** * Component INPUT[type=date] for forms */ -class Date extends AbstractElement +class Date extends \Phalcon\Forms\Element\AbstractElement { /** @@ -17,4 +24,5 @@ class Date extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/ElementInterface.php b/src/Phalcon/Forms/Element/ElementInterface.php similarity index 95% rename from src/Phalcon/forms/element/ElementInterface.php rename to src/Phalcon/Forms/Element/ElementInterface.php index fbde7685..b4ccef34 100644 --- a/src/Phalcon/forms/element/ElementInterface.php +++ b/src/Phalcon/Forms/Element/ElementInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; use Phalcon\Forms\Form; @@ -86,7 +93,7 @@ public function getFilters(); /** * Returns the parent form to the element * - * @return \Phalcon\Forms\Form + * @return Form */ public function getForm(): Form; @@ -101,7 +108,7 @@ public function getLabel(): string; * Returns the messages that belongs to the element * The element needs to be attached to a form * - * @return \Phalcon\Messages\Messages + * @return Messages */ public function getMessages(): Messages; @@ -131,7 +138,7 @@ public function getUserOptions(): array; /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array */ public function getValidators(): array; @@ -256,4 +263,5 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; + } diff --git a/src/Phalcon/forms/element/Email.php b/src/Phalcon/Forms/Element/Email.php similarity index 53% rename from src/Phalcon/forms/element/Email.php rename to src/Phalcon/Forms/Element/Email.php index d008a2a0..09536c67 100644 --- a/src/Phalcon/forms/element/Email.php +++ b/src/Phalcon/Forms/Element/Email.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=email] for forms */ -class Email extends AbstractElement +class Email extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Email extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/File.php b/src/Phalcon/Forms/Element/File.php similarity index 50% rename from src/Phalcon/forms/element/File.php rename to src/Phalcon/Forms/Element/File.php index 89f91f29..c7b958d4 100644 --- a/src/Phalcon/forms/element/File.php +++ b/src/Phalcon/Forms/Element/File.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** * Component INPUT[type=file] for forms */ -class File extends AbstractElement +class File extends \Phalcon\Forms\Element\AbstractElement { /** @@ -17,4 +24,5 @@ class File extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Hidden.php b/src/Phalcon/Forms/Element/Hidden.php similarity index 53% rename from src/Phalcon/forms/element/Hidden.php rename to src/Phalcon/Forms/Element/Hidden.php index 8821861c..e489d241 100644 --- a/src/Phalcon/forms/element/Hidden.php +++ b/src/Phalcon/Forms/Element/Hidden.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=hidden] for forms */ -class Hidden extends AbstractElement +class Hidden extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Hidden extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Numeric.php b/src/Phalcon/Forms/Element/Numeric.php similarity index 53% rename from src/Phalcon/forms/element/Numeric.php rename to src/Phalcon/Forms/Element/Numeric.php index 2a348713..7de5abb1 100644 --- a/src/Phalcon/forms/element/Numeric.php +++ b/src/Phalcon/Forms/Element/Numeric.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=number] for forms */ -class Numeric extends AbstractElement +class Numeric extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Numeric extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Password.php b/src/Phalcon/Forms/Element/Password.php similarity index 53% rename from src/Phalcon/forms/element/Password.php rename to src/Phalcon/Forms/Element/Password.php index 23f775ed..e7cabd9a 100644 --- a/src/Phalcon/forms/element/Password.php +++ b/src/Phalcon/Forms/Element/Password.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=password] for forms */ -class Password extends AbstractElement +class Password extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Password extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Radio.php b/src/Phalcon/Forms/Element/Radio.php similarity index 53% rename from src/Phalcon/forms/element/Radio.php rename to src/Phalcon/Forms/Element/Radio.php index 1a6b4e25..d59fe9bb 100644 --- a/src/Phalcon/forms/element/Radio.php +++ b/src/Phalcon/Forms/Element/Radio.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=radio] for forms */ -class Radio extends AbstractElement +class Radio extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Radio extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/forms/element/Select.php b/src/Phalcon/Forms/Element/Select.php similarity index 75% rename from src/Phalcon/forms/element/Select.php rename to src/Phalcon/Forms/Element/Select.php index 4c2c5c4c..77700fda 100644 --- a/src/Phalcon/forms/element/Select.php +++ b/src/Phalcon/Forms/Element/Select.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component SELECT (choice) for forms */ -class Select extends AbstractElement +class Select extends \Phalcon\Forms\Element\AbstractElement { protected $optionsValues; @@ -28,7 +35,7 @@ public function __construct(string $name, $options = null, $attributes = null) * Adds an option to the current options * * @param array|string $option - * @return \Phalcon\Forms\Element\ElementInterface + * @return ElementInterface */ public function addOption($option): ElementInterface { @@ -57,9 +64,10 @@ public function render(array $attributes = array()): string * Set the choice's options * * @param array|object $options - * @return \Phalcon\Forms\Element\ElementInterface + * @return ElementInterface */ public function setOptions($options): ElementInterface { } + } diff --git a/src/Phalcon/Forms/Element/Submit.php b/src/Phalcon/Forms/Element/Submit.php new file mode 100644 index 00000000..41c45064 --- /dev/null +++ b/src/Phalcon/Forms/Element/Submit.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Forms\Element; + +/** + * Component INPUT[type=submit] for forms + */ +class Submit extends \Phalcon\Forms\Element\AbstractElement +{ + + /** + * Renders the element widget + * + * @param array $attributes + * @return string + */ + public function render(array $attributes = array()): string + { + } + +} diff --git a/src/Phalcon/forms/element/Text.php b/src/Phalcon/Forms/Element/Text.php similarity index 52% rename from src/Phalcon/forms/element/Text.php rename to src/Phalcon/Forms/Element/Text.php index 32aeaf71..86a5fddb 100644 --- a/src/Phalcon/forms/element/Text.php +++ b/src/Phalcon/Forms/Element/Text.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms\Element; /** @@ -7,7 +14,7 @@ * * Component INPUT[type=text] for forms */ -class Text extends AbstractElement +class Text extends \Phalcon\Forms\Element\AbstractElement { /** @@ -19,4 +26,5 @@ class Text extends AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/TextArea.php b/src/Phalcon/Forms/Element/TextArea.php new file mode 100644 index 00000000..7cefe5e7 --- /dev/null +++ b/src/Phalcon/Forms/Element/TextArea.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Forms\Element; + +/** + * Component TEXTAREA for forms + */ +class TextArea extends \Phalcon\Forms\Element\AbstractElement +{ + + /** + * Renders the element widget + * + * @param array $attributes + * @return string + */ + public function render(array $attributes = array()): string + { + } + +} diff --git a/src/Phalcon/Forms/Exception.php b/src/Phalcon/Forms/Exception.php new file mode 100644 index 00000000..87d1a846 --- /dev/null +++ b/src/Phalcon/Forms/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Forms; + +/** + * Exceptions thrown in Phalcon\Forms will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/forms/Form.php b/src/Phalcon/Forms/Form.php similarity index 93% rename from src/Phalcon/forms/Form.php rename to src/Phalcon/Forms/Form.php index 18cdb99d..66738c7c 100644 --- a/src/Phalcon/forms/Form.php +++ b/src/Phalcon/Forms/Form.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms; use Phalcon\Di\Injectable; @@ -111,7 +118,7 @@ public function count(): int /** * Returns the current element in the iterator * - * @return bool|\Phalcon\Forms\Element\ElementInterface + * @return mixed */ public function current() { @@ -121,7 +128,7 @@ public function current() * Returns an element added to the form by its name * * @param string $name - * @return \Phalcon\Forms\Element\ElementInterface + * @return ElementInterface */ public function get(string $name): ElementInterface { @@ -139,7 +146,7 @@ public function getAction(): string /** * Get Form attributes collection * - * @return \Phalcon\Html\Attributes + * @return Attributes */ public function getAttributes(): Attributes { @@ -148,7 +155,7 @@ public function getAttributes(): Attributes /** * Returns the form elements added to the form * - * @return array|\Phalcon\Forms\Element\ElementInterface[] + * @return array */ public function getElements(): array { @@ -186,7 +193,7 @@ public function getLabel(string $name): string * } * ``` * - * @return array|\Phalcon\Messages\Messages + * @return mixed */ public function getMessages() { @@ -196,7 +203,7 @@ public function getMessages() * Returns the messages generated for a specific element * * @param string $name - * @return \Phalcon\Messages\Messages + * @return Messages */ public function getMessagesFor(string $name): Messages { @@ -285,6 +292,8 @@ public function label(string $name, array $attributes = null): string /** * Moves the internal iteration pointer to the next position + * + * @return void */ public function next() { @@ -313,6 +322,8 @@ public function remove(string $name): bool /** * Rewinds the internal iterator + * + * @return void */ public function rewind() { @@ -321,8 +332,8 @@ public function rewind() /** * Sets the form's action * - * @param string $action * @return Form + * @param string $action */ public function setAction(string $action): Form { @@ -342,7 +353,7 @@ public function setEntity($entity): Form * Set form attributes collection * * @param \Phalcon\Html\Attributes $attributes - * @return \Phalcon\Html\Attributes\AttributesInterface + * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface { @@ -377,4 +388,5 @@ public function setUserOptions(array $options): Form public function valid(): bool { } + } diff --git a/src/Phalcon/forms/Manager.php b/src/Phalcon/Forms/Manager.php similarity index 79% rename from src/Phalcon/forms/Manager.php rename to src/Phalcon/Forms/Manager.php index 42aeafcc..996bea85 100644 --- a/src/Phalcon/forms/Manager.php +++ b/src/Phalcon/Forms/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Forms; /** @@ -52,4 +59,5 @@ public function has(string $name): bool public function set(string $name, Form $form): Manager { } + } diff --git a/src/Phalcon/helper/Arr.php b/src/Phalcon/Helper/Arr.php similarity index 88% rename from src/Phalcon/helper/Arr.php rename to src/Phalcon/Helper/Arr.php index 70f8dd5a..e9bb27a9 100644 --- a/src/Phalcon/helper/Arr.php +++ b/src/Phalcon/Helper/Arr.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Helper; /** @@ -12,8 +19,8 @@ class Arr * Chunks an array into smaller arrays of a specified size. * * @param array $collection - * @param int $size - * @param bool $preserveKeys + * @param int $size + * @param bool $preserveKeys * * @return array */ @@ -25,7 +32,7 @@ final public static function chunk(array $collection, int $size, bool $preserveK * Returns the first element of the collection. If a callable is passed, the * element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -38,7 +45,7 @@ final public static function first(array $collection, $method = null) * Returns the key of the first element of the collection. If a callable * is passed, the element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -51,7 +58,7 @@ final public static function firstKey(array $collection, $method = null) * Flattens an array up to the one level depth, unless `$deep` is set to `true` * * @param array $collection - * @param bool $deep + * @param bool $deep * * @return array */ @@ -75,7 +82,7 @@ final public static function get(array $collection, $index, $defaultValue = null /** * Groups the elements of an array based on the passed callable * - * @param array $collection + * @param array $collection * @param callable $method * * @return array @@ -113,7 +120,7 @@ final public static function isUnique(array $collection): bool * Returns the last element of the collection. If a callable is passed, the * element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * return mixed @@ -127,7 +134,7 @@ final public static function last(array $collection, $method = null) * Returns the key of the last element of the collection. If a callable is * passed, the element returned is the first that validates true * - * @param array $collection + * @param array $collection * @param callable $method * * @return mixed @@ -139,8 +146,8 @@ final public static function lastKey(array $collection, $method = null) /** * Sorts a collection of arrays or objects by key * - * @param array $collection - * @param mixed $attribute + * @param array $collection + * @param mixed $attribute * @param string $order * * @return array @@ -152,7 +159,7 @@ final public static function order(array $collection, $attribute, string $order /** * Retrieves all of the values for a given key: * - * @param array $collection + * @param array $collection * @param string $element * * @return array @@ -178,7 +185,7 @@ final public static function set(array $collection, $value, $index = null): arra * Returns a new array with n elements removed from the right. * * @param array $collection - * @param int $elements + * @param int $elements * * @return array */ @@ -190,7 +197,7 @@ final public static function sliceLeft(array $collection, int $elements = 1): ar * Returns a new array with the X elements from the right * * @param array $collection - * @param int $elements + * @param int $elements * * @return array */ @@ -223,7 +230,7 @@ final public static function toObject(array $collection) * Returns true if the provided function returns true for all elements of * the collection, false otherwise. * - * @param array $collection + * @param array $collection * @param callable $method * * @return bool @@ -236,7 +243,7 @@ final public static function validateAll(array $collection, $method): bool * Returns true if the provided function returns true for at least one * element fo the collection, false otherwise. * - * @param array $collection + * @param array $collection * @param callable $method * * @return bool @@ -248,7 +255,7 @@ final public static function validateAny(array $collection, $method): bool /** * Helper method to filter the collection * - * @param array $collection + * @param array $collection * @param callable $method * * @return array @@ -269,4 +276,5 @@ final private static function filterCollection(array $collection, $method = null final public static function whiteList(array $collection, array $whiteList): array { } + } diff --git a/src/Phalcon/Helper/Exception.php b/src/Phalcon/Helper/Exception.php new file mode 100644 index 00000000..3235d7fa --- /dev/null +++ b/src/Phalcon/Helper/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Helper; + +/** + * Exceptions thrown in Phalcon\Helper will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/helper/Fs.php b/src/Phalcon/Helper/Fs.php similarity index 70% rename from src/Phalcon/helper/Fs.php rename to src/Phalcon/Helper/Fs.php index 04e5c383..ada075bd 100644 --- a/src/Phalcon/helper/Fs.php +++ b/src/Phalcon/Helper/Fs.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Helper; /** @@ -21,4 +28,5 @@ class Fs final public static function basename(string $uri, $suffix = null): string { } + } diff --git a/src/Phalcon/helper/Number.php b/src/Phalcon/Helper/Number.php similarity index 64% rename from src/Phalcon/helper/Number.php rename to src/Phalcon/Helper/Number.php index 63d21e47..be55148b 100644 --- a/src/Phalcon/helper/Number.php +++ b/src/Phalcon/Helper/Number.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Helper; /** @@ -21,4 +28,5 @@ class Number final public static function between(int $value, int $from, int $to): bool { } + } diff --git a/src/Phalcon/helper/Str.php b/src/Phalcon/Helper/Str.php similarity index 96% rename from src/Phalcon/helper/Str.php rename to src/Phalcon/Helper/Str.php index 60e6890a..ac9af5c2 100644 --- a/src/Phalcon/helper/Str.php +++ b/src/Phalcon/Helper/Str.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Helper; /** @@ -38,7 +45,7 @@ class Str * ``` * * @param string $text - * @param mixed $delimiter + * @param mixed $delimiter * * @return string */ @@ -67,9 +74,9 @@ final public static function camelize(string $text, $delimiter = null): string * @param string $b * @param string ...N * + * @return string * @param string ...N * - * @return string */ final public static function concat(): string { @@ -81,8 +88,8 @@ final public static function concat(): string * * @param string $string * - * @param string $text * @return int + * @param string $text */ final public static function countVowels(string $text): int { @@ -94,11 +101,11 @@ final public static function countVowels(string $text): int * string intact, or set it to true to convert to uppercase. * * @param string $string - * @param bool $upperRest + * @param bool $upperRest * @param string $encoding * - * @param string $text * @return string + * @param string $text */ final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string { @@ -187,7 +194,7 @@ final public static function dynamic(string $text, string $leftDelimiter = '{', * * @param string $text * @param string $end - * @param bool $ignoreCase + * @param bool $ignoreCase * * @return bool */ @@ -374,7 +381,7 @@ final public static function reduceSlashes(string $text): string * * @param string $text * @param string $start - * @param bool $ignoreCase + * @param bool $ignoreCase * * @return bool */ @@ -393,7 +400,7 @@ final public static function startsWith(string $text, string $start, bool $ignor * ``` * * @param string $text - * @param mixed $delimiter + * @param mixed $delimiter * * @return string */ @@ -435,4 +442,5 @@ final public static function underscore(string $text): string final public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/html/Attributes.php b/src/Phalcon/Html/Attributes.php similarity index 67% rename from src/Phalcon/html/Attributes.php rename to src/Phalcon/Html/Attributes.php index b15686e8..e060ab67 100644 --- a/src/Phalcon/html/Attributes.php +++ b/src/Phalcon/Html/Attributes.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html; use Phalcon\Collection; @@ -27,4 +34,5 @@ public function render(): string public function __toString(): string { } + } diff --git a/src/Phalcon/html/attributes/AttributesInterface.php b/src/Phalcon/Html/Attributes/AttributesInterface.php similarity index 68% rename from src/Phalcon/html/attributes/AttributesInterface.php rename to src/Phalcon/Html/Attributes/AttributesInterface.php index 10d1db1d..b0cb7391 100644 --- a/src/Phalcon/html/attributes/AttributesInterface.php +++ b/src/Phalcon/Html/Attributes/AttributesInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Attributes; use Phalcon\Html\Attributes; @@ -15,7 +22,7 @@ interface AttributesInterface /** * Get Attributes * - * @return \Phalcon\Html\Attributes + * @return Attributes */ public function getAttributes(): Attributes; @@ -26,4 +33,5 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; + } diff --git a/src/Phalcon/html/attributes/RenderInterface.php b/src/Phalcon/Html/Attributes/RenderInterface.php similarity index 57% rename from src/Phalcon/html/attributes/RenderInterface.php rename to src/Phalcon/Html/Attributes/RenderInterface.php index 1b94eb49..d2a71e41 100644 --- a/src/Phalcon/html/attributes/RenderInterface.php +++ b/src/Phalcon/Html/Attributes/RenderInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Attributes; /** @@ -16,4 +23,5 @@ interface RenderInterface * @return string */ public function render(): string; + } diff --git a/src/Phalcon/html/Breadcrumbs.php b/src/Phalcon/Html/Breadcrumbs.php similarity index 89% rename from src/Phalcon/html/Breadcrumbs.php rename to src/Phalcon/Html/Breadcrumbs.php index be4e59a9..e6a371b1 100644 --- a/src/Phalcon/html/Breadcrumbs.php +++ b/src/Phalcon/Html/Breadcrumbs.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html; /** @@ -76,6 +83,8 @@ public function add(string $label, string $link = ''): Breadcrumbs * ```php * $breadcrumbs->clear() * ``` + * + * @return void */ public function clear() { @@ -92,6 +101,7 @@ public function clear() * ``` * * @param string $link + * @return void */ public function remove(string $link) { @@ -118,4 +128,5 @@ public function render(): string public function toArray(): array { } + } diff --git a/src/Phalcon/Html/Exception.php b/src/Phalcon/Html/Exception.php new file mode 100644 index 00000000..0faae5dc --- /dev/null +++ b/src/Phalcon/Html/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html; + +/** + * Phalcon\Html\Tag\Exception + * + * Exceptions thrown in Phalcon\Html\Tag will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/html/helper/AbstractHelper.php b/src/Phalcon/Html/Helper/AbstractHelper.php similarity index 88% rename from src/Phalcon/html/helper/AbstractHelper.php rename to src/Phalcon/Html/Helper/AbstractHelper.php index 3e4d856f..4d5acd1c 100644 --- a/src/Phalcon/html/helper/AbstractHelper.php +++ b/src/Phalcon/Html/Helper/AbstractHelper.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; use Phalcon\Escaper\EscaperInterface; @@ -81,4 +88,5 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Anchor.php b/src/Phalcon/Html/Helper/Anchor.php similarity index 58% rename from src/Phalcon/html/helper/Anchor.php rename to src/Phalcon/Html/Helper/Anchor.php index 70ad18aa..6730b1fc 100644 --- a/src/Phalcon/html/helper/Anchor.php +++ b/src/Phalcon/Html/Helper/Anchor.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates an anchor */ -class Anchor extends AbstractHelper +class Anchor extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -19,4 +26,5 @@ class Anchor extends AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/AnchorRaw.php b/src/Phalcon/Html/Helper/AnchorRaw.php similarity index 58% rename from src/Phalcon/html/helper/AnchorRaw.php rename to src/Phalcon/Html/Helper/AnchorRaw.php index 27555b04..91a80136 100644 --- a/src/Phalcon/html/helper/AnchorRaw.php +++ b/src/Phalcon/Html/Helper/AnchorRaw.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates a raw anchor */ -class AnchorRaw extends AbstractHelper +class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -19,4 +26,5 @@ class AnchorRaw extends AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Body.php b/src/Phalcon/Html/Helper/Body.php new file mode 100644 index 00000000..e2233f65 --- /dev/null +++ b/src/Phalcon/Html/Helper/Body.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Helper; + +/** + * Phalcon\Html\Helper\Body + * + * Creates a body tag + */ +class Body extends \Phalcon\Html\Helper\AbstractHelper +{ + + /** + * @param array $attributes Any additional attributes + * @return string + */ + public function __invoke(array $attributes = array()): string + { + } + +} diff --git a/src/Phalcon/html/helper/Button.php b/src/Phalcon/Html/Helper/Button.php similarity index 55% rename from src/Phalcon/html/helper/Button.php rename to src/Phalcon/Html/Helper/Button.php index 56b8eca9..d1b38b84 100644 --- a/src/Phalcon/html/helper/Button.php +++ b/src/Phalcon/Html/Helper/Button.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates a button tag */ -class Button extends AbstractHelper +class Button extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -18,4 +25,5 @@ class Button extends AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Close.php b/src/Phalcon/Html/Helper/Close.php similarity index 57% rename from src/Phalcon/html/helper/Close.php rename to src/Phalcon/Html/Helper/Close.php index 5e4d0e78..741496f8 100644 --- a/src/Phalcon/html/helper/Close.php +++ b/src/Phalcon/Html/Helper/Close.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -18,4 +25,5 @@ class Close extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag): string { } + } diff --git a/src/Phalcon/html/helper/Element.php b/src/Phalcon/Html/Helper/Element.php similarity index 58% rename from src/Phalcon/html/helper/Element.php rename to src/Phalcon/Html/Helper/Element.php index 92d66641..ea372eda 100644 --- a/src/Phalcon/html/helper/Element.php +++ b/src/Phalcon/Html/Helper/Element.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates an element */ -class Element extends AbstractHelper +class Element extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -19,4 +26,5 @@ class Element extends AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/ElementRaw.php b/src/Phalcon/Html/Helper/ElementRaw.php new file mode 100644 index 00000000..13ad5f4b --- /dev/null +++ b/src/Phalcon/Html/Helper/ElementRaw.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Helper; + +use Phalcon\Html\Exception; + +/** + * Phalcon\Html\Helper\ElementRaw + * + * Creates an element raw + */ +class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper +{ + + /** + * @param string $tag The tag for the anchor + * @param string $text The text for the anchor + * @param array $attributes Any additional attributes + * + * @return string + * @throws Exception + */ + public function __invoke(string $tag, string $text, array $attributes = array()): string + { + } + +} diff --git a/src/Phalcon/html/helper/Form.php b/src/Phalcon/Html/Helper/Form.php similarity index 50% rename from src/Phalcon/html/helper/Form.php rename to src/Phalcon/Html/Helper/Form.php index 341db284..57a5fb31 100644 --- a/src/Phalcon/html/helper/Form.php +++ b/src/Phalcon/Html/Helper/Form.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates a form opening tag */ -class Form extends AbstractHelper +class Form extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -17,4 +24,5 @@ class Form extends AbstractHelper public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Img.php b/src/Phalcon/Html/Helper/Img.php similarity index 56% rename from src/Phalcon/html/helper/Img.php rename to src/Phalcon/Html/Helper/Img.php index 1fa5ed79..0faa56b8 100644 --- a/src/Phalcon/html/helper/Img.php +++ b/src/Phalcon/Html/Helper/Img.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; use Phalcon\Html\Exception; @@ -14,7 +21,7 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper /** * @param string $src - * @param array $attributes Any additional attributes + * @param array $attributes Any additional attributes * * @return string * @throws Exception @@ -22,4 +29,5 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $src, array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/Label.php b/src/Phalcon/Html/Helper/Label.php similarity index 63% rename from src/Phalcon/html/helper/Label.php rename to src/Phalcon/Html/Helper/Label.php index c6b67169..773932c4 100644 --- a/src/Phalcon/html/helper/Label.php +++ b/src/Phalcon/Html/Helper/Label.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; use Phalcon\Html\Exception; @@ -21,4 +28,5 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/html/helper/TextArea.php b/src/Phalcon/Html/Helper/TextArea.php similarity index 55% rename from src/Phalcon/html/helper/TextArea.php rename to src/Phalcon/Html/Helper/TextArea.php index ba570df0..50c632ce 100644 --- a/src/Phalcon/html/helper/TextArea.php +++ b/src/Phalcon/Html/Helper/TextArea.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html\Helper; /** @@ -7,7 +14,7 @@ * * Creates a textarea tag */ -class TextArea extends AbstractHelper +class TextArea extends \Phalcon\Html\Helper\AbstractHelper { /** @@ -18,4 +25,5 @@ class TextArea extends AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Link/EvolvableLink.php b/src/Phalcon/Html/Link/EvolvableLink.php new file mode 100644 index 00000000..787dfbf9 --- /dev/null +++ b/src/Phalcon/Html/Link/EvolvableLink.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link; + +use Psr\Link\EvolvableLinkInterface; + +/** + * Class Phalcon\Http\Link\EvolvableLink + * + * @property array attributes + * @property string href + * @property array rels + * @property bool templated + */ +class EvolvableLink extends \Phalcon\Html\Link\Link implements \Psr\Link\EvolvableLinkInterface +{ + + /** + * Returns an instance with the specified attribute added. + * + * If the specified attribute is already present, it will be overwritten + * with the new value. + * + * @param string $attribute The attribute to include. + * @param string $value The value of the attribute to set. + * + * @return static + */ + public function withAttribute($attribute, $value) + { + } + + /** + * Returns an instance with the specified href. + * + * @param string $href * The href value to include. It must be one of: + * - An absolute URI, as defined by RFC 5988. + * - A relative URI, as defined by RFC 5988. The base of the relative + * link is assumed to be known based on context by the client. + * - A URI template as defined by RFC 6570. + * - An object implementing __toString() that produces one of the + * above values. + * + * An implementing library SHOULD evaluate a passed object to a string + * immediately rather than waiting for it to be returned later. + * + * @return static + */ + public function withHref($href) + { + } + + /** + * Returns an instance with the specified relationship included. + * + * If the specified rel is already present, this method MUST return + * normally without errors, but without adding the rel a second time. + * + * @param string $rel * The relationship value to add. + * + * @return static + */ + public function withRel($rel) + { + } + + /** + * Returns an instance with the specified attribute excluded. + * + * If the specified attribute is not present, this method MUST return + * normally without errors. + * + * @param string $attribute * The attribute to remove. + * + * @return static + */ + public function withoutAttribute($attribute) + { + } + + /** + * Returns an instance with the specified relationship excluded. + * + * If the specified rel is already not present, this method MUST return + * normally without errors. + * + * @param string $rel * The relationship value to exclude. + * + * @return static + */ + public function withoutRel($rel) + { + } + +} diff --git a/src/Phalcon/Html/Link/EvolvableLinkProvider.php b/src/Phalcon/Html/Link/EvolvableLinkProvider.php new file mode 100644 index 00000000..0846b9ca --- /dev/null +++ b/src/Phalcon/Html/Link/EvolvableLinkProvider.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link; + +use Psr\Link\EvolvableLinkProviderInterface; +use Psr\Link\LinkInterface; + +/** + * Class Phalcon\Http\Link\LinkProvider + * + * @property LinkInterface[] links + */ +class EvolvableLinkProvider extends \Phalcon\Html\Link\LinkProvider implements \Psr\Link\EvolvableLinkProviderInterface +{ + + /** + * Returns an instance with the specified link included. + * + * If the specified link is already present, this method MUST return + * normally without errors. The link is present if link is === identical + * to a link object already in the collection. + * + * @param LinkInterface $link * A link object that should be included in this collection. + * + * @return static + */ + public function withLink(\Psr\Link\LinkInterface $link) + { + } + + /** + * Returns an instance with the specified link removed. + * + * If the specified link is not present, this method MUST return normally + * without errors. The link is present if link is === identical to a link + * object already in the collection. + * + * @param LinkInterface $link * The link to remove. + * + * @return static + */ + public function withoutLink(\Psr\Link\LinkInterface $link) + { + } + +} diff --git a/src/Phalcon/Html/Link/Link.php b/src/Phalcon/Html/Link/Link.php new file mode 100644 index 00000000..94eed4c7 --- /dev/null +++ b/src/Phalcon/Html/Link/Link.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link; + +use Phalcon\Collection; +use Psr\Link\LinkInterface; + +/** + * Class Phalcon\Http\Link\Link + * + * @property array attributes + * @property string href + * @property array rels + * @property bool templated + */ +class Link implements \Psr\Link\LinkInterface +{ + /** + * @var Collection + */ + protected $attributes; + + /** + * @var string + */ + protected $href = ''; + + /** + * @var Collection + */ + protected $rels; + + /** + * @var bool + */ + protected $templated = false; + + + /** + * Link constructor. + * + * @param string $rel + * @param string $href + * @param array $attributes + */ + public function __construct(string $rel = '', string $href = '', array $attributes = array()) + { + } + + /** + * Returns a list of attributes that describe the target URI. + * + * @return array + * A key-value list of attributes, where the key is a string and the value + * is either a PHP primitive or an array of PHP strings. If no values are + * found an empty array MUST be returned. + */ + public function getAttributes() + { + } + + /** + * Returns the target of the link. + * + * The target link must be one of: + * - An absolute URI, as defined by RFC 5988. + * - A relative URI, as defined by RFC 5988. The base of the relative link + * is assumed to be known based on context by the client. + * - A URI template as defined by RFC 6570. + * + * If a URI template is returned, isTemplated() MUST return True. + * + * @return string + */ + public function getHref() + { + } + + /** + * Returns the relationship type(s) of the link. + * + * This method returns 0 or more relationship types for a link, expressed + * as an array of strings. + * + * @return string[] + */ + public function getRels() + { + } + + /** + * Returns whether or not this is a templated link. + * + * @return bool True if this link object is templated, False otherwise. + */ + public function isTemplated() + { + } + + /** + * Determines if a href is a templated link or not. + * + * @see https://tools.ietf.org/html/rfc6570 + * + * @param string $href * + * @return bool + */ + protected function hrefIsTemplated(string $href): bool + { + } + +} diff --git a/src/Phalcon/Html/Link/LinkProvider.php b/src/Phalcon/Html/Link/LinkProvider.php new file mode 100644 index 00000000..7b6a0adb --- /dev/null +++ b/src/Phalcon/Html/Link/LinkProvider.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link; + +use Psr\Link\LinkInterface; +use Psr\Link\LinkProviderInterface; + +/** + * Class Phalcon\Http\Link\LinkProvider + * + * @property LinkInterface[] links + */ +class LinkProvider implements \Psr\Link\LinkProviderInterface +{ + /** + * @var LinkInterface[] + */ + protected $links = array(); + + + /** + * LinkProvider constructor. + * + * @param array $links + */ + public function __construct(array $links = array()) + { + } + + /** + * Returns an iterable of LinkInterface objects. + * + * The iterable may be an array or any PHP \Traversable object. If no links + * are available, an empty array or \Traversable MUST be returned. + * + * @return LinkInterface[]|\Traversable + */ + public function getLinks() + { + } + + /** + * Returns an iterable of LinkInterface objects that have a specific + * relationship. + * + * The iterable may be an array or any PHP \Traversable object. If no links + * with that relationship are available, an empty array or \Traversable + * MUST be returned. + * + * @return LinkInterface[]|Traversable + * @param mixed $rel + */ + public function getLinksByRel($rel) + { + } + + /** + * Returns the object hash key + * + * @param LinkInterface $link * + * @return string + */ + protected function getKey(\Psr\Link\LinkInterface $link): string + { + } + +} diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Phalcon/Html/Link/Serializer/Header.php new file mode 100644 index 00000000..a55767a1 --- /dev/null +++ b/src/Phalcon/Html/Link/Serializer/Header.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link\Serializer; + +use Psr\Link\EvolvableLinkInterface; + +/** + * Class Phalcon\Http\Link\Serializer\Header + */ +class Header implements Phalcon\Html\Link\Serializer\SerializerInterface +{ + + /** + * Serializes all the passed links to a HTTP link header + * + * @param array $links + * @return string|null + */ + public function serialize(array $links): ?string + { + } + +} diff --git a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php new file mode 100644 index 00000000..9b922a51 --- /dev/null +++ b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Html\Link\Serializer; + +/** + * Class Phalcon\Http\Link\Serializer\SerializerInterface + */ +interface SerializerInterface +{ + + /** + * Serializer method + * + * @param array $links + * @return string|null + */ + public function serialize(array $links): ?string; + +} diff --git a/src/Phalcon/html/TagFactory.php b/src/Phalcon/Html/TagFactory.php similarity index 77% rename from src/Phalcon/html/TagFactory.php rename to src/Phalcon/Html/TagFactory.php index 161d4ecf..7b13153a 100644 --- a/src/Phalcon/html/TagFactory.php +++ b/src/Phalcon/Html/TagFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Html; use Phalcon\Escaper\EscaperInterface; @@ -41,4 +48,5 @@ public function newInstance(string $name) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/http/Cookie.php b/src/Phalcon/Http/Cookie.php similarity index 94% rename from src/Phalcon/http/Cookie.php rename to src/Phalcon/Http/Cookie.php index bf5ffb55..f9a04fb0 100644 --- a/src/Phalcon/http/Cookie.php +++ b/src/Phalcon/Http/Cookie.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; use Phalcon\Di\AbstractInjectionAware; @@ -7,7 +14,7 @@ /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInterface +class Cookie extends AbstractInjectionAware implements Phalcon\Http\CookieInterface { protected $domain; @@ -238,10 +245,10 @@ public function setSecure(bool $secure): CookieInterface * * Use NULL to disable cookie signing. * + * @see \Phalcon\Security\Random + * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey * @return CookieInterface - * @throws \Phalcon\Http\Cookie\Exception - * @see \Phalcon\Security\Random */ public function setSignKey(string $signKey = null): CookieInterface { @@ -270,10 +277,12 @@ public function useEncryption(bool $useEncryption): CookieInterface /** * Assert the cookie's key is enough long. * - * @param string $signKey * @throws \Phalcon\Http\Cookie\Exception + * @param string $signKey + * @return void */ protected function assertSignKeyIsLongEnough(string $signKey) { } + } diff --git a/src/Phalcon/Http/Cookie/Exception.php b/src/Phalcon/Http/Cookie/Exception.php new file mode 100644 index 00000000..aab99c80 --- /dev/null +++ b/src/Phalcon/Http/Cookie/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Http\Cookie; + +/** + * Phalcon\Http\Cookie\Exception + * + * Exceptions thrown in Phalcon\Http\Cookie will use this class. + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/http/CookieInterface.php b/src/Phalcon/Http/CookieInterface.php similarity index 92% rename from src/Phalcon/http/CookieInterface.php rename to src/Phalcon/Http/CookieInterface.php index 8d2386f2..1477dc8a 100644 --- a/src/Phalcon/http/CookieInterface.php +++ b/src/Phalcon/Http/CookieInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; /** @@ -135,4 +142,5 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; + } diff --git a/src/Phalcon/http/message/AbstractCommon.php b/src/Phalcon/Http/Message/AbstractCommon.php similarity index 71% rename from src/Phalcon/http/message/AbstractCommon.php rename to src/Phalcon/Http/Message/AbstractCommon.php index 61a4e2a7..ed1e45e0 100644 --- a/src/Phalcon/http/message/AbstractCommon.php +++ b/src/Phalcon/Http/Message/AbstractCommon.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; /** @@ -11,7 +18,7 @@ abstract class AbstractCommon /** * Returns a new instance having set the parameter * - * @param mixed $element + * @param mixed $element * @param string $property * * @return mixed @@ -24,6 +31,7 @@ final protected function cloneInstance($element, string $property) * Checks the element passed if it is a string * * @param mixed $element + * @return void */ final protected function checkStringParameter($element) { @@ -33,7 +41,7 @@ final protected function checkStringParameter($element) * Checks the element passed; assigns it to the property and returns a * clone of the object back * - * @param mixed $element + * @param mixed $element * @param string $property * * @return mixed @@ -41,4 +49,5 @@ final protected function checkStringParameter($element) final protected function processWith($element, string $property) { } + } diff --git a/src/Phalcon/http/message/AbstractMessage.php b/src/Phalcon/Http/Message/AbstractMessage.php similarity index 95% rename from src/Phalcon/http/message/AbstractMessage.php rename to src/Phalcon/Http/Message/AbstractMessage.php index 861c686d..22907bad 100644 --- a/src/Phalcon/http/message/AbstractMessage.php +++ b/src/Phalcon/Http/Message/AbstractMessage.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Collection; @@ -10,7 +17,7 @@ /** * Message methods */ -abstract class AbstractMessage extends AbstractCommon +abstract class AbstractMessage extends \Phalcon\Http\Message\AbstractCommon { /** * Gets the body of the message. @@ -51,7 +58,7 @@ abstract class AbstractMessage extends AbstractCommon /** * Gets the body of the message. * - * @return StreamInterface + * @return mixed */ public function getBody() { @@ -74,7 +81,7 @@ public function getProtocolVersion(): string * * This method MUST return a UriInterface instance. * - * @return UriInterface + * @return mixed */ public function getUri() { @@ -169,13 +176,13 @@ public function hasHeader($name): bool * immutability of the message, and MUST return an instance that has the * new header and/or value. * - * @param string $name + * @param string $name * @param string|string[] $value * + * @return self * @param mixed $value * @param string|string [] $value * - * @return self */ public function withAddedHeader($name, $value) { @@ -211,15 +218,15 @@ public function withBody(\Psr\Http\Message\StreamInterface $body) * immutability of the message, and MUST return an instance that has the * new and/or updated header and value. * - * @param string $name + * @param string $name * @param string|string[] $value * - * @param mixed $value - * @param string|string [] $value - * * @return self * @throws InvalidArgumentException for invalid header names or values. * + * @param mixed $value + * @param string|string [] $value + * */ public function withHeader($name, $value) { @@ -278,6 +285,7 @@ final protected function checkHeaderHost(\Phalcon\Collection $collection): Colle * * @see http://tools.ietf.org/html/rfc7230#section-3.2 * @param mixed $name + * @return void */ final protected function checkHeaderName($name) { @@ -328,6 +336,7 @@ final protected function checkHeaderName($name) * * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 * @param mixed $value + * @return void */ final protected function checkHeaderValue($value) { @@ -369,7 +378,7 @@ final protected function populateHeaderCollection(array $headers): Collection * Set a valid stream * * @param StreamInterface|resource|string $body - * @param string $mode + * @param string $mode * * @return StreamInterface */ @@ -381,7 +390,7 @@ final protected function processBody($body = 'php://memory', string $mode = 'r+b * Sets the headers * * @param mixed $headers - * @return \Phalcon\Collection + * @return Collection */ final protected function processHeaders($headers): Collection { @@ -397,4 +406,5 @@ final protected function processHeaders($headers): Collection final protected function processProtocol($protocol = ''): string { } + } diff --git a/src/Phalcon/http/message/AbstractRequest.php b/src/Phalcon/Http/Message/AbstractRequest.php similarity index 92% rename from src/Phalcon/http/message/AbstractRequest.php rename to src/Phalcon/Http/Message/AbstractRequest.php index cf69d995..58a23a84 100644 --- a/src/Phalcon/http/message/AbstractRequest.php +++ b/src/Phalcon/Http/Message/AbstractRequest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Http\Message\Exception\InvalidArgumentException; @@ -8,7 +15,7 @@ /** * Request methods */ -abstract class AbstractRequest extends AbstractMessage +abstract class AbstractRequest extends \Phalcon\Http\Message\AbstractMessage { /** * Retrieves the HTTP method of the request. @@ -50,7 +57,7 @@ public function getMethod(): string * * This method MUST return a UriInterface instance. * - * @return UriInterface + * @return mixed */ public function getUri() { @@ -146,7 +153,7 @@ public function withRequestTarget($requestTarget) * @see http://tools.ietf.org/html/rfc3986#section-4.3 * * @param UriInterface $uri - * @param bool $preserveHost + * @param bool $preserveHost * * @return object */ @@ -175,4 +182,5 @@ final protected function processMethod($method = ''): string final protected function processUri($uri): UriInterface { } + } diff --git a/src/Phalcon/http/message/exception/InvalidArgumentException.php b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php similarity index 62% rename from src/Phalcon/http/message/exception/InvalidArgumentException.php rename to src/Phalcon/Http/Message/Exception/InvalidArgumentException.php index a2ebf36c..14de3be7 100644 --- a/src/Phalcon/http/message/exception/InvalidArgumentException.php +++ b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message\Exception; /** diff --git a/src/Phalcon/http/message/Request.php b/src/Phalcon/Http/Message/Request.php similarity index 56% rename from src/Phalcon/http/message/Request.php rename to src/Phalcon/Http/Message/Request.php index 7033576c..484dd5af 100644 --- a/src/Phalcon/http/message/Request.php +++ b/src/Phalcon/Http/Message/Request.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\RequestInterface; @@ -15,12 +22,13 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request /** * Request constructor. * - * @param string $method - * @param UriInterface|string|null $uri + * @param string $method + * @param UriInterface|string|null $uri * @param StreamInterface|resource|string $body - * @param array $headers + * @param array $headers */ public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } + } diff --git a/src/Phalcon/http/message/RequestFactory.php b/src/Phalcon/Http/Message/RequestFactory.php similarity index 64% rename from src/Phalcon/http/message/RequestFactory.php rename to src/Phalcon/Http/Message/RequestFactory.php index f5f626f2..faef1c72 100644 --- a/src/Phalcon/http/message/RequestFactory.php +++ b/src/Phalcon/Http/Message/RequestFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\RequestFactoryInterface; @@ -15,7 +22,7 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface /** * Create a new request. * - * @param string $method + * @param string $method * @param UriInterface|string|null $uri * * @return RequestInterface @@ -23,4 +30,5 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface public function createRequest(string $method, $uri): RequestInterface { } + } diff --git a/src/Phalcon/http/message/Response.php b/src/Phalcon/Http/Message/Response.php similarity index 90% rename from src/Phalcon/http/message/Response.php rename to src/Phalcon/Http/Message/Response.php index c82cf0f7..996e4aef 100644 --- a/src/Phalcon/http/message/Response.php +++ b/src/Phalcon/Http/Message/Response.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\ResponseInterface; @@ -69,8 +76,8 @@ public function getStatusCode(): int * Response constructor. * * @param string $body - * @param int $code - * @param array $headers + * @param int $code + * @param array $headers */ public function __construct($body = 'php://memory', int $code = 200, array $headers = array()) { @@ -91,7 +98,7 @@ public function __construct($body = 'php://memory', int $code = 200, array $head * @see http://tools.ietf.org/html/rfc7231#section-6 * @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * - * @param int $code + * @param int $code * @param string $reasonPhrase * * @return Response @@ -104,6 +111,7 @@ public function withStatus($code, $reasonPhrase = ''): Response * Checks if a code is integer or string * * @param mixed $code + * @return void */ private function checkCodeType($code) { @@ -113,6 +121,7 @@ private function checkCodeType($code) * Checks if a code is integer or string * * @param int $code + * @return void */ private function checkCodeValue(int $code) { @@ -132,8 +141,10 @@ private function getPhrases(): array * * @param mixed $code * @param mixed $phrase + * @return void */ private function processCode($code, $phrase = '') { } + } diff --git a/src/Phalcon/http/message/ResponseFactory.php b/src/Phalcon/Http/Message/ResponseFactory.php similarity index 71% rename from src/Phalcon/http/message/ResponseFactory.php rename to src/Phalcon/Http/Message/ResponseFactory.php index 91b3541a..2b1b0bc8 100644 --- a/src/Phalcon/http/message/ResponseFactory.php +++ b/src/Phalcon/Http/Message/ResponseFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\ResponseFactoryInterface; @@ -14,7 +21,7 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac /** * Create a new response. * - * @param int $code The HTTP status code. Defaults to 200. + * @param int $code The HTTP status code. Defaults to 200. * @param string $reasonPhrase The reason phrase to associate with the status * code in the generated response. If none is * provided, implementations MAY use the defaults @@ -25,4 +32,5 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } + } diff --git a/src/Phalcon/http/message/ServerRequest.php b/src/Phalcon/Http/Message/ServerRequest.php similarity index 92% rename from src/Phalcon/http/message/ServerRequest.php rename to src/Phalcon/Http/Message/ServerRequest.php index 5f62b6e8..9f668251 100644 --- a/src/Phalcon/http/message/ServerRequest.php +++ b/src/Phalcon/Http/Message/ServerRequest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Collection; @@ -12,7 +19,7 @@ /** * PSR-7 ServerRequest */ -final class ServerRequest extends AbstractRequest implements \Psr\Http\Message\ServerRequestInterface +final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implements \Psr\Http\Message\ServerRequestInterface { /** * @var Collection @@ -165,16 +172,16 @@ public function getUploadedFiles(): array /** * ServerRequest constructor. * - * @param string $method + * @param string $method * @param UriInterface|string|null $uri - * @param array $serverParams - * @param StreamInterface|string $body - * @param array $headers - * @param array $cookies - * @param array $queryParams - * @param array $uploadFiles - * @param null|array|object $parsedBody - * @param string $protocol + * @param array $serverParams + * @param StreamInterface|string $body + * @param array $headers + * @param array $cookies + * @param array $queryParams + * @param array $uploadFiles + * @param null|array|object $parsedBody + * @param string $protocol */ public function __construct(string $method = 'GET', $uri = null, array $serverParams = array(), $body = 'php://input', $headers = array(), array $cookies = array(), array $queryParams = array(), array $uploadFiles = array(), $parsedBody = null, string $protocol = '1.1') { @@ -190,8 +197,8 @@ public function __construct(string $method = 'GET', $uri = null, array $serverPa * This method obviates the need for a hasAttribute() method, as it allows * specifying a default value to return if the attribute is not found. * - * @param string $name - * @param mixed|null $defaultValue + * @param string $name + * @param mixed|null $defaultValue * * @return mixed */ @@ -225,7 +232,7 @@ public function getAttributes(): array * updated attribute. * * @param string $name - * @param mixed $value + * @param mixed $value * * @return ServerRequest */ @@ -352,8 +359,10 @@ public function withoutAttribute($name): ServerRequest * Checks the uploaded files * * @param array $files + * @return void */ private function checkUploadedFiles(array $files) { } + } diff --git a/src/Phalcon/http/message/ServerRequestFactory.php b/src/Phalcon/Http/Message/ServerRequestFactory.php similarity index 89% rename from src/Phalcon/http/message/ServerRequestFactory.php rename to src/Phalcon/Http/Message/ServerRequestFactory.php index 5bc42c35..7dd6a7ea 100644 --- a/src/Phalcon/http/message/ServerRequestFactory.php +++ b/src/Phalcon/Http/Message/ServerRequestFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Collection; @@ -23,14 +30,14 @@ class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInte * no attempt is made to determine the HTTP method or URI, which must be * provided explicitly. * - * @param string $method The HTTP method associated with + * @param string $method The HTTP method associated with * the request. - * @param UriInterface|string $uri The URI associated with the + * @param UriInterface|string $uri The URI associated with the * request. If the value is a * string, the factory MUST create * a UriInterface instance based * on it. - * @param array $serverParams Array of SAPI parameters with + * @param array $serverParams Array of SAPI parameters with * which to seed the generated * request instance. * @@ -46,11 +53,11 @@ public function createServerRequest(string $method, $uri, array $serverParams = * If any argument is not supplied, the corresponding superglobal value will * be used. * - * @param array $server $_SERVER superglobal - * @param array $get $_GET superglobal - * @param array $post $_POST superglobal + * @param array $server $_SERVER superglobal + * @param array $get $_GET superglobal + * @param array $post $_POST superglobal * @param array $cookies $_COOKIE superglobal - * @param array $files $_FILES superglobal + * @param array $files $_FILES superglobal * * @return ServerRequest * @see fromServer() @@ -155,7 +162,7 @@ private function createUploadedFile(array $file): UploadedFile * Returns a header * * @param Collection $headers - * @param string $name + * @param string $name * @param mixed|null $defaultValue * * @return mixed|string @@ -234,4 +241,5 @@ private function parseUploadedFiles(array $files): Collection private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri { } + } diff --git a/src/Phalcon/http/message/Stream.php b/src/Phalcon/Http/Message/Stream.php similarity index 89% rename from src/Phalcon/http/message/Stream.php rename to src/Phalcon/Http/Message/Stream.php index 2a44a4f0..f0bf06b5 100644 --- a/src/Phalcon/http/message/Stream.php +++ b/src/Phalcon/Http/Message/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\StreamInterface; @@ -23,7 +30,7 @@ class Stream implements \Psr\Http\Message\StreamInterface /** * Stream constructor. * - * @param mixed $stream + * @param mixed $stream * @param string $mode */ public function __construct($stream, string $mode = 'rb') @@ -57,6 +64,8 @@ public function __toString(): string /** * Closes the stream and any underlying resources. + * + * @return void */ public function close() { @@ -157,6 +166,8 @@ public function read($length): string * * If the stream is not seekable, this method will raise an exception; * otherwise, it will perform a seek(0). + * + * @return void */ public function rewind() { @@ -167,6 +178,7 @@ public function rewind() * * @param int $offset * @param int $whence + * @return void */ public function seek($offset, $whence = 0) { @@ -175,8 +187,9 @@ public function seek($offset, $whence = 0) /** * Sets the stream - existing instance * - * @param mixed $stream + * @param mixed $stream * @param string $mode + * @return void */ public function setStream($stream, string $mode = 'rb') { @@ -204,6 +217,8 @@ public function write($data): int /** * Checks if a handle is available and throws an exception otherwise + * + * @return void */ private function checkHandle() { @@ -211,6 +226,8 @@ private function checkHandle() /** * Checks if a handle is readable and throws an exception otherwise + * + * @return void */ private function checkReadable() { @@ -218,6 +235,8 @@ private function checkReadable() /** * Checks if a handle is seekable and throws an exception otherwise + * + * @return void */ private function checkSeekable() { @@ -225,8 +244,11 @@ private function checkSeekable() /** * Checks if a handle is writeable and throws an exception otherwise + * + * @return void */ private function checkWritable() { } + } diff --git a/src/Phalcon/http/message/stream/Input.php b/src/Phalcon/Http/Message/Stream/Input.php similarity index 88% rename from src/Phalcon/http/message/stream/Input.php rename to src/Phalcon/Http/Message/Stream/Input.php index 88c39025..bb33507f 100644 --- a/src/Phalcon/http/message/stream/Input.php +++ b/src/Phalcon/Http/Message/Stream/Input.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -52,12 +59,12 @@ public function __toString(): string /** * Returns the remaining contents in a string * - * @param int $length - * - * @return string * @throws RuntimeException if unable to read. * @throws RuntimeException if error occurs while reading. * + * @param int $length + * + * @return string */ public function getContents(int $length = -1): string { @@ -82,4 +89,5 @@ public function isWritable(): bool public function read($length): string { } + } diff --git a/src/Phalcon/http/message/stream/Memory.php b/src/Phalcon/Http/Message/Stream/Memory.php similarity index 67% rename from src/Phalcon/http/message/stream/Memory.php rename to src/Phalcon/Http/Message/Stream/Memory.php index f325bf53..2f83336f 100644 --- a/src/Phalcon/http/message/stream/Memory.php +++ b/src/Phalcon/Http/Message/Stream/Memory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -22,4 +29,5 @@ class Memory extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/http/message/stream/Temp.php b/src/Phalcon/Http/Message/Stream/Temp.php similarity index 67% rename from src/Phalcon/http/message/stream/Temp.php rename to src/Phalcon/Http/Message/Stream/Temp.php index 8f9b6650..bd28c2f7 100644 --- a/src/Phalcon/http/message/stream/Temp.php +++ b/src/Phalcon/Http/Message/Stream/Temp.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message\Stream; use Phalcon\Http\Message\Stream; @@ -22,4 +29,5 @@ class Temp extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/http/message/StreamFactory.php b/src/Phalcon/Http/Message/StreamFactory.php similarity index 81% rename from src/Phalcon/http/message/StreamFactory.php rename to src/Phalcon/Http/Message/StreamFactory.php index ee5921f9..911a1512 100644 --- a/src/Phalcon/http/message/StreamFactory.php +++ b/src/Phalcon/Http/Message/StreamFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\StreamFactoryInterface; @@ -34,7 +41,7 @@ public function createStream(string $content = ''): StreamInterface * * @param string $filename The filename or stream URI to use as basis of * stream. - * @param string $mode The mode with which to open the underlying + * @param string $mode The mode with which to open the underlying * filename/stream. * * @return StreamInterface @@ -49,9 +56,10 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St * The stream MUST be readable and may be writable. * * @param mixed $phpResource - * @return \Psr\Http\Message\StreamInterface + * @return StreamInterface */ public function createStreamFromResource($phpResource): StreamInterface { } + } diff --git a/src/Phalcon/http/message/UploadedFile.php b/src/Phalcon/Http/Message/UploadedFile.php similarity index 92% rename from src/Phalcon/http/message/UploadedFile.php rename to src/Phalcon/Http/Message/UploadedFile.php index fa61d185..20d2ca4b 100644 --- a/src/Phalcon/http/message/UploadedFile.php +++ b/src/Phalcon/Http/Message/UploadedFile.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Http\Message\Exception\InvalidArgumentException; @@ -156,10 +163,10 @@ public function getSize(): ?int * UploadedFile constructor. * * @param StreamInterface|string|null $stream - * @param int|null $size - * @param int $error - * @param string|null $clientFilename - * @param string|null $clientMediaType + * @param int|null $size + * @param int $error + * @param string|null $clientFilename + * @param string|null $clientMediaType */ public function __construct($stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null) { @@ -217,6 +224,7 @@ public function getStream() * @throws InvalidArgumentException if the $targetPath specified is invalid. * @throws RuntimeException on any error during the move operation, or on * the second or subsequent call to the method. + * @return void */ public function moveTo($targetPath) { @@ -226,6 +234,7 @@ public function moveTo($targetPath) * Checks the passed error code and if not in the range throws an exception * * @param int $error + * @return void */ private function checkError(int $error) { @@ -235,7 +244,8 @@ private function checkError(int $error) * Checks the passed error code and if not in the range throws an exception * * @param StreamInterface|resource|string $stream - * @param int $error + * @param int $error + * @return void */ private function checkStream($stream, int $error) { @@ -256,8 +266,10 @@ private function getErrorDescription(int $error): string * Store a file in the new location (stream) * * @param string $targetPath + * @return void */ private function storeFile(string $targetPath) { } + } diff --git a/src/Phalcon/http/message/UploadedFileFactory.php b/src/Phalcon/Http/Message/UploadedFileFactory.php similarity index 58% rename from src/Phalcon/http/message/UploadedFileFactory.php rename to src/Phalcon/Http/Message/UploadedFileFactory.php index fe2c233e..7b553ac2 100644 --- a/src/Phalcon/http/message/UploadedFileFactory.php +++ b/src/Phalcon/Http/Message/UploadedFileFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\StreamInterface; @@ -21,17 +28,18 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory * @link http://php.net/manual/features.file-upload.post-method.php * @link http://php.net/manual/features.file-upload.errors.php * - * @param StreamInterface $stream The underlying stream representing the + * @param StreamInterface $stream The underlying stream representing the * uploaded file content. - * @param int $size The size of the file in bytes. - * @param int $error The PHP file upload error. - * @param string $clientFilename The filename as provided by the client, if any. - * @param string $clientMediaType The media type as provided by the client, if any. + * @param int $size The size of the file in bytes. + * @param int $error The PHP file upload error. + * @param string $clientFilename The filename as provided by the client, if any. + * @param string $clientMediaType The media type as provided by the client, if any. * * @throws \InvalidArgumentException If the file resource is not readable. - * @return \Psr\Http\Message\UploadedFileInterface + * @return UploadedFileInterface */ public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } + } diff --git a/src/Phalcon/http/message/Uri.php b/src/Phalcon/Http/Message/Uri.php similarity index 97% rename from src/Phalcon/http/message/Uri.php rename to src/Phalcon/Http/Message/Uri.php index ab67acd2..93f6483c 100644 --- a/src/Phalcon/http/message/Uri.php +++ b/src/Phalcon/Http/Message/Uri.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Phalcon\Http\Message\Exception\InvalidArgumentException; @@ -8,7 +15,7 @@ /** * PSR-7 Uri */ -final class Uri extends AbstractCommon implements \Psr\Http\Message\UriInterface +final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Http\Message\UriInterface { /** * Returns the fragment of the URL @@ -317,7 +324,7 @@ public function withScheme($scheme): Uri /** * Return an instance with the specified user information. * - * @param string $user + * @param string $user * @param string|null $password * * @return Uri @@ -465,4 +472,5 @@ private function filterScheme(string $scheme): string private function splitQueryValue(string $element): array { } + } diff --git a/src/Phalcon/http/message/UriFactory.php b/src/Phalcon/Http/Message/UriFactory.php similarity index 63% rename from src/Phalcon/http/message/UriFactory.php rename to src/Phalcon/Http/Message/UriFactory.php index e3ba04cf..81168be2 100644 --- a/src/Phalcon/http/message/UriFactory.php +++ b/src/Phalcon/Http/Message/UriFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Message; use Psr\Http\Message\UriFactoryInterface; @@ -16,9 +23,10 @@ final class UriFactory implements \Psr\Http\Message\UriFactoryInterface * functions * * @param string $uri - * @return \Psr\Http\Message\UriInterface + * @return UriInterface */ public function createUri(string $uri = ''): UriInterface { } + } diff --git a/src/Phalcon/http/Request.php b/src/Phalcon/Http/Request.php similarity index 96% rename from src/Phalcon/http/Request.php rename to src/Phalcon/Http/Request.php index a8f767ee..fa07b276 100644 --- a/src/Phalcon/http/Request.php +++ b/src/Phalcon/Http/Request.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; use Phalcon\Di\AbstractInjectionAware; @@ -31,7 +38,7 @@ * $request->getLanguages(); * ``` */ -class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInterface +class Request extends AbstractInjectionAware implements Phalcon\Http\RequestInterface { private $filterService; @@ -308,7 +315,7 @@ public function getHTTPReferer(): string * Gets decoded JSON HTTP raw request body * * @param bool $associative - * @return array|bool|\stdClass + * @return mixed */ public function getJsonRawBody(bool $associative = false) { @@ -472,7 +479,7 @@ public function getServerName(): string * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] + * @return array */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array { @@ -516,14 +523,11 @@ public function has(string $name): bool } /** - * Returns the number of files available - * - * TODO: Check this + * Returns if the request has files or not * - * @param bool $onlySuccessful - * @return long + * @return bool */ - public function hasFiles(bool $onlySuccessful = false): int + public function hasFiles(): bool { } @@ -736,6 +740,16 @@ public function isValidHttpMethod(string $method): bool { } + /** + * Returns the number of files available + * + * @param bool $onlySuccessful + * @return int + */ + public function numFiles(bool $onlySuccessful = false): int + { + } + /** * Sets automatic sanitizers/filters for a particular field and for * particular methods @@ -792,7 +806,7 @@ final protected function getHelper(array $source, string $name = null, $filters * * @param mixed $data * @param bool $onlySuccessful - * @return long + * @return int */ final protected function hasFileHelper($data, bool $onlySuccessful): int { @@ -836,7 +850,7 @@ final protected function smoothFiles(array $names, array $types, array $tmp_name /** * Checks the filter service and assigns it to the class parameter * - * @return \Phalcon\Filter\FilterInterface + * @return FilterInterface */ private function getFilterService(): FilterInterface { @@ -848,4 +862,5 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } + } diff --git a/src/Phalcon/Http/Request/Exception.php b/src/Phalcon/Http/Request/Exception.php new file mode 100644 index 00000000..2005b9fa --- /dev/null +++ b/src/Phalcon/Http/Request/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Http\Request; + +/** + * Phalcon\Http\Request\Exception + * + * Exceptions thrown in Phalcon\Http\Request will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/http/request/File.php b/src/Phalcon/Http/Request/File.php similarity index 90% rename from src/Phalcon/http/request/File.php rename to src/Phalcon/Http/Request/File.php index e3fc6ff0..983865b5 100644 --- a/src/Phalcon/http/request/File.php +++ b/src/Phalcon/Http/Request/File.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Request; /** @@ -25,7 +32,7 @@ * } * ``` */ -class File implements \Phalcon\Http\Request\FileInterface +class File implements Phalcon\Http\Request\FileInterface { /** * @var string|null @@ -153,4 +160,5 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } + } diff --git a/src/Phalcon/http/request/FileInterface.php b/src/Phalcon/Http/Request/FileInterface.php similarity index 83% rename from src/Phalcon/http/request/FileInterface.php rename to src/Phalcon/Http/Request/FileInterface.php index 8353aca4..220db2e3 100644 --- a/src/Phalcon/http/request/FileInterface.php +++ b/src/Phalcon/Http/Request/FileInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Request; /** @@ -53,4 +60,5 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; + } diff --git a/src/Phalcon/http/RequestInterface.php b/src/Phalcon/Http/RequestInterface.php similarity index 96% rename from src/Phalcon/http/RequestInterface.php rename to src/Phalcon/Http/RequestInterface.php index d15b3a93..7724af2f 100644 --- a/src/Phalcon/http/RequestInterface.php +++ b/src/Phalcon/Http/RequestInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; /** @@ -177,7 +184,7 @@ public function getHTTPReferer(): string; * Gets decoded JSON HTTP raw request body * * @param bool $associative - * @return array|bool|\stdClass + * @return mixed */ public function getJsonRawBody(bool $associative = false); @@ -334,7 +341,7 @@ public function getServerName(): string; * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] + * @return array */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; @@ -355,12 +362,10 @@ public function has(string $name): bool; /** * Checks whether request include attached files - * TODO: We need to check the name. Not very intuitive * - * @param bool $onlySuccessful - * @return long + * @return bool */ - public function hasFiles(bool $onlySuccessful = false): int; + public function hasFiles(): bool; /** * Checks whether headers has certain index @@ -495,4 +500,13 @@ public function isSoap(): bool; * @return bool */ public function isTrace(): bool; + + /** + * Returns the number of files available + * + * @param bool $onlySuccessful + * @return int + */ + public function numFiles(bool $onlySuccessful = false): int; + } diff --git a/src/Phalcon/http/Response.php b/src/Phalcon/Http/Response.php similarity index 94% rename from src/Phalcon/http/Response.php rename to src/Phalcon/Http/Response.php index a25698f6..d41d388f 100644 --- a/src/Phalcon/http/Response.php +++ b/src/Phalcon/Http/Response.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; use Phalcon\Di\DiInterface; @@ -21,7 +28,7 @@ * $response->send(); * ``` */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Response implements Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { protected $container; @@ -83,7 +90,7 @@ public function getContent(): string /** * Returns cookies set by the user * - * @return \Phalcon\Http\Response\CookiesInterface + * @return CookiesInterface */ public function getCookies(): CookiesInterface { @@ -92,7 +99,7 @@ public function getCookies(): CookiesInterface /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -101,7 +108,7 @@ public function getDI(): DiInterface /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -110,7 +117,7 @@ public function getEventsManager(): ManagerInterface /** * Returns headers set by the user * - * @return \Phalcon\Http\Response\HeadersInterface + * @return HeadersInterface */ public function getHeaders(): HeadersInterface { @@ -237,7 +244,7 @@ public function sendCookies(): ResponseInterface /** * Sends headers to the client * - * @return bool|ResponseInterface + * @return mixed */ public function sendHeaders() { @@ -315,6 +322,7 @@ public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): Re * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -358,6 +366,7 @@ public function setExpires(\DateTime $datetime): ResponseInterface * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -474,4 +483,5 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } + } diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/Http/Response/Cookies.php similarity index 90% rename from src/Phalcon/http/response/Cookies.php rename to src/Phalcon/Http/Response/Cookies.php index a08fb7e8..79bc9b97 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/Http/Response/Cookies.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Response; use Phalcon\Di\AbstractInjectionAware; @@ -53,7 +60,7 @@ * ); * ``` */ -class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\CookiesInterface +class Cookies extends AbstractInjectionAware implements Phalcon\Http\Response\CookiesInterface { protected $cookies = array(); @@ -97,7 +104,7 @@ public function delete(string $name): bool * Gets a cookie from the bag * * @param string $name - * @return \Phalcon\Http\CookieInterface + * @return CookieInterface */ public function get(string $name): CookieInterface { @@ -135,7 +142,7 @@ public function isUsingEncryption(): bool /** * Reset set cookies * - * @return \Phalcon\Http\Response\CookiesInterface + * @return CookiesInterface */ public function reset(): CookiesInterface { @@ -177,7 +184,7 @@ public function send(): bool * @param bool $secure * @param string $domain * @param bool $httpOnly - * @return \Phalcon\Http\Response\CookiesInterface + * @return CookiesInterface */ public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface { @@ -191,9 +198,9 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * * Use NULL to disable cookie signing. * - * @param string $signKey - * @return \Phalcon\Http\CookieInterface * @see \Phalcon\Security\Random + * @param string $signKey + * @return CookieInterface */ public function setSignKey(string $signKey = null): CookieInterface { @@ -203,9 +210,10 @@ public function setSignKey(string $signKey = null): CookieInterface * Set if cookies in the bag must be automatically encrypted/decrypted * * @param bool $useEncryption - * @return \Phalcon\Http\Response\CookiesInterface + * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface { } + } diff --git a/src/Phalcon/http/response/CookiesInterface.php b/src/Phalcon/Http/Response/CookiesInterface.php similarity index 88% rename from src/Phalcon/http/response/CookiesInterface.php rename to src/Phalcon/Http/Response/CookiesInterface.php index 63093998..1bffce49 100644 --- a/src/Phalcon/http/response/CookiesInterface.php +++ b/src/Phalcon/Http/Response/CookiesInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Response; use Phalcon\Http\CookieInterface; @@ -25,7 +32,7 @@ public function delete(string $name): bool; * Gets a cookie from the bag * * @param string $name - * @return \Phalcon\Http\CookieInterface + * @return CookieInterface */ public function get(string $name): CookieInterface; @@ -79,4 +86,5 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; + } diff --git a/src/Phalcon/Http/Response/Exception.php b/src/Phalcon/Http/Response/Exception.php new file mode 100644 index 00000000..22395565 --- /dev/null +++ b/src/Phalcon/Http/Response/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Http\Response; + +/** + * Phalcon\Http\Response\Exception + * + * Exceptions thrown in Phalcon\Http\Response will use this class. + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/http/response/Headers.php b/src/Phalcon/Http/Response/Headers.php similarity index 79% rename from src/Phalcon/http/response/Headers.php rename to src/Phalcon/Http/Response/Headers.php index 47b88b13..6dd8bdaf 100644 --- a/src/Phalcon/http/response/Headers.php +++ b/src/Phalcon/Http/Response/Headers.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Response; /** @@ -7,7 +14,7 @@ * * This class is a bag to manage the response headers */ -class Headers implements \Phalcon\Http\Response\HeadersInterface +class Headers implements Phalcon\Http\Response\HeadersInterface { protected $headers = array(); @@ -37,7 +44,7 @@ public function has(string $name): bool * Removes a header to be sent at the end of the request * * @param string $header - * @return \Phalcon\Http\Response\HeadersInterface + * @return HeadersInterface */ public function remove(string $header): HeadersInterface { @@ -64,7 +71,7 @@ public function send(): bool * * @param string $name * @param string $value - * @return \Phalcon\Http\Response\HeadersInterface + * @return HeadersInterface */ public function set(string $name, string $value): HeadersInterface { @@ -74,7 +81,7 @@ public function set(string $name, string $value): HeadersInterface * Sets a raw header to be sent at the end of the request * * @param string $header - * @return \Phalcon\Http\Response\HeadersInterface + * @return HeadersInterface */ public function setRaw(string $header): HeadersInterface { @@ -88,4 +95,5 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } + } diff --git a/src/Phalcon/http/response/HeadersInterface.php b/src/Phalcon/Http/Response/HeadersInterface.php similarity index 82% rename from src/Phalcon/http/response/HeadersInterface.php rename to src/Phalcon/Http/Response/HeadersInterface.php index 0e178f64..c72a5305 100644 --- a/src/Phalcon/http/response/HeadersInterface.php +++ b/src/Phalcon/Http/Response/HeadersInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Response; /** @@ -52,4 +59,5 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); + } diff --git a/src/Phalcon/http/ResponseInterface.php b/src/Phalcon/Http/ResponseInterface.php similarity index 93% rename from src/Phalcon/http/ResponseInterface.php rename to src/Phalcon/Http/ResponseInterface.php index 8d6ba4e4..a9a385dd 100644 --- a/src/Phalcon/http/ResponseInterface.php +++ b/src/Phalcon/Http/ResponseInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http; use Phalcon\Http\Response\HeadersInterface; @@ -37,7 +44,7 @@ public function getStatusCode(): ?int; /** * Returns headers set by the user * - * @return \Phalcon\Http\Response\HeadersInterface + * @return HeadersInterface */ public function getHeaders(): HeadersInterface; @@ -181,7 +188,8 @@ public function sendCookies(): ResponseInterface; /** * Sends headers to the client * - * @return bool|ResponseInterface + * @return mixed */ public function sendHeaders(); + } diff --git a/src/Phalcon/http/server/AbstractMiddleware.php b/src/Phalcon/Http/Server/AbstractMiddleware.php similarity index 81% rename from src/Phalcon/http/server/AbstractMiddleware.php rename to src/Phalcon/Http/Server/AbstractMiddleware.php index 1dd1de4b..ff970f7b 100644 --- a/src/Phalcon/http/server/AbstractMiddleware.php +++ b/src/Phalcon/Http/Server/AbstractMiddleware.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Server; use Psr\Http\Message\ResponseInterface; @@ -26,7 +33,8 @@ abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterfac * * @param \Psr\Http\Message\ServerRequestInterface $request * @param \Psr\Http\Server\RequestHandlerInterface $handler - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; + } diff --git a/src/Phalcon/http/server/AbstractRequestHandler.php b/src/Phalcon/Http/Server/AbstractRequestHandler.php similarity index 73% rename from src/Phalcon/http/server/AbstractRequestHandler.php rename to src/Phalcon/Http/Server/AbstractRequestHandler.php index 9d08bce7..b74a5596 100644 --- a/src/Phalcon/http/server/AbstractRequestHandler.php +++ b/src/Phalcon/Http/Server/AbstractRequestHandler.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Http\Server; use Psr\Http\Message\ResponseInterface; @@ -21,7 +28,8 @@ abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandler * May call other collaborating code to generate the response. * * @param \Psr\Http\Message\ServerRequestInterface $request - * @return \Psr\Http\Message\ResponseInterface + * @return ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; + } diff --git a/src/Phalcon/image/adapter/AbstractAdapter.php b/src/Phalcon/Image/Adapter/AbstractAdapter.php similarity index 92% rename from src/Phalcon/image/adapter/AbstractAdapter.php rename to src/Phalcon/Image/Adapter/AbstractAdapter.php index 253757e4..54c5d6e5 100644 --- a/src/Phalcon/image/adapter/AbstractAdapter.php +++ b/src/Phalcon/Image/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image\Adapter; use Phalcon\Image\Enum; @@ -9,10 +16,10 @@ * * All image adapters must use this class */ -abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Image\Adapter\AdapterInterface { - protected static $checked = false; + static protected $checked = false; protected $file; @@ -150,8 +157,8 @@ public function flip(int $direction): AdapterInterface * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. * @return AbstractAdapter @@ -274,4 +281,5 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } + } diff --git a/src/Phalcon/image/adapter/AdapterInterface.php b/src/Phalcon/Image/Adapter/AdapterInterface.php similarity index 93% rename from src/Phalcon/image/adapter/AdapterInterface.php rename to src/Phalcon/Image/Adapter/AdapterInterface.php index d6c1dd93..4325b26a 100644 --- a/src/Phalcon/image/adapter/AdapterInterface.php +++ b/src/Phalcon/Image/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image\Adapter; use Phalcon\Image\Enum; @@ -117,4 +124,5 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; + } diff --git a/src/Phalcon/image/adapter/Gd.php b/src/Phalcon/Image/Adapter/Gd.php similarity index 90% rename from src/Phalcon/image/adapter/Gd.php rename to src/Phalcon/Image/Adapter/Gd.php index 01ed1339..a626f8d8 100644 --- a/src/Phalcon/image/adapter/Gd.php +++ b/src/Phalcon/Image/Adapter/Gd.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image\Adapter; /** @@ -10,10 +17,10 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Gd extends AbstractAdapter +class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - protected static $checked = false; + static protected $checked = false; /** @@ -171,4 +178,5 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) { } + } diff --git a/src/Phalcon/image/adapter/Imagick.php b/src/Phalcon/Image/Adapter/Imagick.php similarity index 91% rename from src/Phalcon/image/adapter/Imagick.php rename to src/Phalcon/Image/Adapter/Imagick.php index 41cf51c9..3cc6d8f2 100644 --- a/src/Phalcon/image/adapter/Imagick.php +++ b/src/Phalcon/Image/Adapter/Imagick.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image\Adapter; /** @@ -18,13 +25,13 @@ * } * ``` */ -class Imagick extends AbstractAdapter +class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - protected static $checked = false; + static protected $checked = false; - protected static $version = 0; + static protected $version = 0; /** @@ -120,8 +127,8 @@ protected function processFlip(int $direction) * This method scales the images using liquid rescaling method. Only support * Imagick * - * @param int $width new width - * @param int $height new height + * @param int $width new width + * @param int $height new height * @param int $deltaX How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. */ @@ -235,4 +242,5 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } + } diff --git a/src/Phalcon/image/Enum.php b/src/Phalcon/Image/Enum.php similarity index 68% rename from src/Phalcon/image/Enum.php rename to src/Phalcon/Image/Enum.php index 2a1a2ca5..f059d608 100644 --- a/src/Phalcon/image/Enum.php +++ b/src/Phalcon/Image/Enum.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image; /** @@ -38,4 +45,6 @@ class Enum const VERTICAL = 12; + + } diff --git a/src/Phalcon/Image/Exception.php b/src/Phalcon/Image/Exception.php new file mode 100644 index 00000000..a0223ee0 --- /dev/null +++ b/src/Phalcon/Image/Exception.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Image; + +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/image/ImageFactory.php b/src/Phalcon/Image/ImageFactory.php similarity index 75% rename from src/Phalcon/image/ImageFactory.php rename to src/Phalcon/Image/ImageFactory.php index a1c1fb96..68285a8e 100644 --- a/src/Phalcon/image/ImageFactory.php +++ b/src/Phalcon/Image/ImageFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Image; use Phalcon\Factory\AbstractFactory; @@ -24,7 +31,7 @@ public function __construct(array $services = array()) * Factory to create an instace from a Config object * * @param mixed $config - * @return \Phalcon\Image\Adapter\AdapterInterface + * @return AdapterInterface */ public function load($config): AdapterInterface { @@ -37,7 +44,7 @@ public function load($config): AdapterInterface * @param string $file * @param int $width * @param int $height - * @return \Phalcon\Image\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, string $file, int $width = null, int $height = null): AdapterInterface { @@ -49,4 +56,5 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index dbca3b84..e0c058b9 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -12,10 +19,11 @@ class Kernel * Produces a pre-computed hash key based on a string. This function * produces different numbers in 32bit/64bit processors * - * @param string $key * @return string + * @param string $key */ public static function preComputeHashKey(string $key) { } + } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 62055867..fd1bc6d3 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Events\ManagerInterface; @@ -117,7 +124,7 @@ public function getDirs(): array /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -161,6 +168,8 @@ public function getNamespaces(): array /** * Checks if a file exists and then adds the file by doing virtual require + * + * @return void */ public function loadFiles() { @@ -225,6 +234,7 @@ public function registerNamespaces(array $namespaces, bool $merge = false): Load * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -279,4 +289,5 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } + } diff --git a/src/Phalcon/Loader/Exception.php b/src/Phalcon/Loader/Exception.php new file mode 100644 index 00000000..6e7018dc --- /dev/null +++ b/src/Phalcon/Loader/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Loader; + +/** + * Phalcon\Loader\Exception + * + * Exceptions thrown in Phalcon\Loader will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 85dda5f1..9d7be128 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Logger\Adapter\AdapterInterface; @@ -132,6 +139,7 @@ public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterfac * * @param string $message * @param array $context + * @return void */ public function alert($message, array $context = array()) { @@ -144,6 +152,7 @@ public function alert($message, array $context = array()) * * @param string $message * @param array $context + * @return void */ public function critical($message, array $context = array()) { @@ -154,6 +163,7 @@ public function critical($message, array $context = array()) * * @param string $message * @param array $context + * @return void */ public function debug($message, array $context = array()) { @@ -165,6 +175,7 @@ public function debug($message, array $context = array()) * * @param string $message * @param array $context + * @return void */ public function error($message, array $context = array()) { @@ -175,6 +186,7 @@ public function error($message, array $context = array()) * * @param string $message * @param array $context + * @return void */ public function emergency($message, array $context = array()) { @@ -195,8 +207,8 @@ public function excludeAdapters(array $adapters = array()): Logger * * @param string $name The name of the adapter * - * @return \Phalcon\Logger\Adapter\AdapterInterface * @throws Exception + * @return AdapterInterface */ public function getAdapter(string $name): AdapterInterface { @@ -227,6 +239,7 @@ public function getName(): string * * @param string $message * @param array $context + * @return void */ public function info($message, array $context = array()) { @@ -238,6 +251,7 @@ public function info($message, array $context = array()) * @param mixed $level * @param string $message * @param array $context + * @return void */ public function log($level, $message, array $context = array()) { @@ -248,6 +262,7 @@ public function log($level, $message, array $context = array()) * * @param string $message * @param array $context + * @return void */ public function notice($message, array $context = array()) { @@ -258,8 +273,8 @@ public function notice($message, array $context = array()) * * @param string $name The name of the adapter * - * @return Logger * @throws Logger\Exception + * @return Logger */ public function removeAdapter(string $name): Logger { @@ -293,6 +308,7 @@ public function setLogLevel(int $level): Logger * * @param string $message * @param array $context + * @return void */ public function warning($message, array $context = array()) { @@ -303,9 +319,9 @@ public function warning($message, array $context = array()) * * @param int $level * @param string $message * + * @throws Logger\Exception * @param array $context * @return bool - * @throws Logger\Exception */ protected function addMessage(int $level, string $message, array $context = array()): bool { @@ -329,4 +345,5 @@ protected function getLevels(): array private function getLevelNumber($level): int { } + } diff --git a/src/Phalcon/logger/adapter/AbstractAdapter.php b/src/Phalcon/Logger/Adapter/AbstractAdapter.php similarity index 80% rename from src/Phalcon/logger/adapter/AbstractAdapter.php rename to src/Phalcon/Logger/Adapter/AbstractAdapter.php index 3fe967ae..66c7e7bf 100644 --- a/src/Phalcon/logger/adapter/AbstractAdapter.php +++ b/src/Phalcon/Logger/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Adapter; use Phalcon\Logger\Formatter\FormatterInterface; @@ -12,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Logger\Adapter\AdapterInterface { /** * Name of the default formatter class @@ -54,7 +61,7 @@ public function __destruct() * Adds a message to the queue * * @param \Phalcon\Logger\Item $item - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function add(\Phalcon\Logger\Item $item): AdapterInterface { @@ -63,7 +70,7 @@ public function add(\Phalcon\Logger\Item $item): AdapterInterface /** * Starts a transaction * - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function begin(): AdapterInterface { @@ -72,14 +79,14 @@ public function begin(): AdapterInterface /** * Commits the internal transaction * - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function commit(): AdapterInterface { } /** - * @return \Phalcon\Logger\Formatter\FormatterInterface + * @return FormatterInterface */ public function getFormatter(): FormatterInterface { @@ -98,13 +105,14 @@ public function inTransaction(): bool * Processes the message in the adapter * * @param \Phalcon\Logger\Item $item + * @return void */ abstract public function process(\Phalcon\Logger\Item $item); /** * Rollbacks the internal transaction * - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function rollback(): AdapterInterface { @@ -114,9 +122,10 @@ public function rollback(): AdapterInterface * Sets the message formatter * * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } + } diff --git a/src/Phalcon/logger/adapter/AdapterInterface.php b/src/Phalcon/Logger/Adapter/AdapterInterface.php similarity index 84% rename from src/Phalcon/logger/adapter/AdapterInterface.php rename to src/Phalcon/Logger/Adapter/AdapterInterface.php index b93635a8..7bc7cad0 100644 --- a/src/Phalcon/logger/adapter/AdapterInterface.php +++ b/src/Phalcon/Logger/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Adapter; use Phalcon\Logger\Formatter\FormatterInterface; @@ -44,7 +51,7 @@ public function commit(): AdapterInterface; /** * Returns the internal formatter * - * @return \Phalcon\Logger\Formatter\FormatterInterface + * @return FormatterInterface */ public function getFormatter(): FormatterInterface; @@ -52,6 +59,7 @@ public function getFormatter(): FormatterInterface; * Processes the message in the adapter * * @param \Phalcon\Logger\Item $item + * @return void */ public function process(\Phalcon\Logger\Item $item); @@ -69,4 +77,5 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; + } diff --git a/src/Phalcon/logger/adapter/Noop.php b/src/Phalcon/Logger/Adapter/Noop.php similarity index 73% rename from src/Phalcon/logger/adapter/Noop.php rename to src/Phalcon/Logger/Adapter/Noop.php index bf2b4978..2b9761fb 100644 --- a/src/Phalcon/logger/adapter/Noop.php +++ b/src/Phalcon/Logger/Adapter/Noop.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Adapter; /** @@ -32,8 +39,10 @@ public function close(): bool * Processes the message i.e. writes it to the file * * @param \Phalcon\Logger\Item $item + * @return void */ public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/logger/adapter/Stream.php b/src/Phalcon/Logger/Adapter/Stream.php similarity index 85% rename from src/Phalcon/logger/adapter/Stream.php rename to src/Phalcon/Logger/Adapter/Stream.php index c61052d7..32cfeb14 100644 --- a/src/Phalcon/logger/adapter/Stream.php +++ b/src/Phalcon/Logger/Adapter/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Adapter; /** @@ -80,8 +87,10 @@ public function close(): bool * Processes the message i.e. writes it to the file * * @param \Phalcon\Logger\Item $item + * @return void */ public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/logger/adapter/Syslog.php b/src/Phalcon/Logger/Adapter/Syslog.php similarity index 85% rename from src/Phalcon/logger/adapter/Syslog.php rename to src/Phalcon/Logger/Adapter/Syslog.php index 382cf89e..9aa24131 100644 --- a/src/Phalcon/logger/adapter/Syslog.php +++ b/src/Phalcon/Logger/Adapter/Syslog.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Adapter; /** @@ -32,7 +39,7 @@ class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter * * @var string */ - protected $defaultFormatter = 'Syslog'; + protected $defaultFormatter = 'Line'; /** * @var int @@ -78,6 +85,7 @@ public function close(): bool * Processes the message i.e. writes it to the syslog * * @param \Phalcon\Logger\Item $item + * @return void */ public function process(\Phalcon\Logger\Item $item) { @@ -92,4 +100,5 @@ public function process(\Phalcon\Logger\Item $item) private function logLevelToSyslog(string $level): int { } + } diff --git a/src/Phalcon/logger/AdapterFactory.php b/src/Phalcon/Logger/AdapterFactory.php similarity index 78% rename from src/Phalcon/logger/AdapterFactory.php rename to src/Phalcon/Logger/AdapterFactory.php index 690af95f..c6cc1b36 100644 --- a/src/Phalcon/logger/AdapterFactory.php +++ b/src/Phalcon/Logger/AdapterFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger; use Phalcon\Factory\AbstractFactory; @@ -31,7 +38,7 @@ public function __construct(array $services = array()) * @param string $name * @param string $fileName * @param array $options - * @return \Phalcon\Logger\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, string $fileName, array $options = array()): AdapterInterface { @@ -43,4 +50,5 @@ public function newInstance(string $name, string $fileName, array $options = arr protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Logger/Exception.php b/src/Phalcon/Logger/Exception.php new file mode 100644 index 00000000..81003e63 --- /dev/null +++ b/src/Phalcon/Logger/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Logger; + +/** + * Phalcon\Logger\Exception + * + * Exceptions thrown in Phalcon\Logger will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/logger/formatter/AbstractFormatter.php b/src/Phalcon/Logger/Formatter/AbstractFormatter.php similarity index 64% rename from src/Phalcon/logger/formatter/AbstractFormatter.php rename to src/Phalcon/Logger/Formatter/AbstractFormatter.php index 5b00a527..e2fb16c2 100644 --- a/src/Phalcon/logger/formatter/AbstractFormatter.php +++ b/src/Phalcon/Logger/Formatter/AbstractFormatter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Formatter; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface +abstract class AbstractFormatter implements Phalcon\Logger\Formatter\FormatterInterface { /** @@ -23,4 +30,5 @@ abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterI public function interpolate(string $message, $context = null) { } + } diff --git a/src/Phalcon/logger/formatter/FormatterInterface.php b/src/Phalcon/Logger/Formatter/FormatterInterface.php similarity index 62% rename from src/Phalcon/logger/formatter/FormatterInterface.php rename to src/Phalcon/Logger/Formatter/FormatterInterface.php index bf4239f3..47332298 100644 --- a/src/Phalcon/logger/formatter/FormatterInterface.php +++ b/src/Phalcon/Logger/Formatter/FormatterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Formatter; /** @@ -17,4 +24,5 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); + } diff --git a/src/Phalcon/logger/formatter/Json.php b/src/Phalcon/Logger/Formatter/Json.php similarity index 76% rename from src/Phalcon/logger/formatter/Json.php rename to src/Phalcon/Logger/Formatter/Json.php index 18029e00..b5eaad88 100644 --- a/src/Phalcon/logger/formatter/Json.php +++ b/src/Phalcon/Logger/Formatter/Json.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Formatter; /** @@ -7,7 +14,7 @@ * * Formats messages using JSON encoding */ -class Json extends AbstractFormatter +class Json extends \Phalcon\Logger\Formatter\AbstractFormatter { /** * Default date format @@ -53,4 +60,5 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/logger/formatter/Line.php b/src/Phalcon/Logger/Formatter/Line.php similarity index 86% rename from src/Phalcon/logger/formatter/Line.php rename to src/Phalcon/Logger/Formatter/Line.php index 9f516272..2dc2d324 100644 --- a/src/Phalcon/logger/formatter/Line.php +++ b/src/Phalcon/Logger/Formatter/Line.php @@ -1,9 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger\Formatter; -use Phalcon\Logger\Formatter\Formatter; - /** * Phalcon\Logger\Formatter\Line * @@ -81,4 +86,5 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/logger/Item.php b/src/Phalcon/Logger/Item.php similarity index 82% rename from src/Phalcon/logger/Item.php rename to src/Phalcon/Logger/Item.php index 0b66a8ff..9b1b4d4f 100644 --- a/src/Phalcon/logger/Item.php +++ b/src/Phalcon/Logger/Item.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger; /** @@ -41,6 +48,7 @@ class Item protected $type; + public function getContext() { } @@ -66,7 +74,7 @@ public function getName(): string /** * Log timestamp * - * @return integer + * @return mixed */ public function getTime() { @@ -75,7 +83,7 @@ public function getTime() /** * Log type * - * @return integer + * @return mixed */ public function getType() { @@ -93,4 +101,5 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } + } diff --git a/src/Phalcon/logger/LoggerFactory.php b/src/Phalcon/Logger/LoggerFactory.php similarity index 57% rename from src/Phalcon/logger/LoggerFactory.php rename to src/Phalcon/Logger/LoggerFactory.php index 99c61357..c050fdec 100644 --- a/src/Phalcon/logger/LoggerFactory.php +++ b/src/Phalcon/Logger/LoggerFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Logger; use Phalcon\Logger; @@ -18,9 +25,9 @@ class LoggerFactory /** - * @param \Phalcon\Logger\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Logger\AdapterFactory $factory) + public function __construct(AdapterFactory $factory) { } @@ -28,9 +35,9 @@ public function __construct(\Phalcon\Logger\AdapterFactory $factory) * Factory to create an instace from a Config object * * @param mixed $config - * @return mixed + * @return Logger */ - public function load($config) + public function load($config): Logger { } @@ -38,11 +45,12 @@ public function load($config) * Returns a Logger object * * @param string $name - * @param array $adapters + * @param array $adapters * * @return Logger */ public function newInstance(string $name, array $adapters = array()): Logger { } + } diff --git a/src/Phalcon/Messages/Exception.php b/src/Phalcon/Messages/Exception.php new file mode 100644 index 00000000..763aced5 --- /dev/null +++ b/src/Phalcon/Messages/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Messages; + +/** + * Phalcon\Validation\Exception + * + * Exceptions thrown in Phalcon\Messages\ classes will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/messages/Message.php b/src/Phalcon/Messages/Message.php similarity index 83% rename from src/Phalcon/messages/Message.php rename to src/Phalcon/Messages/Message.php index 7f1ac8b6..77a55f6a 100644 --- a/src/Phalcon/messages/Message.php +++ b/src/Phalcon/Messages/Message.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Messages; /** @@ -7,7 +14,7 @@ * * Stores a message from various components */ -class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable +class Message implements Phalcon\Messages\MessageInterface, \JsonSerializable { /** * @var int @@ -105,7 +112,7 @@ public function jsonSerialize(): array * Sets code for the message * * @param int $code - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function setCode(int $code): MessageInterface { @@ -115,7 +122,7 @@ public function setCode(int $code): MessageInterface * Sets field name related to message * * @param mixed $field - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function setField($field): MessageInterface { @@ -125,7 +132,7 @@ public function setField($field): MessageInterface * Sets verbose message * * @param string $message - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function setMessage(string $message): MessageInterface { @@ -135,7 +142,7 @@ public function setMessage(string $message): MessageInterface * Sets message metadata * * @param array $metaData - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function setMetaData(array $metaData): MessageInterface { @@ -145,9 +152,10 @@ public function setMetaData(array $metaData): MessageInterface * Sets message type * * @param string $type - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function setType(string $type): MessageInterface { } + } diff --git a/src/Phalcon/messages/MessageInterface.php b/src/Phalcon/Messages/MessageInterface.php similarity index 88% rename from src/Phalcon/messages/MessageInterface.php rename to src/Phalcon/Messages/MessageInterface.php index 4eb1cdba..14a99d06 100644 --- a/src/Phalcon/messages/MessageInterface.php +++ b/src/Phalcon/Messages/MessageInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Messages; /** @@ -91,4 +98,5 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; + } diff --git a/src/Phalcon/messages/Messages.php b/src/Phalcon/Messages/Messages.php similarity index 88% rename from src/Phalcon/messages/Messages.php rename to src/Phalcon/Messages/Messages.php index 230bc5af..736ec4e1 100644 --- a/src/Phalcon/messages/Messages.php +++ b/src/Phalcon/Messages/Messages.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Messages; /** @@ -36,9 +43,9 @@ public function __construct(array $messages = array()) * ); * ``` * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message) + public function appendMessage(MessageInterface $message) { } @@ -69,7 +76,7 @@ public function count(): int /** * Returns the current message in the iterator * - * @return \Phalcon\Messages\MessageInterface + * @return MessageInterface */ public function current(): MessageInterface { @@ -111,6 +118,8 @@ public function key(): int /** * Moves the internal iteration pointer to the next position + * + * @return void */ public function next() { @@ -157,6 +166,7 @@ public function offsetGet($index) * * @param \Phalcon\Messages\Message $message * @param mixed $index + * @return void */ public function offsetSet($index, $message) { @@ -170,6 +180,7 @@ public function offsetSet($index, $message) * ``` * * @param mixed $index + * @return void */ public function offsetUnset($index) { @@ -177,6 +188,8 @@ public function offsetUnset($index) /** * Rewinds the internal iterator + * + * @return void */ public function rewind() { @@ -190,4 +203,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/mvc/Application.php b/src/Phalcon/Mvc/Application.php similarity index 90% rename from src/Phalcon/mvc/Application.php rename to src/Phalcon/Mvc/Application.php index a0bb0045..44449753 100644 --- a/src/Phalcon/mvc/Application.php +++ b/src/Phalcon/Mvc/Application.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Application\AbstractApplication; @@ -66,7 +73,7 @@ class Application extends AbstractApplication * Handles a MVC request * * @param string $uri - * @return bool|\Phalcon\Http\ResponseInterface + * @return mixed */ public function handle(string $uri) { @@ -102,4 +109,5 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } + } diff --git a/src/Phalcon/Mvc/Application/Exception.php b/src/Phalcon/Mvc/Application/Exception.php new file mode 100644 index 00000000..fc30b094 --- /dev/null +++ b/src/Phalcon/Mvc/Application/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\Application; + +/** + * Phalcon\Mvc\Application\Exception + * + * Exceptions thrown in Phalcon\Mvc\Application class will use this class + */ +class Exception extends \Phalcon\Application\Exception +{ + +} diff --git a/src/Phalcon/mvc/Controller.php b/src/Phalcon/Mvc/Controller.php similarity index 78% rename from src/Phalcon/mvc/Controller.php rename to src/Phalcon/Mvc/Controller.php index bf38986f..1e83c775 100644 --- a/src/Phalcon/mvc/Controller.php +++ b/src/Phalcon/Mvc/Controller.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Di\Injectable; @@ -44,7 +51,7 @@ * } * ``` */ -abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerInterface +abstract class Controller extends Injectable implements Phalcon\Mvc\ControllerInterface { /** @@ -53,4 +60,5 @@ abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerI final public function __construct() { } + } diff --git a/src/Phalcon/mvc/controller/BindModelInterface.php b/src/Phalcon/Mvc/Controller/BindModelInterface.php similarity index 59% rename from src/Phalcon/mvc/controller/BindModelInterface.php rename to src/Phalcon/Mvc/Controller/BindModelInterface.php index 7df463ff..1d8c0bfb 100644 --- a/src/Phalcon/mvc/controller/BindModelInterface.php +++ b/src/Phalcon/Mvc/Controller/BindModelInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Controller; /** @@ -16,4 +23,5 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; + } diff --git a/src/Phalcon/Mvc/ControllerInterface.php b/src/Phalcon/Mvc/ControllerInterface.php new file mode 100644 index 00000000..92854264 --- /dev/null +++ b/src/Phalcon/Mvc/ControllerInterface.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc; + +/** + * Phalcon\Mvc\ControllerInterface + * + * Interface for controller handlers + */ +interface ControllerInterface +{ + +} diff --git a/src/Phalcon/mvc/Dispatcher.php b/src/Phalcon/Mvc/Dispatcher.php similarity index 92% rename from src/Phalcon/mvc/Dispatcher.php rename to src/Phalcon/Mvc/Dispatcher.php index 3d851dec..ebe7dff7 100644 --- a/src/Phalcon/mvc/Dispatcher.php +++ b/src/Phalcon/Mvc/Dispatcher.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; /** @@ -22,7 +29,7 @@ * $controller = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements Phalcon\Mvc\DispatcherInterface { protected $defaultAction = 'index'; @@ -92,6 +99,7 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal * ``` * * @param array $forward + * @return void */ public function forward(array $forward) { @@ -100,7 +108,7 @@ public function forward(array $forward) /** * Returns the active controller in the dispatcher * - * @return \Phalcon\Mvc\ControllerInterface + * @return ControllerInterface */ public function getActiveController(): ControllerInterface { @@ -128,7 +136,7 @@ public function getControllerName(): string /** * Returns the latest dispatched controller * - * @return \Phalcon\Mvc\ControllerInterface + * @return ControllerInterface */ public function getLastController(): ControllerInterface { @@ -206,4 +214,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/Mvc/Dispatcher/Exception.php b/src/Phalcon/Mvc/Dispatcher/Exception.php new file mode 100644 index 00000000..413795b2 --- /dev/null +++ b/src/Phalcon/Mvc/Dispatcher/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\Dispatcher; + +/** + * Phalcon\Mvc\Dispatcher\Exception + * + * Exceptions thrown in Phalcon\Mvc\Dispatcher will use this class + */ +class Exception extends \Phalcon\Dispatcher\Exception +{ + +} diff --git a/src/Phalcon/mvc/DispatcherInterface.php b/src/Phalcon/Mvc/DispatcherInterface.php similarity index 70% rename from src/Phalcon/mvc/DispatcherInterface.php rename to src/Phalcon/Mvc/DispatcherInterface.php index 61c4366e..4d239253 100644 --- a/src/Phalcon/mvc/DispatcherInterface.php +++ b/src/Phalcon/Mvc/DispatcherInterface.php @@ -1,19 +1,28 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; +use Phalcon\Dispatcher\DispatcherInterface as DispatcherInterfaceBase; + /** * Phalcon\Mvc\DispatcherInterface * * Interface for Phalcon\Mvc\Dispatcher */ -interface DispatcherInterface extends \Phalcon\Dispatcher\DispatcherInterface +interface DispatcherInterface extends DispatcherInterfaceBase { /** * Returns the active controller in the dispatcher * - * @return \Phalcon\Mvc\ControllerInterface + * @return ControllerInterface */ public function getActiveController(): ControllerInterface; @@ -27,7 +36,7 @@ public function getControllerName(): string; /** * Returns the latest dispatched controller * - * @return \Phalcon\Mvc\ControllerInterface + * @return ControllerInterface */ public function getLastController(): ControllerInterface; @@ -51,4 +60,5 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); + } diff --git a/src/Phalcon/mvc/EntityInterface.php b/src/Phalcon/Mvc/EntityInterface.php similarity index 70% rename from src/Phalcon/mvc/EntityInterface.php rename to src/Phalcon/Mvc/EntityInterface.php index 1d14a5df..b530459d 100644 --- a/src/Phalcon/mvc/EntityInterface.php +++ b/src/Phalcon/Mvc/EntityInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; /** @@ -25,4 +32,5 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); + } diff --git a/src/Phalcon/mvc/Micro.php b/src/Phalcon/Mvc/Micro.php similarity index 93% rename from src/Phalcon/mvc/Micro.php rename to src/Phalcon/Mvc/Micro.php index fe66be93..bc87bbdb 100644 --- a/src/Phalcon/mvc/Micro.php +++ b/src/Phalcon/Mvc/Micro.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Di\Injectable; @@ -121,7 +128,7 @@ public function before($handler): Micro * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function delete(string $routePattern, $handler): RouteInterface { @@ -153,7 +160,7 @@ public function finish($handler): Micro * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function get(string $routePattern, $handler): RouteInterface { @@ -180,7 +187,7 @@ public function getBoundModels(): array /** * Returns the internal event manager * - * @return null|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface { @@ -190,6 +197,7 @@ public function getEventsManager(): ?ManagerInterface * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -207,7 +215,7 @@ public function getHandlers(): array /** * Gets model binder * - * @return null|\Phalcon\Mvc\Model\BinderInterface + * @return mixed */ public function getModelBinder(): ?BinderInterface { @@ -234,8 +242,8 @@ public function getRouter(): RouterInterface /** * Obtains a service from the DI * - * @param string $serviceName * @return object + * @param string $serviceName */ public function getService(string $serviceName) { @@ -244,8 +252,8 @@ public function getService(string $serviceName) /** * Obtains a shared service from the DI * - * @param string $serviceName * @return mixed + * @param string $serviceName */ public function getSharedService(string $serviceName) { @@ -276,7 +284,7 @@ public function hasService(string $serviceName): bool * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function head(string $routePattern, $handler): RouteInterface { @@ -287,7 +295,7 @@ public function head(string $routePattern, $handler): RouteInterface * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function map(string $routePattern, $handler): RouteInterface { @@ -352,6 +360,7 @@ public function offsetGet($alias) * * @param mixed $alias * @param mixed $definition + * @return void */ public function offsetSet($alias, $definition) { @@ -362,6 +371,7 @@ public function offsetSet($alias, $definition) * syntax * * @param mixed $alias + * @return void */ public function offsetUnset($alias) { @@ -372,7 +382,7 @@ public function offsetUnset($alias) * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function options(string $routePattern, $handler): RouteInterface { @@ -383,7 +393,7 @@ public function options(string $routePattern, $handler): RouteInterface * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function patch(string $routePattern, $handler): RouteInterface { @@ -394,7 +404,7 @@ public function patch(string $routePattern, $handler): RouteInterface * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function post(string $routePattern, $handler): RouteInterface { @@ -405,7 +415,7 @@ public function post(string $routePattern, $handler): RouteInterface * * @param callable $handler * @param string $routePattern - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function put(string $routePattern, $handler): RouteInterface { @@ -424,6 +434,7 @@ public function setActiveHandler($activeHandler) * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -466,7 +477,7 @@ public function setResponseHandler($handler): Micro * @param string $serviceName * @param mixed $definition * @param bool $shared - * @return \Phalcon\Di\ServiceInterface + * @return ServiceInterface */ public function setService(string $serviceName, $definition, bool $shared = false): ServiceInterface { @@ -479,4 +490,5 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } + } diff --git a/src/Phalcon/mvc/micro/Collection.php b/src/Phalcon/Mvc/Micro/Collection.php similarity index 94% rename from src/Phalcon/mvc/micro/Collection.php rename to src/Phalcon/Mvc/Micro/Collection.php index ff9801d6..701453be 100644 --- a/src/Phalcon/mvc/micro/Collection.php +++ b/src/Phalcon/Mvc/Micro/Collection.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Micro; /** @@ -21,7 +28,7 @@ * $app->mount($collection); * ``` */ -class Collection implements \Phalcon\Mvc\Micro\CollectionInterface +class Collection implements Phalcon\Mvc\Micro\CollectionInterface { protected $handler; @@ -233,4 +240,5 @@ public function setPrefix(string $prefix): CollectionInterface protected function addMap($method, string $routePattern, $handler, string $name) { } + } diff --git a/src/Phalcon/mvc/micro/CollectionInterface.php b/src/Phalcon/Mvc/Micro/CollectionInterface.php similarity index 94% rename from src/Phalcon/mvc/micro/CollectionInterface.php rename to src/Phalcon/Mvc/Micro/CollectionInterface.php index 878f6c72..6b685496 100644 --- a/src/Phalcon/mvc/micro/CollectionInterface.php +++ b/src/Phalcon/Mvc/Micro/CollectionInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Micro; /** @@ -142,4 +149,5 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; + } diff --git a/src/Phalcon/Mvc/Micro/Exception.php b/src/Phalcon/Mvc/Micro/Exception.php new file mode 100644 index 00000000..4c2e82e0 --- /dev/null +++ b/src/Phalcon/Mvc/Micro/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\Micro; + +/** + * Exceptions thrown in Phalcon\Mvc\Micro will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/mvc/micro/LazyLoader.php b/src/Phalcon/Mvc/Micro/LazyLoader.php similarity index 76% rename from src/Phalcon/mvc/micro/LazyLoader.php rename to src/Phalcon/Mvc/Micro/LazyLoader.php index ab704b4f..5e2dd112 100644 --- a/src/Phalcon/mvc/micro/LazyLoader.php +++ b/src/Phalcon/Mvc/Micro/LazyLoader.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Micro; /** @@ -16,6 +23,7 @@ class LazyLoader protected $definition; + public function getDefinition() { } @@ -33,11 +41,12 @@ public function __construct(string $definition) * Calling __call method * * @param array $arguments + * @return mixed * @param string $method * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder - * @return mixed */ public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) { } + } diff --git a/src/Phalcon/mvc/micro/MiddlewareInterface.php b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php similarity index 56% rename from src/Phalcon/mvc/micro/MiddlewareInterface.php rename to src/Phalcon/Mvc/Micro/MiddlewareInterface.php index e3fe446c..ce5155e2 100644 --- a/src/Phalcon/mvc/micro/MiddlewareInterface.php +++ b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Micro; /** @@ -14,4 +21,5 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); + } diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/Mvc/Model.php similarity index 94% rename from src/Phalcon/mvc/Model.php rename to src/Phalcon/Mvc/Model.php index 130ed03a..5b6f598a 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/Mvc/Model.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\ManagerInterface as EventsManagerInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\ManagerInterface; use Phalcon\Mvc\Model\MetaDataInterface; @@ -48,7 +56,7 @@ * } * ``` */ -abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable +abstract class Model extends AbstractInjectionAware implements Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable { const DIRTY_STATE_DETACHED = 2; @@ -117,6 +125,7 @@ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\Enti protected $uniqueTypes; + public function getTransaction() { } @@ -135,10 +144,10 @@ final public function __construct($data = null, \Phalcon\Di\DiInterface $contain /** * Handles method calls when a method is not implemented * - * @param string $method - * @param array $arguments * @return mixed * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist + * @param string $method + * @param array $arguments */ public function __call(string $method, array $arguments) { @@ -147,10 +156,10 @@ public function __call(string $method, array $arguments) /** * Handles method calls when a static method is not implemented * - * @param string $method - * @param array $arguments * @return mixed * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist + * @param string $method + * @param array $arguments */ public static function __callStatic(string $method, array $arguments) { @@ -160,8 +169,8 @@ public static function __callStatic(string $method, array $arguments) * Magic method to get related records using the relation alias as a * property * - * @param string $property * @return mixed + * @param string $property */ public function __get(string $property) { @@ -213,6 +222,7 @@ public function __set(string $property, $value) * ``` * * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @return void */ public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) { @@ -241,7 +251,7 @@ public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) * ``` * * @param \Phalcon\Messages\MessageInterface $message - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface { @@ -294,7 +304,7 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Mode * @param array $dataColumnMap array to transform keys of data to another * @param array $whiteList * @param array $data - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function assign(array $data, $whiteList = null, $dataColumnMap = null): ModelInterface { @@ -349,7 +359,7 @@ public static function average($parameters = null): float * @param \Phalcon\Mvc\ModelInterface $base * @param array $data * @param int $dirtyState - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $data, int $dirtyState = 0): ModelInterface { @@ -374,7 +384,7 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * @param array $data * @param int $dirtyState * @param bool $keepSnapshots - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface { @@ -384,9 +394,9 @@ public static function cloneResultMap($base, array $data, $columnMap, int $dirty * Returns an hydrated result based on the data and the column map * * @param array $columnMap + * @return mixed * @param array $data * @param int $hydrationMode - * @return mixed */ public static function cloneResultMapHydrate(array $data, $columnMap, int $hydrationMode) { @@ -646,7 +656,7 @@ public function dump(): array * ``` * * @param mixed $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ public static function find($parameters = null): ResultsetInterface { @@ -719,7 +729,7 @@ public static function find($parameters = null): ResultsetInterface * ``` * * @param string|array $parameters - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public static function findFirst($parameters = null) { @@ -780,7 +790,7 @@ public function getDirtyState(): int /** * Returns the custom events manager * - * @return \Phalcon\Events\ManagerInterface + * @return EventsManagerInterface */ public function getEventsManager(): EventsManagerInterface { @@ -810,7 +820,7 @@ public function getEventsManager(): EventsManagerInterface * ``` * * @param mixed $filter - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages($filter = null): array { @@ -819,7 +829,7 @@ public function getMessages($filter = null): array /** * Returns the models manager related to the entity instance * - * @return \Phalcon\Mvc\Model\ManagerInterface + * @return ManagerInterface */ public function getModelsManager(): ManagerInterface { @@ -828,7 +838,7 @@ public function getModelsManager(): ManagerInterface /** * {@inheritdoc} * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @return MetaDataInterface */ public function getModelsMetaData(): MetaDataInterface { @@ -856,7 +866,7 @@ public function getOldSnapshotData(): array /** * Gets the connection used to read data for the model * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ final public function getReadConnection(): AdapterInterface { @@ -876,8 +886,8 @@ final public function getReadConnectionService(): string * Returns related records based on defined relations * * @param array $arguments - * @param string $alias * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param string $alias */ public function getRelated(string $alias, $arguments = null) { @@ -962,7 +972,7 @@ public function getUpdatedFields(): array /** * Gets the connection used to write data to the model * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ final public function getWriteConnection(): AdapterInterface { @@ -1108,7 +1118,7 @@ public static function minimum($parameters = null) * Create a criteria for a specific model * * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface { @@ -1131,7 +1141,7 @@ public function readAttribute(string $attribute) /** * Refreshes the model attributes re-querying the record from the database * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function refresh(): ModelInterface { @@ -1188,6 +1198,7 @@ public function unserialize($data) * Sets the DependencyInjection connection service name * * @param string $connectionService + * @return void */ final public function setConnectionService(string $connectionService) { @@ -1197,7 +1208,7 @@ final public function setConnectionService(string $connectionService) * Sets the dirty state of the object using one of the DIRTY_STATE_ constants * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function setDirtyState(int $dirtyState) { @@ -1216,6 +1227,7 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager * Sets the DependencyInjection connection service name used to read data * * @param string $connectionService + * @return void */ final public function setReadConnectionService(string $connectionService) { @@ -1240,6 +1252,7 @@ public function setOldSnapshotData(array $data, $columnMap = null) * * @param array $columnMap * @param array $data + * @return void */ public function setSnapshotData(array $data, $columnMap = null) { @@ -1285,7 +1298,7 @@ public function setSnapshotData(array $data, $columnMap = null) * ``` * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface { @@ -1295,6 +1308,7 @@ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transact * Enables/disables options in the ORM * * @param array $options + * @return void */ public static function setup(array $options) { @@ -1304,6 +1318,7 @@ public static function setup(array $options) * Sets the DependencyInjection connection service name used to write data * * @param string $connectionService + * @return void */ final public function setWriteConnectionService(string $connectionService) { @@ -1313,6 +1328,7 @@ final public function setWriteConnectionService(string $connectionService) * Skips the current operation forcing a success state * * @param bool $skip + * @return void */ public function skipOperation(bool $skip) { @@ -1395,6 +1411,7 @@ public function update(): bool * * @param string $attribute * @param mixed $value + * @return void */ public function writeAttribute(string $attribute, $value) { @@ -1486,7 +1503,7 @@ protected function _getRelatedRecords(string $modelName, string $method, array $ * @param array $parameters * @param string $functionName * @param string $alias - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ protected static function _groupResult(string $functionName, string $alias, $parameters): ResultsetInterface { @@ -1495,11 +1512,11 @@ protected static function _groupResult(string $functionName, string $alias, $par /** * Try to check if the query must invoke a finder * + * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool * @param string $method * @param array $arguments - * @return \Phalcon\Mvc\ModelInterface[]|\Phalcon\Mvc\ModelInterface|bool */ - final protected static function _invokeFinder(string $method, array $arguments) + protected final static function _invokeFinder(string $method, array $arguments) { } @@ -1553,7 +1570,7 @@ protected function _postSave(bool $success, bool $exists): bool /** * Save the related records assigned in the has-one/has-many relations * - * @param Phalcon\Mvc\ModelInterface[] related + * @param Phalcon\Mvc\ModelInterface[] related * @param \Phalcon\Db\Adapter\AdapterInterface $connection * @param mixed $related * @param Phalcon\Mvc\ModelInterface [] related @@ -1582,6 +1599,7 @@ protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface * ``` * * @param array $attributes + * @return void */ protected function allowEmptyStringValues(array $attributes) { @@ -1615,7 +1633,7 @@ protected function _cancelOperation() * @param string $referenceModel * @param mixed $referencedFields * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @return Relation */ protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation { @@ -1626,7 +1644,7 @@ protected function belongsTo($fields, string $referenceModel, $referencedFields, * * @param mixed $params * @param mixed $limit - * @return \Phalcon\Mvc\Model\Query + * @return Query */ private static function getPreparedQuery($params, $limit = null): Query { @@ -1653,7 +1671,7 @@ private static function getPreparedQuery($params, $limit = null): Query * @param string $referenceModel * @param mixed $referencedFields * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @return Relation */ protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation { @@ -1688,7 +1706,7 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * @param array $options * @param string $intermediateModel * @param string $referenceModel - * @return \Phalcon\Mvc\Model\Relation + * @return Relation */ protected function hasManyToMany($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation { @@ -1715,12 +1733,47 @@ protected function hasManyToMany($fields, string $intermediateModel, $intermedia * @param string $referenceModel * @param mixed $referencedFields * @param mixed $options - * @return \Phalcon\Mvc\Model\Relation + * @return Relation */ protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation { } + /** + * Setup a 1-1 relation between two models, through an intermediate + * relation + * + * ```php + * class Robots extends \Phalcon\Mvc\Model + * { + * public function initialize() + * { + * // Setup a 1-1 relation to one item from Parts through RobotsParts + * $this->hasOneThrough( + * "id", + * RobotsParts::class, + * "robots_id", + * "parts_id", + * Parts::class, + * "id", + * ); + * } + * } + * ``` + * + * @param string|array $fields + * @param string|array $intermediateFields + * @param string|array $intermediateReferencedFields + * @param string|array $referencedFields + * @param array $options + * @param string $intermediateModel + * @param string $referenceModel + * @return Relation + */ + protected function hasOneThrough($fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referenceModel, $referencedFields, $options = null): Relation + { + } + /** * Sets if the model must keep the original record snapshot in memory * @@ -1737,6 +1790,7 @@ protected function hasOne($fields, string $referenceModel, $referencedFields, $o * ``` * * @param bool $keepSnapshot + * @return void */ protected function keepSnapshots(bool $keepSnapshot) { @@ -1746,7 +1800,7 @@ protected function keepSnapshots(bool $keepSnapshot) * Sets schema name where the mapped table is located * * @param string $schema - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ final protected function setSchema(string $schema): ModelInterface { @@ -1756,7 +1810,7 @@ final protected function setSchema(string $schema): ModelInterface * Sets the table name to which model should be mapped * * @param string $source - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ final protected function setSource(string $source): ModelInterface { @@ -1805,6 +1859,7 @@ protected function skipAttributes(array $attributes) * ``` * * @param array $attributes + * @return void */ protected function skipAttributesOnCreate(array $attributes) { @@ -1829,6 +1884,7 @@ protected function skipAttributesOnCreate(array $attributes) * ``` * * @param array $attributes + * @return void */ protected function skipAttributesOnUpdate(array $attributes) { @@ -1850,6 +1906,7 @@ protected function skipAttributesOnUpdate(array $attributes) * ``` * * @param bool $dynamicUpdate + * @return void */ protected function useDynamicUpdate(bool $dynamicUpdate) { @@ -1940,4 +1997,5 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } + } diff --git a/src/Phalcon/mvc/model/Behavior.php b/src/Phalcon/Mvc/Model/Behavior.php similarity index 82% rename from src/Phalcon/mvc/model/Behavior.php rename to src/Phalcon/Mvc/Model/Behavior.php index a22c6289..c0c481ba 100644 --- a/src/Phalcon/mvc/model/Behavior.php +++ b/src/Phalcon/Mvc/Model/Behavior.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -7,7 +14,7 @@ * * This is an optional base class for ORM behaviors */ -abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface +abstract class Behavior implements Phalcon\Mvc\Model\BehaviorInterface { /** * @var array @@ -27,8 +34,8 @@ public function __construct(array $options = array()) /** * Returns the behavior options related to an event * - * @param string $eventName * @return array + * @param string $eventName */ protected function getOptions(string $eventName = null) { @@ -64,4 +71,5 @@ protected function mustTakeAction(string $eventName): bool public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/mvc/model/behavior/SoftDelete.php b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php similarity index 69% rename from src/Phalcon/mvc/model/behavior/SoftDelete.php rename to src/Phalcon/Mvc/Model/Behavior/SoftDelete.php index 53c93099..2e7edce9 100644 --- a/src/Phalcon/mvc/model/behavior/SoftDelete.php +++ b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Behavior; use Phalcon\Mvc\Model\Behavior; @@ -22,4 +29,5 @@ class SoftDelete extends Behavior public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/mvc/model/behavior/Timestampable.php b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php similarity index 73% rename from src/Phalcon/mvc/model/behavior/Timestampable.php rename to src/Phalcon/Mvc/Model/Behavior/Timestampable.php index e6eb4f72..eb844d40 100644 --- a/src/Phalcon/mvc/model/behavior/Timestampable.php +++ b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Behavior; use Phalcon\Mvc\Model\Behavior; @@ -29,4 +36,5 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } + } diff --git a/src/Phalcon/mvc/model/BehaviorInterface.php b/src/Phalcon/Mvc/Model/BehaviorInterface.php similarity index 75% rename from src/Phalcon/mvc/model/BehaviorInterface.php rename to src/Phalcon/Mvc/Model/BehaviorInterface.php index a6a61047..7b22c889 100644 --- a/src/Phalcon/mvc/model/BehaviorInterface.php +++ b/src/Phalcon/Mvc/Model/BehaviorInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -26,4 +33,5 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); + } diff --git a/src/Phalcon/mvc/model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php similarity index 89% rename from src/Phalcon/mvc/model/Binder.php rename to src/Phalcon/Mvc/Model/Binder.php index 243ee36a..2b0a64b5 100644 --- a/src/Phalcon/mvc/model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Cache\Adapter\AdapterInterface; @@ -9,7 +16,7 @@ * * This is an class for binding models into params for handler */ -class Binder implements \Phalcon\Mvc\Model\BinderInterface +class Binder implements Phalcon\Mvc\Model\BinderInterface { /** * Array for storing active bound models @@ -86,7 +93,7 @@ protected function findBoundModel($paramValue, string $className): bool /** * Sets cache instance * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return AdapterInterface */ public function getCache(): AdapterInterface { @@ -124,4 +131,5 @@ protected function getParamsFromReflection($handler, array $params, string $cach public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface { } + } diff --git a/src/Phalcon/mvc/model/binder/BindableInterface.php b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php similarity index 60% rename from src/Phalcon/mvc/model/binder/BindableInterface.php rename to src/Phalcon/Mvc/Model/Binder/BindableInterface.php index d0b643e6..f8d4bafb 100644 --- a/src/Phalcon/mvc/model/binder/BindableInterface.php +++ b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Binder; /** @@ -17,4 +24,5 @@ interface BindableInterface * @return string|array */ public function getModelName(); + } diff --git a/src/Phalcon/mvc/model/BinderInterface.php b/src/Phalcon/Mvc/Model/BinderInterface.php similarity index 79% rename from src/Phalcon/mvc/model/BinderInterface.php rename to src/Phalcon/Mvc/Model/BinderInterface.php index 8ce5d24a..29a7e408 100644 --- a/src/Phalcon/mvc/model/BinderInterface.php +++ b/src/Phalcon/Mvc/Model/BinderInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Cache\Adapter\AdapterInterface; @@ -33,7 +40,7 @@ public function getBoundModels(): array; /** * Gets cache instance * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return AdapterInterface */ public function getCache(): AdapterInterface; @@ -44,4 +51,5 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; + } diff --git a/src/Phalcon/mvc/model/Criteria.php b/src/Phalcon/Mvc/Model/Criteria.php similarity index 87% rename from src/Phalcon/mvc/model/Criteria.php rename to src/Phalcon/Mvc/Model/Criteria.php index 0eebabeb..2086b85a 100644 --- a/src/Phalcon/mvc/model/Criteria.php +++ b/src/Phalcon/Mvc/Model/Criteria.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Di\DiInterface; @@ -22,7 +29,7 @@ * ->execute(); * ``` */ -class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface +class Criteria implements Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; @@ -44,6 +51,7 @@ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\Inje * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -52,7 +60,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -62,7 +70,7 @@ public function getDI(): DiInterface * Set a model on which the query will be executed * * @param string $modelName - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function setModelName(string $modelName): CriteriaInterface { @@ -83,7 +91,7 @@ public function getModelName(): string * * @param array $bindParams * @param bool $merge - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function bind(array $bindParams, bool $merge = false): CriteriaInterface { @@ -94,7 +102,7 @@ public function bind(array $bindParams, bool $merge = false): CriteriaInterface * This method replaces all previously set bound parameters * * @param array $bindTypes - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function bindTypes(array $bindTypes): CriteriaInterface { @@ -104,7 +112,7 @@ public function bindTypes(array $bindTypes): CriteriaInterface * Sets SELECT DISTINCT / SELECT ALL flag * * @param mixed $distinct - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function distinct($distinct): CriteriaInterface { @@ -123,7 +131,7 @@ public function distinct($distinct): CriteriaInterface * ``` * * @param string|array $columns - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function columns($columns): CriteriaInterface { @@ -160,7 +168,7 @@ public function columns($columns): CriteriaInterface * @param mixed $conditions * @param mixed $alias * @param mixed $type - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function join(string $model, $conditions = null, $alias = null, $type = null): CriteriaInterface { @@ -189,7 +197,7 @@ public function join(string $model, $conditions = null, $alias = null, $type = n * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function innerJoin(string $model, $conditions = null, $alias = null): CriteriaInterface { @@ -209,7 +217,7 @@ public function innerJoin(string $model, $conditions = null, $alias = null): Cri * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function leftJoin(string $model, $conditions = null, $alias = null): CriteriaInterface { @@ -229,7 +237,7 @@ public function leftJoin(string $model, $conditions = null, $alias = null): Crit * @param string $model * @param mixed $conditions * @param mixed $alias - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function rightJoin(string $model, $conditions = null, $alias = null): CriteriaInterface { @@ -241,7 +249,7 @@ public function rightJoin(string $model, $conditions = null, $alias = null): Cri * @param string $conditions * @param mixed $bindParams * @param mixed $bindTypes - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function where(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface { @@ -253,7 +261,7 @@ public function where(string $conditions, $bindParams = null, $bindTypes = null) * @param string $conditions * @param mixed $bindParams * @param mixed $bindTypes - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function andWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface { @@ -265,7 +273,7 @@ public function andWhere(string $conditions, $bindParams = null, $bindTypes = nu * @param string $conditions * @param mixed $bindParams * @param mixed $bindTypes - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function orWhere(string $conditions, $bindParams = null, $bindTypes = null): CriteriaInterface { @@ -281,7 +289,7 @@ public function orWhere(string $conditions, $bindParams = null, $bindTypes = nul * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterface { @@ -297,7 +305,7 @@ public function betweenWhere(string $expr, $minimum, $maximum): CriteriaInterfac * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInterface { @@ -312,7 +320,7 @@ public function notBetweenWhere(string $expr, $minimum, $maximum): CriteriaInter * * @param string $expr * @param array $values - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function inWhere(string $expr, array $values): CriteriaInterface { @@ -327,7 +335,7 @@ public function inWhere(string $expr, array $values): CriteriaInterface * * @param string $expr * @param array $values - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function notInWhere(string $expr, array $values): CriteriaInterface { @@ -337,7 +345,7 @@ public function notInWhere(string $expr, array $values): CriteriaInterface * Adds the conditions parameter to the criteria * * @param string $conditions - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function conditions(string $conditions): CriteriaInterface { @@ -347,7 +355,7 @@ public function conditions(string $conditions): CriteriaInterface * Adds the order-by clause to the criteria * * @param string $orderColumns - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function orderBy(string $orderColumns): CriteriaInterface { @@ -357,7 +365,7 @@ public function orderBy(string $orderColumns): CriteriaInterface * Adds the group-by clause to the criteria * * @param mixed $group - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function groupBy($group): CriteriaInterface { @@ -367,7 +375,7 @@ public function groupBy($group): CriteriaInterface * Adds the having clause to the criteria * * @param mixed $having - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function having($having): CriteriaInterface { @@ -384,7 +392,7 @@ public function having($having): CriteriaInterface * * @param int $limit * @param int $offset - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function limit(int $limit, int $offset = 0): CriteriaInterface { @@ -394,7 +402,7 @@ public function limit(int $limit, int $offset = 0): CriteriaInterface * Adds the "for_update" parameter to the criteria * * @param bool $forUpdate - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function forUpdate(bool $forUpdate = true): CriteriaInterface { @@ -404,7 +412,7 @@ public function forUpdate(bool $forUpdate = true): CriteriaInterface * Adds the "shared_lock" parameter to the criteria * * @param bool $sharedLock - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function sharedLock(bool $sharedLock = true): CriteriaInterface { @@ -415,7 +423,7 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface * This method replaces all previously set cache options * * @param array $cache - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public function cache(array $cache): CriteriaInterface { @@ -498,7 +506,7 @@ public function getParams(): array * @param string $modelName * @param array $data * @param string $operator - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface { @@ -514,7 +522,7 @@ public static function fromInput(\Phalcon\Di\DiInterface $container, string $mod * ->createBuilder(); * ``` * - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function createBuilder(): BuilderInterface { @@ -523,9 +531,10 @@ public function createBuilder(): BuilderInterface /** * Executes a find using the parameters built with the criteria * - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ public function execute(): ResultsetInterface { } + } diff --git a/src/Phalcon/mvc/model/CriteriaInterface.php b/src/Phalcon/Mvc/Model/CriteriaInterface.php similarity index 97% rename from src/Phalcon/mvc/model/CriteriaInterface.php rename to src/Phalcon/Mvc/Model/CriteriaInterface.php index 09adbbdb..e515c29b 100644 --- a/src/Phalcon/mvc/model/CriteriaInterface.php +++ b/src/Phalcon/Mvc/Model/CriteriaInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -322,4 +329,5 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; + } diff --git a/src/Phalcon/Mvc/Model/Exception.php b/src/Phalcon/Mvc/Model/Exception.php new file mode 100644 index 00000000..376877b4 --- /dev/null +++ b/src/Phalcon/Mvc/Model/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\Model; + +/** + * Phalcon\Mvc\Model\Exception + * + * Exceptions thrown in Phalcon\Mvc\Model\ classes will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/mvc/model/Manager.php b/src/Phalcon/Mvc/Model/Manager.php similarity index 87% rename from src/Phalcon/mvc/model/Manager.php rename to src/Phalcon/Mvc/Model/Manager.php index 99d4af9e..1355dbc5 100644 --- a/src/Phalcon/mvc/model/Manager.php +++ b/src/Phalcon/Mvc/Model/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; @@ -97,6 +104,16 @@ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\Inject */ protected $hasOneSingle = array(); + /** + * Has one through relations + */ + protected $hasOneThrough = array(); + + /** + * Has one through relations by model + */ + protected $hasOneThroughSingle = array(); + /** * Mark initialized models */ @@ -143,6 +160,7 @@ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\Inject * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -151,7 +169,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -161,6 +179,7 @@ public function getDI(): DiInterface * Sets a global events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -169,7 +188,7 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return EventsManagerInterface */ public function getEventsManager(): EventsManagerInterface { @@ -180,6 +199,7 @@ public function getEventsManager(): EventsManagerInterface * * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) { @@ -189,7 +209,7 @@ public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phal * Returns a custom events manager related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return bool|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) { @@ -218,7 +238,7 @@ public function isInitialized(string $className): bool /** * Get last initialized model * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getLastInitialized(): ModelInterface { @@ -228,7 +248,7 @@ public function getLastInitialized(): ModelInterface * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function load(string $modelName): ModelInterface { @@ -257,6 +277,7 @@ public function load(string $modelName): ModelInterface * ``` * * @param string $prefix + * @return void */ public function setModelPrefix(string $prefix) { @@ -276,6 +297,7 @@ public function getModelPrefix(): string * * @param \Phalcon\Mvc\ModelInterface $model * @param string $source + * @return void */ public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) { @@ -314,6 +336,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string * * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema + * @return void */ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) { @@ -334,6 +357,7 @@ public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string * * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService + * @return void */ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) { @@ -344,6 +368,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService + * @return void */ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) { @@ -354,6 +379,7 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService + * @return void */ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) { @@ -363,7 +389,7 @@ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, str * Returns the connection to read data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface { @@ -373,7 +399,7 @@ public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterIn * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface { @@ -384,7 +410,7 @@ public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterI * * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $connectionServices - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface { @@ -452,6 +478,7 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventN * * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @return void */ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior) { @@ -462,6 +489,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots + * @return void */ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) { @@ -482,6 +510,7 @@ public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool * * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate + * @return void */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) { @@ -505,12 +534,29 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } + /** + * Setups a relation 1-1 between two models using an intermediate model + * + * @param string $fields + * @param string $intermediateFields + * @param string $intermediateReferencedFields + * @param string $referencedFields + * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $intermediateModel + * @param string $referencedModel + * @return RelationInterface + */ + public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface + { + } + /** * Setup a relation reverse many to one between two models * @@ -519,7 +565,7 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { @@ -533,7 +579,7 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string * @param \Phalcon\Mvc\ModelInterface $model * @param mixed $fields * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { @@ -550,7 +596,7 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ * @param \Phalcon\Mvc\ModelInterface $model * @param string $intermediateModel * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface { @@ -589,6 +635,17 @@ public function existsHasOne(string $modelName, string $modelRelation): bool { } + /** + * Checks whether a model has a hasOneThrough relation with another model + * + * @param string $modelName + * @param string $modelRelation + * @return bool + */ + public function existsHasOneThrough(string $modelName, string $modelRelation): bool + { + } + /** * Checks whether a model has a hasManyToMany relation with another model * @@ -605,7 +662,7 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b * * @param string $modelName * @param string $alias - * @return bool|\Phalcon\Mvc\Model\RelationInterface + * @return mixed */ public function getRelationByAlias(string $modelName, string $alias) { @@ -625,13 +682,13 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a /** * Helper method to query records based on a relation definition * - * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false + * @param RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + public function getRelationRecords(RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { } @@ -651,6 +708,7 @@ public function getReusableRecords(string $modelName, string $key) * @param string $modelName * @param string $key * @param mixed $records + * @return void */ public function setReusableRecords(string $modelName, string $key, $records) { @@ -658,6 +716,8 @@ public function setReusableRecords(string $modelName, string $key, $records) /** * Clears the internal reusable list + * + * @return void */ public function clearReusableObjects() { @@ -671,7 +731,7 @@ public function clearReusableObjects() * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|\Phalcon\Mvc\Model\ResultsetInterface + * @return mixed */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -685,7 +745,7 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|\Phalcon\Mvc\Model\ResultsetInterface + * @return mixed */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -699,7 +759,7 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) { @@ -715,7 +775,7 @@ public function getHasOneRecords(string $modelName, string $modelRelation, \Phal * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array { @@ -725,7 +785,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array * Gets hasMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -741,11 +801,21 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array { } + /** + * Gets hasOneThrough relations defined on a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return array + */ + public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array + { + } + /** * Gets hasManyToMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -755,7 +825,7 @@ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -765,7 +835,7 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array * Query all the relationships defined on a model * * @param string $modelName - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getRelations(string $modelName): array { @@ -776,7 +846,7 @@ public function getRelations(string $modelName): array * * @param string $first * @param string $second - * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] + * @return array|bool */ public function getRelationsBetween(string $first, string $second) { @@ -786,7 +856,7 @@ public function getRelationsBetween(string $first, string $second) * Creates a Phalcon\Mvc\Model\Query without execute it * * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function createQuery(string $phql): QueryInterface { @@ -798,7 +868,7 @@ public function createQuery(string $phql): QueryInterface * @param string $phql * @param mixed $placeholders * @param mixed $types - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function executeQuery(string $phql, $placeholders = null, $types = null): QueryInterface { @@ -808,7 +878,7 @@ public function executeQuery(string $phql, $placeholders = null, $types = null): * Creates a Phalcon\Mvc\Model\Query\Builder * * @param mixed $params - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function createBuilder($params = null): BuilderInterface { @@ -817,7 +887,7 @@ public function createBuilder($params = null): BuilderInterface /** * Returns the last query created or executed in the models manager * - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function getLastQuery(): QueryInterface { @@ -829,4 +899,5 @@ public function getLastQuery(): QueryInterface public function __destruct() { } + } diff --git a/src/Phalcon/mvc/model/ManagerInterface.php b/src/Phalcon/Mvc/Model/ManagerInterface.php similarity index 80% rename from src/Phalcon/mvc/model/ManagerInterface.php rename to src/Phalcon/Mvc/Model/ManagerInterface.php index 04b666e8..a3a8195d 100644 --- a/src/Phalcon/mvc/model/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/ManagerInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; @@ -18,9 +25,10 @@ interface ManagerInterface * Binds a behavior to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @param BehaviorInterface $behavior + * @return void */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior); + public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior); /** * Setup a relation reverse 1-1 between two models @@ -30,7 +38,7 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Mod * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -42,7 +50,7 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -54,10 +62,25 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ * @param array $options * @param \Phalcon\Mvc\ModelInterface $model * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + /** + * Setups a 1-1 relation between two models using an intermediate table + * + * @param string $fields + * @param string $intermediateFields + * @param string $intermediateReferencedFields + * @param string $referencedFields + * @param array $options + * @param \Phalcon\Mvc\ModelInterface $model + * @param string $intermediateModel + * @param string $referencedModel + * @return RelationInterface + */ + public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + /** * Setups a relation n-m between two models * @@ -69,7 +92,7 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r * @param \Phalcon\Mvc\ModelInterface $model * @param string $intermediateModel * @param string $referencedModel - * @return \Phalcon\Mvc\Model\RelationInterface + * @return RelationInterface */ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; @@ -77,7 +100,7 @@ public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, st * Creates a Phalcon\Mvc\Model\Query\Builder * * @param string $params - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function createBuilder($params = null): BuilderInterface; @@ -85,7 +108,7 @@ public function createBuilder($params = null): BuilderInterface; * Creates a Phalcon\Mvc\Model\Query without execute it * * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function createQuery(string $phql): QueryInterface; @@ -94,7 +117,7 @@ public function createQuery(string $phql): QueryInterface; * * @param array $placeholders * @param string $phql - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function executeQuery(string $phql, $placeholders = null): QueryInterface; @@ -125,6 +148,15 @@ public function existsHasMany(string $modelName, string $modelRelation): bool; */ public function existsHasOne(string $modelName, string $modelRelation): bool; + /** + * Checks whether a model has a hasOneThrough relation with another model + * + * @param string $modelName + * @param string $modelRelation + * @return bool + */ + public function existsHasOneThrough(string $modelName, string $modelRelation): bool; + /** * Checks whether a model has a hasManyToMany relation with another model * @@ -138,19 +170,19 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b * Gets belongsTo relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets belongsTo related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method - * @return bool|ResultsetInterface + * @param ModelInterface $record + * @param string|null $method + * @return mixed */ public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -158,19 +190,19 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * Gets hasMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** * Gets hasMany related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method - * @return bool|ResultsetInterface + * @param ModelInterface $record + * @param string|null $method + * @return mixed */ public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); @@ -178,7 +210,7 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * Gets hasManyToMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; @@ -186,41 +218,49 @@ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; + /** + * Gets hasOneThrough relations defined on a model + * + * @param \Phalcon\Mvc\ModelInterface $model + * @return array + */ + public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array; + /** * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; /** - * Gets belongsTo related records from a model + * Gets hasOne related records from a model * - * @param string $modelName - * @param string $modelRelation + * @param string $modelName + * @param string $modelRelation * @param array|string|null $parameters - * @param ModelInterface $record - * @param string|null $method - * @return bool|\Phalcon\Mvc\ModelInterface + * @param ModelInterface $record + * @param string|null $method + * @return mixed */ public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** * Get last initialized model * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getLastInitialized(): ModelInterface; /** * Returns the last query created or executed in the models manager * - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function getLastQuery(): QueryInterface; @@ -244,7 +284,7 @@ public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string; * Returns the connection to read data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; @@ -261,26 +301,26 @@ public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): st * * @param string $modelName * @param string $alias - * @return bool|Relation + * @return mixed */ public function getRelationByAlias(string $modelName, string $alias); /** * Helper method to query records based on a relation definition * - * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false + * @param RelationInterface $relation * @param \Phalcon\Mvc\ModelInterface $record * @param mixed $parameters * @param string $method - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(\Phalcon\Mvc\Model\RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getRelationRecords(RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); /** * Query all the relationships defined on a model * * @param string $modelName - * @return array|\Phalcon\Mvc\Model\RelationInterface[] + * @return array */ public function getRelations(string $modelName): array; @@ -289,7 +329,7 @@ public function getRelations(string $modelName): array; * * @param string $first * @param string $second - * @return array|bool|\Phalcon\Mvc\Model\RelationInterface[] + * @return array|bool */ public function getRelationsBetween(string $first, string $second); @@ -297,7 +337,7 @@ public function getRelationsBetween(string $first, string $second); * Returns the connection to write data related to a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; @@ -313,7 +353,7 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): s * Loads a model throwing an exception if it doesn't exist * * @param string $modelName - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function load(string $modelName): ModelInterface; @@ -369,6 +409,7 @@ public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, strin * * @param \Phalcon\Mvc\ModelInterface $model * @param bool $keepSnapshots + * @return void */ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); @@ -378,9 +419,9 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * meaning that a least one is implemented * * @param array $data + * @return bool * @param \Phalcon\Mvc\ModelInterface $model * @param string $eventName - * @return bool */ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); @@ -398,6 +439,7 @@ public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $mode * * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService + * @return void */ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); @@ -406,6 +448,7 @@ public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string * * @param \Phalcon\Mvc\ModelInterface $model * @param string $connectionService + * @return void */ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); @@ -414,6 +457,7 @@ public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, str * * @param \Phalcon\Mvc\ModelInterface $model * @param string $schema + * @return void */ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); @@ -422,6 +466,7 @@ public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schem * * @param \Phalcon\Mvc\ModelInterface $model * @param string $source + * @return void */ public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); @@ -438,6 +483,8 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * * @param \Phalcon\Mvc\ModelInterface $model * @param bool $dynamicUpdate + * @return void */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); + } diff --git a/src/Phalcon/mvc/model/MetaData.php b/src/Phalcon/Mvc/Model/MetaData.php similarity index 95% rename from src/Phalcon/mvc/model/MetaData.php rename to src/Phalcon/Mvc/Model/MetaData.php index 60d9f426..aa796a3a 100644 --- a/src/Phalcon/mvc/model/MetaData.php +++ b/src/Phalcon/Mvc/Model/MetaData.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; +use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; use Phalcon\Di\DiInterface; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; @@ -25,7 +33,7 @@ * print_r($attributes); * ``` */ -abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface +abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, Phalcon\Mvc\Model\MetaDataInterface { const MODELS_ATTRIBUTES = 0; @@ -240,7 +248,7 @@ public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -276,9 +284,9 @@ public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): ar * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return string|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string { } @@ -357,7 +365,7 @@ public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array /** * Return the strategy to obtain the meta-data * - * @return \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface + * @return StrategyInterface */ public function getStrategy(): StrategyInterface { @@ -488,6 +496,8 @@ final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int * ```php * $metaData->reset(); * ``` + * + * @return void */ public function reset() { @@ -507,6 +517,7 @@ public function reset() * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes + * @return void */ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) { @@ -526,6 +537,7 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes + * @return void */ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) { @@ -545,6 +557,7 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes + * @return void */ public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) { @@ -554,6 +567,7 @@ public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, arr * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -563,6 +577,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) * Set the meta-data extraction strategy * * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy + * @return void */ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy) { @@ -573,6 +588,7 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * * @param string $key * @param array $data + * @return void */ public function write(string $key, array $data) { @@ -596,6 +612,7 @@ public function write(string $key, array $data) * @param \Phalcon\Mvc\ModelInterface $model * @param int $index * @param mixed $data + * @return void */ final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) { @@ -617,8 +634,10 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t * Throws an exception when the metadata cannot be written * * @param mixed $option + * @return void */ private function throwWriteException($option) { } + } diff --git a/src/Phalcon/mvc/model/metadata/Apcu.php b/src/Phalcon/Mvc/Model/MetaData/Apcu.php similarity index 78% rename from src/Phalcon/mvc/model/metadata/Apcu.php rename to src/Phalcon/Mvc/Model/MetaData/Apcu.php index 612da494..21a020d1 100644 --- a/src/Phalcon/mvc/model/metadata/Apcu.php +++ b/src/Phalcon/Mvc/Model/MetaData/Apcu.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; @@ -34,4 +41,5 @@ class Apcu extends MetaData public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) { } + } diff --git a/src/Phalcon/mvc/model/metadata/Libmemcached.php b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php similarity index 73% rename from src/Phalcon/mvc/model/metadata/Libmemcached.php rename to src/Phalcon/Mvc/Model/MetaData/Libmemcached.php index fcd40dc2..4abe8316 100644 --- a/src/Phalcon/mvc/model/metadata/Libmemcached.php +++ b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; @@ -26,8 +33,11 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio /** * Flush Memcache data and resets internal meta-data in order to regenerate it + * + * @return void */ public function reset() { } + } diff --git a/src/Phalcon/mvc/model/metadata/Memory.php b/src/Phalcon/Mvc/Model/MetaData/Memory.php similarity index 75% rename from src/Phalcon/mvc/model/metadata/Memory.php rename to src/Phalcon/Mvc/Model/MetaData/Memory.php index 456302dd..41ce9a31 100644 --- a/src/Phalcon/mvc/model/metadata/Memory.php +++ b/src/Phalcon/Mvc/Model/MetaData/Memory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; @@ -36,8 +43,10 @@ public function read(string $key): ?array * * @param string $key * @param array $data + * @return void */ public function write(string $key, array $data) { } + } diff --git a/src/Phalcon/mvc/model/metadata/Redis.php b/src/Phalcon/Mvc/Model/MetaData/Redis.php similarity index 78% rename from src/Phalcon/mvc/model/metadata/Redis.php rename to src/Phalcon/Mvc/Model/MetaData/Redis.php index 0a72aa37..9a2a5bc4 100644 --- a/src/Phalcon/mvc/model/metadata/Redis.php +++ b/src/Phalcon/Mvc/Model/MetaData/Redis.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; @@ -40,8 +47,11 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio /** * Flush Redis data and resets internal meta-data in order to regenerate it + * + * @return void */ public function reset() { } + } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php similarity index 59% rename from src/Phalcon/mvc/model/metadata/strategy/Introspection.php rename to src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php index d1974e36..d464e641 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Introspection.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php @@ -1,13 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData\Strategy; /** - * Phalcon\Mvc\Model\MetaData\Strategy\Introspection + * This file is part of the Phalcon Framework. * - * Queries the table meta-data in order to introspect the model's metadata + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. */ -class Introspection implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +class Annotations implements Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface { /** @@ -31,4 +41,5 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } + } diff --git a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php similarity index 78% rename from src/Phalcon/mvc/model/metadata/strategy/Annotations.php rename to src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php index 8b941252..d8f7e480 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/Annotations.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php @@ -1,16 +1,20 @@ * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Annotations implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +namespace Phalcon\Mvc\Model\MetaData\Strategy; + +/** + * Phalcon\Mvc\Model\MetaData\Strategy\Introspection + * + * Queries the table meta-data in order to introspect the model's metadata + */ +class Introspection implements Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface { /** @@ -34,4 +38,5 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } + } diff --git a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php similarity index 81% rename from src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php rename to src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php index 57a22db3..43cf3173 100644 --- a/src/Phalcon/mvc/model/metadata/strategy/StrategyInterface.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData\Strategy; /** @@ -16,10 +23,10 @@ interface StrategyInterface /** * Read the model's column map, this can't be inferred * + * @todo Not implemented * @param \Phalcon\Mvc\ModelInterface $model * @param \Phalcon\Di\DiInterface $container * @return array - * @todo Not implemented */ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; @@ -31,4 +38,5 @@ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\Di * @return array */ public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; + } diff --git a/src/Phalcon/mvc/model/metadata/Stream.php b/src/Phalcon/Mvc/Model/MetaData/Stream.php similarity index 80% rename from src/Phalcon/mvc/model/metadata/Stream.php rename to src/Phalcon/Mvc/Model/MetaData/Stream.php index 97092b45..eaa23474 100644 --- a/src/Phalcon/mvc/model/metadata/Stream.php +++ b/src/Phalcon/Mvc/Model/MetaData/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; @@ -47,6 +54,7 @@ public function read(string $key): ?array * * @param string $key * @param array $data + * @return void */ public function write(string $key, array $data) { @@ -56,8 +64,10 @@ public function write(string $key, array $data) * Throws an exception when the metadata cannot be written * * @param mixed $option + * @return void */ private function throwWriteException($option) { } + } diff --git a/src/Phalcon/mvc/model/MetaDataInterface.php b/src/Phalcon/Mvc/Model/MetaDataInterface.php similarity index 95% rename from src/Phalcon/mvc/model/MetaDataInterface.php rename to src/Phalcon/Mvc/Model/MetaDataInterface.php index 3818ede4..50c44024 100644 --- a/src/Phalcon/mvc/model/MetaDataInterface.php +++ b/src/Phalcon/Mvc/Model/MetaDataInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; @@ -88,9 +95,9 @@ public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): ar * Returns the name of identity field (if one is present) * * @param \Phalcon\Mvc\ModelInterface $model - * @return string + * @return string|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string; + public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string; /** * Returns an array of fields which are not part of the primary key @@ -127,7 +134,7 @@ public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; /** * Return the strategy to obtain the meta-data * - * @return \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface + * @return StrategyInterface */ public function getStrategy(): StrategyInterface; @@ -214,6 +221,7 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * * @param \Phalcon\Mvc\ModelInterface $model * @param array $attributes + * @return void */ public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); @@ -238,6 +246,8 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * * @param string $key * @param array $data + * @return void */ public function write(string $key, array $data); + } diff --git a/src/Phalcon/mvc/model/Query.php b/src/Phalcon/Mvc/Model/Query.php similarity index 88% rename from src/Phalcon/mvc/model/Query.php rename to src/Phalcon/Mvc/Model/Query.php index bb8ffd26..e64d4188 100644 --- a/src/Phalcon/mvc/model/Query.php +++ b/src/Phalcon/Mvc/Model/Query.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; @@ -57,7 +64,7 @@ * $resultWithOutEntries = $queryWithTransaction->execute(); * ``` */ -class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface +class Query implements Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { const TYPE_DELETE = 303; @@ -138,7 +145,7 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA protected $uniqueRow; - protected static $_irPhqlCache; + static protected $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -175,6 +182,7 @@ public function __construct(string $phql = null, \Phalcon\Di\DiInterface $contai * Sets the dependency injection container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -183,7 +191,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) /** * Returns the dependency injection container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -194,7 +202,7 @@ public function getDI(): DiInterface * returned * * @param bool $uniqueRow - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface { @@ -276,22 +284,22 @@ final protected function _getSelectColumn(array $column): array /** * Resolves a table in a SELECT statement checking if the model exists * - * @param \Phalcon\Mvc\Model\ManagerInterface $manager - * @param array $qualifiedName * @return string + * @param ManagerInterface $manager + * @param array $qualifiedName */ - final protected function _getTable(\Phalcon\Mvc\Model\ManagerInterface $manager, array $qualifiedName) + final protected function _getTable(ManagerInterface $manager, array $qualifiedName) { } /** * Resolves a JOIN clause checking if the associated models exist * - * @param \Phalcon\Mvc\Model\ManagerInterface $manager + * @param ManagerInterface $manager * @param array $join * @return array */ - final protected function _getJoin(\Phalcon\Mvc\Model\ManagerInterface $manager, array $join): array + final protected function _getJoin(ManagerInterface $manager, array $join): array { } @@ -312,10 +320,10 @@ final protected function _getJoinType(array $join): string * @param string $joinType * @param string $modelAlias * @param string $joinAlias - * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @param RelationInterface $relation * @return array */ - final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array + final protected function _getSingleJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array { } @@ -326,10 +334,10 @@ final protected function _getSingleJoin(string $joinType, $joinSource, string $m * @param string $joinType * @param string $modelAlias * @param string $joinAlias - * @param \Phalcon\Mvc\Model\RelationInterface $relation + * @param RelationInterface $relation * @return array */ - final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, \Phalcon\Mvc\Model\RelationInterface $relation): array + final protected function _getMultiJoin(string $joinType, $joinSource, string $modelAlias, string $joinAlias, RelationInterface $relation): array { } @@ -429,7 +437,7 @@ public function parse(): array /** * Returns the current cache backend instance * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getCache(): AdapterInterface { @@ -443,7 +451,7 @@ public function getCache(): AdapterInterface * @param array $bindParams * @param array $bindTypes * @param bool $simulate - * @return array|\Phalcon\Mvc\Model\ResultsetInterface + * @return mixed */ final protected function _executeSelect(array $intermediate, array $bindParams, array $bindTypes, bool $simulate = false) { @@ -456,7 +464,7 @@ final protected function _executeSelect(array $intermediate, array $bindParams, * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\StatusInterface + * @return StatusInterface */ final protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { @@ -469,7 +477,7 @@ final protected function _executeInsert(array $intermediate, array $bindParams, * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\StatusInterface + * @return StatusInterface */ final protected function _executeUpdate(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { @@ -482,7 +490,7 @@ final protected function _executeUpdate(array $intermediate, array $bindParams, * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\StatusInterface + * @return StatusInterface */ final protected function _executeDelete(array $intermediate, array $bindParams, array $bindTypes): StatusInterface { @@ -495,7 +503,7 @@ final protected function _executeDelete(array $intermediate, array $bindParams, * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface { @@ -504,9 +512,9 @@ final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, /** * Executes a parsed PHQL statement * + * @return mixed * @param array $bindParams * @param array $bindTypes - * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()) { @@ -517,7 +525,7 @@ public function execute(array $bindParams = array(), array $bindTypes = array()) * * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface { @@ -527,7 +535,7 @@ public function getSingleResult(array $bindParams = array(), array $bindTypes = * Sets the type of PHQL statement to be executed * * @param int $type - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setType(int $type): QueryInterface { @@ -547,7 +555,7 @@ public function getType(): int * * @param array $bindParams * @param bool $merge - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setBindParams(array $bindParams, bool $merge = false): QueryInterface { @@ -567,7 +575,7 @@ public function getBindParams(): array * * @param array $bindTypes * @param bool $merge - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterface { @@ -577,7 +585,7 @@ public function setBindTypes(array $bindTypes, bool $merge = false): QueryInterf * Set SHARED LOCK clause * * @param bool $sharedLock - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setSharedLock(bool $sharedLock = false): QueryInterface { @@ -596,7 +604,7 @@ public function getBindTypes(): array * Allows to set the IR to be executed * * @param array $intermediate - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function setIntermediate(array $intermediate): QueryInterface { @@ -615,7 +623,7 @@ public function getIntermediate(): array * Sets the cache parameters of the query * * @param array $cacheOptions - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function cache(array $cacheOptions): QueryInterface { @@ -642,6 +650,8 @@ public function getSql(): array /** * Destroys the internal PHQL cache + * + * @return void */ public static function clean() { @@ -655,7 +665,7 @@ public static function clean() * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface { @@ -669,7 +679,7 @@ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $ * @param array $intermediate * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface { @@ -678,10 +688,11 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array /** * allows to wrap a transaction around all queries * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction - * @return \Phalcon\Mvc\Model\QueryInterface + * @param TransactionInterface $transaction + * @return QueryInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): QueryInterface + public function setTransaction(TransactionInterface $transaction): QueryInterface { } + } diff --git a/src/Phalcon/mvc/model/query/Builder.php b/src/Phalcon/Mvc/Model/Query/Builder.php similarity index 90% rename from src/Phalcon/mvc/model/query/Builder.php rename to src/Phalcon/Mvc/Model/Query/Builder.php index 6fec223c..d6f93cd8 100644 --- a/src/Phalcon/mvc/model/query/Builder.php +++ b/src/Phalcon/Mvc/Model/Query/Builder.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Query; use Phalcon\Di\DiInterface; @@ -41,7 +48,7 @@ * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); * ``` */ -class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface +class Builder implements Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; @@ -122,7 +129,7 @@ public function __construct($params = null, \Phalcon\Di\DiInterface $container = * * @param string $model * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function addFrom(string $model, string $alias = null): BuilderInterface { @@ -145,7 +152,7 @@ public function addFrom(string $model, string $alias = null): BuilderInterface * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function andHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -169,7 +176,7 @@ public function andHaving(string $conditions, array $bindParams = array(), array * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function andWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -196,7 +203,7 @@ final public function autoescape(string $identifier): string * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function betweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -213,7 +220,7 @@ public function betweenHaving(string $expr, $minimum, $maximum, string $operator * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function betweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -241,7 +248,7 @@ public function betweenWhere(string $expr, $minimum, $maximum, string $operator * ``` * * @param mixed $columns - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function columns($columns): BuilderInterface { @@ -256,7 +263,7 @@ public function columns($columns): BuilderInterface * ``` * * @param mixed $distinct - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function distinct($distinct): BuilderInterface { @@ -270,7 +277,7 @@ public function distinct($distinct): BuilderInterface * ``` * * @param bool $forUpdate - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function forUpdate(bool $forUpdate): BuilderInterface { @@ -300,7 +307,7 @@ public function forUpdate(bool $forUpdate): BuilderInterface * ``` * * @param mixed $models - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function from($models): BuilderInterface { @@ -336,7 +343,7 @@ public function getColumns() /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -435,7 +442,7 @@ final public function getPhql(): string /** * Returns the query built * - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function getQuery(): QueryInterface { @@ -462,7 +469,7 @@ public function getWhere() * ``` * * @param string|array $group - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function groupBy($group): BuilderInterface { @@ -485,7 +492,7 @@ public function groupBy($group): BuilderInterface * @param mixed $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function having($conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -501,7 +508,7 @@ public function having($conditions, array $bindParams = array(), array $bindType * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function inHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -533,7 +540,7 @@ public function inHaving(string $expr, array $values, string $operator = Builder * @param string $model * @param string $conditions * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function innerJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface { @@ -552,7 +559,7 @@ public function innerJoin(string $model, string $conditions = null, string $alia * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function inWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -593,7 +600,7 @@ public function inWhere(string $expr, array $values, string $operator = BuilderI * @param string $conditions * @param string $alias * @param string $type - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function join(string $model, string $conditions = null, string $alias = null, string $type = null): BuilderInterface { @@ -613,7 +620,7 @@ public function join(string $model, string $conditions = null, string $alias = n * @param string $model * @param string $conditions * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function leftJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface { @@ -630,7 +637,7 @@ public function leftJoin(string $model, string $conditions = null, string $alias * * @param int $limit * @param mixed $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function limit(int $limit, $offset = null): BuilderInterface { @@ -647,7 +654,7 @@ public function limit(int $limit, $offset = null): BuilderInterface * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function notBetweenHaving(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -664,7 +671,7 @@ public function notBetweenHaving(string $expr, $minimum, $maximum, string $opera * @param mixed $minimum * @param mixed $maximum * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function notBetweenWhere(string $expr, $minimum, $maximum, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -680,7 +687,7 @@ public function notBetweenWhere(string $expr, $minimum, $maximum, string $operat * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function notInHaving(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -696,7 +703,7 @@ public function notInHaving(string $expr, array $values, string $operator = Buil * @param string $expr * @param array $values * @param string $operator - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function notInWhere(string $expr, array $values, string $operator = BuilderInterface::OPERATOR_AND): BuilderInterface { @@ -710,7 +717,7 @@ public function notInWhere(string $expr, array $values, string $operator = Build * ``` * * @param int $offset - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function offset(int $offset): BuilderInterface { @@ -726,7 +733,7 @@ public function offset(int $offset): BuilderInterface * ``` * * @param string|array $orderBy - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function orderBy($orderBy): BuilderInterface { @@ -749,7 +756,7 @@ public function orderBy($orderBy): BuilderInterface * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function orHaving(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -773,7 +780,7 @@ public function orHaving(string $conditions, array $bindParams = array(), array * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function orWhere(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -793,7 +800,7 @@ public function orWhere(string $conditions, array $bindParams = array(), array $ * @param string $model * @param string $conditions * @param string $alias - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function rightJoin(string $model, string $conditions = null, string $alias = null): BuilderInterface { @@ -804,7 +811,7 @@ public function rightJoin(string $model, string $conditions = null, string $alia * * @param array $bindParams * @param bool $merge - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function setBindParams(array $bindParams, bool $merge = false): BuilderInterface { @@ -815,7 +822,7 @@ public function setBindParams(array $bindParams, bool $merge = false): BuilderIn * * @param array $bindTypes * @param bool $merge - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInterface { @@ -825,6 +832,7 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -850,7 +858,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) * @param string $conditions * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface { @@ -864,7 +872,7 @@ public function where(string $conditions, array $bindParams = array(), array $bi * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ protected function conditionBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface { @@ -877,7 +885,7 @@ protected function conditionBetween(string $clause, string $operator, string $ex * @param string $operator * @param string $expr * @param array $values - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ protected function conditionIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { @@ -891,7 +899,7 @@ protected function conditionIn(string $clause, string $operator, string $expr, a * @param string $expr * @param mixed $minimum * @param mixed $maximum - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ protected function conditionNotBetween(string $clause, string $operator, string $expr, $minimum, $maximum): BuilderInterface { @@ -904,9 +912,10 @@ protected function conditionNotBetween(string $clause, string $operator, string * @param string $operator * @param string $expr * @param array $values - * @return \Phalcon\Mvc\Model\Query\BuilderInterface + * @return BuilderInterface */ protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } + } diff --git a/src/Phalcon/mvc/model/query/BuilderInterface.php b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php similarity index 97% rename from src/Phalcon/mvc/model/query/BuilderInterface.php rename to src/Phalcon/Mvc/Model/Query/BuilderInterface.php index 1b77025f..5ecec31b 100644 --- a/src/Phalcon/mvc/model/query/BuilderInterface.php +++ b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Query; use Phalcon\Mvc\Model\QueryInterface; @@ -176,7 +183,7 @@ public function getPhql(): string; /** * Returns the query built * - * @return \Phalcon\Mvc\Model\QueryInterface + * @return QueryInterface */ public function getQuery(): QueryInterface; @@ -343,4 +350,5 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + } diff --git a/src/Phalcon/mvc/model/query/Lang.php b/src/Phalcon/Mvc/Model/Query/Lang.php similarity index 82% rename from src/Phalcon/mvc/model/query/Lang.php rename to src/Phalcon/Mvc/Model/Query/Lang.php index 4f574562..f87716d1 100644 --- a/src/Phalcon/mvc/model/query/Lang.php +++ b/src/Phalcon/Mvc/Model/Query/Lang.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Query; /** @@ -35,4 +42,5 @@ abstract class Lang public static function parsePHQL(string $phql): array { } + } diff --git a/src/Phalcon/mvc/model/query/Status.php b/src/Phalcon/Mvc/Model/Query/Status.php similarity index 81% rename from src/Phalcon/mvc/model/query/Status.php rename to src/Phalcon/Mvc/Model/Query/Status.php index 027decdf..bf3c8160 100644 --- a/src/Phalcon/mvc/model/query/Status.php +++ b/src/Phalcon/Mvc/Model/Query/Status.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Query; use Phalcon\Mvc\ModelInterface; @@ -31,7 +38,7 @@ * } * ``` */ -class Status implements \Phalcon\Mvc\Model\Query\StatusInterface +class Status implements Phalcon\Mvc\Model\Query\StatusInterface { protected $model; @@ -53,7 +60,7 @@ public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = /** * Returns the messages produced because of a failed operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages(): array { @@ -62,7 +69,7 @@ public function getMessages(): array /** * Returns the model that executed the action * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getModel(): ModelInterface { @@ -76,4 +83,5 @@ public function getModel(): ModelInterface public function success(): bool { } + } diff --git a/src/Phalcon/mvc/model/query/StatusInterface.php b/src/Phalcon/Mvc/Model/Query/StatusInterface.php similarity index 68% rename from src/Phalcon/mvc/model/query/StatusInterface.php rename to src/Phalcon/Mvc/Model/Query/StatusInterface.php index a333a915..dcfce38c 100644 --- a/src/Phalcon/mvc/model/query/StatusInterface.php +++ b/src/Phalcon/Mvc/Model/Query/StatusInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Query; use Phalcon\Mvc\ModelInterface; @@ -15,14 +22,14 @@ interface StatusInterface /** * Returns the messages produced by an operation failed * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages(): array; /** * Returns the model which executed the action * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getModel(): ModelInterface; @@ -32,4 +39,5 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; + } diff --git a/src/Phalcon/mvc/model/QueryInterface.php b/src/Phalcon/Mvc/Model/QueryInterface.php similarity index 91% rename from src/Phalcon/mvc/model/QueryInterface.php rename to src/Phalcon/Mvc/Model/QueryInterface.php index 83e2d6a6..d6dc6696 100644 --- a/src/Phalcon/mvc/model/QueryInterface.php +++ b/src/Phalcon/Mvc/Model/QueryInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; @@ -23,9 +30,9 @@ public function cache(array $cacheOptions): QueryInterface; /** * Executes a parsed PHQL statement * + * @return mixed * @param array $bindParams * @param array $bindTypes - * @return mixed */ public function execute(array $bindParams = array(), array $bindTypes = array()); @@ -62,7 +69,7 @@ public function getSql(): array; * * @param array $bindParams * @param array $bindTypes - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getSingleResult(array $bindParams = array(), array $bindTypes = array()): ModelInterface; @@ -114,4 +121,5 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; + } diff --git a/src/Phalcon/mvc/model/Relation.php b/src/Phalcon/Mvc/Model/Relation.php similarity index 92% rename from src/Phalcon/mvc/model/Relation.php rename to src/Phalcon/Mvc/Model/Relation.php index 655e4598..057f23ee 100644 --- a/src/Phalcon/mvc/model/Relation.php +++ b/src/Phalcon/Mvc/Model/Relation.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -7,7 +14,7 @@ * * This class represents a relationship between two models */ -class Relation implements \Phalcon\Mvc\Model\RelationInterface +class Relation implements Phalcon\Mvc\Model\RelationInterface { const ACTION_CASCADE = 2; @@ -208,4 +215,5 @@ public function isReusable(): bool public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } + } diff --git a/src/Phalcon/mvc/model/RelationInterface.php b/src/Phalcon/Mvc/Model/RelationInterface.php similarity index 91% rename from src/Phalcon/mvc/model/RelationInterface.php rename to src/Phalcon/Mvc/Model/RelationInterface.php index f8c565d0..724df960 100644 --- a/src/Phalcon/mvc/model/RelationInterface.php +++ b/src/Phalcon/Mvc/Model/RelationInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -117,4 +124,5 @@ public function isThrough(): bool; * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); + } diff --git a/src/Phalcon/mvc/model/ResultInterface.php b/src/Phalcon/Mvc/Model/ResultInterface.php similarity index 57% rename from src/Phalcon/mvc/model/ResultInterface.php rename to src/Phalcon/Mvc/Model/ResultInterface.php index 58bdb6d5..9d94b919 100644 --- a/src/Phalcon/mvc/model/ResultInterface.php +++ b/src/Phalcon/Mvc/Model/ResultInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -14,7 +21,8 @@ interface ResultInterface * Sets the object's state * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function setDirtyState(int $dirtyState); + } diff --git a/src/Phalcon/mvc/model/Resultset.php b/src/Phalcon/Mvc/Model/Resultset.php similarity index 89% rename from src/Phalcon/mvc/model/Resultset.php rename to src/Phalcon/Mvc/Model/Resultset.php index b4e6fbc3..e6af34ff 100644 --- a/src/Phalcon/mvc/model/Resultset.php +++ b/src/Phalcon/Mvc/Model/Resultset.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Cache\Adapter\AdapterInterface; @@ -46,7 +53,7 @@ * } * ``` */ -abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable +abstract class Resultset implements Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { const HYDRATE_ARRAYS = 1; @@ -139,7 +146,7 @@ public function delete(\Closure $conditionCallback = null): bool * ``` * * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] + * @return array */ public function filter($filter): array { @@ -148,7 +155,7 @@ public function filter($filter): array /** * Returns the associated cache for the resultset * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return AdapterInterface */ public function getCache(): AdapterInterface { @@ -157,7 +164,7 @@ public function getCache(): AdapterInterface /** * Get first row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function getFirst(): ?ModelInterface { @@ -175,7 +182,7 @@ public function getHydrateMode(): int /** * Get last row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function getLast(): ?ModelInterface { @@ -184,7 +191,7 @@ public function getLast(): ?ModelInterface /** * Returns the error messages produced by a batch operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages(): array { @@ -235,6 +242,8 @@ public function key(): ?int /** * Moves cursor to next row in the resultset + * + * @return void */ public function next() { @@ -244,7 +253,7 @@ public function next() * Gets row in a specific position of the resultset * * @param mixed $index - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function offsetGet($index) { @@ -265,6 +274,7 @@ public function offsetExists($index): bool * * @param int $index * @param \Phalcon\Mvc\ModelInterface $value + * @return void */ public function offsetSet($index, $value) { @@ -274,6 +284,7 @@ public function offsetSet($index, $value) * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param mixed $offset + * @return void */ public function offsetUnset($offset) { @@ -281,6 +292,8 @@ public function offsetUnset($offset) /** * Rewinds resultset to its beginning + * + * @return void */ final public function rewind() { @@ -291,6 +304,7 @@ final public function rewind() * Set the new position if required, and then set this->row * * @param mixed $position + * @return void */ final public function seek($position) { @@ -300,7 +314,7 @@ final public function seek($position) * Sets the hydration mode in the resultset * * @param int $hydrateMode - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ public function setHydrateMode(int $hydrateMode): ResultsetInterface { @@ -310,7 +324,7 @@ public function setHydrateMode(int $hydrateMode): ResultsetInterface * Set if the resultset is fresh or an old one cached * * @param bool $isFresh - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ public function setIsFresh(bool $isFresh): ResultsetInterface { @@ -335,4 +349,5 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } + } diff --git a/src/Phalcon/mvc/model/resultset/Complex.php b/src/Phalcon/Mvc/Model/Resultset/Complex.php similarity index 86% rename from src/Phalcon/mvc/model/resultset/Complex.php rename to src/Phalcon/Mvc/Model/Resultset/Complex.php index cc90a156..f888848f 100644 --- a/src/Phalcon/mvc/model/resultset/Complex.php +++ b/src/Phalcon/Mvc/Model/Resultset/Complex.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset; @@ -36,7 +43,7 @@ public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = /** * Returns current row in the resultset * - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ final public function current() { @@ -65,8 +72,10 @@ public function serialize(): string * Unserializing a resultset will allow to only works on the rows present in the saved state * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/mvc/model/resultset/Simple.php b/src/Phalcon/Mvc/Model/Resultset/Simple.php similarity index 87% rename from src/Phalcon/mvc/model/resultset/Simple.php rename to src/Phalcon/Mvc/Model/Resultset/Simple.php index 1cd3e083..9787164c 100644 --- a/src/Phalcon/mvc/model/resultset/Simple.php +++ b/src/Phalcon/Mvc/Model/Resultset/Simple.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset; @@ -41,7 +48,7 @@ public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\ /** * Returns current row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return mixed */ final public function current(): ?ModelInterface { @@ -74,8 +81,10 @@ public function serialize(): string * the saved state * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/mvc/model/ResultsetInterface.php b/src/Phalcon/Mvc/Model/ResultsetInterface.php similarity index 88% rename from src/Phalcon/mvc/model/ResultsetInterface.php rename to src/Phalcon/Mvc/Model/ResultsetInterface.php index f95ac27c..ca24b3f6 100644 --- a/src/Phalcon/mvc/model/ResultsetInterface.php +++ b/src/Phalcon/Mvc/Model/ResultsetInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Cache\Adapter\AdapterInterface; @@ -35,21 +42,21 @@ public function delete(\Closure $conditionCallback = null): bool; * ``` * * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] + * @return array */ public function filter($filter): array; /** * Returns the associated cache for the resultset * - * @return \Phalcon\Cache\Adapter\AdapterInterface + * @return AdapterInterface */ public function getCache(): AdapterInterface; /** * Get first row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function getFirst(): ?ModelInterface; @@ -63,14 +70,14 @@ public function getHydrateMode(): int; /** * Get last row in the resultset * - * @return null|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function getLast(): ?ModelInterface; /** * Returns the error messages produced by a batch operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages(): array; @@ -120,4 +127,5 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; + } diff --git a/src/Phalcon/mvc/model/Row.php b/src/Phalcon/Mvc/Model/Row.php similarity index 83% rename from src/Phalcon/mvc/model/Row.php rename to src/Phalcon/Mvc/Model/Row.php index 6c8eae16..f009d3b3 100644 --- a/src/Phalcon/mvc/model/Row.php +++ b/src/Phalcon/Mvc/Model/Row.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -8,7 +15,7 @@ * This component allows Phalcon\Mvc\Model to return rows without an associated entity. * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. */ -class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable +class Row implements \Phalcon\Mvc\EntityInterface, Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable { /** @@ -45,6 +52,7 @@ public function offsetExists($index): bool * * @param string|int $index * @param \Phalcon\Mvc\ModelInterface $value + * @return void */ public function offsetSet($index, $value) { @@ -54,6 +62,7 @@ public function offsetSet($index, $value) * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param string|int $offset + * @return void */ public function offsetUnset($offset) { @@ -66,8 +75,8 @@ public function offsetUnset($offset) * echo $robot->readAttribute("name"); * ``` * - * @param string $attribute * @return mixed + * @param string $attribute */ public function readAttribute(string $attribute) { @@ -77,7 +86,7 @@ public function readAttribute(string $attribute) * Set the current object's state * * @param int $dirtyState - * @return bool|\Phalcon\Mvc\ModelInterface + * @return mixed */ public function setDirtyState(int $dirtyState) { @@ -101,8 +110,10 @@ public function toArray(): array * * @param mixed $value * @param string $attribute + * @return void */ public function writeAttribute(string $attribute, $value) { } + } diff --git a/src/Phalcon/mvc/model/Transaction.php b/src/Phalcon/Mvc/Model/Transaction.php similarity index 92% rename from src/Phalcon/mvc/model/Transaction.php rename to src/Phalcon/Mvc/Model/Transaction.php index 4ab0dc7d..6ca304d2 100644 --- a/src/Phalcon/mvc/model/Transaction.php +++ b/src/Phalcon/Mvc/Model/Transaction.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -153,6 +160,7 @@ public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInter * Sets if is a reused transaction or new once * * @param bool $isNew + * @return void */ public function setIsNewTransaction(bool $isNew) { @@ -162,6 +170,7 @@ public function setIsNewTransaction(bool $isNew) * Sets flag to rollback on abort the HTTP connection * * @param bool $rollbackOnAbort + * @return void */ public function setRollbackOnAbort(bool $rollbackOnAbort) { @@ -171,6 +180,7 @@ public function setRollbackOnAbort(bool $rollbackOnAbort) * Sets object which generates rollback action * * @param \Phalcon\Mvc\ModelInterface $record + * @return void */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) { @@ -180,6 +190,7 @@ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) * Sets transaction manager related to the transaction * * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + * @return void */ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) { @@ -189,9 +200,10 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * Enables throwing exception * * @param bool $status - * @return \Phalcon\Mvc\Model\TransactionInterface + * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface { } + } diff --git a/src/Phalcon/mvc/model/transaction/Exception.php b/src/Phalcon/Mvc/Model/Transaction/Exception.php similarity index 50% rename from src/Phalcon/mvc/model/transaction/Exception.php rename to src/Phalcon/Mvc/Model/Transaction/Exception.php index 51ec8b7d..466a2b52 100644 --- a/src/Phalcon/mvc/model/transaction/Exception.php +++ b/src/Phalcon/Mvc/Model/Transaction/Exception.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Transaction; /** diff --git a/src/Phalcon/mvc/model/transaction/Failed.php b/src/Phalcon/Mvc/Model/Transaction/Failed.php similarity index 70% rename from src/Phalcon/mvc/model/transaction/Failed.php rename to src/Phalcon/Mvc/Model/Transaction/Failed.php index 21c32947..3c387526 100644 --- a/src/Phalcon/mvc/model/transaction/Failed.php +++ b/src/Phalcon/Mvc/Model/Transaction/Failed.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\ModelInterface; @@ -9,7 +16,7 @@ * * This class will be thrown to exit a try/catch block for isolated transactions */ -class Failed extends Exception +class Failed extends \Phalcon\Mvc\Model\Transaction\Exception { protected $record = null; @@ -28,7 +35,7 @@ public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record /** * Returns validation record messages which stop the transaction * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getRecord(): ModelInterface { @@ -37,9 +44,10 @@ public function getRecord(): ModelInterface /** * Returns validation record messages which stop the transaction * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getRecordMessages(): array { } + } diff --git a/src/Phalcon/mvc/model/transaction/Manager.php b/src/Phalcon/Mvc/Model/Transaction/Manager.php similarity index 88% rename from src/Phalcon/mvc/model/transaction/Manager.php rename to src/Phalcon/Mvc/Model/Transaction/Manager.php index 70953823..1fe6dd31 100644 --- a/src/Phalcon/mvc/model/transaction/Manager.php +++ b/src/Phalcon/Mvc/Model/Transaction/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Transaction; use Phalcon\Di\DiInterface; @@ -52,7 +59,7 @@ * } * ``` */ -class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface +class Manager implements Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { protected $container; @@ -86,6 +93,8 @@ public function __construct(\Phalcon\Di\DiInterface $container = null) /** * Remove all the transactions from the manager + * + * @return void */ public function collectTransactions() { @@ -103,7 +112,7 @@ public function commit() * This method registers a shutdown function to rollback active connections * * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @return TransactionInterface */ public function get(bool $autoBegin = true): TransactionInterface { @@ -121,7 +130,7 @@ public function getDbService(): string /** * Returns the dependency injection container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -131,7 +140,7 @@ public function getDI(): DiInterface * Create/Returns a new transaction or an existing one * * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @return TransactionInterface */ public function getOrCreateTransaction(bool $autoBegin = true): TransactionInterface { @@ -160,6 +169,7 @@ public function has(): bool * Notifies the manager about a committed transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return void */ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) { @@ -169,6 +179,7 @@ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transactio * Notifies the manager about a rollbacked transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return void */ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) { @@ -179,6 +190,7 @@ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transact * Collect will remove the transaction from the manager * * @param bool $collect + * @return void */ public function rollback(bool $collect = true) { @@ -186,6 +198,8 @@ public function rollback(bool $collect = true) /** * Rollbacks active transactions within the manager + * + * @return void */ public function rollbackPendent() { @@ -195,7 +209,7 @@ public function rollbackPendent() * Sets the database service used to run the isolated transactions * * @param string $service - * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface + * @return ManagerInterface */ public function setDbService(string $service): ManagerInterface { @@ -205,6 +219,7 @@ public function setDbService(string $service): ManagerInterface * Sets the dependency injection container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -215,7 +230,7 @@ public function setDI(\Phalcon\Di\DiInterface $container) * up pendent transactions * * @param bool $rollbackPendent - * @return \Phalcon\Mvc\Model\Transaction\ManagerInterface + * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface { @@ -225,8 +240,10 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface * Removes transactions from the TransactionManager * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return void */ protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) { } + } diff --git a/src/Phalcon/mvc/model/transaction/ManagerInterface.php b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php similarity index 86% rename from src/Phalcon/mvc/model/transaction/ManagerInterface.php rename to src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php index fc07bdbc..7bde20da 100644 --- a/src/Phalcon/mvc/model/transaction/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\Model\TransactionInterface; @@ -14,6 +21,8 @@ interface ManagerInterface /** * Remove all the transactions from the manager + * + * @return void */ public function collectTransactions(); @@ -26,7 +35,7 @@ public function commit(); * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once * * @param bool $autoBegin - * @return \Phalcon\Mvc\Model\TransactionInterface + * @return TransactionInterface */ public function get(bool $autoBegin = true): TransactionInterface; @@ -55,6 +64,7 @@ public function has(): bool; * Notifies the manager about a committed transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return void */ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); @@ -62,6 +72,7 @@ public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transactio * Notifies the manager about a rollbacked transaction * * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @return void */ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); @@ -70,11 +81,14 @@ public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transact * Collect will remove transaction from the manager * * @param bool $collect + * @return void */ public function rollback(bool $collect = false); /** * Rollbacks active transactions within the manager + * + * @return void */ public function rollbackPendent(); @@ -93,4 +107,5 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; + } diff --git a/src/Phalcon/mvc/model/TransactionInterface.php b/src/Phalcon/Mvc/Model/TransactionInterface.php similarity index 88% rename from src/Phalcon/mvc/model/TransactionInterface.php rename to src/Phalcon/Mvc/Model/TransactionInterface.php index 2499aebe..4cd1d2eb 100644 --- a/src/Phalcon/mvc/model/TransactionInterface.php +++ b/src/Phalcon/Mvc/Model/TransactionInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; /** @@ -65,6 +72,7 @@ public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInter * Sets if is a reused transaction or new once * * @param bool $isNew + * @return void */ public function setIsNewTransaction(bool $isNew); @@ -72,6 +80,7 @@ public function setIsNewTransaction(bool $isNew); * Sets flag to rollback on abort the HTTP connection * * @param bool $rollbackOnAbort + * @return void */ public function setRollbackOnAbort(bool $rollbackOnAbort); @@ -79,6 +88,7 @@ public function setRollbackOnAbort(bool $rollbackOnAbort); * Sets object which generates rollback action * * @param \Phalcon\Mvc\ModelInterface $record + * @return void */ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); @@ -86,6 +96,7 @@ public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); * Sets transaction manager related to the transaction * * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + * @return void */ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); @@ -96,4 +107,5 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; + } diff --git a/src/Phalcon/mvc/model/ValidationFailed.php b/src/Phalcon/Mvc/Model/ValidationFailed.php similarity index 78% rename from src/Phalcon/mvc/model/ValidationFailed.php rename to src/Phalcon/Mvc/Model/ValidationFailed.php index 200baf2c..eeff8de2 100644 --- a/src/Phalcon/mvc/model/ValidationFailed.php +++ b/src/Phalcon/Mvc/Model/ValidationFailed.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; @@ -34,7 +41,7 @@ public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validatio /** * Returns the complete group of messages produced in the validation * - * @return array|Message[] + * @return array */ public function getMessages(): array { @@ -43,9 +50,10 @@ public function getMessages(): array /** * Returns the model that generated the messages * - * @return \Phalcon\Mvc\ModelInterface + * @return ModelInterface */ public function getModel(): ModelInterface { } + } diff --git a/src/Phalcon/mvc/ModelInterface.php b/src/Phalcon/Mvc/ModelInterface.php similarity index 94% rename from src/Phalcon/mvc/ModelInterface.php rename to src/Phalcon/Mvc/ModelInterface.php index 91ccf067..7d20a38d 100644 --- a/src/Phalcon/mvc/ModelInterface.php +++ b/src/Phalcon/Mvc/ModelInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Db\Adapter\AdapterInterface; @@ -58,10 +65,10 @@ public static function cloneResult(ModelInterface $base, array $data, int $dirty * * @param \Phalcon\Mvc\Model $base * @param array $columnMap + * @return \Phalcon\Mvc\Model result * @param array $data * @param int $dirtyState * @param bool $keepSnapshots - * @return \Phalcon\Mvc\Model result */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; @@ -102,7 +109,7 @@ public function delete(): bool; * Allows to query a set of records that match the specified conditions * * @param mixed $parameters - * @return \Phalcon\Mvc\Model\ResultsetInterface + * @return ResultsetInterface */ public static function find($parameters = null): ResultsetInterface; @@ -110,7 +117,7 @@ public static function find($parameters = null): ResultsetInterface; * Allows to query the first record that match the specified conditions * * @param array $parameters - * @return bool|ModelInterface + * @return mixed */ public static function findFirst($parameters = null); @@ -144,14 +151,14 @@ public function getDirtyState(): int; /** * Returns array of validation messages * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array */ public function getMessages(): array; /** * Returns the models meta-data service related to the entity instance. * - * @return \Phalcon\Mvc\Model\MetaDataInterface + * @return MetaDataInterface */ public function getModelsMetaData(): MetaDataInterface; @@ -166,7 +173,7 @@ public function getOperationMade(): int; /** * Gets internal database connection * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getReadConnection(): AdapterInterface; @@ -181,8 +188,8 @@ public function getReadConnectionService(): string; * Returns related records based on defined relations * * @param array $arguments - * @param string $alias * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @param string $alias */ public function getRelated(string $alias, $arguments = null); @@ -203,7 +210,7 @@ public function getSource(): string; /** * Gets internal database connection * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ public function getWriteConnection(): AdapterInterface; @@ -236,7 +243,7 @@ public static function minimum($parameters = null); * Create a criteria for a specific model * * @param \Phalcon\Di\DiInterface $container - * @return \Phalcon\Mvc\Model\CriteriaInterface + * @return CriteriaInterface */ public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface; @@ -259,6 +266,7 @@ public function save(): bool; * Sets both read/write connection services * * @param string $connectionService + * @return void */ public function setConnectionService(string $connectionService); @@ -267,7 +275,7 @@ public function setConnectionService(string $connectionService); * constants * * @param int $dirtyState - * @return bool|ModelInterface + * @return mixed */ public function setDirtyState(int $dirtyState); @@ -275,6 +283,7 @@ public function setDirtyState(int $dirtyState); * Sets the DependencyInjection connection service used to read data * * @param string $connectionService + * @return void */ public function setReadConnectionService(string $connectionService); @@ -284,6 +293,7 @@ public function setReadConnectionService(string $connectionService); * * @param array $columnMap * @param array $data + * @return void */ public function setSnapshotData(array $data, $columnMap = null); @@ -299,6 +309,7 @@ public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transact * Sets the DependencyInjection connection service used to write data * * @param string $connectionService + * @return void */ public function setWriteConnectionService(string $connectionService); @@ -306,6 +317,7 @@ public function setWriteConnectionService(string $connectionService); * Skips the current operation forcing a success state * * @param bool $skip + * @return void */ public function skipOperation(bool $skip); @@ -332,4 +344,5 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; + } diff --git a/src/Phalcon/mvc/ModuleDefinitionInterface.php b/src/Phalcon/Mvc/ModuleDefinitionInterface.php similarity index 72% rename from src/Phalcon/mvc/ModuleDefinitionInterface.php rename to src/Phalcon/Mvc/ModuleDefinitionInterface.php index 04605ce1..9b455a2a 100644 --- a/src/Phalcon/mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/Mvc/ModuleDefinitionInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; /** @@ -23,4 +30,5 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); + } diff --git a/src/Phalcon/mvc/Router.php b/src/Phalcon/Mvc/Router.php similarity index 92% rename from src/Phalcon/mvc/Router.php rename to src/Phalcon/Mvc/Router.php index 6054ff5c..9863abad 100644 --- a/src/Phalcon/mvc/Router.php +++ b/src/Phalcon/Mvc/Router.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Di\AbstractInjectionAware; @@ -34,7 +41,7 @@ * echo $router->getControllerName(); * ``` */ -class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface +class Router extends AbstractInjectionAware implements Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { const POSITION_FIRST = 0; @@ -103,6 +110,7 @@ class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterf protected $wasMatched = false; + public function getKeyRouteNames() { } @@ -161,7 +169,7 @@ public function __construct(bool $defaultRoutes = true) * @param mixed $paths * @param mixed $httpMethods * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null, $position = Router::POSITION_LAST): RouteInterface { @@ -173,7 +181,7 @@ public function add(string $pattern, $paths = null, $httpMethods = null, $positi * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addConnect(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -185,7 +193,7 @@ public function addConnect(string $pattern, $paths = null, $position = Router::P * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addDelete(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -197,7 +205,7 @@ public function addDelete(string $pattern, $paths = null, $position = Router::PO * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addGet(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -209,7 +217,7 @@ public function addGet(string $pattern, $paths = null, $position = Router::POSIT * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addHead(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -221,7 +229,7 @@ public function addHead(string $pattern, $paths = null, $position = Router::POSI * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addOptions(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -233,7 +241,7 @@ public function addOptions(string $pattern, $paths = null, $position = Router::P * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPatch(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -245,7 +253,7 @@ public function addPatch(string $pattern, $paths = null, $position = Router::POS * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPost(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -258,7 +266,7 @@ public function addPost(string $pattern, $paths = null, $position = Router::POSI * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPurge(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -270,7 +278,7 @@ public function addPurge(string $pattern, $paths = null, $position = Router::POS * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPut(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -282,7 +290,7 @@ public function addPut(string $pattern, $paths = null, $position = Router::POSIT * @param string $pattern * @param mixed $paths * @param mixed $position - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addTrace(string $pattern, $paths = null, $position = Router::POSITION_LAST): RouteInterface { @@ -317,6 +325,8 @@ public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Ro /** * Removes all the pre-defined routes + * + * @return void */ public function clear() { @@ -325,7 +335,7 @@ public function clear() /** * Returns the internal event manager * - * @return \Phalcon\Events\ManagerInterface + * @return ManagerInterface */ public function getEventsManager(): ManagerInterface { @@ -352,7 +362,7 @@ public function getControllerName(): string /** * Returns the route that matches the handled URI * - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function getMatchedRoute(): RouteInterface { @@ -398,7 +408,7 @@ public function getParams(): array * Returns a route object by its id * * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return mixed */ public function getRouteById($id) { @@ -408,7 +418,7 @@ public function getRouteById($id) * Returns a route object by its name * * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return mixed */ public function getRouteByName(string $name) { @@ -417,7 +427,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array */ public function getRoutes(): array { @@ -432,6 +442,7 @@ public function getRoutes(): array * ``` * * @param string $uri + * @return void */ public function handle(string $uri) { @@ -551,6 +562,7 @@ public function getDefaults(): array * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -564,4 +576,5 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } + } diff --git a/src/Phalcon/mvc/router/Annotations.php b/src/Phalcon/Mvc/Router/Annotations.php similarity index 92% rename from src/Phalcon/mvc/router/Annotations.php rename to src/Phalcon/Mvc/Router/Annotations.php index 565a5564..ef4a8b38 100644 --- a/src/Phalcon/mvc/router/Annotations.php +++ b/src/Phalcon/Mvc/Router/Annotations.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Router; use Phalcon\Mvc\Router; @@ -80,6 +87,7 @@ public function getResources(): array * Produce the routing parameters from the rewrite information * * @param string $uri + * @return void */ public function handle(string $uri) { @@ -125,4 +133,5 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } + } diff --git a/src/Phalcon/Mvc/Router/Exception.php b/src/Phalcon/Mvc/Router/Exception.php new file mode 100644 index 00000000..f60ebd75 --- /dev/null +++ b/src/Phalcon/Mvc/Router/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\Router; + +/** + * Phalcon\Mvc\Router\Exception + * + * Exceptions thrown in Phalcon\Mvc\Router will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/mvc/router/Group.php b/src/Phalcon/Mvc/Router/Group.php similarity index 94% rename from src/Phalcon/mvc/router/Group.php rename to src/Phalcon/Mvc/Router/Group.php index b1a49f19..d9536b6c 100644 --- a/src/Phalcon/mvc/router/Group.php +++ b/src/Phalcon/Mvc/Router/Group.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Router; /** @@ -50,7 +57,7 @@ * $router->mount($blog); * ``` */ -class Group implements \Phalcon\Mvc\Router\GroupInterface +class Group implements Phalcon\Mvc\Router\GroupInterface { protected $beforeMatch; @@ -217,6 +224,8 @@ public function beforeMatch($beforeMatch): GroupInterface /** * Removes all the pre-defined routes + * + * @return void */ public function clear() { @@ -225,7 +234,7 @@ public function clear() /** * Returns the 'before match' callback if any * - * @return callable + * @return mixed */ public function getBeforeMatch() { @@ -261,7 +270,7 @@ public function getPrefix(): string /** * Returns the routes added to the group * - * @return array|RouteInterface[] + * @return array */ public function getRoutes(): array { @@ -308,4 +317,5 @@ public function setPrefix(string $prefix): GroupInterface protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } + } diff --git a/src/Phalcon/mvc/router/GroupInterface.php b/src/Phalcon/Mvc/Router/GroupInterface.php similarity index 89% rename from src/Phalcon/mvc/router/GroupInterface.php rename to src/Phalcon/Mvc/Router/GroupInterface.php index c504e20c..2bb94856 100644 --- a/src/Phalcon/mvc/router/GroupInterface.php +++ b/src/Phalcon/Mvc/Router/GroupInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Router; /** @@ -61,7 +68,7 @@ interface GroupInterface * @param string $pattern * @param mixed $paths * @param mixed $httpMethods - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; @@ -70,7 +77,7 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface; @@ -79,7 +86,7 @@ public function addConnect(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface; @@ -88,7 +95,7 @@ public function addDelete(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface; @@ -97,7 +104,7 @@ public function addGet(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface; @@ -106,7 +113,7 @@ public function addHead(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface; @@ -115,7 +122,7 @@ public function addOptions(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface; @@ -124,7 +131,7 @@ public function addPatch(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface; @@ -133,7 +140,7 @@ public function addPost(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface; @@ -142,7 +149,7 @@ public function addPurge(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface; @@ -151,7 +158,7 @@ public function addPut(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface; @@ -167,13 +174,15 @@ public function beforeMatch($beforeMatch): GroupInterface; /** * Removes all the pre-defined routes + * + * @return void */ public function clear(); /** * Returns the 'before match' callback if any * - * @return callable + * @return mixed */ public function getBeforeMatch(); @@ -201,7 +210,7 @@ public function getPrefix(): string; /** * Returns the routes added to the group * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array */ public function getRoutes(): array; @@ -228,4 +237,5 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; + } diff --git a/src/Phalcon/mvc/router/Route.php b/src/Phalcon/Mvc/Router/Route.php similarity index 93% rename from src/Phalcon/mvc/router/Route.php rename to src/Phalcon/Mvc/Router/Route.php index 7eb8bf76..c2e979fb 100644 --- a/src/Phalcon/mvc/router/Route.php +++ b/src/Phalcon/Mvc/Router/Route.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Router; /** @@ -7,7 +14,7 @@ * * This class represents every route added to the router */ -class Route implements \Phalcon\Mvc\Router\RouteInterface +class Route implements Phalcon\Mvc\Router\RouteInterface { protected $beforeMatch; @@ -43,7 +50,8 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; + public function getId() @@ -126,7 +134,7 @@ public function extractNamedParams(string $pattern) /** * Returns the 'before match' callback if any * - * @return callable + * @return mixed */ public function getBeforeMatch() { @@ -153,7 +161,7 @@ public function getConverters(): array /** * Returns the group associated with the route * - * @return null|GroupInterface + * @return mixed */ public function getGroup(): ?GroupInterface { @@ -180,7 +188,7 @@ public function getHostname(): string /** * Returns the 'match' callback if any * - * @return callable + * @return mixed */ public function getMatch() { @@ -267,6 +275,7 @@ public function match($callback): RouteInterface * * @param string $pattern * @param mixed $paths + * @return void */ public function reConfigure(string $pattern, $paths = null) { @@ -274,6 +283,8 @@ public function reConfigure(string $pattern, $paths = null) /** * Resets the internal route id generator + * + * @return void */ public static function reset() { @@ -363,4 +374,5 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } + } diff --git a/src/Phalcon/mvc/router/RouteInterface.php b/src/Phalcon/Mvc/Router/RouteInterface.php similarity index 91% rename from src/Phalcon/mvc/router/RouteInterface.php rename to src/Phalcon/Mvc/Router/RouteInterface.php index 39e2d5cf..c8930254 100644 --- a/src/Phalcon/mvc/router/RouteInterface.php +++ b/src/Phalcon/Mvc/Router/RouteInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\Router; /** @@ -112,11 +119,14 @@ public function setName(string $name): RouteInterface; * * @param string $pattern * @param mixed $paths + * @return void */ public function reConfigure(string $pattern, $paths = null); /** * Resets the internal route id generator + * + * @return void */ public static function reset(); @@ -127,4 +137,5 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; + } diff --git a/src/Phalcon/mvc/RouterInterface.php b/src/Phalcon/Mvc/RouterInterface.php similarity index 88% rename from src/Phalcon/mvc/RouterInterface.php rename to src/Phalcon/Mvc/RouterInterface.php index 7ab02262..aad2dcee 100644 --- a/src/Phalcon/mvc/RouterInterface.php +++ b/src/Phalcon/Mvc/RouterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Mvc\Router\RouteInterface; @@ -16,7 +23,7 @@ interface RouterInterface * @param string $pattern * @param mixed $paths * @param mixed $httpMethods - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function add(string $pattern, $paths = null, $httpMethods = null): RouteInterface; @@ -34,7 +41,7 @@ public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Ro * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addConnect(string $pattern, $paths = null): RouteInterface; @@ -43,7 +50,7 @@ public function addConnect(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addDelete(string $pattern, $paths = null): RouteInterface; @@ -52,7 +59,7 @@ public function addDelete(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addHead(string $pattern, $paths = null): RouteInterface; @@ -61,7 +68,7 @@ public function addHead(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addGet(string $pattern, $paths = null): RouteInterface; @@ -70,7 +77,7 @@ public function addGet(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addOptions(string $pattern, $paths = null): RouteInterface; @@ -79,7 +86,7 @@ public function addOptions(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPatch(string $pattern, $paths = null): RouteInterface; @@ -88,7 +95,7 @@ public function addPatch(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPost(string $pattern, $paths = null): RouteInterface; @@ -98,7 +105,7 @@ public function addPost(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPurge(string $pattern, $paths = null): RouteInterface; @@ -107,7 +114,7 @@ public function addPurge(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addPut(string $pattern, $paths = null): RouteInterface; @@ -116,12 +123,14 @@ public function addPut(string $pattern, $paths = null): RouteInterface; * * @param string $pattern * @param mixed $paths - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function addTrace(string $pattern, $paths = null): RouteInterface; /** * Removes all the defined routes + * + * @return void */ public function clear(); @@ -142,7 +151,7 @@ public function getControllerName(): string; /** * Returns the route that matches the handled URI * - * @return \Phalcon\Mvc\Router\RouteInterface + * @return RouteInterface */ public function getMatchedRoute(): RouteInterface; @@ -177,7 +186,7 @@ public function getParams(): array; /** * Return all the routes defined in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array */ public function getRoutes(): array; @@ -185,7 +194,7 @@ public function getRoutes(): array; * Returns a route object by its id * * @param mixed $id - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return mixed */ public function getRouteById($id); @@ -193,7 +202,7 @@ public function getRouteById($id); * Returns a route object by its name * * @param string $name - * @return bool|\Phalcon\Mvc\Router\RouteInterface + * @return mixed */ public function getRouteByName(string $name); @@ -201,6 +210,7 @@ public function getRouteByName(string $name); * Handles routing information received from the rewrite engine * * @param string $uri + * @return void */ public function handle(string $uri); @@ -250,4 +260,5 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/mvc/View.php b/src/Phalcon/Mvc/View.php similarity index 97% rename from src/Phalcon/mvc/View.php rename to src/Phalcon/Mvc/View.php index ea069d7d..028ad42c 100644 --- a/src/Phalcon/mvc/View.php +++ b/src/Phalcon/Mvc/View.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; use Phalcon\Di\Injectable; @@ -31,7 +38,7 @@ * echo $view->getContent(); * ``` */ -class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface +class View extends Injectable implements Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface { /** * Render Level: To the action view @@ -133,6 +140,7 @@ class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Ev protected $viewParams = array(); + public function getCurrentRenderLevel() { } @@ -227,7 +235,7 @@ public function cleanTemplateBefore(): View * ``` * * @param mixed $level - * @return \Phalcon\Mvc\ViewInterface + * @return ViewInterface */ public function disableLevel($level): ViewInterface { @@ -318,7 +326,7 @@ public function getControllerName(): string /** * Returns the internal event manager * - * @return null|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface { @@ -535,7 +543,7 @@ public function registerEngines(array $engines): View * @param string $controllerName * @param string $actionName * @param array $params - * @return bool|View + * @return mixed */ public function render(string $controllerName, string $actionName, array $params = array()) { @@ -583,6 +591,7 @@ public function setContent(string $content): View * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -677,7 +686,7 @@ public function setParamToView(string $key, $value): View * ``` * * @param int $level - * @return \Phalcon\Mvc\ViewInterface + * @return ViewInterface */ public function setRenderLevel(int $level): ViewInterface { @@ -812,4 +821,5 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } + } diff --git a/src/Phalcon/mvc/view/engine/AbstractEngine.php b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php similarity index 74% rename from src/Phalcon/mvc/view/engine/AbstractEngine.php rename to src/Phalcon/Mvc/View/Engine/AbstractEngine.php index b67caa74..804161f7 100644 --- a/src/Phalcon/mvc/view/engine/AbstractEngine.php +++ b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine; use Phalcon\Di\Injectable; @@ -9,7 +16,7 @@ * All the template engine adapters must inherit this class. This provides * basic interfacing between the engine and the Phalcon\Mvc\View component. */ -abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface +abstract class AbstractEngine extends Injectable implements Phalcon\Mvc\View\Engine\EngineInterface { protected $view; @@ -37,7 +44,7 @@ public function getContent(): string /** * Returns the view component related to the adapter * - * @return \Phalcon\Mvc\ViewBaseInterface + * @return ViewBaseInterface */ public function getView(): ViewBaseInterface { @@ -48,8 +55,10 @@ public function getView(): ViewBaseInterface * * @param array $params * @param string $partialPath + * @return void */ public function partial(string $partialPath, $params = null) { } + } diff --git a/src/Phalcon/mvc/view/engine/EngineInterface.php b/src/Phalcon/Mvc/View/Engine/EngineInterface.php similarity index 73% rename from src/Phalcon/mvc/view/engine/EngineInterface.php rename to src/Phalcon/Mvc/View/Engine/EngineInterface.php index 7f0d981f..b0d283c7 100644 --- a/src/Phalcon/mvc/view/engine/EngineInterface.php +++ b/src/Phalcon/Mvc/View/Engine/EngineInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine; /** @@ -20,6 +27,7 @@ public function getContent(): string; * * @param string $partialPath * @param mixed $params + * @return void */ public function partial(string $partialPath, $params = null); @@ -31,4 +39,5 @@ public function partial(string $partialPath, $params = null); * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); + } diff --git a/src/Phalcon/mvc/view/engine/Php.php b/src/Phalcon/Mvc/View/Engine/Php.php similarity index 55% rename from src/Phalcon/mvc/view/engine/Php.php rename to src/Phalcon/Mvc/View/Engine/Php.php index 0e6d1a5a..a8b2ac61 100644 --- a/src/Phalcon/mvc/view/engine/Php.php +++ b/src/Phalcon/Mvc/View/Engine/Php.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine; /** * Adapter to use PHP itself as templating engine */ -class Php extends AbstractEngine +class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine { /** @@ -18,4 +25,5 @@ class Php extends AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } + } diff --git a/src/Phalcon/mvc/view/engine/Volt.php b/src/Phalcon/Mvc/View/Engine/Volt.php similarity index 86% rename from src/Phalcon/mvc/view/engine/Volt.php rename to src/Phalcon/Mvc/View/Engine/Volt.php index d4e83800..3abc528b 100644 --- a/src/Phalcon/mvc/view/engine/Volt.php +++ b/src/Phalcon/Mvc/View/Engine/Volt.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine; use Phalcon\Events\ManagerInterface; @@ -8,7 +15,7 @@ /** * Designer friendly and fast template engine for PHP written in Zephir/C */ -class Volt extends AbstractEngine implements \Phalcon\Events\EventsAwareInterface +class Volt extends \Phalcon\Mvc\View\Engine\AbstractEngine implements \Phalcon\Events\EventsAwareInterface { protected $compiler; @@ -49,7 +56,7 @@ public function convertEncoding(string $text, string $from, string $to): string /** * Returns the Volt's compiler * - * @return \Phalcon\Mvc\View\Engine\Volt\Compiler + * @return Compiler */ public function getCompiler(): Compiler { @@ -58,7 +65,7 @@ public function getCompiler(): Compiler /** * Returns the internal event manager * - * @return null|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface { @@ -109,6 +116,7 @@ public function render(string $templatePath, $params, bool $mustClean = false) * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -143,4 +151,5 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } + } diff --git a/src/Phalcon/mvc/view/engine/volt/Compiler.php b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php similarity index 97% rename from src/Phalcon/mvc/view/engine/volt/Compiler.php rename to src/Phalcon/Mvc/View/Engine/Volt/Compiler.php index 8c89fc49..5fe0be21 100644 --- a/src/Phalcon/mvc/view/engine/volt/Compiler.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine\Volt; use Phalcon\Di\DiInterface; @@ -232,10 +239,10 @@ public function compileElseIf(array $statement): string * ); * ``` * + * @return string|array * @param string $path * @param string $compiledPath * @param bool $extendsMode - * @return string|array */ public function compileFile(string $path, string $compiledPath, bool $extendsMode = false) { @@ -353,8 +360,8 @@ final public function expression(array $expr): string * Fires an event to registered extensions * * @param array $arguments - * @param string $name * @return mixed + * @param string $name */ final public function fireExtensionEvent(string $name, $arguments = null) { @@ -382,7 +389,7 @@ public function getCompiledTemplatePath(): string /** * Returns the internal dependency injector * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -418,8 +425,8 @@ public function getFunctions(): array /** * Returns a compiler's option * - * @param string $option * @return string + * @param string $option */ public function getOption(string $option) { @@ -462,8 +469,8 @@ public function getUniquePrefix(): string * ); * ``` * - * @param string $viewCode * @return array + * @param string $viewCode */ public function parse(string $viewCode) { @@ -484,6 +491,7 @@ public function resolveTest(array $test, string $left): string * Sets the dependency injector * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { @@ -569,4 +577,5 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } + } diff --git a/src/Phalcon/mvc/view/engine/volt/Exception.php b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php similarity index 66% rename from src/Phalcon/mvc/view/engine/volt/Exception.php rename to src/Phalcon/Mvc/View/Engine/Volt/Exception.php index 915f73b0..2f5151f0 100644 --- a/src/Phalcon/mvc/view/engine/volt/Exception.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php @@ -1,13 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View\Engine\Volt; -use Phalcon\Mvc\View\Exception as BaseException; - /** * Class for exceptions thrown by Phalcon\Mvc\View */ -class Exception extends BaseException +class Exception extends \Phalcon\Mvc\View\Exception { protected $statement; @@ -31,4 +36,5 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } + } diff --git a/src/Phalcon/Mvc/View/Exception.php b/src/Phalcon/Mvc/View/Exception.php new file mode 100644 index 00000000..92c5704b --- /dev/null +++ b/src/Phalcon/Mvc/View/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Mvc\View; + +/** + * Phalcon\Mvc\View\Exception + * + * Class for exceptions thrown by Phalcon\Mvc\View + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/mvc/view/Simple.php b/src/Phalcon/Mvc/View/Simple.php similarity index 95% rename from src/Phalcon/mvc/view/Simple.php rename to src/Phalcon/Mvc/View/Simple.php index 9a93d03b..958ef113 100644 --- a/src/Phalcon/mvc/view/Simple.php +++ b/src/Phalcon/Mvc/View/Simple.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc\View; use Phalcon\Di\Injectable; @@ -131,7 +138,7 @@ public function getContent(): string /** * Returns the internal event manager * - * @return null|\Phalcon\Events\ManagerInterface + * @return mixed */ public function getEventsManager(): ?ManagerInterface { @@ -238,6 +245,7 @@ public function setContent(string $content): Simple * Sets the events manager * * @param \Phalcon\Events\ManagerInterface $eventsManager + * @return void */ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { @@ -320,4 +328,5 @@ protected function loadTemplateEngines(): array final protected function internalRender(string $path, $params) { } + } diff --git a/src/Phalcon/mvc/ViewBaseInterface.php b/src/Phalcon/Mvc/ViewBaseInterface.php similarity index 86% rename from src/Phalcon/mvc/ViewBaseInterface.php rename to src/Phalcon/Mvc/ViewBaseInterface.php index 0495848b..fb99dbdd 100644 --- a/src/Phalcon/mvc/ViewBaseInterface.php +++ b/src/Phalcon/Mvc/ViewBaseInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; /** @@ -69,4 +76,5 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); + } diff --git a/src/Phalcon/mvc/ViewInterface.php b/src/Phalcon/Mvc/ViewInterface.php similarity index 93% rename from src/Phalcon/mvc/ViewInterface.php rename to src/Phalcon/Mvc/ViewInterface.php index 94305bb5..5b9bc7e2 100644 --- a/src/Phalcon/mvc/ViewInterface.php +++ b/src/Phalcon/Mvc/ViewInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Mvc; /** @@ -7,7 +14,7 @@ * * Interface for Phalcon\Mvc\View */ -interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface +interface ViewInterface extends Phalcon\Mvc\ViewBaseInterface { /** @@ -118,7 +125,7 @@ public function registerEngines(array $engines); * @param string $controllerName * @param string $actionName * @param array $params - * @return bool|ViewInterface + * @return mixed */ public function render(string $controllerName, string $actionName, array $params = array()); @@ -195,4 +202,5 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); + } diff --git a/src/Phalcon/paginator/adapter/AbstractAdapter.php b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php similarity index 78% rename from src/Phalcon/paginator/adapter/AbstractAdapter.php rename to src/Phalcon/Paginator/Adapter/AbstractAdapter.php index 6dfb374e..13c31f1b 100644 --- a/src/Phalcon/paginator/adapter/AbstractAdapter.php +++ b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator\Adapter; use Phalcon\Paginator\RepositoryInterface; @@ -7,7 +14,7 @@ /** * Phalcon\Paginator\Adapter\AbstractAdapter */ -abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Paginator\Adapter\AdapterInterface { /** * Configuration of paginator @@ -54,7 +61,7 @@ public function getLimit(): int * Set the current page number * * @param int $page - * @return \Phalcon\Paginator\Adapter\AdapterInterface + * @return AdapterInterface */ public function setCurrentPage(int $page): AdapterInterface { @@ -64,7 +71,7 @@ public function setCurrentPage(int $page): AdapterInterface * Set current rows limit * * @param int $limitRows - * @return \Phalcon\Paginator\Adapter\AdapterInterface + * @return AdapterInterface */ public function setLimit(int $limitRows): AdapterInterface { @@ -74,7 +81,7 @@ public function setLimit(int $limitRows): AdapterInterface * Sets current repository for pagination * * @param \Phalcon\Paginator\RepositoryInterface $repository - * @return \Phalcon\Paginator\Adapter\AdapterInterface + * @return AdapterInterface */ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): AdapterInterface { @@ -84,9 +91,10 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository * Gets current repository for pagination * * @param array $properties - * @return \Phalcon\Paginator\RepositoryInterface + * @return RepositoryInterface */ protected function getRepository(array $properties = null): RepositoryInterface { } + } diff --git a/src/Phalcon/paginator/adapter/AdapterInterface.php b/src/Phalcon/Paginator/Adapter/AdapterInterface.php similarity index 73% rename from src/Phalcon/paginator/adapter/AdapterInterface.php rename to src/Phalcon/Paginator/Adapter/AdapterInterface.php index b577dc1e..e4136ebe 100644 --- a/src/Phalcon/paginator/adapter/AdapterInterface.php +++ b/src/Phalcon/Paginator/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator\Adapter; use Phalcon\Paginator\RepositoryInterface; @@ -22,7 +29,7 @@ public function getLimit(): int; /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @return RepositoryInterface */ public function paginate(): RepositoryInterface; @@ -39,4 +46,5 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); + } diff --git a/src/Phalcon/Paginator/Adapter/Model.php b/src/Phalcon/Paginator/Adapter/Model.php new file mode 100644 index 00000000..9b246d4b --- /dev/null +++ b/src/Phalcon/Paginator/Adapter/Model.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Paginator\Adapter; + +use Phalcon\Paginator\RepositoryInterface; + +/** + * Phalcon\Paginator\Adapter\Model + * + * This adapter allows to paginate data using a Phalcon\Mvc\Model resultset as a + * base. + * + * ```php + * use Phalcon\Paginator\Adapter\Model; + * + * $paginator = new Model( + * [ + * "model" => Robots::class, + * "limit" => 25, + * "page" => $currentPage, + * ] + * ); + * + * $paginator = new Model( + * [ + * "model" => Robots::class, + * "parameters" => [ + * "columns" => "id, name" + * ], + * "limit" => 12, + * "page" => $currentPage, + * ] + * ); + * + * $paginator = new Model( + * [ + * "model" => Robots::class, + * "parameters" => [ + * "type = :type:", + * "bind" => [ + * "type" => "mechanical" + * ], + * "order" => "name" + * ], + * "limit" => 16, + * "page" => $currentPage, + * ] + * ); + * + * $paginator = new Model( + * [ + * "model" => Robots::class, + * "parameters" => "(id % 2) = 0", + * "limit" => 8, + * "page" => $currentPage, + * ] + * ); + * + * $paginator = new Model( + * [ + * "model" => Robots::class, + * "parameters" => [ "(id % 2) = 0" ], + * "limit" => 8, + * "page" => $currentPage, + * ] + * ); + * + * $paginate = $paginator->paginate(); + * ``` + */ +class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter +{ + + /** + * Returns a slice of the resultset to show in the pagination + * + * @return RepositoryInterface + */ + public function paginate(): RepositoryInterface + { + } + +} diff --git a/src/Phalcon/paginator/adapter/NativeArray.php b/src/Phalcon/Paginator/Adapter/NativeArray.php similarity index 71% rename from src/Phalcon/paginator/adapter/NativeArray.php rename to src/Phalcon/Paginator/Adapter/NativeArray.php index b3e7fe96..345ae715 100644 --- a/src/Phalcon/paginator/adapter/NativeArray.php +++ b/src/Phalcon/Paginator/Adapter/NativeArray.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator\Adapter; use Phalcon\Paginator\RepositoryInterface; @@ -27,15 +34,16 @@ * ); * ``` */ -class NativeArray extends AbstractAdapter +class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter { /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @return RepositoryInterface */ public function paginate(): RepositoryInterface { } + } diff --git a/src/Phalcon/paginator/adapter/QueryBuilder.php b/src/Phalcon/Paginator/Adapter/QueryBuilder.php similarity index 81% rename from src/Phalcon/paginator/adapter/QueryBuilder.php rename to src/Phalcon/Paginator/Adapter/QueryBuilder.php index 9d95c134..eb27d4d2 100644 --- a/src/Phalcon/paginator/adapter/QueryBuilder.php +++ b/src/Phalcon/Paginator/Adapter/QueryBuilder.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator\Adapter; use Phalcon\Mvc\Model\Query\Builder; @@ -27,7 +34,7 @@ * ); * ``` */ -class QueryBuilder extends AbstractAdapter +class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter { /** * Paginator's data @@ -61,7 +68,7 @@ public function getCurrentPage(): int /** * Get query builder object * - * @return \Phalcon\Mvc\Model\Query\Builder + * @return Builder */ public function getQueryBuilder(): Builder { @@ -70,7 +77,7 @@ public function getQueryBuilder(): Builder /** * Returns a slice of the resultset to show in the pagination * - * @return \Phalcon\Paginator\RepositoryInterface + * @return RepositoryInterface */ public function paginate(): RepositoryInterface { @@ -85,4 +92,5 @@ public function paginate(): RepositoryInterface public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder { } + } diff --git a/src/Phalcon/Paginator/Exception.php b/src/Phalcon/Paginator/Exception.php new file mode 100644 index 00000000..4939c43b --- /dev/null +++ b/src/Phalcon/Paginator/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Paginator; + +/** + * Phalcon\Paginator\Exception + * + * Exceptions thrown in Phalcon\Paginator will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/paginator/PaginatorFactory.php b/src/Phalcon/Paginator/PaginatorFactory.php similarity index 84% rename from src/Phalcon/paginator/PaginatorFactory.php rename to src/Phalcon/Paginator/PaginatorFactory.php index 598bfcd6..f42f2f94 100644 --- a/src/Phalcon/paginator/PaginatorFactory.php +++ b/src/Phalcon/Paginator/PaginatorFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator; use Phalcon\Factory\AbstractFactory; @@ -49,7 +56,7 @@ public function __construct(array $services = array()) * ``` * * @param mixed $config - * @return \Phalcon\Paginator\Adapter\AdapterInterface + * @return AdapterInterface */ public function load($config): AdapterInterface { @@ -60,7 +67,7 @@ public function load($config): AdapterInterface * * @param string $name * @param array $options - * @return \Phalcon\Paginator\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface { @@ -72,4 +79,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/paginator/Repository.php b/src/Phalcon/Paginator/Repository.php similarity index 88% rename from src/Phalcon/paginator/Repository.php rename to src/Phalcon/Paginator/Repository.php index 14a0eadf..051dca35 100644 --- a/src/Phalcon/paginator/Repository.php +++ b/src/Phalcon/Paginator/Repository.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator; /** @@ -7,7 +14,7 @@ * * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements \Phalcon\Paginator\RepositoryInterface, \JsonSerializable +class Repository implements Phalcon\Paginator\RepositoryInterface, \JsonSerializable { /** * @var array @@ -160,4 +167,5 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } + } diff --git a/src/Phalcon/paginator/RepositoryInterface.php b/src/Phalcon/Paginator/RepositoryInterface.php similarity index 90% rename from src/Phalcon/paginator/RepositoryInterface.php rename to src/Phalcon/Paginator/RepositoryInterface.php index 7eeac3db..37835568 100644 --- a/src/Phalcon/paginator/RepositoryInterface.php +++ b/src/Phalcon/Paginator/RepositoryInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Paginator; /** @@ -113,4 +120,5 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; + } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index e5234f64..b78f5d0e 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Traversable; @@ -54,7 +61,7 @@ * are implemented using object handlers or similar techniques: this allows to * bypass relatively slow method calls. */ -final class Registry extends Collection +final class Registry extends \Phalcon\Collection { /** @@ -91,6 +98,7 @@ final public function __isset(string $element): bool * * @param string $element * @param mixed $value + * @return void */ final public function __set(string $element, $value) { @@ -100,6 +108,7 @@ final public function __set(string $element, $value) * Magic unset to remove an element from the collection * * @param string $element + * @return void */ final public function __unset(string $element) { @@ -107,6 +116,8 @@ final public function __unset(string $element) /** * Clears the internal collection + * + * @return void */ final public function clear() { @@ -137,7 +148,7 @@ final public function get(string $element, $defaultValue = null, string $cast = /** * Returns the iterator of the class * - * @return \Traversable + * @return Traversable */ final public function getIterator(): Traversable { @@ -157,6 +168,7 @@ final public function has(string $element): bool * Initialize internal array * * @param array $data + * @return void */ final public function init(array $data = array()) { @@ -200,6 +212,7 @@ final public function offsetGet($element) * @link https://php.net/manual/en/arrayaccess.offsetset.php * @param mixed $element * @param mixed $value + * @return void */ final public function offsetSet($element, $value) { @@ -210,6 +223,7 @@ final public function offsetSet($element, $value) * * @link https://php.net/manual/en/arrayaccess.offsetunset.php * @param mixed $element + * @return void */ final public function offsetUnset($element) { @@ -219,6 +233,7 @@ final public function offsetUnset($element) * Delete the element from the collection * * @param string $element + * @return void */ final public function remove(string $element) { @@ -239,6 +254,7 @@ final public function serialize(): string * * @param string $element * @param mixed $value + * @return void */ final public function set(string $element, $value) { @@ -273,8 +289,10 @@ final public function toJson(int $options = 79): string * * @link https://php.net/manual/en/serializable.unserialize.php * @param mixed $serialized + * @return void */ final public function unserialize($serialized) { } + } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index eb791bf6..d34bb3c0 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -1,10 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; use Phalcon\Security\Random; +use Phalcon\Session\ManagerInterface as SessionInterface; /** * This component provides a set of functions to improve the security in Phalcon @@ -171,7 +179,7 @@ public function getDefaultHash(): ?int /** * Returns a secure random number generator instance * - * @return \Phalcon\Security\Random + * @return Random */ public function getRandom(): Random { @@ -279,16 +287,17 @@ public function setRandomBytes(int $randomBytes): Security } /** - * @return null|\Phalcon\Http\RequestInterface + * @return mixed */ private function getLocalRequest(): ?RequestInterface { } /** - * @return null|\Phalcon\Session\ManagerInterface + * @return mixed */ private function getLocalSession(): ?SessionInterface { } + } diff --git a/src/Phalcon/Security/Exception.php b/src/Phalcon/Security/Exception.php new file mode 100644 index 00000000..d382be1a --- /dev/null +++ b/src/Phalcon/Security/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Security; + +/** + * Phalcon\Security\Exception + * + * Exceptions thrown in Phalcon\Security will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/security/Random.php b/src/Phalcon/Security/Random.php similarity index 97% rename from src/Phalcon/security/Random.php rename to src/Phalcon/Security/Random.php index 08449196..ea9b65f9 100644 --- a/src/Phalcon/security/Random.php +++ b/src/Phalcon/Security/Random.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Security; /** @@ -86,11 +93,11 @@ class Random * echo $random->base58(); // 4kUgL2pdQMSCQtjE * ``` * + * @see \Phalcon\Security\Random:base64 + * @link https://en.wikipedia.org/wiki/Base58 + * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read - * @link https://en.wikipedia.org/wiki/Base58 - * @see \Phalcon\Security\Random:base64 */ public function base58(int $len = null): string { @@ -112,10 +119,10 @@ public function base58(int $len = null): string * echo $random->base62(); // z0RkwHfh8ErDM1xw * ``` * + * @see \Phalcon\Security\Random:base58 + * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read - * @see \Phalcon\Security\Random:base58 */ public function base62(int $len = null): string { @@ -134,9 +141,9 @@ public function base62(int $len = null): string * echo $random->base64(12); // 3rcq39QzGK9fUqh8 * ``` * + * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read */ public function base64(int $len = null): string { @@ -186,9 +193,9 @@ public function base64Safe(int $len = null, bool $padding = false): string * // Possible output: string(32) "00f6c04b144b41fad6a59111c126e1ee" * ``` * + * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read */ public function bytes(int $len = 16): string { @@ -206,9 +213,9 @@ public function bytes(int $len = 16): string * echo $random->hex(10); // a29f470508d5ccb8e289 * ``` * + * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read */ public function hex(int $len = null): string { @@ -225,9 +232,9 @@ public function hex(int $len = null): string * echo $random->number(16); // 8 * ``` * + * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 * @param int $len * @return int - * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 */ public function number(int $len): int { @@ -266,13 +273,14 @@ public function uuid(): string * * If $n is not specified, 16 is assumed. It may be larger in future. * + * @throws Exception If secure random number generator is not available or unexpected partial read * @param string $alphabet * @param int $base * @param mixed $n * @return string - * @throws Exception If secure random number generator is not available or unexpected partial read */ protected function base(string $alphabet, int $base, $n = null): string { } + } diff --git a/src/Phalcon/session/adapter/AbstractAdapter.php b/src/Phalcon/Session/Adapter/AbstractAdapter.php similarity index 85% rename from src/Phalcon/session/adapter/AbstractAdapter.php rename to src/Phalcon/Session/Adapter/AbstractAdapter.php index 7b73851e..d487482c 100644 --- a/src/Phalcon/session/adapter/AbstractAdapter.php +++ b/src/Phalcon/Session/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session\Adapter; use Phalcon\Storage\Adapter\AdapterInterface; @@ -80,4 +87,5 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } + } diff --git a/src/Phalcon/session/adapter/Libmemcached.php b/src/Phalcon/Session/Adapter/Libmemcached.php similarity index 53% rename from src/Phalcon/session/adapter/Libmemcached.php rename to src/Phalcon/Session/Adapter/Libmemcached.php index 7ebded2f..73d7dc39 100644 --- a/src/Phalcon/session/adapter/Libmemcached.php +++ b/src/Phalcon/Session/Adapter/Libmemcached.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session\Adapter; /** * Phalcon\Session\Adapter\Libmemcached */ -class Libmemcached extends AbstractAdapter +class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter { /** @@ -17,4 +24,5 @@ class Libmemcached extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/session/adapter/Noop.php b/src/Phalcon/Session/Adapter/Noop.php similarity index 89% rename from src/Phalcon/session/adapter/Noop.php rename to src/Phalcon/Session/Adapter/Noop.php index d324e104..d54c11b4 100644 --- a/src/Phalcon/session/adapter/Noop.php +++ b/src/Phalcon/Session/Adapter/Noop.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session\Adapter; /** @@ -126,4 +133,5 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } + } diff --git a/src/Phalcon/session/adapter/Redis.php b/src/Phalcon/Session/Adapter/Redis.php similarity index 53% rename from src/Phalcon/session/adapter/Redis.php rename to src/Phalcon/Session/Adapter/Redis.php index 12df0d78..d13b86c4 100644 --- a/src/Phalcon/session/adapter/Redis.php +++ b/src/Phalcon/Session/Adapter/Redis.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session\Adapter; /** * Phalcon\Session\Adapter\Redis */ -class Redis extends AbstractAdapter +class Redis extends \Phalcon\Session\Adapter\AbstractAdapter { /** @@ -17,4 +24,5 @@ class Redis extends AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/session/adapter/Stream.php b/src/Phalcon/Session/Adapter/Stream.php similarity index 85% rename from src/Phalcon/session/adapter/Stream.php rename to src/Phalcon/Session/Adapter/Stream.php index 8ab1e0bf..27ab090d 100644 --- a/src/Phalcon/session/adapter/Stream.php +++ b/src/Phalcon/Session/Adapter/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session\Adapter; /** @@ -56,9 +63,9 @@ public function gc($maxlifetime): bool /** * Ignore the savePath and use local defined path * + * @return bool * @param mixed $savePath * @param mixed $sessionName - * @return bool */ public function open($savePath, $sessionName): bool { @@ -80,4 +87,5 @@ public function read($id): string public function write($id, $data): bool { } + } diff --git a/src/Phalcon/session/Bag.php b/src/Phalcon/Session/Bag.php similarity index 81% rename from src/Phalcon/session/Bag.php rename to src/Phalcon/Session/Bag.php index 14ae6175..09309bbb 100644 --- a/src/Phalcon/session/Bag.php +++ b/src/Phalcon/Session/Bag.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session; use Phalcon\Collection; @@ -42,6 +49,8 @@ public function __construct(string $name) /** * Destroys the session bag + * + * @return void */ public function clear() { @@ -50,7 +59,7 @@ public function clear() /** * Returns the DependencyInjector container * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public function getDI(): DiInterface { @@ -60,6 +69,7 @@ public function getDI(): DiInterface * Removes a property from the internal bag * * @param array $data + * @return void */ public function init(array $data = array()) { @@ -69,6 +79,7 @@ public function init(array $data = array()) * Removes a property from the internal bag * * @param string $element + * @return void */ public function remove(string $element) { @@ -79,6 +90,7 @@ public function remove(string $element) * * @param string $element * @param mixed $value + * @return void */ public function set(string $element, $value) { @@ -88,8 +100,10 @@ public function set(string $element, $value) * Sets the DependencyInjector container * * @param \Phalcon\Di\DiInterface $container + * @return void */ public function setDI(\Phalcon\Di\DiInterface $container) { } + } diff --git a/src/Phalcon/Session/Exception.php b/src/Phalcon/Session/Exception.php new file mode 100644 index 00000000..5a48add9 --- /dev/null +++ b/src/Phalcon/Session/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Session; + +/** + * Phalcon\Session\Exception + * + * Exceptions thrown in Phalcon\Session will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/session/Manager.php b/src/Phalcon/Session/Manager.php similarity index 88% rename from src/Phalcon/session/Manager.php rename to src/Phalcon/Session/Manager.php index 83df12cc..14b80655 100644 --- a/src/Phalcon/session/Manager.php +++ b/src/Phalcon/Session/Manager.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session; use InvalidArgumentException; @@ -11,7 +18,7 @@ * * Session manager class */ -class Manager extends AbstractInjectionAware implements \Phalcon\Session\ManagerInterface +class Manager extends AbstractInjectionAware implements Phalcon\Session\ManagerInterface { /** * @var SessionHandlerInterface|null @@ -68,6 +75,7 @@ public function __isset(string $key): bool * * @param string $key * @param mixed $value + * @return void */ public function __set(string $key, $value) { @@ -77,6 +85,7 @@ public function __set(string $key, $value) * Alias: Removes a session variable from an application context * * @param string $key + * @return void */ public function __unset(string $key) { @@ -84,6 +93,8 @@ public function __unset(string $key) /** * Destroy/end a session + * + * @return void */ public function destroy() { @@ -113,7 +124,7 @@ public function get(string $key, $defaultValue = null, bool $remove = false) /** * Returns the stored session adapter * - * @return \SessionHandlerInterface + * @return SessionHandlerInterface */ public function getAdapter(): SessionHandlerInterface { @@ -160,7 +171,7 @@ public function getOptions(): array * Regenerates the session id using the adapter. * * @param mixed $deleteOldSession - * @return \Phalcon\Session\ManagerInterface + * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface { @@ -170,6 +181,7 @@ public function regenerateId($deleteOldSession = true): ManagerInterface * Removes a session variable from an application context * * @param string $key + * @return void */ public function remove(string $key) { @@ -180,6 +192,7 @@ public function remove(string $key) * * @param string $key * @param mixed $value + * @return void */ public function set(string $key, $value) { @@ -189,7 +202,7 @@ public function set(string $key, $value) * Set the adapter for the session * * @param \SessionHandlerInterface $adapter - * @return \Phalcon\Session\ManagerInterface + * @return ManagerInterface */ public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface { @@ -199,7 +212,7 @@ public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface * Set session Id * * @param string $id - * @return \Phalcon\Session\ManagerInterface + * @return ManagerInterface */ public function setId(string $id): ManagerInterface { @@ -210,9 +223,9 @@ public function setId(string $id): ManagerInterface * and do not allow poop names * * @param string $name * - * @return Manager * @throws InvalidArgumentException * + * @return Manager */ public function setName(string $name): ManagerInterface { @@ -222,6 +235,7 @@ public function setName(string $name): ManagerInterface * Sets session's options * * @param array $options + * @return void */ public function setOptions(array $options) { @@ -255,4 +269,5 @@ public function status(): int private function getUniqueKey(string $key): string { } + } diff --git a/src/Phalcon/session/ManagerInterface.php b/src/Phalcon/Session/ManagerInterface.php similarity index 90% rename from src/Phalcon/session/ManagerInterface.php rename to src/Phalcon/Session/ManagerInterface.php index 2d0e35b5..c3d76dfb 100644 --- a/src/Phalcon/session/ManagerInterface.php +++ b/src/Phalcon/Session/ManagerInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Session; use InvalidArgumentException; @@ -43,6 +50,7 @@ public function __isset(string $key): bool; * * @param string $key * @param mixed $value + * @return void */ public function __set(string $key, $value); @@ -50,6 +58,7 @@ public function __set(string $key, $value); * Alias: Removes a session variable from an application context * * @param string $key + * @return void */ public function __unset(string $key); @@ -62,6 +71,8 @@ public function exists(): bool; /** * Destroy/end a session + * + * @return void */ public function destroy(); @@ -85,7 +96,7 @@ public function getId(): string; /** * Returns the stored session adapter * - * @return \SessionHandlerInterface + * @return SessionHandlerInterface */ public function getAdapter(): SessionHandlerInterface; @@ -115,6 +126,7 @@ public function has(string $key): bool; * Removes a session variable from an application context * * @param string $key + * @return void */ public function remove(string $key); @@ -123,6 +135,7 @@ public function remove(string $key); * * @param string $key * @param mixed $value + * @return void */ public function set(string $key, $value); @@ -146,9 +159,9 @@ public function setId(string $id): ManagerInterface; * Set the session name. Throw exception if the session has started * and do not allow poop names * + * @throws InvalidArgumentException * @param string $name * @return ManagerInterface - * @throws InvalidArgumentException */ public function setName(string $name): ManagerInterface; @@ -156,6 +169,7 @@ public function setName(string $name): ManagerInterface; * Sets session's options * * @param array $options + * @return void */ public function setOptions(array $options); @@ -181,4 +195,5 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; + } diff --git a/src/Phalcon/storage/adapter/AbstractAdapter.php b/src/Phalcon/Storage/Adapter/AbstractAdapter.php similarity index 92% rename from src/Phalcon/storage/adapter/AbstractAdapter.php rename to src/Phalcon/Storage/Adapter/AbstractAdapter.php index 94256425..29865491 100644 --- a/src/Phalcon/storage/adapter/AbstractAdapter.php +++ b/src/Phalcon/Storage/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; use DateInterval; @@ -15,7 +22,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Storage\Adapter\AdapterInterface { /** * @var mixed @@ -209,8 +216,11 @@ protected function getUnserializedData($content, $defaultValue = null) /** * Initializes the serializer + * + * @return void */ protected function initSerializer() { } + } diff --git a/src/Phalcon/storage/adapter/AdapterInterface.php b/src/Phalcon/Storage/Adapter/AdapterInterface.php similarity index 88% rename from src/Phalcon/storage/adapter/AdapterInterface.php rename to src/Phalcon/Storage/Adapter/AdapterInterface.php index 5e182da4..5386c52a 100644 --- a/src/Phalcon/storage/adapter/AdapterInterface.php +++ b/src/Phalcon/Storage/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; /** @@ -88,4 +95,5 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; + } diff --git a/src/Phalcon/storage/adapter/Apcu.php b/src/Phalcon/Storage/Adapter/Apcu.php similarity index 79% rename from src/Phalcon/storage/adapter/Apcu.php rename to src/Phalcon/Storage/Adapter/Apcu.php index 48c4b88b..a083f819 100644 --- a/src/Phalcon/storage/adapter/Apcu.php +++ b/src/Phalcon/Storage/Adapter/Apcu.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; /** * Apcu adapter */ -class Apcu extends AbstractAdapter +class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter { /** * @var array @@ -36,7 +43,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -59,7 +66,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed */ @@ -68,10 +75,9 @@ public function get(string $key, $defaultValue = null) } /** - * Returns the already connected adapter or connects to the Memcached - * server(s) + * Always returns null * - * @return mixed + * @return null */ public function getAdapter() { @@ -101,7 +107,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -113,8 +119,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws \Exception @@ -122,4 +128,5 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/storage/adapter/Libmemcached.php b/src/Phalcon/Storage/Adapter/Libmemcached.php similarity index 85% rename from src/Phalcon/storage/adapter/Libmemcached.php rename to src/Phalcon/Storage/Adapter/Libmemcached.php index 0ea8caee..c044cea6 100644 --- a/src/Phalcon/storage/adapter/Libmemcached.php +++ b/src/Phalcon/Storage/Adapter/Libmemcached.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; use Phalcon\Storage\Exception; @@ -7,7 +14,7 @@ /** * Libmemcached adapter */ -class Libmemcached extends AbstractAdapter +class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter { /** * @var array @@ -62,7 +69,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed * @throws Exception @@ -108,7 +115,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -121,8 +128,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws Exception @@ -140,4 +147,5 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Memcached $connection) { } + } diff --git a/src/Phalcon/storage/adapter/Memory.php b/src/Phalcon/Storage/Adapter/Memory.php similarity index 80% rename from src/Phalcon/storage/adapter/Memory.php rename to src/Phalcon/Storage/Adapter/Memory.php index 10c77db9..76a40139 100644 --- a/src/Phalcon/storage/adapter/Memory.php +++ b/src/Phalcon/Storage/Adapter/Memory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; use Phalcon\Collection; @@ -7,7 +14,7 @@ /** * Memory adapter */ -class Memory extends AbstractAdapter +class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter { /** * @var Collection @@ -43,7 +50,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -65,7 +72,7 @@ public function delete(string $key): bool /** * Reads data from the adapter * - * @param string $key + * @param string $key * @param mixed|null $defaultValue * * @return mixed @@ -75,10 +82,9 @@ public function get(string $key, $defaultValue = null) } /** - * Returns the already connected adapter or connects to the Memcached - * server(s) + * Always returns null * - * @return mixed + * @return null */ public function getAdapter() { @@ -108,7 +114,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int */ @@ -120,12 +126,13 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool */ public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/storage/adapter/Redis.php b/src/Phalcon/Storage/Adapter/Redis.php similarity index 84% rename from src/Phalcon/storage/adapter/Redis.php rename to src/Phalcon/Storage/Adapter/Redis.php index e110d1a2..94f266ec 100644 --- a/src/Phalcon/storage/adapter/Redis.php +++ b/src/Phalcon/Storage/Adapter/Redis.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; use Phalcon\Storage\Exception; @@ -7,7 +14,7 @@ /** * Redis adapter */ -class Redis extends AbstractAdapter +class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter { /** * @var array @@ -39,7 +46,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -64,7 +71,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed * @throws Exception @@ -74,7 +81,7 @@ public function get(string $key, $defaultValue = null) } /** - * Returns the already connected adapter or connects to the Memcached + * Returns the already connected adapter or connects to the Redis * server(s) * * @return mixed|\Redis @@ -110,7 +117,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws Exception @@ -123,8 +130,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws Exception @@ -142,4 +149,5 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } + } diff --git a/src/Phalcon/storage/adapter/Stream.php b/src/Phalcon/Storage/Adapter/Stream.php similarity index 86% rename from src/Phalcon/storage/adapter/Stream.php rename to src/Phalcon/Storage/Adapter/Stream.php index 6279bd5e..7a36572d 100644 --- a/src/Phalcon/storage/adapter/Stream.php +++ b/src/Phalcon/Storage/Adapter/Stream.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Adapter; use Iterator; @@ -8,7 +15,7 @@ /** * Stream adapter */ -class Stream extends AbstractAdapter +class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter { /** * @var string @@ -31,8 +38,8 @@ class Stream extends AbstractAdapter * * @param array $options * - * @param \Phalcon\Storage\SerializerFactory $factory * @throws Exception + * @param \Phalcon\Storage\SerializerFactory $factory */ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) { @@ -51,7 +58,7 @@ public function clear(): bool * Decrements a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws \Exception @@ -75,7 +82,7 @@ public function delete(string $key): bool * Reads data from the adapter * * @param string $key - * @param null $defaultValue + * @param null $defaultValue * * @return mixed|null */ @@ -84,10 +91,9 @@ public function get(string $key, $defaultValue = null) } /** - * Returns the already connected adapter or connects to the Memcached - * server(s) + * Always returns null * - * @return mixed + * @return null */ public function getAdapter() { @@ -117,7 +123,7 @@ public function has(string $key): bool * Increments a stored number * * @param string $key - * @param int $value + * @param int $value * * @return bool|int * @throws \Exception @@ -130,8 +136,8 @@ public function increment(string $key, int $value = 1) * Stores data in the adapter * * @param string $key - * @param mixed $value - * @param null $ttl + * @param mixed $value + * @param null $ttl * * @return bool * @throws \Exception @@ -165,7 +171,7 @@ private function getFilepath(string $key): string * Returns an iterator for the directory contents * * @param string $dir - * @return \Iterator + * @return Iterator */ private function getIterator(string $dir): Iterator { @@ -192,4 +198,5 @@ private function getPayload(string $filepath): array private function isExpired(array $payload): bool { } + } diff --git a/src/Phalcon/storage/AdapterFactory.php b/src/Phalcon/Storage/AdapterFactory.php similarity index 69% rename from src/Phalcon/storage/AdapterFactory.php rename to src/Phalcon/Storage/AdapterFactory.php index dd7887d1..4d0d1ed7 100644 --- a/src/Phalcon/storage/AdapterFactory.php +++ b/src/Phalcon/Storage/AdapterFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage; use Phalcon\Factory\AbstractFactory; @@ -24,10 +31,10 @@ class AdapterFactory extends AbstractFactory /** * AdapterFactory constructor. * - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory * @param array $services */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) + public function __construct(SerializerFactory $factory = null, array $services = array()) { } @@ -36,7 +43,7 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, * * @param string $name * @param array $options - * @return \Phalcon\Storage\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface { @@ -48,4 +55,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Storage/Exception.php b/src/Phalcon/Storage/Exception.php new file mode 100644 index 00000000..8026ddee --- /dev/null +++ b/src/Phalcon/Storage/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Storage; + +/** + * Phalcon\Storage\Exception + * + * Exceptions thrown in Phalcon\Storage will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/storage/serializer/AbstractSerializer.php b/src/Phalcon/Storage/Serializer/AbstractSerializer.php similarity index 71% rename from src/Phalcon/storage/serializer/AbstractSerializer.php rename to src/Phalcon/Storage/Serializer/AbstractSerializer.php index 205118eb..013336c7 100644 --- a/src/Phalcon/storage/serializer/AbstractSerializer.php +++ b/src/Phalcon/Storage/Serializer/AbstractSerializer.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface +abstract class AbstractSerializer implements Phalcon\Storage\Serializer\SerializerInterface { /** * @var mixed @@ -46,8 +53,10 @@ public function getData() /** * @param mixed $data + * @return void */ public function setData($data) { } + } diff --git a/src/Phalcon/storage/serializer/Base64.php b/src/Phalcon/Storage/Serializer/Base64.php similarity index 62% rename from src/Phalcon/storage/serializer/Base64.php rename to src/Phalcon/Storage/Serializer/Base64.php index ac8ebb63..f87ef760 100644 --- a/src/Phalcon/storage/serializer/Base64.php +++ b/src/Phalcon/Storage/Serializer/Base64.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Base64 extends AbstractSerializer +class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/Igbinary.php b/src/Phalcon/Storage/Serializer/Igbinary.php similarity index 62% rename from src/Phalcon/storage/serializer/Igbinary.php rename to src/Phalcon/Storage/Serializer/Igbinary.php index 5ae29919..975beca9 100644 --- a/src/Phalcon/storage/serializer/Igbinary.php +++ b/src/Phalcon/Storage/Serializer/Igbinary.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Igbinary extends AbstractSerializer +class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/Json.php b/src/Phalcon/Storage/Serializer/Json.php similarity index 62% rename from src/Phalcon/storage/serializer/Json.php rename to src/Phalcon/Storage/Serializer/Json.php index 98601157..bcff273e 100644 --- a/src/Phalcon/storage/serializer/Json.php +++ b/src/Phalcon/Storage/Serializer/Json.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Json extends AbstractSerializer +class Json extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/Msgpack.php b/src/Phalcon/Storage/Serializer/Msgpack.php similarity index 62% rename from src/Phalcon/storage/serializer/Msgpack.php rename to src/Phalcon/Storage/Serializer/Msgpack.php index 7b5cc9f0..65fb50a4 100644 --- a/src/Phalcon/storage/serializer/Msgpack.php +++ b/src/Phalcon/Storage/Serializer/Msgpack.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Msgpack extends AbstractSerializer +class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): ?string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/None.php b/src/Phalcon/Storage/Serializer/None.php similarity index 62% rename from src/Phalcon/storage/serializer/None.php rename to src/Phalcon/Storage/Serializer/None.php index 4887eb92..b7eb3f6e 100644 --- a/src/Phalcon/storage/serializer/None.php +++ b/src/Phalcon/Storage/Serializer/None.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class None extends AbstractSerializer +class None extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/Php.php b/src/Phalcon/Storage/Serializer/Php.php similarity index 62% rename from src/Phalcon/storage/serializer/Php.php rename to src/Phalcon/Storage/Serializer/Php.php index 07a289c5..d261cf4a 100644 --- a/src/Phalcon/storage/serializer/Php.php +++ b/src/Phalcon/Storage/Serializer/Php.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Php extends AbstractSerializer +class Php extends \Phalcon\Storage\Serializer\AbstractSerializer { /** @@ -26,8 +33,10 @@ public function serialize(): string * Unserializes data * * @param mixed $data + * @return void */ public function unserialize($data) { } + } diff --git a/src/Phalcon/storage/serializer/SerializerInterface.php b/src/Phalcon/Storage/Serializer/SerializerInterface.php similarity index 66% rename from src/Phalcon/storage/serializer/SerializerInterface.php rename to src/Phalcon/Storage/Serializer/SerializerInterface.php index e70bde5d..0eff6249 100644 --- a/src/Phalcon/storage/serializer/SerializerInterface.php +++ b/src/Phalcon/Storage/Serializer/SerializerInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage\Serializer; /** @@ -20,6 +27,8 @@ public function getData(); /** * @param mixed $data + * @return void */ public function setData($data); + } diff --git a/src/Phalcon/storage/SerializerFactory.php b/src/Phalcon/Storage/SerializerFactory.php similarity index 78% rename from src/Phalcon/storage/SerializerFactory.php rename to src/Phalcon/Storage/SerializerFactory.php index a2d1ccd9..bf753855 100644 --- a/src/Phalcon/storage/SerializerFactory.php +++ b/src/Phalcon/Storage/SerializerFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Storage; use Phalcon\Factory\AbstractFactory; @@ -40,4 +47,5 @@ public function newInstance(string $name): SerializerInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index c4b1e65b..e7b4be90 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\DiInterface; @@ -47,46 +54,47 @@ class Tag const XHTML5 = 11; - protected static $autoEscape = true; + static protected $autoEscape = true; /** * DI Container */ - protected static $container; + static protected $container; /** * Pre-assigned values for components */ - protected static $displayValues; + static protected $displayValues; - protected static $documentAppendTitle = null; + static protected $documentAppendTitle = null; - protected static $documentPrependTitle = null; + static protected $documentPrependTitle = null; /** * HTML document title */ - protected static $documentTitle = null; + static protected $documentTitle = null; - protected static $documentTitleSeparator = null; + static protected $documentTitleSeparator = null; - protected static $documentType = 11; + static protected $documentType = 11; - protected static $escaperService = null; + static protected $escaperService = null; - protected static $urlService = null; + static protected $urlService = null; /** * Appends a text to current document title * * @param mixed $title + * @return void */ public static function appendTitle($title) { @@ -147,6 +155,7 @@ public static function dateTimeLocalField($parameters): string * * @param string $id * @param mixed $value + * @return void */ public static function displayTo(string $id, $value) { @@ -217,7 +226,7 @@ public static function getDocType(): string * Obtains the 'escaper' service if required * * @param array $params - * @return null|\Phalcon\Escaper\EscaperInterface + * @return mixed */ public static function getEscaper(array $params): ?EscaperInterface { @@ -226,7 +235,7 @@ public static function getEscaper(array $params): ?EscaperInterface /** * Internally gets the request dispatcher * - * @return \Phalcon\Di\DiInterface + * @return DiInterface */ public static function getDI(): DiInterface { @@ -235,7 +244,7 @@ public static function getDI(): DiInterface /** * Returns an Escaper service from the default DI * - * @return \Phalcon\Escaper\EscaperInterface + * @return EscaperInterface */ public static function getEscaperService(): EscaperInterface { @@ -264,7 +273,7 @@ public static function getTitleSeparator(): string /** * Returns a URL service from the default DI * - * @return \Phalcon\Url\UrlInterface + * @return UrlInterface */ public static function getUrlService(): UrlInterface { @@ -380,6 +389,7 @@ public static function passwordField($parameters): string * Prepends a text to current document title * * @param mixed $title + * @return void */ public static function prependTitle($title) { @@ -433,6 +443,7 @@ public static function renderTitle(bool $prepend = true, bool $append = true): s * * @deprecated Will be removed in 4.0.0 * @deprecated + * @return void */ public static function resetInput() { @@ -474,6 +485,7 @@ public static function selectStatic($parameters, $data = null): string * Set autoescape mode in generated html * * @param bool $autoescape + * @return void */ public static function setAutoescape(bool $autoescape) { @@ -484,6 +496,7 @@ public static function setAutoescape(bool $autoescape) * * @param string $id * @param mixed $value + * @return void */ public static function setDefault(string $id, $value) { @@ -494,6 +507,7 @@ public static function setDefault(string $id, $value) * * @param array $values * @param bool $merge + * @return void */ public static function setDefaults(array $values, bool $merge = false) { @@ -503,6 +517,7 @@ public static function setDefaults(array $values, bool $merge = false) * Sets the dependency injector container. * * @param \Phalcon\Di\DiInterface $container + * @return void */ public static function setDI(\Phalcon\Di\DiInterface $container) { @@ -512,6 +527,7 @@ public static function setDI(\Phalcon\Di\DiInterface $container) * Set the document type of content * * @param int $doctype + * @return void */ public static function setDocType(int $doctype) { @@ -521,6 +537,7 @@ public static function setDocType(int $doctype) * Set the title of view content * * @param string $title + * @return void */ public static function setTitle(string $title) { @@ -530,6 +547,7 @@ public static function setTitle(string $title) * Set the title separator of view content * * @param string $titleSeparator + * @return void */ public static function setTitleSeparator(string $titleSeparator) { @@ -649,7 +667,7 @@ public static function weekField($parameters): string * @param bool $asValue * @return string */ - final protected static function inputField(string $type, $parameters, bool $asValue = false): string + static final protected function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -660,7 +678,8 @@ final protected static function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - final protected static function inputFieldChecked(string $type, $parameters): string + static final protected function inputFieldChecked(string $type, $parameters): string { } + } diff --git a/src/Phalcon/Tag/Exception.php b/src/Phalcon/Tag/Exception.php new file mode 100644 index 00000000..2a322cc7 --- /dev/null +++ b/src/Phalcon/Tag/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Tag; + +/** + * Phalcon\Tag\Exception + * + * Exceptions thrown in Phalcon\Tag will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/tag/Select.php b/src/Phalcon/Tag/Select.php similarity index 82% rename from src/Phalcon/tag/Select.php rename to src/Phalcon/Tag/Select.php index 4d7fbcef..6b650d24 100644 --- a/src/Phalcon/tag/Select.php +++ b/src/Phalcon/Tag/Select.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Tag; /** @@ -46,4 +53,5 @@ private static function optionsFromArray(array $data, $value, string $closeOptio private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string { } + } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index e5971794..f72cf7b1 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -269,4 +276,5 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/translate/adapter/AbstractAdapter.php b/src/Phalcon/Translate/Adapter/AbstractAdapter.php similarity index 85% rename from src/Phalcon/translate/adapter/AbstractAdapter.php rename to src/Phalcon/Translate/Adapter/AbstractAdapter.php index 61eb811a..4fbfa7a0 100644 --- a/src/Phalcon/translate/adapter/AbstractAdapter.php +++ b/src/Phalcon/Translate/Adapter/AbstractAdapter.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Adapter; use Phalcon\Translate\InterpolatorFactory; @@ -9,7 +16,7 @@ * * Base class for Phalcon\Translate adapters */ -abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInterface +abstract class AbstractAdapter implements Phalcon\Translate\Adapter\AdapterInterface { /** * @var string @@ -66,6 +73,7 @@ public function offsetGet($translateKey) * * @param string $value * @param mixed $offset + * @return void */ public function offsetSet($offset, $value) { @@ -75,6 +83,7 @@ public function offsetSet($offset, $value) * Unsets a translation from the dictionary * * @param mixed $offset + * @return void */ public function offsetUnset($offset) { @@ -101,4 +110,5 @@ public function t(string $translateKey, array $placeholders = array()): string protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/translate/adapter/AdapterInterface.php b/src/Phalcon/Translate/Adapter/AdapterInterface.php similarity index 79% rename from src/Phalcon/translate/adapter/AdapterInterface.php rename to src/Phalcon/Translate/Adapter/AdapterInterface.php index d3e246e6..a452d6c3 100644 --- a/src/Phalcon/translate/adapter/AdapterInterface.php +++ b/src/Phalcon/Translate/Adapter/AdapterInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Adapter; /** @@ -35,4 +42,5 @@ public function query(string $translateKey, array $placeholders = array()): stri * @return string */ public function t(string $translateKey, array $placeholders = array()): string; + } diff --git a/src/Phalcon/translate/adapter/Csv.php b/src/Phalcon/Translate/Adapter/Csv.php similarity index 78% rename from src/Phalcon/translate/adapter/Csv.php rename to src/Phalcon/Translate/Adapter/Csv.php index 42cf4523..db6a9aa3 100644 --- a/src/Phalcon/translate/adapter/Csv.php +++ b/src/Phalcon/Translate/Adapter/Csv.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Adapter; /** @@ -7,7 +14,7 @@ * * Allows to define translation lists using CSV file */ -class Csv extends AbstractAdapter implements \ArrayAccess +class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { /** * @var array @@ -53,8 +60,10 @@ public function query(string $index, array $placeholders = array()): string * @param int $length * @param string $delimiter * @param string $enclosure + * @return void */ private function load(string $file, int $length, string $delimiter, string $enclosure) { } + } diff --git a/src/Phalcon/translate/adapter/Gettext.php b/src/Phalcon/Translate/Adapter/Gettext.php similarity index 91% rename from src/Phalcon/translate/adapter/Gettext.php rename to src/Phalcon/Translate/Adapter/Gettext.php index 9c4cfd96..1c8efb28 100644 --- a/src/Phalcon/translate/adapter/Gettext.php +++ b/src/Phalcon/Translate/Adapter/Gettext.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Adapter; /** @@ -20,7 +27,7 @@ * * Allows translate using gettext */ -class Gettext extends AbstractAdapter implements \ArrayAccess +class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { /** * @var int @@ -135,6 +142,7 @@ public function resetDomain(): string * Sets the domain default to search within when calls are made to gettext() * * @param string $domain + * @return void */ public function setDefaultDomain(string $domain) { @@ -157,6 +165,7 @@ public function setDefaultDomain(string $domain) * ``` * * @param string|array $directory The directory path or an array of directories and domains + * @return void */ public function setDirectory($directory) { @@ -204,8 +213,10 @@ protected function getOptionsDefault(): array * Validator for constructor * * @param array $options + * @return void */ protected function prepareOptions(array $options) { } + } diff --git a/src/Phalcon/translate/adapter/NativeArray.php b/src/Phalcon/Translate/Adapter/NativeArray.php similarity index 79% rename from src/Phalcon/translate/adapter/NativeArray.php rename to src/Phalcon/Translate/Adapter/NativeArray.php index b61536af..efe9f26a 100644 --- a/src/Phalcon/translate/adapter/NativeArray.php +++ b/src/Phalcon/Translate/Adapter/NativeArray.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Adapter; /** @@ -7,7 +14,7 @@ * * Allows to define translation lists using PHP arrays */ -class NativeArray extends AbstractAdapter implements \ArrayAccess +class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess { /** * @var array @@ -60,4 +67,5 @@ public function notFound(string $index): string public function query(string $index, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/Translate/Exception.php b/src/Phalcon/Translate/Exception.php new file mode 100644 index 00000000..2c13440f --- /dev/null +++ b/src/Phalcon/Translate/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Translate; + +/** + * Phalcon\Translate\Exception + * + * Class for exceptions thrown by Phalcon\Translate + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/AssociativeArray.php new file mode 100644 index 00000000..72c95433 --- /dev/null +++ b/src/Phalcon/Translate/Interpolator/AssociativeArray.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Translate\Interpolator; + +/** + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +class AssociativeArray implements Phalcon\Translate\Interpolator\InterpolatorInterface +{ + + /** + * Replaces placeholders by the values passed + * + * @param string $translation + * @param array $placeholders + * @return string + */ + public function replacePlaceholders(string $translation, array $placeholders = array()): string + { + } + +} diff --git a/src/Phalcon/translate/interpolator/IndexedArray.php b/src/Phalcon/Translate/Interpolator/IndexedArray.php similarity index 64% rename from src/Phalcon/translate/interpolator/IndexedArray.php rename to src/Phalcon/Translate/Interpolator/IndexedArray.php index d1bf80ab..fd69b8fe 100644 --- a/src/Phalcon/translate/interpolator/IndexedArray.php +++ b/src/Phalcon/Translate/Interpolator/IndexedArray.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate\Interpolator; /** @@ -10,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface +class IndexedArray implements Phalcon\Translate\Interpolator\InterpolatorInterface { /** @@ -23,4 +30,5 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf public function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/translate/interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php similarity index 68% rename from src/Phalcon/translate/interpolator/AssociativeArray.php rename to src/Phalcon/Translate/Interpolator/InterpolatorInterface.php index f38fa2ff..157fa7b4 100644 --- a/src/Phalcon/translate/interpolator/AssociativeArray.php +++ b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php @@ -1,16 +1,20 @@ * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface +namespace Phalcon\Translate\Interpolator; + +/** + * Phalcon\Translate\InterpolatorInterface + * + * Interface for Phalcon\Translate interpolators + */ +interface InterpolatorInterface { /** @@ -20,7 +24,6 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn * @param array $placeholders * @return string */ - public function replacePlaceholders(string $translation, array $placeholders = array()): string - { - } + public function replacePlaceholders(string $translation, array $placeholders = array()): string; + } diff --git a/src/Phalcon/translate/InterpolatorFactory.php b/src/Phalcon/Translate/InterpolatorFactory.php similarity index 78% rename from src/Phalcon/translate/InterpolatorFactory.php rename to src/Phalcon/Translate/InterpolatorFactory.php index 2b8f0d68..d5894d24 100644 --- a/src/Phalcon/translate/InterpolatorFactory.php +++ b/src/Phalcon/Translate/InterpolatorFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate; use Phalcon\Factory\AbstractFactory; @@ -39,7 +46,7 @@ public function __construct(array $services = array()) * Create a new instance of the adapter * * @param string $name - * @return \Phalcon\Translate\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name): AdapterInterface { @@ -51,4 +58,5 @@ public function newInstance(string $name): AdapterInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/translate/TranslateFactory.php b/src/Phalcon/Translate/TranslateFactory.php similarity index 72% rename from src/Phalcon/translate/TranslateFactory.php rename to src/Phalcon/Translate/TranslateFactory.php index bb89fff5..e91e5a02 100644 --- a/src/Phalcon/translate/TranslateFactory.php +++ b/src/Phalcon/Translate/TranslateFactory.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Translate; use Phalcon\Factory\AbstractFactory; @@ -24,10 +31,10 @@ class TranslateFactory extends AbstractFactory /** * AdapterFactory constructor. * - * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param InterpolatorFactory $interpolator * @param array $services */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $services = array()) + public function __construct(InterpolatorFactory $interpolator, array $services = array()) { } @@ -46,7 +53,7 @@ public function load($config) * * @param string $name * @param array $options - * @return \Phalcon\Translate\Adapter\AdapterInterface + * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface { @@ -58,4 +65,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index b5786583..c29f8ac4 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\AbstractInjectionAware; @@ -153,7 +160,7 @@ public function getStaticBaseUri(): string * ``` * * @param string $basePath - * @return \Phalcon\Url\UrlInterface + * @return UrlInterface */ public function setBasePath(string $basePath): UrlInterface { @@ -169,7 +176,7 @@ public function setBasePath(string $basePath): UrlInterface * ``` * * @param string $baseUri - * @return \Phalcon\Url\UrlInterface + * @return UrlInterface */ public function setBaseUri(string $baseUri): UrlInterface { @@ -183,7 +190,7 @@ public function setBaseUri(string $baseUri): UrlInterface * ``` * * @param string $staticBaseUri - * @return \Phalcon\Url\UrlInterface + * @return UrlInterface */ public function setStaticBaseUri(string $staticBaseUri): UrlInterface { @@ -198,4 +205,5 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } + } diff --git a/src/Phalcon/Url/Exception.php b/src/Phalcon/Url/Exception.php new file mode 100644 index 00000000..6e425288 --- /dev/null +++ b/src/Phalcon/Url/Exception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Url; + +/** + * Phalcon\Url\Exception + * + * Exceptions thrown in Phalcon\Url will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/url/UrlInterface.php b/src/Phalcon/Url/UrlInterface.php similarity index 84% rename from src/Phalcon/url/UrlInterface.php rename to src/Phalcon/Url/UrlInterface.php index c7d6b3a6..7f5c8764 100644 --- a/src/Phalcon/url/UrlInterface.php +++ b/src/Phalcon/Url/UrlInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Url; /** @@ -55,4 +62,5 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; + } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index 99644012..103cea19 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; use Phalcon\Di\Injectable; @@ -36,6 +43,7 @@ class Validation extends Injectable implements \Phalcon\Validation\ValidationInt protected $values; + public function getData() { } @@ -61,7 +69,7 @@ public function __construct(array $validators = array()) * * @param mixed $field * @param \Phalcon\Validation\ValidatorInterface $validator - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface { @@ -71,7 +79,7 @@ public function add($field, \Phalcon\Validation\ValidatorInterface $validator): * Appends a message to the messages list * * @param \Phalcon\Messages\MessageInterface $message - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface { @@ -83,7 +91,7 @@ public function appendMessage(\Phalcon\Messages\MessageInterface $message): Vali * * @param object $entity * @param array|object $data - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function bind($entity, $data): ValidationInterface { @@ -121,7 +129,7 @@ public function getLabel($field): string /** * Returns the registered validators * - * @return \Phalcon\Messages\Messages + * @return Messages */ public function getMessages(): Messages { @@ -151,7 +159,7 @@ public function getValue(string $field) * * @param mixed $field * @param \Phalcon\Validation\ValidatorInterface $validator - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface { @@ -162,7 +170,7 @@ public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): * * @param mixed $field * @param array $validators - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function rules($field, array $validators): ValidationInterface { @@ -172,6 +180,7 @@ public function rules($field, array $validators): ValidationInterface * Sets the bound entity * * @param object $entity + * @return void */ public function setEntity($entity) { @@ -182,7 +191,7 @@ public function setEntity($entity) * * @param string $field * @param array|string $filters - * @return \Phalcon\Validation\ValidationInterface + * @return ValidationInterface */ public function setFilters($field, $filters): ValidationInterface { @@ -192,6 +201,7 @@ public function setFilters($field, $filters): ValidationInterface * Adds labels for fields * * @param array $labels + * @return void */ public function setLabels(array $labels) { @@ -202,7 +212,7 @@ public function setLabels(array $labels) * * @param array|object $data * @param object $entity - * @return \Phalcon\Messages\Messages + * @return Messages */ public function validate($data = null, $entity = null): Messages { @@ -218,4 +228,5 @@ public function validate($data = null, $entity = null): Messages protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool { } + } diff --git a/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php b/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php new file mode 100644 index 00000000..f75e0a48 --- /dev/null +++ b/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Validation; + +/** + * This is a base class for combined fields validators + */ +abstract class AbstractCombinedFieldsValidator extends \Phalcon\Validation\AbstractValidator +{ + +} diff --git a/src/Phalcon/validation/AbstractValidator.php b/src/Phalcon/Validation/AbstractValidator.php similarity index 90% rename from src/Phalcon/validation/AbstractValidator.php rename to src/Phalcon/Validation/AbstractValidator.php index 1a0bc25b..6fe46703 100644 --- a/src/Phalcon/validation/AbstractValidator.php +++ b/src/Phalcon/Validation/AbstractValidator.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; use Phalcon\Messages\Message; @@ -7,7 +14,7 @@ /** * This is a base class for validators */ -abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface +abstract class AbstractValidator implements Phalcon\Validation\ValidatorInterface { /** * Message template @@ -39,9 +46,9 @@ public function __construct(array $options = array()) /** * Get the template message * - * @param string $field * @return string * @throw InvalidArgumentException When the field does not exists + * @param string $field */ public function getTemplate(string $field = null): string { @@ -59,8 +66,8 @@ public function getTemplates(): array /** * Clear current templates and set new from an array, * - * @param array $templates * @return ValidatorInterface + * @param array $templates */ public function setTemplates(array $templates): ValidatorInterface { @@ -69,8 +76,8 @@ public function setTemplates(array $templates): ValidatorInterface /** * Set a new template message * - * @param string $template * @return ValidatorInterface + * @param string $template */ public function setTemplate(string $template): ValidatorInterface { @@ -103,6 +110,7 @@ public function hasOption(string $key): bool * * @param string $key * @param mixed $value + * @return void */ public function setOption(string $key, $value) { @@ -141,14 +149,15 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) /** * Create a default message by factory * - * @param \Phalcon\Validation $validation - * @param mixed $field - * @param array $replacements * @return Message * * @throw Exception + * @param \Phalcon\Validation $validation + * @param mixed $field + * @param array $replacements */ public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message { } + } diff --git a/src/Phalcon/validation/AbstractValidatorComposite.php b/src/Phalcon/Validation/AbstractValidatorComposite.php similarity index 64% rename from src/Phalcon/validation/AbstractValidatorComposite.php rename to src/Phalcon/Validation/AbstractValidatorComposite.php index 842ec995..9488548f 100644 --- a/src/Phalcon/validation/AbstractValidatorComposite.php +++ b/src/Phalcon/Validation/AbstractValidatorComposite.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; /** * This is a base class for combined fields validators */ -abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements \Phalcon\Validation\ValidatorCompositeInterface +abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements Phalcon\Validation\ValidatorCompositeInterface { /** * @var array @@ -30,4 +37,5 @@ public function getValidators(): array public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Exception.php b/src/Phalcon/Validation/Exception.php new file mode 100644 index 00000000..44c0dce8 --- /dev/null +++ b/src/Phalcon/Validation/Exception.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Validation; + +/** + * Exceptions thrown in Phalcon\Validation\ classes will use this class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/validation/ValidationInterface.php b/src/Phalcon/Validation/ValidationInterface.php similarity index 82% rename from src/Phalcon/validation/ValidationInterface.php rename to src/Phalcon/Validation/ValidationInterface.php index 260f0862..e439e0d7 100644 --- a/src/Phalcon/validation/ValidationInterface.php +++ b/src/Phalcon/Validation/ValidationInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; use Phalcon\Messages\Messages; @@ -14,10 +21,10 @@ interface ValidationInterface * Adds a validator to a field * * @param string $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ValidationInterface */ - public function add(string $field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface; + public function add(string $field, ValidatorInterface $validator): ValidationInterface; /** * Appends a message to the messages list @@ -63,7 +70,7 @@ public function getLabel(string $field): string; /** * Returns the registered validators * - * @return \Phalcon\Messages\Messages + * @return Messages */ public function getMessages(): Messages; @@ -86,10 +93,10 @@ public function getValue(string $field); * Alias of `add` method * * @param string $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ValidationInterface */ - public function rule(string $field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface; + public function rule(string $field, ValidatorInterface $validator): ValidationInterface; /** * Adds the validators to a field @@ -113,6 +120,7 @@ public function setFilters(string $field, $filters): ValidationInterface; * Adds labels for fields * * @param array $labels + * @return void */ public function setLabels(array $labels); @@ -121,7 +129,8 @@ public function setLabels(array $labels); * * @param array|object $data * @param object $entity - * @return \Phalcon\Messages\Messages + * @return Messages */ public function validate($data = null, $entity = null): Messages; + } diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/Validation/Validator/Alnum.php similarity index 84% rename from src/Phalcon/validation/validator/Alnum.php rename to src/Phalcon/Validation/Validator/Alnum.php index c42de8bd..3bb554b6 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/Validation/Validator/Alnum.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Alnum extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/Validation/Validator/Alpha.php similarity index 83% rename from src/Phalcon/validation/validator/Alpha.php rename to src/Phalcon/Validation/Validator/Alpha.php index 890bd985..2c51c103 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/Validation/Validator/Alpha.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Alpha extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/Validation/Validator/Between.php similarity index 87% rename from src/Phalcon/validation/validator/Between.php rename to src/Phalcon/Validation/Validator/Between.php index 8c59ea02..3d26ffc8 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/Validation/Validator/Between.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -65,4 +72,5 @@ class Between extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/Validation/Validator/Callback.php similarity index 87% rename from src/Phalcon/validation/validator/Callback.php rename to src/Phalcon/Validation/Validator/Callback.php index d9ed74af..24ea5033 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/Validation/Validator/Callback.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -64,4 +71,5 @@ class Callback extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/Validation/Validator/Confirmation.php similarity index 87% rename from src/Phalcon/validation/validator/Confirmation.php rename to src/Phalcon/Validation/Validator/Confirmation.php index 294f6d93..c809f153 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/Validation/Validator/Confirmation.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -70,4 +77,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } + } diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/Validation/Validator/CreditCard.php similarity index 86% rename from src/Phalcon/validation/validator/CreditCard.php rename to src/Phalcon/Validation/Validator/CreditCard.php index bfc588b7..4ab9bca6 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/Validation/Validator/CreditCard.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -65,4 +72,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } + } diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/Validation/Validator/Date.php similarity index 86% rename from src/Phalcon/validation/validator/Date.php rename to src/Phalcon/Validation/Validator/Date.php index 538b51c1..90d5e1f8 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/Validation/Validator/Date.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -68,4 +75,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } + } diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/Validation/Validator/Digit.php similarity index 82% rename from src/Phalcon/validation/validator/Digit.php rename to src/Phalcon/Validation/Validator/Digit.php index c09dc3cc..c1c90ce0 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/Validation/Validator/Digit.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Digit extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/Validation/Validator/Email.php similarity index 83% rename from src/Phalcon/validation/validator/Email.php rename to src/Phalcon/Validation/Validator/Email.php index 1b537ecb..53553bb3 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/Validation/Validator/Email.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Email extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Exception.php b/src/Phalcon/Validation/Validator/Exception.php new file mode 100644 index 00000000..d6afa040 --- /dev/null +++ b/src/Phalcon/Validation/Validator/Exception.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Validation\Validator; + +/** + * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this + * class + */ +class Exception extends \Phalcon\Exception +{ + +} diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/Validation/Validator/ExclusionIn.php similarity index 86% rename from src/Phalcon/validation/validator/ExclusionIn.php rename to src/Phalcon/Validation/Validator/ExclusionIn.php index 4933c82a..1f8c7823 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/Validation/Validator/ExclusionIn.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -65,4 +72,5 @@ class ExclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/Validation/Validator/File.php similarity index 91% rename from src/Phalcon/validation/validator/File.php rename to src/Phalcon/Validation/Validator/File.php index 9aef43c4..1a91d938 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/Validation/Validator/File.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidatorComposite; @@ -82,4 +89,5 @@ class File extends AbstractValidatorComposite public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/validation/validator/file/AbstractFile.php b/src/Phalcon/Validation/Validator/File/AbstractFile.php similarity index 94% rename from src/Phalcon/validation/validator/file/AbstractFile.php rename to src/Phalcon/Validation/Validator/File/AbstractFile.php index a787dddc..84a89418 100644 --- a/src/Phalcon/validation/validator/file/AbstractFile.php +++ b/src/Phalcon/Validation/Validator/File/AbstractFile.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File; use Phalcon\Validation; @@ -174,4 +181,5 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } + } diff --git a/src/Phalcon/validation/validator/file/MimeType.php b/src/Phalcon/Validation/Validator/File/MimeType.php similarity index 83% rename from src/Phalcon/validation/validator/file/MimeType.php rename to src/Phalcon/Validation/Validator/File/MimeType.php index 777c08be..ea84c5f9 100644 --- a/src/Phalcon/validation/validator/file/MimeType.php +++ b/src/Phalcon/Validation/Validator/File/MimeType.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File; use Phalcon\Validation; @@ -52,7 +59,7 @@ * ); * ``` */ -class MimeType extends AbstractFile +class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile { protected $template = 'File :field must be of type: :types'; @@ -68,4 +75,5 @@ class MimeType extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Equal.php b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php similarity index 86% rename from src/Phalcon/validation/validator/file/resolution/Equal.php rename to src/Phalcon/Validation/Validator/File/Resolution/Equal.php index 8c266d16..38bb7bec 100644 --- a/src/Phalcon/validation/validator/file/resolution/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Resolution; use Phalcon\Validation\Validator\File\AbstractFile; @@ -59,4 +66,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Max.php b/src/Phalcon/Validation/Validator/File/Resolution/Max.php similarity index 87% rename from src/Phalcon/validation/validator/file/resolution/Max.php rename to src/Phalcon/Validation/Validator/File/Resolution/Max.php index af9715d6..e72aad5d 100644 --- a/src/Phalcon/validation/validator/file/resolution/Max.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Max.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Resolution; use Phalcon\Validation\Validator\File\AbstractFile; @@ -64,4 +71,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/resolution/Min.php b/src/Phalcon/Validation/Validator/File/Resolution/Min.php similarity index 87% rename from src/Phalcon/validation/validator/file/resolution/Min.php rename to src/Phalcon/Validation/Validator/File/Resolution/Min.php index 75e48df5..217bc726 100644 --- a/src/Phalcon/validation/validator/file/resolution/Min.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Min.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Resolution; use Phalcon\Validation\Validator\File\AbstractFile; @@ -64,4 +71,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Equal.php b/src/Phalcon/Validation/Validator/File/Size/Equal.php similarity index 86% rename from src/Phalcon/validation/validator/file/size/Equal.php rename to src/Phalcon/Validation/Validator/File/Size/Equal.php index 852b0144..98e35fb2 100644 --- a/src/Phalcon/validation/validator/file/size/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Size/Equal.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Size; use Phalcon\Validation\Validator\File\AbstractFile; @@ -64,4 +71,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Max.php b/src/Phalcon/Validation/Validator/File/Size/Max.php similarity index 86% rename from src/Phalcon/validation/validator/file/size/Max.php rename to src/Phalcon/Validation/Validator/File/Size/Max.php index 7465186a..393bb74d 100644 --- a/src/Phalcon/validation/validator/file/size/Max.php +++ b/src/Phalcon/Validation/Validator/File/Size/Max.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Size; use Phalcon\Validation\Validator\File\AbstractFile; @@ -64,4 +71,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/file/size/Min.php b/src/Phalcon/Validation/Validator/File/Size/Min.php similarity index 86% rename from src/Phalcon/validation/validator/file/size/Min.php rename to src/Phalcon/Validation/Validator/File/Size/Min.php index 01383b3b..c4f39021 100644 --- a/src/Phalcon/validation/validator/file/size/Min.php +++ b/src/Phalcon/Validation/Validator/File/Size/Min.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\File\Size; use Phalcon\Validation\Validator\File\AbstractFile; @@ -64,4 +71,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/Validation/Validator/Identical.php similarity index 85% rename from src/Phalcon/validation/validator/Identical.php rename to src/Phalcon/Validation/Validator/Identical.php index b3299ff1..8d57756c 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/Validation/Validator/Identical.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -59,4 +66,5 @@ class Identical extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/Validation/Validator/InclusionIn.php similarity index 85% rename from src/Phalcon/validation/validator/InclusionIn.php rename to src/Phalcon/Validation/Validator/InclusionIn.php index 05a1c725..766f0443 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/Validation/Validator/InclusionIn.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -59,4 +66,5 @@ class InclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Ip.php b/src/Phalcon/Validation/Validator/Ip.php similarity index 90% rename from src/Phalcon/validation/validator/Ip.php rename to src/Phalcon/Validation/Validator/Ip.php index ccfddd67..830108e5 100644 --- a/src/Phalcon/validation/validator/Ip.php +++ b/src/Phalcon/Validation/Validator/Ip.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -77,4 +84,5 @@ class Ip extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/Validation/Validator/Numericality.php similarity index 82% rename from src/Phalcon/validation/validator/Numericality.php rename to src/Phalcon/Validation/Validator/Numericality.php index d991fcb4..a9e38b56 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/Validation/Validator/Numericality.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Numericality extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/Validation/Validator/PresenceOf.php similarity index 82% rename from src/Phalcon/validation/validator/PresenceOf.php rename to src/Phalcon/Validation/Validator/PresenceOf.php index c0002357..2a0abec7 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/Validation/Validator/PresenceOf.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class PresenceOf extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/Validation/Validator/Regex.php similarity index 86% rename from src/Phalcon/validation/validator/Regex.php rename to src/Phalcon/Validation/Validator/Regex.php index c25b6ecf..85badd74 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/Validation/Validator/Regex.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -59,4 +66,5 @@ class Regex extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/Validation/Validator/StringLength.php similarity index 90% rename from src/Phalcon/validation/validator/StringLength.php rename to src/Phalcon/Validation/Validator/StringLength.php index b3b7a984..599159a9 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/Validation/Validator/StringLength.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidatorComposite; @@ -77,4 +84,5 @@ class StringLength extends AbstractValidatorComposite public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/validation/validator/stringlength/Max.php b/src/Phalcon/Validation/Validator/StringLength/Max.php similarity index 87% rename from src/Phalcon/validation/validator/stringlength/Max.php rename to src/Phalcon/Validation/Validator/StringLength/Max.php index 6dfb16a1..41c15755 100644 --- a/src/Phalcon/validation/validator/stringlength/Max.php +++ b/src/Phalcon/Validation/Validator/StringLength/Max.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\StringLength; use Phalcon\Validation\AbstractValidator; @@ -66,4 +73,5 @@ class Max extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/stringlength/Min.php b/src/Phalcon/Validation/Validator/StringLength/Min.php similarity index 87% rename from src/Phalcon/validation/validator/stringlength/Min.php rename to src/Phalcon/Validation/Validator/StringLength/Min.php index 5c77a755..3cc02bbd 100644 --- a/src/Phalcon/validation/validator/stringlength/Min.php +++ b/src/Phalcon/Validation/Validator/StringLength/Min.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator\StringLength; use Phalcon\Validation\AbstractValidator; @@ -66,4 +73,5 @@ class Min extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/Validation/Validator/Uniqueness.php similarity index 92% rename from src/Phalcon/validation/validator/Uniqueness.php rename to src/Phalcon/Validation/Validator/Uniqueness.php index dd3b39cf..51fc19d0 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/Validation/Validator/Uniqueness.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractCombinedFieldsValidator; @@ -124,4 +131,5 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } + } diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/Validation/Validator/Url.php similarity index 82% rename from src/Phalcon/validation/validator/Url.php rename to src/Phalcon/Validation/Validator/Url.php index 3872318a..23c3bbbb 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/Validation/Validator/Url.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation\Validator; use Phalcon\Validation\AbstractValidator; @@ -54,4 +61,5 @@ class Url extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/validation/ValidatorCompositeInterface.php b/src/Phalcon/Validation/ValidatorCompositeInterface.php similarity index 68% rename from src/Phalcon/validation/ValidatorCompositeInterface.php rename to src/Phalcon/Validation/ValidatorCompositeInterface.php index 602bef4d..c7eadf9f 100644 --- a/src/Phalcon/validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/Validation/ValidatorCompositeInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; /** @@ -23,4 +30,5 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; + } diff --git a/src/Phalcon/validation/ValidatorFactory.php b/src/Phalcon/Validation/ValidatorFactory.php similarity index 65% rename from src/Phalcon/validation/ValidatorFactory.php rename to src/Phalcon/Validation/ValidatorFactory.php index 955bd259..c07b1c1d 100644 --- a/src/Phalcon/validation/ValidatorFactory.php +++ b/src/Phalcon/Validation/ValidatorFactory.php @@ -1,8 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; use Phalcon\Factory\AbstractFactory; +use Phalcon\Factory\ValidatorInterface; /** * This file is part of the Phalcon Framework. @@ -28,9 +36,9 @@ public function __construct(array $services = array()) * Creates a new instance * * @param string $name - * @return mixed + * @return ValidatorInterface */ - public function newInstance(string $name) + public function newInstance(string $name): ValidatorInterface { } @@ -40,4 +48,5 @@ public function newInstance(string $name) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/validation/ValidatorInterface.php b/src/Phalcon/Validation/ValidatorInterface.php similarity index 87% rename from src/Phalcon/validation/ValidatorInterface.php rename to src/Phalcon/Validation/ValidatorInterface.php index f1848f02..da14e5a5 100644 --- a/src/Phalcon/validation/ValidatorInterface.php +++ b/src/Phalcon/Validation/ValidatorInterface.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon\Validation; /** @@ -12,35 +19,35 @@ interface ValidatorInterface * Returns an option in the validator's options * Returns null if the option hasn't set * + * @return mixed * @param string $key * @param mixed $defaultValue - * @return mixed */ public function getOption(string $key, $defaultValue = null); /** * Checks if an option is defined * - * @param string $key * @return boolean + * @param string $key */ public function hasOption(string $key): bool; /** * Executes the validation * + * @return boolean * @param \Phalcon\Validation $validation * @param mixed $field - * @return boolean */ public function validate(\Phalcon\Validation $validation, $field): bool; /** * Get the template message * - * @param string $field * @return string * @throw InvalidArgumentException When the field does not exists + * @param string $field */ public function getTemplate(string $field): string; @@ -54,16 +61,17 @@ public function getTemplates(): array; /** * Clear current template and set new from an array, * - * @param array $templates * @return ValidatorInterface + * @param array $templates */ public function setTemplates(array $templates): ValidatorInterface; /** * Set a new temlate message * - * @param string $template * @return ValidatorInterface + * @param string $template */ public function setTemplate(string $template): ValidatorInterface; + } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 237ed367..07b80a6b 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ namespace Phalcon; /** @@ -85,7 +92,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - final protected static function _getSpecial(int $special): string + protected final static function _getSpecial(int $special): string { } @@ -131,4 +138,5 @@ public static function getId(): string public static function getPart(int $part): string { } + } diff --git a/src/Phalcon/acl/Enum.php b/src/Phalcon/acl/Enum.php deleted file mode 100644 index a81e1a28..00000000 --- a/src/Phalcon/acl/Enum.php +++ /dev/null @@ -1,15 +0,0 @@ - Robots::find(), - * "limit" => 25, - * "page" => $currentPage, - * ] - * ); - * - * $paginate = $paginator->paginate(); - * ``` - */ -class Model extends AbstractAdapter -{ - - /** - * Returns a slice of the resultset to show in the pagination - * - * @return \Phalcon\Paginator\RepositoryInterface - */ - public function paginate(): RepositoryInterface - { - } -} diff --git a/src/Phalcon/security/Exception.php b/src/Phalcon/security/Exception.php deleted file mode 100644 index c13eabd7..00000000 --- a/src/Phalcon/security/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Mon, 18 Nov 2019 13:44:01 +0100 Subject: [PATCH 22/25] Fixed errors manually. See issue https://github.com/phalcon/zephir/issues/2016 --- src/Phalcon/Acl/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Acl/Component.php | 2 +- src/Phalcon/Acl/Role.php | 2 +- src/Phalcon/Annotations/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Annotations/Reader.php | 2 +- src/Phalcon/Assets/Asset.php | 2 +- src/Phalcon/Assets/Inline.php | 2 +- src/Phalcon/Cache/Exception/Exception.php | 2 +- src/Phalcon/Cache/Exception/InvalidArgumentException.php | 2 +- src/Phalcon/Cli/Dispatcher.php | 2 +- src/Phalcon/Cli/Router/Route.php | 2 +- src/Phalcon/Cli/Task.php | 2 +- src/Phalcon/Db/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Db/Column.php | 2 +- src/Phalcon/Db/Dialect.php | 2 +- src/Phalcon/Db/Index.php | 2 +- src/Phalcon/Db/Reference.php | 2 +- src/Phalcon/Di/AbstractInjectionAware.php | 2 +- src/Phalcon/Di/Injectable.php | 2 +- src/Phalcon/Di/Service.php | 2 +- src/Phalcon/Dispatcher/AbstractDispatcher.php | 2 +- src/Phalcon/Domain/Payload/Payload.php | 2 +- src/Phalcon/Domain/Payload/PayloadInterface.php | 2 +- src/Phalcon/Events/Event.php | 2 +- src/Phalcon/Events/Manager.php | 2 +- src/Phalcon/Exception.php | 2 +- src/Phalcon/Firewall/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Flash/AbstractFlash.php | 2 +- src/Phalcon/Forms/Element/AbstractElement.php | 2 +- src/Phalcon/Html/Link/Serializer/Header.php | 2 +- src/Phalcon/Http/Cookie.php | 2 +- src/Phalcon/Http/Request.php | 2 +- src/Phalcon/Http/Request/File.php | 2 +- src/Phalcon/Http/Response.php | 2 +- src/Phalcon/Http/Response/Cookies.php | 2 +- src/Phalcon/Http/Response/Headers.php | 2 +- src/Phalcon/Image/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Logger/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Logger/Formatter/AbstractFormatter.php | 2 +- src/Phalcon/Messages/Message.php | 2 +- src/Phalcon/Mvc/Controller.php | 2 +- src/Phalcon/Mvc/Dispatcher.php | 2 +- src/Phalcon/Mvc/Micro/Collection.php | 2 +- src/Phalcon/Mvc/Model.php | 2 +- src/Phalcon/Mvc/Model/Behavior.php | 2 +- src/Phalcon/Mvc/Model/Binder.php | 2 +- src/Phalcon/Mvc/Model/Criteria.php | 2 +- src/Phalcon/Mvc/Model/MetaData.php | 2 +- src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php | 2 +- src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php | 2 +- src/Phalcon/Mvc/Model/Query.php | 2 +- src/Phalcon/Mvc/Model/Query/Builder.php | 2 +- src/Phalcon/Mvc/Model/Query/Status.php | 2 +- src/Phalcon/Mvc/Model/Relation.php | 2 +- src/Phalcon/Mvc/Model/Resultset.php | 2 +- src/Phalcon/Mvc/Model/Row.php | 2 +- src/Phalcon/Mvc/Model/Transaction/Manager.php | 2 +- src/Phalcon/Mvc/Router.php | 2 +- src/Phalcon/Mvc/Router/Group.php | 2 +- src/Phalcon/Mvc/Router/Route.php | 2 +- src/Phalcon/Mvc/View.php | 2 +- src/Phalcon/Mvc/View/Engine/AbstractEngine.php | 2 +- src/Phalcon/Mvc/ViewInterface.php | 2 +- src/Phalcon/Paginator/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Paginator/Repository.php | 2 +- src/Phalcon/Session/Manager.php | 2 +- src/Phalcon/Storage/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Storage/Serializer/AbstractSerializer.php | 2 +- src/Phalcon/Translate/Adapter/AbstractAdapter.php | 2 +- src/Phalcon/Translate/Interpolator/AssociativeArray.php | 2 +- src/Phalcon/Translate/Interpolator/IndexedArray.php | 2 +- src/Phalcon/Validation/AbstractValidator.php | 2 +- src/Phalcon/Validation/AbstractValidatorComposite.php | 2 +- 73 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/Phalcon/Acl/Adapter/AbstractAdapter.php b/src/Phalcon/Acl/Adapter/AbstractAdapter.php index 70abf468..ffe1ab47 100644 --- a/src/Phalcon/Acl/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Acl/Adapter/AbstractAdapter.php @@ -14,7 +14,7 @@ /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Active access which the list is checking if some role can access it diff --git a/src/Phalcon/Acl/Component.php b/src/Phalcon/Acl/Component.php index 6f7a986d..66c8319f 100644 --- a/src/Phalcon/Acl/Component.php +++ b/src/Phalcon/Acl/Component.php @@ -12,7 +12,7 @@ /** * This class defines component entity and its description */ -class Component implements Phalcon\Acl\ComponentInterface +class Component implements \Phalcon\Acl\ComponentInterface { /** * Component description diff --git a/src/Phalcon/Acl/Role.php b/src/Phalcon/Acl/Role.php index b127b2c7..784d988f 100644 --- a/src/Phalcon/Acl/Role.php +++ b/src/Phalcon/Acl/Role.php @@ -12,7 +12,7 @@ /** * This class defines role entity and its description */ -class Role implements Phalcon\Acl\RoleInterface +class Role implements \Phalcon\Acl\RoleInterface { /** * Role name diff --git a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php index 42b046a9..de60fd5b 100644 --- a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php @@ -17,7 +17,7 @@ /** * This is the base class for Phalcon\Annotations adapters */ -abstract class AbstractAdapter implements Phalcon\Annotations\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface { /** * @var array diff --git a/src/Phalcon/Annotations/Reader.php b/src/Phalcon/Annotations/Reader.php index 5552bc46..d834a449 100644 --- a/src/Phalcon/Annotations/Reader.php +++ b/src/Phalcon/Annotations/Reader.php @@ -12,7 +12,7 @@ /** * Parses docblocks returning an array with the found annotations */ -class Reader implements Phalcon\Annotations\ReaderInterface +class Reader implements \Phalcon\Annotations\ReaderInterface { /** diff --git a/src/Phalcon/Assets/Asset.php b/src/Phalcon/Assets/Asset.php index b9604235..65a2ead6 100644 --- a/src/Phalcon/Assets/Asset.php +++ b/src/Phalcon/Assets/Asset.php @@ -16,7 +16,7 @@ * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); * ``` */ -class Asset implements Phalcon\Assets\AssetInterface +class Asset implements \Phalcon\Assets\AssetInterface { /** * @var array | null diff --git a/src/Phalcon/Assets/Inline.php b/src/Phalcon/Assets/Inline.php index ea47a56b..862368ec 100644 --- a/src/Phalcon/Assets/Inline.php +++ b/src/Phalcon/Assets/Inline.php @@ -16,7 +16,7 @@ * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); * ``` */ -class Inline implements Phalcon\Assets\AssetInterface +class Inline implements \Phalcon\Assets\AssetInterface { /** * @var array | null diff --git a/src/Phalcon/Cache/Exception/Exception.php b/src/Phalcon/Cache/Exception/Exception.php index f86ea319..d8df7b13 100644 --- a/src/Phalcon/Cache/Exception/Exception.php +++ b/src/Phalcon/Cache/Exception/Exception.php @@ -12,7 +12,7 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class Exception extends \Phalcon\Exception implements Psr\SimpleCache\CacheException +class Exception extends \Phalcon\Exception implements \Psr\SimpleCache\CacheException { } diff --git a/src/Phalcon/Cache/Exception/InvalidArgumentException.php b/src/Phalcon/Cache/Exception/InvalidArgumentException.php index c317d6d3..fead573d 100644 --- a/src/Phalcon/Cache/Exception/InvalidArgumentException.php +++ b/src/Phalcon/Cache/Exception/InvalidArgumentException.php @@ -12,7 +12,7 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class InvalidArgumentException extends \Phalcon\Exception implements Psr\SimpleCache\InvalidArgumentException +class InvalidArgumentException extends \Phalcon\Exception implements \Psr\SimpleCache\InvalidArgumentException { } diff --git a/src/Phalcon/Cli/Dispatcher.php b/src/Phalcon/Cli/Dispatcher.php index ba8d3160..a0090e81 100644 --- a/src/Phalcon/Cli/Dispatcher.php +++ b/src/Phalcon/Cli/Dispatcher.php @@ -31,7 +31,7 @@ * $handle = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements Phalcon\Cli\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface { /** * @var string diff --git a/src/Phalcon/Cli/Router/Route.php b/src/Phalcon/Cli/Router/Route.php index e9120f83..4d5f3ee1 100644 --- a/src/Phalcon/Cli/Router/Route.php +++ b/src/Phalcon/Cli/Router/Route.php @@ -12,7 +12,7 @@ /** * This class represents every route added to the router */ -class Route implements Phalcon\Cli\Router\RouteInterface +class Route implements \Phalcon\Cli\Router\RouteInterface { const DEFAULT_DELIMITER = ' '; diff --git a/src/Phalcon/Cli/Task.php b/src/Phalcon/Cli/Task.php index a727cac9..28a5e58e 100644 --- a/src/Phalcon/Cli/Task.php +++ b/src/Phalcon/Cli/Task.php @@ -36,7 +36,7 @@ * } * ``` */ -class Task extends Injectable implements Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface +class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface { protected $eventsManager; diff --git a/src/Phalcon/Db/Adapter/AbstractAdapter.php b/src/Phalcon/Db/Adapter/AbstractAdapter.php index 46ede959..783491cb 100644 --- a/src/Phalcon/Db/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Db/Adapter/AbstractAdapter.php @@ -17,7 +17,7 @@ /** * Base class for Phalcon\Db adapters */ -abstract class AbstractAdapter implements Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Connection ID diff --git a/src/Phalcon/Db/Column.php b/src/Phalcon/Db/Column.php index b2134888..d646e799 100644 --- a/src/Phalcon/Db/Column.php +++ b/src/Phalcon/Db/Column.php @@ -32,7 +32,7 @@ * $connection->addColumn("robots", null, $column); * ``` */ -class Column implements Phalcon\Db\ColumnInterface +class Column implements \Phalcon\Db\ColumnInterface { /** * Bind Type Blob diff --git a/src/Phalcon/Db/Dialect.php b/src/Phalcon/Db/Dialect.php index a81d79c5..e1b85297 100644 --- a/src/Phalcon/Db/Dialect.php +++ b/src/Phalcon/Db/Dialect.php @@ -13,7 +13,7 @@ * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ -abstract class Dialect implements Phalcon\Db\DialectInterface +abstract class Dialect implements \Phalcon\Db\DialectInterface { protected $escapeChar; diff --git a/src/Phalcon/Db/Index.php b/src/Phalcon/Db/Index.php index f64d51c5..586c8433 100644 --- a/src/Phalcon/Db/Index.php +++ b/src/Phalcon/Db/Index.php @@ -38,7 +38,7 @@ * $connection->addIndex("robots", null, $index_primary); * ``` */ -class Index implements Phalcon\Db\IndexInterface +class Index implements \Phalcon\Db\IndexInterface { /** * Index columns diff --git a/src/Phalcon/Db/Reference.php b/src/Phalcon/Db/Reference.php index 50eb11bf..5763cd2a 100644 --- a/src/Phalcon/Db/Reference.php +++ b/src/Phalcon/Db/Reference.php @@ -30,7 +30,7 @@ * ); * ``` */ -class Reference implements Phalcon\Db\ReferenceInterface +class Reference implements \Phalcon\Db\ReferenceInterface { /** * Local reference columns diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Phalcon/Di/AbstractInjectionAware.php index 0ff55e59..1938a255 100644 --- a/src/Phalcon/Di/AbstractInjectionAware.php +++ b/src/Phalcon/Di/AbstractInjectionAware.php @@ -12,7 +12,7 @@ /** * This abstract class offers common access to the DI in a class */ -abstract class AbstractInjectionAware implements Phalcon\Di\InjectionAwareInterface +abstract class AbstractInjectionAware implements \Phalcon\Di\InjectionAwareInterface { /** * Dependency Injector diff --git a/src/Phalcon/Di/Injectable.php b/src/Phalcon/Di/Injectable.php index 3ddbd7b7..d22f46de 100644 --- a/src/Phalcon/Di/Injectable.php +++ b/src/Phalcon/Di/Injectable.php @@ -40,7 +40,7 @@ * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ -abstract class Injectable implements Phalcon\Di\InjectionAwareInterface +abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface { /** * Dependency Injector diff --git a/src/Phalcon/Di/Service.php b/src/Phalcon/Di/Service.php index 3fb77b6a..8288d118 100644 --- a/src/Phalcon/Di/Service.php +++ b/src/Phalcon/Di/Service.php @@ -21,7 +21,7 @@ * $request = service->resolve(); * ``` */ -class Service implements Phalcon\Di\ServiceInterface +class Service implements \Phalcon\Di\ServiceInterface { protected $definition; diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php index e8033256..d93b081b 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -18,7 +18,7 @@ * This class can't be instantiated directly, you can use it to create your own * dispatchers. */ -abstract class AbstractDispatcher extends AbstractInjectionAware implements Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface { protected $activeHandler; diff --git a/src/Phalcon/Domain/Payload/Payload.php b/src/Phalcon/Domain/Payload/Payload.php index 70ea8595..ca684c8e 100644 --- a/src/Phalcon/Domain/Payload/Payload.php +++ b/src/Phalcon/Domain/Payload/Payload.php @@ -12,7 +12,7 @@ /** * Holds the payload */ -class Payload implements Phalcon\Domain\Payload\PayloadInterface +class Payload implements \Phalcon\Domain\Payload\PayloadInterface { /** * Extra information diff --git a/src/Phalcon/Domain/Payload/PayloadInterface.php b/src/Phalcon/Domain/Payload/PayloadInterface.php index ebd39d11..a96ecd8e 100644 --- a/src/Phalcon/Domain/Payload/PayloadInterface.php +++ b/src/Phalcon/Domain/Payload/PayloadInterface.php @@ -12,7 +12,7 @@ /** * This interface is used for consumers */ -interface PayloadInterface extends Phalcon\Domain\Payload\ReadableInterface, Phalcon\Domain\Payload\WriteableInterface +interface PayloadInterface extends \Phalcon\Domain\Payload\ReadableInterface, \Phalcon\Domain\Payload\WriteableInterface { } diff --git a/src/Phalcon/Events/Event.php b/src/Phalcon/Events/Event.php index 3166c89e..a59342ca 100644 --- a/src/Phalcon/Events/Event.php +++ b/src/Phalcon/Events/Event.php @@ -24,7 +24,7 @@ * } * ``` */ -class Event implements Phalcon\Events\EventInterface +class Event implements \Phalcon\Events\EventInterface { /** * Is event cancelable? diff --git a/src/Phalcon/Events/Manager.php b/src/Phalcon/Events/Manager.php index 612b43c4..caca4dce 100644 --- a/src/Phalcon/Events/Manager.php +++ b/src/Phalcon/Events/Manager.php @@ -17,7 +17,7 @@ * can create hooks or plugins that will offer monitoring of data, manipulation, * conditional execution and much more. */ -class Manager implements Phalcon\Events\ManagerInterface +class Manager implements \Phalcon\Events\ManagerInterface { const DEFAULT_PRIORITY = 100; diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index ac2afe29..129c46bf 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -14,7 +14,7 @@ * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception implements Throwable +class Exception extends \Exception implements \Throwable { /** diff --git a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php index a11986ca..d5e2ce07 100644 --- a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php @@ -17,7 +17,7 @@ /** * Adapter for Phalcon\Firewall adapters */ -abstract class AbstractAdapter implements Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements \Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { /** * Storing active identity object implementing Phalcon/Acl/RoleAware diff --git a/src/Phalcon/Flash/AbstractFlash.php b/src/Phalcon/Flash/AbstractFlash.php index 2d234c8c..de3ab534 100644 --- a/src/Phalcon/Flash/AbstractFlash.php +++ b/src/Phalcon/Flash/AbstractFlash.php @@ -22,7 +22,7 @@ * $flash->error("Cannot open the file"); * ``` */ -abstract class AbstractFlash extends AbstractInjectionAware implements Phalcon\Flash\FlashInterface +abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\Flash\FlashInterface { /** * @var bool diff --git a/src/Phalcon/Forms/Element/AbstractElement.php b/src/Phalcon/Forms/Element/AbstractElement.php index 4a7f9445..bd2c3213 100644 --- a/src/Phalcon/Forms/Element/AbstractElement.php +++ b/src/Phalcon/Forms/Element/AbstractElement.php @@ -15,7 +15,7 @@ /** * This is a base class for form elements */ -abstract class AbstractElement implements Phalcon\Forms\Element\ElementInterface +abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface { protected $attributes; diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Phalcon/Html/Link/Serializer/Header.php index a55767a1..9efafa8f 100644 --- a/src/Phalcon/Html/Link/Serializer/Header.php +++ b/src/Phalcon/Html/Link/Serializer/Header.php @@ -14,7 +14,7 @@ /** * Class Phalcon\Http\Link\Serializer\Header */ -class Header implements Phalcon\Html\Link\Serializer\SerializerInterface +class Header implements \Phalcon\Html\Link\Serializer\SerializerInterface { /** diff --git a/src/Phalcon/Http/Cookie.php b/src/Phalcon/Http/Cookie.php index f9a04fb0..e9da6a27 100644 --- a/src/Phalcon/Http/Cookie.php +++ b/src/Phalcon/Http/Cookie.php @@ -14,7 +14,7 @@ /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie extends AbstractInjectionAware implements Phalcon\Http\CookieInterface +class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInterface { protected $domain; diff --git a/src/Phalcon/Http/Request.php b/src/Phalcon/Http/Request.php index fa07b276..77188ec6 100644 --- a/src/Phalcon/Http/Request.php +++ b/src/Phalcon/Http/Request.php @@ -38,7 +38,7 @@ * $request->getLanguages(); * ``` */ -class Request extends AbstractInjectionAware implements Phalcon\Http\RequestInterface +class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInterface { private $filterService; diff --git a/src/Phalcon/Http/Request/File.php b/src/Phalcon/Http/Request/File.php index 983865b5..e9e9d497 100644 --- a/src/Phalcon/Http/Request/File.php +++ b/src/Phalcon/Http/Request/File.php @@ -32,7 +32,7 @@ * } * ``` */ -class File implements Phalcon\Http\Request\FileInterface +class File implements \Phalcon\Http\Request\FileInterface { /** * @var string|null diff --git a/src/Phalcon/Http/Response.php b/src/Phalcon/Http/Response.php index d41d388f..dd2ee8e3 100644 --- a/src/Phalcon/Http/Response.php +++ b/src/Phalcon/Http/Response.php @@ -28,7 +28,7 @@ * $response->send(); * ``` */ -class Response implements Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface { protected $container; diff --git a/src/Phalcon/Http/Response/Cookies.php b/src/Phalcon/Http/Response/Cookies.php index 79bc9b97..be8de066 100644 --- a/src/Phalcon/Http/Response/Cookies.php +++ b/src/Phalcon/Http/Response/Cookies.php @@ -60,7 +60,7 @@ * ); * ``` */ -class Cookies extends AbstractInjectionAware implements Phalcon\Http\Response\CookiesInterface +class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\CookiesInterface { protected $cookies = array(); diff --git a/src/Phalcon/Http/Response/Headers.php b/src/Phalcon/Http/Response/Headers.php index 6dd8bdaf..9f181adb 100644 --- a/src/Phalcon/Http/Response/Headers.php +++ b/src/Phalcon/Http/Response/Headers.php @@ -14,7 +14,7 @@ * * This class is a bag to manage the response headers */ -class Headers implements Phalcon\Http\Response\HeadersInterface +class Headers implements \Phalcon\Http\Response\HeadersInterface { protected $headers = array(); diff --git a/src/Phalcon/Image/Adapter/AbstractAdapter.php b/src/Phalcon/Image/Adapter/AbstractAdapter.php index 54c5d6e5..18a7f2aa 100644 --- a/src/Phalcon/Image/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Image/Adapter/AbstractAdapter.php @@ -16,7 +16,7 @@ * * All image adapters must use this class */ -abstract class AbstractAdapter implements Phalcon\Image\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { static protected $checked = false; diff --git a/src/Phalcon/Logger/Adapter/AbstractAdapter.php b/src/Phalcon/Logger/Adapter/AbstractAdapter.php index 66c7e7bf..e80b5977 100644 --- a/src/Phalcon/Logger/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Logger/Adapter/AbstractAdapter.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements Phalcon\Logger\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface { /** * Name of the default formatter class diff --git a/src/Phalcon/Logger/Formatter/AbstractFormatter.php b/src/Phalcon/Logger/Formatter/AbstractFormatter.php index e2fb16c2..039a9ce9 100644 --- a/src/Phalcon/Logger/Formatter/AbstractFormatter.php +++ b/src/Phalcon/Logger/Formatter/AbstractFormatter.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractFormatter implements Phalcon\Logger\Formatter\FormatterInterface +abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface { /** diff --git a/src/Phalcon/Messages/Message.php b/src/Phalcon/Messages/Message.php index 77a55f6a..0d0c22d2 100644 --- a/src/Phalcon/Messages/Message.php +++ b/src/Phalcon/Messages/Message.php @@ -14,7 +14,7 @@ * * Stores a message from various components */ -class Message implements Phalcon\Messages\MessageInterface, \JsonSerializable +class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable { /** * @var int diff --git a/src/Phalcon/Mvc/Controller.php b/src/Phalcon/Mvc/Controller.php index 1e83c775..0bdb95f1 100644 --- a/src/Phalcon/Mvc/Controller.php +++ b/src/Phalcon/Mvc/Controller.php @@ -51,7 +51,7 @@ * } * ``` */ -abstract class Controller extends Injectable implements Phalcon\Mvc\ControllerInterface +abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerInterface { /** diff --git a/src/Phalcon/Mvc/Dispatcher.php b/src/Phalcon/Mvc/Dispatcher.php index ebe7dff7..ec27db58 100644 --- a/src/Phalcon/Mvc/Dispatcher.php +++ b/src/Phalcon/Mvc/Dispatcher.php @@ -29,7 +29,7 @@ * $controller = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements Phalcon\Mvc\DispatcherInterface +class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface { protected $defaultAction = 'index'; diff --git a/src/Phalcon/Mvc/Micro/Collection.php b/src/Phalcon/Mvc/Micro/Collection.php index 701453be..21b72524 100644 --- a/src/Phalcon/Mvc/Micro/Collection.php +++ b/src/Phalcon/Mvc/Micro/Collection.php @@ -28,7 +28,7 @@ * $app->mount($collection); * ``` */ -class Collection implements Phalcon\Mvc\Micro\CollectionInterface +class Collection implements \Phalcon\Mvc\Micro\CollectionInterface { protected $handler; diff --git a/src/Phalcon/Mvc/Model.php b/src/Phalcon/Mvc/Model.php index 5b6f598a..34475a50 100644 --- a/src/Phalcon/Mvc/Model.php +++ b/src/Phalcon/Mvc/Model.php @@ -56,7 +56,7 @@ * } * ``` */ -abstract class Model extends AbstractInjectionAware implements Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable +abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable { const DIRTY_STATE_DETACHED = 2; diff --git a/src/Phalcon/Mvc/Model/Behavior.php b/src/Phalcon/Mvc/Model/Behavior.php index c0c481ba..15de1735 100644 --- a/src/Phalcon/Mvc/Model/Behavior.php +++ b/src/Phalcon/Mvc/Model/Behavior.php @@ -14,7 +14,7 @@ * * This is an optional base class for ORM behaviors */ -abstract class Behavior implements Phalcon\Mvc\Model\BehaviorInterface +abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface { /** * @var array diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php index 2b0a64b5..fc1bcbcb 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -16,7 +16,7 @@ * * This is an class for binding models into params for handler */ -class Binder implements Phalcon\Mvc\Model\BinderInterface +class Binder implements \Phalcon\Mvc\Model\BinderInterface { /** * Array for storing active bound models diff --git a/src/Phalcon/Mvc/Model/Criteria.php b/src/Phalcon/Mvc/Model/Criteria.php index 2086b85a..c7ef2073 100644 --- a/src/Phalcon/Mvc/Model/Criteria.php +++ b/src/Phalcon/Mvc/Model/Criteria.php @@ -29,7 +29,7 @@ * ->execute(); * ``` */ -class Criteria implements Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface +class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; diff --git a/src/Phalcon/Mvc/Model/MetaData.php b/src/Phalcon/Mvc/Model/MetaData.php index aa796a3a..2b4b31a2 100644 --- a/src/Phalcon/Mvc/Model/MetaData.php +++ b/src/Phalcon/Mvc/Model/MetaData.php @@ -33,7 +33,7 @@ * print_r($attributes); * ``` */ -abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, Phalcon\Mvc\Model\MetaDataInterface +abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface { const MODELS_ATTRIBUTES = 0; diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php index d464e641..7ba89439 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Annotations implements Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +class Annotations implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface { /** diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php index d8f7e480..2837cf3b 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php @@ -14,7 +14,7 @@ * * Queries the table meta-data in order to introspect the model's metadata */ -class Introspection implements Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +class Introspection implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface { /** diff --git a/src/Phalcon/Mvc/Model/Query.php b/src/Phalcon/Mvc/Model/Query.php index e64d4188..7782369d 100644 --- a/src/Phalcon/Mvc/Model/Query.php +++ b/src/Phalcon/Mvc/Model/Query.php @@ -64,7 +64,7 @@ * $resultWithOutEntries = $queryWithTransaction->execute(); * ``` */ -class Query implements Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface +class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface { const TYPE_DELETE = 303; diff --git a/src/Phalcon/Mvc/Model/Query/Builder.php b/src/Phalcon/Mvc/Model/Query/Builder.php index d6f93cd8..945d697d 100644 --- a/src/Phalcon/Mvc/Model/Query/Builder.php +++ b/src/Phalcon/Mvc/Model/Query/Builder.php @@ -48,7 +48,7 @@ * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); * ``` */ -class Builder implements Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface +class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface { protected $bindParams; diff --git a/src/Phalcon/Mvc/Model/Query/Status.php b/src/Phalcon/Mvc/Model/Query/Status.php index bf3c8160..f074d66a 100644 --- a/src/Phalcon/Mvc/Model/Query/Status.php +++ b/src/Phalcon/Mvc/Model/Query/Status.php @@ -38,7 +38,7 @@ * } * ``` */ -class Status implements Phalcon\Mvc\Model\Query\StatusInterface +class Status implements \Phalcon\Mvc\Model\Query\StatusInterface { protected $model; diff --git a/src/Phalcon/Mvc/Model/Relation.php b/src/Phalcon/Mvc/Model/Relation.php index 057f23ee..a11d2579 100644 --- a/src/Phalcon/Mvc/Model/Relation.php +++ b/src/Phalcon/Mvc/Model/Relation.php @@ -14,7 +14,7 @@ * * This class represents a relationship between two models */ -class Relation implements Phalcon\Mvc\Model\RelationInterface +class Relation implements \Phalcon\Mvc\Model\RelationInterface { const ACTION_CASCADE = 2; diff --git a/src/Phalcon/Mvc/Model/Resultset.php b/src/Phalcon/Mvc/Model/Resultset.php index e6af34ff..481025d2 100644 --- a/src/Phalcon/Mvc/Model/Resultset.php +++ b/src/Phalcon/Mvc/Model/Resultset.php @@ -53,7 +53,7 @@ * } * ``` */ -abstract class Resultset implements Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable +abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { const HYDRATE_ARRAYS = 1; diff --git a/src/Phalcon/Mvc/Model/Row.php b/src/Phalcon/Mvc/Model/Row.php index f009d3b3..9be5a159 100644 --- a/src/Phalcon/Mvc/Model/Row.php +++ b/src/Phalcon/Mvc/Model/Row.php @@ -15,7 +15,7 @@ * This component allows Phalcon\Mvc\Model to return rows without an associated entity. * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. */ -class Row implements \Phalcon\Mvc\EntityInterface, Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable +class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable { /** diff --git a/src/Phalcon/Mvc/Model/Transaction/Manager.php b/src/Phalcon/Mvc/Model/Transaction/Manager.php index 1fe6dd31..5c1f7874 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Manager.php +++ b/src/Phalcon/Mvc/Model/Transaction/Manager.php @@ -59,7 +59,7 @@ * } * ``` */ -class Manager implements Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface +class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface { protected $container; diff --git a/src/Phalcon/Mvc/Router.php b/src/Phalcon/Mvc/Router.php index 9863abad..1e568dc4 100644 --- a/src/Phalcon/Mvc/Router.php +++ b/src/Phalcon/Mvc/Router.php @@ -41,7 +41,7 @@ * echo $router->getControllerName(); * ``` */ -class Router extends AbstractInjectionAware implements Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface +class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface { const POSITION_FIRST = 0; diff --git a/src/Phalcon/Mvc/Router/Group.php b/src/Phalcon/Mvc/Router/Group.php index d9536b6c..72ad0d0a 100644 --- a/src/Phalcon/Mvc/Router/Group.php +++ b/src/Phalcon/Mvc/Router/Group.php @@ -57,7 +57,7 @@ * $router->mount($blog); * ``` */ -class Group implements Phalcon\Mvc\Router\GroupInterface +class Group implements \Phalcon\Mvc\Router\GroupInterface { protected $beforeMatch; diff --git a/src/Phalcon/Mvc/Router/Route.php b/src/Phalcon/Mvc/Router/Route.php index c2e979fb..19f95622 100644 --- a/src/Phalcon/Mvc/Router/Route.php +++ b/src/Phalcon/Mvc/Router/Route.php @@ -14,7 +14,7 @@ * * This class represents every route added to the router */ -class Route implements Phalcon\Mvc\Router\RouteInterface +class Route implements \Phalcon\Mvc\Router\RouteInterface { protected $beforeMatch; diff --git a/src/Phalcon/Mvc/View.php b/src/Phalcon/Mvc/View.php index 028ad42c..b213e8da 100644 --- a/src/Phalcon/Mvc/View.php +++ b/src/Phalcon/Mvc/View.php @@ -38,7 +38,7 @@ * echo $view->getContent(); * ``` */ -class View extends Injectable implements Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface +class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface { /** * Render Level: To the action view diff --git a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php index 804161f7..31d85c4f 100644 --- a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php +++ b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php @@ -16,7 +16,7 @@ * All the template engine adapters must inherit this class. This provides * basic interfacing between the engine and the Phalcon\Mvc\View component. */ -abstract class AbstractEngine extends Injectable implements Phalcon\Mvc\View\Engine\EngineInterface +abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface { protected $view; diff --git a/src/Phalcon/Mvc/ViewInterface.php b/src/Phalcon/Mvc/ViewInterface.php index 5b9bc7e2..ed02efdb 100644 --- a/src/Phalcon/Mvc/ViewInterface.php +++ b/src/Phalcon/Mvc/ViewInterface.php @@ -14,7 +14,7 @@ * * Interface for Phalcon\Mvc\View */ -interface ViewInterface extends Phalcon\Mvc\ViewBaseInterface +interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface { /** diff --git a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php index 13c31f1b..f9f7ece9 100644 --- a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php @@ -14,7 +14,7 @@ /** * Phalcon\Paginator\Adapter\AbstractAdapter */ -abstract class AbstractAdapter implements Phalcon\Paginator\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInterface { /** * Configuration of paginator diff --git a/src/Phalcon/Paginator/Repository.php b/src/Phalcon/Paginator/Repository.php index 051dca35..f27e8342 100644 --- a/src/Phalcon/Paginator/Repository.php +++ b/src/Phalcon/Paginator/Repository.php @@ -14,7 +14,7 @@ * * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements Phalcon\Paginator\RepositoryInterface, \JsonSerializable +class Repository implements \Phalcon\Paginator\RepositoryInterface, \JsonSerializable { /** * @var array diff --git a/src/Phalcon/Session/Manager.php b/src/Phalcon/Session/Manager.php index 14b80655..e8cf8c35 100644 --- a/src/Phalcon/Session/Manager.php +++ b/src/Phalcon/Session/Manager.php @@ -18,7 +18,7 @@ * * Session manager class */ -class Manager extends AbstractInjectionAware implements Phalcon\Session\ManagerInterface +class Manager extends AbstractInjectionAware implements \Phalcon\Session\ManagerInterface { /** * @var SessionHandlerInterface|null diff --git a/src/Phalcon/Storage/Adapter/AbstractAdapter.php b/src/Phalcon/Storage/Adapter/AbstractAdapter.php index 29865491..c7b49c30 100644 --- a/src/Phalcon/Storage/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Storage/Adapter/AbstractAdapter.php @@ -22,7 +22,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements Phalcon\Storage\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface { /** * @var mixed diff --git a/src/Phalcon/Storage/Serializer/AbstractSerializer.php b/src/Phalcon/Storage/Serializer/AbstractSerializer.php index 013336c7..bf18491b 100644 --- a/src/Phalcon/Storage/Serializer/AbstractSerializer.php +++ b/src/Phalcon/Storage/Serializer/AbstractSerializer.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractSerializer implements Phalcon\Storage\Serializer\SerializerInterface +abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface { /** * @var mixed diff --git a/src/Phalcon/Translate/Adapter/AbstractAdapter.php b/src/Phalcon/Translate/Adapter/AbstractAdapter.php index 4fbfa7a0..c4e1c024 100644 --- a/src/Phalcon/Translate/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Translate/Adapter/AbstractAdapter.php @@ -16,7 +16,7 @@ * * Base class for Phalcon\Translate adapters */ -abstract class AbstractAdapter implements Phalcon\Translate\Adapter\AdapterInterface +abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInterface { /** * @var string diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/AssociativeArray.php index 72c95433..026b5fda 100644 --- a/src/Phalcon/Translate/Interpolator/AssociativeArray.php +++ b/src/Phalcon/Translate/Interpolator/AssociativeArray.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AssociativeArray implements Phalcon\Translate\Interpolator\InterpolatorInterface +class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** diff --git a/src/Phalcon/Translate/Interpolator/IndexedArray.php b/src/Phalcon/Translate/Interpolator/IndexedArray.php index fd69b8fe..dab117e5 100644 --- a/src/Phalcon/Translate/Interpolator/IndexedArray.php +++ b/src/Phalcon/Translate/Interpolator/IndexedArray.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class IndexedArray implements Phalcon\Translate\Interpolator\InterpolatorInterface +class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface { /** diff --git a/src/Phalcon/Validation/AbstractValidator.php b/src/Phalcon/Validation/AbstractValidator.php index 6fe46703..aff26d6a 100644 --- a/src/Phalcon/Validation/AbstractValidator.php +++ b/src/Phalcon/Validation/AbstractValidator.php @@ -14,7 +14,7 @@ /** * This is a base class for validators */ -abstract class AbstractValidator implements Phalcon\Validation\ValidatorInterface +abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface { /** * Message template diff --git a/src/Phalcon/Validation/AbstractValidatorComposite.php b/src/Phalcon/Validation/AbstractValidatorComposite.php index 9488548f..03f6ed1b 100644 --- a/src/Phalcon/Validation/AbstractValidatorComposite.php +++ b/src/Phalcon/Validation/AbstractValidatorComposite.php @@ -12,7 +12,7 @@ /** * This is a base class for combined fields validators */ -abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements Phalcon\Validation\ValidatorCompositeInterface +abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements \Phalcon\Validation\ValidatorCompositeInterface { /** * @var array From f1e00c4c319645ab509987625dde8848df0ee74a Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Mon, 18 Nov 2019 13:47:55 +0100 Subject: [PATCH 23/25] Phpcs --- src/Phalcon/Acl/Adapter/AbstractAdapter.php | 1 - src/Phalcon/Acl/Adapter/AdapterInterface.php | 1 - src/Phalcon/Acl/Adapter/Memory.php | 1 - src/Phalcon/Acl/Component.php | 1 - src/Phalcon/Acl/ComponentAware.php | 1 - src/Phalcon/Acl/ComponentInterface.php | 1 - src/Phalcon/Acl/Enum.php | 2 -- src/Phalcon/Acl/Role.php | 1 - src/Phalcon/Acl/RoleAware.php | 1 - src/Phalcon/Acl/RoleInterface.php | 1 - .../Annotations/Adapter/AbstractAdapter.php | 1 - .../Annotations/Adapter/AdapterInterface.php | 1 - src/Phalcon/Annotations/Adapter/Apcu.php | 1 - src/Phalcon/Annotations/Adapter/Memory.php | 1 - src/Phalcon/Annotations/Adapter/Stream.php | 1 - src/Phalcon/Annotations/Annotation.php | 1 - .../Annotations/AnnotationsFactory.php | 1 - src/Phalcon/Annotations/Collection.php | 1 - src/Phalcon/Annotations/Reader.php | 1 - src/Phalcon/Annotations/ReaderInterface.php | 1 - src/Phalcon/Annotations/Reflection.php | 1 - .../Application/AbstractApplication.php | 1 - src/Phalcon/Assets/Asset.php | 1 - src/Phalcon/Assets/Asset/Css.php | 1 - src/Phalcon/Assets/Asset/Js.php | 1 - src/Phalcon/Assets/AssetInterface.php | 1 - src/Phalcon/Assets/Collection.php | 1 - src/Phalcon/Assets/FilterInterface.php | 1 - src/Phalcon/Assets/Filters/Cssmin.php | 1 - src/Phalcon/Assets/Filters/Jsmin.php | 1 - src/Phalcon/Assets/Filters/None.php | 1 - src/Phalcon/Assets/Inline.php | 1 - src/Phalcon/Assets/Inline/Css.php | 1 - src/Phalcon/Assets/Inline/Js.php | 1 - src/Phalcon/Assets/Manager.php | 1 - src/Phalcon/Cache.php | 1 - src/Phalcon/Cache/AdapterFactory.php | 1 - src/Phalcon/Cache/CacheFactory.php | 1 - src/Phalcon/Cli/Console.php | 1 - src/Phalcon/Cli/Dispatcher.php | 1 - src/Phalcon/Cli/DispatcherInterface.php | 1 - src/Phalcon/Cli/Router.php | 1 - src/Phalcon/Cli/Router/Route.php | 5 ++-- src/Phalcon/Cli/Router/RouteInterface.php | 1 - src/Phalcon/Cli/RouterInterface.php | 1 - src/Phalcon/Cli/Task.php | 1 - src/Phalcon/Collection.php | 1 - src/Phalcon/Collection/ReadOnly.php | 1 - src/Phalcon/Config.php | 1 - src/Phalcon/Config/Adapter/Grouped.php | 1 - src/Phalcon/Config/Adapter/Ini.php | 1 - src/Phalcon/Config/Adapter/Json.php | 1 - src/Phalcon/Config/Adapter/Php.php | 1 - src/Phalcon/Config/Adapter/Yaml.php | 1 - src/Phalcon/Config/ConfigFactory.php | 1 - src/Phalcon/Container.php | 1 - src/Phalcon/Crypt.php | 1 - src/Phalcon/Crypt/CryptInterface.php | 1 - src/Phalcon/Db/AbstractDb.php | 1 - src/Phalcon/Db/Adapter/AbstractAdapter.php | 3 +-- src/Phalcon/Db/Adapter/AdapterInterface.php | 1 - src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php | 1 - src/Phalcon/Db/Adapter/Pdo/Mysql.php | 1 - src/Phalcon/Db/Adapter/Pdo/Postgresql.php | 1 - src/Phalcon/Db/Adapter/Pdo/Sqlite.php | 1 - src/Phalcon/Db/Adapter/PdoFactory.php | 1 - src/Phalcon/Db/Column.php | 1 - src/Phalcon/Db/ColumnInterface.php | 1 - src/Phalcon/Db/Dialect.php | 1 - src/Phalcon/Db/Dialect/Mysql.php | 1 - src/Phalcon/Db/Dialect/Postgresql.php | 1 - src/Phalcon/Db/Dialect/Sqlite.php | 1 - src/Phalcon/Db/DialectInterface.php | 1 - src/Phalcon/Db/Enum.php | 2 -- src/Phalcon/Db/Index.php | 1 - src/Phalcon/Db/IndexInterface.php | 1 - src/Phalcon/Db/Profiler.php | 1 - src/Phalcon/Db/Profiler/Item.php | 1 - src/Phalcon/Db/RawValue.php | 1 - src/Phalcon/Db/Reference.php | 1 - src/Phalcon/Db/ReferenceInterface.php | 1 - src/Phalcon/Db/Result/Pdo.php | 1 - src/Phalcon/Db/ResultInterface.php | 1 - src/Phalcon/Debug.php | 3 +-- src/Phalcon/Debug/Dump.php | 1 - src/Phalcon/Di.php | 3 +-- src/Phalcon/Di/AbstractInjectionAware.php | 1 - src/Phalcon/Di/DiInterface.php | 1 - src/Phalcon/Di/FactoryDefault.php | 1 - src/Phalcon/Di/FactoryDefault/Cli.php | 1 - src/Phalcon/Di/Injectable.php | 1 - src/Phalcon/Di/InjectionAwareInterface.php | 1 - src/Phalcon/Di/Service.php | 1 - src/Phalcon/Di/Service/Builder.php | 1 - src/Phalcon/Di/ServiceInterface.php | 1 - src/Phalcon/Di/ServiceProviderInterface.php | 1 - src/Phalcon/Dispatcher/AbstractDispatcher.php | 1 - .../Dispatcher/DispatcherInterface.php | 1 - src/Phalcon/Dispatcher/Exception.php | 2 -- src/Phalcon/Domain/Payload/Payload.php | 1 - src/Phalcon/Domain/Payload/PayloadFactory.php | 1 - .../Domain/Payload/ReadableInterface.php | 1 - src/Phalcon/Domain/Payload/Status.php | 1 - .../Domain/Payload/WriteableInterface.php | 1 - src/Phalcon/Escaper.php | 1 - src/Phalcon/Escaper/EscaperInterface.php | 1 - src/Phalcon/Events/Event.php | 1 - src/Phalcon/Events/EventInterface.php | 1 - src/Phalcon/Events/EventsAwareInterface.php | 1 - src/Phalcon/Events/Manager.php | 1 - src/Phalcon/Events/ManagerInterface.php | 1 - src/Phalcon/Exception.php | 1 - src/Phalcon/Factory/AbstractFactory.php | 1 - src/Phalcon/Filter.php | 1 - src/Phalcon/Filter/FilterFactory.php | 1 - src/Phalcon/Filter/FilterInterface.php | 1 - src/Phalcon/Filter/Sanitize/AbsInt.php | 1 - src/Phalcon/Filter/Sanitize/Alnum.php | 1 - src/Phalcon/Filter/Sanitize/Alpha.php | 1 - src/Phalcon/Filter/Sanitize/BoolVal.php | 1 - src/Phalcon/Filter/Sanitize/Email.php | 1 - src/Phalcon/Filter/Sanitize/FloatVal.php | 1 - src/Phalcon/Filter/Sanitize/IntVal.php | 1 - src/Phalcon/Filter/Sanitize/Lower.php | 1 - src/Phalcon/Filter/Sanitize/LowerFirst.php | 1 - src/Phalcon/Filter/Sanitize/Regex.php | 1 - src/Phalcon/Filter/Sanitize/Remove.php | 1 - src/Phalcon/Filter/Sanitize/Replace.php | 1 - src/Phalcon/Filter/Sanitize/Special.php | 1 - src/Phalcon/Filter/Sanitize/SpecialFull.php | 1 - src/Phalcon/Filter/Sanitize/StringVal.php | 1 - src/Phalcon/Filter/Sanitize/Striptags.php | 1 - src/Phalcon/Filter/Sanitize/Trim.php | 1 - src/Phalcon/Filter/Sanitize/Upper.php | 1 - src/Phalcon/Filter/Sanitize/UpperFirst.php | 1 - src/Phalcon/Filter/Sanitize/UpperWords.php | 1 - src/Phalcon/Filter/Sanitize/Url.php | 1 - .../Firewall/Adapter/AbstractAdapter.php | 1 - src/Phalcon/Firewall/Adapter/Acl.php | 1 - .../Firewall/Adapter/AdapterInterface.php | 1 - src/Phalcon/Firewall/Adapter/Annotations.php | 1 - src/Phalcon/Firewall/Adapter/Micro/Acl.php | 1 - src/Phalcon/Flash/AbstractFlash.php | 1 - src/Phalcon/Flash/Direct.php | 1 - src/Phalcon/Flash/FlashInterface.php | 1 - src/Phalcon/Flash/Session.php | 1 - src/Phalcon/Forms/Element/AbstractElement.php | 1 - src/Phalcon/Forms/Element/Check.php | 1 - src/Phalcon/Forms/Element/Date.php | 1 - .../Forms/Element/ElementInterface.php | 1 - src/Phalcon/Forms/Element/Email.php | 1 - src/Phalcon/Forms/Element/File.php | 1 - src/Phalcon/Forms/Element/Hidden.php | 1 - src/Phalcon/Forms/Element/Numeric.php | 1 - src/Phalcon/Forms/Element/Password.php | 1 - src/Phalcon/Forms/Element/Radio.php | 1 - src/Phalcon/Forms/Element/Select.php | 1 - src/Phalcon/Forms/Element/Submit.php | 1 - src/Phalcon/Forms/Element/Text.php | 1 - src/Phalcon/Forms/Element/TextArea.php | 1 - src/Phalcon/Forms/Form.php | 1 - src/Phalcon/Forms/Manager.php | 1 - src/Phalcon/Helper/Arr.php | 1 - src/Phalcon/Helper/Fs.php | 1 - src/Phalcon/Helper/Number.php | 1 - src/Phalcon/Helper/Str.php | 1 - src/Phalcon/Html/Attributes.php | 1 - .../Html/Attributes/AttributesInterface.php | 1 - .../Html/Attributes/RenderInterface.php | 1 - src/Phalcon/Html/Breadcrumbs.php | 1 - src/Phalcon/Html/Helper/AbstractHelper.php | 1 - src/Phalcon/Html/Helper/Anchor.php | 1 - src/Phalcon/Html/Helper/AnchorRaw.php | 1 - src/Phalcon/Html/Helper/Body.php | 1 - src/Phalcon/Html/Helper/Button.php | 1 - src/Phalcon/Html/Helper/Close.php | 1 - src/Phalcon/Html/Helper/Element.php | 1 - src/Phalcon/Html/Helper/ElementRaw.php | 1 - src/Phalcon/Html/Helper/Form.php | 1 - src/Phalcon/Html/Helper/Img.php | 1 - src/Phalcon/Html/Helper/Label.php | 1 - src/Phalcon/Html/Helper/TextArea.php | 1 - src/Phalcon/Html/Link/EvolvableLink.php | 1 - .../Html/Link/EvolvableLinkProvider.php | 1 - src/Phalcon/Html/Link/Link.php | 1 - src/Phalcon/Html/Link/LinkProvider.php | 1 - src/Phalcon/Html/Link/Serializer/Header.php | 1 - .../Link/Serializer/SerializerInterface.php | 1 - src/Phalcon/Html/TagFactory.php | 1 - src/Phalcon/Http/Cookie.php | 1 - src/Phalcon/Http/CookieInterface.php | 1 - src/Phalcon/Http/Message/AbstractCommon.php | 1 - src/Phalcon/Http/Message/AbstractMessage.php | 1 - src/Phalcon/Http/Message/AbstractRequest.php | 1 - src/Phalcon/Http/Message/Request.php | 1 - src/Phalcon/Http/Message/RequestFactory.php | 1 - src/Phalcon/Http/Message/Response.php | 1 - src/Phalcon/Http/Message/ResponseFactory.php | 1 - src/Phalcon/Http/Message/ServerRequest.php | 1 - .../Http/Message/ServerRequestFactory.php | 1 - src/Phalcon/Http/Message/Stream.php | 1 - src/Phalcon/Http/Message/Stream/Input.php | 1 - src/Phalcon/Http/Message/Stream/Memory.php | 1 - src/Phalcon/Http/Message/Stream/Temp.php | 1 - src/Phalcon/Http/Message/StreamFactory.php | 1 - src/Phalcon/Http/Message/UploadedFile.php | 1 - .../Http/Message/UploadedFileFactory.php | 1 - src/Phalcon/Http/Message/Uri.php | 1 - src/Phalcon/Http/Message/UriFactory.php | 1 - src/Phalcon/Http/Request.php | 1 - src/Phalcon/Http/Request/File.php | 1 - src/Phalcon/Http/Request/FileInterface.php | 1 - src/Phalcon/Http/RequestInterface.php | 1 - src/Phalcon/Http/Response.php | 1 - src/Phalcon/Http/Response/Cookies.php | 1 - .../Http/Response/CookiesInterface.php | 1 - src/Phalcon/Http/Response/Headers.php | 1 - .../Http/Response/HeadersInterface.php | 1 - src/Phalcon/Http/ResponseInterface.php | 1 - .../Http/Server/AbstractMiddleware.php | 1 - .../Http/Server/AbstractRequestHandler.php | 1 - src/Phalcon/Image/Adapter/AbstractAdapter.php | 3 +-- .../Image/Adapter/AdapterInterface.php | 1 - src/Phalcon/Image/Adapter/Gd.php | 3 +-- src/Phalcon/Image/Adapter/Imagick.php | 5 ++-- src/Phalcon/Image/Enum.php | 2 -- src/Phalcon/Image/ImageFactory.php | 1 - src/Phalcon/Kernel.php | 1 - src/Phalcon/Loader.php | 1 - src/Phalcon/Logger.php | 1 - .../Logger/Adapter/AbstractAdapter.php | 1 - .../Logger/Adapter/AdapterInterface.php | 1 - src/Phalcon/Logger/Adapter/Noop.php | 1 - src/Phalcon/Logger/Adapter/Stream.php | 1 - src/Phalcon/Logger/Adapter/Syslog.php | 1 - src/Phalcon/Logger/AdapterFactory.php | 1 - .../Logger/Formatter/AbstractFormatter.php | 1 - .../Logger/Formatter/FormatterInterface.php | 1 - src/Phalcon/Logger/Formatter/Json.php | 1 - src/Phalcon/Logger/Formatter/Line.php | 1 - src/Phalcon/Logger/Item.php | 1 - src/Phalcon/Logger/LoggerFactory.php | 1 - src/Phalcon/Messages/Message.php | 1 - src/Phalcon/Messages/MessageInterface.php | 1 - src/Phalcon/Messages/Messages.php | 1 - src/Phalcon/Mvc/Application.php | 1 - src/Phalcon/Mvc/Controller.php | 1 - .../Mvc/Controller/BindModelInterface.php | 1 - src/Phalcon/Mvc/Dispatcher.php | 1 - src/Phalcon/Mvc/DispatcherInterface.php | 1 - src/Phalcon/Mvc/EntityInterface.php | 1 - src/Phalcon/Mvc/Micro.php | 1 - src/Phalcon/Mvc/Micro/Collection.php | 1 - src/Phalcon/Mvc/Micro/CollectionInterface.php | 1 - src/Phalcon/Mvc/Micro/LazyLoader.php | 1 - src/Phalcon/Mvc/Micro/MiddlewareInterface.php | 1 - src/Phalcon/Mvc/Model.php | 3 +-- src/Phalcon/Mvc/Model/Behavior.php | 1 - src/Phalcon/Mvc/Model/Behavior/SoftDelete.php | 1 - .../Mvc/Model/Behavior/Timestampable.php | 1 - src/Phalcon/Mvc/Model/BehaviorInterface.php | 1 - src/Phalcon/Mvc/Model/Binder.php | 1 - .../Mvc/Model/Binder/BindableInterface.php | 1 - src/Phalcon/Mvc/Model/BinderInterface.php | 1 - src/Phalcon/Mvc/Model/Criteria.php | 1 - src/Phalcon/Mvc/Model/CriteriaInterface.php | 1 - src/Phalcon/Mvc/Model/Manager.php | 1 - src/Phalcon/Mvc/Model/ManagerInterface.php | 1 - src/Phalcon/Mvc/Model/MetaData.php | 1 - src/Phalcon/Mvc/Model/MetaData/Apcu.php | 1 - .../Mvc/Model/MetaData/Libmemcached.php | 1 - src/Phalcon/Mvc/Model/MetaData/Memory.php | 1 - src/Phalcon/Mvc/Model/MetaData/Redis.php | 1 - .../Model/MetaData/Strategy/Annotations.php | 1 - .../Model/MetaData/Strategy/Introspection.php | 1 - .../MetaData/Strategy/StrategyInterface.php | 1 - src/Phalcon/Mvc/Model/MetaData/Stream.php | 1 - src/Phalcon/Mvc/Model/MetaDataInterface.php | 1 - src/Phalcon/Mvc/Model/Query.php | 3 +-- src/Phalcon/Mvc/Model/Query/Builder.php | 1 - .../Mvc/Model/Query/BuilderInterface.php | 1 - src/Phalcon/Mvc/Model/Query/Lang.php | 1 - src/Phalcon/Mvc/Model/Query/Status.php | 1 - .../Mvc/Model/Query/StatusInterface.php | 1 - src/Phalcon/Mvc/Model/QueryInterface.php | 1 - src/Phalcon/Mvc/Model/Relation.php | 1 - src/Phalcon/Mvc/Model/RelationInterface.php | 1 - src/Phalcon/Mvc/Model/ResultInterface.php | 1 - src/Phalcon/Mvc/Model/Resultset.php | 1 - src/Phalcon/Mvc/Model/Resultset/Complex.php | 1 - src/Phalcon/Mvc/Model/Resultset/Simple.php | 1 - src/Phalcon/Mvc/Model/ResultsetInterface.php | 1 - src/Phalcon/Mvc/Model/Row.php | 1 - src/Phalcon/Mvc/Model/Transaction.php | 1 - src/Phalcon/Mvc/Model/Transaction/Failed.php | 1 - src/Phalcon/Mvc/Model/Transaction/Manager.php | 1 - .../Model/Transaction/ManagerInterface.php | 1 - .../Mvc/Model/TransactionInterface.php | 1 - src/Phalcon/Mvc/Model/ValidationFailed.php | 1 - src/Phalcon/Mvc/ModelInterface.php | 1 - src/Phalcon/Mvc/ModuleDefinitionInterface.php | 1 - src/Phalcon/Mvc/Router.php | 1 - src/Phalcon/Mvc/Router/Annotations.php | 1 - src/Phalcon/Mvc/Router/Group.php | 1 - src/Phalcon/Mvc/Router/GroupInterface.php | 1 - src/Phalcon/Mvc/Router/Route.php | 3 +-- src/Phalcon/Mvc/Router/RouteInterface.php | 1 - src/Phalcon/Mvc/RouterInterface.php | 1 - src/Phalcon/Mvc/View.php | 1 - .../Mvc/View/Engine/AbstractEngine.php | 1 - .../Mvc/View/Engine/EngineInterface.php | 1 - src/Phalcon/Mvc/View/Engine/Php.php | 1 - src/Phalcon/Mvc/View/Engine/Volt.php | 1 - src/Phalcon/Mvc/View/Engine/Volt/Compiler.php | 1 - .../Mvc/View/Engine/Volt/Exception.php | 1 - src/Phalcon/Mvc/View/Simple.php | 1 - src/Phalcon/Mvc/ViewBaseInterface.php | 1 - src/Phalcon/Mvc/ViewInterface.php | 1 - .../Paginator/Adapter/AbstractAdapter.php | 1 - .../Paginator/Adapter/AdapterInterface.php | 1 - src/Phalcon/Paginator/Adapter/Model.php | 1 - src/Phalcon/Paginator/Adapter/NativeArray.php | 1 - .../Paginator/Adapter/QueryBuilder.php | 1 - src/Phalcon/Paginator/PaginatorFactory.php | 1 - src/Phalcon/Paginator/Repository.php | 1 - src/Phalcon/Paginator/RepositoryInterface.php | 1 - src/Phalcon/Registry.php | 1 - src/Phalcon/Security.php | 1 - src/Phalcon/Security/Random.php | 1 - .../Session/Adapter/AbstractAdapter.php | 1 - src/Phalcon/Session/Adapter/Libmemcached.php | 1 - src/Phalcon/Session/Adapter/Noop.php | 1 - src/Phalcon/Session/Adapter/Redis.php | 1 - src/Phalcon/Session/Adapter/Stream.php | 1 - src/Phalcon/Session/Bag.php | 1 - src/Phalcon/Session/Manager.php | 1 - src/Phalcon/Session/ManagerInterface.php | 1 - .../Storage/Adapter/AbstractAdapter.php | 1 - .../Storage/Adapter/AdapterInterface.php | 1 - src/Phalcon/Storage/Adapter/Apcu.php | 1 - src/Phalcon/Storage/Adapter/Libmemcached.php | 1 - src/Phalcon/Storage/Adapter/Memory.php | 1 - src/Phalcon/Storage/Adapter/Redis.php | 1 - src/Phalcon/Storage/Adapter/Stream.php | 1 - src/Phalcon/Storage/AdapterFactory.php | 1 - .../Storage/Serializer/AbstractSerializer.php | 1 - src/Phalcon/Storage/Serializer/Base64.php | 1 - src/Phalcon/Storage/Serializer/Igbinary.php | 1 - src/Phalcon/Storage/Serializer/Json.php | 1 - src/Phalcon/Storage/Serializer/Msgpack.php | 1 - src/Phalcon/Storage/Serializer/None.php | 1 - src/Phalcon/Storage/Serializer/Php.php | 1 - .../Serializer/SerializerInterface.php | 1 - src/Phalcon/Storage/SerializerFactory.php | 1 - src/Phalcon/Tag.php | 25 +++++++++---------- src/Phalcon/Tag/Select.php | 1 - src/Phalcon/Text.php | 1 - .../Translate/Adapter/AbstractAdapter.php | 1 - .../Translate/Adapter/AdapterInterface.php | 1 - src/Phalcon/Translate/Adapter/Csv.php | 1 - src/Phalcon/Translate/Adapter/Gettext.php | 1 - src/Phalcon/Translate/Adapter/NativeArray.php | 1 - .../Interpolator/AssociativeArray.php | 1 - .../Translate/Interpolator/IndexedArray.php | 1 - .../Interpolator/InterpolatorInterface.php | 1 - src/Phalcon/Translate/InterpolatorFactory.php | 1 - src/Phalcon/Translate/TranslateFactory.php | 1 - src/Phalcon/Url.php | 1 - src/Phalcon/Url/UrlInterface.php | 1 - src/Phalcon/Validation.php | 1 - src/Phalcon/Validation/AbstractValidator.php | 1 - .../Validation/AbstractValidatorComposite.php | 1 - .../Validation/ValidationInterface.php | 1 - src/Phalcon/Validation/Validator/Alnum.php | 1 - src/Phalcon/Validation/Validator/Alpha.php | 1 - src/Phalcon/Validation/Validator/Between.php | 1 - src/Phalcon/Validation/Validator/Callback.php | 1 - .../Validation/Validator/Confirmation.php | 1 - .../Validation/Validator/CreditCard.php | 1 - src/Phalcon/Validation/Validator/Date.php | 1 - src/Phalcon/Validation/Validator/Digit.php | 1 - src/Phalcon/Validation/Validator/Email.php | 1 - .../Validation/Validator/ExclusionIn.php | 1 - src/Phalcon/Validation/Validator/File.php | 1 - .../Validator/File/AbstractFile.php | 1 - .../Validation/Validator/File/MimeType.php | 1 - .../Validator/File/Resolution/Equal.php | 1 - .../Validator/File/Resolution/Max.php | 1 - .../Validator/File/Resolution/Min.php | 1 - .../Validation/Validator/File/Size/Equal.php | 1 - .../Validation/Validator/File/Size/Max.php | 1 - .../Validation/Validator/File/Size/Min.php | 1 - .../Validation/Validator/Identical.php | 1 - .../Validation/Validator/InclusionIn.php | 1 - src/Phalcon/Validation/Validator/Ip.php | 1 - .../Validation/Validator/Numericality.php | 1 - .../Validation/Validator/PresenceOf.php | 1 - src/Phalcon/Validation/Validator/Regex.php | 1 - .../Validation/Validator/StringLength.php | 1 - .../Validation/Validator/StringLength/Max.php | 1 - .../Validation/Validator/StringLength/Min.php | 1 - .../Validation/Validator/Uniqueness.php | 1 - src/Phalcon/Validation/Validator/Url.php | 1 - .../ValidatorCompositeInterface.php | 1 - src/Phalcon/Validation/ValidatorFactory.php | 1 - src/Phalcon/Validation/ValidatorInterface.php | 1 - src/Phalcon/Version.php | 3 +-- 407 files changed, 25 insertions(+), 436 deletions(-) diff --git a/src/Phalcon/Acl/Adapter/AbstractAdapter.php b/src/Phalcon/Acl/Adapter/AbstractAdapter.php index ffe1ab47..d7ea0d05 100644 --- a/src/Phalcon/Acl/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Acl/Adapter/AbstractAdapter.php @@ -126,5 +126,4 @@ public function setDefaultAction(int $defaultAccess) public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Acl/Adapter/AdapterInterface.php b/src/Phalcon/Acl/Adapter/AdapterInterface.php index 0dba54ab..50dcf539 100644 --- a/src/Phalcon/Acl/Adapter/AdapterInterface.php +++ b/src/Phalcon/Acl/Adapter/AdapterInterface.php @@ -182,5 +182,4 @@ public function setDefaultAction(int $defaultAccess); * @return void */ public function setNoArgumentsDefaultAction(int $defaultAccess); - } diff --git a/src/Phalcon/Acl/Adapter/Memory.php b/src/Phalcon/Acl/Adapter/Memory.php index 04f635ce..6a243609 100644 --- a/src/Phalcon/Acl/Adapter/Memory.php +++ b/src/Phalcon/Acl/Adapter/Memory.php @@ -455,5 +455,4 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } - } diff --git a/src/Phalcon/Acl/Component.php b/src/Phalcon/Acl/Component.php index 66c8319f..3de82caf 100644 --- a/src/Phalcon/Acl/Component.php +++ b/src/Phalcon/Acl/Component.php @@ -65,5 +65,4 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/Acl/ComponentAware.php b/src/Phalcon/Acl/ComponentAware.php index 37b68783..a631e35b 100644 --- a/src/Phalcon/Acl/ComponentAware.php +++ b/src/Phalcon/Acl/ComponentAware.php @@ -21,5 +21,4 @@ interface ComponentAware * @return string */ public function getComponentName(): string; - } diff --git a/src/Phalcon/Acl/ComponentInterface.php b/src/Phalcon/Acl/ComponentInterface.php index 92284e37..3cc7b050 100644 --- a/src/Phalcon/Acl/ComponentInterface.php +++ b/src/Phalcon/Acl/ComponentInterface.php @@ -35,5 +35,4 @@ public function getName(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/Acl/Enum.php b/src/Phalcon/Acl/Enum.php index 31c3e271..b6d62470 100644 --- a/src/Phalcon/Acl/Enum.php +++ b/src/Phalcon/Acl/Enum.php @@ -19,6 +19,4 @@ class Enum const DENY = 0; - - } diff --git a/src/Phalcon/Acl/Role.php b/src/Phalcon/Acl/Role.php index 784d988f..0618f41a 100644 --- a/src/Phalcon/Acl/Role.php +++ b/src/Phalcon/Acl/Role.php @@ -65,5 +65,4 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/Acl/RoleAware.php b/src/Phalcon/Acl/RoleAware.php index 2f1a3fb9..2ffaf09f 100644 --- a/src/Phalcon/Acl/RoleAware.php +++ b/src/Phalcon/Acl/RoleAware.php @@ -21,5 +21,4 @@ interface RoleAware * @return string */ public function getRoleName(): string; - } diff --git a/src/Phalcon/Acl/RoleInterface.php b/src/Phalcon/Acl/RoleInterface.php index edfc723a..87beb275 100644 --- a/src/Phalcon/Acl/RoleInterface.php +++ b/src/Phalcon/Acl/RoleInterface.php @@ -35,5 +35,4 @@ public function getDescription(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php index de60fd5b..97373f18 100644 --- a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php @@ -99,5 +99,4 @@ public function getReader(): ReaderInterface public function setReader(\Phalcon\Annotations\ReaderInterface $reader) { } - } diff --git a/src/Phalcon/Annotations/Adapter/AdapterInterface.php b/src/Phalcon/Annotations/Adapter/AdapterInterface.php index ca7dbadc..6f851a21 100644 --- a/src/Phalcon/Annotations/Adapter/AdapterInterface.php +++ b/src/Phalcon/Annotations/Adapter/AdapterInterface.php @@ -74,5 +74,4 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); - } diff --git a/src/Phalcon/Annotations/Adapter/Apcu.php b/src/Phalcon/Annotations/Adapter/Apcu.php index a34bb2d2..00e61855 100644 --- a/src/Phalcon/Annotations/Adapter/Apcu.php +++ b/src/Phalcon/Annotations/Adapter/Apcu.php @@ -60,5 +60,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data): bool { } - } diff --git a/src/Phalcon/Annotations/Adapter/Memory.php b/src/Phalcon/Annotations/Adapter/Memory.php index ed7d5e6a..cce0444f 100644 --- a/src/Phalcon/Annotations/Adapter/Memory.php +++ b/src/Phalcon/Annotations/Adapter/Memory.php @@ -41,5 +41,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } - } diff --git a/src/Phalcon/Annotations/Adapter/Stream.php b/src/Phalcon/Annotations/Adapter/Stream.php index 56ff5b87..da16f41b 100644 --- a/src/Phalcon/Annotations/Adapter/Stream.php +++ b/src/Phalcon/Annotations/Adapter/Stream.php @@ -59,5 +59,4 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } - } diff --git a/src/Phalcon/Annotations/Annotation.php b/src/Phalcon/Annotations/Annotation.php index 9ef3dd5c..243f63a8 100644 --- a/src/Phalcon/Annotations/Annotation.php +++ b/src/Phalcon/Annotations/Annotation.php @@ -128,5 +128,4 @@ public function hasArgument($position): bool public function numberArguments(): int { } - } diff --git a/src/Phalcon/Annotations/AnnotationsFactory.php b/src/Phalcon/Annotations/AnnotationsFactory.php index 1775f423..f72f80a1 100644 --- a/src/Phalcon/Annotations/AnnotationsFactory.php +++ b/src/Phalcon/Annotations/AnnotationsFactory.php @@ -56,5 +56,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Annotations/Collection.php b/src/Phalcon/Annotations/Collection.php index 5f58c604..d949b7c4 100644 --- a/src/Phalcon/Annotations/Collection.php +++ b/src/Phalcon/Annotations/Collection.php @@ -140,5 +140,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/Annotations/Reader.php b/src/Phalcon/Annotations/Reader.php index d834a449..ddccab04 100644 --- a/src/Phalcon/Annotations/Reader.php +++ b/src/Phalcon/Annotations/Reader.php @@ -36,5 +36,4 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } - } diff --git a/src/Phalcon/Annotations/ReaderInterface.php b/src/Phalcon/Annotations/ReaderInterface.php index a8cc3f42..af370c66 100644 --- a/src/Phalcon/Annotations/ReaderInterface.php +++ b/src/Phalcon/Annotations/ReaderInterface.php @@ -32,5 +32,4 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; - } diff --git a/src/Phalcon/Annotations/Reflection.php b/src/Phalcon/Annotations/Reflection.php index 00ddc477..fdcb7760 100644 --- a/src/Phalcon/Annotations/Reflection.php +++ b/src/Phalcon/Annotations/Reflection.php @@ -89,5 +89,4 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } - } diff --git a/src/Phalcon/Application/AbstractApplication.php b/src/Phalcon/Application/AbstractApplication.php index 6cf9b5d4..9b1a733f 100644 --- a/src/Phalcon/Application/AbstractApplication.php +++ b/src/Phalcon/Application/AbstractApplication.php @@ -130,5 +130,4 @@ public function setDefaultModule(string $defaultModule): AbstractApplication public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Assets/Asset.php b/src/Phalcon/Assets/Asset.php index 65a2ead6..59669813 100644 --- a/src/Phalcon/Assets/Asset.php +++ b/src/Phalcon/Assets/Asset.php @@ -304,5 +304,4 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } - } diff --git a/src/Phalcon/Assets/Asset/Css.php b/src/Phalcon/Assets/Asset/Css.php index d3cdc4e1..a730da27 100644 --- a/src/Phalcon/Assets/Asset/Css.php +++ b/src/Phalcon/Assets/Asset/Css.php @@ -28,5 +28,4 @@ class Css extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/Assets/Asset/Js.php b/src/Phalcon/Assets/Asset/Js.php index 7f795ede..80c4b120 100644 --- a/src/Phalcon/Assets/Asset/Js.php +++ b/src/Phalcon/Assets/Asset/Js.php @@ -28,5 +28,4 @@ class Js extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/Assets/AssetInterface.php b/src/Phalcon/Assets/AssetInterface.php index b43c3ac9..bbc486c9 100644 --- a/src/Phalcon/Assets/AssetInterface.php +++ b/src/Phalcon/Assets/AssetInterface.php @@ -66,5 +66,4 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; - } diff --git a/src/Phalcon/Assets/Collection.php b/src/Phalcon/Assets/Collection.php index 430013f2..e4fd9766 100644 --- a/src/Phalcon/Assets/Collection.php +++ b/src/Phalcon/Assets/Collection.php @@ -492,5 +492,4 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } - } diff --git a/src/Phalcon/Assets/FilterInterface.php b/src/Phalcon/Assets/FilterInterface.php index 9fdbdef2..a93e24c8 100644 --- a/src/Phalcon/Assets/FilterInterface.php +++ b/src/Phalcon/Assets/FilterInterface.php @@ -22,5 +22,4 @@ interface FilterInterface * @return string */ public function filter(string $content): string; - } diff --git a/src/Phalcon/Assets/Filters/Cssmin.php b/src/Phalcon/Assets/Filters/Cssmin.php index 8bfc92fa..8c2698e6 100644 --- a/src/Phalcon/Assets/Filters/Cssmin.php +++ b/src/Phalcon/Assets/Filters/Cssmin.php @@ -26,5 +26,4 @@ class Cssmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Filters/Jsmin.php b/src/Phalcon/Assets/Filters/Jsmin.php index 822c0515..e0701838 100644 --- a/src/Phalcon/Assets/Filters/Jsmin.php +++ b/src/Phalcon/Assets/Filters/Jsmin.php @@ -27,5 +27,4 @@ class Jsmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Filters/None.php b/src/Phalcon/Assets/Filters/None.php index 85509aed..a5e19df9 100644 --- a/src/Phalcon/Assets/Filters/None.php +++ b/src/Phalcon/Assets/Filters/None.php @@ -24,5 +24,4 @@ class None implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Inline.php b/src/Phalcon/Assets/Inline.php index 862368ec..8a76055b 100644 --- a/src/Phalcon/Assets/Inline.php +++ b/src/Phalcon/Assets/Inline.php @@ -117,5 +117,4 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } - } diff --git a/src/Phalcon/Assets/Inline/Css.php b/src/Phalcon/Assets/Inline/Css.php index f1920e72..2353cd4e 100644 --- a/src/Phalcon/Assets/Inline/Css.php +++ b/src/Phalcon/Assets/Inline/Css.php @@ -25,5 +25,4 @@ class Css extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/Assets/Inline/Js.php b/src/Phalcon/Assets/Inline/Js.php index 6d332d4b..1ec6fd4e 100644 --- a/src/Phalcon/Assets/Inline/Js.php +++ b/src/Phalcon/Assets/Inline/Js.php @@ -25,5 +25,4 @@ class Js extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/Assets/Manager.php b/src/Phalcon/Assets/Manager.php index 5ffeb528..9386ec9a 100644 --- a/src/Phalcon/Assets/Manager.php +++ b/src/Phalcon/Assets/Manager.php @@ -358,5 +358,4 @@ public function useImplicitOutput(bool $implicitOutput): Manager private function getPrefixedPath(Collection $collection, string $path): string { } - } diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index 0540bd23..cf660ec4 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -173,5 +173,4 @@ protected function checkKey($key) protected function checkKeys($keys) { } - } diff --git a/src/Phalcon/Cache/AdapterFactory.php b/src/Phalcon/Cache/AdapterFactory.php index 79bf2e3c..baee1b7e 100644 --- a/src/Phalcon/Cache/AdapterFactory.php +++ b/src/Phalcon/Cache/AdapterFactory.php @@ -53,5 +53,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Cache/CacheFactory.php b/src/Phalcon/Cache/CacheFactory.php index 18e85bb2..794af9f5 100644 --- a/src/Phalcon/Cache/CacheFactory.php +++ b/src/Phalcon/Cache/CacheFactory.php @@ -51,5 +51,4 @@ public function load($config) public function newInstance(string $name, array $options = array()): CacheInterface { } - } diff --git a/src/Phalcon/Cli/Console.php b/src/Phalcon/Cli/Console.php index 13506d43..b0b15ca9 100644 --- a/src/Phalcon/Cli/Console.php +++ b/src/Phalcon/Cli/Console.php @@ -47,5 +47,4 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } - } diff --git a/src/Phalcon/Cli/Dispatcher.php b/src/Phalcon/Cli/Dispatcher.php index a0090e81..aa31c964 100644 --- a/src/Phalcon/Cli/Dispatcher.php +++ b/src/Phalcon/Cli/Dispatcher.php @@ -191,5 +191,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/Cli/DispatcherInterface.php b/src/Phalcon/Cli/DispatcherInterface.php index dc877448..f4f6c0f5 100644 --- a/src/Phalcon/Cli/DispatcherInterface.php +++ b/src/Phalcon/Cli/DispatcherInterface.php @@ -83,5 +83,4 @@ public function setTaskName(string $taskName); * @return void */ public function setTaskSuffix(string $taskSuffix); - } diff --git a/src/Phalcon/Cli/Router.php b/src/Phalcon/Cli/Router.php index fb84ba98..861414e1 100644 --- a/src/Phalcon/Cli/Router.php +++ b/src/Phalcon/Cli/Router.php @@ -248,5 +248,4 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } - } diff --git a/src/Phalcon/Cli/Router/Route.php b/src/Phalcon/Cli/Router/Route.php index 4d5f3ee1..eb98027e 100644 --- a/src/Phalcon/Cli/Router/Route.php +++ b/src/Phalcon/Cli/Router/Route.php @@ -30,7 +30,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $delimiter; - static protected $delimiterPath = self::DEFAULT_DELIMITER; + protected static $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -48,7 +48,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; /** @@ -252,5 +252,4 @@ public function setDescription(string $description): RouteInterface public function setName(string $name): RouteInterface { } - } diff --git a/src/Phalcon/Cli/Router/RouteInterface.php b/src/Phalcon/Cli/Router/RouteInterface.php index 7730db7d..de7f9f28 100644 --- a/src/Phalcon/Cli/Router/RouteInterface.php +++ b/src/Phalcon/Cli/Router/RouteInterface.php @@ -118,5 +118,4 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; - } diff --git a/src/Phalcon/Cli/RouterInterface.php b/src/Phalcon/Cli/RouterInterface.php index f304abec..7c6c9571 100644 --- a/src/Phalcon/Cli/RouterInterface.php +++ b/src/Phalcon/Cli/RouterInterface.php @@ -136,5 +136,4 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/Cli/Task.php b/src/Phalcon/Cli/Task.php index 28a5e58e..02010ee6 100644 --- a/src/Phalcon/Cli/Task.php +++ b/src/Phalcon/Cli/Task.php @@ -67,5 +67,4 @@ public function getEventsManager(): ?ManagerInterface public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index bbeb32f6..0c8dd5af 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -299,5 +299,4 @@ public function unserialize($serialized) protected function setData(string $element, $value) { } - } diff --git a/src/Phalcon/Collection/ReadOnly.php b/src/Phalcon/Collection/ReadOnly.php index cc06d071..28ca4011 100644 --- a/src/Phalcon/Collection/ReadOnly.php +++ b/src/Phalcon/Collection/ReadOnly.php @@ -37,5 +37,4 @@ public function remove(string $element) public function set(string $element, $value) { } - } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index e5531b65..6339dff4 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -137,5 +137,4 @@ final protected function internalMerge(array $source, array $target): array protected function setData($element, $value) { } - } diff --git a/src/Phalcon/Config/Adapter/Grouped.php b/src/Phalcon/Config/Adapter/Grouped.php index 0fb590f0..23fb326f 100644 --- a/src/Phalcon/Config/Adapter/Grouped.php +++ b/src/Phalcon/Config/Adapter/Grouped.php @@ -74,5 +74,4 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } - } diff --git a/src/Phalcon/Config/Adapter/Ini.php b/src/Phalcon/Config/Adapter/Ini.php index 1f859292..2d94f022 100644 --- a/src/Phalcon/Config/Adapter/Ini.php +++ b/src/Phalcon/Config/Adapter/Ini.php @@ -87,5 +87,4 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } - } diff --git a/src/Phalcon/Config/Adapter/Json.php b/src/Phalcon/Config/Adapter/Json.php index c4feb76a..4c4b1e3f 100644 --- a/src/Phalcon/Config/Adapter/Json.php +++ b/src/Phalcon/Config/Adapter/Json.php @@ -42,5 +42,4 @@ class Json extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/Config/Adapter/Php.php b/src/Phalcon/Config/Adapter/Php.php index f94da213..30ee68a9 100644 --- a/src/Phalcon/Config/Adapter/Php.php +++ b/src/Phalcon/Config/Adapter/Php.php @@ -57,5 +57,4 @@ class Php extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/Config/Adapter/Yaml.php b/src/Phalcon/Config/Adapter/Yaml.php index d290eab0..b4713fba 100644 --- a/src/Phalcon/Config/Adapter/Yaml.php +++ b/src/Phalcon/Config/Adapter/Yaml.php @@ -60,5 +60,4 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } - } diff --git a/src/Phalcon/Config/ConfigFactory.php b/src/Phalcon/Config/ConfigFactory.php index ed023eb7..be130d32 100644 --- a/src/Phalcon/Config/ConfigFactory.php +++ b/src/Phalcon/Config/ConfigFactory.php @@ -68,5 +68,4 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 36e22a2e..fe533a3c 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -50,5 +50,4 @@ public function get($name) public function has($name): bool { } - } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index d23d17bf..add83cf9 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -407,5 +407,4 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } - } diff --git a/src/Phalcon/Crypt/CryptInterface.php b/src/Phalcon/Crypt/CryptInterface.php index 5f30daa2..d33f3ddc 100644 --- a/src/Phalcon/Crypt/CryptInterface.php +++ b/src/Phalcon/Crypt/CryptInterface.php @@ -140,5 +140,4 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; - } diff --git a/src/Phalcon/Db/AbstractDb.php b/src/Phalcon/Db/AbstractDb.php index f98e83b0..7ee0ca46 100644 --- a/src/Phalcon/Db/AbstractDb.php +++ b/src/Phalcon/Db/AbstractDb.php @@ -64,5 +64,4 @@ abstract class AbstractDb public static function setup(array $options) { } - } diff --git a/src/Phalcon/Db/Adapter/AbstractAdapter.php b/src/Phalcon/Db/Adapter/AbstractAdapter.php index 783491cb..d09a00f4 100644 --- a/src/Phalcon/Db/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Db/Adapter/AbstractAdapter.php @@ -22,7 +22,7 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, /** * Connection ID */ - static protected $connectionConsecutive = 0; + protected static $connectionConsecutive = 0; /** * Active connection ID @@ -927,5 +927,4 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } - } diff --git a/src/Phalcon/Db/Adapter/AdapterInterface.php b/src/Phalcon/Db/Adapter/AdapterInterface.php index 693d5d1c..2e2e691f 100644 --- a/src/Phalcon/Db/Adapter/AdapterInterface.php +++ b/src/Phalcon/Db/Adapter/AdapterInterface.php @@ -628,5 +628,4 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; - } diff --git a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php index 349ee165..87b45d63 100644 --- a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php @@ -373,5 +373,4 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Mysql.php b/src/Phalcon/Db/Adapter/Pdo/Mysql.php index 2c98b823..c72a284f 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Mysql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Mysql.php @@ -110,5 +110,4 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php index 7742e96a..5235f722 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php @@ -174,5 +174,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php index d787d148..ebec76be 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php +++ b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php @@ -145,5 +145,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/PdoFactory.php b/src/Phalcon/Db/Adapter/PdoFactory.php index f2f06b3c..b243a7d7 100644 --- a/src/Phalcon/Db/Adapter/PdoFactory.php +++ b/src/Phalcon/Db/Adapter/PdoFactory.php @@ -60,5 +60,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Db/Column.php b/src/Phalcon/Db/Column.php index d646e799..bfadbc3e 100644 --- a/src/Phalcon/Db/Column.php +++ b/src/Phalcon/Db/Column.php @@ -453,5 +453,4 @@ public function isPrimary(): bool public function isUnsigned(): bool { } - } diff --git a/src/Phalcon/Db/ColumnInterface.php b/src/Phalcon/Db/ColumnInterface.php index 4dde08e8..4860a22b 100644 --- a/src/Phalcon/Db/ColumnInterface.php +++ b/src/Phalcon/Db/ColumnInterface.php @@ -126,5 +126,4 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; - } diff --git a/src/Phalcon/Db/Dialect.php b/src/Phalcon/Db/Dialect.php index e1b85297..63bd2a63 100644 --- a/src/Phalcon/Db/Dialect.php +++ b/src/Phalcon/Db/Dialect.php @@ -509,5 +509,4 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } - } diff --git a/src/Phalcon/Db/Dialect/Mysql.php b/src/Phalcon/Db/Dialect/Mysql.php index 7f099f5e..eeef5199 100644 --- a/src/Phalcon/Db/Dialect/Mysql.php +++ b/src/Phalcon/Db/Dialect/Mysql.php @@ -358,5 +358,4 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string { } - } diff --git a/src/Phalcon/Db/Dialect/Postgresql.php b/src/Phalcon/Db/Dialect/Postgresql.php index 342c20b4..4e57d5f8 100644 --- a/src/Phalcon/Db/Dialect/Postgresql.php +++ b/src/Phalcon/Db/Dialect/Postgresql.php @@ -329,5 +329,4 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } - } diff --git a/src/Phalcon/Db/Dialect/Sqlite.php b/src/Phalcon/Db/Dialect/Sqlite.php index a436f2de..3b2a56cc 100644 --- a/src/Phalcon/Db/Dialect/Sqlite.php +++ b/src/Phalcon/Db/Dialect/Sqlite.php @@ -352,5 +352,4 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } - } diff --git a/src/Phalcon/Db/DialectInterface.php b/src/Phalcon/Db/DialectInterface.php index 208f30ee..fa6b3057 100644 --- a/src/Phalcon/Db/DialectInterface.php +++ b/src/Phalcon/Db/DialectInterface.php @@ -319,5 +319,4 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; - } diff --git a/src/Phalcon/Db/Enum.php b/src/Phalcon/Db/Enum.php index d826fa71..cff4d17c 100644 --- a/src/Phalcon/Db/Enum.php +++ b/src/Phalcon/Db/Enum.php @@ -64,6 +64,4 @@ class Enum const FETCH_UNIQUE = 196608; - - } diff --git a/src/Phalcon/Db/Index.php b/src/Phalcon/Db/Index.php index 586c8433..1832a2f8 100644 --- a/src/Phalcon/Db/Index.php +++ b/src/Phalcon/Db/Index.php @@ -99,5 +99,4 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } - } diff --git a/src/Phalcon/Db/IndexInterface.php b/src/Phalcon/Db/IndexInterface.php index f1a7074c..d981c426 100644 --- a/src/Phalcon/Db/IndexInterface.php +++ b/src/Phalcon/Db/IndexInterface.php @@ -35,5 +35,4 @@ public function getName(): string; * @return string */ public function getType(): string; - } diff --git a/src/Phalcon/Db/Profiler.php b/src/Phalcon/Db/Profiler.php index 60c783a5..96fe89e0 100644 --- a/src/Phalcon/Db/Profiler.php +++ b/src/Phalcon/Db/Profiler.php @@ -150,5 +150,4 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } - } diff --git a/src/Phalcon/Db/Profiler/Item.php b/src/Phalcon/Db/Profiler/Item.php index 24610248..71b5487b 100644 --- a/src/Phalcon/Db/Profiler/Item.php +++ b/src/Phalcon/Db/Profiler/Item.php @@ -148,5 +148,4 @@ public function getSqlVariables(): array public function getTotalElapsedSeconds(): float { } - } diff --git a/src/Phalcon/Db/RawValue.php b/src/Phalcon/Db/RawValue.php index 27a98c78..1ecfc9b1 100644 --- a/src/Phalcon/Db/RawValue.php +++ b/src/Phalcon/Db/RawValue.php @@ -59,5 +59,4 @@ public function __toString(): string public function __construct($value) { } - } diff --git a/src/Phalcon/Db/Reference.php b/src/Phalcon/Db/Reference.php index 5763cd2a..04964948 100644 --- a/src/Phalcon/Db/Reference.php +++ b/src/Phalcon/Db/Reference.php @@ -170,5 +170,4 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } - } diff --git a/src/Phalcon/Db/ReferenceInterface.php b/src/Phalcon/Db/ReferenceInterface.php index 9e2a3bf1..c28ff533 100644 --- a/src/Phalcon/Db/ReferenceInterface.php +++ b/src/Phalcon/Db/ReferenceInterface.php @@ -70,5 +70,4 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; - } diff --git a/src/Phalcon/Db/Result/Pdo.php b/src/Phalcon/Db/Result/Pdo.php index 3552dc33..ab2ffa8f 100644 --- a/src/Phalcon/Db/Result/Pdo.php +++ b/src/Phalcon/Db/Result/Pdo.php @@ -233,5 +233,4 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } - } diff --git a/src/Phalcon/Db/ResultInterface.php b/src/Phalcon/Db/ResultInterface.php index 93923545..5f7abd5c 100644 --- a/src/Phalcon/Db/ResultInterface.php +++ b/src/Phalcon/Db/ResultInterface.php @@ -80,5 +80,4 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; - } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 368851a6..8911041f 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -30,7 +30,7 @@ class Debug /** * @var bool */ - static protected $isActive; + protected static $isActive; /** * @var bool @@ -254,5 +254,4 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } - } diff --git a/src/Phalcon/Debug/Dump.php b/src/Phalcon/Debug/Dump.php index 9eb9eed7..aad14563 100644 --- a/src/Phalcon/Debug/Dump.php +++ b/src/Phalcon/Debug/Dump.php @@ -175,5 +175,4 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } - } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index c5d7ac56..d5194233 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -73,7 +73,7 @@ class Di implements \Phalcon\Di\DiInterface /** * Latest DI build */ - static protected $_default; + protected static $_default; /** @@ -426,5 +426,4 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition public function setShared(string $name, $definition): ServiceInterface { } - } diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Phalcon/Di/AbstractInjectionAware.php index 1938a255..d9f43b71 100644 --- a/src/Phalcon/Di/AbstractInjectionAware.php +++ b/src/Phalcon/Di/AbstractInjectionAware.php @@ -40,5 +40,4 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } - } diff --git a/src/Phalcon/Di/DiInterface.php b/src/Phalcon/Di/DiInterface.php index 2cdcc2ce..0afcd9a9 100644 --- a/src/Phalcon/Di/DiInterface.php +++ b/src/Phalcon/Di/DiInterface.php @@ -134,5 +134,4 @@ public function setRaw(string $name, ServiceInterface $rawDefinition): ServiceIn * @return ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; - } diff --git a/src/Phalcon/Di/FactoryDefault.php b/src/Phalcon/Di/FactoryDefault.php index 5ef10181..6d8546f6 100644 --- a/src/Phalcon/Di/FactoryDefault.php +++ b/src/Phalcon/Di/FactoryDefault.php @@ -24,5 +24,4 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } - } diff --git a/src/Phalcon/Di/FactoryDefault/Cli.php b/src/Phalcon/Di/FactoryDefault/Cli.php index 2536e2aa..d2d3c9be 100644 --- a/src/Phalcon/Di/FactoryDefault/Cli.php +++ b/src/Phalcon/Di/FactoryDefault/Cli.php @@ -28,5 +28,4 @@ class Cli extends FactoryDefault public function __construct() { } - } diff --git a/src/Phalcon/Di/Injectable.php b/src/Phalcon/Di/Injectable.php index d22f46de..6fab0c01 100644 --- a/src/Phalcon/Di/Injectable.php +++ b/src/Phalcon/Di/Injectable.php @@ -88,5 +88,4 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } - } diff --git a/src/Phalcon/Di/InjectionAwareInterface.php b/src/Phalcon/Di/InjectionAwareInterface.php index 72cd4198..97b68a27 100644 --- a/src/Phalcon/Di/InjectionAwareInterface.php +++ b/src/Phalcon/Di/InjectionAwareInterface.php @@ -30,5 +30,4 @@ public function setDI(DiInterface $container); * @return DiInterface */ public function getDI(): DiInterface; - } diff --git a/src/Phalcon/Di/Service.php b/src/Phalcon/Di/Service.php index 8288d118..f3db7b4a 100644 --- a/src/Phalcon/Di/Service.php +++ b/src/Phalcon/Di/Service.php @@ -138,5 +138,4 @@ public function setShared(bool $shared) public function setSharedInstance($sharedInstance) { } - } diff --git a/src/Phalcon/Di/Service/Builder.php b/src/Phalcon/Di/Service/Builder.php index 57fffd66..b8a5a1f3 100644 --- a/src/Phalcon/Di/Service/Builder.php +++ b/src/Phalcon/Di/Service/Builder.php @@ -51,5 +51,4 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array { } - } diff --git a/src/Phalcon/Di/ServiceInterface.php b/src/Phalcon/Di/ServiceInterface.php index 31af1fe3..52c09130 100644 --- a/src/Phalcon/Di/ServiceInterface.php +++ b/src/Phalcon/Di/ServiceInterface.php @@ -75,5 +75,4 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); - } diff --git a/src/Phalcon/Di/ServiceProviderInterface.php b/src/Phalcon/Di/ServiceProviderInterface.php index bde1316f..497bac34 100644 --- a/src/Phalcon/Di/ServiceProviderInterface.php +++ b/src/Phalcon/Di/ServiceProviderInterface.php @@ -43,5 +43,4 @@ interface ServiceProviderInterface * @return void */ public function register(DiInterface $di); - } diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php index d93b081b..7b307449 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -484,5 +484,4 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } - } diff --git a/src/Phalcon/Dispatcher/DispatcherInterface.php b/src/Phalcon/Dispatcher/DispatcherInterface.php index 952c39e1..8b7244f9 100644 --- a/src/Phalcon/Dispatcher/DispatcherInterface.php +++ b/src/Phalcon/Dispatcher/DispatcherInterface.php @@ -162,5 +162,4 @@ public function setParam($param, $value); * @return void */ public function setParams(array $params); - } diff --git a/src/Phalcon/Dispatcher/Exception.php b/src/Phalcon/Dispatcher/Exception.php index fb0da6ee..940db816 100644 --- a/src/Phalcon/Dispatcher/Exception.php +++ b/src/Phalcon/Dispatcher/Exception.php @@ -31,6 +31,4 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; - - } diff --git a/src/Phalcon/Domain/Payload/Payload.php b/src/Phalcon/Domain/Payload/Payload.php index ca684c8e..1046c7ac 100644 --- a/src/Phalcon/Domain/Payload/Payload.php +++ b/src/Phalcon/Domain/Payload/Payload.php @@ -144,5 +144,4 @@ public function setOutput($output): PayloadInterface public function setStatus($status): PayloadInterface { } - } diff --git a/src/Phalcon/Domain/Payload/PayloadFactory.php b/src/Phalcon/Domain/Payload/PayloadFactory.php index 518657a0..adc02bfd 100644 --- a/src/Phalcon/Domain/Payload/PayloadFactory.php +++ b/src/Phalcon/Domain/Payload/PayloadFactory.php @@ -23,5 +23,4 @@ class PayloadFactory public function newInstance(): PayloadInterface { } - } diff --git a/src/Phalcon/Domain/Payload/ReadableInterface.php b/src/Phalcon/Domain/Payload/ReadableInterface.php index 0e3fbad3..c482a277 100644 --- a/src/Phalcon/Domain/Payload/ReadableInterface.php +++ b/src/Phalcon/Domain/Payload/ReadableInterface.php @@ -49,5 +49,4 @@ public function getMessages(); * @return mixed */ public function getExtras(); - } diff --git a/src/Phalcon/Domain/Payload/Status.php b/src/Phalcon/Domain/Payload/Status.php index 03f52886..292e2da0 100644 --- a/src/Phalcon/Domain/Payload/Status.php +++ b/src/Phalcon/Domain/Payload/Status.php @@ -81,5 +81,4 @@ class Status final private function __construct() { } - } diff --git a/src/Phalcon/Domain/Payload/WriteableInterface.php b/src/Phalcon/Domain/Payload/WriteableInterface.php index 0228bb9e..bd44b3e0 100644 --- a/src/Phalcon/Domain/Payload/WriteableInterface.php +++ b/src/Phalcon/Domain/Payload/WriteableInterface.php @@ -56,5 +56,4 @@ public function setMessages($messages): PayloadInterface; * @return PayloadInterface */ public function setExtras($extras): PayloadInterface; - } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index eb891448..01954765 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -169,5 +169,4 @@ public function setEncoding(string $encoding) public function setHtmlQuoteType(int $quoteType) { } - } diff --git a/src/Phalcon/Escaper/EscaperInterface.php b/src/Phalcon/Escaper/EscaperInterface.php index d067a4d3..09e2ba21 100644 --- a/src/Phalcon/Escaper/EscaperInterface.php +++ b/src/Phalcon/Escaper/EscaperInterface.php @@ -79,5 +79,4 @@ public function setEncoding(string $encoding); * @return void */ public function setHtmlQuoteType(int $quoteType); - } diff --git a/src/Phalcon/Events/Event.php b/src/Phalcon/Events/Event.php index a59342ca..a2c97950 100644 --- a/src/Phalcon/Events/Event.php +++ b/src/Phalcon/Events/Event.php @@ -159,5 +159,4 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } - } diff --git a/src/Phalcon/Events/EventInterface.php b/src/Phalcon/Events/EventInterface.php index 02ed6dd1..51e4b8e8 100644 --- a/src/Phalcon/Events/EventInterface.php +++ b/src/Phalcon/Events/EventInterface.php @@ -67,5 +67,4 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; - } diff --git a/src/Phalcon/Events/EventsAwareInterface.php b/src/Phalcon/Events/EventsAwareInterface.php index aa0509f4..f35d4f45 100644 --- a/src/Phalcon/Events/EventsAwareInterface.php +++ b/src/Phalcon/Events/EventsAwareInterface.php @@ -32,5 +32,4 @@ public function getEventsManager(): ?ManagerInterface; * @return void */ public function setEventsManager(ManagerInterface $eventsManager); - } diff --git a/src/Phalcon/Events/Manager.php b/src/Phalcon/Events/Manager.php index caca4dce..90fc951f 100644 --- a/src/Phalcon/Events/Manager.php +++ b/src/Phalcon/Events/Manager.php @@ -170,5 +170,4 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } - } diff --git a/src/Phalcon/Events/ManagerInterface.php b/src/Phalcon/Events/ManagerInterface.php index e6ba4fbe..6e491e8a 100644 --- a/src/Phalcon/Events/ManagerInterface.php +++ b/src/Phalcon/Events/ManagerInterface.php @@ -73,5 +73,4 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; - } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 129c46bf..09a741b3 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -24,5 +24,4 @@ class Exception extends \Exception implements \Throwable public static function containerServiceNotFound(string $service): string { } - } diff --git a/src/Phalcon/Factory/AbstractFactory.php b/src/Phalcon/Factory/AbstractFactory.php index bace4908..d4feaa9b 100644 --- a/src/Phalcon/Factory/AbstractFactory.php +++ b/src/Phalcon/Factory/AbstractFactory.php @@ -66,5 +66,4 @@ abstract protected function getAdapters(): array; protected function init(array $services = array()) { } - } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index 4af061d9..cf5fcae8 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -175,5 +175,4 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } - } diff --git a/src/Phalcon/Filter/FilterFactory.php b/src/Phalcon/Filter/FilterFactory.php index 69735a20..649ba460 100644 --- a/src/Phalcon/Filter/FilterFactory.php +++ b/src/Phalcon/Filter/FilterFactory.php @@ -36,5 +36,4 @@ public function newInstance(): FilterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Filter/FilterInterface.php b/src/Phalcon/Filter/FilterInterface.php index a455a176..f7922641 100644 --- a/src/Phalcon/Filter/FilterInterface.php +++ b/src/Phalcon/Filter/FilterInterface.php @@ -24,5 +24,4 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); - } diff --git a/src/Phalcon/Filter/Sanitize/AbsInt.php b/src/Phalcon/Filter/Sanitize/AbsInt.php index 5b155476..3aabb4f2 100644 --- a/src/Phalcon/Filter/Sanitize/AbsInt.php +++ b/src/Phalcon/Filter/Sanitize/AbsInt.php @@ -23,5 +23,4 @@ class AbsInt public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Alnum.php b/src/Phalcon/Filter/Sanitize/Alnum.php index 29516b2e..a715f0df 100644 --- a/src/Phalcon/Filter/Sanitize/Alnum.php +++ b/src/Phalcon/Filter/Sanitize/Alnum.php @@ -23,5 +23,4 @@ class Alnum public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Alpha.php b/src/Phalcon/Filter/Sanitize/Alpha.php index 65c9ad74..33eefae7 100644 --- a/src/Phalcon/Filter/Sanitize/Alpha.php +++ b/src/Phalcon/Filter/Sanitize/Alpha.php @@ -23,5 +23,4 @@ class Alpha public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/BoolVal.php b/src/Phalcon/Filter/Sanitize/BoolVal.php index 09aa4364..67d8ec37 100644 --- a/src/Phalcon/Filter/Sanitize/BoolVal.php +++ b/src/Phalcon/Filter/Sanitize/BoolVal.php @@ -23,5 +23,4 @@ class BoolVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Email.php b/src/Phalcon/Filter/Sanitize/Email.php index 5dfab0c8..26f81b73 100644 --- a/src/Phalcon/Filter/Sanitize/Email.php +++ b/src/Phalcon/Filter/Sanitize/Email.php @@ -23,5 +23,4 @@ class Email public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/FloatVal.php b/src/Phalcon/Filter/Sanitize/FloatVal.php index 6341decf..8ab85789 100644 --- a/src/Phalcon/Filter/Sanitize/FloatVal.php +++ b/src/Phalcon/Filter/Sanitize/FloatVal.php @@ -23,5 +23,4 @@ class FloatVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/IntVal.php b/src/Phalcon/Filter/Sanitize/IntVal.php index 1583ff87..dac4e5c3 100644 --- a/src/Phalcon/Filter/Sanitize/IntVal.php +++ b/src/Phalcon/Filter/Sanitize/IntVal.php @@ -23,5 +23,4 @@ class IntVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Lower.php b/src/Phalcon/Filter/Sanitize/Lower.php index a61fa1c6..c25fda7c 100644 --- a/src/Phalcon/Filter/Sanitize/Lower.php +++ b/src/Phalcon/Filter/Sanitize/Lower.php @@ -23,5 +23,4 @@ class Lower public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/LowerFirst.php b/src/Phalcon/Filter/Sanitize/LowerFirst.php index d331cf11..9595ffff 100644 --- a/src/Phalcon/Filter/Sanitize/LowerFirst.php +++ b/src/Phalcon/Filter/Sanitize/LowerFirst.php @@ -23,5 +23,4 @@ class LowerFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Regex.php b/src/Phalcon/Filter/Sanitize/Regex.php index 8817613c..7441191b 100644 --- a/src/Phalcon/Filter/Sanitize/Regex.php +++ b/src/Phalcon/Filter/Sanitize/Regex.php @@ -25,5 +25,4 @@ class Regex public function __invoke($input, $pattern, $replace) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Remove.php b/src/Phalcon/Filter/Sanitize/Remove.php index 1c7a90e5..a8225560 100644 --- a/src/Phalcon/Filter/Sanitize/Remove.php +++ b/src/Phalcon/Filter/Sanitize/Remove.php @@ -24,5 +24,4 @@ class Remove public function __invoke($input, $replace) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Replace.php b/src/Phalcon/Filter/Sanitize/Replace.php index 05a72069..6a60ca8f 100644 --- a/src/Phalcon/Filter/Sanitize/Replace.php +++ b/src/Phalcon/Filter/Sanitize/Replace.php @@ -25,5 +25,4 @@ class Replace public function __invoke($input, $from, $to) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Special.php b/src/Phalcon/Filter/Sanitize/Special.php index 33735f44..9ab25623 100644 --- a/src/Phalcon/Filter/Sanitize/Special.php +++ b/src/Phalcon/Filter/Sanitize/Special.php @@ -23,5 +23,4 @@ class Special public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/SpecialFull.php b/src/Phalcon/Filter/Sanitize/SpecialFull.php index 5170dfb7..f57bad76 100644 --- a/src/Phalcon/Filter/Sanitize/SpecialFull.php +++ b/src/Phalcon/Filter/Sanitize/SpecialFull.php @@ -23,5 +23,4 @@ class SpecialFull public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/StringVal.php b/src/Phalcon/Filter/Sanitize/StringVal.php index 798afafc..a2fcb069 100644 --- a/src/Phalcon/Filter/Sanitize/StringVal.php +++ b/src/Phalcon/Filter/Sanitize/StringVal.php @@ -23,5 +23,4 @@ class StringVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Striptags.php b/src/Phalcon/Filter/Sanitize/Striptags.php index 94588b4a..0b8a60b2 100644 --- a/src/Phalcon/Filter/Sanitize/Striptags.php +++ b/src/Phalcon/Filter/Sanitize/Striptags.php @@ -23,5 +23,4 @@ class Striptags public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Trim.php b/src/Phalcon/Filter/Sanitize/Trim.php index 73b27c53..4d20bd15 100644 --- a/src/Phalcon/Filter/Sanitize/Trim.php +++ b/src/Phalcon/Filter/Sanitize/Trim.php @@ -23,5 +23,4 @@ class Trim public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Upper.php b/src/Phalcon/Filter/Sanitize/Upper.php index b6232b24..73eaa13a 100644 --- a/src/Phalcon/Filter/Sanitize/Upper.php +++ b/src/Phalcon/Filter/Sanitize/Upper.php @@ -23,5 +23,4 @@ class Upper public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/UpperFirst.php b/src/Phalcon/Filter/Sanitize/UpperFirst.php index 29abcedd..52a48308 100644 --- a/src/Phalcon/Filter/Sanitize/UpperFirst.php +++ b/src/Phalcon/Filter/Sanitize/UpperFirst.php @@ -23,5 +23,4 @@ class UpperFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/UpperWords.php b/src/Phalcon/Filter/Sanitize/UpperWords.php index 1a7a72e5..a0ffce76 100644 --- a/src/Phalcon/Filter/Sanitize/UpperWords.php +++ b/src/Phalcon/Filter/Sanitize/UpperWords.php @@ -23,5 +23,4 @@ class UpperWords public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Url.php b/src/Phalcon/Filter/Sanitize/Url.php index fdd131c4..8a9ee8d9 100644 --- a/src/Phalcon/Filter/Sanitize/Url.php +++ b/src/Phalcon/Filter/Sanitize/Url.php @@ -23,5 +23,4 @@ class Url public function __invoke($input) { } - } diff --git a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php index d5e2ce07..8b1b5e98 100644 --- a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php @@ -235,5 +235,4 @@ protected function saveAccessInCache(string $key, bool $access) protected function throwFirewallException(string $message, int $exceptionCode = 0): bool { } - } diff --git a/src/Phalcon/Firewall/Adapter/Acl.php b/src/Phalcon/Firewall/Adapter/Acl.php index df37cfc6..a7cd0383 100644 --- a/src/Phalcon/Firewall/Adapter/Acl.php +++ b/src/Phalcon/Firewall/Adapter/Acl.php @@ -214,5 +214,4 @@ protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher protected function saveAccessInCache(string $key, bool $access) { } - } diff --git a/src/Phalcon/Firewall/Adapter/AdapterInterface.php b/src/Phalcon/Firewall/Adapter/AdapterInterface.php index efd297f1..e356e610 100644 --- a/src/Phalcon/Firewall/Adapter/AdapterInterface.php +++ b/src/Phalcon/Firewall/Adapter/AdapterInterface.php @@ -69,5 +69,4 @@ public function setDefaultAccess(int $defaultAccess): AdapterInterface; * @return AdapterInterface */ public function setRoleCallback(\Closure $callback): AdapterInterface; - } diff --git a/src/Phalcon/Firewall/Adapter/Annotations.php b/src/Phalcon/Firewall/Adapter/Annotations.php index 5eb9cb40..38def960 100644 --- a/src/Phalcon/Firewall/Adapter/Annotations.php +++ b/src/Phalcon/Firewall/Adapter/Annotations.php @@ -133,5 +133,4 @@ protected function getAccessFromCache(string $key, array $originalValues = null, protected function handleAnnotation($annotation, bool $access, $role) { } - } diff --git a/src/Phalcon/Firewall/Adapter/Micro/Acl.php b/src/Phalcon/Firewall/Adapter/Micro/Acl.php index 7d013d6a..0d54d50a 100644 --- a/src/Phalcon/Firewall/Adapter/Micro/Acl.php +++ b/src/Phalcon/Firewall/Adapter/Micro/Acl.php @@ -240,5 +240,4 @@ protected function handleRouter(\Phalcon\Mvc\Micro $micro) protected function saveAccessInCache(string $key, bool $access) { } - } diff --git a/src/Phalcon/Flash/AbstractFlash.php b/src/Phalcon/Flash/AbstractFlash.php index de3ab534..cb3086e4 100644 --- a/src/Phalcon/Flash/AbstractFlash.php +++ b/src/Phalcon/Flash/AbstractFlash.php @@ -276,5 +276,4 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } - } diff --git a/src/Phalcon/Flash/Direct.php b/src/Phalcon/Flash/Direct.php index af28ca9c..e4a809ee 100644 --- a/src/Phalcon/Flash/Direct.php +++ b/src/Phalcon/Flash/Direct.php @@ -36,5 +36,4 @@ public function message(string $type, $message): ?string public function output(bool $remove = true) { } - } diff --git a/src/Phalcon/Flash/FlashInterface.php b/src/Phalcon/Flash/FlashInterface.php index 5ef00ebd..d311b268 100644 --- a/src/Phalcon/Flash/FlashInterface.php +++ b/src/Phalcon/Flash/FlashInterface.php @@ -57,5 +57,4 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; - } diff --git a/src/Phalcon/Flash/Session.php b/src/Phalcon/Flash/Session.php index dea4c208..4bf0687f 100644 --- a/src/Phalcon/Flash/Session.php +++ b/src/Phalcon/Flash/Session.php @@ -98,5 +98,4 @@ protected function setSessionMessages(array $messages): array public function getSessionService(): ManagerInterface { } - } diff --git a/src/Phalcon/Forms/Element/AbstractElement.php b/src/Phalcon/Forms/Element/AbstractElement.php index bd2c3213..8dbc902e 100644 --- a/src/Phalcon/Forms/Element/AbstractElement.php +++ b/src/Phalcon/Forms/Element/AbstractElement.php @@ -364,5 +364,4 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } - } diff --git a/src/Phalcon/Forms/Element/Check.php b/src/Phalcon/Forms/Element/Check.php index 0f5ae153..252045d6 100644 --- a/src/Phalcon/Forms/Element/Check.php +++ b/src/Phalcon/Forms/Element/Check.php @@ -26,5 +26,4 @@ class Check extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Date.php b/src/Phalcon/Forms/Element/Date.php index d7a24ed8..fc2cc229 100644 --- a/src/Phalcon/Forms/Element/Date.php +++ b/src/Phalcon/Forms/Element/Date.php @@ -24,5 +24,4 @@ class Date extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/ElementInterface.php b/src/Phalcon/Forms/Element/ElementInterface.php index b4ccef34..4274309b 100644 --- a/src/Phalcon/Forms/Element/ElementInterface.php +++ b/src/Phalcon/Forms/Element/ElementInterface.php @@ -263,5 +263,4 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; - } diff --git a/src/Phalcon/Forms/Element/Email.php b/src/Phalcon/Forms/Element/Email.php index 09536c67..d89895dd 100644 --- a/src/Phalcon/Forms/Element/Email.php +++ b/src/Phalcon/Forms/Element/Email.php @@ -26,5 +26,4 @@ class Email extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/File.php b/src/Phalcon/Forms/Element/File.php index c7b958d4..7085a434 100644 --- a/src/Phalcon/Forms/Element/File.php +++ b/src/Phalcon/Forms/Element/File.php @@ -24,5 +24,4 @@ class File extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Hidden.php b/src/Phalcon/Forms/Element/Hidden.php index e489d241..faa70448 100644 --- a/src/Phalcon/Forms/Element/Hidden.php +++ b/src/Phalcon/Forms/Element/Hidden.php @@ -26,5 +26,4 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Numeric.php b/src/Phalcon/Forms/Element/Numeric.php index 7de5abb1..384b8af1 100644 --- a/src/Phalcon/Forms/Element/Numeric.php +++ b/src/Phalcon/Forms/Element/Numeric.php @@ -26,5 +26,4 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Password.php b/src/Phalcon/Forms/Element/Password.php index e7cabd9a..a914d3c0 100644 --- a/src/Phalcon/Forms/Element/Password.php +++ b/src/Phalcon/Forms/Element/Password.php @@ -26,5 +26,4 @@ class Password extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Radio.php b/src/Phalcon/Forms/Element/Radio.php index d59fe9bb..c3ce28db 100644 --- a/src/Phalcon/Forms/Element/Radio.php +++ b/src/Phalcon/Forms/Element/Radio.php @@ -26,5 +26,4 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Select.php b/src/Phalcon/Forms/Element/Select.php index 77700fda..7796f076 100644 --- a/src/Phalcon/Forms/Element/Select.php +++ b/src/Phalcon/Forms/Element/Select.php @@ -69,5 +69,4 @@ public function render(array $attributes = array()): string public function setOptions($options): ElementInterface { } - } diff --git a/src/Phalcon/Forms/Element/Submit.php b/src/Phalcon/Forms/Element/Submit.php index 41c45064..36dfea82 100644 --- a/src/Phalcon/Forms/Element/Submit.php +++ b/src/Phalcon/Forms/Element/Submit.php @@ -24,5 +24,4 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Text.php b/src/Phalcon/Forms/Element/Text.php index 86a5fddb..f66ebf22 100644 --- a/src/Phalcon/Forms/Element/Text.php +++ b/src/Phalcon/Forms/Element/Text.php @@ -26,5 +26,4 @@ class Text extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/TextArea.php b/src/Phalcon/Forms/Element/TextArea.php index 7cefe5e7..b316bbf2 100644 --- a/src/Phalcon/Forms/Element/TextArea.php +++ b/src/Phalcon/Forms/Element/TextArea.php @@ -24,5 +24,4 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Form.php b/src/Phalcon/Forms/Form.php index 66738c7c..01e9d411 100644 --- a/src/Phalcon/Forms/Form.php +++ b/src/Phalcon/Forms/Form.php @@ -388,5 +388,4 @@ public function setUserOptions(array $options): Form public function valid(): bool { } - } diff --git a/src/Phalcon/Forms/Manager.php b/src/Phalcon/Forms/Manager.php index 996bea85..89f01681 100644 --- a/src/Phalcon/Forms/Manager.php +++ b/src/Phalcon/Forms/Manager.php @@ -59,5 +59,4 @@ public function has(string $name): bool public function set(string $name, Form $form): Manager { } - } diff --git a/src/Phalcon/Helper/Arr.php b/src/Phalcon/Helper/Arr.php index e9bb27a9..4181a55a 100644 --- a/src/Phalcon/Helper/Arr.php +++ b/src/Phalcon/Helper/Arr.php @@ -276,5 +276,4 @@ final private static function filterCollection(array $collection, $method = null final public static function whiteList(array $collection, array $whiteList): array { } - } diff --git a/src/Phalcon/Helper/Fs.php b/src/Phalcon/Helper/Fs.php index ada075bd..b0ad9265 100644 --- a/src/Phalcon/Helper/Fs.php +++ b/src/Phalcon/Helper/Fs.php @@ -28,5 +28,4 @@ class Fs final public static function basename(string $uri, $suffix = null): string { } - } diff --git a/src/Phalcon/Helper/Number.php b/src/Phalcon/Helper/Number.php index be55148b..09e62a95 100644 --- a/src/Phalcon/Helper/Number.php +++ b/src/Phalcon/Helper/Number.php @@ -28,5 +28,4 @@ class Number final public static function between(int $value, int $from, int $to): bool { } - } diff --git a/src/Phalcon/Helper/Str.php b/src/Phalcon/Helper/Str.php index ac9af5c2..7d3de81d 100644 --- a/src/Phalcon/Helper/Str.php +++ b/src/Phalcon/Helper/Str.php @@ -442,5 +442,4 @@ final public static function underscore(string $text): string final public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/Html/Attributes.php b/src/Phalcon/Html/Attributes.php index e060ab67..d431bbcc 100644 --- a/src/Phalcon/Html/Attributes.php +++ b/src/Phalcon/Html/Attributes.php @@ -34,5 +34,4 @@ public function render(): string public function __toString(): string { } - } diff --git a/src/Phalcon/Html/Attributes/AttributesInterface.php b/src/Phalcon/Html/Attributes/AttributesInterface.php index b0cb7391..8d5a50e0 100644 --- a/src/Phalcon/Html/Attributes/AttributesInterface.php +++ b/src/Phalcon/Html/Attributes/AttributesInterface.php @@ -33,5 +33,4 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; - } diff --git a/src/Phalcon/Html/Attributes/RenderInterface.php b/src/Phalcon/Html/Attributes/RenderInterface.php index d2a71e41..7fb01f6a 100644 --- a/src/Phalcon/Html/Attributes/RenderInterface.php +++ b/src/Phalcon/Html/Attributes/RenderInterface.php @@ -23,5 +23,4 @@ interface RenderInterface * @return string */ public function render(): string; - } diff --git a/src/Phalcon/Html/Breadcrumbs.php b/src/Phalcon/Html/Breadcrumbs.php index e6a371b1..dae1eeb7 100644 --- a/src/Phalcon/Html/Breadcrumbs.php +++ b/src/Phalcon/Html/Breadcrumbs.php @@ -128,5 +128,4 @@ public function render(): string public function toArray(): array { } - } diff --git a/src/Phalcon/Html/Helper/AbstractHelper.php b/src/Phalcon/Html/Helper/AbstractHelper.php index 4d5acd1c..8e02f3e8 100644 --- a/src/Phalcon/Html/Helper/AbstractHelper.php +++ b/src/Phalcon/Html/Helper/AbstractHelper.php @@ -88,5 +88,4 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Anchor.php b/src/Phalcon/Html/Helper/Anchor.php index 6730b1fc..2624e59f 100644 --- a/src/Phalcon/Html/Helper/Anchor.php +++ b/src/Phalcon/Html/Helper/Anchor.php @@ -26,5 +26,4 @@ class Anchor extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/AnchorRaw.php b/src/Phalcon/Html/Helper/AnchorRaw.php index 91a80136..402f7bde 100644 --- a/src/Phalcon/Html/Helper/AnchorRaw.php +++ b/src/Phalcon/Html/Helper/AnchorRaw.php @@ -26,5 +26,4 @@ class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Body.php b/src/Phalcon/Html/Helper/Body.php index e2233f65..6584697d 100644 --- a/src/Phalcon/Html/Helper/Body.php +++ b/src/Phalcon/Html/Helper/Body.php @@ -24,5 +24,4 @@ class Body extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Button.php b/src/Phalcon/Html/Helper/Button.php index d1b38b84..75de0d32 100644 --- a/src/Phalcon/Html/Helper/Button.php +++ b/src/Phalcon/Html/Helper/Button.php @@ -25,5 +25,4 @@ class Button extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Close.php b/src/Phalcon/Html/Helper/Close.php index 741496f8..3077a9fc 100644 --- a/src/Phalcon/Html/Helper/Close.php +++ b/src/Phalcon/Html/Helper/Close.php @@ -25,5 +25,4 @@ class Close extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag): string { } - } diff --git a/src/Phalcon/Html/Helper/Element.php b/src/Phalcon/Html/Helper/Element.php index ea372eda..ec33c18b 100644 --- a/src/Phalcon/Html/Helper/Element.php +++ b/src/Phalcon/Html/Helper/Element.php @@ -26,5 +26,4 @@ class Element extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/ElementRaw.php b/src/Phalcon/Html/Helper/ElementRaw.php index 13ad5f4b..e59e6900 100644 --- a/src/Phalcon/Html/Helper/ElementRaw.php +++ b/src/Phalcon/Html/Helper/ElementRaw.php @@ -30,5 +30,4 @@ class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Form.php b/src/Phalcon/Html/Helper/Form.php index 57a5fb31..41e5fd76 100644 --- a/src/Phalcon/Html/Helper/Form.php +++ b/src/Phalcon/Html/Helper/Form.php @@ -24,5 +24,4 @@ class Form extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Img.php b/src/Phalcon/Html/Helper/Img.php index 0faa56b8..1ae6623c 100644 --- a/src/Phalcon/Html/Helper/Img.php +++ b/src/Phalcon/Html/Helper/Img.php @@ -29,5 +29,4 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $src, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Label.php b/src/Phalcon/Html/Helper/Label.php index 773932c4..cf170cb5 100644 --- a/src/Phalcon/Html/Helper/Label.php +++ b/src/Phalcon/Html/Helper/Label.php @@ -28,5 +28,4 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/TextArea.php b/src/Phalcon/Html/Helper/TextArea.php index 50c632ce..63fe97a0 100644 --- a/src/Phalcon/Html/Helper/TextArea.php +++ b/src/Phalcon/Html/Helper/TextArea.php @@ -25,5 +25,4 @@ class TextArea extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Link/EvolvableLink.php b/src/Phalcon/Html/Link/EvolvableLink.php index 787dfbf9..36576364 100644 --- a/src/Phalcon/Html/Link/EvolvableLink.php +++ b/src/Phalcon/Html/Link/EvolvableLink.php @@ -98,5 +98,4 @@ public function withoutAttribute($attribute) public function withoutRel($rel) { } - } diff --git a/src/Phalcon/Html/Link/EvolvableLinkProvider.php b/src/Phalcon/Html/Link/EvolvableLinkProvider.php index 0846b9ca..46df0820 100644 --- a/src/Phalcon/Html/Link/EvolvableLinkProvider.php +++ b/src/Phalcon/Html/Link/EvolvableLinkProvider.php @@ -49,5 +49,4 @@ public function withLink(\Psr\Link\LinkInterface $link) public function withoutLink(\Psr\Link\LinkInterface $link) { } - } diff --git a/src/Phalcon/Html/Link/Link.php b/src/Phalcon/Html/Link/Link.php index 94eed4c7..96a73caa 100644 --- a/src/Phalcon/Html/Link/Link.php +++ b/src/Phalcon/Html/Link/Link.php @@ -115,5 +115,4 @@ public function isTemplated() protected function hrefIsTemplated(string $href): bool { } - } diff --git a/src/Phalcon/Html/Link/LinkProvider.php b/src/Phalcon/Html/Link/LinkProvider.php index 7b6a0adb..a7829ba5 100644 --- a/src/Phalcon/Html/Link/LinkProvider.php +++ b/src/Phalcon/Html/Link/LinkProvider.php @@ -70,5 +70,4 @@ public function getLinksByRel($rel) protected function getKey(\Psr\Link\LinkInterface $link): string { } - } diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Phalcon/Html/Link/Serializer/Header.php index 9efafa8f..cd9f5957 100644 --- a/src/Phalcon/Html/Link/Serializer/Header.php +++ b/src/Phalcon/Html/Link/Serializer/Header.php @@ -26,5 +26,4 @@ class Header implements \Phalcon\Html\Link\Serializer\SerializerInterface public function serialize(array $links): ?string { } - } diff --git a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php index 9b922a51..d2804463 100644 --- a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php +++ b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php @@ -22,5 +22,4 @@ interface SerializerInterface * @return string|null */ public function serialize(array $links): ?string; - } diff --git a/src/Phalcon/Html/TagFactory.php b/src/Phalcon/Html/TagFactory.php index 7b13153a..63c147f3 100644 --- a/src/Phalcon/Html/TagFactory.php +++ b/src/Phalcon/Html/TagFactory.php @@ -48,5 +48,4 @@ public function newInstance(string $name) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Http/Cookie.php b/src/Phalcon/Http/Cookie.php index e9da6a27..e9159ba8 100644 --- a/src/Phalcon/Http/Cookie.php +++ b/src/Phalcon/Http/Cookie.php @@ -284,5 +284,4 @@ public function useEncryption(bool $useEncryption): CookieInterface protected function assertSignKeyIsLongEnough(string $signKey) { } - } diff --git a/src/Phalcon/Http/CookieInterface.php b/src/Phalcon/Http/CookieInterface.php index 1477dc8a..39573562 100644 --- a/src/Phalcon/Http/CookieInterface.php +++ b/src/Phalcon/Http/CookieInterface.php @@ -142,5 +142,4 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; - } diff --git a/src/Phalcon/Http/Message/AbstractCommon.php b/src/Phalcon/Http/Message/AbstractCommon.php index ed1e45e0..91c209e8 100644 --- a/src/Phalcon/Http/Message/AbstractCommon.php +++ b/src/Phalcon/Http/Message/AbstractCommon.php @@ -49,5 +49,4 @@ final protected function checkStringParameter($element) final protected function processWith($element, string $property) { } - } diff --git a/src/Phalcon/Http/Message/AbstractMessage.php b/src/Phalcon/Http/Message/AbstractMessage.php index 22907bad..8073f424 100644 --- a/src/Phalcon/Http/Message/AbstractMessage.php +++ b/src/Phalcon/Http/Message/AbstractMessage.php @@ -406,5 +406,4 @@ final protected function processHeaders($headers): Collection final protected function processProtocol($protocol = ''): string { } - } diff --git a/src/Phalcon/Http/Message/AbstractRequest.php b/src/Phalcon/Http/Message/AbstractRequest.php index 58a23a84..fd605d15 100644 --- a/src/Phalcon/Http/Message/AbstractRequest.php +++ b/src/Phalcon/Http/Message/AbstractRequest.php @@ -182,5 +182,4 @@ final protected function processMethod($method = ''): string final protected function processUri($uri): UriInterface { } - } diff --git a/src/Phalcon/Http/Message/Request.php b/src/Phalcon/Http/Message/Request.php index 484dd5af..802c9ceb 100644 --- a/src/Phalcon/Http/Message/Request.php +++ b/src/Phalcon/Http/Message/Request.php @@ -30,5 +30,4 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } - } diff --git a/src/Phalcon/Http/Message/RequestFactory.php b/src/Phalcon/Http/Message/RequestFactory.php index faef1c72..b7bd65e4 100644 --- a/src/Phalcon/Http/Message/RequestFactory.php +++ b/src/Phalcon/Http/Message/RequestFactory.php @@ -30,5 +30,4 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface public function createRequest(string $method, $uri): RequestInterface { } - } diff --git a/src/Phalcon/Http/Message/Response.php b/src/Phalcon/Http/Message/Response.php index 996e4aef..cfb4ec27 100644 --- a/src/Phalcon/Http/Message/Response.php +++ b/src/Phalcon/Http/Message/Response.php @@ -146,5 +146,4 @@ private function getPhrases(): array private function processCode($code, $phrase = '') { } - } diff --git a/src/Phalcon/Http/Message/ResponseFactory.php b/src/Phalcon/Http/Message/ResponseFactory.php index 2b1b0bc8..7491c31a 100644 --- a/src/Phalcon/Http/Message/ResponseFactory.php +++ b/src/Phalcon/Http/Message/ResponseFactory.php @@ -32,5 +32,4 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } - } diff --git a/src/Phalcon/Http/Message/ServerRequest.php b/src/Phalcon/Http/Message/ServerRequest.php index 9f668251..e11cfb58 100644 --- a/src/Phalcon/Http/Message/ServerRequest.php +++ b/src/Phalcon/Http/Message/ServerRequest.php @@ -364,5 +364,4 @@ public function withoutAttribute($name): ServerRequest private function checkUploadedFiles(array $files) { } - } diff --git a/src/Phalcon/Http/Message/ServerRequestFactory.php b/src/Phalcon/Http/Message/ServerRequestFactory.php index 7dd6a7ea..65dbc874 100644 --- a/src/Phalcon/Http/Message/ServerRequestFactory.php +++ b/src/Phalcon/Http/Message/ServerRequestFactory.php @@ -241,5 +241,4 @@ private function parseUploadedFiles(array $files): Collection private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri { } - } diff --git a/src/Phalcon/Http/Message/Stream.php b/src/Phalcon/Http/Message/Stream.php index f0bf06b5..d01bbcb5 100644 --- a/src/Phalcon/Http/Message/Stream.php +++ b/src/Phalcon/Http/Message/Stream.php @@ -250,5 +250,4 @@ private function checkSeekable() private function checkWritable() { } - } diff --git a/src/Phalcon/Http/Message/Stream/Input.php b/src/Phalcon/Http/Message/Stream/Input.php index bb33507f..2e3f6696 100644 --- a/src/Phalcon/Http/Message/Stream/Input.php +++ b/src/Phalcon/Http/Message/Stream/Input.php @@ -89,5 +89,4 @@ public function isWritable(): bool public function read($length): string { } - } diff --git a/src/Phalcon/Http/Message/Stream/Memory.php b/src/Phalcon/Http/Message/Stream/Memory.php index 2f83336f..efa30ca4 100644 --- a/src/Phalcon/Http/Message/Stream/Memory.php +++ b/src/Phalcon/Http/Message/Stream/Memory.php @@ -29,5 +29,4 @@ class Memory extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/Http/Message/Stream/Temp.php b/src/Phalcon/Http/Message/Stream/Temp.php index bd28c2f7..13dc1d8c 100644 --- a/src/Phalcon/Http/Message/Stream/Temp.php +++ b/src/Phalcon/Http/Message/Stream/Temp.php @@ -29,5 +29,4 @@ class Temp extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/Http/Message/StreamFactory.php b/src/Phalcon/Http/Message/StreamFactory.php index 911a1512..f8401d0d 100644 --- a/src/Phalcon/Http/Message/StreamFactory.php +++ b/src/Phalcon/Http/Message/StreamFactory.php @@ -61,5 +61,4 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St public function createStreamFromResource($phpResource): StreamInterface { } - } diff --git a/src/Phalcon/Http/Message/UploadedFile.php b/src/Phalcon/Http/Message/UploadedFile.php index 20d2ca4b..d309089f 100644 --- a/src/Phalcon/Http/Message/UploadedFile.php +++ b/src/Phalcon/Http/Message/UploadedFile.php @@ -271,5 +271,4 @@ private function getErrorDescription(int $error): string private function storeFile(string $targetPath) { } - } diff --git a/src/Phalcon/Http/Message/UploadedFileFactory.php b/src/Phalcon/Http/Message/UploadedFileFactory.php index 7b553ac2..e01d2ad4 100644 --- a/src/Phalcon/Http/Message/UploadedFileFactory.php +++ b/src/Phalcon/Http/Message/UploadedFileFactory.php @@ -41,5 +41,4 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } - } diff --git a/src/Phalcon/Http/Message/Uri.php b/src/Phalcon/Http/Message/Uri.php index 93f6483c..2b20450a 100644 --- a/src/Phalcon/Http/Message/Uri.php +++ b/src/Phalcon/Http/Message/Uri.php @@ -472,5 +472,4 @@ private function filterScheme(string $scheme): string private function splitQueryValue(string $element): array { } - } diff --git a/src/Phalcon/Http/Message/UriFactory.php b/src/Phalcon/Http/Message/UriFactory.php index 81168be2..221ceffd 100644 --- a/src/Phalcon/Http/Message/UriFactory.php +++ b/src/Phalcon/Http/Message/UriFactory.php @@ -28,5 +28,4 @@ final class UriFactory implements \Psr\Http\Message\UriFactoryInterface public function createUri(string $uri = ''): UriInterface { } - } diff --git a/src/Phalcon/Http/Request.php b/src/Phalcon/Http/Request.php index 77188ec6..6d54dfb5 100644 --- a/src/Phalcon/Http/Request.php +++ b/src/Phalcon/Http/Request.php @@ -862,5 +862,4 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } - } diff --git a/src/Phalcon/Http/Request/File.php b/src/Phalcon/Http/Request/File.php index e9e9d497..eb3c6500 100644 --- a/src/Phalcon/Http/Request/File.php +++ b/src/Phalcon/Http/Request/File.php @@ -160,5 +160,4 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } - } diff --git a/src/Phalcon/Http/Request/FileInterface.php b/src/Phalcon/Http/Request/FileInterface.php index 220db2e3..70ed6b22 100644 --- a/src/Phalcon/Http/Request/FileInterface.php +++ b/src/Phalcon/Http/Request/FileInterface.php @@ -60,5 +60,4 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; - } diff --git a/src/Phalcon/Http/RequestInterface.php b/src/Phalcon/Http/RequestInterface.php index 7724af2f..96b2bee0 100644 --- a/src/Phalcon/Http/RequestInterface.php +++ b/src/Phalcon/Http/RequestInterface.php @@ -508,5 +508,4 @@ public function isTrace(): bool; * @return int */ public function numFiles(bool $onlySuccessful = false): int; - } diff --git a/src/Phalcon/Http/Response.php b/src/Phalcon/Http/Response.php index dd2ee8e3..bb19e53d 100644 --- a/src/Phalcon/Http/Response.php +++ b/src/Phalcon/Http/Response.php @@ -483,5 +483,4 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } - } diff --git a/src/Phalcon/Http/Response/Cookies.php b/src/Phalcon/Http/Response/Cookies.php index be8de066..17ced24f 100644 --- a/src/Phalcon/Http/Response/Cookies.php +++ b/src/Phalcon/Http/Response/Cookies.php @@ -215,5 +215,4 @@ public function setSignKey(string $signKey = null): CookieInterface public function useEncryption(bool $useEncryption): CookiesInterface { } - } diff --git a/src/Phalcon/Http/Response/CookiesInterface.php b/src/Phalcon/Http/Response/CookiesInterface.php index 1bffce49..917e5155 100644 --- a/src/Phalcon/Http/Response/CookiesInterface.php +++ b/src/Phalcon/Http/Response/CookiesInterface.php @@ -86,5 +86,4 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; - } diff --git a/src/Phalcon/Http/Response/Headers.php b/src/Phalcon/Http/Response/Headers.php index 9f181adb..4104cfdd 100644 --- a/src/Phalcon/Http/Response/Headers.php +++ b/src/Phalcon/Http/Response/Headers.php @@ -95,5 +95,4 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } - } diff --git a/src/Phalcon/Http/Response/HeadersInterface.php b/src/Phalcon/Http/Response/HeadersInterface.php index c72a5305..471b9471 100644 --- a/src/Phalcon/Http/Response/HeadersInterface.php +++ b/src/Phalcon/Http/Response/HeadersInterface.php @@ -59,5 +59,4 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); - } diff --git a/src/Phalcon/Http/ResponseInterface.php b/src/Phalcon/Http/ResponseInterface.php index a9a385dd..effb2543 100644 --- a/src/Phalcon/Http/ResponseInterface.php +++ b/src/Phalcon/Http/ResponseInterface.php @@ -191,5 +191,4 @@ public function sendCookies(): ResponseInterface; * @return mixed */ public function sendHeaders(); - } diff --git a/src/Phalcon/Http/Server/AbstractMiddleware.php b/src/Phalcon/Http/Server/AbstractMiddleware.php index ff970f7b..2727615d 100644 --- a/src/Phalcon/Http/Server/AbstractMiddleware.php +++ b/src/Phalcon/Http/Server/AbstractMiddleware.php @@ -36,5 +36,4 @@ abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterfac * @return ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; - } diff --git a/src/Phalcon/Http/Server/AbstractRequestHandler.php b/src/Phalcon/Http/Server/AbstractRequestHandler.php index b74a5596..a272d8ae 100644 --- a/src/Phalcon/Http/Server/AbstractRequestHandler.php +++ b/src/Phalcon/Http/Server/AbstractRequestHandler.php @@ -31,5 +31,4 @@ abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandler * @return ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; - } diff --git a/src/Phalcon/Image/Adapter/AbstractAdapter.php b/src/Phalcon/Image/Adapter/AbstractAdapter.php index 18a7f2aa..24633d97 100644 --- a/src/Phalcon/Image/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Image/Adapter/AbstractAdapter.php @@ -19,7 +19,7 @@ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { - static protected $checked = false; + protected static $checked = false; protected $file; @@ -281,5 +281,4 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } - } diff --git a/src/Phalcon/Image/Adapter/AdapterInterface.php b/src/Phalcon/Image/Adapter/AdapterInterface.php index 4325b26a..a2bff6a5 100644 --- a/src/Phalcon/Image/Adapter/AdapterInterface.php +++ b/src/Phalcon/Image/Adapter/AdapterInterface.php @@ -124,5 +124,4 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; - } diff --git a/src/Phalcon/Image/Adapter/Gd.php b/src/Phalcon/Image/Adapter/Gd.php index a626f8d8..719b860b 100644 --- a/src/Phalcon/Image/Adapter/Gd.php +++ b/src/Phalcon/Image/Adapter/Gd.php @@ -20,7 +20,7 @@ class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $checked = false; + protected static $checked = false; /** @@ -178,5 +178,4 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/Image/Adapter/Imagick.php b/src/Phalcon/Image/Adapter/Imagick.php index 3cc6d8f2..8991ffb6 100644 --- a/src/Phalcon/Image/Adapter/Imagick.php +++ b/src/Phalcon/Image/Adapter/Imagick.php @@ -28,10 +28,10 @@ class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - static protected $checked = false; + protected static $checked = false; - static protected $version = 0; + protected static $version = 0; /** @@ -242,5 +242,4 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/Image/Enum.php b/src/Phalcon/Image/Enum.php index f059d608..f3c5503d 100644 --- a/src/Phalcon/Image/Enum.php +++ b/src/Phalcon/Image/Enum.php @@ -45,6 +45,4 @@ class Enum const VERTICAL = 12; - - } diff --git a/src/Phalcon/Image/ImageFactory.php b/src/Phalcon/Image/ImageFactory.php index 68285a8e..a7389cfa 100644 --- a/src/Phalcon/Image/ImageFactory.php +++ b/src/Phalcon/Image/ImageFactory.php @@ -56,5 +56,4 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index e0c058b9..6450c1fc 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -25,5 +25,4 @@ class Kernel public static function preComputeHashKey(string $key) { } - } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index fd1bc6d3..3ae299da 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -289,5 +289,4 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } - } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 9d7be128..d19cf7ba 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -345,5 +345,4 @@ protected function getLevels(): array private function getLevelNumber($level): int { } - } diff --git a/src/Phalcon/Logger/Adapter/AbstractAdapter.php b/src/Phalcon/Logger/Adapter/AbstractAdapter.php index e80b5977..325b51a8 100644 --- a/src/Phalcon/Logger/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Logger/Adapter/AbstractAdapter.php @@ -127,5 +127,4 @@ public function rollback(): AdapterInterface public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } - } diff --git a/src/Phalcon/Logger/Adapter/AdapterInterface.php b/src/Phalcon/Logger/Adapter/AdapterInterface.php index 7bc7cad0..89f69ed2 100644 --- a/src/Phalcon/Logger/Adapter/AdapterInterface.php +++ b/src/Phalcon/Logger/Adapter/AdapterInterface.php @@ -77,5 +77,4 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; - } diff --git a/src/Phalcon/Logger/Adapter/Noop.php b/src/Phalcon/Logger/Adapter/Noop.php index 2b9761fb..0565cbf0 100644 --- a/src/Phalcon/Logger/Adapter/Noop.php +++ b/src/Phalcon/Logger/Adapter/Noop.php @@ -44,5 +44,4 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } - } diff --git a/src/Phalcon/Logger/Adapter/Stream.php b/src/Phalcon/Logger/Adapter/Stream.php index 32cfeb14..95a5c387 100644 --- a/src/Phalcon/Logger/Adapter/Stream.php +++ b/src/Phalcon/Logger/Adapter/Stream.php @@ -92,5 +92,4 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } - } diff --git a/src/Phalcon/Logger/Adapter/Syslog.php b/src/Phalcon/Logger/Adapter/Syslog.php index 9aa24131..4b440bc3 100644 --- a/src/Phalcon/Logger/Adapter/Syslog.php +++ b/src/Phalcon/Logger/Adapter/Syslog.php @@ -100,5 +100,4 @@ public function process(\Phalcon\Logger\Item $item) private function logLevelToSyslog(string $level): int { } - } diff --git a/src/Phalcon/Logger/AdapterFactory.php b/src/Phalcon/Logger/AdapterFactory.php index c6cc1b36..b2cb8c05 100644 --- a/src/Phalcon/Logger/AdapterFactory.php +++ b/src/Phalcon/Logger/AdapterFactory.php @@ -50,5 +50,4 @@ public function newInstance(string $name, string $fileName, array $options = arr protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Logger/Formatter/AbstractFormatter.php b/src/Phalcon/Logger/Formatter/AbstractFormatter.php index 039a9ce9..6e3f5195 100644 --- a/src/Phalcon/Logger/Formatter/AbstractFormatter.php +++ b/src/Phalcon/Logger/Formatter/AbstractFormatter.php @@ -30,5 +30,4 @@ abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterI public function interpolate(string $message, $context = null) { } - } diff --git a/src/Phalcon/Logger/Formatter/FormatterInterface.php b/src/Phalcon/Logger/Formatter/FormatterInterface.php index 47332298..e51a353d 100644 --- a/src/Phalcon/Logger/Formatter/FormatterInterface.php +++ b/src/Phalcon/Logger/Formatter/FormatterInterface.php @@ -24,5 +24,4 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); - } diff --git a/src/Phalcon/Logger/Formatter/Json.php b/src/Phalcon/Logger/Formatter/Json.php index b5eaad88..9e4157be 100644 --- a/src/Phalcon/Logger/Formatter/Json.php +++ b/src/Phalcon/Logger/Formatter/Json.php @@ -60,5 +60,4 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') public function format(\Phalcon\Logger\Item $item): string { } - } diff --git a/src/Phalcon/Logger/Formatter/Line.php b/src/Phalcon/Logger/Formatter/Line.php index 2dc2d324..d8e1bbbe 100644 --- a/src/Phalcon/Logger/Formatter/Line.php +++ b/src/Phalcon/Logger/Formatter/Line.php @@ -86,5 +86,4 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin public function format(\Phalcon\Logger\Item $item): string { } - } diff --git a/src/Phalcon/Logger/Item.php b/src/Phalcon/Logger/Item.php index 9b1b4d4f..015de099 100644 --- a/src/Phalcon/Logger/Item.php +++ b/src/Phalcon/Logger/Item.php @@ -101,5 +101,4 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } - } diff --git a/src/Phalcon/Logger/LoggerFactory.php b/src/Phalcon/Logger/LoggerFactory.php index c050fdec..50a4cab5 100644 --- a/src/Phalcon/Logger/LoggerFactory.php +++ b/src/Phalcon/Logger/LoggerFactory.php @@ -52,5 +52,4 @@ public function load($config): Logger public function newInstance(string $name, array $adapters = array()): Logger { } - } diff --git a/src/Phalcon/Messages/Message.php b/src/Phalcon/Messages/Message.php index 0d0c22d2..e0da5621 100644 --- a/src/Phalcon/Messages/Message.php +++ b/src/Phalcon/Messages/Message.php @@ -157,5 +157,4 @@ public function setMetaData(array $metaData): MessageInterface public function setType(string $type): MessageInterface { } - } diff --git a/src/Phalcon/Messages/MessageInterface.php b/src/Phalcon/Messages/MessageInterface.php index 14a99d06..3f964f8f 100644 --- a/src/Phalcon/Messages/MessageInterface.php +++ b/src/Phalcon/Messages/MessageInterface.php @@ -98,5 +98,4 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; - } diff --git a/src/Phalcon/Messages/Messages.php b/src/Phalcon/Messages/Messages.php index 736ec4e1..9340fb2b 100644 --- a/src/Phalcon/Messages/Messages.php +++ b/src/Phalcon/Messages/Messages.php @@ -203,5 +203,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/Mvc/Application.php b/src/Phalcon/Mvc/Application.php index 44449753..ec4e78c0 100644 --- a/src/Phalcon/Mvc/Application.php +++ b/src/Phalcon/Mvc/Application.php @@ -109,5 +109,4 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } - } diff --git a/src/Phalcon/Mvc/Controller.php b/src/Phalcon/Mvc/Controller.php index 0bdb95f1..c5bfda01 100644 --- a/src/Phalcon/Mvc/Controller.php +++ b/src/Phalcon/Mvc/Controller.php @@ -60,5 +60,4 @@ abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerI final public function __construct() { } - } diff --git a/src/Phalcon/Mvc/Controller/BindModelInterface.php b/src/Phalcon/Mvc/Controller/BindModelInterface.php index 1d8c0bfb..e53bf305 100644 --- a/src/Phalcon/Mvc/Controller/BindModelInterface.php +++ b/src/Phalcon/Mvc/Controller/BindModelInterface.php @@ -23,5 +23,4 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; - } diff --git a/src/Phalcon/Mvc/Dispatcher.php b/src/Phalcon/Mvc/Dispatcher.php index ec27db58..af0a7413 100644 --- a/src/Phalcon/Mvc/Dispatcher.php +++ b/src/Phalcon/Mvc/Dispatcher.php @@ -214,5 +214,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/Mvc/DispatcherInterface.php b/src/Phalcon/Mvc/DispatcherInterface.php index 4d239253..b3c8103c 100644 --- a/src/Phalcon/Mvc/DispatcherInterface.php +++ b/src/Phalcon/Mvc/DispatcherInterface.php @@ -60,5 +60,4 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); - } diff --git a/src/Phalcon/Mvc/EntityInterface.php b/src/Phalcon/Mvc/EntityInterface.php index b530459d..6056f3a6 100644 --- a/src/Phalcon/Mvc/EntityInterface.php +++ b/src/Phalcon/Mvc/EntityInterface.php @@ -32,5 +32,4 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); - } diff --git a/src/Phalcon/Mvc/Micro.php b/src/Phalcon/Mvc/Micro.php index bc87bbdb..012171b3 100644 --- a/src/Phalcon/Mvc/Micro.php +++ b/src/Phalcon/Mvc/Micro.php @@ -490,5 +490,4 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } - } diff --git a/src/Phalcon/Mvc/Micro/Collection.php b/src/Phalcon/Mvc/Micro/Collection.php index 21b72524..8479ed72 100644 --- a/src/Phalcon/Mvc/Micro/Collection.php +++ b/src/Phalcon/Mvc/Micro/Collection.php @@ -240,5 +240,4 @@ public function setPrefix(string $prefix): CollectionInterface protected function addMap($method, string $routePattern, $handler, string $name) { } - } diff --git a/src/Phalcon/Mvc/Micro/CollectionInterface.php b/src/Phalcon/Mvc/Micro/CollectionInterface.php index 6b685496..a0b3d42a 100644 --- a/src/Phalcon/Mvc/Micro/CollectionInterface.php +++ b/src/Phalcon/Mvc/Micro/CollectionInterface.php @@ -149,5 +149,4 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; - } diff --git a/src/Phalcon/Mvc/Micro/LazyLoader.php b/src/Phalcon/Mvc/Micro/LazyLoader.php index 5e2dd112..1713ab44 100644 --- a/src/Phalcon/Mvc/Micro/LazyLoader.php +++ b/src/Phalcon/Mvc/Micro/LazyLoader.php @@ -48,5 +48,4 @@ public function __construct(string $definition) public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) { } - } diff --git a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php index ce5155e2..ab24356d 100644 --- a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php +++ b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php @@ -21,5 +21,4 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); - } diff --git a/src/Phalcon/Mvc/Model.php b/src/Phalcon/Mvc/Model.php index 34475a50..d51e101a 100644 --- a/src/Phalcon/Mvc/Model.php +++ b/src/Phalcon/Mvc/Model.php @@ -1516,7 +1516,7 @@ protected static function _groupResult(string $functionName, string $alias, $par * @param string $method * @param array $arguments */ - protected final static function _invokeFinder(string $method, array $arguments) + final protected static function _invokeFinder(string $method, array $arguments) { } @@ -1997,5 +1997,4 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior.php b/src/Phalcon/Mvc/Model/Behavior.php index 15de1735..25bf961e 100644 --- a/src/Phalcon/Mvc/Model/Behavior.php +++ b/src/Phalcon/Mvc/Model/Behavior.php @@ -71,5 +71,4 @@ protected function mustTakeAction(string $eventName): bool public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php index 2e7edce9..85b47a4d 100644 --- a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php +++ b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php @@ -29,5 +29,4 @@ class SoftDelete extends Behavior public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php index eb844d40..0863099b 100644 --- a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php +++ b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php @@ -36,5 +36,4 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } - } diff --git a/src/Phalcon/Mvc/Model/BehaviorInterface.php b/src/Phalcon/Mvc/Model/BehaviorInterface.php index 7b22c889..8d42f024 100644 --- a/src/Phalcon/Mvc/Model/BehaviorInterface.php +++ b/src/Phalcon/Mvc/Model/BehaviorInterface.php @@ -33,5 +33,4 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); - } diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php index fc1bcbcb..980c7340 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -131,5 +131,4 @@ protected function getParamsFromReflection($handler, array $params, string $cach public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php index f8d4bafb..f37da24c 100644 --- a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php +++ b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php @@ -24,5 +24,4 @@ interface BindableInterface * @return string|array */ public function getModelName(); - } diff --git a/src/Phalcon/Mvc/Model/BinderInterface.php b/src/Phalcon/Mvc/Model/BinderInterface.php index 29a7e408..8963d43c 100644 --- a/src/Phalcon/Mvc/Model/BinderInterface.php +++ b/src/Phalcon/Mvc/Model/BinderInterface.php @@ -51,5 +51,4 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; - } diff --git a/src/Phalcon/Mvc/Model/Criteria.php b/src/Phalcon/Mvc/Model/Criteria.php index c7ef2073..532ce0b7 100644 --- a/src/Phalcon/Mvc/Model/Criteria.php +++ b/src/Phalcon/Mvc/Model/Criteria.php @@ -536,5 +536,4 @@ public function createBuilder(): BuilderInterface public function execute(): ResultsetInterface { } - } diff --git a/src/Phalcon/Mvc/Model/CriteriaInterface.php b/src/Phalcon/Mvc/Model/CriteriaInterface.php index e515c29b..419e17a5 100644 --- a/src/Phalcon/Mvc/Model/CriteriaInterface.php +++ b/src/Phalcon/Mvc/Model/CriteriaInterface.php @@ -329,5 +329,4 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; - } diff --git a/src/Phalcon/Mvc/Model/Manager.php b/src/Phalcon/Mvc/Model/Manager.php index 1355dbc5..777815c2 100644 --- a/src/Phalcon/Mvc/Model/Manager.php +++ b/src/Phalcon/Mvc/Model/Manager.php @@ -899,5 +899,4 @@ public function getLastQuery(): QueryInterface public function __destruct() { } - } diff --git a/src/Phalcon/Mvc/Model/ManagerInterface.php b/src/Phalcon/Mvc/Model/ManagerInterface.php index a3a8195d..c7d7b345 100644 --- a/src/Phalcon/Mvc/Model/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/ManagerInterface.php @@ -486,5 +486,4 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @return void */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); - } diff --git a/src/Phalcon/Mvc/Model/MetaData.php b/src/Phalcon/Mvc/Model/MetaData.php index 2b4b31a2..e6e6309b 100644 --- a/src/Phalcon/Mvc/Model/MetaData.php +++ b/src/Phalcon/Mvc/Model/MetaData.php @@ -639,5 +639,4 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t private function throwWriteException($option) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Apcu.php b/src/Phalcon/Mvc/Model/MetaData/Apcu.php index 21a020d1..0280a7f7 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Apcu.php +++ b/src/Phalcon/Mvc/Model/MetaData/Apcu.php @@ -41,5 +41,4 @@ class Apcu extends MetaData public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php index 4abe8316..0598634e 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php +++ b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php @@ -39,5 +39,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Memory.php b/src/Phalcon/Mvc/Model/MetaData/Memory.php index 41ce9a31..7b6ef87a 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Memory.php +++ b/src/Phalcon/Mvc/Model/MetaData/Memory.php @@ -48,5 +48,4 @@ public function read(string $key): ?array public function write(string $key, array $data) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Redis.php b/src/Phalcon/Mvc/Model/MetaData/Redis.php index 9a2a5bc4..d320f49a 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Redis.php +++ b/src/Phalcon/Mvc/Model/MetaData/Redis.php @@ -53,5 +53,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php index 7ba89439..9fdd2e38 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php @@ -41,5 +41,4 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php index 2837cf3b..0e875ac1 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php @@ -38,5 +38,4 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php index 43cf3173..f2cf8b19 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php @@ -38,5 +38,4 @@ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\Di * @return array */ public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Stream.php b/src/Phalcon/Mvc/Model/MetaData/Stream.php index eaa23474..a9c7d71d 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Stream.php +++ b/src/Phalcon/Mvc/Model/MetaData/Stream.php @@ -69,5 +69,4 @@ public function write(string $key, array $data) private function throwWriteException($option) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaDataInterface.php b/src/Phalcon/Mvc/Model/MetaDataInterface.php index 50c44024..40abad22 100644 --- a/src/Phalcon/Mvc/Model/MetaDataInterface.php +++ b/src/Phalcon/Mvc/Model/MetaDataInterface.php @@ -249,5 +249,4 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @return void */ public function write(string $key, array $data); - } diff --git a/src/Phalcon/Mvc/Model/Query.php b/src/Phalcon/Mvc/Model/Query.php index 7782369d..31d41240 100644 --- a/src/Phalcon/Mvc/Model/Query.php +++ b/src/Phalcon/Mvc/Model/Query.php @@ -145,7 +145,7 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA protected $uniqueRow; - static protected $_irPhqlCache; + protected static $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -694,5 +694,4 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array public function setTransaction(TransactionInterface $transaction): QueryInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Query/Builder.php b/src/Phalcon/Mvc/Model/Query/Builder.php index 945d697d..6c919f58 100644 --- a/src/Phalcon/Mvc/Model/Query/Builder.php +++ b/src/Phalcon/Mvc/Model/Query/Builder.php @@ -917,5 +917,4 @@ protected function conditionNotBetween(string $clause, string $operator, string protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php index 5ecec31b..d9b86f9b 100644 --- a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php +++ b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php @@ -350,5 +350,4 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; - } diff --git a/src/Phalcon/Mvc/Model/Query/Lang.php b/src/Phalcon/Mvc/Model/Query/Lang.php index f87716d1..1877eef5 100644 --- a/src/Phalcon/Mvc/Model/Query/Lang.php +++ b/src/Phalcon/Mvc/Model/Query/Lang.php @@ -42,5 +42,4 @@ abstract class Lang public static function parsePHQL(string $phql): array { } - } diff --git a/src/Phalcon/Mvc/Model/Query/Status.php b/src/Phalcon/Mvc/Model/Query/Status.php index f074d66a..9c6f5668 100644 --- a/src/Phalcon/Mvc/Model/Query/Status.php +++ b/src/Phalcon/Mvc/Model/Query/Status.php @@ -83,5 +83,4 @@ public function getModel(): ModelInterface public function success(): bool { } - } diff --git a/src/Phalcon/Mvc/Model/Query/StatusInterface.php b/src/Phalcon/Mvc/Model/Query/StatusInterface.php index dcfce38c..c63f95dc 100644 --- a/src/Phalcon/Mvc/Model/Query/StatusInterface.php +++ b/src/Phalcon/Mvc/Model/Query/StatusInterface.php @@ -39,5 +39,4 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; - } diff --git a/src/Phalcon/Mvc/Model/QueryInterface.php b/src/Phalcon/Mvc/Model/QueryInterface.php index d6dc6696..23e22e87 100644 --- a/src/Phalcon/Mvc/Model/QueryInterface.php +++ b/src/Phalcon/Mvc/Model/QueryInterface.php @@ -121,5 +121,4 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; - } diff --git a/src/Phalcon/Mvc/Model/Relation.php b/src/Phalcon/Mvc/Model/Relation.php index a11d2579..5b0487aa 100644 --- a/src/Phalcon/Mvc/Model/Relation.php +++ b/src/Phalcon/Mvc/Model/Relation.php @@ -215,5 +215,4 @@ public function isReusable(): bool public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } - } diff --git a/src/Phalcon/Mvc/Model/RelationInterface.php b/src/Phalcon/Mvc/Model/RelationInterface.php index 724df960..ed33aa25 100644 --- a/src/Phalcon/Mvc/Model/RelationInterface.php +++ b/src/Phalcon/Mvc/Model/RelationInterface.php @@ -124,5 +124,4 @@ public function isThrough(): bool; * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); - } diff --git a/src/Phalcon/Mvc/Model/ResultInterface.php b/src/Phalcon/Mvc/Model/ResultInterface.php index 9d94b919..3f71406f 100644 --- a/src/Phalcon/Mvc/Model/ResultInterface.php +++ b/src/Phalcon/Mvc/Model/ResultInterface.php @@ -24,5 +24,4 @@ interface ResultInterface * @return mixed */ public function setDirtyState(int $dirtyState); - } diff --git a/src/Phalcon/Mvc/Model/Resultset.php b/src/Phalcon/Mvc/Model/Resultset.php index 481025d2..0cb616a9 100644 --- a/src/Phalcon/Mvc/Model/Resultset.php +++ b/src/Phalcon/Mvc/Model/Resultset.php @@ -349,5 +349,4 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } - } diff --git a/src/Phalcon/Mvc/Model/Resultset/Complex.php b/src/Phalcon/Mvc/Model/Resultset/Complex.php index f888848f..4f3240f2 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Complex.php +++ b/src/Phalcon/Mvc/Model/Resultset/Complex.php @@ -77,5 +77,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Mvc/Model/Resultset/Simple.php b/src/Phalcon/Mvc/Model/Resultset/Simple.php index 9787164c..0d428d2b 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Simple.php +++ b/src/Phalcon/Mvc/Model/Resultset/Simple.php @@ -86,5 +86,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Mvc/Model/ResultsetInterface.php b/src/Phalcon/Mvc/Model/ResultsetInterface.php index ca24b3f6..7109e39a 100644 --- a/src/Phalcon/Mvc/Model/ResultsetInterface.php +++ b/src/Phalcon/Mvc/Model/ResultsetInterface.php @@ -127,5 +127,4 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; - } diff --git a/src/Phalcon/Mvc/Model/Row.php b/src/Phalcon/Mvc/Model/Row.php index 9be5a159..5ad81337 100644 --- a/src/Phalcon/Mvc/Model/Row.php +++ b/src/Phalcon/Mvc/Model/Row.php @@ -115,5 +115,4 @@ public function toArray(): array public function writeAttribute(string $attribute, $value) { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction.php b/src/Phalcon/Mvc/Model/Transaction.php index 6ca304d2..9f8d9866 100644 --- a/src/Phalcon/Mvc/Model/Transaction.php +++ b/src/Phalcon/Mvc/Model/Transaction.php @@ -205,5 +205,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte public function throwRollbackException(bool $status): TransactionInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/Failed.php b/src/Phalcon/Mvc/Model/Transaction/Failed.php index 3c387526..b6555617 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Failed.php +++ b/src/Phalcon/Mvc/Model/Transaction/Failed.php @@ -49,5 +49,4 @@ public function getRecord(): ModelInterface public function getRecordMessages(): array { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/Manager.php b/src/Phalcon/Mvc/Model/Transaction/Manager.php index 5c1f7874..28fd6173 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Manager.php +++ b/src/Phalcon/Mvc/Model/Transaction/Manager.php @@ -245,5 +245,4 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php index 7bde20da..d2acfa22 100644 --- a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php @@ -107,5 +107,4 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; - } diff --git a/src/Phalcon/Mvc/Model/TransactionInterface.php b/src/Phalcon/Mvc/Model/TransactionInterface.php index 4cd1d2eb..99dba3e3 100644 --- a/src/Phalcon/Mvc/Model/TransactionInterface.php +++ b/src/Phalcon/Mvc/Model/TransactionInterface.php @@ -107,5 +107,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; - } diff --git a/src/Phalcon/Mvc/Model/ValidationFailed.php b/src/Phalcon/Mvc/Model/ValidationFailed.php index eeff8de2..098cc9d4 100644 --- a/src/Phalcon/Mvc/Model/ValidationFailed.php +++ b/src/Phalcon/Mvc/Model/ValidationFailed.php @@ -55,5 +55,4 @@ public function getMessages(): array public function getModel(): ModelInterface { } - } diff --git a/src/Phalcon/Mvc/ModelInterface.php b/src/Phalcon/Mvc/ModelInterface.php index 7d20a38d..ed66717c 100644 --- a/src/Phalcon/Mvc/ModelInterface.php +++ b/src/Phalcon/Mvc/ModelInterface.php @@ -344,5 +344,4 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; - } diff --git a/src/Phalcon/Mvc/ModuleDefinitionInterface.php b/src/Phalcon/Mvc/ModuleDefinitionInterface.php index 9b455a2a..ac195410 100644 --- a/src/Phalcon/Mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/Mvc/ModuleDefinitionInterface.php @@ -30,5 +30,4 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); - } diff --git a/src/Phalcon/Mvc/Router.php b/src/Phalcon/Mvc/Router.php index 1e568dc4..02751581 100644 --- a/src/Phalcon/Mvc/Router.php +++ b/src/Phalcon/Mvc/Router.php @@ -576,5 +576,4 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } - } diff --git a/src/Phalcon/Mvc/Router/Annotations.php b/src/Phalcon/Mvc/Router/Annotations.php index ef4a8b38..4fd2e415 100644 --- a/src/Phalcon/Mvc/Router/Annotations.php +++ b/src/Phalcon/Mvc/Router/Annotations.php @@ -133,5 +133,4 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } - } diff --git a/src/Phalcon/Mvc/Router/Group.php b/src/Phalcon/Mvc/Router/Group.php index 72ad0d0a..084af716 100644 --- a/src/Phalcon/Mvc/Router/Group.php +++ b/src/Phalcon/Mvc/Router/Group.php @@ -317,5 +317,4 @@ public function setPrefix(string $prefix): GroupInterface protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } - } diff --git a/src/Phalcon/Mvc/Router/GroupInterface.php b/src/Phalcon/Mvc/Router/GroupInterface.php index 2bb94856..d68a50db 100644 --- a/src/Phalcon/Mvc/Router/GroupInterface.php +++ b/src/Phalcon/Mvc/Router/GroupInterface.php @@ -237,5 +237,4 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; - } diff --git a/src/Phalcon/Mvc/Router/Route.php b/src/Phalcon/Mvc/Router/Route.php index 19f95622..bb9ea158 100644 --- a/src/Phalcon/Mvc/Router/Route.php +++ b/src/Phalcon/Mvc/Router/Route.php @@ -50,7 +50,7 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; @@ -374,5 +374,4 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } - } diff --git a/src/Phalcon/Mvc/Router/RouteInterface.php b/src/Phalcon/Mvc/Router/RouteInterface.php index c8930254..830cf72e 100644 --- a/src/Phalcon/Mvc/Router/RouteInterface.php +++ b/src/Phalcon/Mvc/Router/RouteInterface.php @@ -137,5 +137,4 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; - } diff --git a/src/Phalcon/Mvc/RouterInterface.php b/src/Phalcon/Mvc/RouterInterface.php index aad2dcee..eca288fe 100644 --- a/src/Phalcon/Mvc/RouterInterface.php +++ b/src/Phalcon/Mvc/RouterInterface.php @@ -260,5 +260,4 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/Mvc/View.php b/src/Phalcon/Mvc/View.php index b213e8da..29bd0da4 100644 --- a/src/Phalcon/Mvc/View.php +++ b/src/Phalcon/Mvc/View.php @@ -821,5 +821,4 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } - } diff --git a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php index 31d85c4f..007c9c85 100644 --- a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php +++ b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php @@ -60,5 +60,4 @@ public function getView(): ViewBaseInterface public function partial(string $partialPath, $params = null) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/EngineInterface.php b/src/Phalcon/Mvc/View/Engine/EngineInterface.php index b0d283c7..78012e02 100644 --- a/src/Phalcon/Mvc/View/Engine/EngineInterface.php +++ b/src/Phalcon/Mvc/View/Engine/EngineInterface.php @@ -39,5 +39,4 @@ public function partial(string $partialPath, $params = null); * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); - } diff --git a/src/Phalcon/Mvc/View/Engine/Php.php b/src/Phalcon/Mvc/View/Engine/Php.php index a8b2ac61..35138e3f 100644 --- a/src/Phalcon/Mvc/View/Engine/Php.php +++ b/src/Phalcon/Mvc/View/Engine/Php.php @@ -25,5 +25,4 @@ class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt.php b/src/Phalcon/Mvc/View/Engine/Volt.php index 3abc528b..6192db65 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt.php +++ b/src/Phalcon/Mvc/View/Engine/Volt.php @@ -151,5 +151,4 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php index 5fe0be21..9fe907a5 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php @@ -577,5 +577,4 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php index 2f5151f0..08a2dad3 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php @@ -36,5 +36,4 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } - } diff --git a/src/Phalcon/Mvc/View/Simple.php b/src/Phalcon/Mvc/View/Simple.php index 958ef113..7b4e6dd3 100644 --- a/src/Phalcon/Mvc/View/Simple.php +++ b/src/Phalcon/Mvc/View/Simple.php @@ -328,5 +328,4 @@ protected function loadTemplateEngines(): array final protected function internalRender(string $path, $params) { } - } diff --git a/src/Phalcon/Mvc/ViewBaseInterface.php b/src/Phalcon/Mvc/ViewBaseInterface.php index fb99dbdd..494f184a 100644 --- a/src/Phalcon/Mvc/ViewBaseInterface.php +++ b/src/Phalcon/Mvc/ViewBaseInterface.php @@ -76,5 +76,4 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); - } diff --git a/src/Phalcon/Mvc/ViewInterface.php b/src/Phalcon/Mvc/ViewInterface.php index ed02efdb..c791f141 100644 --- a/src/Phalcon/Mvc/ViewInterface.php +++ b/src/Phalcon/Mvc/ViewInterface.php @@ -202,5 +202,4 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); - } diff --git a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php index f9f7ece9..4a919273 100644 --- a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php @@ -96,5 +96,4 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository protected function getRepository(array $properties = null): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/AdapterInterface.php b/src/Phalcon/Paginator/Adapter/AdapterInterface.php index e4136ebe..b39e5b27 100644 --- a/src/Phalcon/Paginator/Adapter/AdapterInterface.php +++ b/src/Phalcon/Paginator/Adapter/AdapterInterface.php @@ -46,5 +46,4 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); - } diff --git a/src/Phalcon/Paginator/Adapter/Model.php b/src/Phalcon/Paginator/Adapter/Model.php index 9b246d4b..cca3b9d3 100644 --- a/src/Phalcon/Paginator/Adapter/Model.php +++ b/src/Phalcon/Paginator/Adapter/Model.php @@ -86,5 +86,4 @@ class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/NativeArray.php b/src/Phalcon/Paginator/Adapter/NativeArray.php index 345ae715..a6bae499 100644 --- a/src/Phalcon/Paginator/Adapter/NativeArray.php +++ b/src/Phalcon/Paginator/Adapter/NativeArray.php @@ -45,5 +45,4 @@ class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/QueryBuilder.php b/src/Phalcon/Paginator/Adapter/QueryBuilder.php index eb27d4d2..45925fcd 100644 --- a/src/Phalcon/Paginator/Adapter/QueryBuilder.php +++ b/src/Phalcon/Paginator/Adapter/QueryBuilder.php @@ -92,5 +92,4 @@ public function paginate(): RepositoryInterface public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder { } - } diff --git a/src/Phalcon/Paginator/PaginatorFactory.php b/src/Phalcon/Paginator/PaginatorFactory.php index f42f2f94..ebe00abd 100644 --- a/src/Phalcon/Paginator/PaginatorFactory.php +++ b/src/Phalcon/Paginator/PaginatorFactory.php @@ -79,5 +79,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Paginator/Repository.php b/src/Phalcon/Paginator/Repository.php index f27e8342..798df280 100644 --- a/src/Phalcon/Paginator/Repository.php +++ b/src/Phalcon/Paginator/Repository.php @@ -167,5 +167,4 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } - } diff --git a/src/Phalcon/Paginator/RepositoryInterface.php b/src/Phalcon/Paginator/RepositoryInterface.php index 37835568..921f0c17 100644 --- a/src/Phalcon/Paginator/RepositoryInterface.php +++ b/src/Phalcon/Paginator/RepositoryInterface.php @@ -120,5 +120,4 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; - } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index b78f5d0e..59f90e2e 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -294,5 +294,4 @@ final public function toJson(int $options = 79): string final public function unserialize($serialized) { } - } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index d34bb3c0..07809558 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -299,5 +299,4 @@ private function getLocalRequest(): ?RequestInterface private function getLocalSession(): ?SessionInterface { } - } diff --git a/src/Phalcon/Security/Random.php b/src/Phalcon/Security/Random.php index ea9b65f9..0c309003 100644 --- a/src/Phalcon/Security/Random.php +++ b/src/Phalcon/Security/Random.php @@ -282,5 +282,4 @@ public function uuid(): string protected function base(string $alphabet, int $base, $n = null): string { } - } diff --git a/src/Phalcon/Session/Adapter/AbstractAdapter.php b/src/Phalcon/Session/Adapter/AbstractAdapter.php index d487482c..e0d4fc6e 100644 --- a/src/Phalcon/Session/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Session/Adapter/AbstractAdapter.php @@ -87,5 +87,4 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } - } diff --git a/src/Phalcon/Session/Adapter/Libmemcached.php b/src/Phalcon/Session/Adapter/Libmemcached.php index 73d7dc39..248cb73d 100644 --- a/src/Phalcon/Session/Adapter/Libmemcached.php +++ b/src/Phalcon/Session/Adapter/Libmemcached.php @@ -24,5 +24,4 @@ class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/Session/Adapter/Noop.php b/src/Phalcon/Session/Adapter/Noop.php index d54c11b4..ffd12844 100644 --- a/src/Phalcon/Session/Adapter/Noop.php +++ b/src/Phalcon/Session/Adapter/Noop.php @@ -133,5 +133,4 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } - } diff --git a/src/Phalcon/Session/Adapter/Redis.php b/src/Phalcon/Session/Adapter/Redis.php index d13b86c4..9a013a2d 100644 --- a/src/Phalcon/Session/Adapter/Redis.php +++ b/src/Phalcon/Session/Adapter/Redis.php @@ -24,5 +24,4 @@ class Redis extends \Phalcon\Session\Adapter\AbstractAdapter public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/Session/Adapter/Stream.php b/src/Phalcon/Session/Adapter/Stream.php index 27ab090d..d1f9cebd 100644 --- a/src/Phalcon/Session/Adapter/Stream.php +++ b/src/Phalcon/Session/Adapter/Stream.php @@ -87,5 +87,4 @@ public function read($id): string public function write($id, $data): bool { } - } diff --git a/src/Phalcon/Session/Bag.php b/src/Phalcon/Session/Bag.php index 09309bbb..5e2d1468 100644 --- a/src/Phalcon/Session/Bag.php +++ b/src/Phalcon/Session/Bag.php @@ -105,5 +105,4 @@ public function set(string $element, $value) public function setDI(\Phalcon\Di\DiInterface $container) { } - } diff --git a/src/Phalcon/Session/Manager.php b/src/Phalcon/Session/Manager.php index e8cf8c35..bb3c27dd 100644 --- a/src/Phalcon/Session/Manager.php +++ b/src/Phalcon/Session/Manager.php @@ -269,5 +269,4 @@ public function status(): int private function getUniqueKey(string $key): string { } - } diff --git a/src/Phalcon/Session/ManagerInterface.php b/src/Phalcon/Session/ManagerInterface.php index c3d76dfb..8be38a03 100644 --- a/src/Phalcon/Session/ManagerInterface.php +++ b/src/Phalcon/Session/ManagerInterface.php @@ -195,5 +195,4 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; - } diff --git a/src/Phalcon/Storage/Adapter/AbstractAdapter.php b/src/Phalcon/Storage/Adapter/AbstractAdapter.php index c7b49c30..acf1b438 100644 --- a/src/Phalcon/Storage/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Storage/Adapter/AbstractAdapter.php @@ -222,5 +222,4 @@ protected function getUnserializedData($content, $defaultValue = null) protected function initSerializer() { } - } diff --git a/src/Phalcon/Storage/Adapter/AdapterInterface.php b/src/Phalcon/Storage/Adapter/AdapterInterface.php index 5386c52a..5c3bc3f0 100644 --- a/src/Phalcon/Storage/Adapter/AdapterInterface.php +++ b/src/Phalcon/Storage/Adapter/AdapterInterface.php @@ -95,5 +95,4 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; - } diff --git a/src/Phalcon/Storage/Adapter/Apcu.php b/src/Phalcon/Storage/Adapter/Apcu.php index a083f819..b7b68ef1 100644 --- a/src/Phalcon/Storage/Adapter/Apcu.php +++ b/src/Phalcon/Storage/Adapter/Apcu.php @@ -128,5 +128,4 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/Storage/Adapter/Libmemcached.php b/src/Phalcon/Storage/Adapter/Libmemcached.php index c044cea6..9977a0ec 100644 --- a/src/Phalcon/Storage/Adapter/Libmemcached.php +++ b/src/Phalcon/Storage/Adapter/Libmemcached.php @@ -147,5 +147,4 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Memcached $connection) { } - } diff --git a/src/Phalcon/Storage/Adapter/Memory.php b/src/Phalcon/Storage/Adapter/Memory.php index 76a40139..91db861e 100644 --- a/src/Phalcon/Storage/Adapter/Memory.php +++ b/src/Phalcon/Storage/Adapter/Memory.php @@ -134,5 +134,4 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/Storage/Adapter/Redis.php b/src/Phalcon/Storage/Adapter/Redis.php index 94f266ec..b6baaec3 100644 --- a/src/Phalcon/Storage/Adapter/Redis.php +++ b/src/Phalcon/Storage/Adapter/Redis.php @@ -149,5 +149,4 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } - } diff --git a/src/Phalcon/Storage/Adapter/Stream.php b/src/Phalcon/Storage/Adapter/Stream.php index 7a36572d..61222306 100644 --- a/src/Phalcon/Storage/Adapter/Stream.php +++ b/src/Phalcon/Storage/Adapter/Stream.php @@ -198,5 +198,4 @@ private function getPayload(string $filepath): array private function isExpired(array $payload): bool { } - } diff --git a/src/Phalcon/Storage/AdapterFactory.php b/src/Phalcon/Storage/AdapterFactory.php index 4d0d1ed7..099c16b5 100644 --- a/src/Phalcon/Storage/AdapterFactory.php +++ b/src/Phalcon/Storage/AdapterFactory.php @@ -55,5 +55,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Storage/Serializer/AbstractSerializer.php b/src/Phalcon/Storage/Serializer/AbstractSerializer.php index bf18491b..7dbe671d 100644 --- a/src/Phalcon/Storage/Serializer/AbstractSerializer.php +++ b/src/Phalcon/Storage/Serializer/AbstractSerializer.php @@ -58,5 +58,4 @@ public function getData() public function setData($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Base64.php b/src/Phalcon/Storage/Serializer/Base64.php index f87ef760..45363d98 100644 --- a/src/Phalcon/Storage/Serializer/Base64.php +++ b/src/Phalcon/Storage/Serializer/Base64.php @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Igbinary.php b/src/Phalcon/Storage/Serializer/Igbinary.php index 975beca9..c3db0cbe 100644 --- a/src/Phalcon/Storage/Serializer/Igbinary.php +++ b/src/Phalcon/Storage/Serializer/Igbinary.php @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Json.php b/src/Phalcon/Storage/Serializer/Json.php index bcff273e..6695c299 100644 --- a/src/Phalcon/Storage/Serializer/Json.php +++ b/src/Phalcon/Storage/Serializer/Json.php @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Msgpack.php b/src/Phalcon/Storage/Serializer/Msgpack.php index 65fb50a4..44c730ea 100644 --- a/src/Phalcon/Storage/Serializer/Msgpack.php +++ b/src/Phalcon/Storage/Serializer/Msgpack.php @@ -38,5 +38,4 @@ public function serialize(): ?string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/None.php b/src/Phalcon/Storage/Serializer/None.php index b7eb3f6e..141510a0 100644 --- a/src/Phalcon/Storage/Serializer/None.php +++ b/src/Phalcon/Storage/Serializer/None.php @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Php.php b/src/Phalcon/Storage/Serializer/Php.php index d261cf4a..40355084 100644 --- a/src/Phalcon/Storage/Serializer/Php.php +++ b/src/Phalcon/Storage/Serializer/Php.php @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/SerializerInterface.php b/src/Phalcon/Storage/Serializer/SerializerInterface.php index 0eff6249..50a28a44 100644 --- a/src/Phalcon/Storage/Serializer/SerializerInterface.php +++ b/src/Phalcon/Storage/Serializer/SerializerInterface.php @@ -30,5 +30,4 @@ public function getData(); * @return void */ public function setData($data); - } diff --git a/src/Phalcon/Storage/SerializerFactory.php b/src/Phalcon/Storage/SerializerFactory.php index bf753855..0ae0be18 100644 --- a/src/Phalcon/Storage/SerializerFactory.php +++ b/src/Phalcon/Storage/SerializerFactory.php @@ -47,5 +47,4 @@ public function newInstance(string $name): SerializerInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index e7b4be90..bced6d14 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -54,40 +54,40 @@ class Tag const XHTML5 = 11; - static protected $autoEscape = true; + protected static $autoEscape = true; /** * DI Container */ - static protected $container; + protected static $container; /** * Pre-assigned values for components */ - static protected $displayValues; + protected static $displayValues; - static protected $documentAppendTitle = null; + protected static $documentAppendTitle = null; - static protected $documentPrependTitle = null; + protected static $documentPrependTitle = null; /** * HTML document title */ - static protected $documentTitle = null; + protected static $documentTitle = null; - static protected $documentTitleSeparator = null; + protected static $documentTitleSeparator = null; - static protected $documentType = 11; + protected static $documentType = 11; - static protected $escaperService = null; + protected static $escaperService = null; - static protected $urlService = null; + protected static $urlService = null; /** @@ -667,7 +667,7 @@ public static function weekField($parameters): string * @param bool $asValue * @return string */ - static final protected function inputField(string $type, $parameters, bool $asValue = false): string + final protected static function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -678,8 +678,7 @@ static final protected function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - static final protected function inputFieldChecked(string $type, $parameters): string + final protected static function inputFieldChecked(string $type, $parameters): string { } - } diff --git a/src/Phalcon/Tag/Select.php b/src/Phalcon/Tag/Select.php index 6b650d24..687c9fa7 100644 --- a/src/Phalcon/Tag/Select.php +++ b/src/Phalcon/Tag/Select.php @@ -53,5 +53,4 @@ private static function optionsFromArray(array $data, $value, string $closeOptio private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string { } - } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index f72cf7b1..38a3a944 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -276,5 +276,4 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/Translate/Adapter/AbstractAdapter.php b/src/Phalcon/Translate/Adapter/AbstractAdapter.php index c4e1c024..5c2cb5c4 100644 --- a/src/Phalcon/Translate/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Translate/Adapter/AbstractAdapter.php @@ -110,5 +110,4 @@ public function t(string $translateKey, array $placeholders = array()): string protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Adapter/AdapterInterface.php b/src/Phalcon/Translate/Adapter/AdapterInterface.php index a452d6c3..c1de0bfc 100644 --- a/src/Phalcon/Translate/Adapter/AdapterInterface.php +++ b/src/Phalcon/Translate/Adapter/AdapterInterface.php @@ -42,5 +42,4 @@ public function query(string $translateKey, array $placeholders = array()): stri * @return string */ public function t(string $translateKey, array $placeholders = array()): string; - } diff --git a/src/Phalcon/Translate/Adapter/Csv.php b/src/Phalcon/Translate/Adapter/Csv.php index db6a9aa3..5410eead 100644 --- a/src/Phalcon/Translate/Adapter/Csv.php +++ b/src/Phalcon/Translate/Adapter/Csv.php @@ -65,5 +65,4 @@ public function query(string $index, array $placeholders = array()): string private function load(string $file, int $length, string $delimiter, string $enclosure) { } - } diff --git a/src/Phalcon/Translate/Adapter/Gettext.php b/src/Phalcon/Translate/Adapter/Gettext.php index 1c8efb28..c6f706e3 100644 --- a/src/Phalcon/Translate/Adapter/Gettext.php +++ b/src/Phalcon/Translate/Adapter/Gettext.php @@ -218,5 +218,4 @@ protected function getOptionsDefault(): array protected function prepareOptions(array $options) { } - } diff --git a/src/Phalcon/Translate/Adapter/NativeArray.php b/src/Phalcon/Translate/Adapter/NativeArray.php index efe9f26a..09ff3e20 100644 --- a/src/Phalcon/Translate/Adapter/NativeArray.php +++ b/src/Phalcon/Translate/Adapter/NativeArray.php @@ -67,5 +67,4 @@ public function notFound(string $index): string public function query(string $index, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/AssociativeArray.php index 026b5fda..ea3aad8e 100644 --- a/src/Phalcon/Translate/Interpolator/AssociativeArray.php +++ b/src/Phalcon/Translate/Interpolator/AssociativeArray.php @@ -30,5 +30,4 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/IndexedArray.php b/src/Phalcon/Translate/Interpolator/IndexedArray.php index dab117e5..d363ba26 100644 --- a/src/Phalcon/Translate/Interpolator/IndexedArray.php +++ b/src/Phalcon/Translate/Interpolator/IndexedArray.php @@ -30,5 +30,4 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php index 157fa7b4..e3ab9ade 100644 --- a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php +++ b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php @@ -25,5 +25,4 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; - } diff --git a/src/Phalcon/Translate/InterpolatorFactory.php b/src/Phalcon/Translate/InterpolatorFactory.php index d5894d24..1a2657ba 100644 --- a/src/Phalcon/Translate/InterpolatorFactory.php +++ b/src/Phalcon/Translate/InterpolatorFactory.php @@ -58,5 +58,4 @@ public function newInstance(string $name): AdapterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Translate/TranslateFactory.php b/src/Phalcon/Translate/TranslateFactory.php index e91e5a02..fbdb6200 100644 --- a/src/Phalcon/Translate/TranslateFactory.php +++ b/src/Phalcon/Translate/TranslateFactory.php @@ -65,5 +65,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index c29f8ac4..60223859 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -205,5 +205,4 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } - } diff --git a/src/Phalcon/Url/UrlInterface.php b/src/Phalcon/Url/UrlInterface.php index 7f5c8764..3a25a9f8 100644 --- a/src/Phalcon/Url/UrlInterface.php +++ b/src/Phalcon/Url/UrlInterface.php @@ -62,5 +62,4 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; - } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index 103cea19..ed18b42d 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -228,5 +228,4 @@ public function validate($data = null, $entity = null): Messages protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool { } - } diff --git a/src/Phalcon/Validation/AbstractValidator.php b/src/Phalcon/Validation/AbstractValidator.php index aff26d6a..92f00e49 100644 --- a/src/Phalcon/Validation/AbstractValidator.php +++ b/src/Phalcon/Validation/AbstractValidator.php @@ -159,5 +159,4 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message { } - } diff --git a/src/Phalcon/Validation/AbstractValidatorComposite.php b/src/Phalcon/Validation/AbstractValidatorComposite.php index 03f6ed1b..b1180f8d 100644 --- a/src/Phalcon/Validation/AbstractValidatorComposite.php +++ b/src/Phalcon/Validation/AbstractValidatorComposite.php @@ -37,5 +37,4 @@ public function getValidators(): array public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/ValidationInterface.php b/src/Phalcon/Validation/ValidationInterface.php index e439e0d7..d8a7caf5 100644 --- a/src/Phalcon/Validation/ValidationInterface.php +++ b/src/Phalcon/Validation/ValidationInterface.php @@ -132,5 +132,4 @@ public function setLabels(array $labels); * @return Messages */ public function validate($data = null, $entity = null): Messages; - } diff --git a/src/Phalcon/Validation/Validator/Alnum.php b/src/Phalcon/Validation/Validator/Alnum.php index 3bb554b6..bdd79a8b 100644 --- a/src/Phalcon/Validation/Validator/Alnum.php +++ b/src/Phalcon/Validation/Validator/Alnum.php @@ -61,5 +61,4 @@ class Alnum extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Alpha.php b/src/Phalcon/Validation/Validator/Alpha.php index 2c51c103..64b374fd 100644 --- a/src/Phalcon/Validation/Validator/Alpha.php +++ b/src/Phalcon/Validation/Validator/Alpha.php @@ -61,5 +61,4 @@ class Alpha extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Between.php b/src/Phalcon/Validation/Validator/Between.php index 3d26ffc8..40ecc261 100644 --- a/src/Phalcon/Validation/Validator/Between.php +++ b/src/Phalcon/Validation/Validator/Between.php @@ -72,5 +72,4 @@ class Between extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Callback.php b/src/Phalcon/Validation/Validator/Callback.php index 24ea5033..3187fafb 100644 --- a/src/Phalcon/Validation/Validator/Callback.php +++ b/src/Phalcon/Validation/Validator/Callback.php @@ -71,5 +71,4 @@ class Callback extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Confirmation.php b/src/Phalcon/Validation/Validator/Confirmation.php index c809f153..da86e02f 100644 --- a/src/Phalcon/Validation/Validator/Confirmation.php +++ b/src/Phalcon/Validation/Validator/Confirmation.php @@ -77,5 +77,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } - } diff --git a/src/Phalcon/Validation/Validator/CreditCard.php b/src/Phalcon/Validation/Validator/CreditCard.php index 4ab9bca6..be542d77 100644 --- a/src/Phalcon/Validation/Validator/CreditCard.php +++ b/src/Phalcon/Validation/Validator/CreditCard.php @@ -72,5 +72,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Date.php b/src/Phalcon/Validation/Validator/Date.php index 90d5e1f8..7f73687e 100644 --- a/src/Phalcon/Validation/Validator/Date.php +++ b/src/Phalcon/Validation/Validator/Date.php @@ -75,5 +75,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Digit.php b/src/Phalcon/Validation/Validator/Digit.php index c1c90ce0..c98a06d5 100644 --- a/src/Phalcon/Validation/Validator/Digit.php +++ b/src/Phalcon/Validation/Validator/Digit.php @@ -61,5 +61,4 @@ class Digit extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Email.php b/src/Phalcon/Validation/Validator/Email.php index 53553bb3..9d783851 100644 --- a/src/Phalcon/Validation/Validator/Email.php +++ b/src/Phalcon/Validation/Validator/Email.php @@ -61,5 +61,4 @@ class Email extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/ExclusionIn.php b/src/Phalcon/Validation/Validator/ExclusionIn.php index 1f8c7823..48552430 100644 --- a/src/Phalcon/Validation/Validator/ExclusionIn.php +++ b/src/Phalcon/Validation/Validator/ExclusionIn.php @@ -72,5 +72,4 @@ class ExclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File.php b/src/Phalcon/Validation/Validator/File.php index 1a91d938..8e036ab0 100644 --- a/src/Phalcon/Validation/Validator/File.php +++ b/src/Phalcon/Validation/Validator/File.php @@ -89,5 +89,4 @@ class File extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/Validation/Validator/File/AbstractFile.php b/src/Phalcon/Validation/Validator/File/AbstractFile.php index 84a89418..849cd591 100644 --- a/src/Phalcon/Validation/Validator/File/AbstractFile.php +++ b/src/Phalcon/Validation/Validator/File/AbstractFile.php @@ -181,5 +181,4 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } - } diff --git a/src/Phalcon/Validation/Validator/File/MimeType.php b/src/Phalcon/Validation/Validator/File/MimeType.php index ea84c5f9..443c35bd 100644 --- a/src/Phalcon/Validation/Validator/File/MimeType.php +++ b/src/Phalcon/Validation/Validator/File/MimeType.php @@ -75,5 +75,4 @@ class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php index 38bb7bec..a12f6db2 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php @@ -66,5 +66,4 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Max.php b/src/Phalcon/Validation/Validator/File/Resolution/Max.php index e72aad5d..24db0706 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Max.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Max.php @@ -71,5 +71,4 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Min.php b/src/Phalcon/Validation/Validator/File/Resolution/Min.php index 217bc726..35a093c6 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Min.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Min.php @@ -71,5 +71,4 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Equal.php b/src/Phalcon/Validation/Validator/File/Size/Equal.php index 98e35fb2..1974832e 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Size/Equal.php @@ -71,5 +71,4 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Max.php b/src/Phalcon/Validation/Validator/File/Size/Max.php index 393bb74d..48d4aebf 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Max.php +++ b/src/Phalcon/Validation/Validator/File/Size/Max.php @@ -71,5 +71,4 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Min.php b/src/Phalcon/Validation/Validator/File/Size/Min.php index c4f39021..621a0439 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Min.php +++ b/src/Phalcon/Validation/Validator/File/Size/Min.php @@ -71,5 +71,4 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Identical.php b/src/Phalcon/Validation/Validator/Identical.php index 8d57756c..4091901f 100644 --- a/src/Phalcon/Validation/Validator/Identical.php +++ b/src/Phalcon/Validation/Validator/Identical.php @@ -66,5 +66,4 @@ class Identical extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/InclusionIn.php b/src/Phalcon/Validation/Validator/InclusionIn.php index 766f0443..68e790e9 100644 --- a/src/Phalcon/Validation/Validator/InclusionIn.php +++ b/src/Phalcon/Validation/Validator/InclusionIn.php @@ -66,5 +66,4 @@ class InclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Ip.php b/src/Phalcon/Validation/Validator/Ip.php index 830108e5..1ed667e6 100644 --- a/src/Phalcon/Validation/Validator/Ip.php +++ b/src/Phalcon/Validation/Validator/Ip.php @@ -84,5 +84,4 @@ class Ip extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Numericality.php b/src/Phalcon/Validation/Validator/Numericality.php index a9e38b56..e7443a15 100644 --- a/src/Phalcon/Validation/Validator/Numericality.php +++ b/src/Phalcon/Validation/Validator/Numericality.php @@ -61,5 +61,4 @@ class Numericality extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/PresenceOf.php b/src/Phalcon/Validation/Validator/PresenceOf.php index 2a0abec7..9b7e57a4 100644 --- a/src/Phalcon/Validation/Validator/PresenceOf.php +++ b/src/Phalcon/Validation/Validator/PresenceOf.php @@ -61,5 +61,4 @@ class PresenceOf extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Regex.php b/src/Phalcon/Validation/Validator/Regex.php index 85badd74..03fbc77d 100644 --- a/src/Phalcon/Validation/Validator/Regex.php +++ b/src/Phalcon/Validation/Validator/Regex.php @@ -66,5 +66,4 @@ class Regex extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength.php b/src/Phalcon/Validation/Validator/StringLength.php index 599159a9..1e332e06 100644 --- a/src/Phalcon/Validation/Validator/StringLength.php +++ b/src/Phalcon/Validation/Validator/StringLength.php @@ -84,5 +84,4 @@ class StringLength extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength/Max.php b/src/Phalcon/Validation/Validator/StringLength/Max.php index 41c15755..d7a6e675 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Max.php +++ b/src/Phalcon/Validation/Validator/StringLength/Max.php @@ -73,5 +73,4 @@ class Max extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength/Min.php b/src/Phalcon/Validation/Validator/StringLength/Min.php index 3cc02bbd..93a22fa2 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Min.php +++ b/src/Phalcon/Validation/Validator/StringLength/Min.php @@ -73,5 +73,4 @@ class Min extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Uniqueness.php b/src/Phalcon/Validation/Validator/Uniqueness.php index 51fc19d0..4ded9900 100644 --- a/src/Phalcon/Validation/Validator/Uniqueness.php +++ b/src/Phalcon/Validation/Validator/Uniqueness.php @@ -131,5 +131,4 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } - } diff --git a/src/Phalcon/Validation/Validator/Url.php b/src/Phalcon/Validation/Validator/Url.php index 23c3bbbb..19f47564 100644 --- a/src/Phalcon/Validation/Validator/Url.php +++ b/src/Phalcon/Validation/Validator/Url.php @@ -61,5 +61,4 @@ class Url extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/ValidatorCompositeInterface.php b/src/Phalcon/Validation/ValidatorCompositeInterface.php index c7eadf9f..cb532dfc 100644 --- a/src/Phalcon/Validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/Validation/ValidatorCompositeInterface.php @@ -30,5 +30,4 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; - } diff --git a/src/Phalcon/Validation/ValidatorFactory.php b/src/Phalcon/Validation/ValidatorFactory.php index c07b1c1d..d1253674 100644 --- a/src/Phalcon/Validation/ValidatorFactory.php +++ b/src/Phalcon/Validation/ValidatorFactory.php @@ -48,5 +48,4 @@ public function newInstance(string $name): ValidatorInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Validation/ValidatorInterface.php b/src/Phalcon/Validation/ValidatorInterface.php index da14e5a5..2019197f 100644 --- a/src/Phalcon/Validation/ValidatorInterface.php +++ b/src/Phalcon/Validation/ValidatorInterface.php @@ -73,5 +73,4 @@ public function setTemplates(array $templates): ValidatorInterface; * @param string $template */ public function setTemplate(string $template): ValidatorInterface; - } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 07b80a6b..f9904425 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -92,7 +92,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - protected final static function _getSpecial(int $special): string + final protected static function _getSpecial(int $special): string { } @@ -138,5 +138,4 @@ public static function getId(): string public static function getPart(int $part): string { } - } From 21b5a6650cecb0a44194129014afd758be6d8099 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sat, 21 Dec 2019 20:19:45 +0100 Subject: [PATCH 24/25] Upgraded stubs --- src/Phalcon/Acl/Adapter/AbstractAdapter.php | 2 + src/Phalcon/Acl/Adapter/AdapterInterface.php | 8 +- src/Phalcon/Acl/Adapter/Memory.php | 14 +- src/Phalcon/Acl/Component.php | 1 + src/Phalcon/Acl/ComponentAware.php | 1 + src/Phalcon/Acl/ComponentInterface.php | 1 + src/Phalcon/Acl/Enum.php | 2 + src/Phalcon/Acl/Role.php | 1 + src/Phalcon/Acl/RoleAware.php | 1 + src/Phalcon/Acl/RoleInterface.php | 1 + .../Annotations/Adapter/AbstractAdapter.php | 6 +- .../Annotations/Adapter/AdapterInterface.php | 3 +- src/Phalcon/Annotations/Adapter/Apcu.php | 10 +- src/Phalcon/Annotations/Adapter/Memory.php | 3 + src/Phalcon/Annotations/Adapter/Stream.php | 11 +- src/Phalcon/Annotations/Annotation.php | 1 + .../Annotations/AnnotationsFactory.php | 19 +- src/Phalcon/Annotations/Collection.php | 8 +- src/Phalcon/Annotations/Reader.php | 3 + src/Phalcon/Annotations/ReaderInterface.php | 1 + src/Phalcon/Annotations/Reflection.php | 5 +- .../Application/AbstractApplication.php | 2 + src/Phalcon/Assets/Asset.php | 1 + src/Phalcon/Assets/Asset/Css.php | 3 + src/Phalcon/Assets/Asset/Js.php | 3 + src/Phalcon/Assets/AssetInterface.php | 1 + src/Phalcon/Assets/Collection.php | 8 + src/Phalcon/Assets/FilterInterface.php | 1 + src/Phalcon/Assets/Filters/Cssmin.php | 3 + src/Phalcon/Assets/Filters/Jsmin.php | 3 + src/Phalcon/Assets/Filters/None.php | 3 + src/Phalcon/Assets/Inline.php | 1 + src/Phalcon/Assets/Inline/Css.php | 3 + src/Phalcon/Assets/Inline/Js.php | 3 + src/Phalcon/Assets/Manager.php | 9 +- src/Phalcon/Cache.php | 3 + src/Phalcon/Cache/Adapter/Apcu.php | 1 + src/Phalcon/Cache/Adapter/Libmemcached.php | 1 + src/Phalcon/Cache/Adapter/Memory.php | 1 + src/Phalcon/Cache/Adapter/Redis.php | 1 + src/Phalcon/Cache/Adapter/Stream.php | 1 + src/Phalcon/Cache/AdapterFactory.php | 23 +- src/Phalcon/Cache/CacheFactory.php | 53 +++- src/Phalcon/Cli/Console.php | 5 + src/Phalcon/Cli/Dispatcher.php | 6 + src/Phalcon/Cli/DispatcherInterface.php | 1 + src/Phalcon/Cli/Router.php | 8 +- src/Phalcon/Cli/Router/Route.php | 5 +- src/Phalcon/Cli/Router/RouteInterface.php | 1 + src/Phalcon/Cli/RouterInterface.php | 3 +- src/Phalcon/Cli/Task.php | 2 + src/Phalcon/Collection.php | 8 + src/Phalcon/Collection/Exception.php | 2 + src/Phalcon/Collection/ReadOnly.php | 1 + src/Phalcon/Config.php | 4 + src/Phalcon/Config/Adapter/Grouped.php | 4 + src/Phalcon/Config/Adapter/Ini.php | 2 + src/Phalcon/Config/Adapter/Json.php | 2 + src/Phalcon/Config/Adapter/Php.php | 1 + src/Phalcon/Config/Adapter/Yaml.php | 2 + src/Phalcon/Config/ConfigFactory.php | 16 +- src/Phalcon/Container.php | 2 + src/Phalcon/Crypt.php | 3 + src/Phalcon/Crypt/CryptInterface.php | 1 + src/Phalcon/Db/AbstractDb.php | 3 + src/Phalcon/Db/Adapter/AbstractAdapter.php | 26 +- src/Phalcon/Db/Adapter/AdapterInterface.php | 11 +- src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php | 18 +- src/Phalcon/Db/Adapter/Pdo/Mysql.php | 17 +- src/Phalcon/Db/Adapter/Pdo/Postgresql.php | 13 +- src/Phalcon/Db/Adapter/Pdo/Sqlite.php | 16 +- src/Phalcon/Db/Adapter/PdoFactory.php | 17 +- src/Phalcon/Db/Column.php | 1 + src/Phalcon/Db/ColumnInterface.php | 1 + src/Phalcon/Db/Dialect.php | 1 + src/Phalcon/Db/Dialect/Mysql.php | 7 + src/Phalcon/Db/Dialect/Postgresql.php | 7 + src/Phalcon/Db/Dialect/Sqlite.php | 7 + src/Phalcon/Db/DialectInterface.php | 1 + src/Phalcon/Db/Enum.php | 2 + src/Phalcon/Db/Index.php | 1 + src/Phalcon/Db/IndexInterface.php | 1 + src/Phalcon/Db/Profiler.php | 3 +- src/Phalcon/Db/Profiler/Item.php | 1 + src/Phalcon/Db/RawValue.php | 1 + src/Phalcon/Db/Reference.php | 1 + src/Phalcon/Db/ReferenceInterface.php | 1 + src/Phalcon/Db/Result/Pdo.php | 3 + src/Phalcon/Db/ResultInterface.php | 1 + src/Phalcon/Debug.php | 10 +- src/Phalcon/Debug/Dump.php | 8 + src/Phalcon/Di.php | 14 +- src/Phalcon/Di/AbstractInjectionAware.php | 1 + src/Phalcon/Di/DiInterface.php | 7 +- src/Phalcon/Di/FactoryDefault.php | 3 + src/Phalcon/Di/FactoryDefault/Cli.php | 3 + src/Phalcon/Di/Injectable.php | 2 + src/Phalcon/Di/InjectionAwareInterface.php | 1 + src/Phalcon/Di/Service.php | 5 + src/Phalcon/Di/Service/Builder.php | 4 + src/Phalcon/Di/ServiceInterface.php | 1 + src/Phalcon/Di/ServiceProviderInterface.php | 1 + src/Phalcon/Dispatcher/AbstractDispatcher.php | 7 + .../Dispatcher/DispatcherInterface.php | 1 + src/Phalcon/Dispatcher/Exception.php | 2 + src/Phalcon/Domain/Payload/Payload.php | 30 +++ src/Phalcon/Domain/Payload/PayloadFactory.php | 1 + .../Domain/Payload/ReadableInterface.php | 26 +- src/Phalcon/Domain/Payload/Status.php | 1 + .../Domain/Payload/WriteableInterface.php | 39 ++- src/Phalcon/Escaper.php | 9 +- src/Phalcon/Escaper/EscaperInterface.php | 1 + src/Phalcon/Events/Event.php | 1 + src/Phalcon/Events/EventInterface.php | 1 + src/Phalcon/Events/EventsAwareInterface.php | 1 + src/Phalcon/Events/Manager.php | 4 + src/Phalcon/Events/ManagerInterface.php | 8 +- src/Phalcon/Exception.php | 1 + src/Phalcon/Factory/AbstractFactory.php | 3 + src/Phalcon/Filter.php | 5 + src/Phalcon/Filter/FilterFactory.php | 3 + src/Phalcon/Filter/FilterInterface.php | 1 + src/Phalcon/Filter/Sanitize/AbsInt.php | 1 + src/Phalcon/Filter/Sanitize/Alnum.php | 1 + src/Phalcon/Filter/Sanitize/Alpha.php | 1 + src/Phalcon/Filter/Sanitize/BoolVal.php | 1 + src/Phalcon/Filter/Sanitize/Email.php | 1 + src/Phalcon/Filter/Sanitize/FloatVal.php | 1 + src/Phalcon/Filter/Sanitize/IntVal.php | 1 + src/Phalcon/Filter/Sanitize/Lower.php | 1 + src/Phalcon/Filter/Sanitize/LowerFirst.php | 1 + src/Phalcon/Filter/Sanitize/Regex.php | 1 + src/Phalcon/Filter/Sanitize/Remove.php | 1 + src/Phalcon/Filter/Sanitize/Replace.php | 1 + src/Phalcon/Filter/Sanitize/Special.php | 1 + src/Phalcon/Filter/Sanitize/SpecialFull.php | 1 + src/Phalcon/Filter/Sanitize/StringVal.php | 1 + src/Phalcon/Filter/Sanitize/Striptags.php | 1 + src/Phalcon/Filter/Sanitize/Trim.php | 1 + src/Phalcon/Filter/Sanitize/Upper.php | 1 + src/Phalcon/Filter/Sanitize/UpperFirst.php | 1 + src/Phalcon/Filter/Sanitize/UpperWords.php | 1 + src/Phalcon/Filter/Sanitize/Url.php | 1 + .../Firewall/Adapter/AbstractAdapter.php | 238 ----------------- src/Phalcon/Firewall/Adapter/Acl.php | 217 --------------- .../Firewall/Adapter/AdapterInterface.php | 72 ----- src/Phalcon/Firewall/Adapter/Annotations.php | 136 ---------- src/Phalcon/Firewall/Adapter/Micro/Acl.php | 243 ----------------- src/Phalcon/Firewall/Exception.php | 18 -- src/Phalcon/Flash/AbstractFlash.php | 3 + src/Phalcon/Flash/Direct.php | 1 + src/Phalcon/Flash/FlashInterface.php | 1 + src/Phalcon/Flash/Session.php | 2 + src/Phalcon/Forms/Element/AbstractElement.php | 8 +- src/Phalcon/Forms/Element/Check.php | 3 + src/Phalcon/Forms/Element/Date.php | 3 + .../Forms/Element/ElementInterface.php | 5 +- src/Phalcon/Forms/Element/Email.php | 3 + src/Phalcon/Forms/Element/File.php | 3 + src/Phalcon/Forms/Element/Hidden.php | 3 + src/Phalcon/Forms/Element/Numeric.php | 3 + src/Phalcon/Forms/Element/Password.php | 3 + src/Phalcon/Forms/Element/Radio.php | 3 + src/Phalcon/Forms/Element/Select.php | 3 + src/Phalcon/Forms/Element/Submit.php | 3 + src/Phalcon/Forms/Element/Text.php | 3 + src/Phalcon/Forms/Element/TextArea.php | 3 + src/Phalcon/Forms/Form.php | 10 +- src/Phalcon/Forms/Manager.php | 1 + src/Phalcon/Helper/Arr.php | 31 ++- src/Phalcon/Helper/Fs.php | 1 + src/Phalcon/Helper/Json.php | 79 ++++++ src/Phalcon/Helper/Number.php | 1 + src/Phalcon/Helper/Str.php | 23 ++ src/Phalcon/Html/Attributes.php | 3 + .../Html/Attributes/AttributesInterface.php | 1 + .../Html/Attributes/RenderInterface.php | 1 + src/Phalcon/Html/Breadcrumbs.php | 3 + src/Phalcon/Html/Helper/AbstractHelper.php | 2 + src/Phalcon/Html/Helper/Anchor.php | 1 + src/Phalcon/Html/Helper/AnchorRaw.php | 1 + src/Phalcon/Html/Helper/Body.php | 1 + src/Phalcon/Html/Helper/Button.php | 1 + src/Phalcon/Html/Helper/Close.php | 1 + src/Phalcon/Html/Helper/Element.php | 1 + src/Phalcon/Html/Helper/ElementRaw.php | 1 + src/Phalcon/Html/Helper/Form.php | 1 + src/Phalcon/Html/Helper/Img.php | 1 + src/Phalcon/Html/Helper/Label.php | 1 + src/Phalcon/Html/Helper/TextArea.php | 1 + src/Phalcon/Html/Link/EvolvableLink.php | 1 + .../Html/Link/EvolvableLinkProvider.php | 1 + src/Phalcon/Html/Link/Link.php | 1 + src/Phalcon/Html/Link/LinkProvider.php | 1 + src/Phalcon/Html/Link/Serializer/Header.php | 1 + .../Link/Serializer/SerializerInterface.php | 1 + src/Phalcon/Html/TagFactory.php | 2 + src/Phalcon/Http/Cookie.php | 78 +++++- .../Http/{ => Cookie}/CookieInterface.php | 18 +- src/Phalcon/Http/Message/AbstractCommon.php | 3 + src/Phalcon/Http/Message/AbstractMessage.php | 1 + src/Phalcon/Http/Message/AbstractRequest.php | 2 + .../Exception/InvalidArgumentException.php | 2 + src/Phalcon/Http/Message/Request.php | 3 + src/Phalcon/Http/Message/RequestFactory.php | 3 +- src/Phalcon/Http/Message/Response.php | 4 + src/Phalcon/Http/Message/ResponseFactory.php | 3 +- src/Phalcon/Http/Message/ServerRequest.php | 2 + .../Http/Message/ServerRequestFactory.php | 4 +- src/Phalcon/Http/Message/Stream.php | 4 + src/Phalcon/Http/Message/Stream/Input.php | 1 + src/Phalcon/Http/Message/Stream/Memory.php | 1 + src/Phalcon/Http/Message/Stream/Temp.php | 1 + src/Phalcon/Http/Message/StreamFactory.php | 2 + src/Phalcon/Http/Message/UploadedFile.php | 4 + .../Http/Message/UploadedFileFactory.php | 3 +- src/Phalcon/Http/Message/Uri.php | 3 + src/Phalcon/Http/Message/UriFactory.php | 1 + src/Phalcon/Http/Request.php | 11 +- src/Phalcon/Http/Request/File.php | 1 + src/Phalcon/Http/Request/FileInterface.php | 8 + src/Phalcon/Http/RequestInterface.php | 6 +- src/Phalcon/Http/Response.php | 16 +- src/Phalcon/Http/Response/Cookies.php | 8 +- .../Http/Response/CookiesInterface.php | 6 +- src/Phalcon/Http/Response/Headers.php | 1 + .../Http/Response/HeadersInterface.php | 1 + src/Phalcon/Http/ResponseInterface.php | 2 + .../Http/Server/AbstractMiddleware.php | 1 + .../Http/Server/AbstractRequestHandler.php | 1 + src/Phalcon/Image/Adapter/AbstractAdapter.php | 4 +- .../Image/Adapter/AdapterInterface.php | 1 + src/Phalcon/Image/Adapter/Gd.php | 6 +- src/Phalcon/Image/Adapter/Imagick.php | 8 +- src/Phalcon/Image/Enum.php | 2 + src/Phalcon/Image/ImageFactory.php | 10 +- src/Phalcon/Kernel.php | 1 + src/Phalcon/Loader.php | 3 + src/Phalcon/Logger.php | 5 +- .../Logger/Adapter/AbstractAdapter.php | 4 + .../Logger/Adapter/AdapterInterface.php | 10 + src/Phalcon/Logger/Adapter/Noop.php | 3 + src/Phalcon/Logger/Adapter/Stream.php | 11 +- src/Phalcon/Logger/Adapter/Syslog.php | 18 +- src/Phalcon/Logger/AdapterFactory.php | 1 + .../Logger/Formatter/AbstractFormatter.php | 3 + .../Logger/Formatter/FormatterInterface.php | 3 + src/Phalcon/Logger/Formatter/Json.php | 6 +- src/Phalcon/Logger/Formatter/Line.php | 5 +- src/Phalcon/Logger/Item.php | 1 + src/Phalcon/Logger/LoggerFactory.php | 16 +- src/Phalcon/Messages/Message.php | 3 + src/Phalcon/Messages/MessageInterface.php | 1 + src/Phalcon/Messages/Messages.php | 6 + src/Phalcon/Mvc/Application.php | 8 + src/Phalcon/Mvc/Controller.php | 1 + .../Mvc/Controller/BindModelInterface.php | 1 + src/Phalcon/Mvc/Dispatcher.php | 6 + src/Phalcon/Mvc/DispatcherInterface.php | 1 + src/Phalcon/Mvc/EntityInterface.php | 1 + src/Phalcon/Mvc/Micro.php | 15 +- src/Phalcon/Mvc/Micro/Collection.php | 1 + src/Phalcon/Mvc/Micro/CollectionInterface.php | 1 + src/Phalcon/Mvc/Micro/LazyLoader.php | 3 + src/Phalcon/Mvc/Micro/MiddlewareInterface.php | 3 + src/Phalcon/Mvc/Model.php | 192 +++++++++++++- src/Phalcon/Mvc/Model/Behavior.php | 3 + src/Phalcon/Mvc/Model/Behavior/SoftDelete.php | 3 + .../Mvc/Model/Behavior/Timestampable.php | 4 + src/Phalcon/Mvc/Model/BehaviorInterface.php | 3 + src/Phalcon/Mvc/Model/Binder.php | 6 + .../Mvc/Model/Binder/BindableInterface.php | 1 + src/Phalcon/Mvc/Model/BinderInterface.php | 1 + src/Phalcon/Mvc/Model/Criteria.php | 4 + src/Phalcon/Mvc/Model/CriteriaInterface.php | 3 + src/Phalcon/Mvc/Model/Manager.php | 29 +- src/Phalcon/Mvc/Model/ManagerInterface.php | 20 +- src/Phalcon/Mvc/Model/MetaData.php | 4 + src/Phalcon/Mvc/Model/MetaData/Apcu.php | 4 + .../Mvc/Model/MetaData/Libmemcached.php | 4 + src/Phalcon/Mvc/Model/MetaData/Memory.php | 2 + src/Phalcon/Mvc/Model/MetaData/Redis.php | 3 + .../Model/MetaData/Strategy/Annotations.php | 7 + .../Model/MetaData/Strategy/Introspection.php | 8 + .../MetaData/Strategy/StrategyInterface.php | 4 + src/Phalcon/Mvc/Model/MetaData/Stream.php | 2 + src/Phalcon/Mvc/Model/MetaDataInterface.php | 2 + src/Phalcon/Mvc/Model/Query.php | 16 +- src/Phalcon/Mvc/Model/Query/Builder.php | 6 + .../Mvc/Model/Query/BuilderInterface.php | 1 + src/Phalcon/Mvc/Model/Query/Lang.php | 1 + src/Phalcon/Mvc/Model/Query/Status.php | 4 +- .../Mvc/Model/Query/StatusInterface.php | 4 +- src/Phalcon/Mvc/Model/QueryInterface.php | 1 + src/Phalcon/Mvc/Model/Relation.php | 1 + src/Phalcon/Mvc/Model/RelationInterface.php | 1 + src/Phalcon/Mvc/Model/ResultInterface.php | 3 + src/Phalcon/Mvc/Model/Resultset.php | 18 +- src/Phalcon/Mvc/Model/Resultset/Complex.php | 12 + src/Phalcon/Mvc/Model/Resultset/Simple.php | 7 + src/Phalcon/Mvc/Model/ResultsetInterface.php | 9 +- src/Phalcon/Mvc/Model/Row.php | 6 + src/Phalcon/Mvc/Model/Transaction.php | 7 + src/Phalcon/Mvc/Model/Transaction/Failed.php | 4 +- src/Phalcon/Mvc/Model/Transaction/Manager.php | 4 + .../Model/Transaction/ManagerInterface.php | 1 + .../Mvc/Model/TransactionInterface.php | 4 + src/Phalcon/Mvc/Model/ValidationFailed.php | 3 +- src/Phalcon/Mvc/ModelInterface.php | 6 +- src/Phalcon/Mvc/ModuleDefinitionInterface.php | 3 + src/Phalcon/Mvc/Router.php | 86 +++++- src/Phalcon/Mvc/Router/Annotations.php | 3 + src/Phalcon/Mvc/Router/Group.php | 87 +++++- src/Phalcon/Mvc/Router/GroupInterface.php | 3 +- src/Phalcon/Mvc/Router/Route.php | 3 +- src/Phalcon/Mvc/Router/RouteInterface.php | 1 + src/Phalcon/Mvc/RouterInterface.php | 4 +- src/Phalcon/Mvc/View.php | 8 + .../Mvc/View/Engine/AbstractEngine.php | 2 + .../Mvc/View/Engine/EngineInterface.php | 1 + src/Phalcon/Mvc/View/Engine/Php.php | 1 + src/Phalcon/Mvc/View/Engine/Volt.php | 4 + src/Phalcon/Mvc/View/Engine/Volt/Compiler.php | 4 + .../Mvc/View/Engine/Volt/Exception.php | 3 + src/Phalcon/Mvc/View/Simple.php | 9 + src/Phalcon/Mvc/ViewBaseInterface.php | 3 + src/Phalcon/Mvc/ViewInterface.php | 1 + .../Paginator/Adapter/AbstractAdapter.php | 3 + .../Paginator/Adapter/AdapterInterface.php | 1 + src/Phalcon/Paginator/Adapter/Model.php | 5 + src/Phalcon/Paginator/Adapter/NativeArray.php | 2 + .../Paginator/Adapter/QueryBuilder.php | 9 +- src/Phalcon/Paginator/PaginatorFactory.php | 16 +- src/Phalcon/Paginator/Repository.php | 4 + src/Phalcon/Paginator/RepositoryInterface.php | 1 + src/Phalcon/Registry.php | 1 + src/Phalcon/Security.php | 74 ++++-- src/Phalcon/Security/Random.php | 1 + .../Session/Adapter/AbstractAdapter.php | 2 + src/Phalcon/Session/Adapter/Libmemcached.php | 18 +- src/Phalcon/Session/Adapter/Noop.php | 7 +- src/Phalcon/Session/Adapter/Redis.php | 13 +- src/Phalcon/Session/Adapter/Stream.php | 11 +- src/Phalcon/Session/Bag.php | 3 + src/Phalcon/Session/Manager.php | 10 +- src/Phalcon/Session/ManagerInterface.php | 2 + .../Storage/Adapter/AbstractAdapter.php | 33 ++- .../Storage/Adapter/AdapterInterface.php | 9 +- src/Phalcon/Storage/Adapter/Apcu.php | 19 +- src/Phalcon/Storage/Adapter/Libmemcached.php | 24 +- src/Phalcon/Storage/Adapter/Memory.php | 19 +- src/Phalcon/Storage/Adapter/Redis.php | 22 +- src/Phalcon/Storage/Adapter/Stream.php | 32 ++- src/Phalcon/Storage/AdapterFactory.php | 24 +- .../Storage/Serializer/AbstractSerializer.php | 3 + src/Phalcon/Storage/Serializer/Base64.php | 3 + src/Phalcon/Storage/Serializer/Igbinary.php | 1 + src/Phalcon/Storage/Serializer/Json.php | 5 + src/Phalcon/Storage/Serializer/Msgpack.php | 1 + src/Phalcon/Storage/Serializer/None.php | 3 + src/Phalcon/Storage/Serializer/Php.php | 4 + .../Serializer/SerializerInterface.php | 3 + src/Phalcon/Storage/SerializerFactory.php | 1 + src/Phalcon/Tag.php | 249 +++++++++++++++--- src/Phalcon/Tag/Select.php | 14 +- src/Phalcon/Text.php | 3 + .../Translate/Adapter/AbstractAdapter.php | 3 + .../Translate/Adapter/AdapterInterface.php | 3 +- src/Phalcon/Translate/Adapter/Csv.php | 11 +- src/Phalcon/Translate/Adapter/Gettext.php | 12 +- src/Phalcon/Translate/Adapter/NativeArray.php | 10 +- .../Interpolator/AssociativeArray.php | 1 + .../Translate/Interpolator/IndexedArray.php | 1 + .../Interpolator/InterpolatorInterface.php | 1 + src/Phalcon/Translate/InterpolatorFactory.php | 1 + src/Phalcon/Translate/TranslateFactory.php | 29 ++ src/Phalcon/Url.php | 12 +- src/Phalcon/Url/UrlInterface.php | 1 + src/Phalcon/Validation.php | 7 + src/Phalcon/Validation/AbstractValidator.php | 4 + .../Validation/AbstractValidatorComposite.php | 3 + .../Validation/ValidationInterface.php | 3 + src/Phalcon/Validation/Validator/Alnum.php | 15 ++ src/Phalcon/Validation/Validator/Alpha.php | 16 ++ src/Phalcon/Validation/Validator/Between.php | 18 ++ src/Phalcon/Validation/Validator/Callback.php | 18 ++ .../Validation/Validator/Confirmation.php | 20 ++ .../Validation/Validator/CreditCard.php | 16 ++ src/Phalcon/Validation/Validator/Date.php | 18 ++ src/Phalcon/Validation/Validator/Digit.php | 16 ++ src/Phalcon/Validation/Validator/Email.php | 16 ++ .../Validation/Validator/ExclusionIn.php | 19 ++ src/Phalcon/Validation/Validator/File.php | 33 ++- .../Validator/File/AbstractFile.php | 2 + .../Validation/Validator/File/MimeType.php | 3 + .../Validator/File/Resolution/Equal.php | 16 ++ .../Validator/File/Resolution/Max.php | 17 ++ .../Validator/File/Resolution/Min.php | 17 ++ .../Validation/Validator/File/Size/Equal.php | 16 ++ .../Validation/Validator/File/Size/Max.php | 17 ++ .../Validation/Validator/File/Size/Min.php | 17 ++ .../Validation/Validator/Identical.php | 18 ++ .../Validation/Validator/InclusionIn.php | 19 ++ src/Phalcon/Validation/Validator/Ip.php | 18 ++ .../Validation/Validator/Numericality.php | 16 ++ .../Validation/Validator/PresenceOf.php | 16 ++ src/Phalcon/Validation/Validator/Regex.php | 17 ++ .../Validation/Validator/StringLength.php | 17 +- .../Validation/Validator/StringLength/Max.php | 19 ++ .../Validation/Validator/StringLength/Min.php | 19 ++ .../Validation/Validator/Uniqueness.php | 22 ++ src/Phalcon/Validation/Validator/Url.php | 17 ++ .../ValidatorCompositeInterface.php | 3 + src/Phalcon/Validation/ValidatorFactory.php | 2 + src/Phalcon/Validation/ValidatorInterface.php | 4 + src/Phalcon/Version.php | 3 +- 416 files changed, 2917 insertions(+), 1242 deletions(-) delete mode 100644 src/Phalcon/Firewall/Adapter/AbstractAdapter.php delete mode 100644 src/Phalcon/Firewall/Adapter/Acl.php delete mode 100644 src/Phalcon/Firewall/Adapter/AdapterInterface.php delete mode 100644 src/Phalcon/Firewall/Adapter/Annotations.php delete mode 100644 src/Phalcon/Firewall/Adapter/Micro/Acl.php delete mode 100644 src/Phalcon/Firewall/Exception.php create mode 100644 src/Phalcon/Helper/Json.php rename src/Phalcon/Http/{ => Cookie}/CookieInterface.php (90%) diff --git a/src/Phalcon/Acl/Adapter/AbstractAdapter.php b/src/Phalcon/Acl/Adapter/AbstractAdapter.php index d7ea0d05..fe90af61 100644 --- a/src/Phalcon/Acl/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Acl/Adapter/AbstractAdapter.php @@ -10,6 +10,7 @@ namespace Phalcon\Acl\Adapter; use Phalcon\Events\ManagerInterface; +use Phalcon\Events\EventsAwareInterface; /** * Adapter for Phalcon\Acl adapters @@ -126,4 +127,5 @@ public function setDefaultAction(int $defaultAccess) public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/Acl/Adapter/AdapterInterface.php b/src/Phalcon/Acl/Adapter/AdapterInterface.php index 50dcf539..58fde935 100644 --- a/src/Phalcon/Acl/Adapter/AdapterInterface.php +++ b/src/Phalcon/Acl/Adapter/AdapterInterface.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Acl\Adapter; +use Phalcon\Acl\ComponentInterface; +use Phalcon\Acl\RoleInterface; + /** * Interface for Phalcon\Acl adapters */ @@ -127,14 +130,14 @@ public function getNoArgumentsDefaultAction(): int; /** * Return an array with every role registered in the list * - * @return array + * @return array|\Phalcon\Acl\RoleInterface[] */ public function getRoles(): array; /** * Return an array with every component registered in the list * - * @return array + * @return array|\Phalcon\Acl\ComponentInterface[] */ public function getComponents(): array; @@ -182,4 +185,5 @@ public function setDefaultAction(int $defaultAccess); * @return void */ public function setNoArgumentsDefaultAction(int $defaultAccess); + } diff --git a/src/Phalcon/Acl/Adapter/Memory.php b/src/Phalcon/Acl/Adapter/Memory.php index 6a243609..9d367571 100644 --- a/src/Phalcon/Acl/Adapter/Memory.php +++ b/src/Phalcon/Acl/Adapter/Memory.php @@ -10,6 +10,15 @@ namespace Phalcon\Acl\Adapter; use Phalcon\Acl\Enum; +use Phalcon\Acl\Role; +use Phalcon\Acl\RoleInterface; +use Phalcon\Acl\Component; +use Phalcon\Acl\Exception; +use Phalcon\Events\Manager as EventsManager; +use Phalcon\Acl\RoleAware; +use Phalcon\Acl\ComponentAware; +use Phalcon\Acl\ComponentInterface; +use ReflectionFunction; /** * Manages ACL lists in memory @@ -362,7 +371,7 @@ public function getNoArgumentsDefaultAction(): int /** * Return an array with every role registered in the list * - * @return array + * @return array|\Phalcon\Acl\RoleInterface[] */ public function getRoles(): array { @@ -371,7 +380,7 @@ public function getRoles(): array /** * Return an array with every component registered in the list * - * @return array + * @return array|\Phalcon\Acl\ComponentInterface[] */ public function getComponents(): array { @@ -455,4 +464,5 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } + } diff --git a/src/Phalcon/Acl/Component.php b/src/Phalcon/Acl/Component.php index 3de82caf..66c8319f 100644 --- a/src/Phalcon/Acl/Component.php +++ b/src/Phalcon/Acl/Component.php @@ -65,4 +65,5 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/Acl/ComponentAware.php b/src/Phalcon/Acl/ComponentAware.php index a631e35b..37b68783 100644 --- a/src/Phalcon/Acl/ComponentAware.php +++ b/src/Phalcon/Acl/ComponentAware.php @@ -21,4 +21,5 @@ interface ComponentAware * @return string */ public function getComponentName(): string; + } diff --git a/src/Phalcon/Acl/ComponentInterface.php b/src/Phalcon/Acl/ComponentInterface.php index 3cc7b050..92284e37 100644 --- a/src/Phalcon/Acl/ComponentInterface.php +++ b/src/Phalcon/Acl/ComponentInterface.php @@ -35,4 +35,5 @@ public function getName(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/Acl/Enum.php b/src/Phalcon/Acl/Enum.php index b6d62470..31c3e271 100644 --- a/src/Phalcon/Acl/Enum.php +++ b/src/Phalcon/Acl/Enum.php @@ -19,4 +19,6 @@ class Enum const DENY = 0; + + } diff --git a/src/Phalcon/Acl/Role.php b/src/Phalcon/Acl/Role.php index 0618f41a..784d988f 100644 --- a/src/Phalcon/Acl/Role.php +++ b/src/Phalcon/Acl/Role.php @@ -65,4 +65,5 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } + } diff --git a/src/Phalcon/Acl/RoleAware.php b/src/Phalcon/Acl/RoleAware.php index 2ffaf09f..2f1a3fb9 100644 --- a/src/Phalcon/Acl/RoleAware.php +++ b/src/Phalcon/Acl/RoleAware.php @@ -21,4 +21,5 @@ interface RoleAware * @return string */ public function getRoleName(): string; + } diff --git a/src/Phalcon/Acl/RoleInterface.php b/src/Phalcon/Acl/RoleInterface.php index 87beb275..edfc723a 100644 --- a/src/Phalcon/Acl/RoleInterface.php +++ b/src/Phalcon/Acl/RoleInterface.php @@ -35,4 +35,5 @@ public function getDescription(): string; * @return string */ public function __toString(): string; + } diff --git a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php index 97373f18..daf66dc7 100644 --- a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php @@ -9,10 +9,11 @@ */ namespace Phalcon\Annotations\Adapter; -use Phalcon\Annotations\Collection; use Phalcon\Annotations\Reader; -use Phalcon\Annotations\ReaderInterface; +use Phalcon\Annotations\Exception; +use Phalcon\Annotations\Collection; use Phalcon\Annotations\Reflection; +use Phalcon\Annotations\ReaderInterface; /** * This is the base class for Phalcon\Annotations adapters @@ -99,4 +100,5 @@ public function getReader(): ReaderInterface public function setReader(\Phalcon\Annotations\ReaderInterface $reader) { } + } diff --git a/src/Phalcon/Annotations/Adapter/AdapterInterface.php b/src/Phalcon/Annotations/Adapter/AdapterInterface.php index 6f851a21..d5a01454 100644 --- a/src/Phalcon/Annotations/Adapter/AdapterInterface.php +++ b/src/Phalcon/Annotations/Adapter/AdapterInterface.php @@ -9,9 +9,9 @@ */ namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Reflection; use Phalcon\Annotations\Collection; use Phalcon\Annotations\ReaderInterface; -use Phalcon\Annotations\Reflection; /** * This interface must be implemented by adapters in Phalcon\Annotations @@ -74,4 +74,5 @@ public function getReader(): ReaderInterface; * @param \Phalcon\Annotations\ReaderInterface $reader */ public function setReader(\Phalcon\Annotations\ReaderInterface $reader); + } diff --git a/src/Phalcon/Annotations/Adapter/Apcu.php b/src/Phalcon/Annotations/Adapter/Apcu.php index 00e61855..b4eb9fe6 100644 --- a/src/Phalcon/Annotations/Adapter/Apcu.php +++ b/src/Phalcon/Annotations/Adapter/Apcu.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Reflection; + /** * Stores the parsed annotations in APCu. This adapter is suitable for production * @@ -32,9 +34,12 @@ class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter /** - * Phalcon\Annotations\Adapter\Apcu constructor + * @param array $options = [ + * 'prefix' => 'phalcon' + * 'lifetime' => 3600 + * ] * - * @param array $options + * Phalcon\Annotations\Adapter\Apcu constructor */ public function __construct(array $options = array()) { @@ -60,4 +65,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data): bool { } + } diff --git a/src/Phalcon/Annotations/Adapter/Memory.php b/src/Phalcon/Annotations/Adapter/Memory.php index cce0444f..69d73519 100644 --- a/src/Phalcon/Annotations/Adapter/Memory.php +++ b/src/Phalcon/Annotations/Adapter/Memory.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Reflection; + /** * Stores the parsed annotations in memory. This adapter is the suitable * development/testing @@ -41,4 +43,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/Annotations/Adapter/Stream.php b/src/Phalcon/Annotations/Adapter/Stream.php index da16f41b..b5c4a1e1 100644 --- a/src/Phalcon/Annotations/Adapter/Stream.php +++ b/src/Phalcon/Annotations/Adapter/Stream.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Annotations\Adapter; +use Phalcon\Annotations\Reflection; +use Phalcon\Annotations\Exception; +use RuntimeException; + /** * Stores the parsed annotations in files. This adapter is suitable for production * @@ -31,9 +35,11 @@ class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter /** - * Phalcon\Annotations\Adapter\Stream constructor + * @param array $options = [ + * 'annotationsDir' => 'phalconDir' + * ] * - * @param array $options + * Phalcon\Annotations\Adapter\Stream constructor */ public function __construct(array $options = array()) { @@ -59,4 +65,5 @@ public function read(string $key) public function write(string $key, \Phalcon\Annotations\Reflection $data) { } + } diff --git a/src/Phalcon/Annotations/Annotation.php b/src/Phalcon/Annotations/Annotation.php index 243f63a8..9ef3dd5c 100644 --- a/src/Phalcon/Annotations/Annotation.php +++ b/src/Phalcon/Annotations/Annotation.php @@ -128,4 +128,5 @@ public function hasArgument($position): bool public function numberArguments(): int { } + } diff --git a/src/Phalcon/Annotations/AnnotationsFactory.php b/src/Phalcon/Annotations/AnnotationsFactory.php index f72f80a1..051517ab 100644 --- a/src/Phalcon/Annotations/AnnotationsFactory.php +++ b/src/Phalcon/Annotations/AnnotationsFactory.php @@ -11,6 +11,7 @@ use Phalcon\Annotations\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; /** * Factory to create annotations components @@ -28,9 +29,16 @@ public function __construct(array $services = array()) } /** - * Factory to create an instace from a Config object + * @param array|\Phalcon\Config $config = [ + * 'adapter' => 'apcu', + * 'options' => [ + * 'prefix' => 'phalcon', + * 'lifetime' => 3600, + * 'annotationsDir' => 'phalconDir' + * ] + * ] * - * @param mixed $config + * Factory to create an instace from a Config object * @return mixed */ public function load($config) @@ -40,8 +48,12 @@ public function load($config) /** * Create a new instance of the adapter * + * @param array $options = [ + * 'prefix' => 'phalcon', + * 'lifetime' => 3600, + * 'annotationsDir' => 'phalconDir' + * ] * @param string $name - * @param array $options * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface @@ -56,4 +68,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Annotations/Collection.php b/src/Phalcon/Annotations/Collection.php index d949b7c4..cc123049 100644 --- a/src/Phalcon/Annotations/Collection.php +++ b/src/Phalcon/Annotations/Collection.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Annotations; +use Countable; +use Iterator; + /** * Represents a collection of annotations. This class allows to traverse a group * of annotations easily @@ -80,7 +83,7 @@ public function get(string $name): Annotation * Returns all the annotations that match a name * * @param string $name - * @return array + * @return array|Annotation[] */ public function getAll(string $name): array { @@ -89,7 +92,7 @@ public function getAll(string $name): array /** * Returns the internal annotations as an array * - * @return array + * @return array|Annotation[] */ public function getAnnotations(): array { @@ -140,4 +143,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/Annotations/Reader.php b/src/Phalcon/Annotations/Reader.php index ddccab04..c164bee2 100644 --- a/src/Phalcon/Annotations/Reader.php +++ b/src/Phalcon/Annotations/Reader.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Annotations; +use ReflectionClass; + /** * Parses docblocks returning an array with the found annotations */ @@ -36,4 +38,5 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } + } diff --git a/src/Phalcon/Annotations/ReaderInterface.php b/src/Phalcon/Annotations/ReaderInterface.php index af370c66..a8cc3f42 100644 --- a/src/Phalcon/Annotations/ReaderInterface.php +++ b/src/Phalcon/Annotations/ReaderInterface.php @@ -32,4 +32,5 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; + } diff --git a/src/Phalcon/Annotations/Reflection.php b/src/Phalcon/Annotations/Reflection.php index fdcb7760..696c51e1 100644 --- a/src/Phalcon/Annotations/Reflection.php +++ b/src/Phalcon/Annotations/Reflection.php @@ -65,7 +65,7 @@ public function getClassAnnotations() /** * Returns the annotations found in the methods' docblocks * - * @return array|bool + * @return array|bool|Collection[] */ public function getMethodsAnnotations() { @@ -74,7 +74,7 @@ public function getMethodsAnnotations() /** * Returns the annotations found in the properties' docblocks * - * @return array|bool + * @return array|bool|Collection[] */ public function getPropertiesAnnotations() { @@ -89,4 +89,5 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } + } diff --git a/src/Phalcon/Application/AbstractApplication.php b/src/Phalcon/Application/AbstractApplication.php index 9b1a733f..b4c7a914 100644 --- a/src/Phalcon/Application/AbstractApplication.php +++ b/src/Phalcon/Application/AbstractApplication.php @@ -11,6 +11,7 @@ use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** @@ -130,4 +131,5 @@ public function setDefaultModule(string $defaultModule): AbstractApplication public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/Assets/Asset.php b/src/Phalcon/Assets/Asset.php index 59669813..65a2ead6 100644 --- a/src/Phalcon/Assets/Asset.php +++ b/src/Phalcon/Assets/Asset.php @@ -304,4 +304,5 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } + } diff --git a/src/Phalcon/Assets/Asset/Css.php b/src/Phalcon/Assets/Asset/Css.php index a730da27..4f6e2da8 100644 --- a/src/Phalcon/Assets/Asset/Css.php +++ b/src/Phalcon/Assets/Asset/Css.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Asset; +use Phalcon\Assets\Asset as AssetBase; + /** * Represents CSS assets */ @@ -28,4 +30,5 @@ class Css extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/Assets/Asset/Js.php b/src/Phalcon/Assets/Asset/Js.php index 80c4b120..2273fea0 100644 --- a/src/Phalcon/Assets/Asset/Js.php +++ b/src/Phalcon/Assets/Asset/Js.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Asset; +use Phalcon\Assets\Asset as AssetBase; + /** * Represents Javascript assets */ @@ -28,4 +30,5 @@ class Js extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } + } diff --git a/src/Phalcon/Assets/AssetInterface.php b/src/Phalcon/Assets/AssetInterface.php index bbc486c9..b43c3ac9 100644 --- a/src/Phalcon/Assets/AssetInterface.php +++ b/src/Phalcon/Assets/AssetInterface.php @@ -66,4 +66,5 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; + } diff --git a/src/Phalcon/Assets/Collection.php b/src/Phalcon/Assets/Collection.php index e4fd9766..74bcd61d 100644 --- a/src/Phalcon/Assets/Collection.php +++ b/src/Phalcon/Assets/Collection.php @@ -9,6 +9,13 @@ */ namespace Phalcon\Assets; +use Countable; +use Iterator; +use Phalcon\Assets\Asset\Css as AssetCss; +use Phalcon\Assets\Asset\Js as AssetJs; +use Phalcon\Assets\Inline\Js as InlineJs; +use Phalcon\Assets\Inline\Css as InlineCss; + /** * Represents a collection of assets */ @@ -492,4 +499,5 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } + } diff --git a/src/Phalcon/Assets/FilterInterface.php b/src/Phalcon/Assets/FilterInterface.php index a93e24c8..9fdbdef2 100644 --- a/src/Phalcon/Assets/FilterInterface.php +++ b/src/Phalcon/Assets/FilterInterface.php @@ -22,4 +22,5 @@ interface FilterInterface * @return string */ public function filter(string $content): string; + } diff --git a/src/Phalcon/Assets/Filters/Cssmin.php b/src/Phalcon/Assets/Filters/Cssmin.php index 8c2698e6..5a699cc8 100644 --- a/src/Phalcon/Assets/Filters/Cssmin.php +++ b/src/Phalcon/Assets/Filters/Cssmin.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Minify the css - removes comments removes newlines and line feeds keeping * removes last semicolon from last property @@ -26,4 +28,5 @@ class Cssmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/Assets/Filters/Jsmin.php b/src/Phalcon/Assets/Filters/Jsmin.php index e0701838..c4959b95 100644 --- a/src/Phalcon/Assets/Filters/Jsmin.php +++ b/src/Phalcon/Assets/Filters/Jsmin.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Deletes the characters which are insignificant to JavaScript. Comments will * be removed. Tabs will be replaced with spaces. Carriage returns will be @@ -27,4 +29,5 @@ class Jsmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/Assets/Filters/None.php b/src/Phalcon/Assets/Filters/None.php index a5e19df9..cb4bb08c 100644 --- a/src/Phalcon/Assets/Filters/None.php +++ b/src/Phalcon/Assets/Filters/None.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Filters; +use Phalcon\Assets\FilterInterface; + /** * Returns the content without make any modification to the original source */ @@ -24,4 +26,5 @@ class None implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } + } diff --git a/src/Phalcon/Assets/Inline.php b/src/Phalcon/Assets/Inline.php index 8a76055b..862368ec 100644 --- a/src/Phalcon/Assets/Inline.php +++ b/src/Phalcon/Assets/Inline.php @@ -117,4 +117,5 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } + } diff --git a/src/Phalcon/Assets/Inline/Css.php b/src/Phalcon/Assets/Inline/Css.php index 2353cd4e..14f7b91d 100644 --- a/src/Phalcon/Assets/Inline/Css.php +++ b/src/Phalcon/Assets/Inline/Css.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Inline; +use Phalcon\Assets\Inline as InlineBase; + /** * Represents an inlined CSS */ @@ -25,4 +27,5 @@ class Css extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/Assets/Inline/Js.php b/src/Phalcon/Assets/Inline/Js.php index 1ec6fd4e..22409a46 100644 --- a/src/Phalcon/Assets/Inline/Js.php +++ b/src/Phalcon/Assets/Inline/Js.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Assets\Inline; +use Phalcon\Assets\Inline as InlineBase; + /** * Represents an inline JavaScript */ @@ -25,4 +27,5 @@ class Js extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } + } diff --git a/src/Phalcon/Assets/Manager.php b/src/Phalcon/Assets/Manager.php index 9386ec9a..c31a164e 100644 --- a/src/Phalcon/Assets/Manager.php +++ b/src/Phalcon/Assets/Manager.php @@ -9,6 +9,12 @@ */ namespace Phalcon\Assets; +use Phalcon\Tag; +use Phalcon\Assets\Asset\Js as AssetJs; +use Phalcon\Assets\Asset\Css as AssetCss; +use Phalcon\Assets\Inline\Css as InlineCss; +use Phalcon\Assets\Inline\Js as InlineJs; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; /** @@ -217,7 +223,7 @@ public function get(string $id): Collection /** * Returns existing collections in the manager * - * @return array + * @return array|Collection[] */ public function getCollections(): array { @@ -358,4 +364,5 @@ public function useImplicitOutput(bool $implicitOutput): Manager private function getPrefixedPath(Collection $collection, string $path): string { } + } diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index cf660ec4..aaf9ded6 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -10,8 +10,10 @@ namespace Phalcon; use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Exception\Exception; use Phalcon\Cache\Exception\InvalidArgumentException; use Psr\SimpleCache\CacheInterface; +use Traversable; /** * This component offers caching capabilities for your application. @@ -173,4 +175,5 @@ protected function checkKey($key) protected function checkKeys($keys) { } + } diff --git a/src/Phalcon/Cache/Adapter/Apcu.php b/src/Phalcon/Cache/Adapter/Apcu.php index 01481ad0..191e2ec9 100644 --- a/src/Phalcon/Cache/Adapter/Apcu.php +++ b/src/Phalcon/Cache/Adapter/Apcu.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Apcu as StorageApcu; /** * Apcu adapter diff --git a/src/Phalcon/Cache/Adapter/Libmemcached.php b/src/Phalcon/Cache/Adapter/Libmemcached.php index 43526134..a00deb4a 100644 --- a/src/Phalcon/Cache/Adapter/Libmemcached.php +++ b/src/Phalcon/Cache/Adapter/Libmemcached.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Libmemcached as StorageLibmemcached; /** * Libmemcached adapter diff --git a/src/Phalcon/Cache/Adapter/Memory.php b/src/Phalcon/Cache/Adapter/Memory.php index 4cbe2d5e..41619081 100644 --- a/src/Phalcon/Cache/Adapter/Memory.php +++ b/src/Phalcon/Cache/Adapter/Memory.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Memory as StorageMemory; /** * Memory adapter diff --git a/src/Phalcon/Cache/Adapter/Redis.php b/src/Phalcon/Cache/Adapter/Redis.php index c3c8ce7a..f9551cec 100644 --- a/src/Phalcon/Cache/Adapter/Redis.php +++ b/src/Phalcon/Cache/Adapter/Redis.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Redis as StorageRedis; /** * Redis adapter diff --git a/src/Phalcon/Cache/Adapter/Stream.php b/src/Phalcon/Cache/Adapter/Stream.php index 7002ae87..376e7a73 100644 --- a/src/Phalcon/Cache/Adapter/Stream.php +++ b/src/Phalcon/Cache/Adapter/Stream.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache\Adapter; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; +use Phalcon\Storage\Adapter\Stream as StorageStream; /** * Stream adapter diff --git a/src/Phalcon/Cache/AdapterFactory.php b/src/Phalcon/Cache/AdapterFactory.php index baee1b7e..158b44b5 100644 --- a/src/Phalcon/Cache/AdapterFactory.php +++ b/src/Phalcon/Cache/AdapterFactory.php @@ -10,6 +10,7 @@ namespace Phalcon\Cache; use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Exception\Exception; use Phalcon\Factory\AbstractFactory; use Phalcon\Storage\SerializerFactory; @@ -37,8 +38,27 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, /** * Create a new instance of the adapter * + * @param array $options = [ + * 'servers' => [ + * [ + * 'host' => 'localhost', + * 'port' => 11211, + * 'weight' => 1, + * ] + * ], + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => 'phalcon', + * 'storageDir' => '' + * ] * @param string $name - * @param array $options * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface @@ -53,4 +73,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Cache/CacheFactory.php b/src/Phalcon/Cache/CacheFactory.php index 794af9f5..9ce7d917 100644 --- a/src/Phalcon/Cache/CacheFactory.php +++ b/src/Phalcon/Cache/CacheFactory.php @@ -9,7 +9,12 @@ */ namespace Phalcon\Cache; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache; use Psr\SimpleCache\CacheInterface; +use Phalcon\Cache\Exception\Exception; +use Phalcon\Config; +use Phalcon\Helper\Arr; /** * Creates a new Cache class @@ -34,7 +39,30 @@ public function __construct(AdapterFactory $factory) /** * Factory to create an instace from a Config object * - * @param mixed $config + * @param array|\Phalcon\Config $config = [ + * 'adapter' => 'apcu', + * 'options' => [ + * 'servers' => [ + * [ + * 'host' => 'localhost', + * 'port' => 11211, + * 'weight' => 1, + * + * ] + * ], + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => 'phalcon', + * 'storageDir' => '' + * ] + * ] * @return mixed */ public function load($config) @@ -44,11 +72,32 @@ public function load($config) /** * Constructs a new Cache instance. * + * @param array $options = [ + * 'servers' => [ + * [ + * 'host' => 'localhost', + * 'port' => 11211, + * 'weight' => 1, + * + * ] + * ], + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => 'phalcon', + * 'storageDir' => '' + * ] * @param string $name - * @param array $options * @return CacheInterface */ public function newInstance(string $name, array $options = array()): CacheInterface { } + } diff --git a/src/Phalcon/Cli/Console.php b/src/Phalcon/Cli/Console.php index b0b15ca9..8f6b76b0 100644 --- a/src/Phalcon/Cli/Console.php +++ b/src/Phalcon/Cli/Console.php @@ -10,6 +10,10 @@ namespace Phalcon\Cli; use Phalcon\Application\AbstractApplication; +use Phalcon\Cli\Router\Route; +use Phalcon\Cli\Console\Exception; +use Phalcon\Di\DiInterface; +use Phalcon\Events\ManagerInterface; /** * This component allows to create CLI applications using Phalcon @@ -47,4 +51,5 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } + } diff --git a/src/Phalcon/Cli/Dispatcher.php b/src/Phalcon/Cli/Dispatcher.php index aa31c964..3fd0b8a6 100644 --- a/src/Phalcon/Cli/Dispatcher.php +++ b/src/Phalcon/Cli/Dispatcher.php @@ -9,6 +9,11 @@ */ namespace Phalcon\Cli; +use Phalcon\Cli\Dispatcher\Exception; +use Phalcon\Dispatcher\AbstractDispatcher as CliDispatcher; +use Phalcon\Events\ManagerInterface; +use Phalcon\Filter\FilterInterface; + /** * Dispatching is the process of taking the command-line arguments, extracting * the module name, task name, action name, and optional parameters contained in @@ -191,4 +196,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/Cli/DispatcherInterface.php b/src/Phalcon/Cli/DispatcherInterface.php index f4f6c0f5..dc877448 100644 --- a/src/Phalcon/Cli/DispatcherInterface.php +++ b/src/Phalcon/Cli/DispatcherInterface.php @@ -83,4 +83,5 @@ public function setTaskName(string $taskName); * @return void */ public function setTaskSuffix(string $taskSuffix); + } diff --git a/src/Phalcon/Cli/Router.php b/src/Phalcon/Cli/Router.php index 861414e1..942eb93f 100644 --- a/src/Phalcon/Cli/Router.php +++ b/src/Phalcon/Cli/Router.php @@ -9,8 +9,11 @@ */ namespace Phalcon\Cli; -use Phalcon\Cli\Router\RouteInterface; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Cli\Router\Route; +use Phalcon\Cli\Router\Exception; +use Phalcon\Cli\Router\RouteInterface; /** * Phalcon\Cli\Router is the standard framework router. Routing is the process @@ -167,7 +170,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array + * @return array|\Phalcon\Cli\Router\Route[] */ public function getRoutes(): array { @@ -248,4 +251,5 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } + } diff --git a/src/Phalcon/Cli/Router/Route.php b/src/Phalcon/Cli/Router/Route.php index eb98027e..4d5f3ee1 100644 --- a/src/Phalcon/Cli/Router/Route.php +++ b/src/Phalcon/Cli/Router/Route.php @@ -30,7 +30,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $delimiter; - protected static $delimiterPath = self::DEFAULT_DELIMITER; + static protected $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -48,7 +48,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; /** @@ -252,4 +252,5 @@ public function setDescription(string $description): RouteInterface public function setName(string $name): RouteInterface { } + } diff --git a/src/Phalcon/Cli/Router/RouteInterface.php b/src/Phalcon/Cli/Router/RouteInterface.php index de7f9f28..7730db7d 100644 --- a/src/Phalcon/Cli/Router/RouteInterface.php +++ b/src/Phalcon/Cli/Router/RouteInterface.php @@ -118,4 +118,5 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; + } diff --git a/src/Phalcon/Cli/RouterInterface.php b/src/Phalcon/Cli/RouterInterface.php index 7c6c9571..0b632e04 100644 --- a/src/Phalcon/Cli/RouterInterface.php +++ b/src/Phalcon/Cli/RouterInterface.php @@ -80,7 +80,7 @@ public function getRouteByName(string $name): RouteInterface; /** * Return all the routes defined in the router * - * @return array + * @return array|\Phalcon\Cli\Router\RouteInterface[] */ public function getRoutes(): array; @@ -136,4 +136,5 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/Cli/Task.php b/src/Phalcon/Cli/Task.php index 02010ee6..e3d414b5 100644 --- a/src/Phalcon/Cli/Task.php +++ b/src/Phalcon/Cli/Task.php @@ -10,6 +10,7 @@ namespace Phalcon\Cli; use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** @@ -67,4 +68,5 @@ public function getEventsManager(): ?ManagerInterface public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) { } + } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index 0c8dd5af..2028a89a 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -9,6 +9,13 @@ */ namespace Phalcon; +use ArrayAccess; +use ArrayIterator; +use Countable; +use IteratorAggregate; +use JsonSerializable; +use Phalcon\Helper\Json; +use Serializable; use Traversable; /** @@ -299,4 +306,5 @@ public function unserialize($serialized) protected function setData(string $element, $value) { } + } diff --git a/src/Phalcon/Collection/Exception.php b/src/Phalcon/Collection/Exception.php index 5b84c7ed..badabd18 100644 --- a/src/Phalcon/Collection/Exception.php +++ b/src/Phalcon/Collection/Exception.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Collection; +use Throwable; + /** * Exceptions for the Collection object */ diff --git a/src/Phalcon/Collection/ReadOnly.php b/src/Phalcon/Collection/ReadOnly.php index 28ca4011..cc06d071 100644 --- a/src/Phalcon/Collection/ReadOnly.php +++ b/src/Phalcon/Collection/ReadOnly.php @@ -37,4 +37,5 @@ public function remove(string $element) public function set(string $element, $value) { } + } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index 6339dff4..6954aa7a 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -9,6 +9,9 @@ */ namespace Phalcon; +use Phalcon\Collection; +use Phalcon\Config\Exception; + /** * `Phalcon\Config` is designed to simplify the access to, and the use of, * configuration data within applications. It provides a nested object property @@ -137,4 +140,5 @@ final protected function internalMerge(array $source, array $target): array protected function setData($element, $value) { } + } diff --git a/src/Phalcon/Config/Adapter/Grouped.php b/src/Phalcon/Config/Adapter/Grouped.php index 23fb326f..9f4fa60f 100644 --- a/src/Phalcon/Config/Adapter/Grouped.php +++ b/src/Phalcon/Config/Adapter/Grouped.php @@ -10,6 +10,9 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; +use Phalcon\Factory\Exception as FactoryException; +use Phalcon\Config\ConfigFactory; /** * Reads multiple files (or arrays) and merges them all together. @@ -74,4 +77,5 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } + } diff --git a/src/Phalcon/Config/Adapter/Ini.php b/src/Phalcon/Config/Adapter/Ini.php index 2d94f022..bc63a72a 100644 --- a/src/Phalcon/Config/Adapter/Ini.php +++ b/src/Phalcon/Config/Adapter/Ini.php @@ -10,6 +10,7 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; /** * Reads ini files and converts them to Phalcon\Config objects. @@ -87,4 +88,5 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } + } diff --git a/src/Phalcon/Config/Adapter/Json.php b/src/Phalcon/Config/Adapter/Json.php index 4c4b1e3f..39a242a2 100644 --- a/src/Phalcon/Config/Adapter/Json.php +++ b/src/Phalcon/Config/Adapter/Json.php @@ -10,6 +10,7 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Helper\Json; /** * Reads JSON files and converts them to Phalcon\Config objects. @@ -42,4 +43,5 @@ class Json extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/Config/Adapter/Php.php b/src/Phalcon/Config/Adapter/Php.php index 30ee68a9..f94da213 100644 --- a/src/Phalcon/Config/Adapter/Php.php +++ b/src/Phalcon/Config/Adapter/Php.php @@ -57,4 +57,5 @@ class Php extends Config public function __construct(string $filePath) { } + } diff --git a/src/Phalcon/Config/Adapter/Yaml.php b/src/Phalcon/Config/Adapter/Yaml.php index b4713fba..494fe97c 100644 --- a/src/Phalcon/Config/Adapter/Yaml.php +++ b/src/Phalcon/Config/Adapter/Yaml.php @@ -10,6 +10,7 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; +use Phalcon\Config\Exception; /** * Reads YAML files and converts them to Phalcon\Config objects. @@ -60,4 +61,5 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } + } diff --git a/src/Phalcon/Config/ConfigFactory.php b/src/Phalcon/Config/ConfigFactory.php index be130d32..7ec304f3 100644 --- a/src/Phalcon/Config/ConfigFactory.php +++ b/src/Phalcon/Config/ConfigFactory.php @@ -9,7 +9,15 @@ */ namespace Phalcon\Config; +use Phalcon\Config; +use Phalcon\Config\Adapter\Grouped; +use Phalcon\Config\Adapter\Ini; +use Phalcon\Config\Adapter\Json; +use Phalcon\Config\Adapter\Php; +use Phalcon\Config\Adapter\Yaml; use Phalcon\Factory\AbstractFactory; +use Phalcon\Factory\Exception as FactoryException; +use Phalcon\Helper\Arr; /** * Loads Config Adapter class using 'adapter' option, if no extension is @@ -41,7 +49,12 @@ public function __construct(array $services = array()) /** * Load a config to create a new instance * - * @param mixed $config + * @param string|array|\Phalcon\Config $config = [ + * 'adapter' => 'ini', + * 'filePath' => 'config.ini', + * 'mode' => null, + * 'callbacks' => null + * ] * @return object */ public function load($config) @@ -68,4 +81,5 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index fe533a3c..74f55334 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -9,6 +9,7 @@ */ namespace Phalcon; +use Psr\Container\ContainerInterface; use Phalcon\Di\DiInterface; /** @@ -50,4 +51,5 @@ public function get($name) public function has($name): bool { } + } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index add83cf9..8cbf6869 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -10,6 +10,8 @@ namespace Phalcon; use Phalcon\Crypt\CryptInterface; +use Phalcon\Crypt\Exception; +use Phalcon\Crypt\Mismatch; /** * Provides encryption capabilities to Phalcon applications. @@ -407,4 +409,5 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } + } diff --git a/src/Phalcon/Crypt/CryptInterface.php b/src/Phalcon/Crypt/CryptInterface.php index d33f3ddc..5f30daa2 100644 --- a/src/Phalcon/Crypt/CryptInterface.php +++ b/src/Phalcon/Crypt/CryptInterface.php @@ -140,4 +140,5 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; + } diff --git a/src/Phalcon/Db/AbstractDb.php b/src/Phalcon/Db/AbstractDb.php index 7ee0ca46..e85944e8 100644 --- a/src/Phalcon/Db/AbstractDb.php +++ b/src/Phalcon/Db/AbstractDb.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Db; +use \PDO as Pdo; + /** * Phalcon\Db and its related classes provide a simple SQL database interface * for Phalcon Framework. The Phalcon\Db is the basic class you use to connect @@ -64,4 +66,5 @@ abstract class AbstractDb public static function setup(array $options) { } + } diff --git a/src/Phalcon/Db/Adapter/AbstractAdapter.php b/src/Phalcon/Db/Adapter/AbstractAdapter.php index d09a00f4..a6dde037 100644 --- a/src/Phalcon/Db/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Db/Adapter/AbstractAdapter.php @@ -10,8 +10,15 @@ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; +use Phalcon\Db\ColumnInterface; use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; use Phalcon\Db\RawValue; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; /** @@ -22,7 +29,7 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, /** * Connection ID */ - protected static $connectionConsecutive = 0; + static protected $connectionConsecutive = 0; /** * Active connection ID @@ -124,7 +131,17 @@ public function getType(): string /** * Phalcon\Db\Adapter constructor * - * @param array $descriptor + * @param array $descriptor = [ + * 'host' => 'localhost', + * 'port' => '3306', + * 'dbname' => 'blog', + * 'username' => 'sigma' + * 'password' => 'secret', + * 'dialectClass' => null, + * 'options' => [], + * 'dsn' => null, + * 'charset' => 'utf8mb4' + * ] */ public function __construct(array $descriptor) { @@ -247,7 +264,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -264,7 +281,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -927,4 +944,5 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } + } diff --git a/src/Phalcon/Db/Adapter/AdapterInterface.php b/src/Phalcon/Db/Adapter/AdapterInterface.php index 2e2e691f..4a3018d6 100644 --- a/src/Phalcon/Db/Adapter/AdapterInterface.php +++ b/src/Phalcon/Db/Adapter/AdapterInterface.php @@ -10,7 +10,11 @@ namespace Phalcon\Db\Adapter; use Phalcon\Db\DialectInterface; +use Phalcon\Db\ResultInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; +use Phalcon\Db\ReferenceInterface; /** * Interface for Phalcon\Db adapters @@ -143,7 +147,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array; @@ -152,7 +156,7 @@ public function describeColumns(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array; @@ -161,7 +165,7 @@ public function describeIndexes(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array; @@ -628,4 +632,5 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; + } diff --git a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php index 87b45d63..7b43793d 100644 --- a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php @@ -10,6 +10,11 @@ namespace Phalcon\Db\Adapter\Pdo; use Phalcon\Db\Adapter\AbstractAdapter; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\Result\Pdo as ResultPdo; +use Phalcon\Db\ResultInterface; +use Phalcon\Events\ManagerInterface; /** * Phalcon\Db\Adapter\Pdo is the Phalcon\Db that internally uses PDO to connect @@ -47,7 +52,17 @@ abstract class AbstractPdo extends AbstractAdapter /** * Constructor for Phalcon\Db\Adapter\Pdo * - * @param array $descriptor + * @param array|\Phalcon\Config $descriptor = [ + * 'host' => 'localhost', + * 'port' => '3306', + * 'dbname' => 'blog', + * 'username' => 'sigma' + * 'password' => 'secret' + * 'dialectClass' => null, + * 'options' => [], + * 'dsn' => null, + * 'charset' => 'utf8mb4' + * ] */ public function __construct(array $descriptor) { @@ -373,4 +388,5 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; + } diff --git a/src/Phalcon/Db/Adapter/Pdo/Mysql.php b/src/Phalcon/Db/Adapter/Pdo/Mysql.php index c72a284f..3f6e2df8 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Mysql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Mysql.php @@ -9,6 +9,16 @@ */ namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; + /** * Specific functions for the Mysql database system * @@ -62,7 +72,7 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -79,7 +89,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -96,7 +106,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -110,4 +120,5 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php index 5235f722..5721393a 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php @@ -9,7 +9,15 @@ */ namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; use Phalcon\Db\RawValue; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; +use Throwable; /** * Specific functions for the Postgresql database system @@ -84,7 +92,7 @@ public function createTable(string $tableName, string $schemaName, array $defini * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -101,7 +109,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -174,4 +182,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php index ebec76be..897f7b6f 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php +++ b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php @@ -9,7 +9,16 @@ */ namespace Phalcon\Db\Adapter\Pdo; +use Phalcon\Db\Adapter\Pdo\AbstractPdo as PdoAdapter; +use Phalcon\Db\Column; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\Exception; +use Phalcon\Db\Index; +use Phalcon\Db\IndexInterface; use Phalcon\Db\RawValue; +use Phalcon\Db\Reference; +use Phalcon\Db\ReferenceInterface; /** * Specific functions for the Sqlite database system @@ -68,7 +77,7 @@ public function connect(array $descriptor = null): bool * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -85,7 +94,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -96,7 +105,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array + * @return array|\Phalcon\Db\ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -145,4 +154,5 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } + } diff --git a/src/Phalcon/Db/Adapter/PdoFactory.php b/src/Phalcon/Db/Adapter/PdoFactory.php index b243a7d7..18e59fa8 100644 --- a/src/Phalcon/Db/Adapter/PdoFactory.php +++ b/src/Phalcon/Db/Adapter/PdoFactory.php @@ -10,6 +10,7 @@ namespace Phalcon\Db\Adapter; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. @@ -34,7 +35,20 @@ public function __construct(array $services = array()) /** * Factory to create an instace from a Config object * - * @param mixed $config + * @param array|\Phalcon\Config $config = [ + * 'adapter' => 'mysql', + * 'options' => [ + * 'host' => 'localhost', + * 'port' => '3306', + * 'dbname' => 'blog', + * 'username' => 'sigma' + * 'password' => 'secret', + * 'dialectClass' => null, + * 'options' => [], + * 'dsn' => null, + * 'charset' => 'utf8mb4' + * ] + * ] * @return AdapterInterface */ public function load($config): AdapterInterface @@ -60,4 +74,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Db/Column.php b/src/Phalcon/Db/Column.php index bfadbc3e..d646e799 100644 --- a/src/Phalcon/Db/Column.php +++ b/src/Phalcon/Db/Column.php @@ -453,4 +453,5 @@ public function isPrimary(): bool public function isUnsigned(): bool { } + } diff --git a/src/Phalcon/Db/ColumnInterface.php b/src/Phalcon/Db/ColumnInterface.php index 4860a22b..4dde08e8 100644 --- a/src/Phalcon/Db/ColumnInterface.php +++ b/src/Phalcon/Db/ColumnInterface.php @@ -126,4 +126,5 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; + } diff --git a/src/Phalcon/Db/Dialect.php b/src/Phalcon/Db/Dialect.php index 63bd2a63..e1b85297 100644 --- a/src/Phalcon/Db/Dialect.php +++ b/src/Phalcon/Db/Dialect.php @@ -509,4 +509,5 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } + } diff --git a/src/Phalcon/Db/Dialect/Mysql.php b/src/Phalcon/Db/Dialect/Mysql.php index eeef5199..c80be775 100644 --- a/src/Phalcon/Db/Dialect/Mysql.php +++ b/src/Phalcon/Db/Dialect/Mysql.php @@ -10,6 +10,12 @@ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; +use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the MySQL RDBMS @@ -358,4 +364,5 @@ private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): s private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string { } + } diff --git a/src/Phalcon/Db/Dialect/Postgresql.php b/src/Phalcon/Db/Dialect/Postgresql.php index 4e57d5f8..7d680ec5 100644 --- a/src/Phalcon/Db/Dialect/Postgresql.php +++ b/src/Phalcon/Db/Dialect/Postgresql.php @@ -10,6 +10,12 @@ namespace Phalcon\Db\Dialect; use Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; +use Phalcon\Db\DialectInterface; /** * Generates database specific SQL for the PostgreSQL RDBMS @@ -329,4 +335,5 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } + } diff --git a/src/Phalcon/Db/Dialect/Sqlite.php b/src/Phalcon/Db/Dialect/Sqlite.php index 3b2a56cc..17f84685 100644 --- a/src/Phalcon/Db/Dialect/Sqlite.php +++ b/src/Phalcon/Db/Dialect/Sqlite.php @@ -9,7 +9,13 @@ */ namespace Phalcon\Db\Dialect; +use Phalcon\Db\Column; +use Phalcon\Db\Exception; +use Phalcon\Db\IndexInterface; use Phalcon\Db\Dialect; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\ColumnInterface; +use Phalcon\Db\ReferenceInterface; /** * Generates database specific SQL for the SQLite RDBMS @@ -352,4 +358,5 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } + } diff --git a/src/Phalcon/Db/DialectInterface.php b/src/Phalcon/Db/DialectInterface.php index fa6b3057..208f30ee 100644 --- a/src/Phalcon/Db/DialectInterface.php +++ b/src/Phalcon/Db/DialectInterface.php @@ -319,4 +319,5 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; + } diff --git a/src/Phalcon/Db/Enum.php b/src/Phalcon/Db/Enum.php index cff4d17c..d826fa71 100644 --- a/src/Phalcon/Db/Enum.php +++ b/src/Phalcon/Db/Enum.php @@ -64,4 +64,6 @@ class Enum const FETCH_UNIQUE = 196608; + + } diff --git a/src/Phalcon/Db/Index.php b/src/Phalcon/Db/Index.php index 1832a2f8..586c8433 100644 --- a/src/Phalcon/Db/Index.php +++ b/src/Phalcon/Db/Index.php @@ -99,4 +99,5 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } + } diff --git a/src/Phalcon/Db/IndexInterface.php b/src/Phalcon/Db/IndexInterface.php index d981c426..f1a7074c 100644 --- a/src/Phalcon/Db/IndexInterface.php +++ b/src/Phalcon/Db/IndexInterface.php @@ -35,4 +35,5 @@ public function getName(): string; * @return string */ public function getType(): string; + } diff --git a/src/Phalcon/Db/Profiler.php b/src/Phalcon/Db/Profiler.php index 96fe89e0..177cbc01 100644 --- a/src/Phalcon/Db/Profiler.php +++ b/src/Phalcon/Db/Profiler.php @@ -115,7 +115,7 @@ public function getTotalElapsedSeconds(): float /** * Returns all the processed profiles * - * @return array + * @return array|\Phalcon\Db\Profiler\Item[] */ public function getProfiles(): array { @@ -150,4 +150,5 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } + } diff --git a/src/Phalcon/Db/Profiler/Item.php b/src/Phalcon/Db/Profiler/Item.php index 71b5487b..24610248 100644 --- a/src/Phalcon/Db/Profiler/Item.php +++ b/src/Phalcon/Db/Profiler/Item.php @@ -148,4 +148,5 @@ public function getSqlVariables(): array public function getTotalElapsedSeconds(): float { } + } diff --git a/src/Phalcon/Db/RawValue.php b/src/Phalcon/Db/RawValue.php index 1ecfc9b1..27a98c78 100644 --- a/src/Phalcon/Db/RawValue.php +++ b/src/Phalcon/Db/RawValue.php @@ -59,4 +59,5 @@ public function __toString(): string public function __construct($value) { } + } diff --git a/src/Phalcon/Db/Reference.php b/src/Phalcon/Db/Reference.php index 04964948..5763cd2a 100644 --- a/src/Phalcon/Db/Reference.php +++ b/src/Phalcon/Db/Reference.php @@ -170,4 +170,5 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } + } diff --git a/src/Phalcon/Db/ReferenceInterface.php b/src/Phalcon/Db/ReferenceInterface.php index c28ff533..9e2a3bf1 100644 --- a/src/Phalcon/Db/ReferenceInterface.php +++ b/src/Phalcon/Db/ReferenceInterface.php @@ -70,4 +70,5 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; + } diff --git a/src/Phalcon/Db/Result/Pdo.php b/src/Phalcon/Db/Result/Pdo.php index ab2ffa8f..d06e7c99 100644 --- a/src/Phalcon/Db/Result/Pdo.php +++ b/src/Phalcon/Db/Result/Pdo.php @@ -10,6 +10,8 @@ namespace Phalcon\Db\Result; use Phalcon\Db\Enum; +use Phalcon\Db\ResultInterface; +use Phalcon\Db\Adapter\AdapterInterface; /** * Encapsulates the resultset internals @@ -233,4 +235,5 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } + } diff --git a/src/Phalcon/Db/ResultInterface.php b/src/Phalcon/Db/ResultInterface.php index 5f7abd5c..93923545 100644 --- a/src/Phalcon/Db/ResultInterface.php +++ b/src/Phalcon/Db/ResultInterface.php @@ -80,4 +80,5 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; + } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 8911041f..8ec1b483 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -9,6 +9,13 @@ */ namespace Phalcon; +use ErrorException; +use Phalcon\Helper\Arr; +use Phalcon\Version; +use Phalcon\Tag; +use ReflectionClass; +use ReflectionFunction; + /** * Provides debug capabilities to Phalcon applications */ @@ -30,7 +37,7 @@ class Debug /** * @var bool */ - protected static $isActive; + static protected $isActive; /** * @var bool @@ -254,4 +261,5 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } + } diff --git a/src/Phalcon/Debug/Dump.php b/src/Phalcon/Debug/Dump.php index aad14563..7a4f9cef 100644 --- a/src/Phalcon/Debug/Dump.php +++ b/src/Phalcon/Debug/Dump.php @@ -9,6 +9,13 @@ */ namespace Phalcon\Debug; +use Phalcon\Di; +use Phalcon\Helper\Json; +use Reflection; +use ReflectionClass; +use ReflectionProperty; +use stdClass; + /** * Dumps information about a variable(s) * @@ -175,4 +182,5 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } + } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index d5194233..e8b8907a 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -9,9 +9,16 @@ */ namespace Phalcon; +use Phalcon\Di\Service; use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception; +use Phalcon\Di\Exception\ServiceResolutionException; +use Phalcon\Config\Adapter\Php; +use Phalcon\Config\Adapter\Yaml; use Phalcon\Di\ServiceInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Di\ServiceProviderInterface; /** * Phalcon\Di is a component that implements Dependency Injection/Service @@ -73,7 +80,7 @@ class Di implements \Phalcon\Di\DiInterface /** * Latest DI build */ - protected static $_default; + static protected $_default; /** @@ -160,7 +167,7 @@ public function getService(string $name): ServiceInterface /** * Return the services registered in the DI * - * @return array + * @return array|\Phalcon\Di\ServiceInterface[] */ public function getServices(): array { @@ -412,7 +419,7 @@ public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $event * @param \Phalcon\Di\ServiceInterface $rawDefinition * @return ServiceInterface */ - public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface + public function setService(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface { } @@ -426,4 +433,5 @@ public function setRaw(string $name, \Phalcon\Di\ServiceInterface $rawDefinition public function setShared(string $name, $definition): ServiceInterface { } + } diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Phalcon/Di/AbstractInjectionAware.php index d9f43b71..1938a255 100644 --- a/src/Phalcon/Di/AbstractInjectionAware.php +++ b/src/Phalcon/Di/AbstractInjectionAware.php @@ -40,4 +40,5 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } + } diff --git a/src/Phalcon/Di/DiInterface.php b/src/Phalcon/Di/DiInterface.php index 0afcd9a9..58f711b4 100644 --- a/src/Phalcon/Di/DiInterface.php +++ b/src/Phalcon/Di/DiInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Di; +use ArrayAccess; + /** * Interface for Phalcon\Di */ @@ -62,7 +64,7 @@ public function getService(string $name): ServiceInterface; /** * Return the services registered in the DI * - * @return array + * @return array|ServiceInterface[] */ public function getServices(): array; @@ -124,7 +126,7 @@ public static function setDefault(DiInterface $container); * @param ServiceInterface $rawDefinition * @return ServiceInterface */ - public function setRaw(string $name, ServiceInterface $rawDefinition): ServiceInterface; + public function setService(string $name, ServiceInterface $rawDefinition): ServiceInterface; /** * Registers an "always shared" service in the services container @@ -134,4 +136,5 @@ public function setRaw(string $name, ServiceInterface $rawDefinition): ServiceIn * @return ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; + } diff --git a/src/Phalcon/Di/FactoryDefault.php b/src/Phalcon/Di/FactoryDefault.php index 6d8546f6..501926d9 100644 --- a/src/Phalcon/Di/FactoryDefault.php +++ b/src/Phalcon/Di/FactoryDefault.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Di; +use Phalcon\Filter\FilterFactory; + /** * This is a variant of the standard Phalcon\Di. By default it automatically * registers all the services provided by the framework. Thanks to this, the @@ -24,4 +26,5 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } + } diff --git a/src/Phalcon/Di/FactoryDefault/Cli.php b/src/Phalcon/Di/FactoryDefault/Cli.php index d2d3c9be..24d167c9 100644 --- a/src/Phalcon/Di/FactoryDefault/Cli.php +++ b/src/Phalcon/Di/FactoryDefault/Cli.php @@ -10,6 +10,8 @@ namespace Phalcon\Di\FactoryDefault; use Phalcon\Di\FactoryDefault; +use Phalcon\Di\Service; +use Phalcon\Filter\FilterFactory; /** * Phalcon\Di\FactoryDefault\Cli @@ -28,4 +30,5 @@ class Cli extends FactoryDefault public function __construct() { } + } diff --git a/src/Phalcon/Di/Injectable.php b/src/Phalcon/Di/Injectable.php index 6fab0c01..2ee6dfbb 100644 --- a/src/Phalcon/Di/Injectable.php +++ b/src/Phalcon/Di/Injectable.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Di; +use Phalcon\Di; use Phalcon\Session\BagInterface; /** @@ -88,4 +89,5 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } + } diff --git a/src/Phalcon/Di/InjectionAwareInterface.php b/src/Phalcon/Di/InjectionAwareInterface.php index 97b68a27..72cd4198 100644 --- a/src/Phalcon/Di/InjectionAwareInterface.php +++ b/src/Phalcon/Di/InjectionAwareInterface.php @@ -30,4 +30,5 @@ public function setDI(DiInterface $container); * @return DiInterface */ public function getDI(): DiInterface; + } diff --git a/src/Phalcon/Di/Service.php b/src/Phalcon/Di/Service.php index f3db7b4a..ddba7f20 100644 --- a/src/Phalcon/Di/Service.php +++ b/src/Phalcon/Di/Service.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Di; +use Closure; +use Phalcon\Di\Exception\ServiceResolutionException; +use Phalcon\Di\Service\Builder; + /** * Represents individually a service in the services container * @@ -138,4 +142,5 @@ public function setShared(bool $shared) public function setSharedInstance($sharedInstance) { } + } diff --git a/src/Phalcon/Di/Service/Builder.php b/src/Phalcon/Di/Service/Builder.php index b8a5a1f3..a3079d45 100644 --- a/src/Phalcon/Di/Service/Builder.php +++ b/src/Phalcon/Di/Service/Builder.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Di\Service; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Exception; + /** * Phalcon\Di\Service\Builder * @@ -51,4 +54,5 @@ private function buildParameter(\Phalcon\Di\DiInterface $container, int $positio private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array { } + } diff --git a/src/Phalcon/Di/ServiceInterface.php b/src/Phalcon/Di/ServiceInterface.php index 52c09130..31af1fe3 100644 --- a/src/Phalcon/Di/ServiceInterface.php +++ b/src/Phalcon/Di/ServiceInterface.php @@ -75,4 +75,5 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); + } diff --git a/src/Phalcon/Di/ServiceProviderInterface.php b/src/Phalcon/Di/ServiceProviderInterface.php index 497bac34..bde1316f 100644 --- a/src/Phalcon/Di/ServiceProviderInterface.php +++ b/src/Phalcon/Di/ServiceProviderInterface.php @@ -43,4 +43,5 @@ interface ServiceProviderInterface * @return void */ public function register(DiInterface $di); + } diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php index 7b307449..f38bc389 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -9,8 +9,14 @@ */ namespace Phalcon\Dispatcher; +use Exception; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Dispatcher\Exception as PhalconException; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Filter\FilterInterface; +use Phalcon\Mvc\Model\Binder; use Phalcon\Mvc\Model\BinderInterface; /** @@ -484,4 +490,5 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } + } diff --git a/src/Phalcon/Dispatcher/DispatcherInterface.php b/src/Phalcon/Dispatcher/DispatcherInterface.php index 8b7244f9..952c39e1 100644 --- a/src/Phalcon/Dispatcher/DispatcherInterface.php +++ b/src/Phalcon/Dispatcher/DispatcherInterface.php @@ -162,4 +162,5 @@ public function setParam($param, $value); * @return void */ public function setParams(array $params); + } diff --git a/src/Phalcon/Dispatcher/Exception.php b/src/Phalcon/Dispatcher/Exception.php index 940db816..fb0da6ee 100644 --- a/src/Phalcon/Dispatcher/Exception.php +++ b/src/Phalcon/Dispatcher/Exception.php @@ -31,4 +31,6 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; + + } diff --git a/src/Phalcon/Domain/Payload/Payload.php b/src/Phalcon/Domain/Payload/Payload.php index 1046c7ac..134b79c7 100644 --- a/src/Phalcon/Domain/Payload/Payload.php +++ b/src/Phalcon/Domain/Payload/Payload.php @@ -9,11 +9,20 @@ */ namespace Phalcon\Domain\Payload; +use Throwable; + /** * Holds the payload */ class Payload implements \Phalcon\Domain\Payload\PayloadInterface { + /** + * Exception if any + * + * @var Throwable|null + */ + protected $exception = null; + /** * Extra information * @@ -95,6 +104,26 @@ public function getOutput() { } + /** + * Gets the potential exception thrown in the domain layer + * + * @return Throwable|null + */ + public function getException(): ?Throwable + { + } + + /** + * Sets an exception thrown in the domain + * + * @param Throwable $exception + * + * @return PayloadInterface + */ + public function setException(\Throwable $exception): PayloadInterface + { + } + /** * Sets arbitrary extra domain information. * @@ -144,4 +173,5 @@ public function setOutput($output): PayloadInterface public function setStatus($status): PayloadInterface { } + } diff --git a/src/Phalcon/Domain/Payload/PayloadFactory.php b/src/Phalcon/Domain/Payload/PayloadFactory.php index adc02bfd..518657a0 100644 --- a/src/Phalcon/Domain/Payload/PayloadFactory.php +++ b/src/Phalcon/Domain/Payload/PayloadFactory.php @@ -23,4 +23,5 @@ class PayloadFactory public function newInstance(): PayloadInterface { } + } diff --git a/src/Phalcon/Domain/Payload/ReadableInterface.php b/src/Phalcon/Domain/Payload/ReadableInterface.php index c482a277..d787b7bc 100644 --- a/src/Phalcon/Domain/Payload/ReadableInterface.php +++ b/src/Phalcon/Domain/Payload/ReadableInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Domain\Payload; +use Throwable; + /** * This interface is used for consumers (read only) */ @@ -16,11 +18,18 @@ interface ReadableInterface { /** - * Gets the status of this payload. + * Gets the potential exception thrown in the domain layer + * + * @return Throwable|null + */ + public function getException(): ?Throwable; + + /** + * Gets arbitrary extra values produced by the domain layer. * * @return mixed */ - public function getStatus(); + public function getExtras(); /** * Gets the input received by the domain layer. @@ -30,23 +39,24 @@ public function getStatus(); public function getInput(); /** - * Gets the output produced from the domain layer. + * Gets the messages produced by the domain layer. * * @return mixed */ - public function getOutput(); + public function getMessages(); /** - * Gets the messages produced by the domain layer. + * Gets the output produced from the domain layer. * * @return mixed */ - public function getMessages(); + public function getOutput(); /** - * Gets arbitrary extra values produced by the domain layer. + * Gets the status of this payload. * * @return mixed */ - public function getExtras(); + public function getStatus(); + } diff --git a/src/Phalcon/Domain/Payload/Status.php b/src/Phalcon/Domain/Payload/Status.php index 292e2da0..03f52886 100644 --- a/src/Phalcon/Domain/Payload/Status.php +++ b/src/Phalcon/Domain/Payload/Status.php @@ -81,4 +81,5 @@ class Status final private function __construct() { } + } diff --git a/src/Phalcon/Domain/Payload/WriteableInterface.php b/src/Phalcon/Domain/Payload/WriteableInterface.php index bd44b3e0..a0509926 100644 --- a/src/Phalcon/Domain/Payload/WriteableInterface.php +++ b/src/Phalcon/Domain/Payload/WriteableInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Domain\Payload; +use Throwable; + /** * This interface is used for consumers (write) */ @@ -16,15 +18,24 @@ interface WriteableInterface { /** - * Sets the status of this payload. + * Sets an exception produced by the domain layer. + * + * @param Throwable $exception The exception thrown in the domain layer * - * @param mixed $status The status for this payload. * @return PayloadInterface */ - public function setStatus($status): PayloadInterface; + public function setException(\Throwable $exception): PayloadInterface; /** + * Sets arbitrary extra values produced by the domain layer. + * + * @param mixed $extras Arbitrary extra values produced by the domain layer. * + * @return PayloadInterface + */ + public function setExtras($extras): PayloadInterface; + + /** * Sets the input received by the domain layer. * * @param mixed $input The input received by the domain layer. @@ -34,26 +45,30 @@ public function setStatus($status): PayloadInterface; public function setInput($input): PayloadInterface; /** - * Sets the output produced from the domain layer. + * Sets the messages produced by the domain layer. + * + * @param mixed $messages The messages produced by the domain layer. * - * @param mixed $output The output produced from the domain layer. * @return PayloadInterface */ - public function setOutput($output): PayloadInterface; + public function setMessages($messages): PayloadInterface; /** - * Sets the messages produced by the domain layer. + * Sets the output produced from the domain layer. + * + * @param mixed $output The output produced from the domain layer. * - * @param mixed $messages The messages produced by the domain layer. * @return PayloadInterface */ - public function setMessages($messages): PayloadInterface; + public function setOutput($output): PayloadInterface; /** - * Sets arbitrary extra values produced by the domain layer. + * Sets the status of this payload. + * + * @param mixed $status The status for this payload. * - * @param mixed $extras Arbitrary extra values produced by the domain layer. * @return PayloadInterface */ - public function setExtras($extras): PayloadInterface; + public function setStatus($status): PayloadInterface; + } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index 01954765..32c4f24b 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -9,6 +9,10 @@ */ namespace Phalcon; +use Phalcon\Di\DiInterface; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Escaper\Exception; + /** * Phalcon\Escaper * @@ -85,7 +89,7 @@ public function escapeJs(string $js): string * @param string $text * @return string */ - public function escapeHtml(string $text): string + public function escapeHtml(string $text = null): string { } @@ -95,7 +99,7 @@ public function escapeHtml(string $text): string * @param string $attribute * @return string */ - public function escapeHtmlAttr(string $attribute): string + public function escapeHtmlAttr(string $attribute = null): string { } @@ -169,4 +173,5 @@ public function setEncoding(string $encoding) public function setHtmlQuoteType(int $quoteType) { } + } diff --git a/src/Phalcon/Escaper/EscaperInterface.php b/src/Phalcon/Escaper/EscaperInterface.php index 09e2ba21..d067a4d3 100644 --- a/src/Phalcon/Escaper/EscaperInterface.php +++ b/src/Phalcon/Escaper/EscaperInterface.php @@ -79,4 +79,5 @@ public function setEncoding(string $encoding); * @return void */ public function setHtmlQuoteType(int $quoteType); + } diff --git a/src/Phalcon/Events/Event.php b/src/Phalcon/Events/Event.php index a2c97950..a59342ca 100644 --- a/src/Phalcon/Events/Event.php +++ b/src/Phalcon/Events/Event.php @@ -159,4 +159,5 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } + } diff --git a/src/Phalcon/Events/EventInterface.php b/src/Phalcon/Events/EventInterface.php index 51e4b8e8..02ed6dd1 100644 --- a/src/Phalcon/Events/EventInterface.php +++ b/src/Phalcon/Events/EventInterface.php @@ -67,4 +67,5 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; + } diff --git a/src/Phalcon/Events/EventsAwareInterface.php b/src/Phalcon/Events/EventsAwareInterface.php index f35d4f45..aa0509f4 100644 --- a/src/Phalcon/Events/EventsAwareInterface.php +++ b/src/Phalcon/Events/EventsAwareInterface.php @@ -32,4 +32,5 @@ public function getEventsManager(): ?ManagerInterface; * @return void */ public function setEventsManager(ManagerInterface $eventsManager); + } diff --git a/src/Phalcon/Events/Manager.php b/src/Phalcon/Events/Manager.php index 90fc951f..105c486c 100644 --- a/src/Phalcon/Events/Manager.php +++ b/src/Phalcon/Events/Manager.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Events; +use Closure; +use SplPriorityQueue; + /** * Phalcon\Events\Manager * @@ -170,4 +173,5 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } + } diff --git a/src/Phalcon/Events/ManagerInterface.php b/src/Phalcon/Events/ManagerInterface.php index 6e491e8a..c4e5eba0 100644 --- a/src/Phalcon/Events/ManagerInterface.php +++ b/src/Phalcon/Events/ManagerInterface.php @@ -10,12 +10,9 @@ namespace Phalcon\Events; /** - * Phalcon\Events\Manager + * Phalcon\Events\ManagerInterface * - * Phalcon Events Manager, offers an easy way to intercept and manipulate, if - * needed, the normal flow of operation. With the EventsManager the developer - * can create hooks or plugins that will offer monitoring of data, manipulation, - * conditional execution and much more. + * Interface for Phalcon\Events managers. */ interface ManagerInterface { @@ -73,4 +70,5 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; + } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 09a741b3..129c46bf 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -24,4 +24,5 @@ class Exception extends \Exception implements \Throwable public static function containerServiceNotFound(string $service): string { } + } diff --git a/src/Phalcon/Factory/AbstractFactory.php b/src/Phalcon/Factory/AbstractFactory.php index d4feaa9b..2cb9a1fd 100644 --- a/src/Phalcon/Factory/AbstractFactory.php +++ b/src/Phalcon/Factory/AbstractFactory.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Factory; +use Phalcon\Config; + /** * This file is part of the Phalcon Framework. * @@ -66,4 +68,5 @@ abstract protected function getAdapters(): array; protected function init(array $services = array()) { } + } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index cf5fcae8..5611d4f4 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -9,6 +9,10 @@ */ namespace Phalcon; +use Closure; +use Phalcon\Filter\Exception; +use Phalcon\Filter\FilterInterface; + /** * Lazy loads, stores and exposes sanitizer objects */ @@ -175,4 +179,5 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } + } diff --git a/src/Phalcon/Filter/FilterFactory.php b/src/Phalcon/Filter/FilterFactory.php index 649ba460..a99627ae 100644 --- a/src/Phalcon/Filter/FilterFactory.php +++ b/src/Phalcon/Filter/FilterFactory.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Filter; +use Phalcon\Filter; + /** * This file is part of the Phalcon Framework. * @@ -36,4 +38,5 @@ public function newInstance(): FilterInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Filter/FilterInterface.php b/src/Phalcon/Filter/FilterInterface.php index f7922641..a455a176 100644 --- a/src/Phalcon/Filter/FilterInterface.php +++ b/src/Phalcon/Filter/FilterInterface.php @@ -24,4 +24,5 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); + } diff --git a/src/Phalcon/Filter/Sanitize/AbsInt.php b/src/Phalcon/Filter/Sanitize/AbsInt.php index 3aabb4f2..5b155476 100644 --- a/src/Phalcon/Filter/Sanitize/AbsInt.php +++ b/src/Phalcon/Filter/Sanitize/AbsInt.php @@ -23,4 +23,5 @@ class AbsInt public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Alnum.php b/src/Phalcon/Filter/Sanitize/Alnum.php index a715f0df..29516b2e 100644 --- a/src/Phalcon/Filter/Sanitize/Alnum.php +++ b/src/Phalcon/Filter/Sanitize/Alnum.php @@ -23,4 +23,5 @@ class Alnum public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Alpha.php b/src/Phalcon/Filter/Sanitize/Alpha.php index 33eefae7..65c9ad74 100644 --- a/src/Phalcon/Filter/Sanitize/Alpha.php +++ b/src/Phalcon/Filter/Sanitize/Alpha.php @@ -23,4 +23,5 @@ class Alpha public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/BoolVal.php b/src/Phalcon/Filter/Sanitize/BoolVal.php index 67d8ec37..09aa4364 100644 --- a/src/Phalcon/Filter/Sanitize/BoolVal.php +++ b/src/Phalcon/Filter/Sanitize/BoolVal.php @@ -23,4 +23,5 @@ class BoolVal public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Email.php b/src/Phalcon/Filter/Sanitize/Email.php index 26f81b73..5dfab0c8 100644 --- a/src/Phalcon/Filter/Sanitize/Email.php +++ b/src/Phalcon/Filter/Sanitize/Email.php @@ -23,4 +23,5 @@ class Email public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/FloatVal.php b/src/Phalcon/Filter/Sanitize/FloatVal.php index 8ab85789..6341decf 100644 --- a/src/Phalcon/Filter/Sanitize/FloatVal.php +++ b/src/Phalcon/Filter/Sanitize/FloatVal.php @@ -23,4 +23,5 @@ class FloatVal public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/IntVal.php b/src/Phalcon/Filter/Sanitize/IntVal.php index dac4e5c3..1583ff87 100644 --- a/src/Phalcon/Filter/Sanitize/IntVal.php +++ b/src/Phalcon/Filter/Sanitize/IntVal.php @@ -23,4 +23,5 @@ class IntVal public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Lower.php b/src/Phalcon/Filter/Sanitize/Lower.php index c25fda7c..a61fa1c6 100644 --- a/src/Phalcon/Filter/Sanitize/Lower.php +++ b/src/Phalcon/Filter/Sanitize/Lower.php @@ -23,4 +23,5 @@ class Lower public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/LowerFirst.php b/src/Phalcon/Filter/Sanitize/LowerFirst.php index 9595ffff..d331cf11 100644 --- a/src/Phalcon/Filter/Sanitize/LowerFirst.php +++ b/src/Phalcon/Filter/Sanitize/LowerFirst.php @@ -23,4 +23,5 @@ class LowerFirst public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Regex.php b/src/Phalcon/Filter/Sanitize/Regex.php index 7441191b..8817613c 100644 --- a/src/Phalcon/Filter/Sanitize/Regex.php +++ b/src/Phalcon/Filter/Sanitize/Regex.php @@ -25,4 +25,5 @@ class Regex public function __invoke($input, $pattern, $replace) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Remove.php b/src/Phalcon/Filter/Sanitize/Remove.php index a8225560..1c7a90e5 100644 --- a/src/Phalcon/Filter/Sanitize/Remove.php +++ b/src/Phalcon/Filter/Sanitize/Remove.php @@ -24,4 +24,5 @@ class Remove public function __invoke($input, $replace) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Replace.php b/src/Phalcon/Filter/Sanitize/Replace.php index 6a60ca8f..05a72069 100644 --- a/src/Phalcon/Filter/Sanitize/Replace.php +++ b/src/Phalcon/Filter/Sanitize/Replace.php @@ -25,4 +25,5 @@ class Replace public function __invoke($input, $from, $to) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Special.php b/src/Phalcon/Filter/Sanitize/Special.php index 9ab25623..33735f44 100644 --- a/src/Phalcon/Filter/Sanitize/Special.php +++ b/src/Phalcon/Filter/Sanitize/Special.php @@ -23,4 +23,5 @@ class Special public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/SpecialFull.php b/src/Phalcon/Filter/Sanitize/SpecialFull.php index f57bad76..5170dfb7 100644 --- a/src/Phalcon/Filter/Sanitize/SpecialFull.php +++ b/src/Phalcon/Filter/Sanitize/SpecialFull.php @@ -23,4 +23,5 @@ class SpecialFull public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/StringVal.php b/src/Phalcon/Filter/Sanitize/StringVal.php index a2fcb069..798afafc 100644 --- a/src/Phalcon/Filter/Sanitize/StringVal.php +++ b/src/Phalcon/Filter/Sanitize/StringVal.php @@ -23,4 +23,5 @@ class StringVal public function __invoke($input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Striptags.php b/src/Phalcon/Filter/Sanitize/Striptags.php index 0b8a60b2..94588b4a 100644 --- a/src/Phalcon/Filter/Sanitize/Striptags.php +++ b/src/Phalcon/Filter/Sanitize/Striptags.php @@ -23,4 +23,5 @@ class Striptags public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Trim.php b/src/Phalcon/Filter/Sanitize/Trim.php index 4d20bd15..73b27c53 100644 --- a/src/Phalcon/Filter/Sanitize/Trim.php +++ b/src/Phalcon/Filter/Sanitize/Trim.php @@ -23,4 +23,5 @@ class Trim public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Upper.php b/src/Phalcon/Filter/Sanitize/Upper.php index 73eaa13a..b6232b24 100644 --- a/src/Phalcon/Filter/Sanitize/Upper.php +++ b/src/Phalcon/Filter/Sanitize/Upper.php @@ -23,4 +23,5 @@ class Upper public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/UpperFirst.php b/src/Phalcon/Filter/Sanitize/UpperFirst.php index 52a48308..29abcedd 100644 --- a/src/Phalcon/Filter/Sanitize/UpperFirst.php +++ b/src/Phalcon/Filter/Sanitize/UpperFirst.php @@ -23,4 +23,5 @@ class UpperFirst public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/UpperWords.php b/src/Phalcon/Filter/Sanitize/UpperWords.php index a0ffce76..1a7a72e5 100644 --- a/src/Phalcon/Filter/Sanitize/UpperWords.php +++ b/src/Phalcon/Filter/Sanitize/UpperWords.php @@ -23,4 +23,5 @@ class UpperWords public function __invoke(string $input) { } + } diff --git a/src/Phalcon/Filter/Sanitize/Url.php b/src/Phalcon/Filter/Sanitize/Url.php index 8a9ee8d9..fdd131c4 100644 --- a/src/Phalcon/Filter/Sanitize/Url.php +++ b/src/Phalcon/Filter/Sanitize/Url.php @@ -23,4 +23,5 @@ class Url public function __invoke($input) { } + } diff --git a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php b/src/Phalcon/Firewall/Adapter/AbstractAdapter.php deleted file mode 100644 index 8b1b5e98..00000000 --- a/src/Phalcon/Firewall/Adapter/AbstractAdapter.php +++ /dev/null @@ -1,238 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall\Adapter; - -use Closure; -use Phalcon\Acl\Enum; -use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; -use Phalcon\Events\ManagerInterface; - -/** - * Adapter for Phalcon\Firewall adapters - */ -abstract class AbstractAdapter implements \Phalcon\Firewall\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface -{ - /** - * Storing active identity object implementing Phalcon/Acl/RoleAware - */ - protected $activeIdentity; - - /** - * Storing active user role - */ - protected $activeRole; - - /** - * Should role always be resolved using role callback or just once? - * - * @var bool - */ - protected $alwaysResolvingRole = false; - - /** - * Cache for caching access - * - * @var CacheAdapterInterface - */ - protected $cache; - - /** - * Default access - * - * @var int - */ - protected $defaultAccess = Enum::DENY; - - /** - * Events manager - * - * @var mixed - */ - protected $eventsManager; - - /** - * Internal cache for caching access during request time - * - * @var mixed - */ - protected $internalCache; - - /** - * Anonymous function for getting user identity - this function must - * return string, array or object implementing Phalcon\Acl\RoleAware - * - * @var mixed - */ - protected $roleCallback; - - - /** - * Storing active identity object implementing Phalcon/Acl/RoleAware - */ - public function getActiveIdentity() - { - } - - /** - * Storing active user role - */ - public function getActiveRole() - { - } - - /** - * Default access - * - * @return int - */ - public function getDefaultAccess(): int - { - } - - /** - * Returns the internal event manager - * - * @return ManagerInterface - */ - public function getEventsManager(): ManagerInterface - { - } - - /** - * Gets role callback to fetch role name - * - * @return Closure - */ - public function getRoleCallback(): Closure - { - } - - /** - * Gets always resolving role option - * - * @return bool - */ - public function isAlwaysResolvingRole(): bool - { - } - - /** - * Sets the cache adapter - * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @return AdapterInterface - */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface - { - } - - /** - * Sets the default access level (Phalcon\Acl\Enum::ALLOW or Phalcon\Acl\Enum::DENY) - * - * @param int $defaultAccess - * @return AdapterInterface - */ - public function setDefaultAccess(int $defaultAccess): AdapterInterface - { - } - - /** - * Sets the events manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return void - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) - { - } - - /** - * Sets role callback to fetch role name - * - * @param \Closure $callback - * @return AdapterInterface - */ - public function setRoleCallback(\Closure $callback): AdapterInterface - { - } - - /** - * Sets always resolving role option - * - * @param bool $alwaysResolvingRole - * @return void - */ - public function setAlwaysResolvingRole(bool $alwaysResolvingRole) - { - } - - /** - * @param \Phalcon\Di\DiInterface $container - * @return void - */ - protected function callRoleCallback(\Phalcon\Di\DiInterface $container) - { - } - - /** - * Gets access from cache - * - * @param string $key - * @param array $originalValues - * @param string $roleCacheKey - * @return bool|null - */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool - { - } - - /** - * Handles a user exception - * - * @param \Exception $exception - */ - protected function handleException(\Exception $exception) - { - } - - /** - * Fires event or throwing exception - * - * @param mixed $role - * @param string $actionName - * @param string $controllerName - * @param bool $access - */ - protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) - { - } - - /** - * Saves access in cache and internal cache - * - * @param string $key - * @param bool $access - * @return void - */ - protected function saveAccessInCache(string $key, bool $access) - { - } - - /** - * Throws an internal exception - * - * @param string $message - * @param int $exceptionCode - * @return bool - */ - protected function throwFirewallException(string $message, int $exceptionCode = 0): bool - { - } -} diff --git a/src/Phalcon/Firewall/Adapter/Acl.php b/src/Phalcon/Firewall/Adapter/Acl.php deleted file mode 100644 index a7cd0383..00000000 --- a/src/Phalcon/Firewall/Adapter/Acl.php +++ /dev/null @@ -1,217 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall\Adapter; - -use Phalcon\Mvc\DispatcherInterface; - -/** - * FirewallZ for Phalcon\Application which depends on acl and dispatcher - */ -class Acl extends \Phalcon\Firewall\Adapter\AbstractAdapter -{ - /** - * Acl service name - * - * @var string - */ - protected $aclServiceName; - - /** - * Bound models - * - * @var array - */ - protected $boundModels; - - /** - * Property used for setting different key names in associated acl function than got from Binder - */ - protected $boundModelsKeyMap; - - /** - * Dispatcher - * - * @var mixed - */ - protected $dispatcher; - - /** - * Parameter for using with multi module application - * - * @var bool - */ - protected $multiModuleConfiguration = false; - - /** - * Separator between module name and controller prefix - * - * @var string - */ - protected $moduleSeparator = ':'; - - /** - * Function returning string for role cache key - * - * @var mixed - */ - protected $roleCacheCallback; - - - /** - * Acl service name - * - * @return string - */ - public function getAclServiceName(): string - { - } - - /** - * Acl service name - * - * @param string $aclServiceName - */ - public function setAclServiceName(string $aclServiceName) - { - } - - /** - * Property used for setting different key names in associated acl function than got from Binder - */ - public function getBoundModelsKeyMap() - { - } - - /** - * Property used for setting different key names in associated acl function than got from Binder - * - * @param mixed $boundModelsKeyMap - */ - public function setBoundModelsKeyMap($boundModelsKeyMap) - { - } - - /** - * Separator between module name and controller prefix - * - * @return string - */ - public function getModuleSeparator(): string - { - } - - /** - * Separator between module name and controller prefix - * - * @param string $moduleSeparator - */ - public function setModuleSeparator(string $moduleSeparator) - { - } - - /** - * Function returning string for role cache key - * - * @return mixed - */ - public function getRoleCacheCallback() - { - } - - /** - * Function returning string for role cache key - * - * @param mixed $roleCacheCallback - */ - public function setRoleCacheCallback($roleCacheCallback) - { - } - - /** - * Phalcon\Firewall\Adapter\Acl constructor - * - * @param string $aclServiceName - * @param array $boundModelsKeyMap - */ - public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) - { - } - - /** - * @param \Phalcon\Events\Event $event - * @param \Phalcon\Mvc\DispatcherInterface $dispatcher - * @param mixed $data - */ - public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) - { - } - - /** - * @param \Phalcon\Events\Event $event - * @param \Phalcon\Mvc\DispatcherInterface $dispatcher - * @param mixed $data - */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) - { - } - - /** - * Gets dispatcher - * - * @return DispatcherInterface - */ - public function getDispatcher(): DispatcherInterface - { - } - - /** - * Returns multiModuleConfiguration - * - * @return bool - */ - public function isMultiModuleConfiguration(): bool - { - } - - /** - * Sets multiModuleConfiguration - * - * @param bool $multiModuleConfiguration - */ - public function useMultiModuleConfiguration(bool $multiModuleConfiguration) - { - } - - /** - * @param string $key - * @param array $originalValues - * @param string $roleCacheKey - * @return bool|null - */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool - { - } - - /** - * @param \Phalcon\Mvc\DispatcherInterface $dispatcher - */ - protected function handleDispatcher(\Phalcon\Mvc\DispatcherInterface $dispatcher) - { - } - - /** - * @param string $key - * @param bool $access - * @return void - */ - protected function saveAccessInCache(string $key, bool $access) - { - } -} diff --git a/src/Phalcon/Firewall/Adapter/AdapterInterface.php b/src/Phalcon/Firewall/Adapter/AdapterInterface.php deleted file mode 100644 index e356e610..00000000 --- a/src/Phalcon/Firewall/Adapter/AdapterInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall\Adapter; - -use Closure; - -/** - * Interface for Phalcon\Mvc\Dispatcher\Firewall adapters - */ -interface AdapterInterface -{ - - /** - * Returns the default ACL access level - * - * @return int - */ - public function getDefaultAccess(): int; - - /** - * Gets role callback to fetch role name - * - * @return Closure - */ - public function getRoleCallback(): Closure; - - /** - * Gets always resolving role option - * - * @return bool - */ - public function isAlwaysResolvingRole(): bool; - - /** - * Sets always resolving role option - * - * @param bool $alwaysResolvingRole - * @return void - */ - public function setAlwaysResolvingRole(bool $alwaysResolvingRole); - - /** - * Sets cache backend - * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache - * @return AdapterInterface - */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): AdapterInterface; - - /** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - * - * @param int $defaultAccess - * @return AdapterInterface - */ - public function setDefaultAccess(int $defaultAccess): AdapterInterface; - - /** - * Sets role callback to fetch role name - * - * @param \Closure $callback - * @return AdapterInterface - */ - public function setRoleCallback(\Closure $callback): AdapterInterface; -} diff --git a/src/Phalcon/Firewall/Adapter/Annotations.php b/src/Phalcon/Firewall/Adapter/Annotations.php deleted file mode 100644 index 38def960..00000000 --- a/src/Phalcon/Firewall/Adapter/Annotations.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall\Adapter; - -use Phalcon\Mvc\DispatcherInterface; - -/** - * Firewall which depends on annotations and dispatcher - */ -class Annotations extends \Phalcon\Firewall\Adapter\AbstractAdapter -{ - /** - * Number of active active arguments in active annotation - * - * @var int - */ - protected $activeArgumentsNumber = 0; - - /** - * Adapter for annotations - * - * @var mixed - */ - protected $annotationsAdapter; - - /** - * Dispatcher - * - * @var mixed - */ - protected $dispatcher; - - /** - * Role for which access was granted - */ - protected $resolvedRole; - - - /** - * Adapter for annotations - * - * @return mixed - */ - public function getAnnotationsAdapter() - { - } - - /** - * Adapter for annotations - * - * @param mixed $annotationsAdapter - */ - public function setAnnotationsAdapter($annotationsAdapter) - { - } - - /** - * Phalcon\Firewall\Adapter\Annotations constructor - * - * @param \Phalcon\Annotations\Adapter\AdapterInterface $annotationsAdapter - */ - public function __construct(\Phalcon\Annotations\Adapter\AdapterInterface $annotationsAdapter) - { - } - - /** - * @param \Phalcon\Events\Event $event - * @param \Phalcon\Mvc\DispatcherInterface $dispatcher - * @param mixed $data - */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\DispatcherInterface $dispatcher, $data) - { - } - - /** - * Gets dispatcher - * - * @return DispatcherInterface - */ - public function getDispatcher(): DispatcherInterface - { - } - - /** - * @param string $controllerClass - * @param string $controllerName - * @param mixed $role - */ - protected function checkControllerAnnotationAccess(string $controllerClass, string $controllerName, $role) - { - } - - /** - * @param mixed $annotations - * @param mixed $role - */ - protected function checkAnnotations($annotations, $role) - { - } - - /** - * @param string $controllerClass - * @param string $controllerName - * @param string $actionName - * @param mixed $role - */ - protected function checkActionAnnotationAccess(string $controllerClass, string $controllerName, string $actionName, $role) - { - } - - /** - * @param string $key - * @param array $originalValues - * @param string $roleCacheKey - * @return bool|null - */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool - { - } - - /** - * @param mixed $annotation - * @param bool $access - * @param mixed $role - */ - protected function handleAnnotation($annotation, bool $access, $role) - { - } -} diff --git a/src/Phalcon/Firewall/Adapter/Micro/Acl.php b/src/Phalcon/Firewall/Adapter/Micro/Acl.php deleted file mode 100644 index 0d54d50a..00000000 --- a/src/Phalcon/Firewall/Adapter/Micro/Acl.php +++ /dev/null @@ -1,243 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall\Adapter\Micro; - -use Phalcon\Firewall\Adapter\AbstractAdapter; -use Phalcon\Mvc\Micro; - -/** - * Firewall for Phalcon\Mvc\Micro which depends on ACL - */ -class Acl extends AbstractAdapter -{ - /** - * Acl service name - * - * @var string - */ - protected $aclServiceName; - - /** - * Bound models - * - * @var array - */ - protected $boundModels; - - /** - * Property used for setting different key names in associated ACL function - * than got from Binder - */ - protected $boundModelsKeyMap; - - /** - * Component name used to acquire access, be default it's Micro - * - * @var string - */ - protected $componentName = 'Micro'; - - /** - * Micro object - * - * @var mixed - */ - protected $micro; - - /** - * Function returning string for role cache key - * - * @var mixed - */ - protected $roleCacheCallback; - - /** - * Router object - * - * @var mixed - */ - protected $router; - - /** - * By default using route names which are required, you can change it to - * false to use route patterns - * - * @var bool - */ - protected $routeNameConfiguration = true; - - - /** - * Acl service name - * - * @return string - */ - public function getAclServiceName(): string - { - } - - /** - * Acl service name - * - * @param string $aclServiceName - */ - public function setAclServiceName(string $aclServiceName) - { - } - - /** - * Property used for setting different key names in associated ACL function - * - * than got from Binder - */ - public function getBoundModelsKeyMap() - { - } - - /** - * Property used for setting different key names in associated ACL function - * - * than got from Binder - * - * @param mixed $boundModelsKeyMap - */ - public function setBoundModelsKeyMap($boundModelsKeyMap) - { - } - - /** - * Component name used to acquire access, be default it's Micro - * - * @return string - */ - public function getComponentName(): string - { - } - - /** - * Component name used to acquire access, be default it's Micro - * - * @param string $componentName - */ - public function setComponentName(string $componentName) - { - } - - /** - * Function returning string for role cache key - * - * @return mixed - */ - public function getRoleCacheCallback() - { - } - - /** - * Function returning string for role cache key - * - * @param mixed $roleCacheCallback - */ - public function setRoleCacheCallback($roleCacheCallback) - { - } - - /** - * By default using route names which are required, you can change it to - * - * false to use route patterns - * - * @param bool $routeNameConfiguration - */ - public function setRouteNameConfiguration(bool $routeNameConfiguration) - { - } - - /** - * @param string $aclServiceName - * @param array $boundModelsKeyMap - */ - public function __construct(string $aclServiceName, array $boundModelsKeyMap = null) - { - } - - /** - * @param \Phalcon\Events\Event $event - * @param \Phalcon\Mvc\Micro $micro - * @param mixed $data - */ - public function afterBinding(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) - { - } - - /** - * @param \Phalcon\Events\Event $event - * @param \Phalcon\Mvc\Micro $micro - * @param mixed $data - */ - public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Micro $micro, $data) - { - } - - /** - * Gets micro - * - * @return Micro - */ - public function getMicro(): Micro - { - } - - /** - * Gets route name configuration - * - * @return bool - */ - public function isRouteNameConfiguration(): bool - { - } - - /** - * Fires event or throwing exception - * - * @param mixed $role - * @param string $actionName - * @param string $controllerName - * @param bool $access - */ - protected function fireEventOrThrowException($role, string $actionName, string $controllerName, bool $access) - { - } - - /** - * @param string $key - * @param array $originalValues - * @param string $roleCacheKey - * @return bool|null - */ - protected function getAccessFromCache(string $key, array $originalValues = null, string $roleCacheKey = null): ?bool - { - } - - /** - * @param \Phalcon\Mvc\Micro $micro - */ - protected function handleRouter(\Phalcon\Mvc\Micro $micro) - { - } - - /** - * @param string $key - * @param bool $access - * @return void - */ - protected function saveAccessInCache(string $key, bool $access) - { - } -} diff --git a/src/Phalcon/Firewall/Exception.php b/src/Phalcon/Firewall/Exception.php deleted file mode 100644 index df1a6c70..00000000 --- a/src/Phalcon/Firewall/Exception.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Firewall; - -/** - * Exceptions thrown in Phalcon\Firewall will use this class - */ -class Exception extends \Phalcon\Exception -{ - -} diff --git a/src/Phalcon/Flash/AbstractFlash.php b/src/Phalcon/Flash/AbstractFlash.php index cb3086e4..3d23a6c3 100644 --- a/src/Phalcon/Flash/AbstractFlash.php +++ b/src/Phalcon/Flash/AbstractFlash.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Flash; +use Phalcon\Di; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Escaper\EscaperInterface; use Phalcon\Session\ManagerInterface as SessionInterface; @@ -276,4 +278,5 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } + } diff --git a/src/Phalcon/Flash/Direct.php b/src/Phalcon/Flash/Direct.php index e4a809ee..af28ca9c 100644 --- a/src/Phalcon/Flash/Direct.php +++ b/src/Phalcon/Flash/Direct.php @@ -36,4 +36,5 @@ public function message(string $type, $message): ?string public function output(bool $remove = true) { } + } diff --git a/src/Phalcon/Flash/FlashInterface.php b/src/Phalcon/Flash/FlashInterface.php index d311b268..5ef00ebd 100644 --- a/src/Phalcon/Flash/FlashInterface.php +++ b/src/Phalcon/Flash/FlashInterface.php @@ -57,4 +57,5 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; + } diff --git a/src/Phalcon/Flash/Session.php b/src/Phalcon/Flash/Session.php index 4bf0687f..ed658964 100644 --- a/src/Phalcon/Flash/Session.php +++ b/src/Phalcon/Flash/Session.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Flash; +use Phalcon\Di\DiInterface; use Phalcon\Session\ManagerInterface; /** @@ -98,4 +99,5 @@ protected function setSessionMessages(array $messages): array public function getSessionService(): ManagerInterface { } + } diff --git a/src/Phalcon/Forms/Element/AbstractElement.php b/src/Phalcon/Forms/Element/AbstractElement.php index 8dbc902e..3ece2995 100644 --- a/src/Phalcon/Forms/Element/AbstractElement.php +++ b/src/Phalcon/Forms/Element/AbstractElement.php @@ -9,8 +9,13 @@ */ namespace Phalcon\Forms\Element; +use InvalidArgumentException; use Phalcon\Forms\Form; +use Phalcon\Forms\Exception; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; +use Phalcon\Tag; +use Phalcon\Validation\ValidatorInterface; /** * This is a base class for form elements @@ -216,7 +221,7 @@ public function getUserOptions(): array /** * Returns the validators registered for the element * - * @return array + * @return array|\Phalcon\Validation\ValidatorInterface[] */ public function getValidators(): array { @@ -364,4 +369,5 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } + } diff --git a/src/Phalcon/Forms/Element/Check.php b/src/Phalcon/Forms/Element/Check.php index 252045d6..0fe4857b 100644 --- a/src/Phalcon/Forms/Element/Check.php +++ b/src/Phalcon/Forms/Element/Check.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Check * @@ -26,4 +28,5 @@ class Check extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Date.php b/src/Phalcon/Forms/Element/Date.php index fc2cc229..50d1d1dc 100644 --- a/src/Phalcon/Forms/Element/Date.php +++ b/src/Phalcon/Forms/Element/Date.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Component INPUT[type=date] for forms */ @@ -24,4 +26,5 @@ class Date extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/ElementInterface.php b/src/Phalcon/Forms/Element/ElementInterface.php index 4274309b..e67d9a07 100644 --- a/src/Phalcon/Forms/Element/ElementInterface.php +++ b/src/Phalcon/Forms/Element/ElementInterface.php @@ -10,7 +10,9 @@ namespace Phalcon\Forms\Element; use Phalcon\Forms\Form; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; +use Phalcon\Validation\ValidatorInterface; /** * Interface for Phalcon\Forms\Element classes @@ -138,7 +140,7 @@ public function getUserOptions(): array; /** * Returns the validators registered for the element * - * @return array + * @return array|\Phalcon\Validation\ValidatorInterface[] */ public function getValidators(): array; @@ -263,4 +265,5 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; + } diff --git a/src/Phalcon/Forms/Element/Email.php b/src/Phalcon/Forms/Element/Email.php index d89895dd..9f39071f 100644 --- a/src/Phalcon/Forms/Element/Email.php +++ b/src/Phalcon/Forms/Element/Email.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Email * @@ -26,4 +28,5 @@ class Email extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/File.php b/src/Phalcon/Forms/Element/File.php index 7085a434..4db2874d 100644 --- a/src/Phalcon/Forms/Element/File.php +++ b/src/Phalcon/Forms/Element/File.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Component INPUT[type=file] for forms */ @@ -24,4 +26,5 @@ class File extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Hidden.php b/src/Phalcon/Forms/Element/Hidden.php index faa70448..739d3c73 100644 --- a/src/Phalcon/Forms/Element/Hidden.php +++ b/src/Phalcon/Forms/Element/Hidden.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Hidden * @@ -26,4 +28,5 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Numeric.php b/src/Phalcon/Forms/Element/Numeric.php index 384b8af1..0400349b 100644 --- a/src/Phalcon/Forms/Element/Numeric.php +++ b/src/Phalcon/Forms/Element/Numeric.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Numeric * @@ -26,4 +28,5 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Password.php b/src/Phalcon/Forms/Element/Password.php index a914d3c0..fddfcc08 100644 --- a/src/Phalcon/Forms/Element/Password.php +++ b/src/Phalcon/Forms/Element/Password.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Password * @@ -26,4 +28,5 @@ class Password extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Radio.php b/src/Phalcon/Forms/Element/Radio.php index c3ce28db..171ab83c 100644 --- a/src/Phalcon/Forms/Element/Radio.php +++ b/src/Phalcon/Forms/Element/Radio.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Radio * @@ -26,4 +28,5 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Select.php b/src/Phalcon/Forms/Element/Select.php index 7796f076..05f62264 100644 --- a/src/Phalcon/Forms/Element/Select.php +++ b/src/Phalcon/Forms/Element/Select.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag\Select as SelectTag; + /** * Phalcon\Forms\Element\Select * @@ -69,4 +71,5 @@ public function render(array $attributes = array()): string public function setOptions($options): ElementInterface { } + } diff --git a/src/Phalcon/Forms/Element/Submit.php b/src/Phalcon/Forms/Element/Submit.php index 36dfea82..d4a81f90 100644 --- a/src/Phalcon/Forms/Element/Submit.php +++ b/src/Phalcon/Forms/Element/Submit.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Component INPUT[type=submit] for forms */ @@ -24,4 +26,5 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/Text.php b/src/Phalcon/Forms/Element/Text.php index f66ebf22..846871b5 100644 --- a/src/Phalcon/Forms/Element/Text.php +++ b/src/Phalcon/Forms/Element/Text.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Phalcon\Forms\Element\Text * @@ -26,4 +28,5 @@ class Text extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Element/TextArea.php b/src/Phalcon/Forms/Element/TextArea.php index b316bbf2..6a49ba0f 100644 --- a/src/Phalcon/Forms/Element/TextArea.php +++ b/src/Phalcon/Forms/Element/TextArea.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Forms\Element; +use Phalcon\Tag; + /** * Component TEXTAREA for forms */ @@ -24,4 +26,5 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Forms/Form.php b/src/Phalcon/Forms/Form.php index 01e9d411..601e43da 100644 --- a/src/Phalcon/Forms/Form.php +++ b/src/Phalcon/Forms/Form.php @@ -9,11 +9,18 @@ */ namespace Phalcon\Forms; +use Countable; +use Iterator; use Phalcon\Di\Injectable; +use Phalcon\Di\DiInterface; +use Phalcon\Filter\FilterInterface; use Phalcon\Forms\Element\ElementInterface; use Phalcon\Html\Attributes; use Phalcon\Html\Attributes\AttributesInterface; use Phalcon\Messages\Messages; +use Phalcon\Tag; +use Phalcon\Validation; +use Phalcon\Validation\ValidationInterface; /** * This component allows to build forms using an object-oriented interface @@ -155,7 +162,7 @@ public function getAttributes(): Attributes /** * Returns the form elements added to the form * - * @return array + * @return array|\Phalcon\Forms\Element\ElementInterface[] */ public function getElements(): array { @@ -388,4 +395,5 @@ public function setUserOptions(array $options): Form public function valid(): bool { } + } diff --git a/src/Phalcon/Forms/Manager.php b/src/Phalcon/Forms/Manager.php index 89f01681..996bea85 100644 --- a/src/Phalcon/Forms/Manager.php +++ b/src/Phalcon/Forms/Manager.php @@ -59,4 +59,5 @@ public function has(string $name): bool public function set(string $name, Form $form): Manager { } + } diff --git a/src/Phalcon/Helper/Arr.php b/src/Phalcon/Helper/Arr.php index 4181a55a..03ef41ca 100644 --- a/src/Phalcon/Helper/Arr.php +++ b/src/Phalcon/Helper/Arr.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Helper; +use stdClass; + /** * This class offers quick array functions throughout the framework */ @@ -28,6 +30,18 @@ final public static function chunk(array $collection, int $size, bool $preserveK { } + /** + * Helper method to filter the collection + * + * @param array $collection + * @param callable $method + * + * @return array + */ + final public static function filter(array $collection, $method = null): array + { + } + /** * Returns the first element of the collection. If a callable is passed, the * element returned is the first that validates true @@ -235,7 +249,7 @@ final public static function toObject(array $collection) * * @return bool */ - final public static function validateAll(array $collection, $method): bool + final public static function validateAll(array $collection, $method = null): bool { } @@ -248,19 +262,7 @@ final public static function validateAll(array $collection, $method): bool * * @return bool */ - final public static function validateAny(array $collection, $method): bool - { - } - - /** - * Helper method to filter the collection - * - * @param array $collection - * @param callable $method - * - * @return array - */ - final private static function filterCollection(array $collection, $method = null): array + final public static function validateAny(array $collection, $method = null): bool { } @@ -276,4 +278,5 @@ final private static function filterCollection(array $collection, $method = null final public static function whiteList(array $collection, array $whiteList): array { } + } diff --git a/src/Phalcon/Helper/Fs.php b/src/Phalcon/Helper/Fs.php index b0ad9265..ada075bd 100644 --- a/src/Phalcon/Helper/Fs.php +++ b/src/Phalcon/Helper/Fs.php @@ -28,4 +28,5 @@ class Fs final public static function basename(string $uri, $suffix = null): string { } + } diff --git a/src/Phalcon/Helper/Json.php b/src/Phalcon/Helper/Json.php new file mode 100644 index 00000000..110f3160 --- /dev/null +++ b/src/Phalcon/Helper/Json.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Helper; + +use InvalidArgumentException; + +/** + * This class offers a wrapper for JSON methods to serialize and unserialize + */ +class Json +{ + + /** + * Decodes a string using `json_decode` and throws an exception if the + * JSON data cannot be decoded + * + * ```php + * use Phalcon\Helper\Json; + * + * $data = '{"one":"two","0":"three"}'; + * + * var_dump(Json::decode($data)); + * // [ + * // 'one' => 'two', + * // 'three' + * // ]; + * ``` + * + * @param string $data JSON data to parse + * @param bool $associative When `true`, objects are converted to arrays + * @param int $depth Recursion depth. + * @param int $options Bitmask of JSON decode options. + * + * @return mixed + * + * @throws \InvalidArgumentException if the JSON cannot be decoded. + * @link http://www.php.net/manual/en/function.json-decode.php + */ + final public static function decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) + { + } + + /** + * Encodes a string using `json_encode` and throws an exception if the + * JSON data cannot be encoded + * + * ```php + * use Phalcon\Helper\Json; + * + * $data = [ + * 'one' => 'two', + * 'three' + * ]; + * + * echo Json::encode($data); + * // {"one":"two","0":"three"} + * ``` + * + * @param mixed $data JSON data to parse + * @param int $options Bitmask of JSON decode options. + * @param int $depth Recursion depth. + * + * @return mixed + * + * @throws \InvalidArgumentException if the JSON cannot be encoded. + * @link http://www.php.net/manual/en/function.json-encode.php + */ + final public static function encode($data, int $options = 0, int $depth = 512): string + { + } + +} diff --git a/src/Phalcon/Helper/Number.php b/src/Phalcon/Helper/Number.php index 09e62a95..be55148b 100644 --- a/src/Phalcon/Helper/Number.php +++ b/src/Phalcon/Helper/Number.php @@ -28,4 +28,5 @@ class Number final public static function between(int $value, int $from, int $to): bool { } + } diff --git a/src/Phalcon/Helper/Str.php b/src/Phalcon/Helper/Str.php index 7d3de81d..ac750bc7 100644 --- a/src/Phalcon/Helper/Str.php +++ b/src/Phalcon/Helper/Str.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Helper; +use RuntimeException; + /** * This class offers quick string functions throughout the framework */ @@ -111,6 +113,26 @@ final public static function decapitalize(string $text, bool $upperRest = false, { } + /** + * Removes a number from a string or decrements that number if it already is defined. + * defined + * + * ```php + * use Phalcon\Helper\Str; + * + * echo Str::decrement("a_1"); // "a" + * echo Str::decrement("a_2"); // "a_1" + * ``` + * + * @param string $text + * @param string $separator + * + * @return string + */ + final public static function decrement(string $text, string $separator = '_'): string + { + } + /** * Accepts a file name (without extension) and returns a calculated * directory structure with the filename in the end @@ -442,4 +464,5 @@ final public static function underscore(string $text): string final public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/Html/Attributes.php b/src/Phalcon/Html/Attributes.php index d431bbcc..41d7c774 100644 --- a/src/Phalcon/Html/Attributes.php +++ b/src/Phalcon/Html/Attributes.php @@ -10,6 +10,8 @@ namespace Phalcon\Html; use Phalcon\Collection; +use Phalcon\Html\Attributes\RenderInterface; +use Phalcon\Tag; /** * This class helps to work with HTML Attributes @@ -34,4 +36,5 @@ public function render(): string public function __toString(): string { } + } diff --git a/src/Phalcon/Html/Attributes/AttributesInterface.php b/src/Phalcon/Html/Attributes/AttributesInterface.php index 8d5a50e0..b0cb7391 100644 --- a/src/Phalcon/Html/Attributes/AttributesInterface.php +++ b/src/Phalcon/Html/Attributes/AttributesInterface.php @@ -33,4 +33,5 @@ public function getAttributes(): Attributes; * @return AttributesInterface */ public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; + } diff --git a/src/Phalcon/Html/Attributes/RenderInterface.php b/src/Phalcon/Html/Attributes/RenderInterface.php index 7fb01f6a..d2a71e41 100644 --- a/src/Phalcon/Html/Attributes/RenderInterface.php +++ b/src/Phalcon/Html/Attributes/RenderInterface.php @@ -23,4 +23,5 @@ interface RenderInterface * @return string */ public function render(): string; + } diff --git a/src/Phalcon/Html/Breadcrumbs.php b/src/Phalcon/Html/Breadcrumbs.php index dae1eeb7..49a526d3 100644 --- a/src/Phalcon/Html/Breadcrumbs.php +++ b/src/Phalcon/Html/Breadcrumbs.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Html; +use Phalcon\Di\DiInterface; + /** * Phalcon\Html\Breadcrumbs * @@ -128,4 +130,5 @@ public function render(): string public function toArray(): array { } + } diff --git a/src/Phalcon/Html/Helper/AbstractHelper.php b/src/Phalcon/Html/Helper/AbstractHelper.php index 8e02f3e8..ce3a79af 100644 --- a/src/Phalcon/Html/Helper/AbstractHelper.php +++ b/src/Phalcon/Html/Helper/AbstractHelper.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Html\Helper; +use Phalcon\Html\Exception; use Phalcon\Escaper\EscaperInterface; /** @@ -88,4 +89,5 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Anchor.php b/src/Phalcon/Html/Helper/Anchor.php index 2624e59f..6730b1fc 100644 --- a/src/Phalcon/Html/Helper/Anchor.php +++ b/src/Phalcon/Html/Helper/Anchor.php @@ -26,4 +26,5 @@ class Anchor extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/AnchorRaw.php b/src/Phalcon/Html/Helper/AnchorRaw.php index 402f7bde..91a80136 100644 --- a/src/Phalcon/Html/Helper/AnchorRaw.php +++ b/src/Phalcon/Html/Helper/AnchorRaw.php @@ -26,4 +26,5 @@ class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Body.php b/src/Phalcon/Html/Helper/Body.php index 6584697d..e2233f65 100644 --- a/src/Phalcon/Html/Helper/Body.php +++ b/src/Phalcon/Html/Helper/Body.php @@ -24,4 +24,5 @@ class Body extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Button.php b/src/Phalcon/Html/Helper/Button.php index 75de0d32..d1b38b84 100644 --- a/src/Phalcon/Html/Helper/Button.php +++ b/src/Phalcon/Html/Helper/Button.php @@ -25,4 +25,5 @@ class Button extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Close.php b/src/Phalcon/Html/Helper/Close.php index 3077a9fc..741496f8 100644 --- a/src/Phalcon/Html/Helper/Close.php +++ b/src/Phalcon/Html/Helper/Close.php @@ -25,4 +25,5 @@ class Close extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag): string { } + } diff --git a/src/Phalcon/Html/Helper/Element.php b/src/Phalcon/Html/Helper/Element.php index ec33c18b..ea372eda 100644 --- a/src/Phalcon/Html/Helper/Element.php +++ b/src/Phalcon/Html/Helper/Element.php @@ -26,4 +26,5 @@ class Element extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/ElementRaw.php b/src/Phalcon/Html/Helper/ElementRaw.php index e59e6900..13ad5f4b 100644 --- a/src/Phalcon/Html/Helper/ElementRaw.php +++ b/src/Phalcon/Html/Helper/ElementRaw.php @@ -30,4 +30,5 @@ class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Form.php b/src/Phalcon/Html/Helper/Form.php index 41e5fd76..57a5fb31 100644 --- a/src/Phalcon/Html/Helper/Form.php +++ b/src/Phalcon/Html/Helper/Form.php @@ -24,4 +24,5 @@ class Form extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Img.php b/src/Phalcon/Html/Helper/Img.php index 1ae6623c..0faa56b8 100644 --- a/src/Phalcon/Html/Helper/Img.php +++ b/src/Phalcon/Html/Helper/Img.php @@ -29,4 +29,5 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $src, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/Label.php b/src/Phalcon/Html/Helper/Label.php index cf170cb5..773932c4 100644 --- a/src/Phalcon/Html/Helper/Label.php +++ b/src/Phalcon/Html/Helper/Label.php @@ -28,4 +28,5 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Helper/TextArea.php b/src/Phalcon/Html/Helper/TextArea.php index 63fe97a0..50c632ce 100644 --- a/src/Phalcon/Html/Helper/TextArea.php +++ b/src/Phalcon/Html/Helper/TextArea.php @@ -25,4 +25,5 @@ class TextArea extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } + } diff --git a/src/Phalcon/Html/Link/EvolvableLink.php b/src/Phalcon/Html/Link/EvolvableLink.php index 36576364..787dfbf9 100644 --- a/src/Phalcon/Html/Link/EvolvableLink.php +++ b/src/Phalcon/Html/Link/EvolvableLink.php @@ -98,4 +98,5 @@ public function withoutAttribute($attribute) public function withoutRel($rel) { } + } diff --git a/src/Phalcon/Html/Link/EvolvableLinkProvider.php b/src/Phalcon/Html/Link/EvolvableLinkProvider.php index 46df0820..0846b9ca 100644 --- a/src/Phalcon/Html/Link/EvolvableLinkProvider.php +++ b/src/Phalcon/Html/Link/EvolvableLinkProvider.php @@ -49,4 +49,5 @@ public function withLink(\Psr\Link\LinkInterface $link) public function withoutLink(\Psr\Link\LinkInterface $link) { } + } diff --git a/src/Phalcon/Html/Link/Link.php b/src/Phalcon/Html/Link/Link.php index 96a73caa..94eed4c7 100644 --- a/src/Phalcon/Html/Link/Link.php +++ b/src/Phalcon/Html/Link/Link.php @@ -115,4 +115,5 @@ public function isTemplated() protected function hrefIsTemplated(string $href): bool { } + } diff --git a/src/Phalcon/Html/Link/LinkProvider.php b/src/Phalcon/Html/Link/LinkProvider.php index a7829ba5..7b6a0adb 100644 --- a/src/Phalcon/Html/Link/LinkProvider.php +++ b/src/Phalcon/Html/Link/LinkProvider.php @@ -70,4 +70,5 @@ public function getLinksByRel($rel) protected function getKey(\Psr\Link\LinkInterface $link): string { } + } diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Phalcon/Html/Link/Serializer/Header.php index cd9f5957..9efafa8f 100644 --- a/src/Phalcon/Html/Link/Serializer/Header.php +++ b/src/Phalcon/Html/Link/Serializer/Header.php @@ -26,4 +26,5 @@ class Header implements \Phalcon\Html\Link\Serializer\SerializerInterface public function serialize(array $links): ?string { } + } diff --git a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php index d2804463..9b922a51 100644 --- a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php +++ b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php @@ -22,4 +22,5 @@ interface SerializerInterface * @return string|null */ public function serialize(array $links): ?string; + } diff --git a/src/Phalcon/Html/TagFactory.php b/src/Phalcon/Html/TagFactory.php index 63c147f3..ede1e8ce 100644 --- a/src/Phalcon/Html/TagFactory.php +++ b/src/Phalcon/Html/TagFactory.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Html; +use Phalcon\Escaper; use Phalcon\Escaper\EscaperInterface; use Phalcon\Factory\AbstractFactory; @@ -48,4 +49,5 @@ public function newInstance(string $name) protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Http/Cookie.php b/src/Phalcon/Http/Cookie.php index e9159ba8..14792c37 100644 --- a/src/Phalcon/Http/Cookie.php +++ b/src/Phalcon/Http/Cookie.php @@ -9,38 +9,67 @@ */ namespace Phalcon\Http; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Crypt\CryptInterface; +use Phalcon\Crypt\Mismatch; +use Phalcon\Filter\FilterInterface; +use Phalcon\Http\Response\Exception; +use Phalcon\Http\Cookie\CookieInterface; +use Phalcon\Http\Cookie\Exception as CookieException; +use Phalcon\Session\ManagerInterface as SessionManagerInterface; /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInterface +class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\CookieInterface { - + /** + * @var string + */ protected $domain; - + /** + * @var int + */ protected $expire; protected $filter; - + /** + * @var bool + */ protected $httpOnly; - + /** + * @var string + */ protected $name; + /** + * @var array + */ + protected $options = array(); + /** + * @var string + */ protected $path; - + /** + * @var bool + */ protected $read = false; - + /** + * @var bool + */ protected $restored = false; - + /** + * @var bool + */ protected $secure; /** @@ -50,10 +79,14 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInter */ protected $signKey = null; - + /** + * @var bool + */ protected $useEncryption = false; - + /** + * @var mixed + */ protected $value; @@ -67,8 +100,9 @@ class Cookie extends AbstractInjectionAware implements \Phalcon\Http\CookieInter * @param bool $secure * @param string $domain * @param bool $httpOnly + * @param array $options */ - public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = false) + public function __construct(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = false, array $options = array()) { } @@ -124,6 +158,15 @@ public function getName(): string { } + /** + * Returns the current cookie's options + * + * @return array + */ + public function getOptions(): array + { + } + /** * Returns the current cookie's path * @@ -218,7 +261,17 @@ public function setHttpOnly(bool $httpOnly): CookieInterface } /** - * Sets the cookie's expiration time + * Sets the cookie's options + * + * @param array $options + * @return CookieInterface + */ + public function setOptions(array $options): CookieInterface + { + } + + /** + * Sets the cookie's path * * @param string $path * @return CookieInterface @@ -284,4 +337,5 @@ public function useEncryption(bool $useEncryption): CookieInterface protected function assertSignKeyIsLongEnough(string $signKey) { } + } diff --git a/src/Phalcon/Http/CookieInterface.php b/src/Phalcon/Http/Cookie/CookieInterface.php similarity index 90% rename from src/Phalcon/Http/CookieInterface.php rename to src/Phalcon/Http/Cookie/CookieInterface.php index 39573562..e1be940d 100644 --- a/src/Phalcon/Http/CookieInterface.php +++ b/src/Phalcon/Http/Cookie/CookieInterface.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Http; +namespace Phalcon\Http\Cookie; /** * Interface for Phalcon\Http\Cookie @@ -48,6 +48,13 @@ public function getHttpOnly(): bool; */ public function getName(): string; + /** + * Returns the current cookie's options + * + * @return array + */ + public function getOptions(): array; + /** * Returns the current cookie's path * @@ -110,6 +117,14 @@ public function setExpiration(int $expire): CookieInterface; */ public function setHttpOnly(bool $httpOnly): CookieInterface; + /** + * Sets the cookie's options + * + * @param array $options + * @return CookieInterface + */ + public function setOptions(array $options): CookieInterface; + /** * Sets the cookie's expiration time * @@ -142,4 +157,5 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; + } diff --git a/src/Phalcon/Http/Message/AbstractCommon.php b/src/Phalcon/Http/Message/AbstractCommon.php index 91c209e8..0bb36e48 100644 --- a/src/Phalcon/Http/Message/AbstractCommon.php +++ b/src/Phalcon/Http/Message/AbstractCommon.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; + /** * Common methods */ @@ -49,4 +51,5 @@ final protected function checkStringParameter($element) final protected function processWith($element, string $property) { } + } diff --git a/src/Phalcon/Http/Message/AbstractMessage.php b/src/Phalcon/Http/Message/AbstractMessage.php index 8073f424..22907bad 100644 --- a/src/Phalcon/Http/Message/AbstractMessage.php +++ b/src/Phalcon/Http/Message/AbstractMessage.php @@ -406,4 +406,5 @@ final protected function processHeaders($headers): Collection final protected function processProtocol($protocol = ''): string { } + } diff --git a/src/Phalcon/Http/Message/AbstractRequest.php b/src/Phalcon/Http/Message/AbstractRequest.php index fd605d15..afebdec7 100644 --- a/src/Phalcon/Http/Message/AbstractRequest.php +++ b/src/Phalcon/Http/Message/AbstractRequest.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Collection; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\UriInterface; @@ -182,4 +183,5 @@ final protected function processMethod($method = ''): string final protected function processUri($uri): UriInterface { } + } diff --git a/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php index 14de3be7..9ceabc76 100644 --- a/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php +++ b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Http\Message\Exception; +use Throwable; + /** * This file is part of the Phalcon Framework. * diff --git a/src/Phalcon/Http/Message/Request.php b/src/Phalcon/Http/Message/Request.php index 802c9ceb..7f4190ab 100644 --- a/src/Phalcon/Http/Message/Request.php +++ b/src/Phalcon/Http/Message/Request.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Stream\Input; +use Phalcon\Http\Message\AbstractRequest; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -30,4 +32,5 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } + } diff --git a/src/Phalcon/Http/Message/RequestFactory.php b/src/Phalcon/Http/Message/RequestFactory.php index b7bd65e4..a1964d55 100644 --- a/src/Phalcon/Http/Message/RequestFactory.php +++ b/src/Phalcon/Http/Message/RequestFactory.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Http\Message; -use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\UriInterface; /** @@ -30,4 +30,5 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface public function createRequest(string $method, $uri): RequestInterface { } + } diff --git a/src/Phalcon/Http/Message/Response.php b/src/Phalcon/Http/Message/Response.php index cfb4ec27..2d5c9fe7 100644 --- a/src/Phalcon/Http/Message/Response.php +++ b/src/Phalcon/Http/Message/Response.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Helper\Number; +use Phalcon\Http\Message\AbstractMessage; +use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ResponseInterface; /** @@ -146,4 +149,5 @@ private function getPhrases(): array private function processCode($code, $phrase = '') { } + } diff --git a/src/Phalcon/Http/Message/ResponseFactory.php b/src/Phalcon/Http/Message/ResponseFactory.php index 7491c31a..12802988 100644 --- a/src/Phalcon/Http/Message/ResponseFactory.php +++ b/src/Phalcon/Http/Message/ResponseFactory.php @@ -9,8 +9,8 @@ */ namespace Phalcon\Http\Message; -use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ResponseFactoryInterface; /** * PSR-17 ResponseFactory @@ -32,4 +32,5 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } + } diff --git a/src/Phalcon/Http/Message/ServerRequest.php b/src/Phalcon/Http/Message/ServerRequest.php index e11cfb58..d37bac89 100644 --- a/src/Phalcon/Http/Message/ServerRequest.php +++ b/src/Phalcon/Http/Message/ServerRequest.php @@ -11,6 +11,7 @@ use Phalcon\Collection; use Phalcon\Http\Message\Exception\InvalidArgumentException; +use Phalcon\Http\Message\Stream\Input; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -364,4 +365,5 @@ public function withoutAttribute($name): ServerRequest private function checkUploadedFiles(array $files) { } + } diff --git a/src/Phalcon/Http/Message/ServerRequestFactory.php b/src/Phalcon/Http/Message/ServerRequestFactory.php index 65dbc874..d0daf697 100644 --- a/src/Phalcon/Http/Message/ServerRequestFactory.php +++ b/src/Phalcon/Http/Message/ServerRequestFactory.php @@ -10,11 +10,12 @@ namespace Phalcon\Http\Message; use Phalcon\Collection; +use Phalcon\Helper\Arr; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\ServerRequestFactoryInterface; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UriInterface; +use Psr\Http\Message\UploadedFileInterface; /** * PSR-17 ServerRequestFactory @@ -241,4 +242,5 @@ private function parseUploadedFiles(array $files): Collection private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri { } + } diff --git a/src/Phalcon/Http/Message/Stream.php b/src/Phalcon/Http/Message/Stream.php index d01bbcb5..9f0aa50c 100644 --- a/src/Phalcon/Http/Message/Stream.php +++ b/src/Phalcon/Http/Message/Stream.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Helper\Arr; +use Exception; use Psr\Http\Message\StreamInterface; +use RuntimeException; /** * PSR-7 Stream @@ -250,4 +253,5 @@ private function checkSeekable() private function checkWritable() { } + } diff --git a/src/Phalcon/Http/Message/Stream/Input.php b/src/Phalcon/Http/Message/Stream/Input.php index 2e3f6696..bb33507f 100644 --- a/src/Phalcon/Http/Message/Stream/Input.php +++ b/src/Phalcon/Http/Message/Stream/Input.php @@ -89,4 +89,5 @@ public function isWritable(): bool public function read($length): string { } + } diff --git a/src/Phalcon/Http/Message/Stream/Memory.php b/src/Phalcon/Http/Message/Stream/Memory.php index efa30ca4..2f83336f 100644 --- a/src/Phalcon/Http/Message/Stream/Memory.php +++ b/src/Phalcon/Http/Message/Stream/Memory.php @@ -29,4 +29,5 @@ class Memory extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/Http/Message/Stream/Temp.php b/src/Phalcon/Http/Message/Stream/Temp.php index 13dc1d8c..bd28c2f7 100644 --- a/src/Phalcon/Http/Message/Stream/Temp.php +++ b/src/Phalcon/Http/Message/Stream/Temp.php @@ -29,4 +29,5 @@ class Temp extends Stream public function __construct($mode = 'rb') { } + } diff --git a/src/Phalcon/Http/Message/StreamFactory.php b/src/Phalcon/Http/Message/StreamFactory.php index f8401d0d..5cdb0cb8 100644 --- a/src/Phalcon/Http/Message/StreamFactory.php +++ b/src/Phalcon/Http/Message/StreamFactory.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; @@ -61,4 +62,5 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St public function createStreamFromResource($phpResource): StreamInterface { } + } diff --git a/src/Phalcon/Http/Message/UploadedFile.php b/src/Phalcon/Http/Message/UploadedFile.php index d309089f..69d28aca 100644 --- a/src/Phalcon/Http/Message/UploadedFile.php +++ b/src/Phalcon/Http/Message/UploadedFile.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Helper\Number; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -271,4 +274,5 @@ private function getErrorDescription(int $error): string private function storeFile(string $targetPath) { } + } diff --git a/src/Phalcon/Http/Message/UploadedFileFactory.php b/src/Phalcon/Http/Message/UploadedFileFactory.php index e01d2ad4..093f89d5 100644 --- a/src/Phalcon/Http/Message/UploadedFileFactory.php +++ b/src/Phalcon/Http/Message/UploadedFileFactory.php @@ -10,8 +10,8 @@ namespace Phalcon\Http\Message; use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileFactoryInterface; use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; /** * PSR-17 UploadedFileFactory @@ -41,4 +41,5 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } + } diff --git a/src/Phalcon/Http/Message/Uri.php b/src/Phalcon/Http/Message/Uri.php index 2b20450a..6f7bfdad 100644 --- a/src/Phalcon/Http/Message/Uri.php +++ b/src/Phalcon/Http/Message/Uri.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Http\Message; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Http\Message\Exception\InvalidArgumentException; use Psr\Http\Message\UriInterface; @@ -472,4 +474,5 @@ private function filterScheme(string $scheme): string private function splitQueryValue(string $element): array { } + } diff --git a/src/Phalcon/Http/Message/UriFactory.php b/src/Phalcon/Http/Message/UriFactory.php index 221ceffd..81168be2 100644 --- a/src/Phalcon/Http/Message/UriFactory.php +++ b/src/Phalcon/Http/Message/UriFactory.php @@ -28,4 +28,5 @@ final class UriFactory implements \Psr\Http\Message\UriFactoryInterface public function createUri(string $uri = ''): UriInterface { } + } diff --git a/src/Phalcon/Http/Request.php b/src/Phalcon/Http/Request.php index 6d54dfb5..b69a60d7 100644 --- a/src/Phalcon/Http/Request.php +++ b/src/Phalcon/Http/Request.php @@ -9,8 +9,16 @@ */ namespace Phalcon\Http; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\ManagerInterface; use Phalcon\Filter\FilterInterface; +use Phalcon\Helper\Json; +use Phalcon\Http\Request\File; +use Phalcon\Http\Request\FileInterface; +use Phalcon\Http\Request\Exception; +use UnexpectedValueException; +use stdClass; /** * Encapsulates request information for easy and secure access from application @@ -479,7 +487,7 @@ public function getServerName(): string * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array + * @return array|\Phalcon\Http\Request\FileInterface[] */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array { @@ -862,4 +870,5 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } + } diff --git a/src/Phalcon/Http/Request/File.php b/src/Phalcon/Http/Request/File.php index eb3c6500..e9e9d497 100644 --- a/src/Phalcon/Http/Request/File.php +++ b/src/Phalcon/Http/Request/File.php @@ -160,4 +160,5 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } + } diff --git a/src/Phalcon/Http/Request/FileInterface.php b/src/Phalcon/Http/Request/FileInterface.php index 70ed6b22..5568443b 100644 --- a/src/Phalcon/Http/Request/FileInterface.php +++ b/src/Phalcon/Http/Request/FileInterface.php @@ -17,6 +17,13 @@ interface FileInterface { + /** + * Returns the error if any + * + * @return string|null + */ + public function getError(): ?string; + /** * Returns the real name of the uploaded file * @@ -60,4 +67,5 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; + } diff --git a/src/Phalcon/Http/RequestInterface.php b/src/Phalcon/Http/RequestInterface.php index 96b2bee0..70034d4e 100644 --- a/src/Phalcon/Http/RequestInterface.php +++ b/src/Phalcon/Http/RequestInterface.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Http; +use Phalcon\Http\Request\FileInterface; +use stdClass; + /** * Interface for Phalcon\Http\Request */ @@ -341,7 +344,7 @@ public function getServerName(): string; * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array + * @return array|\Phalcon\Http\Request\FileInterface[] */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; @@ -508,4 +511,5 @@ public function isTrace(): bool; * @return int */ public function numFiles(bool $onlySuccessful = false): int; + } diff --git a/src/Phalcon/Http/Response.php b/src/Phalcon/Http/Response.php index bb19e53d..51b425b0 100644 --- a/src/Phalcon/Http/Response.php +++ b/src/Phalcon/Http/Response.php @@ -9,10 +9,21 @@ */ namespace Phalcon\Http; +use DateTime; +use DateTimeZone; +use Phalcon\Di; use Phalcon\Di\DiInterface; -use Phalcon\Events\ManagerInterface; -use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Helper\Fs; +use Phalcon\Helper\Json; +use Phalcon\Http\Response\Exception; use Phalcon\Http\Response\HeadersInterface; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Url\UrlInterface; +use Phalcon\Mvc\ViewInterface; +use Phalcon\Http\Response\Headers; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; /** * Part of the HTTP cycle is return responses to the clients. @@ -483,4 +494,5 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } + } diff --git a/src/Phalcon/Http/Response/Cookies.php b/src/Phalcon/Http/Response/Cookies.php index 17ced24f..a9c4d819 100644 --- a/src/Phalcon/Http/Response/Cookies.php +++ b/src/Phalcon/Http/Response/Cookies.php @@ -9,8 +9,10 @@ */ namespace Phalcon\Http\Response; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Http\CookieInterface; +use Phalcon\Http\Cookie\Exception; +use Phalcon\Http\Cookie\CookieInterface; /** * Phalcon\Http\Response\Cookies @@ -184,9 +186,10 @@ public function send(): bool * @param bool $secure * @param string $domain * @param bool $httpOnly + * @param array $options * @return CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = array()): CookiesInterface { } @@ -215,4 +218,5 @@ public function setSignKey(string $signKey = null): CookieInterface public function useEncryption(bool $useEncryption): CookiesInterface { } + } diff --git a/src/Phalcon/Http/Response/CookiesInterface.php b/src/Phalcon/Http/Response/CookiesInterface.php index 917e5155..e3596d4f 100644 --- a/src/Phalcon/Http/Response/CookiesInterface.php +++ b/src/Phalcon/Http/Response/CookiesInterface.php @@ -9,7 +9,7 @@ */ namespace Phalcon\Http\Response; -use Phalcon\Http\CookieInterface; +use Phalcon\Http\Cookie\CookieInterface; /** * Phalcon\Http\Response\CookiesInterface @@ -75,9 +75,10 @@ public function send(): bool; * @param bool $secure * @param string $domain * @param bool $httpOnly + * @param array $options * @return CookiesInterface */ - public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null): CookiesInterface; + public function set(string $name, $value = null, int $expire = 0, string $path = '/', bool $secure = null, string $domain = null, bool $httpOnly = null, array $options = array()): CookiesInterface; /** * Set if cookies in the bag must be automatically encrypted/decrypted @@ -86,4 +87,5 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; + } diff --git a/src/Phalcon/Http/Response/Headers.php b/src/Phalcon/Http/Response/Headers.php index 4104cfdd..9f181adb 100644 --- a/src/Phalcon/Http/Response/Headers.php +++ b/src/Phalcon/Http/Response/Headers.php @@ -95,4 +95,5 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } + } diff --git a/src/Phalcon/Http/Response/HeadersInterface.php b/src/Phalcon/Http/Response/HeadersInterface.php index 471b9471..c72a5305 100644 --- a/src/Phalcon/Http/Response/HeadersInterface.php +++ b/src/Phalcon/Http/Response/HeadersInterface.php @@ -59,4 +59,5 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); + } diff --git a/src/Phalcon/Http/ResponseInterface.php b/src/Phalcon/Http/ResponseInterface.php index effb2543..3b2d9ba0 100644 --- a/src/Phalcon/Http/ResponseInterface.php +++ b/src/Phalcon/Http/ResponseInterface.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Http; +use DateTime; use Phalcon\Http\Response\HeadersInterface; /** @@ -191,4 +192,5 @@ public function sendCookies(): ResponseInterface; * @return mixed */ public function sendHeaders(); + } diff --git a/src/Phalcon/Http/Server/AbstractMiddleware.php b/src/Phalcon/Http/Server/AbstractMiddleware.php index 2727615d..ff970f7b 100644 --- a/src/Phalcon/Http/Server/AbstractMiddleware.php +++ b/src/Phalcon/Http/Server/AbstractMiddleware.php @@ -36,4 +36,5 @@ abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterfac * @return ResponseInterface */ abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; + } diff --git a/src/Phalcon/Http/Server/AbstractRequestHandler.php b/src/Phalcon/Http/Server/AbstractRequestHandler.php index a272d8ae..b74a5596 100644 --- a/src/Phalcon/Http/Server/AbstractRequestHandler.php +++ b/src/Phalcon/Http/Server/AbstractRequestHandler.php @@ -31,4 +31,5 @@ abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandler * @return ResponseInterface */ abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; + } diff --git a/src/Phalcon/Image/Adapter/AbstractAdapter.php b/src/Phalcon/Image/Adapter/AbstractAdapter.php index 24633d97..9543cd65 100644 --- a/src/Phalcon/Image/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Image/Adapter/AbstractAdapter.php @@ -10,6 +10,7 @@ namespace Phalcon\Image\Adapter; use Phalcon\Image\Enum; +use Phalcon\Image\Exception; /** * Phalcon\Image\Adapter @@ -19,7 +20,7 @@ abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface { - protected static $checked = false; + static protected $checked = false; protected $file; @@ -281,4 +282,5 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } + } diff --git a/src/Phalcon/Image/Adapter/AdapterInterface.php b/src/Phalcon/Image/Adapter/AdapterInterface.php index a2bff6a5..4325b26a 100644 --- a/src/Phalcon/Image/Adapter/AdapterInterface.php +++ b/src/Phalcon/Image/Adapter/AdapterInterface.php @@ -124,4 +124,5 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; + } diff --git a/src/Phalcon/Image/Adapter/Gd.php b/src/Phalcon/Image/Adapter/Gd.php index 719b860b..b5b83264 100644 --- a/src/Phalcon/Image/Adapter/Gd.php +++ b/src/Phalcon/Image/Adapter/Gd.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Image\Adapter; +use Phalcon\Image\Enum; +use Phalcon\Image\Exception; + /** * This file is part of the Phalcon Framework. * @@ -20,7 +23,7 @@ class Gd extends \Phalcon\Image\Adapter\AbstractAdapter { - protected static $checked = false; + static protected $checked = false; /** @@ -178,4 +181,5 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) { } + } diff --git a/src/Phalcon/Image/Adapter/Imagick.php b/src/Phalcon/Image/Adapter/Imagick.php index 8991ffb6..cae0b80e 100644 --- a/src/Phalcon/Image/Adapter/Imagick.php +++ b/src/Phalcon/Image/Adapter/Imagick.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Image\Adapter; +use Phalcon\Image\Enum; +use Phalcon\Image\Exception; + /** * Phalcon\Image\Adapter\Imagick * @@ -28,10 +31,10 @@ class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter { - protected static $checked = false; + static protected $checked = false; - protected static $version = 0; + static protected $version = 0; /** @@ -242,4 +245,5 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } + } diff --git a/src/Phalcon/Image/Enum.php b/src/Phalcon/Image/Enum.php index f3c5503d..f059d608 100644 --- a/src/Phalcon/Image/Enum.php +++ b/src/Phalcon/Image/Enum.php @@ -45,4 +45,6 @@ class Enum const VERTICAL = 12; + + } diff --git a/src/Phalcon/Image/ImageFactory.php b/src/Phalcon/Image/ImageFactory.php index a7389cfa..2a242657 100644 --- a/src/Phalcon/Image/ImageFactory.php +++ b/src/Phalcon/Image/ImageFactory.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Image; +use Phalcon\Config; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; use Phalcon\Image\Adapter\AdapterInterface; /** @@ -30,7 +32,12 @@ public function __construct(array $services = array()) /** * Factory to create an instace from a Config object * - * @param mixed $config + * @param array|\Phalcon\Config $config = [ + * 'adapter' => 'gd', + * 'file' => 'image.jpg', + * 'height' => null, + * 'width' => null + * ] * @return AdapterInterface */ public function load($config): AdapterInterface @@ -56,4 +63,5 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index 6450c1fc..e0c058b9 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -25,4 +25,5 @@ class Kernel public static function preComputeHashKey(string $key) { } + } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index 3ae299da..a3bd45e4 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -9,7 +9,9 @@ */ namespace Phalcon; +use Phalcon\Loader\Exception; use Phalcon\Events\ManagerInterface; +use Phalcon\Events\EventsAwareInterface; /** * This component helps to load your project classes automatically based on some @@ -289,4 +291,5 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } + } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index d19cf7ba..247fe81f 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -9,7 +9,9 @@ */ namespace Phalcon; +use Psr\Log\LoggerInterface; use Phalcon\Logger\Adapter\AdapterInterface; +use Phalcon\Logger\Item; use Phalcon\Logger\Exception; /** @@ -291,7 +293,7 @@ public function setAdapters(array $adapters): Logger } /** - * Sets the adapters stack overriding what is already there + * Sets the log level above which we can log * * @param int $level * @return Logger @@ -345,4 +347,5 @@ protected function getLevels(): array private function getLevelNumber($level): int { } + } diff --git a/src/Phalcon/Logger/Adapter/AbstractAdapter.php b/src/Phalcon/Logger/Adapter/AbstractAdapter.php index 325b51a8..92b8b1d5 100644 --- a/src/Phalcon/Logger/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Logger/Adapter/AbstractAdapter.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Logger\Adapter; +use Phalcon\Logger; +use Phalcon\Logger\Exception; use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; /** * This file is part of the Phalcon Framework. @@ -127,4 +130,5 @@ public function rollback(): AdapterInterface public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface { } + } diff --git a/src/Phalcon/Logger/Adapter/AdapterInterface.php b/src/Phalcon/Logger/Adapter/AdapterInterface.php index 89f69ed2..84dbb44b 100644 --- a/src/Phalcon/Logger/Adapter/AdapterInterface.php +++ b/src/Phalcon/Logger/Adapter/AdapterInterface.php @@ -10,6 +10,7 @@ namespace Phalcon\Logger\Adapter; use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; /** * Phalcon\Logger\AdapterInterface @@ -55,6 +56,14 @@ public function commit(): AdapterInterface; */ public function getFormatter(): FormatterInterface; + /** + * Returns the whether the logger is currently in an active transaction or + * not + * + * @return bool + */ + public function inTransaction(): bool; + /** * Processes the message in the adapter * @@ -77,4 +86,5 @@ public function rollback(): AdapterInterface; * @return AdapterInterface */ public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; + } diff --git a/src/Phalcon/Logger/Adapter/Noop.php b/src/Phalcon/Logger/Adapter/Noop.php index 0565cbf0..42cf96fa 100644 --- a/src/Phalcon/Logger/Adapter/Noop.php +++ b/src/Phalcon/Logger/Adapter/Noop.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Adapter\Noop * @@ -44,4 +46,5 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/Logger/Adapter/Stream.php b/src/Phalcon/Logger/Adapter/Stream.php index 95a5c387..55667f7d 100644 --- a/src/Phalcon/Logger/Adapter/Stream.php +++ b/src/Phalcon/Logger/Adapter/Stream.php @@ -9,6 +9,12 @@ */ namespace Phalcon\Logger\Adapter; +use Phalcon\Logger\Adapter; +use Phalcon\Logger\Exception; +use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; +use UnexpectedValueException; + /** * Phalcon\Logger\Adapter\Stream * @@ -67,8 +73,10 @@ public function getName(): string /** * Constructor. Accepts the name and some options * + * @param array $options = [ + * 'mode' => 'ab' + * ] * @param string $name - * @param array $options */ public function __construct(string $name, array $options = array()) { @@ -92,4 +100,5 @@ public function close(): bool public function process(\Phalcon\Logger\Item $item) { } + } diff --git a/src/Phalcon/Logger/Adapter/Syslog.php b/src/Phalcon/Logger/Adapter/Syslog.php index 4b440bc3..553491c1 100644 --- a/src/Phalcon/Logger/Adapter/Syslog.php +++ b/src/Phalcon/Logger/Adapter/Syslog.php @@ -9,6 +9,14 @@ */ namespace Phalcon\Logger\Adapter; +use LogicException; +use Phalcon\Helper\Arr; +use Phalcon\Logger; +use Phalcon\Logger\Adapter; +use Phalcon\Logger\Exception; +use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Adapter\Syslog * @@ -65,8 +73,11 @@ class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter /** * Phalcon\Logger\Adapter\Syslog constructor * + * @param array $options = [ + * 'option' => null, + * 'facility' => null + * ] * @param string $name - * @param array $options */ public function __construct(string $name, array $options = array()) { @@ -94,10 +105,11 @@ public function process(\Phalcon\Logger\Item $item) /** * Translates a Logger level to a Syslog level * - * @param string $level + * @param int $level * @return int */ - private function logLevelToSyslog(string $level): int + private function logLevelToSyslog(int $level): int { } + } diff --git a/src/Phalcon/Logger/AdapterFactory.php b/src/Phalcon/Logger/AdapterFactory.php index b2cb8c05..c6cc1b36 100644 --- a/src/Phalcon/Logger/AdapterFactory.php +++ b/src/Phalcon/Logger/AdapterFactory.php @@ -50,4 +50,5 @@ public function newInstance(string $name, string $fileName, array $options = arr protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Logger/Formatter/AbstractFormatter.php b/src/Phalcon/Logger/Formatter/AbstractFormatter.php index 6e3f5195..bb51f898 100644 --- a/src/Phalcon/Logger/Formatter/AbstractFormatter.php +++ b/src/Phalcon/Logger/Formatter/AbstractFormatter.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger\Formatter; +use Phalcon\Logger; + /** * This file is part of the Phalcon Framework. * @@ -30,4 +32,5 @@ abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterI public function interpolate(string $message, $context = null) { } + } diff --git a/src/Phalcon/Logger/Formatter/FormatterInterface.php b/src/Phalcon/Logger/Formatter/FormatterInterface.php index e51a353d..11f4d6f9 100644 --- a/src/Phalcon/Logger/Formatter/FormatterInterface.php +++ b/src/Phalcon/Logger/Formatter/FormatterInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\FormatterInterface * @@ -24,4 +26,5 @@ interface FormatterInterface * @return string|array */ public function format(\Phalcon\Logger\Item $item); + } diff --git a/src/Phalcon/Logger/Formatter/Json.php b/src/Phalcon/Logger/Formatter/Json.php index 9e4157be..d0d4495e 100644 --- a/src/Phalcon/Logger/Formatter/Json.php +++ b/src/Phalcon/Logger/Formatter/Json.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Logger\Formatter; +use Phalcon\Helper\Json; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Formatter\Json * @@ -47,7 +50,7 @@ public function setDateFormat(string $dateFormat) * * @param string $dateFormat */ - public function __construct(string $dateFormat = 'D, d M y H:i:s O') + public function __construct(string $dateFormat = 'c') { } @@ -60,4 +63,5 @@ public function __construct(string $dateFormat = 'D, d M y H:i:s O') public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/Logger/Formatter/Line.php b/src/Phalcon/Logger/Formatter/Line.php index d8e1bbbe..b82b22d7 100644 --- a/src/Phalcon/Logger/Formatter/Line.php +++ b/src/Phalcon/Logger/Formatter/Line.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger\Formatter; +use Phalcon\Logger\Item; + /** * Phalcon\Logger\Formatter\Line * @@ -73,7 +75,7 @@ public function setFormat(string $format) * @param string $format * @param string $dateFormat */ - public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'D, d M y H:i:s O') + public function __construct(string $format = '[%date%][%type%] %message%', string $dateFormat = 'c') { } @@ -86,4 +88,5 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin public function format(\Phalcon\Logger\Item $item): string { } + } diff --git a/src/Phalcon/Logger/Item.php b/src/Phalcon/Logger/Item.php index 015de099..9b1b4d4f 100644 --- a/src/Phalcon/Logger/Item.php +++ b/src/Phalcon/Logger/Item.php @@ -101,4 +101,5 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } + } diff --git a/src/Phalcon/Logger/LoggerFactory.php b/src/Phalcon/Logger/LoggerFactory.php index 50a4cab5..47fad313 100644 --- a/src/Phalcon/Logger/LoggerFactory.php +++ b/src/Phalcon/Logger/LoggerFactory.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Logger; +use Phalcon\Config; +use Phalcon\Helper\Arr; use Phalcon\Logger; /** @@ -34,7 +36,18 @@ public function __construct(AdapterFactory $factory) /** * Factory to create an instace from a Config object * - * @param mixed $config + * @param array|\Phalcon\Config $config = [ + * 'name' => 'messages', + * 'adapters' => [ + * 'adapter' => 'stream', + * 'name' => 'file.log', + * 'options' => [ + * 'mode' => 'ab', + * 'option' => null, + * 'facility' => null + * ] + * ] + * ] * @return Logger */ public function load($config): Logger @@ -52,4 +65,5 @@ public function load($config): Logger public function newInstance(string $name, array $adapters = array()): Logger { } + } diff --git a/src/Phalcon/Messages/Message.php b/src/Phalcon/Messages/Message.php index e0da5621..ab4889af 100644 --- a/src/Phalcon/Messages/Message.php +++ b/src/Phalcon/Messages/Message.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Messages; +use JsonSerializable; + /** * Phalcon\Messages\Message * @@ -157,4 +159,5 @@ public function setMetaData(array $metaData): MessageInterface public function setType(string $type): MessageInterface { } + } diff --git a/src/Phalcon/Messages/MessageInterface.php b/src/Phalcon/Messages/MessageInterface.php index 3f964f8f..14a99d06 100644 --- a/src/Phalcon/Messages/MessageInterface.php +++ b/src/Phalcon/Messages/MessageInterface.php @@ -98,4 +98,5 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; + } diff --git a/src/Phalcon/Messages/Messages.php b/src/Phalcon/Messages/Messages.php index 9340fb2b..e41a1564 100644 --- a/src/Phalcon/Messages/Messages.php +++ b/src/Phalcon/Messages/Messages.php @@ -9,6 +9,11 @@ */ namespace Phalcon\Messages; +use ArrayAccess; +use Countable; +use Iterator; +use JsonSerializable; + /** * Represents a collection of messages */ @@ -203,4 +208,5 @@ public function rewind() public function valid(): bool { } + } diff --git a/src/Phalcon/Mvc/Application.php b/src/Phalcon/Mvc/Application.php index ec4e78c0..8204c247 100644 --- a/src/Phalcon/Mvc/Application.php +++ b/src/Phalcon/Mvc/Application.php @@ -9,7 +9,14 @@ */ namespace Phalcon\Mvc; +use Closure; use Phalcon\Application\AbstractApplication; +use Phalcon\Di\DiInterface; +use Phalcon\Http\ResponseInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Application\Exception; +use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Mvc\ModuleDefinitionInterface; /** * Phalcon\Mvc\Application @@ -109,4 +116,5 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } + } diff --git a/src/Phalcon/Mvc/Controller.php b/src/Phalcon/Mvc/Controller.php index c5bfda01..0bdb95f1 100644 --- a/src/Phalcon/Mvc/Controller.php +++ b/src/Phalcon/Mvc/Controller.php @@ -60,4 +60,5 @@ abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerI final public function __construct() { } + } diff --git a/src/Phalcon/Mvc/Controller/BindModelInterface.php b/src/Phalcon/Mvc/Controller/BindModelInterface.php index e53bf305..1d8c0bfb 100644 --- a/src/Phalcon/Mvc/Controller/BindModelInterface.php +++ b/src/Phalcon/Mvc/Controller/BindModelInterface.php @@ -23,4 +23,5 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; + } diff --git a/src/Phalcon/Mvc/Dispatcher.php b/src/Phalcon/Mvc/Dispatcher.php index af0a7413..2806fd28 100644 --- a/src/Phalcon/Mvc/Dispatcher.php +++ b/src/Phalcon/Mvc/Dispatcher.php @@ -9,6 +9,11 @@ */ namespace Phalcon\Mvc; +use Phalcon\Mvc\Dispatcher\Exception; +use Phalcon\Events\ManagerInterface; +use Phalcon\Http\ResponseInterface; +use Phalcon\Dispatcher\AbstractDispatcher as BaseDispatcher; + /** * Dispatching is the process of taking the request object, extracting the * module name, controller name, action name, and optional parameters contained @@ -214,4 +219,5 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } + } diff --git a/src/Phalcon/Mvc/DispatcherInterface.php b/src/Phalcon/Mvc/DispatcherInterface.php index b3c8103c..4d239253 100644 --- a/src/Phalcon/Mvc/DispatcherInterface.php +++ b/src/Phalcon/Mvc/DispatcherInterface.php @@ -60,4 +60,5 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); + } diff --git a/src/Phalcon/Mvc/EntityInterface.php b/src/Phalcon/Mvc/EntityInterface.php index 6056f3a6..b530459d 100644 --- a/src/Phalcon/Mvc/EntityInterface.php +++ b/src/Phalcon/Mvc/EntityInterface.php @@ -32,4 +32,5 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); + } diff --git a/src/Phalcon/Mvc/Micro.php b/src/Phalcon/Mvc/Micro.php index 012171b3..c92e1c24 100644 --- a/src/Phalcon/Mvc/Micro.php +++ b/src/Phalcon/Mvc/Micro.php @@ -9,11 +9,23 @@ */ namespace Phalcon\Mvc; +use ArrayAccess; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Di\FactoryDefault; +use Phalcon\Mvc\Micro\Exception; use Phalcon\Di\ServiceInterface; -use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Micro\Collection; +use Phalcon\Mvc\Micro\LazyLoader; +use Phalcon\Http\ResponseInterface; use Phalcon\Mvc\Model\BinderInterface; use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; +use Phalcon\Mvc\Micro\MiddlewareInterface; +use Phalcon\Mvc\Micro\CollectionInterface; +use Throwable; /** * Phalcon\Mvc\Micro @@ -490,4 +502,5 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } + } diff --git a/src/Phalcon/Mvc/Micro/Collection.php b/src/Phalcon/Mvc/Micro/Collection.php index 8479ed72..21b72524 100644 --- a/src/Phalcon/Mvc/Micro/Collection.php +++ b/src/Phalcon/Mvc/Micro/Collection.php @@ -240,4 +240,5 @@ public function setPrefix(string $prefix): CollectionInterface protected function addMap($method, string $routePattern, $handler, string $name) { } + } diff --git a/src/Phalcon/Mvc/Micro/CollectionInterface.php b/src/Phalcon/Mvc/Micro/CollectionInterface.php index a0b3d42a..6b685496 100644 --- a/src/Phalcon/Mvc/Micro/CollectionInterface.php +++ b/src/Phalcon/Mvc/Micro/CollectionInterface.php @@ -149,4 +149,5 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; + } diff --git a/src/Phalcon/Mvc/Micro/LazyLoader.php b/src/Phalcon/Mvc/Micro/LazyLoader.php index 1713ab44..a520cc8c 100644 --- a/src/Phalcon/Mvc/Micro/LazyLoader.php +++ b/src/Phalcon/Mvc/Micro/LazyLoader.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Micro; +use Phalcon\Mvc\Model\BinderInterface; + /** * Phalcon\Mvc\Micro\LazyLoader * @@ -48,4 +50,5 @@ public function __construct(string $definition) public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) { } + } diff --git a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php index ab24356d..d304f082 100644 --- a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php +++ b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Micro; +use Phalcon\Mvc\Micro; + /** * Allows to implement Phalcon\Mvc\Micro middleware in classes */ @@ -21,4 +23,5 @@ interface MiddlewareInterface * @param \Phalcon\Mvc\Micro $application */ public function call(\Phalcon\Mvc\Micro $application); + } diff --git a/src/Phalcon/Mvc/Model.php b/src/Phalcon/Mvc/Model.php index d51e101a..d8598cec 100644 --- a/src/Phalcon/Mvc/Model.php +++ b/src/Phalcon/Mvc/Model.php @@ -9,15 +9,39 @@ */ namespace Phalcon\Mvc; +use JsonSerializable; use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Db\Column; +use Phalcon\Db\DialectInterface; +use Phalcon\Db\Enum; +use Phalcon\Db\RawValue; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Di; +use Phalcon\Di\DiInterface; use Phalcon\Events\ManagerInterface as EventsManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Messages\Message; +use Phalcon\Messages\MessageInterface; +use Phalcon\Mvc\Model\BehaviorInterface; +use Phalcon\Mvc\Model\Criteria; use Phalcon\Mvc\Model\CriteriaInterface; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\ManagerInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\Query; -use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\Model\ResultInterface; +use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Relation; +use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\TransactionInterface; +use Phalcon\Mvc\Model\ValidationFailed; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Validation\ValidationInterface; +use Serializable; /** * Phalcon\Mvc\Model @@ -85,10 +109,14 @@ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\Enti protected $dirtyState = 1; - + /** + * @var array + */ protected $dirtyRelated = array(); - + /** + * @var array + */ protected $errorMessages = array(); @@ -97,13 +125,17 @@ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\Enti protected $modelsMetaData; - + /** + * @var array + */ protected $related = array(); protected $operationMade = 0; - + /** + * @var array + */ protected $oldSnapshot = array(); @@ -655,7 +687,23 @@ public function dump(): array * $transaction2->rollback(); * ``` * - * @param mixed $parameters + * @param arrray|string|int|null $parameters = [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] * @return ResultsetInterface */ public static function find($parameters = null): ResultsetInterface @@ -728,7 +776,23 @@ public static function find($parameters = null): ResultsetInterface * ); * ``` * - * @param string|array $parameters + * @param arrray|string|int|null $parameters = [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] * @return mixed */ public static function findFirst($parameters = null) @@ -820,7 +884,7 @@ public function getEventsManager(): EventsManagerInterface * ``` * * @param mixed $filter - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages($filter = null): array { @@ -1516,7 +1580,7 @@ protected static function _groupResult(string $functionName, string $alias, $par * @param string $method * @param array $arguments */ - final protected static function _invokeFinder(string $method, array $arguments) + protected final static function _invokeFinder(string $method, array $arguments) { } @@ -1629,10 +1693,35 @@ protected function _cancelOperation() * } * ``` * + * @param array|null $options = [ + * 'reusable' => false, + * 'alias' => 'someAlias', + * 'foreignKey' => [ + * 'message' => null, + * 'allowNulls' => false, + * 'action' => null + * ], + * 'params' => [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] + * ] * @param mixed $fields * @param string $referenceModel * @param mixed $referencedFields - * @param mixed $options * @return Relation */ protected function belongsTo($fields, string $referenceModel, $referencedFields, $options = null): Relation @@ -1667,10 +1756,35 @@ private static function getPreparedQuery($params, $limit = null): Query * } * ``` * + * @param array|null $options = [ + * 'reusable' => false, + * 'alias' => 'someAlias', + * 'foreignKey' => [ + * 'message' => null, + * 'allowNulls' => false, + * 'action' => null + * ], + * 'params' => [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] + * ] * @param mixed $fields * @param string $referenceModel * @param mixed $referencedFields - * @param mixed $options * @return Relation */ protected function hasMany($fields, string $referenceModel, $referencedFields, $options = null): Relation @@ -1703,7 +1817,33 @@ protected function hasMany($fields, string $referenceModel, $referencedFields, $ * @param string|array $intermediateFields * @param string|array $intermediateReferencedFields * @param string|array $referencedFields - * @param array $options + * @param array $options * + * @param array|null $options = [ + * 'reusable' => false, + * 'alias' => 'someAlias', + * 'foreignKey' => [ + * 'message' => null, + * 'allowNulls' => false, + * 'action' => null + * ], + * 'params' => [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] + * ] * @param string $intermediateModel * @param string $referenceModel * @return Relation @@ -1729,10 +1869,35 @@ protected function hasManyToMany($fields, string $intermediateModel, $intermedia * } * ``` * + * @param array|null $options = [ + * 'reusable' => false, + * 'alias' => 'someAlias', + * 'foreignKey' => [ + * 'message' => null, + * 'allowNulls' => false, + * 'action' => null + * ], + * 'params' => [ + * 'conditions' => '' + * 'columns' => '', + * 'bind' => [], + * 'bindTypes => [], + * 'order' => '', + * 'limit' => 10, + * 'offset' => 5, + * 'group' => 'name, status', + * 'for_updated' => false, + * 'shared_lock' => false, + * 'cache' => [ + * 'lifetime' => 3600, + * 'key' => 'my-find-key' + * ], + * 'hydration' => null + * ] + * ] * @param mixed $fields * @param string $referenceModel * @param mixed $referencedFields - * @param mixed $options * @return Relation */ protected function hasOne($fields, string $referenceModel, $referencedFields, $options = null): Relation @@ -1997,4 +2162,5 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } + } diff --git a/src/Phalcon/Mvc/Model/Behavior.php b/src/Phalcon/Mvc/Model/Behavior.php index 25bf961e..85560583 100644 --- a/src/Phalcon/Mvc/Model/Behavior.php +++ b/src/Phalcon/Mvc/Model/Behavior.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Behavior * @@ -71,4 +73,5 @@ protected function mustTakeAction(string $eventName): bool public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php index 85b47a4d..5c7a483a 100644 --- a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php +++ b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\SoftDelete @@ -29,4 +31,5 @@ class SoftDelete extends Behavior public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) { } + } diff --git a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php index 0863099b..3347e329 100644 --- a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php +++ b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\Model\Behavior; +use Closure; +use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Behavior; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\Behavior\Timestampable @@ -36,4 +39,5 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } + } diff --git a/src/Phalcon/Mvc/Model/BehaviorInterface.php b/src/Phalcon/Mvc/Model/BehaviorInterface.php index 8d42f024..818e8054 100644 --- a/src/Phalcon/Mvc/Model/BehaviorInterface.php +++ b/src/Phalcon/Mvc/Model/BehaviorInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\BehaviorInterface * @@ -33,4 +35,5 @@ public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method * @param \Phalcon\Mvc\ModelInterface $model */ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); + } diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php index 980c7340..8ac878f0 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -9,7 +9,12 @@ */ namespace Phalcon\Mvc\Model; +use Closure; +use Phalcon\Mvc\Controller\BindModelInterface; +use Phalcon\Mvc\Model\Binder\BindableInterface; use Phalcon\Cache\Adapter\AdapterInterface; +use ReflectionFunction; +use ReflectionMethod; /** * Phalcon\Mvc\Model\Binding @@ -131,4 +136,5 @@ protected function getParamsFromReflection($handler, array $params, string $cach public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface { } + } diff --git a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php index f37da24c..f8d4bafb 100644 --- a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php +++ b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php @@ -24,4 +24,5 @@ interface BindableInterface * @return string|array */ public function getModelName(); + } diff --git a/src/Phalcon/Mvc/Model/BinderInterface.php b/src/Phalcon/Mvc/Model/BinderInterface.php index 8963d43c..29a7e408 100644 --- a/src/Phalcon/Mvc/Model/BinderInterface.php +++ b/src/Phalcon/Mvc/Model/BinderInterface.php @@ -51,4 +51,5 @@ public function getCache(): AdapterInterface; * @return BinderInterface */ public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; + } diff --git a/src/Phalcon/Mvc/Model/Criteria.php b/src/Phalcon/Mvc/Model/Criteria.php index 532ce0b7..cfb8cdcb 100644 --- a/src/Phalcon/Mvc/Model/Criteria.php +++ b/src/Phalcon/Mvc/Model/Criteria.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Di; +use Phalcon\Db\Column; use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\Query\BuilderInterface; /** @@ -536,4 +539,5 @@ public function createBuilder(): BuilderInterface public function execute(): ResultsetInterface { } + } diff --git a/src/Phalcon/Mvc/Model/CriteriaInterface.php b/src/Phalcon/Mvc/Model/CriteriaInterface.php index 419e17a5..a746186a 100644 --- a/src/Phalcon/Mvc/Model/CriteriaInterface.php +++ b/src/Phalcon/Mvc/Model/CriteriaInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Di\DiInterface; + /** * Phalcon\Mvc\Model\CriteriaInterface * @@ -329,4 +331,5 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; + } diff --git a/src/Phalcon/Mvc/Model/Manager.php b/src/Phalcon/Mvc/Model/Manager.php index 777815c2..91280193 100644 --- a/src/Phalcon/Mvc/Model/Manager.php +++ b/src/Phalcon/Mvc/Model/Manager.php @@ -9,11 +9,19 @@ */ namespace Phalcon\Mvc\Model; -use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; -use Phalcon\Events\ManagerInterface as EventsManagerInterface; -use Phalcon\Mvc\Model\Query\BuilderInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\ManagerInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Mvc\Model\Query; +use Phalcon\Mvc\Model\QueryInterface; +use Phalcon\Mvc\Model\Query\Builder; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\Model\BehaviorInterface; +use Phalcon\Events\ManagerInterface as EventsManagerInterface; /** * Phalcon\Mvc\Model\Manager @@ -775,7 +783,7 @@ public function getHasOneRecords(string $modelName, string $modelRelation, \Phal * ``` * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array { @@ -785,7 +793,7 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array * Gets hasMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -805,7 +813,7 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array * Gets hasOneThrough relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array { @@ -815,7 +823,7 @@ public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array * Gets hasManyToMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -825,7 +833,7 @@ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array { @@ -835,7 +843,7 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array * Query all the relationships defined on a model * * @param string $modelName - * @return array + * @return array|RelationInterface[] */ public function getRelations(string $modelName): array { @@ -846,7 +854,7 @@ public function getRelations(string $modelName): array * * @param string $first * @param string $second - * @return array|bool + * @return array|bool|RelationInterface[] */ public function getRelationsBetween(string $first, string $second) { @@ -899,4 +907,5 @@ public function getLastQuery(): QueryInterface public function __destruct() { } + } diff --git a/src/Phalcon/Mvc/Model/ManagerInterface.php b/src/Phalcon/Mvc/Model/ManagerInterface.php index c7d7b345..b53b9bf0 100644 --- a/src/Phalcon/Mvc/Model/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/ManagerInterface.php @@ -10,8 +10,9 @@ namespace Phalcon\Mvc\Model; use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Mvc\Model\Query\BuilderInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Query\BuilderInterface; +use Phalcon\Mvc\Model\QueryInterface; /** * Phalcon\Mvc\Model\ManagerInterface @@ -170,7 +171,7 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b * Gets belongsTo relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; @@ -190,7 +191,7 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * Gets hasMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; @@ -210,7 +211,7 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * Gets hasManyToMany relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; @@ -218,7 +219,7 @@ public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; @@ -226,7 +227,7 @@ public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; * Gets hasOneThrough relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array; @@ -234,7 +235,7 @@ public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array; * Gets hasOne relations defined on a model * * @param \Phalcon\Mvc\ModelInterface $model - * @return array + * @return array|RelationInterface[] */ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; @@ -320,7 +321,7 @@ public function getRelationRecords(RelationInterface $relation, \Phalcon\Mvc\Mod * Query all the relationships defined on a model * * @param string $modelName - * @return array + * @return array|RelationInterface[] */ public function getRelations(string $modelName): array; @@ -329,7 +330,7 @@ public function getRelations(string $modelName): array; * * @param string $first * @param string $second - * @return array|bool + * @return array|bool|RelationInterface[] */ public function getRelationsBetween(string $first, string $second); @@ -486,4 +487,5 @@ public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, st * @return void */ public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); + } diff --git a/src/Phalcon/Mvc/Model/MetaData.php b/src/Phalcon/Mvc/Model/MetaData.php index e6e6309b..019ed6e1 100644 --- a/src/Phalcon/Mvc/Model/MetaData.php +++ b/src/Phalcon/Mvc/Model/MetaData.php @@ -11,7 +11,10 @@ use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\MetaData\Strategy\Introspection; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; +use Phalcon\Mvc\ModelInterface; /** * Phalcon\Mvc\Model\MetaData @@ -639,4 +642,5 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t private function throwWriteException($option) { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Apcu.php b/src/Phalcon/Mvc/Model/MetaData/Apcu.php index 0280a7f7..ea123946 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Apcu.php +++ b/src/Phalcon/Mvc/Model/MetaData/Apcu.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Helper\Arr; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Apcu @@ -41,4 +44,5 @@ class Apcu extends MetaData public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php index 0598634e..2190420c 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php +++ b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Libmemcached @@ -39,4 +42,5 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Memory.php b/src/Phalcon/Mvc/Model/MetaData/Memory.php index 7b6ef87a..2fb40c00 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Memory.php +++ b/src/Phalcon/Mvc/Model/MetaData/Memory.php @@ -10,6 +10,7 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Memory @@ -48,4 +49,5 @@ public function read(string $key): ?array public function write(string $key, array $data) { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Redis.php b/src/Phalcon/Mvc/Model/MetaData/Redis.php index d320f49a..0c78cbe1 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Redis.php +++ b/src/Phalcon/Mvc/Model/MetaData/Redis.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Mvc\Model\MetaData; +use Phalcon\Helper\Arr; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Cache\AdapterFactory; /** * Phalcon\Mvc\Model\MetaData\Redis @@ -53,4 +55,5 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php index 9fdd2e38..511a53f7 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php @@ -9,6 +9,12 @@ */ namespace Phalcon\Mvc\Model\MetaData\Strategy; +use Phalcon\Di\DiInterface; +use Phalcon\Db\Column; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; + /** * This file is part of the Phalcon Framework. * @@ -41,4 +47,5 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php index 0e875ac1..7284f45f 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php @@ -9,6 +9,13 @@ */ namespace Phalcon\Mvc\Model\MetaData\Strategy; +use Phalcon\Di\DiInterface; +use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Db\Column; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Mvc\Model\MetaData; + /** * Phalcon\Mvc\Model\MetaData\Strategy\Introspection * @@ -38,4 +45,5 @@ final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array { } + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php index f2cf8b19..1ca28cf0 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Mvc\Model\MetaData\Strategy; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Di\DiInterface; + /** * This file is part of the Phalcon Framework. * @@ -38,4 +41,5 @@ public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\Di * @return array */ public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; + } diff --git a/src/Phalcon/Mvc/Model/MetaData/Stream.php b/src/Phalcon/Mvc/Model/MetaData/Stream.php index a9c7d71d..73bcd537 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Stream.php +++ b/src/Phalcon/Mvc/Model/MetaData/Stream.php @@ -10,6 +10,7 @@ namespace Phalcon\Mvc\Model\MetaData; use Phalcon\Mvc\Model\MetaData; +use Phalcon\Mvc\Model\Exception; /** * Phalcon\Mvc\Model\MetaData\Stream @@ -69,4 +70,5 @@ public function write(string $key, array $data) private function throwWriteException($option) { } + } diff --git a/src/Phalcon/Mvc/Model/MetaDataInterface.php b/src/Phalcon/Mvc/Model/MetaDataInterface.php index 40abad22..405e2024 100644 --- a/src/Phalcon/Mvc/Model/MetaDataInterface.php +++ b/src/Phalcon/Mvc/Model/MetaDataInterface.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface; /** @@ -249,4 +250,5 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @return void */ public function write(string $key, array $data); + } diff --git a/src/Phalcon/Mvc/Model/Query.php b/src/Phalcon/Mvc/Model/Query.php index 31d41240..67868bd0 100644 --- a/src/Phalcon/Mvc/Model/Query.php +++ b/src/Phalcon/Mvc/Model/Query.php @@ -9,10 +9,21 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Db\Column; +use Phalcon\Db\RawValue; +use Phalcon\Db\ResultInterface; use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; -use Phalcon\Mvc\Model\Query\StatusInterface; +use Phalcon\Helper\Arr; use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Query\Status; +use Phalcon\Mvc\Model\Resultset\Complex; +use Phalcon\Mvc\Model\Query\StatusInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Resultset\Simple; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Db\DialectInterface; +use Phalcon\Mvc\Model\Query\Lang; /** * Phalcon\Mvc\Model\Query @@ -145,7 +156,7 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA protected $uniqueRow; - protected static $_irPhqlCache; + static protected $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -694,4 +705,5 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array public function setTransaction(TransactionInterface $transaction): QueryInterface { } + } diff --git a/src/Phalcon/Mvc/Model/Query/Builder.php b/src/Phalcon/Mvc/Model/Query/Builder.php index 6c919f58..da85cd9c 100644 --- a/src/Phalcon/Mvc/Model/Query/Builder.php +++ b/src/Phalcon/Mvc/Model/Query/Builder.php @@ -9,7 +9,12 @@ */ namespace Phalcon\Mvc\Model\Query; +use Phalcon\Di; +use Phalcon\Db\Column; use Phalcon\Di\DiInterface; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\Model\Exception; +use Phalcon\Di\InjectionAwareInterface; use Phalcon\Mvc\Model\QueryInterface; /** @@ -917,4 +922,5 @@ protected function conditionNotBetween(string $clause, string $operator, string protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } + } diff --git a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php index d9b86f9b..5ecec31b 100644 --- a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php +++ b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php @@ -350,4 +350,5 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; + } diff --git a/src/Phalcon/Mvc/Model/Query/Lang.php b/src/Phalcon/Mvc/Model/Query/Lang.php index 1877eef5..f87716d1 100644 --- a/src/Phalcon/Mvc/Model/Query/Lang.php +++ b/src/Phalcon/Mvc/Model/Query/Lang.php @@ -42,4 +42,5 @@ abstract class Lang public static function parsePHQL(string $phql): array { } + } diff --git a/src/Phalcon/Mvc/Model/Query/Status.php b/src/Phalcon/Mvc/Model/Query/Status.php index 9c6f5668..eb5cc544 100644 --- a/src/Phalcon/Mvc/Model/Query/Status.php +++ b/src/Phalcon/Mvc/Model/Query/Status.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model\Query; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** @@ -60,7 +61,7 @@ public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = /** * Returns the messages produced because of a failed operation * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages(): array { @@ -83,4 +84,5 @@ public function getModel(): ModelInterface public function success(): bool { } + } diff --git a/src/Phalcon/Mvc/Model/Query/StatusInterface.php b/src/Phalcon/Mvc/Model/Query/StatusInterface.php index c63f95dc..f788b95f 100644 --- a/src/Phalcon/Mvc/Model/Query/StatusInterface.php +++ b/src/Phalcon/Mvc/Model/Query/StatusInterface.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model\Query; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** @@ -22,7 +23,7 @@ interface StatusInterface /** * Returns the messages produced by an operation failed * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages(): array; @@ -39,4 +40,5 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; + } diff --git a/src/Phalcon/Mvc/Model/QueryInterface.php b/src/Phalcon/Mvc/Model/QueryInterface.php index 23e22e87..d6dc6696 100644 --- a/src/Phalcon/Mvc/Model/QueryInterface.php +++ b/src/Phalcon/Mvc/Model/QueryInterface.php @@ -121,4 +121,5 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; + } diff --git a/src/Phalcon/Mvc/Model/Relation.php b/src/Phalcon/Mvc/Model/Relation.php index 5b0487aa..a11d2579 100644 --- a/src/Phalcon/Mvc/Model/Relation.php +++ b/src/Phalcon/Mvc/Model/Relation.php @@ -215,4 +215,5 @@ public function isReusable(): bool public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } + } diff --git a/src/Phalcon/Mvc/Model/RelationInterface.php b/src/Phalcon/Mvc/Model/RelationInterface.php index ed33aa25..724df960 100644 --- a/src/Phalcon/Mvc/Model/RelationInterface.php +++ b/src/Phalcon/Mvc/Model/RelationInterface.php @@ -124,4 +124,5 @@ public function isThrough(): bool; * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); + } diff --git a/src/Phalcon/Mvc/Model/ResultInterface.php b/src/Phalcon/Mvc/Model/ResultInterface.php index 3f71406f..79830bcc 100644 --- a/src/Phalcon/Mvc/Model/ResultInterface.php +++ b/src/Phalcon/Mvc/Model/ResultInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\ResultInterface * @@ -24,4 +26,5 @@ interface ResultInterface * @return mixed */ public function setDirtyState(int $dirtyState); + } diff --git a/src/Phalcon/Mvc/Model/Resultset.php b/src/Phalcon/Mvc/Model/Resultset.php index 0cb616a9..56022edb 100644 --- a/src/Phalcon/Mvc/Model/Resultset.php +++ b/src/Phalcon/Mvc/Model/Resultset.php @@ -9,8 +9,19 @@ */ namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; +use ArrayAccess; +use Closure; +use Countable; +use Iterator; +use JsonSerializable; +use Phalcon\Db\Enum; +use Phalcon\Messages\MessageInterface; +use Phalcon\Mvc\Model; use Phalcon\Mvc\ModelInterface; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Storage\Serializer\SerializerInterface; +use SeekableIterator; +use Serializable; /** * Phalcon\Mvc\Model\Resultset @@ -146,7 +157,7 @@ public function delete(\Closure $conditionCallback = null): bool * ``` * * @param callable $filter - * @return array + * @return array|\Phalcon\Mvc\ModelInterface[] */ public function filter($filter): array { @@ -191,7 +202,7 @@ public function getLast(): ?ModelInterface /** * Returns the error messages produced by a batch operation * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages(): array { @@ -349,4 +360,5 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } + } diff --git a/src/Phalcon/Mvc/Model/Resultset/Complex.php b/src/Phalcon/Mvc/Model/Resultset/Complex.php index 4f3240f2..ed6314da 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Complex.php +++ b/src/Phalcon/Mvc/Model/Resultset/Complex.php @@ -9,7 +9,18 @@ */ namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Db\ResultInterface; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\Row; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Storage\Serializer\SerializerInterface; +use stdClass; /** * Phalcon\Mvc\Model\Resultset\Complex @@ -77,4 +88,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Mvc/Model/Resultset/Simple.php b/src/Phalcon/Mvc/Model/Resultset/Simple.php index 0d428d2b..a27f66b0 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Simple.php +++ b/src/Phalcon/Mvc/Model/Resultset/Simple.php @@ -9,8 +9,14 @@ */ namespace Phalcon\Mvc\Model\Resultset; +use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Di; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\Model\Exception; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\ModelInterface; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Phalcon\Mvc\Model\Resultset\Simple @@ -86,4 +92,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Mvc/Model/ResultsetInterface.php b/src/Phalcon/Mvc/Model/ResultsetInterface.php index 7109e39a..6e57b01a 100644 --- a/src/Phalcon/Mvc/Model/ResultsetInterface.php +++ b/src/Phalcon/Mvc/Model/ResultsetInterface.php @@ -9,8 +9,10 @@ */ namespace Phalcon\Mvc\Model; -use Phalcon\Cache\Adapter\AdapterInterface; +use Closure; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; +use Phalcon\Cache\Adapter\AdapterInterface; /** * Phalcon\Mvc\Model\ResultsetInterface @@ -42,7 +44,7 @@ public function delete(\Closure $conditionCallback = null): bool; * ``` * * @param callable $filter - * @return array + * @return array|\Phalcon\Mvc\ModelInterface[] */ public function filter($filter): array; @@ -77,7 +79,7 @@ public function getLast(): ?ModelInterface; /** * Returns the error messages produced by a batch operation * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages(): array; @@ -127,4 +129,5 @@ public function toArray(): array; * @return bool */ public function update($data, \Closure $conditionCallback = null): bool; + } diff --git a/src/Phalcon/Mvc/Model/Row.php b/src/Phalcon/Mvc/Model/Row.php index 5ad81337..1f28c01a 100644 --- a/src/Phalcon/Mvc/Model/Row.php +++ b/src/Phalcon/Mvc/Model/Row.php @@ -9,6 +9,11 @@ */ namespace Phalcon\Mvc\Model; +use ArrayAccess; +use JsonSerializable; +use Phalcon\Mvc\EntityInterface; +use Phalcon\Mvc\ModelInterface; + /** * Phalcon\Mvc\Model\Row * @@ -115,4 +120,5 @@ public function toArray(): array public function writeAttribute(string $attribute, $value) { } + } diff --git a/src/Phalcon/Mvc/Model/Transaction.php b/src/Phalcon/Mvc/Model/Transaction.php index 9f8d9866..88a1802b 100644 --- a/src/Phalcon/Mvc/Model/Transaction.php +++ b/src/Phalcon/Mvc/Model/Transaction.php @@ -9,6 +9,12 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; +use Phalcon\Mvc\Model\TransactionInterface; + /** * Phalcon\Mvc\Model\Transaction * @@ -205,4 +211,5 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte public function throwRollbackException(bool $status): TransactionInterface { } + } diff --git a/src/Phalcon/Mvc/Model/Transaction/Failed.php b/src/Phalcon/Mvc/Model/Transaction/Failed.php index b6555617..24590b59 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Failed.php +++ b/src/Phalcon/Mvc/Model/Transaction/Failed.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\ModelInterface; /** @@ -44,9 +45,10 @@ public function getRecord(): ModelInterface /** * Returns validation record messages which stop the transaction * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getRecordMessages(): array { } + } diff --git a/src/Phalcon/Mvc/Model/Transaction/Manager.php b/src/Phalcon/Mvc/Model/Transaction/Manager.php index 28fd6173..9949b381 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Manager.php +++ b/src/Phalcon/Mvc/Model/Transaction/Manager.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\Model\Transaction; +use Phalcon\Di; use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; +use Phalcon\Mvc\Model\Transaction; use Phalcon\Mvc\Model\TransactionInterface; /** @@ -245,4 +248,5 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) { } + } diff --git a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php index d2acfa22..7bde20da 100644 --- a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php @@ -107,4 +107,5 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; + } diff --git a/src/Phalcon/Mvc/Model/TransactionInterface.php b/src/Phalcon/Mvc/Model/TransactionInterface.php index 99dba3e3..8f5268b6 100644 --- a/src/Phalcon/Mvc/Model/TransactionInterface.php +++ b/src/Phalcon/Mvc/Model/TransactionInterface.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; + /** * Phalcon\Mvc\Model\TransactionInterface * @@ -107,4 +110,5 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; + } diff --git a/src/Phalcon/Mvc/Model/ValidationFailed.php b/src/Phalcon/Mvc/Model/ValidationFailed.php index 098cc9d4..fec0d493 100644 --- a/src/Phalcon/Mvc/Model/ValidationFailed.php +++ b/src/Phalcon/Mvc/Model/ValidationFailed.php @@ -41,7 +41,7 @@ public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validatio /** * Returns the complete group of messages produced in the validation * - * @return array + * @return array|Message[] */ public function getMessages(): array { @@ -55,4 +55,5 @@ public function getMessages(): array public function getModel(): ModelInterface { } + } diff --git a/src/Phalcon/Mvc/ModelInterface.php b/src/Phalcon/Mvc/ModelInterface.php index ed66717c..b856049b 100644 --- a/src/Phalcon/Mvc/ModelInterface.php +++ b/src/Phalcon/Mvc/ModelInterface.php @@ -10,9 +10,12 @@ namespace Phalcon\Mvc; use Phalcon\Db\Adapter\AdapterInterface; +use Phalcon\Di\DiInterface; +use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\MetaDataInterface; use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Mvc\Model\TransactionInterface; /** * Phalcon\Mvc\ModelInterface @@ -151,7 +154,7 @@ public function getDirtyState(): int; /** * Returns array of validation messages * - * @return array + * @return array|\Phalcon\Messages\MessageInterface[] */ public function getMessages(): array; @@ -344,4 +347,5 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; + } diff --git a/src/Phalcon/Mvc/ModuleDefinitionInterface.php b/src/Phalcon/Mvc/ModuleDefinitionInterface.php index ac195410..2d445b56 100644 --- a/src/Phalcon/Mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/Mvc/ModuleDefinitionInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc; +use Phalcon\Di\DiInterface; + /** * Phalcon\Mvc\ModuleDefinitionInterface * @@ -30,4 +32,5 @@ public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); * @param \Phalcon\Di\DiInterface $container */ public function registerServices(\Phalcon\Di\DiInterface $container); + } diff --git a/src/Phalcon/Mvc/Router.php b/src/Phalcon/Mvc/Router.php index 02751581..65c6e7ef 100644 --- a/src/Phalcon/Mvc/Router.php +++ b/src/Phalcon/Mvc/Router.php @@ -9,8 +9,14 @@ */ namespace Phalcon\Mvc; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Http\RequestInterface; +use Phalcon\Mvc\Router\Exception; +use Phalcon\Mvc\Router\GroupInterface; +use Phalcon\Mvc\Router\Route; use Phalcon\Mvc\Router\RouteInterface; /** @@ -165,8 +171,13 @@ public function __construct(bool $defaultRoutes = true) * ); * ``` * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $httpMethods * @param mixed $position * @return RouteInterface @@ -178,8 +189,13 @@ public function add(string $pattern, $paths = null, $httpMethods = null, $positi /** * Adds a route to the router that only match if the HTTP method is CONNECT * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -190,8 +206,13 @@ public function addConnect(string $pattern, $paths = null, $position = Router::P /** * Adds a route to the router that only match if the HTTP method is DELETE * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -202,8 +223,13 @@ public function addDelete(string $pattern, $paths = null, $position = Router::PO /** * Adds a route to the router that only match if the HTTP method is GET * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -214,8 +240,13 @@ public function addGet(string $pattern, $paths = null, $position = Router::POSIT /** * Adds a route to the router that only match if the HTTP method is HEAD * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -226,8 +257,13 @@ public function addHead(string $pattern, $paths = null, $position = Router::POSI /** * Add a route to the router that only match if the HTTP method is OPTIONS * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -238,8 +274,13 @@ public function addOptions(string $pattern, $paths = null, $position = Router::P /** * Adds a route to the router that only match if the HTTP method is PATCH * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -250,8 +291,13 @@ public function addPatch(string $pattern, $paths = null, $position = Router::POS /** * Adds a route to the router that only match if the HTTP method is POST * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -263,8 +309,13 @@ public function addPost(string $pattern, $paths = null, $position = Router::POSI * Adds a route to the router that only match if the HTTP method is PURGE * (Squid and Varnish support) * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -275,8 +326,13 @@ public function addPurge(string $pattern, $paths = null, $position = Router::POS /** * Adds a route to the router that only match if the HTTP method is PUT * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -287,8 +343,13 @@ public function addPut(string $pattern, $paths = null, $position = Router::POSIT /** * Adds a route to the router that only match if the HTTP method is TRACE * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $position * @return RouteInterface */ @@ -427,7 +488,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ public function getRoutes(): array { @@ -576,4 +637,5 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } + } diff --git a/src/Phalcon/Mvc/Router/Annotations.php b/src/Phalcon/Mvc/Router/Annotations.php index 4fd2e415..db4b9579 100644 --- a/src/Phalcon/Mvc/Router/Annotations.php +++ b/src/Phalcon/Mvc/Router/Annotations.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Mvc\Router; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Router; +use Phalcon\Annotations\Annotation; /** * Phalcon\Mvc\Router\Annotations @@ -133,4 +135,5 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } + } diff --git a/src/Phalcon/Mvc/Router/Group.php b/src/Phalcon/Mvc/Router/Group.php index 084af716..907eebd9 100644 --- a/src/Phalcon/Mvc/Router/Group.php +++ b/src/Phalcon/Mvc/Router/Group.php @@ -91,8 +91,13 @@ public function __construct($paths = null) * $router->add("/about", "About::index"); * ``` * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $httpMethods * @return RouteInterface */ @@ -103,7 +108,12 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI /** * Adds a route to the router that only match if the HTTP method is CONNECT * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -114,7 +124,12 @@ public function addConnect(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is DELETE * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -125,7 +140,12 @@ public function addDelete(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is GET * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -136,7 +156,12 @@ public function addGet(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is HEAD * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -147,7 +172,12 @@ public function addHead(string $pattern, $paths = null): RouteInterface /** * Add a route to the router that only match if the HTTP method is OPTIONS * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -158,7 +188,12 @@ public function addOptions(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PATCH * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -169,7 +204,12 @@ public function addPatch(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is POST * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -180,7 +220,12 @@ public function addPost(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PURGE * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -191,7 +236,12 @@ public function addPurge(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is PUT * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -202,7 +252,12 @@ public function addPut(string $pattern, $paths = null): RouteInterface /** * Adds a route to the router that only match if the HTTP method is TRACE * - * @param string|array $paths + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern * @return RouteInterface */ @@ -270,7 +325,7 @@ public function getPrefix(): string /** * Returns the routes added to the group * - * @return array + * @return array|RouteInterface[] */ public function getRoutes(): array { @@ -309,12 +364,18 @@ public function setPrefix(string $prefix): GroupInterface /** * Adds a route applying the common attributes * + * @param string|array $paths = [ + * 'module => '', + * 'controller' => '', + * 'action' => '', + * 'namespace' => '' + * ] * @param string $pattern - * @param mixed $paths * @param mixed $httpMethods * @return RouteInterface */ protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } + } diff --git a/src/Phalcon/Mvc/Router/GroupInterface.php b/src/Phalcon/Mvc/Router/GroupInterface.php index d68a50db..7a86d77e 100644 --- a/src/Phalcon/Mvc/Router/GroupInterface.php +++ b/src/Phalcon/Mvc/Router/GroupInterface.php @@ -210,7 +210,7 @@ public function getPrefix(): string; /** * Returns the routes added to the group * - * @return array + * @return array|RouteInterface[] */ public function getRoutes(): array; @@ -237,4 +237,5 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; + } diff --git a/src/Phalcon/Mvc/Router/Route.php b/src/Phalcon/Mvc/Router/Route.php index bb9ea158..19f95622 100644 --- a/src/Phalcon/Mvc/Router/Route.php +++ b/src/Phalcon/Mvc/Router/Route.php @@ -50,7 +50,7 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface protected $pattern; - protected static $uniqueId = 0; + static protected $uniqueId = 0; @@ -374,4 +374,5 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } + } diff --git a/src/Phalcon/Mvc/Router/RouteInterface.php b/src/Phalcon/Mvc/Router/RouteInterface.php index 830cf72e..c8930254 100644 --- a/src/Phalcon/Mvc/Router/RouteInterface.php +++ b/src/Phalcon/Mvc/Router/RouteInterface.php @@ -137,4 +137,5 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; + } diff --git a/src/Phalcon/Mvc/RouterInterface.php b/src/Phalcon/Mvc/RouterInterface.php index eca288fe..eae83087 100644 --- a/src/Phalcon/Mvc/RouterInterface.php +++ b/src/Phalcon/Mvc/RouterInterface.php @@ -10,6 +10,7 @@ namespace Phalcon\Mvc; use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Mvc\Router\GroupInterface; /** * Interface for Phalcon\Mvc\Router @@ -186,7 +187,7 @@ public function getParams(): array; /** * Return all the routes defined in the router * - * @return array + * @return array|\Phalcon\Mvc\Router\RouteInterface[] */ public function getRoutes(): array; @@ -260,4 +261,5 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; + } diff --git a/src/Phalcon/Mvc/View.php b/src/Phalcon/Mvc/View.php index 29bd0da4..18898661 100644 --- a/src/Phalcon/Mvc/View.php +++ b/src/Phalcon/Mvc/View.php @@ -9,8 +9,15 @@ */ namespace Phalcon\Mvc; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Events\ManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; +use Phalcon\Mvc\View\Exception; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Mvc\View\Engine\Php as PhpEngine; /** * Phalcon\Mvc\View @@ -821,4 +828,5 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } + } diff --git a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php index 007c9c85..2255dab1 100644 --- a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php +++ b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; use Phalcon\Mvc\ViewBaseInterface; @@ -60,4 +61,5 @@ public function getView(): ViewBaseInterface public function partial(string $partialPath, $params = null) { } + } diff --git a/src/Phalcon/Mvc/View/Engine/EngineInterface.php b/src/Phalcon/Mvc/View/Engine/EngineInterface.php index 78012e02..b0d283c7 100644 --- a/src/Phalcon/Mvc/View/Engine/EngineInterface.php +++ b/src/Phalcon/Mvc/View/Engine/EngineInterface.php @@ -39,4 +39,5 @@ public function partial(string $partialPath, $params = null); * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); + } diff --git a/src/Phalcon/Mvc/View/Engine/Php.php b/src/Phalcon/Mvc/View/Engine/Php.php index 35138e3f..a8b2ac61 100644 --- a/src/Phalcon/Mvc/View/Engine/Php.php +++ b/src/Phalcon/Mvc/View/Engine/Php.php @@ -25,4 +25,5 @@ class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } + } diff --git a/src/Phalcon/Mvc/View/Engine/Volt.php b/src/Phalcon/Mvc/View/Engine/Volt.php index 6192db65..b2ec3a84 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt.php +++ b/src/Phalcon/Mvc/View/Engine/Volt.php @@ -9,8 +9,11 @@ */ namespace Phalcon\Mvc\View\Engine; +use Phalcon\Di\DiInterface; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; use Phalcon\Mvc\View\Engine\Volt\Compiler; +use Phalcon\Mvc\View\Exception; /** * Designer friendly and fast template engine for PHP written in Zephir/C @@ -151,4 +154,5 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } + } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php index 9fe907a5..11a65a55 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Mvc\View\Engine\Volt; +use Closure; use Phalcon\Di\DiInterface; +use Phalcon\Mvc\ViewBaseInterface; +use Phalcon\Di\InjectionAwareInterface; /** * This class reads and compiles Volt templates into PHP plain code @@ -577,4 +580,5 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } + } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php index 08a2dad3..a89fdba6 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc\View\Engine\Volt; +use Phalcon\Mvc\View\Exception as BaseException; + /** * Class for exceptions thrown by Phalcon\Mvc\View */ @@ -36,4 +38,5 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } + } diff --git a/src/Phalcon/Mvc/View/Simple.php b/src/Phalcon/Mvc/View/Simple.php index 7b4e6dd3..67af0f56 100644 --- a/src/Phalcon/Mvc/View/Simple.php +++ b/src/Phalcon/Mvc/View/Simple.php @@ -9,8 +9,16 @@ */ namespace Phalcon\Mvc\View; +use Closure; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; +use Phalcon\Mvc\ViewBaseInterface; +use Phalcon\Mvc\View\Engine\EngineInterface; +use Phalcon\Mvc\View\Engine\Php as PhpEngine; /** * Phalcon\Mvc\View\Simple @@ -328,4 +336,5 @@ protected function loadTemplateEngines(): array final protected function internalRender(string $path, $params) { } + } diff --git a/src/Phalcon/Mvc/ViewBaseInterface.php b/src/Phalcon/Mvc/ViewBaseInterface.php index 494f184a..c01d2115 100644 --- a/src/Phalcon/Mvc/ViewBaseInterface.php +++ b/src/Phalcon/Mvc/ViewBaseInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Mvc; +use Phalcon\Cache\Adapter\AdapterInterface; + /** * Phalcon\Mvc\ViewInterface * @@ -76,4 +78,5 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); + } diff --git a/src/Phalcon/Mvc/ViewInterface.php b/src/Phalcon/Mvc/ViewInterface.php index c791f141..ed02efdb 100644 --- a/src/Phalcon/Mvc/ViewInterface.php +++ b/src/Phalcon/Mvc/ViewInterface.php @@ -202,4 +202,5 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); + } diff --git a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php index 4a919273..351fe3a2 100644 --- a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\Exception; +use Phalcon\Paginator\Repository; use Phalcon\Paginator\RepositoryInterface; /** @@ -96,4 +98,5 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository protected function getRepository(array $properties = null): RepositoryInterface { } + } diff --git a/src/Phalcon/Paginator/Adapter/AdapterInterface.php b/src/Phalcon/Paginator/Adapter/AdapterInterface.php index b39e5b27..e4136ebe 100644 --- a/src/Phalcon/Paginator/Adapter/AdapterInterface.php +++ b/src/Phalcon/Paginator/Adapter/AdapterInterface.php @@ -46,4 +46,5 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); + } diff --git a/src/Phalcon/Paginator/Adapter/Model.php b/src/Phalcon/Paginator/Adapter/Model.php index cca3b9d3..f692741c 100644 --- a/src/Phalcon/Paginator/Adapter/Model.php +++ b/src/Phalcon/Paginator/Adapter/Model.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Paginator\Adapter; +use Phalcon\Helper\Arr; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Mvc\Model\ResultsetInterface; +use Phalcon\Paginator\Exception; use Phalcon\Paginator\RepositoryInterface; /** @@ -86,4 +90,5 @@ class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } + } diff --git a/src/Phalcon/Paginator/Adapter/NativeArray.php b/src/Phalcon/Paginator/Adapter/NativeArray.php index a6bae499..fef477e5 100644 --- a/src/Phalcon/Paginator/Adapter/NativeArray.php +++ b/src/Phalcon/Paginator/Adapter/NativeArray.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Paginator\Adapter; +use Phalcon\Paginator\Exception; use Phalcon\Paginator\RepositoryInterface; /** @@ -45,4 +46,5 @@ class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } + } diff --git a/src/Phalcon/Paginator/Adapter/QueryBuilder.php b/src/Phalcon/Paginator/Adapter/QueryBuilder.php index 45925fcd..e01a2b48 100644 --- a/src/Phalcon/Paginator/Adapter/QueryBuilder.php +++ b/src/Phalcon/Paginator/Adapter/QueryBuilder.php @@ -9,8 +9,10 @@ */ namespace Phalcon\Paginator\Adapter; +use Phalcon\Db\Enum; use Phalcon\Mvc\Model\Query\Builder; use Phalcon\Paginator\RepositoryInterface; +use Phalcon\Paginator\Exception; /** * Phalcon\Paginator\Adapter\QueryBuilder @@ -50,7 +52,11 @@ class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter /** * Phalcon\Paginator\Adapter\QueryBuilder * - * @param array $config + * @param array $config = [ + * 'limit' => 10, + * 'builder' => null, + * 'columns' => '' + * ] */ public function __construct(array $config) { @@ -92,4 +98,5 @@ public function paginate(): RepositoryInterface public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder { } + } diff --git a/src/Phalcon/Paginator/PaginatorFactory.php b/src/Phalcon/Paginator/PaginatorFactory.php index ebe00abd..1509b5b4 100644 --- a/src/Phalcon/Paginator/PaginatorFactory.php +++ b/src/Phalcon/Paginator/PaginatorFactory.php @@ -9,8 +9,9 @@ */ namespace Phalcon\Paginator; -use Phalcon\Factory\AbstractFactory; use Phalcon\Paginator\Adapter\AdapterInterface; +use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. @@ -55,7 +56,19 @@ public function __construct(array $services = array()) * $paginator = (new PaginatorFactory())->load($options); * ``` * + * @param array|\Phalcon\Config = [ + * 'adapter' => 'queryBuilder', + * 'limit' => 20, + * 'page' => 1, + * 'builder' => null + * ] * @param mixed $config + * @param array|\Phalcon\Config = [ + * 'adapter' => 'queryBuilder', + * 'limit' => 20, + * 'page' => 1, + * 'builder' => null + * ] * @return AdapterInterface */ public function load($config): AdapterInterface @@ -79,4 +92,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Paginator/Repository.php b/src/Phalcon/Paginator/Repository.php index 798df280..332c90a8 100644 --- a/src/Phalcon/Paginator/Repository.php +++ b/src/Phalcon/Paginator/Repository.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Paginator; +use JsonSerializable; +use Phalcon\Helper\Arr; + /** * Phalcon\Paginator\Repository * @@ -167,4 +170,5 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } + } diff --git a/src/Phalcon/Paginator/RepositoryInterface.php b/src/Phalcon/Paginator/RepositoryInterface.php index 921f0c17..37835568 100644 --- a/src/Phalcon/Paginator/RepositoryInterface.php +++ b/src/Phalcon/Paginator/RepositoryInterface.php @@ -120,4 +120,5 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; + } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index 59f90e2e..b78f5d0e 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -294,4 +294,5 @@ final public function toJson(int $options = 79): string final public function unserialize($serialized) { } + } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index 07809558..cc55e3ed 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -9,9 +9,11 @@ */ namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; use Phalcon\Security\Random; +use Phalcon\Security\Exception; use Phalcon\Session\ManagerInterface as SessionInterface; /** @@ -63,49 +65,66 @@ class Security extends AbstractInjectionAware const CRYPT_STD_DES = 1; - + /** + * @var int|null + */ protected $defaultHash; - + /** + * @var int + */ protected $numberBytes = 16; - + /** + * @var Random + */ protected $random; - + /** + * @var string}null + */ protected $requestToken; - + /** + * @var string|null + */ protected $token; - + /** + * @var string|null + */ protected $tokenKey; - + /** + * @var string + */ protected $tokenKeySessionId = '$PHALCON/CSRF/KEY$'; - + /** + * @var string + */ protected $tokenValueSessionId = '$PHALCON/CSRF$'; + /** + * @var int + */ + protected $workFactor = 10; - protected $workFactor = 8; - - + /** + * @var SessionInterface|null + */ private $localSession = null; - + /** + * @var RequestInterface|null + */ private $localRequest = null; /** - * @param mixed $workFactor + * @return int */ - public function setWorkFactor($workFactor) - { - } - - - public function getWorkFactor() + public function getWorkFactor(): int { } @@ -189,9 +208,9 @@ public function getRandom(): Random * Returns a number of bytes to be generated by the openssl pseudo random * generator * - * @return string + * @return int */ - public function getRandomBytes(): string + public function getRandomBytes(): int { } @@ -279,13 +298,23 @@ public function setDefaultHash(int $defaultHash): Security * Sets a number of bytes to be generated by the openssl pseudo random * generator * - * @param long $randomBytes + * @param int $randomBytes * @return Security */ public function setRandomBytes(int $randomBytes): Security { } + /** + * Sets the work factor + * + * @param int $workFactor + * @return Security + */ + public function setWorkFactor(int $workFactor): Security + { + } + /** * @return mixed */ @@ -299,4 +328,5 @@ private function getLocalRequest(): ?RequestInterface private function getLocalSession(): ?SessionInterface { } + } diff --git a/src/Phalcon/Security/Random.php b/src/Phalcon/Security/Random.php index 0c309003..ea9b65f9 100644 --- a/src/Phalcon/Security/Random.php +++ b/src/Phalcon/Security/Random.php @@ -282,4 +282,5 @@ public function uuid(): string protected function base(string $alphabet, int $base, $n = null): string { } + } diff --git a/src/Phalcon/Session/Adapter/AbstractAdapter.php b/src/Phalcon/Session/Adapter/AbstractAdapter.php index e0d4fc6e..c563515c 100644 --- a/src/Phalcon/Session/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Session/Adapter/AbstractAdapter.php @@ -10,6 +10,7 @@ namespace Phalcon\Session\Adapter; use Phalcon\Storage\Adapter\AdapterInterface; +use SessionHandlerInterface; /** * This file is part of the Phalcon. @@ -87,4 +88,5 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } + } diff --git a/src/Phalcon/Session/Adapter/Libmemcached.php b/src/Phalcon/Session/Adapter/Libmemcached.php index 248cb73d..d5588187 100644 --- a/src/Phalcon/Session/Adapter/Libmemcached.php +++ b/src/Phalcon/Session/Adapter/Libmemcached.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Session\Adapter; +use Phalcon\Storage\AdapterFactory; + /** * Phalcon\Session\Adapter\Libmemcached */ @@ -18,10 +20,24 @@ class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter /** * Constructor * + * @param array $options = [ + * 'servers' => [ + * [ + * 'host' => 'localhost', + * 'port' => 11211, + * 'weight' => 1, + * + * ] + * ], + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => 'sess-memc-' + * ] * @param \Phalcon\Storage\AdapterFactory $factory - * @param array $options */ public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/Session/Adapter/Noop.php b/src/Phalcon/Session/Adapter/Noop.php index ffd12844..0eeda75f 100644 --- a/src/Phalcon/Session/Adapter/Noop.php +++ b/src/Phalcon/Session/Adapter/Noop.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Session\Adapter; +use SessionHandlerInterface; + /** * Phalcon\Session\Adapter\Noop * @@ -57,7 +59,9 @@ class Noop implements \SessionHandlerInterface /** * Constructor * - * @param array $options + * @param array $options = [ + * 'prefix' => '' + * ] */ public function __construct(array $options = array()) { @@ -133,4 +137,5 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } + } diff --git a/src/Phalcon/Session/Adapter/Redis.php b/src/Phalcon/Session/Adapter/Redis.php index 9a013a2d..fea8ac0d 100644 --- a/src/Phalcon/Session/Adapter/Redis.php +++ b/src/Phalcon/Session/Adapter/Redis.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Session\Adapter; +use Phalcon\Storage\AdapterFactory; + /** * Phalcon\Session\Adapter\Redis */ @@ -18,10 +20,19 @@ class Redis extends \Phalcon\Session\Adapter\AbstractAdapter /** * Constructor * + * @param array $options = [ + * 'prefix' => 'sess-reds-', + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '' + * ] * @param \Phalcon\Storage\AdapterFactory $factory - * @param array $options */ public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) { } + } diff --git a/src/Phalcon/Session/Adapter/Stream.php b/src/Phalcon/Session/Adapter/Stream.php index d1f9cebd..87b0943e 100644 --- a/src/Phalcon/Session/Adapter/Stream.php +++ b/src/Phalcon/Session/Adapter/Stream.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Session\Adapter; +use Phalcon\Helper\Str; +use Phalcon\Session\Exception; + /** * Phalcon\Session\Adapter\Stream * @@ -38,7 +41,12 @@ class Stream extends \Phalcon\Session\Adapter\Noop /** - * @param array $options + * Constructor + * + * @param array $options = [ + * 'prefix' => '', + * 'savePath' => '' + * ] */ public function __construct(array $options = array()) { @@ -87,4 +95,5 @@ public function read($id): string public function write($id, $data): bool { } + } diff --git a/src/Phalcon/Session/Bag.php b/src/Phalcon/Session/Bag.php index 5e2d1468..b8ed5bc5 100644 --- a/src/Phalcon/Session/Bag.php +++ b/src/Phalcon/Session/Bag.php @@ -10,7 +10,9 @@ namespace Phalcon\Session; use Phalcon\Collection; +use Phalcon\Di; use Phalcon\Di\DiInterface; +use Phalcon\Di\InjectionAwareInterface; /** * Phalcon\Session\Bag @@ -105,4 +107,5 @@ public function set(string $element, $value) public function setDI(\Phalcon\Di\DiInterface $container) { } + } diff --git a/src/Phalcon/Session/Manager.php b/src/Phalcon/Session/Manager.php index bb3c27dd..8941957a 100644 --- a/src/Phalcon/Session/Manager.php +++ b/src/Phalcon/Session/Manager.php @@ -10,8 +10,11 @@ namespace Phalcon\Session; use InvalidArgumentException; -use Phalcon\Di\AbstractInjectionAware; +use RuntimeException; use SessionHandlerInterface; +use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Di\DiInterface; +use Phalcon\Helper\Arr; /** * Phalcon\Session\Manager @@ -44,7 +47,9 @@ class Manager extends AbstractInjectionAware implements \Phalcon\Session\Manager /** * Manager constructor. * - * @param array $options + * @param array $options = [ + * 'uniqueId' => null + * ] */ public function __construct(array $options = array()) { @@ -269,4 +274,5 @@ public function status(): int private function getUniqueKey(string $key): string { } + } diff --git a/src/Phalcon/Session/ManagerInterface.php b/src/Phalcon/Session/ManagerInterface.php index 8be38a03..9fd46ea0 100644 --- a/src/Phalcon/Session/ManagerInterface.php +++ b/src/Phalcon/Session/ManagerInterface.php @@ -10,6 +10,7 @@ namespace Phalcon\Session; use InvalidArgumentException; +use RuntimeException; use SessionHandlerInterface; /** @@ -195,4 +196,5 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; + } diff --git a/src/Phalcon/Storage/Adapter/AbstractAdapter.php b/src/Phalcon/Storage/Adapter/AbstractAdapter.php index acf1b438..7159cc00 100644 --- a/src/Phalcon/Storage/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Storage/Adapter/AbstractAdapter.php @@ -10,9 +10,12 @@ namespace Phalcon\Storage\Adapter; use DateInterval; +use DateTime; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Storage\Exception; -use Phalcon\Storage\Serializer\SerializerInterface; use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * This file is part of the Phalcon Framework. @@ -91,10 +94,15 @@ public function getPrefix(): string /** * Sets parameters based on options * + * @param array $options = [ + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options */ - protected function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options) + protected function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -126,9 +134,10 @@ abstract public function delete(string $key): bool; * Reads data from the adapter * * @param string $key + * @param mixed $defaultValue * @return mixed */ - abstract public function get(string $key); + abstract public function get(string $key, $defaultValue = null); /** * Returns the adapter - connects to the storage if not connected @@ -140,9 +149,10 @@ abstract public function getAdapter(); /** * Returns all the keys stored * + * @param string $prefix * @return array */ - abstract public function getKeys(): array; + abstract public function getKeys(string $prefix = ''): array; /** * Checks if an element exists in the cache @@ -171,6 +181,18 @@ abstract public function increment(string $key, int $value = 1); */ abstract public function set(string $key, $value, $ttl = null): bool; + /** + * Filters the keys array based on global and passed prefix + * + * @param mixed $keys + * @param string $prefix + * + * @return array + */ + protected function getFilteredKeys($keys, string $prefix): array + { + } + /** * Returns the key requested, prefixed * @@ -222,4 +244,5 @@ protected function getUnserializedData($content, $defaultValue = null) protected function initSerializer() { } + } diff --git a/src/Phalcon/Storage/Adapter/AdapterInterface.php b/src/Phalcon/Storage/Adapter/AdapterInterface.php index 5c3bc3f0..3260213e 100644 --- a/src/Phalcon/Storage/Adapter/AdapterInterface.php +++ b/src/Phalcon/Storage/Adapter/AdapterInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Storage\Adapter; +use Phalcon\Storage\Serializer\SerializerInterface; + /** * Interface for Phalcon\Logger adapters */ @@ -43,9 +45,10 @@ public function delete(string $key): bool; * Reads data from the adapter * * @param string $key + * @param mixed $defaultValue * @return mixed */ - public function get(string $key); + public function get(string $key, $defaultValue = null); /** * Returns the already connected adapter or connects to the backend @@ -58,9 +61,10 @@ public function getAdapter(); /** * Returns all the keys stored * + * @param string $prefix * @return array */ - public function getKeys(): array; + public function getKeys(string $prefix = ''): array; /** * Returns the prefix for the keys @@ -95,4 +99,5 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; + } diff --git a/src/Phalcon/Storage/Adapter/Apcu.php b/src/Phalcon/Storage/Adapter/Apcu.php index b7b68ef1..c3150976 100644 --- a/src/Phalcon/Storage/Adapter/Apcu.php +++ b/src/Phalcon/Storage/Adapter/Apcu.php @@ -9,6 +9,12 @@ */ namespace Phalcon\Storage\Adapter; +use APCuIterator; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; + /** * Apcu adapter */ @@ -23,10 +29,15 @@ class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter /** * Constructor * + * @param array $options = [ + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -87,8 +98,9 @@ public function getAdapter() * Stores data in the adapter * * @return array + * @param string $prefix */ - public function getKeys(): array + public function getKeys(string $prefix = ''): array { } @@ -128,4 +140,5 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/Storage/Adapter/Libmemcached.php b/src/Phalcon/Storage/Adapter/Libmemcached.php index 9977a0ec..8e600278 100644 --- a/src/Phalcon/Storage/Adapter/Libmemcached.php +++ b/src/Phalcon/Storage/Adapter/Libmemcached.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Storage\Adapter; +use Phalcon\Helper\Arr; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Libmemcached adapter @@ -25,10 +28,22 @@ class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter /** * Libmemcached constructor. * - * @param array $options + * @param array $options = [ + * 'servers' => [ + * [ + * 'host' => '127.0.0.1', + * 'port' => 11211, + * 'weight' => 1 + * ] + * ], + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -93,9 +108,9 @@ public function getAdapter() * Stores data in the adapter * * @return array - * @throws Exception + * @param string $prefix */ - public function getKeys(): array + public function getKeys(string $prefix = ''): array { } @@ -147,4 +162,5 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Memcached $connection) { } + } diff --git a/src/Phalcon/Storage/Adapter/Memory.php b/src/Phalcon/Storage/Adapter/Memory.php index 91db861e..b32d4d38 100644 --- a/src/Phalcon/Storage/Adapter/Memory.php +++ b/src/Phalcon/Storage/Adapter/Memory.php @@ -10,6 +10,10 @@ namespace Phalcon\Storage\Adapter; use Phalcon\Collection; +use Phalcon\Helper\Arr; +use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Memory adapter @@ -19,7 +23,7 @@ class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter /** * @var Collection */ - protected $data = array(); + protected $data; /** * @var array @@ -30,10 +34,15 @@ class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter /** * Constructor * + * @param array $options = [ + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -94,8 +103,9 @@ public function getAdapter() * Stores data in the adapter * * @return array + * @param string $prefix */ - public function getKeys(): array + public function getKeys(string $prefix = ''): array { } @@ -134,4 +144,5 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } + } diff --git a/src/Phalcon/Storage/Adapter/Redis.php b/src/Phalcon/Storage/Adapter/Redis.php index b6baaec3..b49fcb40 100644 --- a/src/Phalcon/Storage/Adapter/Redis.php +++ b/src/Phalcon/Storage/Adapter/Redis.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Storage\Adapter; +use Phalcon\Helper\Arr; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; /** * Redis adapter @@ -25,10 +28,21 @@ class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter /** * Constructor * + * @param array $options = [ + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $options */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -96,8 +110,9 @@ public function getAdapter() * * @return array * @throws Exception + * @param string $prefix */ - public function getKeys(): array + public function getKeys(string $prefix = ''): array { } @@ -149,4 +164,5 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } + } diff --git a/src/Phalcon/Storage/Adapter/Stream.php b/src/Phalcon/Storage/Adapter/Stream.php index 61222306..a15bf621 100644 --- a/src/Phalcon/Storage/Adapter/Stream.php +++ b/src/Phalcon/Storage/Adapter/Stream.php @@ -9,8 +9,15 @@ */ namespace Phalcon\Storage\Adapter; +use FilesystemIterator; use Iterator; +use Phalcon\Helper\Arr; +use Phalcon\Helper\Str; use Phalcon\Storage\Exception; +use Phalcon\Storage\SerializerFactory; +use Phalcon\Storage\Serializer\SerializerInterface; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; /** * Stream adapter @@ -27,21 +34,22 @@ class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter */ protected $options = array(); - /** - * @var bool - */ - private $warning = false; - /** * Stream constructor. * - * @param array $options + * @param array $options = [ + * 'storageDir' => '', + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '' + * ] * * @throws Exception * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $options = array()) + public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) { } @@ -102,9 +110,10 @@ public function getAdapter() /** * Stores data in the adapter * + * @param string $prefix * @return array */ - public function getKeys(): array + public function getKeys(string $prefix = ''): array { } @@ -135,9 +144,9 @@ public function increment(string $key, int $value = 1) /** * Stores data in the adapter * - * @param string $key - * @param mixed $value - * @param null $ttl + * @param string $key + * @param mixed $value + * @param DateInterval|int|null $ttl * * @return bool * @throws \Exception @@ -198,4 +207,5 @@ private function getPayload(string $filepath): array private function isExpired(array $payload): bool { } + } diff --git a/src/Phalcon/Storage/AdapterFactory.php b/src/Phalcon/Storage/AdapterFactory.php index 099c16b5..e458a7ad 100644 --- a/src/Phalcon/Storage/AdapterFactory.php +++ b/src/Phalcon/Storage/AdapterFactory.php @@ -34,15 +34,34 @@ class AdapterFactory extends AbstractFactory * @param SerializerFactory $factory * @param array $services */ - public function __construct(SerializerFactory $factory = null, array $services = array()) + public function __construct(SerializerFactory $factory, array $services = array()) { } /** * Create a new instance of the adapter * + * @param array $options = [ + * 'servers' => [ + * [ + * 'host' => '127.0.0.1', + * 'port' => 11211, + * 'weight' => 1 + * ] + * ], + * 'defaultSerializer' => 'Php', + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => '', + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', + * 'storageDir' => '', + * ] * @param string $name - * @param array $options * @return AdapterInterface */ public function newInstance(string $name, array $options = array()): AdapterInterface @@ -55,4 +74,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Storage/Serializer/AbstractSerializer.php b/src/Phalcon/Storage/Serializer/AbstractSerializer.php index 7dbe671d..ba8429ec 100644 --- a/src/Phalcon/Storage/Serializer/AbstractSerializer.php +++ b/src/Phalcon/Storage/Serializer/AbstractSerializer.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Storage\Serializer; +use Phalcon\Storage\Exception; + /** * This file is part of the Phalcon Framework. * @@ -58,4 +60,5 @@ public function getData() public function setData($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/Base64.php b/src/Phalcon/Storage/Serializer/Base64.php index 45363d98..5956f3c3 100644 --- a/src/Phalcon/Storage/Serializer/Base64.php +++ b/src/Phalcon/Storage/Serializer/Base64.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Storage\Serializer; +use InvalidArgumentException; + /** * This file is part of the Phalcon Framework. * @@ -38,4 +40,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/Igbinary.php b/src/Phalcon/Storage/Serializer/Igbinary.php index c3db0cbe..975beca9 100644 --- a/src/Phalcon/Storage/Serializer/Igbinary.php +++ b/src/Phalcon/Storage/Serializer/Igbinary.php @@ -38,4 +38,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/Json.php b/src/Phalcon/Storage/Serializer/Json.php index 6695c299..f82e5310 100644 --- a/src/Phalcon/Storage/Serializer/Json.php +++ b/src/Phalcon/Storage/Serializer/Json.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Storage\Serializer; +use InvalidArgumentException; +use JsonSerializable; +use Phalcon\Helper\Json; + /** * This file is part of the Phalcon Framework. * @@ -38,4 +42,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/Msgpack.php b/src/Phalcon/Storage/Serializer/Msgpack.php index 44c730ea..65fb50a4 100644 --- a/src/Phalcon/Storage/Serializer/Msgpack.php +++ b/src/Phalcon/Storage/Serializer/Msgpack.php @@ -38,4 +38,5 @@ public function serialize(): ?string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/None.php b/src/Phalcon/Storage/Serializer/None.php index 141510a0..2b8f83c4 100644 --- a/src/Phalcon/Storage/Serializer/None.php +++ b/src/Phalcon/Storage/Serializer/None.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Storage\Serializer; +use InvalidArgumentException; + /** * This file is part of the Phalcon Framework. * @@ -38,4 +40,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/Php.php b/src/Phalcon/Storage/Serializer/Php.php index 40355084..fbfb563c 100644 --- a/src/Phalcon/Storage/Serializer/Php.php +++ b/src/Phalcon/Storage/Serializer/Php.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Storage\Serializer; +use InvalidArgumentException; +use Phalcon\Storage\Exception; + /** * This file is part of the Phalcon Framework. * @@ -38,4 +41,5 @@ public function serialize(): string public function unserialize($data) { } + } diff --git a/src/Phalcon/Storage/Serializer/SerializerInterface.php b/src/Phalcon/Storage/Serializer/SerializerInterface.php index 50a28a44..747a10c6 100644 --- a/src/Phalcon/Storage/Serializer/SerializerInterface.php +++ b/src/Phalcon/Storage/Serializer/SerializerInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Storage\Serializer; +use Serializable; + /** * This file is part of the Phalcon Framework. * @@ -30,4 +32,5 @@ public function getData(); * @return void */ public function setData($data); + } diff --git a/src/Phalcon/Storage/SerializerFactory.php b/src/Phalcon/Storage/SerializerFactory.php index 0ae0be18..bf753855 100644 --- a/src/Phalcon/Storage/SerializerFactory.php +++ b/src/Phalcon/Storage/SerializerFactory.php @@ -47,4 +47,5 @@ public function newInstance(string $name): SerializerInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index bced6d14..9c261da4 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -11,6 +11,8 @@ use Phalcon\Di\DiInterface; use Phalcon\Escaper\EscaperInterface; +use Phalcon\Tag\Select; +use Phalcon\Tag\Exception; use Phalcon\Url\UrlInterface; /** @@ -54,40 +56,40 @@ class Tag const XHTML5 = 11; - protected static $autoEscape = true; + static protected $autoEscape = true; /** * DI Container */ - protected static $container; + static protected $container; /** * Pre-assigned values for components */ - protected static $displayValues; + static protected $displayValues; - protected static $documentAppendTitle = null; + static protected $documentAppendTitle = null; - protected static $documentPrependTitle = null; + static protected $documentPrependTitle = null; /** * HTML document title */ - protected static $documentTitle = null; + static protected $documentTitle = null; - protected static $documentTitleSeparator = null; + static protected $documentTitleSeparator = null; - protected static $documentType = 11; + static protected $documentType = 11; - protected static $escaperService = null; + static protected $escaperService = null; - protected static $urlService = null; + static protected $urlService = null; /** @@ -103,7 +105,12 @@ public static function appendTitle($title) /** * Builds a HTML input[type="check"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function checkField($parameters): string @@ -113,7 +120,12 @@ public static function checkField($parameters): string /** * Builds a HTML input[type="color"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function colorField($parameters): string @@ -123,7 +135,12 @@ public static function colorField($parameters): string /** * Builds a HTML input[type="date"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function dateField($parameters): string @@ -133,7 +150,12 @@ public static function dateField($parameters): string /** * Builds a HTML input[type="datetime"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function dateTimeField($parameters): string @@ -143,7 +165,12 @@ public static function dateTimeField($parameters): string /** * Builds a HTML input[type="datetime-local"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function dateTimeLocalField($parameters): string @@ -164,7 +191,12 @@ public static function displayTo(string $id, $value) /** * Builds a HTML input[type="email"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function emailField($parameters): string @@ -183,7 +215,12 @@ public static function endForm(): string /** * Builds a HTML input[type="file"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'id' => '', + * 'name' => '' + * 'value' => '' + * ] * @return string */ public static function fileField($parameters): string @@ -193,7 +230,14 @@ public static function fileField($parameters): string /** * Builds a HTML FORM tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'method' => 'post', + * 'action' => '', + * 'parameters' => '', + * 'name' => '', + * 'class' => '', + * 'id' => '' + * ] * @return string */ public static function form($parameters): string @@ -304,7 +348,13 @@ public static function hasValue($name): bool /** * Builds a HTML input[type="hidden"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function hiddenField($parameters): string @@ -314,7 +364,12 @@ public static function hiddenField($parameters): string /** * Builds HTML IMG tags * - * @param mixed $parameters + * @param array|string $parameters = [ + * 'src' => '', + * 'class' => '', + * 'id' => '', + * 'name' => '' + * ] * @param bool $local * @return string */ @@ -325,7 +380,12 @@ public static function image($parameters = null, bool $local = true): string /** * Builds a HTML input[type="image"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '' + * ] * @return string */ public static function imageInput($parameters): string @@ -335,7 +395,12 @@ public static function imageInput($parameters): string /** * Builds a SCRIPT[type="javascript"] tag * - * @param mixed $parameters + * @param array|string $parameters = [ + * 'local' => false, + * 'src' => '', + * 'type' => 'text/javascript' + * 'rel' => '' + * ] * @param bool $local * @return string */ @@ -346,6 +411,16 @@ public static function javascriptInclude($parameters = null, bool $local = true) /** * Builds a HTML A tag using framework conventions * + * @param parameters $array |string = [ + * 'action' => '', + * 'text' => '', + * 'local' => false, + * 'query' => '', + * 'class' => '', + * 'name' => '', + * 'href' => '', + * 'id' => '' + * ] * @param mixed $parameters * @param mixed $text * @param mixed $local @@ -358,7 +433,13 @@ public static function linkTo($parameters, $text = null, $local = true): string /** * Builds a HTML input[type="month"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function monthField($parameters): string @@ -368,7 +449,13 @@ public static function monthField($parameters): string /** * Builds a HTML input[type="number"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function numericField($parameters): string @@ -378,7 +465,13 @@ public static function numericField($parameters): string /** * Builds a HTML input[type="password"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function passwordField($parameters): string @@ -398,7 +491,13 @@ public static function prependTitle($title) /** * Builds a HTML input[type="radio"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function radioField($parameters): string @@ -408,7 +507,13 @@ public static function radioField($parameters): string /** * Builds a HTML input[type="range"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function rangeField($parameters): string @@ -418,8 +523,19 @@ public static function rangeField($parameters): string /** * Renders parameters keeping order in their HTML attributes * + * @param array $attributes = [ + * 'rel' => null, + * 'type' => null, + * 'for' => null, + * 'src' => null, + * 'href' => null, + * 'action' => null, + * 'id' => null, + * 'name' => null, + * 'value' => null, + * 'class' => null + * ] * @param string $code - * @param array $attributes * @return string */ public static function renderAttributes(string $code, array $attributes): string @@ -452,7 +568,13 @@ public static function resetInput() /** * Builds a HTML input[type="search"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'class' => '', + * 'name' => '', + * 'src' => '', + * 'id' => '', + * 'value' => '' + * ] * @return string */ public static function searchField($parameters): string @@ -462,7 +584,14 @@ public static function searchField($parameters): string /** * Builds a HTML SELECT tag using a Phalcon\Mvc\Model resultset as options * - * @param mixed $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'useEmpty' => false, + * 'emptyValue' => '', + * 'emptyText' => '', + * ] * @param mixed $data * @return string */ @@ -473,7 +602,14 @@ public static function select($parameters, $data = null): string /** * Builds a HTML SELECT tag using a PHP array for options * - * @param mixed $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'useEmpty' => false, + * 'emptyValue' => '', + * 'emptyText' => '', + * ] * @param mixed $data * @return string */ @@ -602,7 +738,12 @@ public static function tagHtmlClose(string $tagName, bool $useEol = false): stri /** * Builds a HTML input[type="tel"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @return string */ public static function telField($parameters): string @@ -612,6 +753,12 @@ public static function telField($parameters): string /** * Builds a HTML TEXTAREA tag * + * @paraym array parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @param mixed $parameters * @return string */ @@ -622,7 +769,12 @@ public static function textArea($parameters): string /** * Builds a HTML input[type="text"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @return string */ public static function textField($parameters): string @@ -632,6 +784,12 @@ public static function textField($parameters): string /** * Builds a HTML input[type="time"] tag * + * @param array $paramters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @param mixed $parameters * @return string */ @@ -642,6 +800,12 @@ public static function timeField($parameters): string /** * Builds a HTML input[type="url"] tag * + * @param array $paramters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @param mixed $parameters * @return string */ @@ -652,7 +816,12 @@ public static function urlField($parameters): string /** * Builds a HTML input[type="week"] tag * - * @param mixed $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '' + * ] * @return string */ public static function weekField($parameters): string @@ -662,12 +831,19 @@ public static function weekField($parameters): string /** * Builds generic INPUT tags * + * @param array $paramters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'class' => '', + * 'type' => '' + * ] * @param string $type * @param mixed $parameters * @param bool $asValue * @return string */ - final protected static function inputField(string $type, $parameters, bool $asValue = false): string + static final protected function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -678,7 +854,8 @@ final protected static function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - final protected static function inputFieldChecked(string $type, $parameters): string + static final protected function inputFieldChecked(string $type, $parameters): string { } + } diff --git a/src/Phalcon/Tag/Select.php b/src/Phalcon/Tag/Select.php index 687c9fa7..4e2f9ffe 100644 --- a/src/Phalcon/Tag/Select.php +++ b/src/Phalcon/Tag/Select.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Tag; +use Phalcon\Tag as BaseTag; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Mvc\Model\ResultsetInterface; + /** * Phalcon\Tag\Select * @@ -21,7 +25,14 @@ abstract class Select /** * Generates a SELECT tag * - * @param array $parameters + * @param array $parameters = [ + * 'id' => '', + * 'name' => '', + * 'value' => '', + * 'useEmpty' => false, + * 'emptyValue' => '', + * 'emptyText' => '', + * ] * @param array $data * @return string */ @@ -53,4 +64,5 @@ private static function optionsFromArray(array $data, $value, string $closeOptio private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string { } + } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 38a3a944..1b145995 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -9,6 +9,8 @@ */ namespace Phalcon; +use Phalcon\Helper\Str; + /** * Provides utilities to work with texts */ @@ -276,4 +278,5 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } + } diff --git a/src/Phalcon/Translate/Adapter/AbstractAdapter.php b/src/Phalcon/Translate/Adapter/AbstractAdapter.php index 5c2cb5c4..e70d672a 100644 --- a/src/Phalcon/Translate/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Translate/Adapter/AbstractAdapter.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Translate\Adapter; +use Phalcon\Helper\Arr; +use Phalcon\Translate\Exception; use Phalcon\Translate\InterpolatorFactory; /** @@ -110,4 +112,5 @@ public function t(string $translateKey, array $placeholders = array()): string protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/Translate/Adapter/AdapterInterface.php b/src/Phalcon/Translate/Adapter/AdapterInterface.php index c1de0bfc..4dc387dc 100644 --- a/src/Phalcon/Translate/Adapter/AdapterInterface.php +++ b/src/Phalcon/Translate/Adapter/AdapterInterface.php @@ -10,7 +10,7 @@ namespace Phalcon\Translate\Adapter; /** - * Phalcon\Translate\AdapterInterface + * Phalcon\Translate\Adapter\AdapterInterface * * Interface for Phalcon\Translate adapters */ @@ -42,4 +42,5 @@ public function query(string $translateKey, array $placeholders = array()): stri * @return string */ public function t(string $translateKey, array $placeholders = array()): string; + } diff --git a/src/Phalcon/Translate/Adapter/Csv.php b/src/Phalcon/Translate/Adapter/Csv.php index 5410eead..95ad3cd6 100644 --- a/src/Phalcon/Translate/Adapter/Csv.php +++ b/src/Phalcon/Translate/Adapter/Csv.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Translate\Adapter; +use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\InterpolatorFactory; + /** * Phalcon\Translate\Adapter\Csv * @@ -25,8 +29,12 @@ class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAc /** * Phalcon\Translate\Adapter\Csv constructor * + * @param array $options = [ + * 'content' => '', + * 'delimiter' => ';', + * 'enclosure' => '"' + * ] * @param \Phalcon\Translate\InterpolatorFactory $interpolator - * @param array $options */ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) { @@ -65,4 +73,5 @@ public function query(string $index, array $placeholders = array()): string private function load(string $file, int $length, string $delimiter, string $enclosure) { } + } diff --git a/src/Phalcon/Translate/Adapter/Gettext.php b/src/Phalcon/Translate/Adapter/Gettext.php index c6f706e3..befad680 100644 --- a/src/Phalcon/Translate/Adapter/Gettext.php +++ b/src/Phalcon/Translate/Adapter/Gettext.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Translate\Adapter; +use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\InterpolatorFactory; + /** * Phalcon\Translate\Adapter\Gettext * @@ -81,8 +85,13 @@ public function getLocale(): string /** * Phalcon\Translate\Adapter\Gettext constructor * + * @param array $options = [ + * 'locale' => '', + * 'defaultDomain' => '', + * 'directory' => '', + * 'category' => '' + * ] * @param \Phalcon\Translate\InterpolatorFactory $interpolator - * @param array $options */ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) { @@ -218,4 +227,5 @@ protected function getOptionsDefault(): array protected function prepareOptions(array $options) { } + } diff --git a/src/Phalcon/Translate/Adapter/NativeArray.php b/src/Phalcon/Translate/Adapter/NativeArray.php index 09ff3e20..f56d3935 100644 --- a/src/Phalcon/Translate/Adapter/NativeArray.php +++ b/src/Phalcon/Translate/Adapter/NativeArray.php @@ -9,6 +9,10 @@ */ namespace Phalcon\Translate\Adapter; +use ArrayAccess; +use Phalcon\Translate\Exception; +use Phalcon\Translate\InterpolatorFactory; + /** * Phalcon\Translate\Adapter\NativeArray * @@ -30,8 +34,11 @@ class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements /** * Phalcon\Translate\Adapter\NativeArray constructor * + * @param array $options = [ + * 'content' => '', + * 'triggerError' => false + * ] * @param \Phalcon\Translate\InterpolatorFactory $interpolator - * @param array $options */ public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) { @@ -67,4 +74,5 @@ public function notFound(string $index): string public function query(string $index, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/AssociativeArray.php index ea3aad8e..026b5fda 100644 --- a/src/Phalcon/Translate/Interpolator/AssociativeArray.php +++ b/src/Phalcon/Translate/Interpolator/AssociativeArray.php @@ -30,4 +30,5 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn public function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/Translate/Interpolator/IndexedArray.php b/src/Phalcon/Translate/Interpolator/IndexedArray.php index d363ba26..dab117e5 100644 --- a/src/Phalcon/Translate/Interpolator/IndexedArray.php +++ b/src/Phalcon/Translate/Interpolator/IndexedArray.php @@ -30,4 +30,5 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf public function replacePlaceholders(string $translation, array $placeholders = array()): string { } + } diff --git a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php index e3ab9ade..157fa7b4 100644 --- a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php +++ b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php @@ -25,4 +25,5 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; + } diff --git a/src/Phalcon/Translate/InterpolatorFactory.php b/src/Phalcon/Translate/InterpolatorFactory.php index 1a2657ba..d5894d24 100644 --- a/src/Phalcon/Translate/InterpolatorFactory.php +++ b/src/Phalcon/Translate/InterpolatorFactory.php @@ -58,4 +58,5 @@ public function newInstance(string $name): AdapterInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Translate/TranslateFactory.php b/src/Phalcon/Translate/TranslateFactory.php index fbdb6200..6cee0418 100644 --- a/src/Phalcon/Translate/TranslateFactory.php +++ b/src/Phalcon/Translate/TranslateFactory.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Translate; +use Phalcon\Config; use Phalcon\Factory\AbstractFactory; +use Phalcon\Helper\Arr; use Phalcon\Translate\Adapter\AdapterInterface; /** @@ -41,7 +43,33 @@ public function __construct(InterpolatorFactory $interpolator, array $services = /** * Factory to create an instace from a Config object * + * @param array|\Phalcon\Config = [ + * 'adapter' => 'ini, + * 'options' => [ + * 'content' => '', + * 'delimiter' => ';', + * 'enclosure' => '"', + * 'locale' => '', + * 'defaultDomain' => '', + * 'directory' => '', + * 'category' => '' + * 'triggerError' => false + * ] + * ] * @param mixed $config + * @param array|\Phalcon\Config = [ + * 'adapter' => 'ini, + * 'options' => [ + * 'content' => '', + * 'delimiter' => ';', + * 'enclosure' => '"', + * 'locale' => '', + * 'defaultDomain' => '', + * 'directory' => '', + * 'category' => '' + * 'triggerError' => false + * ] + * ] * @return mixed */ public function load($config) @@ -65,4 +93,5 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index 60223859..875d25a9 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -9,8 +9,11 @@ */ namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Mvc\RouterInterface; +use Phalcon\Mvc\Router\RouteInterface; +use Phalcon\Url\Exception; use Phalcon\Url\UrlInterface; /** @@ -93,7 +96,9 @@ public function __construct(\Phalcon\Mvc\RouterInterface $router = null) * ); * ``` * - * @param mixed $uri + * @param array|string $uri = [ + * 'for' => '', + * ] * @param mixed $args * @param bool $local * @param mixed $baseUri @@ -136,7 +141,9 @@ public function getBaseUri(): string * ); * ``` * - * @param mixed $uri + * @param array|string $uri = [ + * 'for' => '' + * ] * @return string */ public function getStatic($uri = null): string @@ -205,4 +212,5 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } + } diff --git a/src/Phalcon/Url/UrlInterface.php b/src/Phalcon/Url/UrlInterface.php index 3a25a9f8..7f5c8764 100644 --- a/src/Phalcon/Url/UrlInterface.php +++ b/src/Phalcon/Url/UrlInterface.php @@ -62,4 +62,5 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; + } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index ed18b42d..febe1975 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -9,9 +9,15 @@ */ namespace Phalcon; +use Phalcon\Di\DiInterface; use Phalcon\Di\Injectable; +use Phalcon\Filter\FilterInterface; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; use Phalcon\Validation\ValidationInterface; +use Phalcon\Validation\Exception; +use Phalcon\Validation\ValidatorInterface; +use Phalcon\Validation\AbstractCombinedFieldsValidator; /** * Allows to validate data using custom or built-in validators @@ -228,4 +234,5 @@ public function validate($data = null, $entity = null): Messages protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool { } + } diff --git a/src/Phalcon/Validation/AbstractValidator.php b/src/Phalcon/Validation/AbstractValidator.php index 92f00e49..8536952d 100644 --- a/src/Phalcon/Validation/AbstractValidator.php +++ b/src/Phalcon/Validation/AbstractValidator.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Validation; +use Phalcon\Collection; +use Phalcon\Helper\Arr; use Phalcon\Messages\Message; +use Phalcon\Validation; /** * This is a base class for validators @@ -159,4 +162,5 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message { } + } diff --git a/src/Phalcon/Validation/AbstractValidatorComposite.php b/src/Phalcon/Validation/AbstractValidatorComposite.php index b1180f8d..e325eab1 100644 --- a/src/Phalcon/Validation/AbstractValidatorComposite.php +++ b/src/Phalcon/Validation/AbstractValidatorComposite.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation; +use Phalcon\Validation; + /** * This is a base class for combined fields validators */ @@ -37,4 +39,5 @@ public function getValidators(): array public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/ValidationInterface.php b/src/Phalcon/Validation/ValidationInterface.php index d8a7caf5..dab50ee1 100644 --- a/src/Phalcon/Validation/ValidationInterface.php +++ b/src/Phalcon/Validation/ValidationInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation; +use Phalcon\Di\Injectable; +use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; /** @@ -132,4 +134,5 @@ public function setLabels(array $labels); * @return Messages */ public function validate($data = null, $entity = null): Messages; + } diff --git a/src/Phalcon/Validation/Validator/Alnum.php b/src/Phalcon/Validation/Validator/Alnum.php index bdd79a8b..5c75c81a 100644 --- a/src/Phalcon/Validation/Validator/Alnum.php +++ b/src/Phalcon/Validation/Validator/Alnum.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +52,19 @@ class Alnum extends AbstractValidator protected $template = 'Field :field must contain only letters and numbers'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +75,5 @@ class Alnum extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Alpha.php b/src/Phalcon/Validation/Validator/Alpha.php index 64b374fd..7dbe8266 100644 --- a/src/Phalcon/Validation/Validator/Alpha.php +++ b/src/Phalcon/Validation/Validator/Alpha.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class Alpha extends AbstractValidator protected $template = 'Field :field must contain only letters'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +76,5 @@ class Alpha extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Between.php b/src/Phalcon/Validation/Validator/Between.php index 40ecc261..756725af 100644 --- a/src/Phalcon/Validation/Validator/Between.php +++ b/src/Phalcon/Validation/Validator/Between.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -62,6 +64,21 @@ class Between extends AbstractValidator protected $template = 'Field :field must be within the range of :min to :max'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'minimum' => 5, + * 'maximum' => 50, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -72,4 +89,5 @@ class Between extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Callback.php b/src/Phalcon/Validation/Validator/Callback.php index 3187fafb..9525d5fe 100644 --- a/src/Phalcon/Validation/Validator/Callback.php +++ b/src/Phalcon/Validation/Validator/Callback.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\ValidatorInterface; use Phalcon\Validation\AbstractValidator; /** @@ -61,6 +64,20 @@ class Callback extends AbstractValidator protected $template = 'Field :field must match the callback function'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'callback' => null, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +88,5 @@ class Callback extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Confirmation.php b/src/Phalcon/Validation/Validator/Confirmation.php index da86e02f..49619823 100644 --- a/src/Phalcon/Validation/Validator/Confirmation.php +++ b/src/Phalcon/Validation/Validator/Confirmation.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; +use Phalcon\Validation\Exception; use Phalcon\Validation\AbstractValidator; /** @@ -56,6 +59,22 @@ class Confirmation extends AbstractValidator protected $template = 'Field :field must be the same as :with'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'with' => '', + * 'labelWith' => '', + * 'ignoreCase' => false, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -77,4 +96,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } + } diff --git a/src/Phalcon/Validation/Validator/CreditCard.php b/src/Phalcon/Validation/Validator/CreditCard.php index be542d77..7402871d 100644 --- a/src/Phalcon/Validation/Validator/CreditCard.php +++ b/src/Phalcon/Validation/Validator/CreditCard.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class CreditCard extends AbstractValidator protected $template = 'Field :field is not valid for a credit card number'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -72,4 +87,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Date.php b/src/Phalcon/Validation/Validator/Date.php index 7f73687e..78b221dc 100644 --- a/src/Phalcon/Validation/Validator/Date.php +++ b/src/Phalcon/Validation/Validator/Date.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Validation\Validator; +use DateTime; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -56,6 +59,20 @@ class Date extends AbstractValidator protected $template = 'Field :field is not a valid date'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'format' => 'Y-m-d', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -75,4 +92,5 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Digit.php b/src/Phalcon/Validation/Validator/Digit.php index c98a06d5..aded9a84 100644 --- a/src/Phalcon/Validation/Validator/Digit.php +++ b/src/Phalcon/Validation/Validator/Digit.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class Digit extends AbstractValidator protected $template = 'Field :field must be numeric'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +76,5 @@ class Digit extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Email.php b/src/Phalcon/Validation/Validator/Email.php index 9d783851..c8a9b38a 100644 --- a/src/Phalcon/Validation/Validator/Email.php +++ b/src/Phalcon/Validation/Validator/Email.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class Email extends AbstractValidator protected $template = 'Field :field must be an email address'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +76,5 @@ class Email extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/ExclusionIn.php b/src/Phalcon/Validation/Validator/ExclusionIn.php index 48552430..4826637c 100644 --- a/src/Phalcon/Validation/Validator/ExclusionIn.php +++ b/src/Phalcon/Validation/Validator/ExclusionIn.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Check if a value is not included into a list of values @@ -62,6 +65,21 @@ class ExclusionIn extends AbstractValidator protected $template = 'Field :field must not be a part of list: :domain'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'domain' => [], + * 'strct' => false, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -72,4 +90,5 @@ class ExclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File.php b/src/Phalcon/Validation/Validator/File.php index 8e036ab0..a05933d3 100644 --- a/src/Phalcon/Validation/Validator/File.php +++ b/src/Phalcon/Validation/Validator/File.php @@ -9,7 +9,17 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Helper\Arr; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidatorComposite; +use Phalcon\Validation\Validator\File\MimeType; +use Phalcon\Validation\Validator\File\Resolution\Equal as EqualResolution; +use Phalcon\Validation\Validator\File\Resolution\Max as MaxResolution; +use Phalcon\Validation\Validator\File\Resolution\Min as MinResolution; +use Phalcon\Validation\Validator\File\Size\Equal as EqualFileSize; +use Phalcon\Validation\Validator\File\Size\Max as MaxFileSize; +use Phalcon\Validation\Validator\File\Size\Min as MinFileSize; /** * Checks if a value has a correct file @@ -84,9 +94,30 @@ class File extends AbstractValidatorComposite /** * Constructor * - * @param array $options + * @param array $options = [ + * 'messageMinSize' => '', + * 'includedMinSize' => false, + * 'minSize' => 100, + * 'maxSize' => 1000, + * 'messageSize' => '', + * 'includedSize' => false, + * 'equalSize' => '', + * 'messageEqualSize' => '', + * 'allowedTypes' => [], + * 'messageType' => '', + * 'maxResolution' => '1000x1000', + * 'messageMaxResolution' => '', + * 'includedMaxResolution' => false, + * 'minResolution => '500x500', + * 'includedMinResolution' => false, + * 'messageMinResolution' => '', + * 'equalResolution' => '1000x1000', + * 'messageEqualResolution' => '', + * 'allowEmpty' => false + * ] */ public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/Validation/Validator/File/AbstractFile.php b/src/Phalcon/Validation/Validator/File/AbstractFile.php index 849cd591..30383155 100644 --- a/src/Phalcon/Validation/Validator/File/AbstractFile.php +++ b/src/Phalcon/Validation/Validator/File/AbstractFile.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Validation\Validator\File; +use Phalcon\Messages\Message; use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; @@ -181,4 +182,5 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } + } diff --git a/src/Phalcon/Validation/Validator/File/MimeType.php b/src/Phalcon/Validation/Validator/File/MimeType.php index 443c35bd..eb0d6f28 100644 --- a/src/Phalcon/Validation/Validator/File/MimeType.php +++ b/src/Phalcon/Validation/Validator/File/MimeType.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Validation\Validator\File; +use Phalcon\Messages\Message; use Phalcon\Validation; +use Phalcon\Validation\Exception; /** * Checks if a value has a correct file mime type @@ -75,4 +77,5 @@ class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php index a12f6db2..cf672b6f 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -56,6 +58,19 @@ class Equal extends AbstractFile protected $template = 'The resolution of the field :field has to be equal :resolution'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'resolution' => '1000x1000' + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -66,4 +81,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Max.php b/src/Phalcon/Validation/Validator/File/Resolution/Max.php index 24db0706..b8e350c9 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Max.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Max.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -61,6 +63,20 @@ class Max extends AbstractFile protected $template = 'File :field exceeds the maximum resolution of :resolution'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'resolution' => '1000x1000', + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +87,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Min.php b/src/Phalcon/Validation/Validator/File/Resolution/Min.php index 35a093c6..9b4f170f 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Min.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Min.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Resolution; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -61,6 +63,20 @@ class Min extends AbstractFile protected $template = 'File :field can not have the minimum resolution of :resolution'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'resolution' => '1000x1000', + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +87,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Size/Equal.php b/src/Phalcon/Validation/Validator/File/Size/Equal.php index 1974832e..b5f968a5 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Size/Equal.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -61,6 +63,19 @@ class Equal extends AbstractFile protected $template = 'File :field does not have the exact :size filesize'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'size' => '2.5MB' + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +86,5 @@ class Equal extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Size/Max.php b/src/Phalcon/Validation/Validator/File/Size/Max.php index 48d4aebf..3f993d32 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Max.php +++ b/src/Phalcon/Validation/Validator/File/Size/Max.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -61,6 +63,20 @@ class Max extends AbstractFile protected $template = 'File :field exceeds the size of :size'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'size' => '2.5MB', + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +87,5 @@ class Max extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/File/Size/Min.php b/src/Phalcon/Validation/Validator/File/Size/Min.php index 621a0439..44aa8a05 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Min.php +++ b/src/Phalcon/Validation/Validator/File/Size/Min.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator\File\Size; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\Validator\File\AbstractFile; /** @@ -61,6 +63,20 @@ class Min extends AbstractFile protected $template = 'File :field can not have the minimum size of :size'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'size' => '2.5MB', + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -71,4 +87,5 @@ class Min extends AbstractFile public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Identical.php b/src/Phalcon/Validation/Validator/Identical.php index 4091901f..35a09e7e 100644 --- a/src/Phalcon/Validation/Validator/Identical.php +++ b/src/Phalcon/Validation/Validator/Identical.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -56,6 +58,21 @@ class Identical extends AbstractValidator protected $template = 'Field :field does not have the expected value'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'accepted' => '', + * 'value' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -66,4 +83,5 @@ class Identical extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/InclusionIn.php b/src/Phalcon/Validation/Validator/InclusionIn.php index 68e790e9..24b67f83 100644 --- a/src/Phalcon/Validation/Validator/InclusionIn.php +++ b/src/Phalcon/Validation/Validator/InclusionIn.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Check if a value is included into a list of values @@ -56,6 +59,21 @@ class InclusionIn extends AbstractValidator protected $template = 'Field :field must be a part of list: :domain'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'domain' => [], + * 'strict' => false, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -66,4 +84,5 @@ class InclusionIn extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Ip.php b/src/Phalcon/Validation/Validator/Ip.php index 1ed667e6..10d0a19e 100644 --- a/src/Phalcon/Validation/Validator/Ip.php +++ b/src/Phalcon/Validation/Validator/Ip.php @@ -9,7 +9,9 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Messages\Message; /** * Check for IP addresses @@ -74,6 +76,21 @@ class Ip extends AbstractValidator protected $template = 'Field :field must be a valid IP address'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowPrivate' => false, + * 'allowReserved' => false, + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -84,4 +101,5 @@ class Ip extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Numericality.php b/src/Phalcon/Validation/Validator/Numericality.php index e7443a15..1213fee8 100644 --- a/src/Phalcon/Validation/Validator/Numericality.php +++ b/src/Phalcon/Validation/Validator/Numericality.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class Numericality extends AbstractValidator protected $template = 'Field :field does not have a valid numeric format'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +76,5 @@ class Numericality extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/PresenceOf.php b/src/Phalcon/Validation/Validator/PresenceOf.php index 9b7e57a4..55e318cd 100644 --- a/src/Phalcon/Validation/Validator/PresenceOf.php +++ b/src/Phalcon/Validation/Validator/PresenceOf.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,19 @@ class PresenceOf extends AbstractValidator protected $template = 'Field :field is required'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +76,5 @@ class PresenceOf extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Regex.php b/src/Phalcon/Validation/Validator/Regex.php index 03fbc77d..7aa942be 100644 --- a/src/Phalcon/Validation/Validator/Regex.php +++ b/src/Phalcon/Validation/Validator/Regex.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -56,6 +58,20 @@ class Regex extends AbstractValidator protected $template = 'Field :field does not match the required format'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false, + * 'pattern' => '' + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -66,4 +82,5 @@ class Regex extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/StringLength.php b/src/Phalcon/Validation/Validator/StringLength.php index 1e332e06..e8fcb442 100644 --- a/src/Phalcon/Validation/Validator/StringLength.php +++ b/src/Phalcon/Validation/Validator/StringLength.php @@ -9,7 +9,12 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation\AbstractValidator; use Phalcon\Validation\AbstractValidatorComposite; +use Phalcon\Validation\Validator\StringLength\Max; +use Phalcon\Validation\Validator\StringLength\Min; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum and minimum constraints @@ -79,9 +84,19 @@ class StringLength extends AbstractValidatorComposite /** * Constructor * - * @param array $options + * @param array $options = [ + * 'min' => 100, + * 'message' => '', + * 'messageMinimum' => '', + * 'included' => '', + * 'includedMinimum' => false, + * 'max' => 1000, + * 'messageMaximum' => '', + * 'includedMaximum' => false + * ] */ public function __construct(array $options = array()) { } + } diff --git a/src/Phalcon/Validation/Validator/StringLength/Max.php b/src/Phalcon/Validation/Validator/StringLength/Max.php index d7a6e675..620efd97 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Max.php +++ b/src/Phalcon/Validation/Validator/StringLength/Max.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified maximum constraints @@ -63,6 +66,21 @@ class Max extends AbstractValidator protected $template = 'Field :field must not exceed :max characters long'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false, + * 'max' => 1000, + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -73,4 +91,5 @@ class Max extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/StringLength/Min.php b/src/Phalcon/Validation/Validator/StringLength/Min.php index 93a22fa2..34fa22db 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Min.php +++ b/src/Phalcon/Validation/Validator/StringLength/Min.php @@ -9,7 +9,10 @@ */ namespace Phalcon\Validation\Validator\StringLength; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; +use Phalcon\Validation\Exception; /** * Validates that a string has the specified minimum constraints @@ -63,6 +66,21 @@ class Min extends AbstractValidator protected $template = 'Field :field must be at least :min characters long'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false, + * 'min' => 1000, + * 'included' => false + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -73,4 +91,5 @@ class Min extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/Validator/Uniqueness.php b/src/Phalcon/Validation/Validator/Uniqueness.php index 4ded9900..c91f3525 100644 --- a/src/Phalcon/Validation/Validator/Uniqueness.php +++ b/src/Phalcon/Validation/Validator/Uniqueness.php @@ -9,7 +9,12 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; +use Phalcon\Validation; use Phalcon\Validation\AbstractCombinedFieldsValidator; +use Phalcon\Validation\Exception; /** * Check that a field is unique in the related table @@ -90,6 +95,22 @@ class Uniqueness extends AbstractCombinedFieldsValidator private $columnMap = null; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false, + * 'convert' => null, + * 'model' => null, + * 'except' => null + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -131,4 +152,5 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } + } diff --git a/src/Phalcon/Validation/Validator/Url.php b/src/Phalcon/Validation/Validator/Url.php index 19f47564..a05abd4c 100644 --- a/src/Phalcon/Validation/Validator/Url.php +++ b/src/Phalcon/Validation/Validator/Url.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation\Validator; +use Phalcon\Messages\Message; +use Phalcon\Validation; use Phalcon\Validation\AbstractValidator; /** @@ -51,6 +53,20 @@ class Url extends AbstractValidator protected $template = 'Field :field must be a url'; + /** + * Constructor + * + * @param array $options = [ + * 'message' => '', + * 'template' => '', + * 'allowEmpty' => false, + * 'options' => [] + * ] + */ + public function __construct(array $options = array()) + { + } + /** * Executes the validation * @@ -61,4 +77,5 @@ class Url extends AbstractValidator public function validate(\Phalcon\Validation $validation, $field): bool { } + } diff --git a/src/Phalcon/Validation/ValidatorCompositeInterface.php b/src/Phalcon/Validation/ValidatorCompositeInterface.php index cb532dfc..28bacbca 100644 --- a/src/Phalcon/Validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/Validation/ValidatorCompositeInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Validation; +use Phalcon\Validation; + /** * This is a base class for combined fields validators */ @@ -30,4 +32,5 @@ public function getValidators(): array; * @return bool */ public function validate(\Phalcon\Validation $validation, $field): bool; + } diff --git a/src/Phalcon/Validation/ValidatorFactory.php b/src/Phalcon/Validation/ValidatorFactory.php index d1253674..818f4c54 100644 --- a/src/Phalcon/Validation/ValidatorFactory.php +++ b/src/Phalcon/Validation/ValidatorFactory.php @@ -11,6 +11,7 @@ use Phalcon\Factory\AbstractFactory; use Phalcon\Factory\ValidatorInterface; +use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. @@ -48,4 +49,5 @@ public function newInstance(string $name): ValidatorInterface protected function getAdapters(): array { } + } diff --git a/src/Phalcon/Validation/ValidatorInterface.php b/src/Phalcon/Validation/ValidatorInterface.php index 2019197f..03bde84b 100644 --- a/src/Phalcon/Validation/ValidatorInterface.php +++ b/src/Phalcon/Validation/ValidatorInterface.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Validation; +use Phalcon\Collection; +use Phalcon\Validation; + /** * Interface for Phalcon\Validation\AbstractValidator */ @@ -73,4 +76,5 @@ public function setTemplates(array $templates): ValidatorInterface; * @param string $template */ public function setTemplate(string $template): ValidatorInterface; + } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index f9904425..07b80a6b 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -92,7 +92,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - final protected static function _getSpecial(int $special): string + protected final static function _getSpecial(int $special): string { } @@ -138,4 +138,5 @@ public static function getId(): string public static function getPart(int $part): string { } + } From 506d25a5612434b995e0a05bde4599596d7b1999 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Sat, 21 Dec 2019 20:30:32 +0100 Subject: [PATCH 25/25] Optimized imports Fixed phpcs --- src/Phalcon/Acl/Adapter/AbstractAdapter.php | 7 +- src/Phalcon/Acl/Adapter/AdapterInterface.php | 5 +- src/Phalcon/Acl/Adapter/Memory.php | 7 +- src/Phalcon/Acl/Component.php | 3 +- src/Phalcon/Acl/ComponentAware.php | 1 - src/Phalcon/Acl/ComponentInterface.php | 1 - src/Phalcon/Acl/Enum.php | 2 - src/Phalcon/Acl/Role.php | 3 +- src/Phalcon/Acl/RoleAware.php | 1 - src/Phalcon/Acl/RoleInterface.php | 1 - .../Annotations/Adapter/AbstractAdapter.php | 7 +- .../Annotations/Adapter/AdapterInterface.php | 5 +- src/Phalcon/Annotations/Adapter/Apcu.php | 7 +- src/Phalcon/Annotations/Adapter/Memory.php | 7 +- src/Phalcon/Annotations/Adapter/Stream.php | 7 +- src/Phalcon/Annotations/Annotation.php | 1 - .../Annotations/AnnotationsFactory.php | 4 +- src/Phalcon/Annotations/Collection.php | 3 +- src/Phalcon/Annotations/Reader.php | 3 +- src/Phalcon/Annotations/ReaderInterface.php | 1 - src/Phalcon/Annotations/Reflection.php | 1 - .../Application/AbstractApplication.php | 11 +- src/Phalcon/Assets/Asset.php | 3 +- src/Phalcon/Assets/Asset/Css.php | 3 +- src/Phalcon/Assets/Asset/Js.php | 3 +- src/Phalcon/Assets/AssetInterface.php | 1 - src/Phalcon/Assets/Collection.php | 3 +- src/Phalcon/Assets/FilterInterface.php | 1 - src/Phalcon/Assets/Filters/Cssmin.php | 3 +- src/Phalcon/Assets/Filters/Jsmin.php | 3 +- src/Phalcon/Assets/Filters/None.php | 3 +- src/Phalcon/Assets/Inline.php | 3 +- src/Phalcon/Assets/Inline/Css.php | 3 +- src/Phalcon/Assets/Inline/Js.php | 3 +- src/Phalcon/Assets/Manager.php | 1 - src/Phalcon/Cache.php | 10 +- src/Phalcon/Cache/Adapter/Apcu.php | 2 +- src/Phalcon/Cache/Adapter/Libmemcached.php | 2 +- src/Phalcon/Cache/Adapter/Memory.php | 2 +- src/Phalcon/Cache/Adapter/Redis.php | 2 +- src/Phalcon/Cache/Adapter/Stream.php | 2 +- src/Phalcon/Cache/AdapterFactory.php | 5 +- src/Phalcon/Cache/CacheFactory.php | 3 +- src/Phalcon/Cache/Exception/Exception.php | 4 +- src/Phalcon/Cli/Console.php | 1 - src/Phalcon/Cli/Dispatcher.php | 3 +- src/Phalcon/Cli/DispatcherInterface.php | 1 - src/Phalcon/Cli/Router.php | 3 +- src/Phalcon/Cli/Router/Route.php | 7 +- src/Phalcon/Cli/Router/RouteInterface.php | 1 - src/Phalcon/Cli/RouterInterface.php | 3 +- src/Phalcon/Cli/Task.php | 7 +- src/Phalcon/Collection.php | 3 +- src/Phalcon/Collection/Exception.php | 2 +- src/Phalcon/Collection/ReadOnly.php | 1 - src/Phalcon/Config.php | 1 - src/Phalcon/Config/Adapter/Grouped.php | 1 - src/Phalcon/Config/Adapter/Ini.php | 1 - src/Phalcon/Config/Adapter/Json.php | 2 - src/Phalcon/Config/Adapter/Php.php | 1 - src/Phalcon/Config/Adapter/Yaml.php | 1 - src/Phalcon/Config/ConfigFactory.php | 3 +- src/Phalcon/Container.php | 7 +- src/Phalcon/Crypt.php | 7 +- src/Phalcon/Crypt/CryptInterface.php | 1 - src/Phalcon/Crypt/Mismatch.php | 2 +- src/Phalcon/Db/AbstractDb.php | 1 - src/Phalcon/Db/Adapter/AbstractAdapter.php | 43 +++-- src/Phalcon/Db/Adapter/AdapterInterface.php | 38 ++-- src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php | 22 ++- src/Phalcon/Db/Adapter/Pdo/Mysql.php | 13 +- src/Phalcon/Db/Adapter/Pdo/Postgresql.php | 13 +- src/Phalcon/Db/Adapter/Pdo/Sqlite.php | 9 +- src/Phalcon/Db/Adapter/PdoFactory.php | 4 +- src/Phalcon/Db/Column.php | 3 +- src/Phalcon/Db/ColumnInterface.php | 1 - src/Phalcon/Db/Dialect.php | 3 +- src/Phalcon/Db/Dialect/Mysql.php | 35 ++-- src/Phalcon/Db/Dialect/Postgresql.php | 31 ++-- src/Phalcon/Db/Dialect/Sqlite.php | 27 ++- src/Phalcon/Db/DialectInterface.php | 1 - src/Phalcon/Db/Enum.php | 2 - src/Phalcon/Db/Index.php | 3 +- src/Phalcon/Db/IndexInterface.php | 1 - src/Phalcon/Db/Profiler.php | 5 +- src/Phalcon/Db/Profiler/Item.php | 1 - src/Phalcon/Db/RawValue.php | 1 - src/Phalcon/Db/Reference.php | 3 +- src/Phalcon/Db/ReferenceInterface.php | 1 - src/Phalcon/Db/Result/Pdo.php | 16 +- src/Phalcon/Db/ResultInterface.php | 7 +- src/Phalcon/Debug.php | 3 +- src/Phalcon/Debug/Dump.php | 1 - src/Phalcon/Di.php | 23 ++- src/Phalcon/Di/AbstractInjectionAware.php | 3 +- src/Phalcon/Di/DiInterface.php | 3 +- .../Exception/ServiceResolutionException.php | 4 +- src/Phalcon/Di/FactoryDefault.php | 4 +- src/Phalcon/Di/FactoryDefault/Cli.php | 1 - src/Phalcon/Di/Injectable.php | 75 +++++--- src/Phalcon/Di/InjectionAwareInterface.php | 1 - src/Phalcon/Di/Service.php | 3 +- src/Phalcon/Di/Service/Builder.php | 17 +- src/Phalcon/Di/ServiceInterface.php | 1 - src/Phalcon/Di/ServiceProviderInterface.php | 1 - src/Phalcon/Dispatcher/AbstractDispatcher.php | 13 +- .../Dispatcher/DispatcherInterface.php | 1 - src/Phalcon/Dispatcher/Exception.php | 2 - src/Phalcon/Domain/Payload/Payload.php | 5 +- src/Phalcon/Domain/Payload/PayloadFactory.php | 1 - .../Domain/Payload/PayloadInterface.php | 2 +- .../Domain/Payload/ReadableInterface.php | 1 - src/Phalcon/Domain/Payload/Status.php | 1 - .../Domain/Payload/WriteableInterface.php | 3 +- src/Phalcon/Escaper.php | 3 +- src/Phalcon/Escaper/EscaperInterface.php | 1 - src/Phalcon/Events/Event.php | 3 +- src/Phalcon/Events/EventInterface.php | 1 - src/Phalcon/Events/EventsAwareInterface.php | 1 - src/Phalcon/Events/Manager.php | 9 +- src/Phalcon/Events/ManagerInterface.php | 1 - src/Phalcon/Exception.php | 5 +- src/Phalcon/Factory/AbstractFactory.php | 1 - src/Phalcon/Filter.php | 3 +- src/Phalcon/Filter/FilterFactory.php | 1 - src/Phalcon/Filter/FilterInterface.php | 1 - src/Phalcon/Filter/Sanitize/AbsInt.php | 1 - src/Phalcon/Filter/Sanitize/Alnum.php | 1 - src/Phalcon/Filter/Sanitize/Alpha.php | 1 - src/Phalcon/Filter/Sanitize/BoolVal.php | 1 - src/Phalcon/Filter/Sanitize/Email.php | 1 - src/Phalcon/Filter/Sanitize/FloatVal.php | 1 - src/Phalcon/Filter/Sanitize/IntVal.php | 1 - src/Phalcon/Filter/Sanitize/Lower.php | 1 - src/Phalcon/Filter/Sanitize/LowerFirst.php | 1 - src/Phalcon/Filter/Sanitize/Regex.php | 1 - src/Phalcon/Filter/Sanitize/Remove.php | 1 - src/Phalcon/Filter/Sanitize/Replace.php | 1 - src/Phalcon/Filter/Sanitize/Special.php | 1 - src/Phalcon/Filter/Sanitize/SpecialFull.php | 1 - src/Phalcon/Filter/Sanitize/StringVal.php | 1 - src/Phalcon/Filter/Sanitize/Striptags.php | 1 - src/Phalcon/Filter/Sanitize/Trim.php | 1 - src/Phalcon/Filter/Sanitize/Upper.php | 1 - src/Phalcon/Filter/Sanitize/UpperFirst.php | 1 - src/Phalcon/Filter/Sanitize/UpperWords.php | 1 - src/Phalcon/Filter/Sanitize/Url.php | 1 - src/Phalcon/Flash/AbstractFlash.php | 13 +- src/Phalcon/Flash/Direct.php | 3 +- src/Phalcon/Flash/FlashInterface.php | 1 - src/Phalcon/Flash/Session.php | 3 +- src/Phalcon/Forms/Element/AbstractElement.php | 25 ++- src/Phalcon/Forms/Element/Check.php | 3 +- src/Phalcon/Forms/Element/Date.php | 3 +- .../Forms/Element/ElementInterface.php | 23 ++- src/Phalcon/Forms/Element/Email.php | 3 +- src/Phalcon/Forms/Element/File.php | 3 +- src/Phalcon/Forms/Element/Hidden.php | 3 +- src/Phalcon/Forms/Element/Numeric.php | 3 +- src/Phalcon/Forms/Element/Password.php | 3 +- src/Phalcon/Forms/Element/Radio.php | 3 +- src/Phalcon/Forms/Element/Select.php | 3 +- src/Phalcon/Forms/Element/Submit.php | 3 +- src/Phalcon/Forms/Element/Text.php | 3 +- src/Phalcon/Forms/Element/TextArea.php | 3 +- src/Phalcon/Forms/Form.php | 13 +- src/Phalcon/Forms/Manager.php | 1 - src/Phalcon/Helper/Arr.php | 1 - src/Phalcon/Helper/Fs.php | 1 - src/Phalcon/Helper/Json.php | 5 +- src/Phalcon/Helper/Number.php | 1 - src/Phalcon/Helper/Str.php | 1 - src/Phalcon/Html/Attributes.php | 3 +- .../Html/Attributes/AttributesInterface.php | 5 +- .../Html/Attributes/RenderInterface.php | 1 - src/Phalcon/Html/Breadcrumbs.php | 1 - src/Phalcon/Html/Helper/AbstractHelper.php | 5 +- src/Phalcon/Html/Helper/Anchor.php | 3 +- src/Phalcon/Html/Helper/AnchorRaw.php | 3 +- src/Phalcon/Html/Helper/Body.php | 3 +- src/Phalcon/Html/Helper/Button.php | 3 +- src/Phalcon/Html/Helper/Close.php | 3 +- src/Phalcon/Html/Helper/Element.php | 3 +- src/Phalcon/Html/Helper/ElementRaw.php | 3 +- src/Phalcon/Html/Helper/Form.php | 3 +- src/Phalcon/Html/Helper/Img.php | 3 +- src/Phalcon/Html/Helper/Label.php | 3 +- src/Phalcon/Html/Helper/TextArea.php | 3 +- src/Phalcon/Html/Link/EvolvableLink.php | 3 +- .../Html/Link/EvolvableLinkProvider.php | 7 +- src/Phalcon/Html/Link/Link.php | 3 +- src/Phalcon/Html/Link/LinkProvider.php | 8 +- src/Phalcon/Html/Link/Serializer/Header.php | 3 +- .../Link/Serializer/SerializerInterface.php | 1 - src/Phalcon/Html/TagFactory.php | 5 +- src/Phalcon/Http/Cookie.php | 9 +- src/Phalcon/Http/Cookie/CookieInterface.php | 1 - src/Phalcon/Http/Message/AbstractCommon.php | 1 - src/Phalcon/Http/Message/AbstractMessage.php | 9 +- src/Phalcon/Http/Message/AbstractRequest.php | 5 +- .../Exception/InvalidArgumentException.php | 2 +- src/Phalcon/Http/Message/Request.php | 3 +- src/Phalcon/Http/Message/RequestFactory.php | 3 +- src/Phalcon/Http/Message/Response.php | 3 +- src/Phalcon/Http/Message/ResponseFactory.php | 3 +- src/Phalcon/Http/Message/ServerRequest.php | 3 +- .../Http/Message/ServerRequestFactory.php | 19 +- src/Phalcon/Http/Message/Stream.php | 3 +- src/Phalcon/Http/Message/Stream/Input.php | 1 - src/Phalcon/Http/Message/Stream/Memory.php | 1 - src/Phalcon/Http/Message/Stream/Temp.php | 1 - src/Phalcon/Http/Message/StreamFactory.php | 3 +- src/Phalcon/Http/Message/UploadedFile.php | 3 +- .../Http/Message/UploadedFileFactory.php | 8 +- src/Phalcon/Http/Message/Uri.php | 3 +- src/Phalcon/Http/Message/UriFactory.php | 3 +- src/Phalcon/Http/Request.php | 5 +- src/Phalcon/Http/Request/File.php | 3 +- src/Phalcon/Http/Request/FileInterface.php | 1 - src/Phalcon/Http/RequestInterface.php | 3 +- src/Phalcon/Http/Response.php | 27 ++- src/Phalcon/Http/Response/Cookies.php | 3 +- .../Http/Response/CookiesInterface.php | 1 - src/Phalcon/Http/Response/Headers.php | 3 +- .../Http/Response/HeadersInterface.php | 1 - src/Phalcon/Http/ResponseInterface.php | 5 +- .../Http/Server/AbstractMiddleware.php | 9 +- .../Http/Server/AbstractRequestHandler.php | 7 +- src/Phalcon/Image/Adapter/AbstractAdapter.php | 5 +- .../Image/Adapter/AdapterInterface.php | 1 - src/Phalcon/Image/Adapter/Gd.php | 5 +- src/Phalcon/Image/Adapter/Imagick.php | 7 +- src/Phalcon/Image/Enum.php | 2 - src/Phalcon/Image/ImageFactory.php | 3 +- src/Phalcon/Kernel.php | 1 - src/Phalcon/Loader.php | 7 +- src/Phalcon/Logger.php | 5 +- .../Logger/Adapter/AbstractAdapter.php | 15 +- .../Logger/Adapter/AdapterInterface.php | 13 +- src/Phalcon/Logger/Adapter/Noop.php | 7 +- src/Phalcon/Logger/Adapter/Stream.php | 7 +- src/Phalcon/Logger/Adapter/Syslog.php | 7 +- src/Phalcon/Logger/AdapterFactory.php | 1 - .../Logger/Formatter/AbstractFormatter.php | 3 +- .../Logger/Formatter/FormatterInterface.php | 5 +- src/Phalcon/Logger/Formatter/Json.php | 8 +- src/Phalcon/Logger/Formatter/Line.php | 7 +- src/Phalcon/Logger/Item.php | 1 - src/Phalcon/Logger/LoggerFactory.php | 3 +- src/Phalcon/Messages/Message.php | 3 +- src/Phalcon/Messages/MessageInterface.php | 1 - src/Phalcon/Messages/Messages.php | 9 +- src/Phalcon/Mvc/Application.php | 1 - src/Phalcon/Mvc/Controller.php | 3 +- .../Mvc/Controller/BindModelInterface.php | 1 - src/Phalcon/Mvc/Dispatcher.php | 3 +- src/Phalcon/Mvc/DispatcherInterface.php | 1 - src/Phalcon/Mvc/EntityInterface.php | 1 - src/Phalcon/Mvc/Micro.php | 23 ++- src/Phalcon/Mvc/Micro/Collection.php | 3 +- src/Phalcon/Mvc/Micro/CollectionInterface.php | 1 - src/Phalcon/Mvc/Micro/LazyLoader.php | 7 +- src/Phalcon/Mvc/Micro/MiddlewareInterface.php | 5 +- src/Phalcon/Mvc/Model.php | 81 +++++---- src/Phalcon/Mvc/Model/Behavior.php | 11 +- src/Phalcon/Mvc/Model/Behavior/SoftDelete.php | 5 +- .../Mvc/Model/Behavior/Timestampable.php | 5 +- src/Phalcon/Mvc/Model/BehaviorInterface.php | 9 +- src/Phalcon/Mvc/Model/Binder.php | 11 +- .../Mvc/Model/Binder/BindableInterface.php | 1 - src/Phalcon/Mvc/Model/BinderInterface.php | 5 +- src/Phalcon/Mvc/Model/Criteria.php | 11 +- src/Phalcon/Mvc/Model/CriteriaInterface.php | 1 - src/Phalcon/Mvc/Model/Manager.php | 171 +++++++++--------- src/Phalcon/Mvc/Model/ManagerInterface.php | 139 +++++++------- src/Phalcon/Mvc/Model/MetaData.php | 107 ++++++----- src/Phalcon/Mvc/Model/MetaData/Apcu.php | 5 +- .../Mvc/Model/MetaData/Libmemcached.php | 5 +- src/Phalcon/Mvc/Model/MetaData/Memory.php | 1 - src/Phalcon/Mvc/Model/MetaData/Redis.php | 5 +- .../Model/MetaData/Strategy/Annotations.php | 15 +- .../Model/MetaData/Strategy/Introspection.php | 15 +- .../MetaData/Strategy/StrategyInterface.php | 15 +- src/Phalcon/Mvc/Model/MetaData/Stream.php | 1 - src/Phalcon/Mvc/Model/MetaDataInterface.php | 97 +++++----- src/Phalcon/Mvc/Model/Query.php | 25 ++- src/Phalcon/Mvc/Model/Query/Builder.php | 11 +- .../Mvc/Model/Query/BuilderInterface.php | 1 - src/Phalcon/Mvc/Model/Query/Lang.php | 1 - src/Phalcon/Mvc/Model/Query/Status.php | 9 +- .../Mvc/Model/Query/StatusInterface.php | 3 +- src/Phalcon/Mvc/Model/QueryInterface.php | 1 - src/Phalcon/Mvc/Model/Relation.php | 3 +- src/Phalcon/Mvc/Model/RelationInterface.php | 1 - src/Phalcon/Mvc/Model/ResultInterface.php | 1 - src/Phalcon/Mvc/Model/Resultset.php | 21 +-- src/Phalcon/Mvc/Model/Resultset/Complex.php | 9 +- src/Phalcon/Mvc/Model/Resultset/Simple.php | 7 +- src/Phalcon/Mvc/Model/ResultsetInterface.php | 13 +- src/Phalcon/Mvc/Model/Row.php | 5 +- src/Phalcon/Mvc/Model/Transaction.php | 22 +-- src/Phalcon/Mvc/Model/Transaction/Failed.php | 9 +- src/Phalcon/Mvc/Model/Transaction/Manager.php | 23 ++- .../Model/Transaction/ManagerInterface.php | 9 +- .../Mvc/Model/TransactionInterface.php | 18 +- src/Phalcon/Mvc/Model/ValidationFailed.php | 7 +- src/Phalcon/Mvc/ModelInterface.php | 22 +-- src/Phalcon/Mvc/ModuleDefinitionInterface.php | 9 +- src/Phalcon/Mvc/Router.php | 17 +- src/Phalcon/Mvc/Router/Annotations.php | 9 +- src/Phalcon/Mvc/Router/Group.php | 3 +- src/Phalcon/Mvc/Router/GroupInterface.php | 1 - src/Phalcon/Mvc/Router/Route.php | 5 +- src/Phalcon/Mvc/Router/RouteInterface.php | 1 - src/Phalcon/Mvc/RouterInterface.php | 11 +- src/Phalcon/Mvc/View.php | 7 +- .../Mvc/View/Engine/AbstractEngine.php | 9 +- .../Mvc/View/Engine/EngineInterface.php | 1 - src/Phalcon/Mvc/View/Engine/Php.php | 3 +- src/Phalcon/Mvc/View/Engine/Volt.php | 7 +- src/Phalcon/Mvc/View/Engine/Volt/Compiler.php | 11 +- .../Mvc/View/Engine/Volt/Exception.php | 3 +- src/Phalcon/Mvc/View/Simple.php | 7 +- src/Phalcon/Mvc/ViewBaseInterface.php | 1 - src/Phalcon/Mvc/ViewInterface.php | 3 +- .../Paginator/Adapter/AbstractAdapter.php | 7 +- .../Paginator/Adapter/AdapterInterface.php | 1 - src/Phalcon/Paginator/Adapter/Model.php | 3 +- src/Phalcon/Paginator/Adapter/NativeArray.php | 3 +- .../Paginator/Adapter/QueryBuilder.php | 7 +- src/Phalcon/Paginator/PaginatorFactory.php | 6 +- src/Phalcon/Paginator/Repository.php | 3 +- src/Phalcon/Paginator/RepositoryInterface.php | 1 - src/Phalcon/Registry.php | 3 +- src/Phalcon/Security.php | 7 +- src/Phalcon/Security/Random.php | 1 - .../Session/Adapter/AbstractAdapter.php | 3 +- src/Phalcon/Session/Adapter/Libmemcached.php | 7 +- src/Phalcon/Session/Adapter/Noop.php | 3 +- src/Phalcon/Session/Adapter/Redis.php | 7 +- src/Phalcon/Session/Adapter/Stream.php | 3 +- src/Phalcon/Session/Bag.php | 7 +- src/Phalcon/Session/Manager.php | 7 +- src/Phalcon/Session/ManagerInterface.php | 5 +- .../Storage/Adapter/AbstractAdapter.php | 7 +- .../Storage/Adapter/AdapterInterface.php | 1 - src/Phalcon/Storage/Adapter/Apcu.php | 7 +- src/Phalcon/Storage/Adapter/Libmemcached.php | 14 +- src/Phalcon/Storage/Adapter/Memory.php | 7 +- src/Phalcon/Storage/Adapter/Redis.php | 7 +- src/Phalcon/Storage/Adapter/Stream.php | 7 +- src/Phalcon/Storage/AdapterFactory.php | 1 - .../Storage/Serializer/AbstractSerializer.php | 3 +- src/Phalcon/Storage/Serializer/Base64.php | 3 +- src/Phalcon/Storage/Serializer/Igbinary.php | 3 +- src/Phalcon/Storage/Serializer/Json.php | 4 +- src/Phalcon/Storage/Serializer/Msgpack.php | 3 +- src/Phalcon/Storage/Serializer/None.php | 3 +- src/Phalcon/Storage/Serializer/Php.php | 3 +- .../Serializer/SerializerInterface.php | 3 +- src/Phalcon/Storage/SerializerFactory.php | 1 - src/Phalcon/Tag.php | 29 ++- src/Phalcon/Tag/Select.php | 5 +- src/Phalcon/Text.php | 1 - .../Translate/Adapter/AbstractAdapter.php | 7 +- .../Translate/Adapter/AdapterInterface.php | 1 - src/Phalcon/Translate/Adapter/Csv.php | 7 +- src/Phalcon/Translate/Adapter/Gettext.php | 7 +- src/Phalcon/Translate/Adapter/NativeArray.php | 7 +- .../Interpolator/AssociativeArray.php | 3 +- .../Translate/Interpolator/IndexedArray.php | 3 +- .../Interpolator/InterpolatorInterface.php | 1 - src/Phalcon/Translate/InterpolatorFactory.php | 1 - src/Phalcon/Translate/TranslateFactory.php | 5 +- src/Phalcon/Url.php | 7 +- src/Phalcon/Url/UrlInterface.php | 1 - src/Phalcon/Validation.php | 19 +- .../AbstractCombinedFieldsValidator.php | 2 +- src/Phalcon/Validation/AbstractValidator.php | 21 +-- .../Validation/AbstractValidatorComposite.php | 7 +- .../Validation/ValidationInterface.php | 5 +- src/Phalcon/Validation/Validator/Alnum.php | 5 +- src/Phalcon/Validation/Validator/Alpha.php | 5 +- src/Phalcon/Validation/Validator/Between.php | 5 +- src/Phalcon/Validation/Validator/Callback.php | 5 +- .../Validation/Validator/Confirmation.php | 5 +- .../Validation/Validator/CreditCard.php | 5 +- src/Phalcon/Validation/Validator/Date.php | 5 +- src/Phalcon/Validation/Validator/Digit.php | 5 +- src/Phalcon/Validation/Validator/Email.php | 5 +- .../Validation/Validator/ExclusionIn.php | 5 +- src/Phalcon/Validation/Validator/File.php | 1 - .../Validator/File/AbstractFile.php | 11 +- .../Validation/Validator/File/MimeType.php | 5 +- .../Validator/File/Resolution/Equal.php | 5 +- .../Validator/File/Resolution/Max.php | 5 +- .../Validator/File/Resolution/Min.php | 5 +- .../Validation/Validator/File/Size/Equal.php | 5 +- .../Validation/Validator/File/Size/Max.php | 5 +- .../Validation/Validator/File/Size/Min.php | 5 +- .../Validation/Validator/Identical.php | 5 +- .../Validation/Validator/InclusionIn.php | 5 +- src/Phalcon/Validation/Validator/Ip.php | 5 +- .../Validation/Validator/Numericality.php | 5 +- .../Validation/Validator/PresenceOf.php | 5 +- src/Phalcon/Validation/Validator/Regex.php | 5 +- .../Validation/Validator/StringLength.php | 1 - .../Validation/Validator/StringLength/Max.php | 5 +- .../Validation/Validator/StringLength/Min.php | 5 +- .../Validation/Validator/Uniqueness.php | 9 +- src/Phalcon/Validation/Validator/Url.php | 5 +- .../ValidatorCompositeInterface.php | 5 +- src/Phalcon/Validation/ValidatorFactory.php | 1 - src/Phalcon/Validation/ValidatorInterface.php | 7 +- src/Phalcon/Version.php | 3 +- test/scan.php | 28 +++ 416 files changed, 1233 insertions(+), 1559 deletions(-) create mode 100644 test/scan.php diff --git a/src/Phalcon/Acl/Adapter/AbstractAdapter.php b/src/Phalcon/Acl/Adapter/AbstractAdapter.php index fe90af61..6c11e916 100644 --- a/src/Phalcon/Acl/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Acl/Adapter/AbstractAdapter.php @@ -15,7 +15,7 @@ /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Active access which the list is checking if some role can access it @@ -121,11 +121,10 @@ public function setDefaultAction(int $defaultAccess) /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Acl/Adapter/AdapterInterface.php b/src/Phalcon/Acl/Adapter/AdapterInterface.php index 58fde935..8197d508 100644 --- a/src/Phalcon/Acl/Adapter/AdapterInterface.php +++ b/src/Phalcon/Acl/Adapter/AdapterInterface.php @@ -130,14 +130,14 @@ public function getNoArgumentsDefaultAction(): int; /** * Return an array with every role registered in the list * - * @return array|\Phalcon\Acl\RoleInterface[] + * @return array|RoleInterface[] */ public function getRoles(): array; /** * Return an array with every component registered in the list * - * @return array|\Phalcon\Acl\ComponentInterface[] + * @return array|ComponentInterface[] */ public function getComponents(): array; @@ -185,5 +185,4 @@ public function setDefaultAction(int $defaultAccess); * @return void */ public function setNoArgumentsDefaultAction(int $defaultAccess); - } diff --git a/src/Phalcon/Acl/Adapter/Memory.php b/src/Phalcon/Acl/Adapter/Memory.php index 9d367571..ed76a85a 100644 --- a/src/Phalcon/Acl/Adapter/Memory.php +++ b/src/Phalcon/Acl/Adapter/Memory.php @@ -83,7 +83,7 @@ * } * ``` */ -class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * Access @@ -371,7 +371,7 @@ public function getNoArgumentsDefaultAction(): int /** * Return an array with every role registered in the list * - * @return array|\Phalcon\Acl\RoleInterface[] + * @return array|RoleInterface[] */ public function getRoles(): array { @@ -380,7 +380,7 @@ public function getRoles(): array /** * Return an array with every component registered in the list * - * @return array|\Phalcon\Acl\ComponentInterface[] + * @return array|ComponentInterface[] */ public function getComponents(): array { @@ -464,5 +464,4 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } - } diff --git a/src/Phalcon/Acl/Component.php b/src/Phalcon/Acl/Component.php index 66c8319f..ea46a65a 100644 --- a/src/Phalcon/Acl/Component.php +++ b/src/Phalcon/Acl/Component.php @@ -12,7 +12,7 @@ /** * This class defines component entity and its description */ -class Component implements \Phalcon\Acl\ComponentInterface +class Component implements ComponentInterface { /** * Component description @@ -65,5 +65,4 @@ public function __toString(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/Acl/ComponentAware.php b/src/Phalcon/Acl/ComponentAware.php index 37b68783..a631e35b 100644 --- a/src/Phalcon/Acl/ComponentAware.php +++ b/src/Phalcon/Acl/ComponentAware.php @@ -21,5 +21,4 @@ interface ComponentAware * @return string */ public function getComponentName(): string; - } diff --git a/src/Phalcon/Acl/ComponentInterface.php b/src/Phalcon/Acl/ComponentInterface.php index 92284e37..3cc7b050 100644 --- a/src/Phalcon/Acl/ComponentInterface.php +++ b/src/Phalcon/Acl/ComponentInterface.php @@ -35,5 +35,4 @@ public function getName(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/Acl/Enum.php b/src/Phalcon/Acl/Enum.php index 31c3e271..b6d62470 100644 --- a/src/Phalcon/Acl/Enum.php +++ b/src/Phalcon/Acl/Enum.php @@ -19,6 +19,4 @@ class Enum const DENY = 0; - - } diff --git a/src/Phalcon/Acl/Role.php b/src/Phalcon/Acl/Role.php index 784d988f..1b69208b 100644 --- a/src/Phalcon/Acl/Role.php +++ b/src/Phalcon/Acl/Role.php @@ -12,7 +12,7 @@ /** * This class defines role entity and its description */ -class Role implements \Phalcon\Acl\RoleInterface +class Role implements RoleInterface { /** * Role name @@ -65,5 +65,4 @@ public function getDescription(): string public function __construct(string $name, string $description = null) { } - } diff --git a/src/Phalcon/Acl/RoleAware.php b/src/Phalcon/Acl/RoleAware.php index 2f1a3fb9..2ffaf09f 100644 --- a/src/Phalcon/Acl/RoleAware.php +++ b/src/Phalcon/Acl/RoleAware.php @@ -21,5 +21,4 @@ interface RoleAware * @return string */ public function getRoleName(): string; - } diff --git a/src/Phalcon/Acl/RoleInterface.php b/src/Phalcon/Acl/RoleInterface.php index edfc723a..87beb275 100644 --- a/src/Phalcon/Acl/RoleInterface.php +++ b/src/Phalcon/Acl/RoleInterface.php @@ -35,5 +35,4 @@ public function getDescription(): string; * @return string */ public function __toString(): string; - } diff --git a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php index daf66dc7..bc523ea2 100644 --- a/src/Phalcon/Annotations/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Annotations/Adapter/AbstractAdapter.php @@ -18,7 +18,7 @@ /** * This is the base class for Phalcon\Annotations adapters */ -abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * @var array @@ -95,10 +95,9 @@ public function getReader(): ReaderInterface /** * Sets the annotations parser * - * @param \Phalcon\Annotations\ReaderInterface $reader + * @param ReaderInterface $reader */ - public function setReader(\Phalcon\Annotations\ReaderInterface $reader) + public function setReader(ReaderInterface $reader) { } - } diff --git a/src/Phalcon/Annotations/Adapter/AdapterInterface.php b/src/Phalcon/Annotations/Adapter/AdapterInterface.php index d5a01454..139297fd 100644 --- a/src/Phalcon/Annotations/Adapter/AdapterInterface.php +++ b/src/Phalcon/Annotations/Adapter/AdapterInterface.php @@ -71,8 +71,7 @@ public function getReader(): ReaderInterface; /** * Sets the annotations parser * - * @param \Phalcon\Annotations\ReaderInterface $reader + * @param ReaderInterface $reader */ - public function setReader(\Phalcon\Annotations\ReaderInterface $reader); - + public function setReader(ReaderInterface $reader); } diff --git a/src/Phalcon/Annotations/Adapter/Apcu.php b/src/Phalcon/Annotations/Adapter/Apcu.php index b4eb9fe6..3d47fd6a 100644 --- a/src/Phalcon/Annotations/Adapter/Apcu.php +++ b/src/Phalcon/Annotations/Adapter/Apcu.php @@ -20,7 +20,7 @@ * $annotations = new Apcu(); * ``` */ -class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Apcu extends AbstractAdapter { /** * @var string @@ -59,11 +59,10 @@ public function read(string $key) * Writes parsed annotations to APCu * * @param string $key - * @param \Phalcon\Annotations\Reflection $data + * @param Reflection $data * @return bool */ - public function write(string $key, \Phalcon\Annotations\Reflection $data): bool + public function write(string $key, Reflection $data): bool { } - } diff --git a/src/Phalcon/Annotations/Adapter/Memory.php b/src/Phalcon/Annotations/Adapter/Memory.php index 69d73519..063679a3 100644 --- a/src/Phalcon/Annotations/Adapter/Memory.php +++ b/src/Phalcon/Annotations/Adapter/Memory.php @@ -15,7 +15,7 @@ * Stores the parsed annotations in memory. This adapter is the suitable * development/testing */ -class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * @var mixed @@ -37,11 +37,10 @@ public function read(string $key) * Writes parsed annotations to memory * * @param string $key - * @param \Phalcon\Annotations\Reflection $data + * @param Reflection $data * @return void */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) + public function write(string $key, Reflection $data) { } - } diff --git a/src/Phalcon/Annotations/Adapter/Stream.php b/src/Phalcon/Annotations/Adapter/Stream.php index b5c4a1e1..a8bd147e 100644 --- a/src/Phalcon/Annotations/Adapter/Stream.php +++ b/src/Phalcon/Annotations/Adapter/Stream.php @@ -26,7 +26,7 @@ * ); * ``` */ -class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * @var string @@ -59,11 +59,10 @@ public function read(string $key) * Writes parsed annotations to files * * @param string $key - * @param \Phalcon\Annotations\Reflection $data + * @param Reflection $data * @return void */ - public function write(string $key, \Phalcon\Annotations\Reflection $data) + public function write(string $key, Reflection $data) { } - } diff --git a/src/Phalcon/Annotations/Annotation.php b/src/Phalcon/Annotations/Annotation.php index 9ef3dd5c..243f63a8 100644 --- a/src/Phalcon/Annotations/Annotation.php +++ b/src/Phalcon/Annotations/Annotation.php @@ -128,5 +128,4 @@ public function hasArgument($position): bool public function numberArguments(): int { } - } diff --git a/src/Phalcon/Annotations/AnnotationsFactory.php b/src/Phalcon/Annotations/AnnotationsFactory.php index 051517ab..2acd879c 100644 --- a/src/Phalcon/Annotations/AnnotationsFactory.php +++ b/src/Phalcon/Annotations/AnnotationsFactory.php @@ -10,6 +10,7 @@ namespace Phalcon\Annotations; use Phalcon\Annotations\Adapter\AdapterInterface; +use Phalcon\Config; use Phalcon\Factory\AbstractFactory; use Phalcon\Helper\Arr; @@ -29,7 +30,7 @@ public function __construct(array $services = array()) } /** - * @param array|\Phalcon\Config $config = [ + * @param array|Config $config = [ * 'adapter' => 'apcu', * 'options' => [ * 'prefix' => 'phalcon', @@ -68,5 +69,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Annotations/Collection.php b/src/Phalcon/Annotations/Collection.php index cc123049..17595aab 100644 --- a/src/Phalcon/Annotations/Collection.php +++ b/src/Phalcon/Annotations/Collection.php @@ -29,7 +29,7 @@ * $annotation = $classAnnotations->get("Cacheable"); * ``` */ -class Collection implements \Iterator, \Countable +class Collection implements Iterator, Countable { /** * @var array @@ -143,5 +143,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/Annotations/Reader.php b/src/Phalcon/Annotations/Reader.php index c164bee2..cce8000c 100644 --- a/src/Phalcon/Annotations/Reader.php +++ b/src/Phalcon/Annotations/Reader.php @@ -14,7 +14,7 @@ /** * Parses docblocks returning an array with the found annotations */ -class Reader implements \Phalcon\Annotations\ReaderInterface +class Reader implements ReaderInterface { /** @@ -38,5 +38,4 @@ public function parse(string $className): array public static function parseDocBlock(string $docBlock, $file = null, $line = null): array { } - } diff --git a/src/Phalcon/Annotations/ReaderInterface.php b/src/Phalcon/Annotations/ReaderInterface.php index a8cc3f42..af370c66 100644 --- a/src/Phalcon/Annotations/ReaderInterface.php +++ b/src/Phalcon/Annotations/ReaderInterface.php @@ -32,5 +32,4 @@ public function parse(string $className): array; * @return array */ public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; - } diff --git a/src/Phalcon/Annotations/Reflection.php b/src/Phalcon/Annotations/Reflection.php index 696c51e1..83bb43fa 100644 --- a/src/Phalcon/Annotations/Reflection.php +++ b/src/Phalcon/Annotations/Reflection.php @@ -89,5 +89,4 @@ public function getPropertiesAnnotations() public function getReflectionData(): array { } - } diff --git a/src/Phalcon/Application/AbstractApplication.php b/src/Phalcon/Application/AbstractApplication.php index b4c7a914..64629f54 100644 --- a/src/Phalcon/Application/AbstractApplication.php +++ b/src/Phalcon/Application/AbstractApplication.php @@ -17,7 +17,7 @@ /** * Base class for Phalcon\Cli\Console and Phalcon\Mvc\Application. */ -abstract class AbstractApplication extends Injectable implements \Phalcon\Events\EventsAwareInterface +abstract class AbstractApplication extends Injectable implements EventsAwareInterface { /** * @var DiInterface @@ -43,9 +43,9 @@ abstract class AbstractApplication extends Injectable implements \Phalcon\Events /** * Phalcon\AbstractApplication constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) + public function __construct(DiInterface $container = null) { } @@ -125,11 +125,10 @@ public function setDefaultModule(string $defaultModule): AbstractApplication /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Assets/Asset.php b/src/Phalcon/Assets/Asset.php index 65a2ead6..46e9d927 100644 --- a/src/Phalcon/Assets/Asset.php +++ b/src/Phalcon/Assets/Asset.php @@ -16,7 +16,7 @@ * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); * ``` */ -class Asset implements \Phalcon\Assets\AssetInterface +class Asset implements AssetInterface { /** * @var array | null @@ -304,5 +304,4 @@ public function setType(string $type): AssetInterface public function setPath(string $path): AssetInterface { } - } diff --git a/src/Phalcon/Assets/Asset/Css.php b/src/Phalcon/Assets/Asset/Css.php index 4f6e2da8..644ea27b 100644 --- a/src/Phalcon/Assets/Asset/Css.php +++ b/src/Phalcon/Assets/Asset/Css.php @@ -14,7 +14,7 @@ /** * Represents CSS assets */ -class Css extends \Phalcon\Assets\Asset +class Css extends AssetBase { /** @@ -30,5 +30,4 @@ class Css extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/Assets/Asset/Js.php b/src/Phalcon/Assets/Asset/Js.php index 2273fea0..02e2cb09 100644 --- a/src/Phalcon/Assets/Asset/Js.php +++ b/src/Phalcon/Assets/Asset/Js.php @@ -14,7 +14,7 @@ /** * Represents Javascript assets */ -class Js extends \Phalcon\Assets\Asset +class Js extends AssetBase { /** @@ -30,5 +30,4 @@ class Js extends \Phalcon\Assets\Asset public function __construct(string $path, bool $local = true, bool $filter = true, array $attributes = array(), string $version = null, bool $autoVersion = false) { } - } diff --git a/src/Phalcon/Assets/AssetInterface.php b/src/Phalcon/Assets/AssetInterface.php index b43c3ac9..bbc486c9 100644 --- a/src/Phalcon/Assets/AssetInterface.php +++ b/src/Phalcon/Assets/AssetInterface.php @@ -66,5 +66,4 @@ public function setFilter(bool $filter): AssetInterface; * @return AssetInterface */ public function setType(string $type): AssetInterface; - } diff --git a/src/Phalcon/Assets/Collection.php b/src/Phalcon/Assets/Collection.php index 74bcd61d..59ace8dc 100644 --- a/src/Phalcon/Assets/Collection.php +++ b/src/Phalcon/Assets/Collection.php @@ -19,7 +19,7 @@ /** * Represents a collection of assets */ -class Collection implements \Countable, \Iterator +class Collection implements Countable, Iterator { /** * @var array @@ -499,5 +499,4 @@ public function valid(): bool final protected function addAsset(AssetInterface $asset): bool { } - } diff --git a/src/Phalcon/Assets/FilterInterface.php b/src/Phalcon/Assets/FilterInterface.php index 9fdbdef2..a93e24c8 100644 --- a/src/Phalcon/Assets/FilterInterface.php +++ b/src/Phalcon/Assets/FilterInterface.php @@ -22,5 +22,4 @@ interface FilterInterface * @return string */ public function filter(string $content): string; - } diff --git a/src/Phalcon/Assets/Filters/Cssmin.php b/src/Phalcon/Assets/Filters/Cssmin.php index 5a699cc8..b772fd07 100644 --- a/src/Phalcon/Assets/Filters/Cssmin.php +++ b/src/Phalcon/Assets/Filters/Cssmin.php @@ -15,7 +15,7 @@ * Minify the css - removes comments removes newlines and line feeds keeping * removes last semicolon from last property */ -class Cssmin implements \Phalcon\Assets\FilterInterface +class Cssmin implements FilterInterface { /** @@ -28,5 +28,4 @@ class Cssmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Filters/Jsmin.php b/src/Phalcon/Assets/Filters/Jsmin.php index c4959b95..381bba16 100644 --- a/src/Phalcon/Assets/Filters/Jsmin.php +++ b/src/Phalcon/Assets/Filters/Jsmin.php @@ -16,7 +16,7 @@ * be removed. Tabs will be replaced with spaces. Carriage returns will be * replaced with linefeeds. Most spaces and linefeeds will be removed. */ -class Jsmin implements \Phalcon\Assets\FilterInterface +class Jsmin implements FilterInterface { /** @@ -29,5 +29,4 @@ class Jsmin implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Filters/None.php b/src/Phalcon/Assets/Filters/None.php index cb4bb08c..29d1c080 100644 --- a/src/Phalcon/Assets/Filters/None.php +++ b/src/Phalcon/Assets/Filters/None.php @@ -14,7 +14,7 @@ /** * Returns the content without make any modification to the original source */ -class None implements \Phalcon\Assets\FilterInterface +class None implements FilterInterface { /** @@ -26,5 +26,4 @@ class None implements \Phalcon\Assets\FilterInterface public function filter(string $content): string { } - } diff --git a/src/Phalcon/Assets/Inline.php b/src/Phalcon/Assets/Inline.php index 862368ec..6e7e4ce2 100644 --- a/src/Phalcon/Assets/Inline.php +++ b/src/Phalcon/Assets/Inline.php @@ -16,7 +16,7 @@ * $inline = new \Phalcon\Assets\Inline("js", "alert('hello world');"); * ``` */ -class Inline implements \Phalcon\Assets\AssetInterface +class Inline implements AssetInterface { /** * @var array | null @@ -117,5 +117,4 @@ public function setFilter(bool $filter): AssetInterface public function setType(string $type): AssetInterface { } - } diff --git a/src/Phalcon/Assets/Inline/Css.php b/src/Phalcon/Assets/Inline/Css.php index 14f7b91d..5ec4d234 100644 --- a/src/Phalcon/Assets/Inline/Css.php +++ b/src/Phalcon/Assets/Inline/Css.php @@ -14,7 +14,7 @@ /** * Represents an inlined CSS */ -class Css extends \Phalcon\Assets\Inline +class Css extends InlineBase { /** @@ -27,5 +27,4 @@ class Css extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/Assets/Inline/Js.php b/src/Phalcon/Assets/Inline/Js.php index 22409a46..dc01af1b 100644 --- a/src/Phalcon/Assets/Inline/Js.php +++ b/src/Phalcon/Assets/Inline/Js.php @@ -14,7 +14,7 @@ /** * Represents an inline JavaScript */ -class Js extends \Phalcon\Assets\Inline +class Js extends InlineBase { /** @@ -27,5 +27,4 @@ class Js extends \Phalcon\Assets\Inline public function __construct(string $content, bool $filter = true, $attributes = null) { } - } diff --git a/src/Phalcon/Assets/Manager.php b/src/Phalcon/Assets/Manager.php index c31a164e..f8bd2a77 100644 --- a/src/Phalcon/Assets/Manager.php +++ b/src/Phalcon/Assets/Manager.php @@ -364,5 +364,4 @@ public function useImplicitOutput(bool $implicitOutput): Manager private function getPrefixedPath(Collection $collection, string $path): string { } - } diff --git a/src/Phalcon/Cache.php b/src/Phalcon/Cache.php index aaf9ded6..81c0d2d1 100644 --- a/src/Phalcon/Cache.php +++ b/src/Phalcon/Cache.php @@ -9,6 +9,7 @@ */ namespace Phalcon; +use DateInterval; use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Cache\Exception\Exception; use Phalcon\Cache\Exception\InvalidArgumentException; @@ -19,7 +20,7 @@ * This component offers caching capabilities for your application. * Phalcon\Cache implements PSR-16. */ -class Cache implements \Psr\SimpleCache\CacheInterface +class Cache implements CacheInterface { /** * The adapter @@ -43,7 +44,7 @@ public function getAdapter() * * @param AdapterInterface $adapter The cache adapter */ - public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $adapter) + public function __construct(AdapterInterface $adapter) { } @@ -128,7 +129,7 @@ public function has($key): bool * * @param string $key The key of the item to store. * @param mixed $value The value of the item to store. Must be serializable. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -144,7 +145,7 @@ public function set($key, $value, $ttl = null): bool * Persists a set of key => value pairs in the cache, with an optional TTL. * * @param iterable $values A list of key => value pairs for a multiple-set operation. - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and * the driver supports TTL then the library may set a default value * for it or let the driver take care of that. * @@ -175,5 +176,4 @@ protected function checkKey($key) protected function checkKeys($keys) { } - } diff --git a/src/Phalcon/Cache/Adapter/Apcu.php b/src/Phalcon/Cache/Adapter/Apcu.php index 191e2ec9..4054ddc5 100644 --- a/src/Phalcon/Cache/Adapter/Apcu.php +++ b/src/Phalcon/Cache/Adapter/Apcu.php @@ -15,7 +15,7 @@ /** * Apcu adapter */ -class Apcu extends \Phalcon\Storage\Adapter\Apcu implements CacheAdapterInterface +class Apcu extends StorageApcu implements CacheAdapterInterface { } diff --git a/src/Phalcon/Cache/Adapter/Libmemcached.php b/src/Phalcon/Cache/Adapter/Libmemcached.php index a00deb4a..7c75a9c5 100644 --- a/src/Phalcon/Cache/Adapter/Libmemcached.php +++ b/src/Phalcon/Cache/Adapter/Libmemcached.php @@ -15,7 +15,7 @@ /** * Libmemcached adapter */ -class Libmemcached extends \Phalcon\Storage\Adapter\Libmemcached implements CacheAdapterInterface +class Libmemcached extends StorageLibmemcached implements CacheAdapterInterface { } diff --git a/src/Phalcon/Cache/Adapter/Memory.php b/src/Phalcon/Cache/Adapter/Memory.php index 41619081..69eeecd5 100644 --- a/src/Phalcon/Cache/Adapter/Memory.php +++ b/src/Phalcon/Cache/Adapter/Memory.php @@ -15,7 +15,7 @@ /** * Memory adapter */ -class Memory extends \Phalcon\Storage\Adapter\Memory implements CacheAdapterInterface +class Memory extends StorageMemory implements CacheAdapterInterface { } diff --git a/src/Phalcon/Cache/Adapter/Redis.php b/src/Phalcon/Cache/Adapter/Redis.php index f9551cec..0e7a1949 100644 --- a/src/Phalcon/Cache/Adapter/Redis.php +++ b/src/Phalcon/Cache/Adapter/Redis.php @@ -15,7 +15,7 @@ /** * Redis adapter */ -class Redis extends \Phalcon\Storage\Adapter\Redis implements CacheAdapterInterface +class Redis extends StorageRedis implements CacheAdapterInterface { } diff --git a/src/Phalcon/Cache/Adapter/Stream.php b/src/Phalcon/Cache/Adapter/Stream.php index 376e7a73..35a69e36 100644 --- a/src/Phalcon/Cache/Adapter/Stream.php +++ b/src/Phalcon/Cache/Adapter/Stream.php @@ -15,7 +15,7 @@ /** * Stream adapter */ -class Stream extends \Phalcon\Storage\Adapter\Stream implements CacheAdapterInterface +class Stream extends StorageStream implements CacheAdapterInterface { } diff --git a/src/Phalcon/Cache/AdapterFactory.php b/src/Phalcon/Cache/AdapterFactory.php index 158b44b5..98747798 100644 --- a/src/Phalcon/Cache/AdapterFactory.php +++ b/src/Phalcon/Cache/AdapterFactory.php @@ -28,10 +28,10 @@ class AdapterFactory extends AbstractFactory /** * AdapterFactory constructor. * - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory * @param array $services */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory = null, array $services = array()) + public function __construct(SerializerFactory $factory = null, array $services = array()) { } @@ -73,5 +73,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Cache/CacheFactory.php b/src/Phalcon/Cache/CacheFactory.php index 9ce7d917..3fb89b1c 100644 --- a/src/Phalcon/Cache/CacheFactory.php +++ b/src/Phalcon/Cache/CacheFactory.php @@ -39,7 +39,7 @@ public function __construct(AdapterFactory $factory) /** * Factory to create an instace from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array|Config $config = [ * 'adapter' => 'apcu', * 'options' => [ * 'servers' => [ @@ -99,5 +99,4 @@ public function load($config) public function newInstance(string $name, array $options = array()): CacheInterface { } - } diff --git a/src/Phalcon/Cache/Exception/Exception.php b/src/Phalcon/Cache/Exception/Exception.php index d8df7b13..4bb6fd79 100644 --- a/src/Phalcon/Cache/Exception/Exception.php +++ b/src/Phalcon/Cache/Exception/Exception.php @@ -9,10 +9,12 @@ */ namespace Phalcon\Cache\Exception; +use Psr\SimpleCache\CacheException; + /** * Exceptions thrown in Phalcon\Cache will use this class */ -class Exception extends \Phalcon\Exception implements \Psr\SimpleCache\CacheException +class Exception extends \Phalcon\Exception implements CacheException { } diff --git a/src/Phalcon/Cli/Console.php b/src/Phalcon/Cli/Console.php index 8f6b76b0..8dfa9988 100644 --- a/src/Phalcon/Cli/Console.php +++ b/src/Phalcon/Cli/Console.php @@ -51,5 +51,4 @@ public function handle(array $arguments = null) public function setArgument(array $arguments = null, bool $str = true, bool $shift = true): Console { } - } diff --git a/src/Phalcon/Cli/Dispatcher.php b/src/Phalcon/Cli/Dispatcher.php index 3fd0b8a6..f6d1ff7a 100644 --- a/src/Phalcon/Cli/Dispatcher.php +++ b/src/Phalcon/Cli/Dispatcher.php @@ -36,7 +36,7 @@ * $handle = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Cli\DispatcherInterface +class Dispatcher extends CliDispatcher implements DispatcherInterface { /** * @var string @@ -196,5 +196,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/Cli/DispatcherInterface.php b/src/Phalcon/Cli/DispatcherInterface.php index dc877448..f4f6c0f5 100644 --- a/src/Phalcon/Cli/DispatcherInterface.php +++ b/src/Phalcon/Cli/DispatcherInterface.php @@ -83,5 +83,4 @@ public function setTaskName(string $taskName); * @return void */ public function setTaskSuffix(string $taskSuffix); - } diff --git a/src/Phalcon/Cli/Router.php b/src/Phalcon/Cli/Router.php index 942eb93f..81e6b58b 100644 --- a/src/Phalcon/Cli/Router.php +++ b/src/Phalcon/Cli/Router.php @@ -170,7 +170,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array|\Phalcon\Cli\Router\Route[] + * @return array|Route[] */ public function getRoutes(): array { @@ -251,5 +251,4 @@ public function setDefaultTask(string $taskName) public function wasMatched(): bool { } - } diff --git a/src/Phalcon/Cli/Router/Route.php b/src/Phalcon/Cli/Router/Route.php index 4d5f3ee1..3095febe 100644 --- a/src/Phalcon/Cli/Router/Route.php +++ b/src/Phalcon/Cli/Router/Route.php @@ -12,7 +12,7 @@ /** * This class represents every route added to the router */ -class Route implements \Phalcon\Cli\Router\RouteInterface +class Route implements RouteInterface { const DEFAULT_DELIMITER = ' '; @@ -30,7 +30,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $delimiter; - static protected $delimiterPath = self::DEFAULT_DELIMITER; + protected static $delimiterPath = self::DEFAULT_DELIMITER; protected $description; @@ -48,7 +48,7 @@ class Route implements \Phalcon\Cli\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; /** @@ -252,5 +252,4 @@ public function setDescription(string $description): RouteInterface public function setName(string $name): RouteInterface { } - } diff --git a/src/Phalcon/Cli/Router/RouteInterface.php b/src/Phalcon/Cli/Router/RouteInterface.php index 7730db7d..de7f9f28 100644 --- a/src/Phalcon/Cli/Router/RouteInterface.php +++ b/src/Phalcon/Cli/Router/RouteInterface.php @@ -118,5 +118,4 @@ public function setDescription(string $description): RouteInterface; * @return RouteInterface */ public function setName(string $name): RouteInterface; - } diff --git a/src/Phalcon/Cli/RouterInterface.php b/src/Phalcon/Cli/RouterInterface.php index 0b632e04..b5eb5259 100644 --- a/src/Phalcon/Cli/RouterInterface.php +++ b/src/Phalcon/Cli/RouterInterface.php @@ -80,7 +80,7 @@ public function getRouteByName(string $name): RouteInterface; /** * Return all the routes defined in the router * - * @return array|\Phalcon\Cli\Router\RouteInterface[] + * @return array|RouteInterface[] */ public function getRoutes(): array; @@ -136,5 +136,4 @@ public function setDefaultTask(string $taskName); * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/Cli/Task.php b/src/Phalcon/Cli/Task.php index e3d414b5..9326ce11 100644 --- a/src/Phalcon/Cli/Task.php +++ b/src/Phalcon/Cli/Task.php @@ -37,7 +37,7 @@ * } * ``` */ -class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface +class Task extends Injectable implements TaskInterface, EventsAwareInterface { protected $eventsManager; @@ -62,11 +62,10 @@ public function getEventsManager(): ?ManagerInterface /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } - } diff --git a/src/Phalcon/Collection.php b/src/Phalcon/Collection.php index 2028a89a..0644597a 100644 --- a/src/Phalcon/Collection.php +++ b/src/Phalcon/Collection.php @@ -30,7 +30,7 @@ * Such implementations are for instance accessing globals `$_GET`, `$_POST` * etc. */ -class Collection implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSerializable, \Serializable +class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable { /** * @var array @@ -306,5 +306,4 @@ public function unserialize($serialized) protected function setData(string $element, $value) { } - } diff --git a/src/Phalcon/Collection/Exception.php b/src/Phalcon/Collection/Exception.php index badabd18..2c431167 100644 --- a/src/Phalcon/Collection/Exception.php +++ b/src/Phalcon/Collection/Exception.php @@ -14,7 +14,7 @@ /** * Exceptions for the Collection object */ -class Exception extends \Phalcon\Exception implements \Throwable +class Exception extends \Phalcon\Exception implements Throwable { } diff --git a/src/Phalcon/Collection/ReadOnly.php b/src/Phalcon/Collection/ReadOnly.php index cc06d071..28ca4011 100644 --- a/src/Phalcon/Collection/ReadOnly.php +++ b/src/Phalcon/Collection/ReadOnly.php @@ -37,5 +37,4 @@ public function remove(string $element) public function set(string $element, $value) { } - } diff --git a/src/Phalcon/Config.php b/src/Phalcon/Config.php index 6954aa7a..adda6d0c 100644 --- a/src/Phalcon/Config.php +++ b/src/Phalcon/Config.php @@ -140,5 +140,4 @@ final protected function internalMerge(array $source, array $target): array protected function setData($element, $value) { } - } diff --git a/src/Phalcon/Config/Adapter/Grouped.php b/src/Phalcon/Config/Adapter/Grouped.php index 9f4fa60f..61ea5056 100644 --- a/src/Phalcon/Config/Adapter/Grouped.php +++ b/src/Phalcon/Config/Adapter/Grouped.php @@ -77,5 +77,4 @@ class Grouped extends Config public function __construct(array $arrayConfig, string $defaultAdapter = 'php') { } - } diff --git a/src/Phalcon/Config/Adapter/Ini.php b/src/Phalcon/Config/Adapter/Ini.php index bc63a72a..f7aa38ca 100644 --- a/src/Phalcon/Config/Adapter/Ini.php +++ b/src/Phalcon/Config/Adapter/Ini.php @@ -88,5 +88,4 @@ protected function cast($ini) protected function parseIniString(string $path, $value): array { } - } diff --git a/src/Phalcon/Config/Adapter/Json.php b/src/Phalcon/Config/Adapter/Json.php index 39a242a2..4c4b1e3f 100644 --- a/src/Phalcon/Config/Adapter/Json.php +++ b/src/Phalcon/Config/Adapter/Json.php @@ -10,7 +10,6 @@ namespace Phalcon\Config\Adapter; use Phalcon\Config; -use Phalcon\Helper\Json; /** * Reads JSON files and converts them to Phalcon\Config objects. @@ -43,5 +42,4 @@ class Json extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/Config/Adapter/Php.php b/src/Phalcon/Config/Adapter/Php.php index f94da213..30ee68a9 100644 --- a/src/Phalcon/Config/Adapter/Php.php +++ b/src/Phalcon/Config/Adapter/Php.php @@ -57,5 +57,4 @@ class Php extends Config public function __construct(string $filePath) { } - } diff --git a/src/Phalcon/Config/Adapter/Yaml.php b/src/Phalcon/Config/Adapter/Yaml.php index 494fe97c..07961a2c 100644 --- a/src/Phalcon/Config/Adapter/Yaml.php +++ b/src/Phalcon/Config/Adapter/Yaml.php @@ -61,5 +61,4 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } - } diff --git a/src/Phalcon/Config/ConfigFactory.php b/src/Phalcon/Config/ConfigFactory.php index 7ec304f3..2cb7faea 100644 --- a/src/Phalcon/Config/ConfigFactory.php +++ b/src/Phalcon/Config/ConfigFactory.php @@ -49,7 +49,7 @@ public function __construct(array $services = array()) /** * Load a config to create a new instance * - * @param string|array|\Phalcon\Config $config = [ + * @param string|array|Config $config = [ * 'adapter' => 'ini', * 'filePath' => 'config.ini', * 'mode' => null, @@ -81,5 +81,4 @@ public function newInstance(string $name, string $fileName, $params = null) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Container.php b/src/Phalcon/Container.php index 74f55334..964b1cf8 100644 --- a/src/Phalcon/Container.php +++ b/src/Phalcon/Container.php @@ -15,7 +15,7 @@ /** * PSR-11 Wrapper for `Phalcon\Di` */ -class Container implements \Psr\Container\ContainerInterface +class Container implements ContainerInterface { /** * @var DiInterface @@ -26,9 +26,9 @@ class Container implements \Psr\Container\ContainerInterface /** * Phalcon\Container constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container) + public function __construct(DiInterface $container) { } @@ -51,5 +51,4 @@ public function get($name) public function has($name): bool { } - } diff --git a/src/Phalcon/Crypt.php b/src/Phalcon/Crypt.php index 8cbf6869..36bb07c6 100644 --- a/src/Phalcon/Crypt.php +++ b/src/Phalcon/Crypt.php @@ -31,7 +31,7 @@ * echo $crypt->decrypt($encrypted, $key); * ``` */ -class Crypt implements \Phalcon\Crypt\CryptInterface +class Crypt implements CryptInterface { const PADDING_ANSI_X_923 = 1; @@ -165,7 +165,7 @@ public function decrypt(string $text, string $key = null): string /** * Decrypt a text that is coded as a base64 string. * - * @throws \Phalcon\Crypt\Mismatch + * @throws Mismatch * @param string $text * @param mixed $key * @param bool $safe @@ -293,7 +293,7 @@ public function setCipher(string $cipher): CryptInterface /** * Set the name of hashing algorithm. * - * @throws \Phalcon\Crypt\Exception + * @throws Exception * @param string $hashAlgo * @return CryptInterface */ @@ -409,5 +409,4 @@ protected function cryptPadText(string $text, string $mode, int $blockSize, int protected function cryptUnpadText(string $text, string $mode, int $blockSize, int $paddingType) { } - } diff --git a/src/Phalcon/Crypt/CryptInterface.php b/src/Phalcon/Crypt/CryptInterface.php index 5f30daa2..d33f3ddc 100644 --- a/src/Phalcon/Crypt/CryptInterface.php +++ b/src/Phalcon/Crypt/CryptInterface.php @@ -140,5 +140,4 @@ public function setKey(string $key): CryptInterface; * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; - } diff --git a/src/Phalcon/Crypt/Mismatch.php b/src/Phalcon/Crypt/Mismatch.php index e747b732..f5f2f7c1 100644 --- a/src/Phalcon/Crypt/Mismatch.php +++ b/src/Phalcon/Crypt/Mismatch.php @@ -12,7 +12,7 @@ /** * Exceptions thrown in Phalcon\Crypt will use this class. */ -class Mismatch extends \Phalcon\Crypt\Exception +class Mismatch extends Exception { } diff --git a/src/Phalcon/Db/AbstractDb.php b/src/Phalcon/Db/AbstractDb.php index e85944e8..0a53b095 100644 --- a/src/Phalcon/Db/AbstractDb.php +++ b/src/Phalcon/Db/AbstractDb.php @@ -66,5 +66,4 @@ abstract class AbstractDb public static function setup(array $options) { } - } diff --git a/src/Phalcon/Db/Adapter/AbstractAdapter.php b/src/Phalcon/Db/Adapter/AbstractAdapter.php index a6dde037..7e259dee 100644 --- a/src/Phalcon/Db/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Db/Adapter/AbstractAdapter.php @@ -24,12 +24,12 @@ /** * Base class for Phalcon\Db adapters */ -abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Connection ID */ - static protected $connectionConsecutive = 0; + protected static $connectionConsecutive = 0; /** * Active connection ID @@ -152,10 +152,10 @@ public function __construct(array $descriptor) * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return bool */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): bool + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): bool { } @@ -164,10 +164,10 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return bool */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): bool { } @@ -176,10 +176,10 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return bool */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): bool { } @@ -188,10 +188,10 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return bool */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): bool { } @@ -264,7 +264,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array|IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -281,7 +281,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array|ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -482,10 +482,10 @@ public function forUpdate(string $sqlQuery): string /** * Returns the SQL column definition from a column * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + public function getColumnDefinition(ColumnInterface $column): string { } @@ -734,11 +734,11 @@ public function listViews(string $schemaName = null): array * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): bool { } @@ -765,19 +765,19 @@ public function rollbackSavepoint(string $name): bool /** * Sets the event manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } /** * Sets the dialect used to produce the SQL * - * @param \Phalcon\Db\DialectInterface $dialect + * @param DialectInterface $dialect */ - public function setDialect(\Phalcon\Db\DialectInterface $dialect) + public function setDialect(DialectInterface $dialect) { } @@ -944,5 +944,4 @@ public function useExplicitIdValue(): bool public function viewExists(string $viewName, string $schemaName = null): bool { } - } diff --git a/src/Phalcon/Db/Adapter/AdapterInterface.php b/src/Phalcon/Db/Adapter/AdapterInterface.php index 4a3018d6..933abe71 100644 --- a/src/Phalcon/Db/Adapter/AdapterInterface.php +++ b/src/Phalcon/Db/Adapter/AdapterInterface.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Db\Adapter; +use PDO; use Phalcon\Db\DialectInterface; use Phalcon\Db\ResultInterface; use Phalcon\Db\ColumnInterface; @@ -27,40 +28,40 @@ interface AdapterInterface * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return bool */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): bool; + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): bool; /** * Adds an index to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return bool */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool; + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): bool; /** * Adds a foreign key to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return bool */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool; + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): bool; /** * Adds a primary key to a table * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return bool */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): bool; + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): bool; /** * Returns the number of affected rows by the last INSERT/UPDATE/DELETE @@ -147,7 +148,7 @@ public function delete($table, $whereCondition = null, $placeholders = null, $da * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array|ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array; @@ -156,7 +157,7 @@ public function describeColumns(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array|IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array; @@ -165,7 +166,7 @@ public function describeIndexes(string $table, string $schema = null): array; * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array|ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array; @@ -310,10 +311,10 @@ public function forUpdate(string $sqlQuery): string; /** * Returns the SQL column definition from a column * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string; + public function getColumnDefinition(ColumnInterface $column): string; /** * Gets a list of columns @@ -361,9 +362,9 @@ public function getDefaultIdValue(): RawValue; /** * Return internal PDO handler * - * @return \PDO + * @return PDO */ - public function getInternalHandler(): \PDO; + public function getInternalHandler(): PDO; /** * Returns the savepoint name to use for nested transactions @@ -494,11 +495,11 @@ public function listViews(string $schemaName = null): array; * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool; + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): bool; /** * Sends SQL statements to the database server returning the success state. @@ -632,5 +633,4 @@ public function useExplicitIdValue(): bool; * @return bool */ public function viewExists(string $viewName, string $schemaName = null): bool; - } diff --git a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php index 7b43793d..23ee630f 100644 --- a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php @@ -9,6 +9,9 @@ */ namespace Phalcon\Db\Adapter\Pdo; +use PDO; +use PDOStatement; +use Phalcon\Config; use Phalcon\Db\Adapter\AbstractAdapter; use Phalcon\Db\Column; use Phalcon\Db\Exception; @@ -44,7 +47,7 @@ abstract class AbstractPdo extends AbstractAdapter /** * PDO Handler * - * @var \PDO + * @var PDO */ protected $pdo; @@ -52,7 +55,7 @@ abstract class AbstractPdo extends AbstractAdapter /** * Constructor for Phalcon\Db\Adapter\Pdo * - * @param array|\Phalcon\Config $descriptor = [ + * @param array|Config $descriptor = [ * 'host' => 'localhost', * 'port' => '3306', * 'dbname' => 'blog', @@ -235,12 +238,12 @@ public function execute(string $sqlStatement, $bindParams = null, $bindTypes = n * ); * ``` * - * @param \PDOStatement $statement + * @param PDOStatement $statement * @param array $placeholders * @param mixed $dataTypes - * @return \PDOStatement + * @return PDOStatement */ - public function executePrepared(\PDOStatement $statement, array $placeholders, $dataTypes): \PDOStatement + public function executePrepared(PDOStatement $statement, array $placeholders, $dataTypes): PDOStatement { } @@ -254,9 +257,9 @@ public function getErrorInfo() /** * Return internal PDO handler * - * @return \PDO + * @return PDO */ - public function getInternalHandler(): \PDO + public function getInternalHandler(): PDO { } @@ -338,9 +341,9 @@ public function lastInsertId($sequenceName = null) * ``` * * @param string $sqlStatement - * @return \PDOStatement + * @return PDOStatement */ - public function prepare(string $sqlStatement): \PDOStatement + public function prepare(string $sqlStatement): PDOStatement { } @@ -388,5 +391,4 @@ public function rollback(bool $nesting = true): bool * @return array */ abstract protected function getDsnDefaults(): array; - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Mysql.php b/src/Phalcon/Db/Adapter/Pdo/Mysql.php index 3f6e2df8..5910e30f 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Mysql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Mysql.php @@ -36,7 +36,7 @@ * $connection = new Mysql($config); * ``` */ -class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Mysql extends AbstractPdo { /** * @var string @@ -54,10 +54,10 @@ class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return bool */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): bool + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): bool { } @@ -72,7 +72,7 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array|ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -89,7 +89,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array|IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -106,7 +106,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array|ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -120,5 +120,4 @@ public function describeReferences(string $table, string $schema = null): array protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php index 5721393a..f3d4e642 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Postgresql.php +++ b/src/Phalcon/Db/Adapter/Pdo/Postgresql.php @@ -36,7 +36,7 @@ * $connection = new Postgresql($config); * ``` */ -class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Postgresql extends AbstractPdo { /** * @var string @@ -92,7 +92,7 @@ public function createTable(string $tableName, string $schemaName, array $defini * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array|ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -109,7 +109,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array|ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -146,11 +146,11 @@ public function getDefaultIdValue(): RawValue * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return bool */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): bool + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): bool { } @@ -182,5 +182,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php index 897f7b6f..36b46bab 100644 --- a/src/Phalcon/Db/Adapter/Pdo/Sqlite.php +++ b/src/Phalcon/Db/Adapter/Pdo/Sqlite.php @@ -33,7 +33,7 @@ * ); * ``` */ -class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo +class Sqlite extends AbstractPdo { /** * @var string @@ -77,7 +77,7 @@ public function connect(array $descriptor = null): bool * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ColumnInterface[] + * @return array|ColumnInterface[] */ public function describeColumns(string $table, string $schema = null): array { @@ -94,7 +94,7 @@ public function describeColumns(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\IndexInterface[] + * @return array|IndexInterface[] */ public function describeIndexes(string $table, string $schema = null): array { @@ -105,7 +105,7 @@ public function describeIndexes(string $table, string $schema = null): array * * @param string $table * @param string $schema - * @return array|\Phalcon\Db\ReferenceInterface[] + * @return array|ReferenceInterface[] */ public function describeReferences(string $table, string $schema = null): array { @@ -154,5 +154,4 @@ public function useExplicitIdValue(): bool protected function getDsnDefaults(): array { } - } diff --git a/src/Phalcon/Db/Adapter/PdoFactory.php b/src/Phalcon/Db/Adapter/PdoFactory.php index 18e59fa8..56c90600 100644 --- a/src/Phalcon/Db/Adapter/PdoFactory.php +++ b/src/Phalcon/Db/Adapter/PdoFactory.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Db\Adapter; +use Phalcon\Config; use Phalcon\Factory\AbstractFactory; use Phalcon\Helper\Arr; @@ -35,7 +36,7 @@ public function __construct(array $services = array()) /** * Factory to create an instace from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array|Config $config = [ * 'adapter' => 'mysql', * 'options' => [ * 'host' => 'localhost', @@ -74,5 +75,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Db/Column.php b/src/Phalcon/Db/Column.php index d646e799..f42f9b8b 100644 --- a/src/Phalcon/Db/Column.php +++ b/src/Phalcon/Db/Column.php @@ -32,7 +32,7 @@ * $connection->addColumn("robots", null, $column); * ``` */ -class Column implements \Phalcon\Db\ColumnInterface +class Column implements ColumnInterface { /** * Bind Type Blob @@ -453,5 +453,4 @@ public function isPrimary(): bool public function isUnsigned(): bool { } - } diff --git a/src/Phalcon/Db/ColumnInterface.php b/src/Phalcon/Db/ColumnInterface.php index 4dde08e8..4860a22b 100644 --- a/src/Phalcon/Db/ColumnInterface.php +++ b/src/Phalcon/Db/ColumnInterface.php @@ -126,5 +126,4 @@ public function isPrimary(): bool; * @return bool */ public function isUnsigned(): bool; - } diff --git a/src/Phalcon/Db/Dialect.php b/src/Phalcon/Db/Dialect.php index e1b85297..cb647536 100644 --- a/src/Phalcon/Db/Dialect.php +++ b/src/Phalcon/Db/Dialect.php @@ -13,7 +13,7 @@ * This is the base class to each database dialect. This implements * common methods to transform intermediate code into its RDBMS related syntax */ -abstract class Dialect implements \Phalcon\Db\DialectInterface +abstract class Dialect implements DialectInterface { protected $escapeChar; @@ -509,5 +509,4 @@ protected function prepareTable(string $table, string $schema = null, string $al protected function prepareQualified(string $column, string $domain = null, string $escapeChar = null): string { } - } diff --git a/src/Phalcon/Db/Dialect/Mysql.php b/src/Phalcon/Db/Dialect/Mysql.php index c80be775..b310d2de 100644 --- a/src/Phalcon/Db/Dialect/Mysql.php +++ b/src/Phalcon/Db/Dialect/Mysql.php @@ -33,10 +33,10 @@ class Mysql extends Dialect * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): string { } @@ -45,10 +45,10 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): string { } @@ -57,10 +57,10 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -69,10 +69,10 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -213,10 +213,10 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx /** * Gets the column name in MySQL * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + public function getColumnDefinition(ColumnInterface $column): string { } @@ -260,11 +260,11 @@ public function listViews(string $schemaName = null): string * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): string { } @@ -348,21 +348,20 @@ protected function getTableOptions(array $definition): string * Checks if the size and/or scale are present and encloses those values * in parentheses if need be * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - private function checkColumnSizeAndScale(\Phalcon\Db\ColumnInterface $column): string + private function checkColumnSizeAndScale(ColumnInterface $column): string { } /** * Checks if a column is unsigned or not and returns the relevant SQL syntax * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - private function checkColumnUnsigned(\Phalcon\Db\ColumnInterface $column): string + private function checkColumnUnsigned(ColumnInterface $column): string { } - } diff --git a/src/Phalcon/Db/Dialect/Postgresql.php b/src/Phalcon/Db/Dialect/Postgresql.php index 7d680ec5..eb705684 100644 --- a/src/Phalcon/Db/Dialect/Postgresql.php +++ b/src/Phalcon/Db/Dialect/Postgresql.php @@ -33,10 +33,10 @@ class Postgresql extends Dialect * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): string { } @@ -45,10 +45,10 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): string { } @@ -57,10 +57,10 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -69,10 +69,10 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -213,10 +213,10 @@ public function dropView(string $viewName, string $schemaName = null, bool $ifEx /** * Gets the column name in PostgreSQL * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + public function getColumnDefinition(ColumnInterface $column): string { } @@ -251,11 +251,11 @@ public function listViews(string $schemaName = null): string * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): string { } @@ -321,10 +321,10 @@ public function viewExists(string $viewName, string $schemaName = null): string } /** - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - protected function castDefault(\Phalcon\Db\ColumnInterface $column): string + protected function castDefault(ColumnInterface $column): string { } @@ -335,5 +335,4 @@ protected function castDefault(\Phalcon\Db\ColumnInterface $column): string protected function getTableOptions(array $definition): string { } - } diff --git a/src/Phalcon/Db/Dialect/Sqlite.php b/src/Phalcon/Db/Dialect/Sqlite.php index 17f84685..06cc8f10 100644 --- a/src/Phalcon/Db/Dialect/Sqlite.php +++ b/src/Phalcon/Db/Dialect/Sqlite.php @@ -33,10 +33,10 @@ class Sqlite extends Dialect * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column): string + public function addColumn(string $tableName, string $schemaName, ColumnInterface $column): string { } @@ -45,10 +45,10 @@ public function addColumn(string $tableName, string $schemaName, \Phalcon\Db\Col * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ReferenceInterface $reference + * @param ReferenceInterface $reference * @return string */ - public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db\ReferenceInterface $reference): string + public function addForeignKey(string $tableName, string $schemaName, ReferenceInterface $reference): string { } @@ -57,10 +57,10 @@ public function addForeignKey(string $tableName, string $schemaName, \Phalcon\Db * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addIndex(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -69,10 +69,10 @@ public function addIndex(string $tableName, string $schemaName, \Phalcon\Db\Inde * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\IndexInterface $index + * @param IndexInterface $index * @return string */ - public function addPrimaryKey(string $tableName, string $schemaName, \Phalcon\Db\IndexInterface $index): string + public function addPrimaryKey(string $tableName, string $schemaName, IndexInterface $index): string { } @@ -234,10 +234,10 @@ public function forUpdate(string $sqlQuery): string /** * Gets the column name in SQLite * - * @param \Phalcon\Db\ColumnInterface $column + * @param ColumnInterface $column * @return string */ - public function getColumnDefinition(\Phalcon\Db\ColumnInterface $column): string + public function getColumnDefinition(ColumnInterface $column): string { } @@ -290,11 +290,11 @@ public function listViews(string $schemaName = null): string * * @param string $tableName * @param string $schemaName - * @param \Phalcon\Db\ColumnInterface $column - * @param \Phalcon\Db\ColumnInterface $currentColumn + * @param ColumnInterface $column + * @param ColumnInterface $currentColumn * @return string */ - public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ColumnInterface $column, \Phalcon\Db\ColumnInterface $currentColumn = null): string + public function modifyColumn(string $tableName, string $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null): string { } @@ -358,5 +358,4 @@ public function truncateTable(string $tableName, string $schemaName): string public function viewExists(string $viewName, string $schemaName = null): string { } - } diff --git a/src/Phalcon/Db/DialectInterface.php b/src/Phalcon/Db/DialectInterface.php index 208f30ee..fa6b3057 100644 --- a/src/Phalcon/Db/DialectInterface.php +++ b/src/Phalcon/Db/DialectInterface.php @@ -319,5 +319,4 @@ public function tableOptions(string $table, string $schema = null): string; * @return string */ public function viewExists(string $viewName, string $schemaName = null): string; - } diff --git a/src/Phalcon/Db/Enum.php b/src/Phalcon/Db/Enum.php index d826fa71..cff4d17c 100644 --- a/src/Phalcon/Db/Enum.php +++ b/src/Phalcon/Db/Enum.php @@ -64,6 +64,4 @@ class Enum const FETCH_UNIQUE = 196608; - - } diff --git a/src/Phalcon/Db/Index.php b/src/Phalcon/Db/Index.php index 586c8433..90806b07 100644 --- a/src/Phalcon/Db/Index.php +++ b/src/Phalcon/Db/Index.php @@ -38,7 +38,7 @@ * $connection->addIndex("robots", null, $index_primary); * ``` */ -class Index implements \Phalcon\Db\IndexInterface +class Index implements IndexInterface { /** * Index columns @@ -99,5 +99,4 @@ public function getType(): string public function __construct(string $name, array $columns, string $type = '') { } - } diff --git a/src/Phalcon/Db/IndexInterface.php b/src/Phalcon/Db/IndexInterface.php index f1a7074c..d981c426 100644 --- a/src/Phalcon/Db/IndexInterface.php +++ b/src/Phalcon/Db/IndexInterface.php @@ -35,5 +35,4 @@ public function getName(): string; * @return string */ public function getType(): string; - } diff --git a/src/Phalcon/Db/Profiler.php b/src/Phalcon/Db/Profiler.php index 177cbc01..686eb278 100644 --- a/src/Phalcon/Db/Profiler.php +++ b/src/Phalcon/Db/Profiler.php @@ -73,7 +73,7 @@ class Profiler /** * All the Phalcon\Db\Profiler\Item in the active profile * - * @var \Phalcon\Db\Profiler\Item[] + * @var Item[] */ protected $allProfiles; @@ -115,7 +115,7 @@ public function getTotalElapsedSeconds(): float /** * Returns all the processed profiles * - * @return array|\Phalcon\Db\Profiler\Item[] + * @return array|Item[] */ public function getProfiles(): array { @@ -150,5 +150,4 @@ public function startProfile(string $sqlStatement, $sqlVariables = null, $sqlBin public function stopProfile(): Profiler { } - } diff --git a/src/Phalcon/Db/Profiler/Item.php b/src/Phalcon/Db/Profiler/Item.php index 24610248..71b5487b 100644 --- a/src/Phalcon/Db/Profiler/Item.php +++ b/src/Phalcon/Db/Profiler/Item.php @@ -148,5 +148,4 @@ public function getSqlVariables(): array public function getTotalElapsedSeconds(): float { } - } diff --git a/src/Phalcon/Db/RawValue.php b/src/Phalcon/Db/RawValue.php index 27a98c78..1ecfc9b1 100644 --- a/src/Phalcon/Db/RawValue.php +++ b/src/Phalcon/Db/RawValue.php @@ -59,5 +59,4 @@ public function __toString(): string public function __construct($value) { } - } diff --git a/src/Phalcon/Db/Reference.php b/src/Phalcon/Db/Reference.php index 5763cd2a..001779a0 100644 --- a/src/Phalcon/Db/Reference.php +++ b/src/Phalcon/Db/Reference.php @@ -30,7 +30,7 @@ * ); * ``` */ -class Reference implements \Phalcon\Db\ReferenceInterface +class Reference implements ReferenceInterface { /** * Local reference columns @@ -170,5 +170,4 @@ public function getOnUpdate(): string public function __construct(string $name, array $definition) { } - } diff --git a/src/Phalcon/Db/ReferenceInterface.php b/src/Phalcon/Db/ReferenceInterface.php index 9e2a3bf1..c28ff533 100644 --- a/src/Phalcon/Db/ReferenceInterface.php +++ b/src/Phalcon/Db/ReferenceInterface.php @@ -70,5 +70,4 @@ public function getReferencedTable(): string; * @return string */ public function getSchemaName(): string; - } diff --git a/src/Phalcon/Db/Result/Pdo.php b/src/Phalcon/Db/Result/Pdo.php index d06e7c99..12f0e9d2 100644 --- a/src/Phalcon/Db/Result/Pdo.php +++ b/src/Phalcon/Db/Result/Pdo.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Db\Result; +use PDOStatement; use Phalcon\Db\Enum; use Phalcon\Db\ResultInterface; use Phalcon\Db\Adapter\AdapterInterface; @@ -28,7 +29,7 @@ * } * ``` */ -class Pdo implements \Phalcon\Db\ResultInterface +class Pdo implements ResultInterface { protected $bindParams; @@ -47,7 +48,7 @@ class Pdo implements \Phalcon\Db\ResultInterface /** * Internal resultset * - * @var \PDOStatement + * @var PDOStatement */ protected $pdoStatement; @@ -64,13 +65,13 @@ class Pdo implements \Phalcon\Db\ResultInterface /** * Phalcon\Db\Result\Pdo constructor * - * @param \Phalcon\Db\Adapter\AdapterInterface $connection - * @param \PDOStatement $result + * @param AdapterInterface $connection + * @param PDOStatement $result * @param mixed $sqlStatement * @param mixed $bindParams * @param mixed $bindTypes */ - public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) + public function __construct(AdapterInterface $connection, PDOStatement $result, $sqlStatement = null, $bindParams = null, $bindTypes = null) { } @@ -179,9 +180,9 @@ public function fetchArray() /** * Gets the internal PDO result object * - * @return \PDOStatement + * @return PDOStatement */ - public function getInternalResult(): \PDOStatement + public function getInternalResult(): PDOStatement { } @@ -235,5 +236,4 @@ public function numRows(): int public function setFetchMode(int $fetchMode, $colNoOrClassNameOrObject = null, $ctorargs = null): bool { } - } diff --git a/src/Phalcon/Db/ResultInterface.php b/src/Phalcon/Db/ResultInterface.php index 93923545..40a9f1c3 100644 --- a/src/Phalcon/Db/ResultInterface.php +++ b/src/Phalcon/Db/ResultInterface.php @@ -9,6 +9,8 @@ */ namespace Phalcon\Db; +use PDOStatement; + /** * Interface for Phalcon\Db\Result objects */ @@ -62,9 +64,9 @@ public function fetchArray(); /** * Gets the internal PDO result object * - * @return \PDOStatement + * @return PDOStatement */ - public function getInternalResult(): \PDOStatement; + public function getInternalResult(): PDOStatement; /** * Gets number of rows returned by a resultset @@ -80,5 +82,4 @@ public function numRows(): int; * @return bool */ public function setFetchMode(int $fetchMode): bool; - } diff --git a/src/Phalcon/Debug.php b/src/Phalcon/Debug.php index 8ec1b483..5be42015 100644 --- a/src/Phalcon/Debug.php +++ b/src/Phalcon/Debug.php @@ -37,7 +37,7 @@ class Debug /** * @var bool */ - static protected $isActive; + protected static $isActive; /** * @var bool @@ -261,5 +261,4 @@ protected function getVarDump($variable): string final protected function showTraceItem(int $n, array $trace): string { } - } diff --git a/src/Phalcon/Debug/Dump.php b/src/Phalcon/Debug/Dump.php index 7a4f9cef..e5b401dc 100644 --- a/src/Phalcon/Debug/Dump.php +++ b/src/Phalcon/Debug/Dump.php @@ -182,5 +182,4 @@ protected function getStyle(string $type): string protected function output($variable, string $name = null, int $tab = 1): string { } - } diff --git a/src/Phalcon/Di.php b/src/Phalcon/Di.php index e8b8907a..b10115ab 100644 --- a/src/Phalcon/Di.php +++ b/src/Phalcon/Di.php @@ -58,7 +58,7 @@ * $request = $di->getRequest(); * ``` */ -class Di implements \Phalcon\Di\DiInterface +class Di implements DiInterface { /** * List of registered services @@ -80,7 +80,7 @@ class Di implements \Phalcon\Di\DiInterface /** * Latest DI build */ - static protected $_default; + protected static $_default; /** @@ -167,7 +167,7 @@ public function getService(string $name): ServiceInterface /** * Return the services registered in the DI * - * @return array|\Phalcon\Di\ServiceInterface[] + * @return array|ServiceInterface[] */ public function getServices(): array { @@ -353,10 +353,10 @@ public function offsetUnset($name) * } * ``` * - * @param \Phalcon\Di\ServiceProviderInterface $provider + * @param ServiceProviderInterface $provider * @return void */ - public function register(\Phalcon\Di\ServiceProviderInterface $provider) + public function register(ServiceProviderInterface $provider) { } @@ -396,19 +396,19 @@ public function set(string $name, $definition, bool $shared = false): ServiceInt * Set a default dependency injection container to be obtained into static * methods * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public static function setDefault(\Phalcon\Di\DiInterface $container) + public static function setDefault(DiInterface $container) { } /** * Sets the internal event manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager */ - public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setInternalEventsManager(ManagerInterface $eventsManager) { } @@ -416,10 +416,10 @@ public function setInternalEventsManager(\Phalcon\Events\ManagerInterface $event * Sets a service using a raw Phalcon\Di\Service definition * * @param string $name - * @param \Phalcon\Di\ServiceInterface $rawDefinition + * @param ServiceInterface $rawDefinition * @return ServiceInterface */ - public function setService(string $name, \Phalcon\Di\ServiceInterface $rawDefinition): ServiceInterface + public function setService(string $name, ServiceInterface $rawDefinition): ServiceInterface { } @@ -433,5 +433,4 @@ public function setService(string $name, \Phalcon\Di\ServiceInterface $rawDefini public function setShared(string $name, $definition): ServiceInterface { } - } diff --git a/src/Phalcon/Di/AbstractInjectionAware.php b/src/Phalcon/Di/AbstractInjectionAware.php index 1938a255..cf7102d0 100644 --- a/src/Phalcon/Di/AbstractInjectionAware.php +++ b/src/Phalcon/Di/AbstractInjectionAware.php @@ -12,7 +12,7 @@ /** * This abstract class offers common access to the DI in a class */ -abstract class AbstractInjectionAware implements \Phalcon\Di\InjectionAwareInterface +abstract class AbstractInjectionAware implements InjectionAwareInterface { /** * Dependency Injector @@ -40,5 +40,4 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } - } diff --git a/src/Phalcon/Di/DiInterface.php b/src/Phalcon/Di/DiInterface.php index 58f711b4..ae11f4be 100644 --- a/src/Phalcon/Di/DiInterface.php +++ b/src/Phalcon/Di/DiInterface.php @@ -14,7 +14,7 @@ /** * Interface for Phalcon\Di */ -interface DiInterface extends \ArrayAccess +interface DiInterface extends ArrayAccess { /** @@ -136,5 +136,4 @@ public function setService(string $name, ServiceInterface $rawDefinition): Servi * @return ServiceInterface */ public function setShared(string $name, $definition): ServiceInterface; - } diff --git a/src/Phalcon/Di/Exception/ServiceResolutionException.php b/src/Phalcon/Di/Exception/ServiceResolutionException.php index bee2d1e1..fe817007 100644 --- a/src/Phalcon/Di/Exception/ServiceResolutionException.php +++ b/src/Phalcon/Di/Exception/ServiceResolutionException.php @@ -9,10 +9,12 @@ */ namespace Phalcon\Di\Exception; +use Phalcon\Di\Exception; + /** * Phalcon\Di\Exception\ServiceResolutionException */ -class ServiceResolutionException extends \Phalcon\Di\Exception +class ServiceResolutionException extends Exception { } diff --git a/src/Phalcon/Di/FactoryDefault.php b/src/Phalcon/Di/FactoryDefault.php index 501926d9..1c58c161 100644 --- a/src/Phalcon/Di/FactoryDefault.php +++ b/src/Phalcon/Di/FactoryDefault.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Di; +use Phalcon\Di; use Phalcon\Filter\FilterFactory; /** @@ -17,7 +18,7 @@ * developer does not need to register each service individually providing a * full stack framework */ -class FactoryDefault extends \Phalcon\Di +class FactoryDefault extends Di { /** @@ -26,5 +27,4 @@ class FactoryDefault extends \Phalcon\Di public function __construct() { } - } diff --git a/src/Phalcon/Di/FactoryDefault/Cli.php b/src/Phalcon/Di/FactoryDefault/Cli.php index 24d167c9..c3dddddd 100644 --- a/src/Phalcon/Di/FactoryDefault/Cli.php +++ b/src/Phalcon/Di/FactoryDefault/Cli.php @@ -30,5 +30,4 @@ class Cli extends FactoryDefault public function __construct() { } - } diff --git a/src/Phalcon/Di/Injectable.php b/src/Phalcon/Di/Injectable.php index 2ee6dfbb..7981d759 100644 --- a/src/Phalcon/Di/Injectable.php +++ b/src/Phalcon/Di/Injectable.php @@ -9,39 +9,69 @@ */ namespace Phalcon\Di; +use Phalcon\Annotations\Adapter; +use Phalcon\Assets\Manager; +use Phalcon\Crypt; +use Phalcon\CryptInterface; +use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di; +use Phalcon\Escaper; +use Phalcon\Escaper\EscaperInterface; +use Phalcon\Filter; +use Phalcon\Flash\Direct; +use Phalcon\Flash\Session; +use Phalcon\Http\Request; +use Phalcon\Http\RequestInterface; +use Phalcon\Http\Response; +use Phalcon\Http\Response\Cookies; +use Phalcon\Http\Response\CookiesInterface; +use Phalcon\Http\ResponseInterface; +use Phalcon\Mvc\Dispatcher; +use Phalcon\Mvc\DispatcherInterface; +use Phalcon\Mvc\Model\MetaData\Memory; +use Phalcon\Mvc\Model\MetadataInterface; +use Phalcon\Mvc\Model\Transaction\ManagerInterface; +use Phalcon\Mvc\Router; +use Phalcon\Mvc\RouterInterface; +use Phalcon\Mvc\View; +use Phalcon\Mvc\ViewInterface; +use Phalcon\Security; +use Phalcon\Session\Bag; use Phalcon\Session\BagInterface; +use Phalcon\Tag; +use Phalcon\Url; +use Phalcon\Url\UrlInterface; /** * This class allows to access services in the services container by just only * accessing a public property with the same name of a registered service * - * @property \Phalcon\Mvc\Dispatcher|\Phalcon\Mvc\DispatcherInterface $dispatcher - * @property \Phalcon\Mvc\Router|\Phalcon\Mvc\RouterInterface $router - * @property \Phalcon\Url|\Phalcon\Url\UrlInterface $url - * @property \Phalcon\Http\Request|\Phalcon\Http\RequestInterface $request - * @property \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface $response - * @property \Phalcon\Http\Response\Cookies|\Phalcon\Http\Response\CookiesInterface $cookies - * @property \Phalcon\Filter $filter - * @property \Phalcon\Flash\Direct $flash - * @property \Phalcon\Flash\Session $flashSession + * @property Dispatcher|DispatcherInterface $dispatcher + * @property Router|RouterInterface $router + * @property Url|UrlInterface $url + * @property Request|RequestInterface $request + * @property Response|ResponseInterface $response + * @property Cookies|CookiesInterface $cookies + * @property Filter $filter + * @property Direct $flash + * @property Session $flashSession * @property \Phalcon\Session\ManagerInterface $session * @property \Phalcon\Events\Manager|\Phalcon\Events\ManagerInterface $eventsManager - * @property \Phalcon\Db\Adapter\AdapterInterface $db - * @property \Phalcon\Security $security - * @property \Phalcon\Crypt|\Phalcon\CryptInterface $crypt - * @property \Phalcon\Tag $tag - * @property \Phalcon\Escaper|\Phalcon\Escaper\EscaperInterface $escaper - * @property \Phalcon\Annotations\Adapter\Memory|\Phalcon\Annotations\Adapter $annotations + * @property AdapterInterface $db + * @property Security $security + * @property Crypt|CryptInterface $crypt + * @property Tag $tag + * @property Escaper|EscaperInterface $escaper + * @property \Phalcon\Annotations\Adapter\Memory|Adapter $annotations * @property \Phalcon\Mvc\Model\Manager|\Phalcon\Mvc\Model\ManagerInterface $modelsManager - * @property \Phalcon\Mvc\Model\MetaData\Memory|\Phalcon\Mvc\Model\MetadataInterface $modelsMetadata - * @property \Phalcon\Mvc\Model\Transaction\Manager|\Phalcon\Mvc\Model\Transaction\ManagerInterface $transactionManager - * @property \Phalcon\Assets\Manager $assets - * @property \Phalcon\Di|\Phalcon\Di\DiInterface $di - * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent - * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view + * @property Memory|MetadataInterface $modelsMetadata + * @property \Phalcon\Mvc\Model\Transaction\Manager|ManagerInterface $transactionManager + * @property Manager $assets + * @property Di|DiInterface $di + * @property Bag|BagInterface $persistent + * @property View|ViewInterface $view */ -abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface +abstract class Injectable implements InjectionAwareInterface { /** * Dependency Injector @@ -89,5 +119,4 @@ public function getDI(): DiInterface public function setDI(DiInterface $container) { } - } diff --git a/src/Phalcon/Di/InjectionAwareInterface.php b/src/Phalcon/Di/InjectionAwareInterface.php index 72cd4198..97b68a27 100644 --- a/src/Phalcon/Di/InjectionAwareInterface.php +++ b/src/Phalcon/Di/InjectionAwareInterface.php @@ -30,5 +30,4 @@ public function setDI(DiInterface $container); * @return DiInterface */ public function getDI(): DiInterface; - } diff --git a/src/Phalcon/Di/Service.php b/src/Phalcon/Di/Service.php index ddba7f20..55c9b180 100644 --- a/src/Phalcon/Di/Service.php +++ b/src/Phalcon/Di/Service.php @@ -25,7 +25,7 @@ * $request = service->resolve(); * ``` */ -class Service implements \Phalcon\Di\ServiceInterface +class Service implements ServiceInterface { protected $definition; @@ -142,5 +142,4 @@ public function setShared(bool $shared) public function setSharedInstance($sharedInstance) { } - } diff --git a/src/Phalcon/Di/Service/Builder.php b/src/Phalcon/Di/Service/Builder.php index a3079d45..e90e2d9a 100644 --- a/src/Phalcon/Di/Service/Builder.php +++ b/src/Phalcon/Di/Service/Builder.php @@ -24,35 +24,34 @@ class Builder * Builds a service using a complex service definition * * @param array $parameters - * @return mixed - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param array $definition + *@return mixed */ - public function build(\Phalcon\Di\DiInterface $container, array $definition, $parameters = null) + public function build(DiInterface $container, array $definition, $parameters = null) { } /** * Resolves a constructor/call parameter * - * @return mixed - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param int $position * @param array $argument + *@return mixed */ - private function buildParameter(\Phalcon\Di\DiInterface $container, int $position, array $argument) + private function buildParameter(DiInterface $container, int $position, array $argument) { } /** * Resolves an array of parameters * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param array $arguments * @return array */ - private function buildParameters(\Phalcon\Di\DiInterface $container, array $arguments): array + private function buildParameters(DiInterface $container, array $arguments): array { } - } diff --git a/src/Phalcon/Di/ServiceInterface.php b/src/Phalcon/Di/ServiceInterface.php index 31af1fe3..52c09130 100644 --- a/src/Phalcon/Di/ServiceInterface.php +++ b/src/Phalcon/Di/ServiceInterface.php @@ -75,5 +75,4 @@ public function setParameter(int $position, array $parameter): ServiceInterface; * @param bool $shared */ public function setShared(bool $shared); - } diff --git a/src/Phalcon/Di/ServiceProviderInterface.php b/src/Phalcon/Di/ServiceProviderInterface.php index bde1316f..497bac34 100644 --- a/src/Phalcon/Di/ServiceProviderInterface.php +++ b/src/Phalcon/Di/ServiceProviderInterface.php @@ -43,5 +43,4 @@ interface ServiceProviderInterface * @return void */ public function register(DiInterface $di); - } diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php index f38bc389..81f8895e 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -24,7 +24,7 @@ * This class can't be instantiated directly, you can use it to create your own * dispatchers. */ -abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractDispatcher extends AbstractInjectionAware implements DispatcherInterface, EventsAwareInterface { protected $activeHandler; @@ -141,7 +141,7 @@ public function callActionMethod($handler, string $actionMethod, array $params = * for CLI dispatching) or false if an exception occurred and the operation was * stopped by returning false in the exception handler. * - * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. + * @throws Exception if any uncaught or unhandled exception occurs during the dispatcher process. */ public function dispatch(): bool { @@ -392,10 +392,10 @@ public function setActionSuffix(string $actionSuffix) /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -428,11 +428,11 @@ public function setHandlerSuffix(string $handlerSuffix) * ); * ``` * - * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder + * @param BinderInterface $modelBinder * @param mixed $cache * @return DispatcherInterface */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): DispatcherInterface + public function setModelBinder(BinderInterface $modelBinder, $cache = null): DispatcherInterface { } @@ -490,5 +490,4 @@ protected function resolveEmptyProperties() protected function toCamelCase(string $input): string { } - } diff --git a/src/Phalcon/Dispatcher/DispatcherInterface.php b/src/Phalcon/Dispatcher/DispatcherInterface.php index 952c39e1..8b7244f9 100644 --- a/src/Phalcon/Dispatcher/DispatcherInterface.php +++ b/src/Phalcon/Dispatcher/DispatcherInterface.php @@ -162,5 +162,4 @@ public function setParam($param, $value); * @return void */ public function setParams(array $params); - } diff --git a/src/Phalcon/Dispatcher/Exception.php b/src/Phalcon/Dispatcher/Exception.php index fb0da6ee..940db816 100644 --- a/src/Phalcon/Dispatcher/Exception.php +++ b/src/Phalcon/Dispatcher/Exception.php @@ -31,6 +31,4 @@ class Exception extends \Phalcon\Exception const EXCEPTION_NO_DI = 0; - - } diff --git a/src/Phalcon/Domain/Payload/Payload.php b/src/Phalcon/Domain/Payload/Payload.php index 134b79c7..04a459ab 100644 --- a/src/Phalcon/Domain/Payload/Payload.php +++ b/src/Phalcon/Domain/Payload/Payload.php @@ -14,7 +14,7 @@ /** * Holds the payload */ -class Payload implements \Phalcon\Domain\Payload\PayloadInterface +class Payload implements PayloadInterface { /** * Exception if any @@ -120,7 +120,7 @@ public function getException(): ?Throwable * * @return PayloadInterface */ - public function setException(\Throwable $exception): PayloadInterface + public function setException(Throwable $exception): PayloadInterface { } @@ -173,5 +173,4 @@ public function setOutput($output): PayloadInterface public function setStatus($status): PayloadInterface { } - } diff --git a/src/Phalcon/Domain/Payload/PayloadFactory.php b/src/Phalcon/Domain/Payload/PayloadFactory.php index 518657a0..adc02bfd 100644 --- a/src/Phalcon/Domain/Payload/PayloadFactory.php +++ b/src/Phalcon/Domain/Payload/PayloadFactory.php @@ -23,5 +23,4 @@ class PayloadFactory public function newInstance(): PayloadInterface { } - } diff --git a/src/Phalcon/Domain/Payload/PayloadInterface.php b/src/Phalcon/Domain/Payload/PayloadInterface.php index a96ecd8e..1d85a732 100644 --- a/src/Phalcon/Domain/Payload/PayloadInterface.php +++ b/src/Phalcon/Domain/Payload/PayloadInterface.php @@ -12,7 +12,7 @@ /** * This interface is used for consumers */ -interface PayloadInterface extends \Phalcon\Domain\Payload\ReadableInterface, \Phalcon\Domain\Payload\WriteableInterface +interface PayloadInterface extends ReadableInterface, WriteableInterface { } diff --git a/src/Phalcon/Domain/Payload/ReadableInterface.php b/src/Phalcon/Domain/Payload/ReadableInterface.php index d787b7bc..c364d7a9 100644 --- a/src/Phalcon/Domain/Payload/ReadableInterface.php +++ b/src/Phalcon/Domain/Payload/ReadableInterface.php @@ -58,5 +58,4 @@ public function getOutput(); * @return mixed */ public function getStatus(); - } diff --git a/src/Phalcon/Domain/Payload/Status.php b/src/Phalcon/Domain/Payload/Status.php index 03f52886..292e2da0 100644 --- a/src/Phalcon/Domain/Payload/Status.php +++ b/src/Phalcon/Domain/Payload/Status.php @@ -81,5 +81,4 @@ class Status final private function __construct() { } - } diff --git a/src/Phalcon/Domain/Payload/WriteableInterface.php b/src/Phalcon/Domain/Payload/WriteableInterface.php index a0509926..010c28cb 100644 --- a/src/Phalcon/Domain/Payload/WriteableInterface.php +++ b/src/Phalcon/Domain/Payload/WriteableInterface.php @@ -24,7 +24,7 @@ interface WriteableInterface * * @return PayloadInterface */ - public function setException(\Throwable $exception): PayloadInterface; + public function setException(Throwable $exception): PayloadInterface; /** * Sets arbitrary extra values produced by the domain layer. @@ -70,5 +70,4 @@ public function setOutput($output): PayloadInterface; * @return PayloadInterface */ public function setStatus($status): PayloadInterface; - } diff --git a/src/Phalcon/Escaper.php b/src/Phalcon/Escaper.php index 32c4f24b..5cc4b544 100644 --- a/src/Phalcon/Escaper.php +++ b/src/Phalcon/Escaper.php @@ -30,7 +30,7 @@ * echo $escaped; // font\2D family\3A \20 \3C Verdana\3E * ``` */ -class Escaper implements \Phalcon\Escaper\EscaperInterface +class Escaper implements EscaperInterface { /** * @var bool @@ -173,5 +173,4 @@ public function setEncoding(string $encoding) public function setHtmlQuoteType(int $quoteType) { } - } diff --git a/src/Phalcon/Escaper/EscaperInterface.php b/src/Phalcon/Escaper/EscaperInterface.php index d067a4d3..09e2ba21 100644 --- a/src/Phalcon/Escaper/EscaperInterface.php +++ b/src/Phalcon/Escaper/EscaperInterface.php @@ -79,5 +79,4 @@ public function setEncoding(string $encoding); * @return void */ public function setHtmlQuoteType(int $quoteType); - } diff --git a/src/Phalcon/Events/Event.php b/src/Phalcon/Events/Event.php index a59342ca..05f50a15 100644 --- a/src/Phalcon/Events/Event.php +++ b/src/Phalcon/Events/Event.php @@ -24,7 +24,7 @@ * } * ``` */ -class Event implements \Phalcon\Events\EventInterface +class Event implements EventInterface { /** * Is event cancelable? @@ -159,5 +159,4 @@ public function setType(string $type): EventInterface public function stop(): EventInterface { } - } diff --git a/src/Phalcon/Events/EventInterface.php b/src/Phalcon/Events/EventInterface.php index 02ed6dd1..51e4b8e8 100644 --- a/src/Phalcon/Events/EventInterface.php +++ b/src/Phalcon/Events/EventInterface.php @@ -67,5 +67,4 @@ public function setType(string $type): EventInterface; * @return EventInterface */ public function stop(): EventInterface; - } diff --git a/src/Phalcon/Events/EventsAwareInterface.php b/src/Phalcon/Events/EventsAwareInterface.php index aa0509f4..f35d4f45 100644 --- a/src/Phalcon/Events/EventsAwareInterface.php +++ b/src/Phalcon/Events/EventsAwareInterface.php @@ -32,5 +32,4 @@ public function getEventsManager(): ?ManagerInterface; * @return void */ public function setEventsManager(ManagerInterface $eventsManager); - } diff --git a/src/Phalcon/Events/Manager.php b/src/Phalcon/Events/Manager.php index 105c486c..a08e356c 100644 --- a/src/Phalcon/Events/Manager.php +++ b/src/Phalcon/Events/Manager.php @@ -20,7 +20,7 @@ * can create hooks or plugins that will offer monitoring of data, manipulation, * conditional execution and much more. */ -class Manager implements \Phalcon\Events\ManagerInterface +class Manager implements ManagerInterface { const DEFAULT_PRIORITY = 100; @@ -126,11 +126,11 @@ public function fire(string $eventType, $source, $data = null, bool $cancelable /** * Internal handler to call a queue of events * - * @return mixed - * @param \SplPriorityQueue $queue + * @param SplPriorityQueue $queue * @param EventInterface $event + *@return mixed */ - final public function fireQueue(\SplPriorityQueue $queue, EventInterface $event) + final public function fireQueue(SplPriorityQueue $queue, EventInterface $event) { } @@ -173,5 +173,4 @@ public function hasListeners(string $type): bool public function isCollecting(): bool { } - } diff --git a/src/Phalcon/Events/ManagerInterface.php b/src/Phalcon/Events/ManagerInterface.php index c4e5eba0..b9a9d50d 100644 --- a/src/Phalcon/Events/ManagerInterface.php +++ b/src/Phalcon/Events/ManagerInterface.php @@ -70,5 +70,4 @@ public function getListeners(string $type): array; * @return bool */ public function hasListeners(string $type): bool; - } diff --git a/src/Phalcon/Exception.php b/src/Phalcon/Exception.php index 129c46bf..6d87ecbb 100644 --- a/src/Phalcon/Exception.php +++ b/src/Phalcon/Exception.php @@ -9,12 +9,14 @@ */ namespace Phalcon; +use Throwable; + /** * Phalcon\Exception * * All framework exceptions should use or extend this exception */ -class Exception extends \Exception implements \Throwable +class Exception extends \Exception implements Throwable { /** @@ -24,5 +26,4 @@ class Exception extends \Exception implements \Throwable public static function containerServiceNotFound(string $service): string { } - } diff --git a/src/Phalcon/Factory/AbstractFactory.php b/src/Phalcon/Factory/AbstractFactory.php index 2cb9a1fd..2b74d0a1 100644 --- a/src/Phalcon/Factory/AbstractFactory.php +++ b/src/Phalcon/Factory/AbstractFactory.php @@ -68,5 +68,4 @@ abstract protected function getAdapters(): array; protected function init(array $services = array()) { } - } diff --git a/src/Phalcon/Filter.php b/src/Phalcon/Filter.php index 5611d4f4..64416762 100644 --- a/src/Phalcon/Filter.php +++ b/src/Phalcon/Filter.php @@ -16,7 +16,7 @@ /** * Lazy loads, stores and exposes sanitizer objects */ -class Filter implements \Phalcon\Filter\FilterInterface +class Filter implements FilterInterface { const FILTER_ABSINT = 'absint'; @@ -179,5 +179,4 @@ private function processArrayValues(array $values, string $sanitizerName, array private function sanitizer($value, string $sanitizerName, array $sanitizerParams = array()) { } - } diff --git a/src/Phalcon/Filter/FilterFactory.php b/src/Phalcon/Filter/FilterFactory.php index a99627ae..d5a5f2bc 100644 --- a/src/Phalcon/Filter/FilterFactory.php +++ b/src/Phalcon/Filter/FilterFactory.php @@ -38,5 +38,4 @@ public function newInstance(): FilterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Filter/FilterInterface.php b/src/Phalcon/Filter/FilterInterface.php index a455a176..f7922641 100644 --- a/src/Phalcon/Filter/FilterInterface.php +++ b/src/Phalcon/Filter/FilterInterface.php @@ -24,5 +24,4 @@ interface FilterInterface * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); - } diff --git a/src/Phalcon/Filter/Sanitize/AbsInt.php b/src/Phalcon/Filter/Sanitize/AbsInt.php index 5b155476..3aabb4f2 100644 --- a/src/Phalcon/Filter/Sanitize/AbsInt.php +++ b/src/Phalcon/Filter/Sanitize/AbsInt.php @@ -23,5 +23,4 @@ class AbsInt public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Alnum.php b/src/Phalcon/Filter/Sanitize/Alnum.php index 29516b2e..a715f0df 100644 --- a/src/Phalcon/Filter/Sanitize/Alnum.php +++ b/src/Phalcon/Filter/Sanitize/Alnum.php @@ -23,5 +23,4 @@ class Alnum public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Alpha.php b/src/Phalcon/Filter/Sanitize/Alpha.php index 65c9ad74..33eefae7 100644 --- a/src/Phalcon/Filter/Sanitize/Alpha.php +++ b/src/Phalcon/Filter/Sanitize/Alpha.php @@ -23,5 +23,4 @@ class Alpha public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/BoolVal.php b/src/Phalcon/Filter/Sanitize/BoolVal.php index 09aa4364..67d8ec37 100644 --- a/src/Phalcon/Filter/Sanitize/BoolVal.php +++ b/src/Phalcon/Filter/Sanitize/BoolVal.php @@ -23,5 +23,4 @@ class BoolVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Email.php b/src/Phalcon/Filter/Sanitize/Email.php index 5dfab0c8..26f81b73 100644 --- a/src/Phalcon/Filter/Sanitize/Email.php +++ b/src/Phalcon/Filter/Sanitize/Email.php @@ -23,5 +23,4 @@ class Email public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/FloatVal.php b/src/Phalcon/Filter/Sanitize/FloatVal.php index 6341decf..8ab85789 100644 --- a/src/Phalcon/Filter/Sanitize/FloatVal.php +++ b/src/Phalcon/Filter/Sanitize/FloatVal.php @@ -23,5 +23,4 @@ class FloatVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/IntVal.php b/src/Phalcon/Filter/Sanitize/IntVal.php index 1583ff87..dac4e5c3 100644 --- a/src/Phalcon/Filter/Sanitize/IntVal.php +++ b/src/Phalcon/Filter/Sanitize/IntVal.php @@ -23,5 +23,4 @@ class IntVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Lower.php b/src/Phalcon/Filter/Sanitize/Lower.php index a61fa1c6..c25fda7c 100644 --- a/src/Phalcon/Filter/Sanitize/Lower.php +++ b/src/Phalcon/Filter/Sanitize/Lower.php @@ -23,5 +23,4 @@ class Lower public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/LowerFirst.php b/src/Phalcon/Filter/Sanitize/LowerFirst.php index d331cf11..9595ffff 100644 --- a/src/Phalcon/Filter/Sanitize/LowerFirst.php +++ b/src/Phalcon/Filter/Sanitize/LowerFirst.php @@ -23,5 +23,4 @@ class LowerFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Regex.php b/src/Phalcon/Filter/Sanitize/Regex.php index 8817613c..7441191b 100644 --- a/src/Phalcon/Filter/Sanitize/Regex.php +++ b/src/Phalcon/Filter/Sanitize/Regex.php @@ -25,5 +25,4 @@ class Regex public function __invoke($input, $pattern, $replace) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Remove.php b/src/Phalcon/Filter/Sanitize/Remove.php index 1c7a90e5..a8225560 100644 --- a/src/Phalcon/Filter/Sanitize/Remove.php +++ b/src/Phalcon/Filter/Sanitize/Remove.php @@ -24,5 +24,4 @@ class Remove public function __invoke($input, $replace) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Replace.php b/src/Phalcon/Filter/Sanitize/Replace.php index 05a72069..6a60ca8f 100644 --- a/src/Phalcon/Filter/Sanitize/Replace.php +++ b/src/Phalcon/Filter/Sanitize/Replace.php @@ -25,5 +25,4 @@ class Replace public function __invoke($input, $from, $to) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Special.php b/src/Phalcon/Filter/Sanitize/Special.php index 33735f44..9ab25623 100644 --- a/src/Phalcon/Filter/Sanitize/Special.php +++ b/src/Phalcon/Filter/Sanitize/Special.php @@ -23,5 +23,4 @@ class Special public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/SpecialFull.php b/src/Phalcon/Filter/Sanitize/SpecialFull.php index 5170dfb7..f57bad76 100644 --- a/src/Phalcon/Filter/Sanitize/SpecialFull.php +++ b/src/Phalcon/Filter/Sanitize/SpecialFull.php @@ -23,5 +23,4 @@ class SpecialFull public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/StringVal.php b/src/Phalcon/Filter/Sanitize/StringVal.php index 798afafc..a2fcb069 100644 --- a/src/Phalcon/Filter/Sanitize/StringVal.php +++ b/src/Phalcon/Filter/Sanitize/StringVal.php @@ -23,5 +23,4 @@ class StringVal public function __invoke($input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Striptags.php b/src/Phalcon/Filter/Sanitize/Striptags.php index 94588b4a..0b8a60b2 100644 --- a/src/Phalcon/Filter/Sanitize/Striptags.php +++ b/src/Phalcon/Filter/Sanitize/Striptags.php @@ -23,5 +23,4 @@ class Striptags public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Trim.php b/src/Phalcon/Filter/Sanitize/Trim.php index 73b27c53..4d20bd15 100644 --- a/src/Phalcon/Filter/Sanitize/Trim.php +++ b/src/Phalcon/Filter/Sanitize/Trim.php @@ -23,5 +23,4 @@ class Trim public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Upper.php b/src/Phalcon/Filter/Sanitize/Upper.php index b6232b24..73eaa13a 100644 --- a/src/Phalcon/Filter/Sanitize/Upper.php +++ b/src/Phalcon/Filter/Sanitize/Upper.php @@ -23,5 +23,4 @@ class Upper public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/UpperFirst.php b/src/Phalcon/Filter/Sanitize/UpperFirst.php index 29abcedd..52a48308 100644 --- a/src/Phalcon/Filter/Sanitize/UpperFirst.php +++ b/src/Phalcon/Filter/Sanitize/UpperFirst.php @@ -23,5 +23,4 @@ class UpperFirst public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/UpperWords.php b/src/Phalcon/Filter/Sanitize/UpperWords.php index 1a7a72e5..a0ffce76 100644 --- a/src/Phalcon/Filter/Sanitize/UpperWords.php +++ b/src/Phalcon/Filter/Sanitize/UpperWords.php @@ -23,5 +23,4 @@ class UpperWords public function __invoke(string $input) { } - } diff --git a/src/Phalcon/Filter/Sanitize/Url.php b/src/Phalcon/Filter/Sanitize/Url.php index fdd131c4..8a9ee8d9 100644 --- a/src/Phalcon/Filter/Sanitize/Url.php +++ b/src/Phalcon/Filter/Sanitize/Url.php @@ -23,5 +23,4 @@ class Url public function __invoke($input) { } - } diff --git a/src/Phalcon/Flash/AbstractFlash.php b/src/Phalcon/Flash/AbstractFlash.php index 3d23a6c3..03f20ae9 100644 --- a/src/Phalcon/Flash/AbstractFlash.php +++ b/src/Phalcon/Flash/AbstractFlash.php @@ -24,7 +24,7 @@ * $flash->error("Cannot open the file"); * ``` */ -abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\Flash\FlashInterface +abstract class AbstractFlash extends AbstractInjectionAware implements FlashInterface { /** * @var bool @@ -91,10 +91,10 @@ public function getCustomTemplate(): string /** * Phalcon\Flash constructor * - * @param \Phalcon\Escaper\EscaperInterface $escaper - * @param \Phalcon\Session\ManagerInterface $session + * @param EscaperInterface $escaper + * @param SessionInterface $session */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) + public function __construct(EscaperInterface $escaper = null, SessionInterface $session = null) { } @@ -187,10 +187,10 @@ public function setCustomTemplate(string $customTemplate): FlashInterface /** * Sets the Escaper Service * - * @param \Phalcon\Escaper\EscaperInterface $escaperService + * @param EscaperInterface $escaperService * @return FlashInterface */ - public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface + public function setEscaperService(EscaperInterface $escaperService): FlashInterface { } @@ -278,5 +278,4 @@ private function prepareEscapedMessage(string $message): string private function prepareHtmlMessage(string $type, string $message): string { } - } diff --git a/src/Phalcon/Flash/Direct.php b/src/Phalcon/Flash/Direct.php index af28ca9c..6291d331 100644 --- a/src/Phalcon/Flash/Direct.php +++ b/src/Phalcon/Flash/Direct.php @@ -13,7 +13,7 @@ * This is a variant of the Phalcon\Flash that immediately outputs any message * passed to it */ -class Direct extends \Phalcon\Flash\AbstractFlash +class Direct extends AbstractFlash { /** @@ -36,5 +36,4 @@ public function message(string $type, $message): ?string public function output(bool $remove = true) { } - } diff --git a/src/Phalcon/Flash/FlashInterface.php b/src/Phalcon/Flash/FlashInterface.php index 5ef00ebd..d311b268 100644 --- a/src/Phalcon/Flash/FlashInterface.php +++ b/src/Phalcon/Flash/FlashInterface.php @@ -57,5 +57,4 @@ public function success(string $message): string; * @return string */ public function warning(string $message): string; - } diff --git a/src/Phalcon/Flash/Session.php b/src/Phalcon/Flash/Session.php index ed658964..12ef6ba9 100644 --- a/src/Phalcon/Flash/Session.php +++ b/src/Phalcon/Flash/Session.php @@ -16,7 +16,7 @@ * Temporarily stores the messages in session, then messages can be printed in * the next request */ -class Session extends \Phalcon\Flash\AbstractFlash +class Session extends AbstractFlash { /** @@ -99,5 +99,4 @@ protected function setSessionMessages(array $messages): array public function getSessionService(): ManagerInterface { } - } diff --git a/src/Phalcon/Forms/Element/AbstractElement.php b/src/Phalcon/Forms/Element/AbstractElement.php index 3ece2995..9a1943fd 100644 --- a/src/Phalcon/Forms/Element/AbstractElement.php +++ b/src/Phalcon/Forms/Element/AbstractElement.php @@ -20,7 +20,7 @@ /** * This is a base class for form elements */ -abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterface +abstract class AbstractElement implements ElementInterface { protected $attributes; @@ -84,20 +84,20 @@ public function addFilter(string $filter): ElementInterface /** * Adds a validator to the element * - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ElementInterface */ - public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface + public function addValidator(ValidatorInterface $validator): ElementInterface { } /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] validators + * @param ValidatorInterface[] validators * @param bool $merge * @param array $validators - * @param \Phalcon\Validation\ValidatorInterface [] validators + * @param ValidatorInterface[] validators * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface @@ -107,10 +107,10 @@ public function addValidators(array $validators, bool $merge = true): ElementInt /** * Appends a message to the internal message list * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ElementInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ElementInterface + public function appendMessage(MessageInterface $message): ElementInterface { } @@ -221,7 +221,7 @@ public function getUserOptions(): array /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array|ValidatorInterface[] */ public function getValidators(): array { @@ -312,10 +312,10 @@ public function setFilters($filters): ElementInterface /** * Sets the parent form to the element * - * @param \Phalcon\Forms\Form $form + * @param Form $form * @return ElementInterface */ - public function setForm(\Phalcon\Forms\Form $form): ElementInterface + public function setForm(Form $form): ElementInterface { } @@ -332,10 +332,10 @@ public function setLabel(string $label): ElementInterface /** * Sets the validation messages related to the element * - * @param \Phalcon\Messages\Messages $messages + * @param Messages $messages * @return ElementInterface */ - public function setMessages(\Phalcon\Messages\Messages $messages): ElementInterface + public function setMessages(Messages $messages): ElementInterface { } @@ -369,5 +369,4 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } - } diff --git a/src/Phalcon/Forms/Element/Check.php b/src/Phalcon/Forms/Element/Check.php index 0fe4857b..9ce32d61 100644 --- a/src/Phalcon/Forms/Element/Check.php +++ b/src/Phalcon/Forms/Element/Check.php @@ -16,7 +16,7 @@ * * Component INPUT[type=check] for forms */ -class Check extends \Phalcon\Forms\Element\AbstractElement +class Check extends AbstractElement { /** @@ -28,5 +28,4 @@ class Check extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Date.php b/src/Phalcon/Forms/Element/Date.php index 50d1d1dc..40333ec2 100644 --- a/src/Phalcon/Forms/Element/Date.php +++ b/src/Phalcon/Forms/Element/Date.php @@ -14,7 +14,7 @@ /** * Component INPUT[type=date] for forms */ -class Date extends \Phalcon\Forms\Element\AbstractElement +class Date extends AbstractElement { /** @@ -26,5 +26,4 @@ class Date extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/ElementInterface.php b/src/Phalcon/Forms/Element/ElementInterface.php index e67d9a07..9c4a2407 100644 --- a/src/Phalcon/Forms/Element/ElementInterface.php +++ b/src/Phalcon/Forms/Element/ElementInterface.php @@ -31,18 +31,18 @@ public function addFilter(string $filter): ElementInterface; /** * Adds a validator to the element * - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ElementInterface */ - public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface; + public function addValidator(ValidatorInterface $validator): ElementInterface; /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] + * @param ValidatorInterface[] * @param array $validators * @param bool $merge - * @param \Phalcon\Validation\ValidatorInterface [] + * @param ValidatorInterface[] * @return ElementInterface */ public function addValidators(array $validators, bool $merge = true): ElementInterface; @@ -50,10 +50,10 @@ public function addValidators(array $validators, bool $merge = true): ElementInt /** * Appends a message to the internal message list * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ElementInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ElementInterface; + public function appendMessage(MessageInterface $message): ElementInterface; /** * Clears every element in the form to its default value @@ -140,7 +140,7 @@ public function getUserOptions(): array; /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array|ValidatorInterface[] */ public function getValidators(): array; @@ -220,10 +220,10 @@ public function setFilters($filters): ElementInterface; /** * Sets the parent form to the element * - * @param \Phalcon\Forms\Form $form + * @param Form $form * @return ElementInterface */ - public function setForm(\Phalcon\Forms\Form $form): ElementInterface; + public function setForm(Form $form): ElementInterface; /** * Sets the element label @@ -236,10 +236,10 @@ public function setLabel(string $label): ElementInterface; /** * Sets the validation messages related to the element * - * @param \Phalcon\Messages\Messages $messages + * @param Messages $messages * @return ElementInterface */ - public function setMessages(\Phalcon\Messages\Messages $messages): ElementInterface; + public function setMessages(Messages $messages): ElementInterface; /** * Sets the element's name @@ -265,5 +265,4 @@ public function setUserOption(string $option, $value): ElementInterface; * @return ElementInterface */ public function setUserOptions(array $options): ElementInterface; - } diff --git a/src/Phalcon/Forms/Element/Email.php b/src/Phalcon/Forms/Element/Email.php index 9f39071f..7a58ffa6 100644 --- a/src/Phalcon/Forms/Element/Email.php +++ b/src/Phalcon/Forms/Element/Email.php @@ -16,7 +16,7 @@ * * Component INPUT[type=email] for forms */ -class Email extends \Phalcon\Forms\Element\AbstractElement +class Email extends AbstractElement { /** @@ -28,5 +28,4 @@ class Email extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/File.php b/src/Phalcon/Forms/Element/File.php index 4db2874d..6dd55786 100644 --- a/src/Phalcon/Forms/Element/File.php +++ b/src/Phalcon/Forms/Element/File.php @@ -14,7 +14,7 @@ /** * Component INPUT[type=file] for forms */ -class File extends \Phalcon\Forms\Element\AbstractElement +class File extends AbstractElement { /** @@ -26,5 +26,4 @@ class File extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Hidden.php b/src/Phalcon/Forms/Element/Hidden.php index 739d3c73..8d9c5427 100644 --- a/src/Phalcon/Forms/Element/Hidden.php +++ b/src/Phalcon/Forms/Element/Hidden.php @@ -16,7 +16,7 @@ * * Component INPUT[type=hidden] for forms */ -class Hidden extends \Phalcon\Forms\Element\AbstractElement +class Hidden extends AbstractElement { /** @@ -28,5 +28,4 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Numeric.php b/src/Phalcon/Forms/Element/Numeric.php index 0400349b..df7c8601 100644 --- a/src/Phalcon/Forms/Element/Numeric.php +++ b/src/Phalcon/Forms/Element/Numeric.php @@ -16,7 +16,7 @@ * * Component INPUT[type=number] for forms */ -class Numeric extends \Phalcon\Forms\Element\AbstractElement +class Numeric extends AbstractElement { /** @@ -28,5 +28,4 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Password.php b/src/Phalcon/Forms/Element/Password.php index fddfcc08..6babba80 100644 --- a/src/Phalcon/Forms/Element/Password.php +++ b/src/Phalcon/Forms/Element/Password.php @@ -16,7 +16,7 @@ * * Component INPUT[type=password] for forms */ -class Password extends \Phalcon\Forms\Element\AbstractElement +class Password extends AbstractElement { /** @@ -28,5 +28,4 @@ class Password extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Radio.php b/src/Phalcon/Forms/Element/Radio.php index 171ab83c..253a5c17 100644 --- a/src/Phalcon/Forms/Element/Radio.php +++ b/src/Phalcon/Forms/Element/Radio.php @@ -16,7 +16,7 @@ * * Component INPUT[type=radio] for forms */ -class Radio extends \Phalcon\Forms\Element\AbstractElement +class Radio extends AbstractElement { /** @@ -28,5 +28,4 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Select.php b/src/Phalcon/Forms/Element/Select.php index 05f62264..df267de8 100644 --- a/src/Phalcon/Forms/Element/Select.php +++ b/src/Phalcon/Forms/Element/Select.php @@ -16,7 +16,7 @@ * * Component SELECT (choice) for forms */ -class Select extends \Phalcon\Forms\Element\AbstractElement +class Select extends AbstractElement { protected $optionsValues; @@ -71,5 +71,4 @@ public function render(array $attributes = array()): string public function setOptions($options): ElementInterface { } - } diff --git a/src/Phalcon/Forms/Element/Submit.php b/src/Phalcon/Forms/Element/Submit.php index d4a81f90..276ff6d2 100644 --- a/src/Phalcon/Forms/Element/Submit.php +++ b/src/Phalcon/Forms/Element/Submit.php @@ -14,7 +14,7 @@ /** * Component INPUT[type=submit] for forms */ -class Submit extends \Phalcon\Forms\Element\AbstractElement +class Submit extends AbstractElement { /** @@ -26,5 +26,4 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/Text.php b/src/Phalcon/Forms/Element/Text.php index 846871b5..70d25940 100644 --- a/src/Phalcon/Forms/Element/Text.php +++ b/src/Phalcon/Forms/Element/Text.php @@ -16,7 +16,7 @@ * * Component INPUT[type=text] for forms */ -class Text extends \Phalcon\Forms\Element\AbstractElement +class Text extends AbstractElement { /** @@ -28,5 +28,4 @@ class Text extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Element/TextArea.php b/src/Phalcon/Forms/Element/TextArea.php index 6a49ba0f..3d256b98 100644 --- a/src/Phalcon/Forms/Element/TextArea.php +++ b/src/Phalcon/Forms/Element/TextArea.php @@ -14,7 +14,7 @@ /** * Component TEXTAREA for forms */ -class TextArea extends \Phalcon\Forms\Element\AbstractElement +class TextArea extends AbstractElement { /** @@ -26,5 +26,4 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement public function render(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Forms/Form.php b/src/Phalcon/Forms/Form.php index 601e43da..e36e9013 100644 --- a/src/Phalcon/Forms/Form.php +++ b/src/Phalcon/Forms/Form.php @@ -25,7 +25,7 @@ /** * This component allows to build forms using an object-oriented interface */ -class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\Attributes\AttributesInterface +class Form extends Injectable implements Countable, Iterator, AttributesInterface { /** * @var Attributes | null @@ -82,12 +82,12 @@ public function __construct($entity = null, array $userOptions = array()) /** * Adds an element to the form * - * @param \Phalcon\Forms\Element\ElementInterface $element + * @param ElementInterface $element * @param string $position * @param bool $type * @return Form */ - public function add(\Phalcon\Forms\Element\ElementInterface $element, string $position = null, bool $type = null): Form + public function add(ElementInterface $element, string $position = null, bool $type = null): Form { } @@ -162,7 +162,7 @@ public function getAttributes(): Attributes /** * Returns the form elements added to the form * - * @return array|\Phalcon\Forms\Element\ElementInterface[] + * @return array|ElementInterface[] */ public function getElements(): array { @@ -359,10 +359,10 @@ public function setEntity($entity): Form /** * Set form attributes collection * - * @param \Phalcon\Html\Attributes $attributes + * @param Attributes $attributes * @return AttributesInterface */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface + public function setAttributes(Attributes $attributes): AttributesInterface { } @@ -395,5 +395,4 @@ public function setUserOptions(array $options): Form public function valid(): bool { } - } diff --git a/src/Phalcon/Forms/Manager.php b/src/Phalcon/Forms/Manager.php index 996bea85..89f01681 100644 --- a/src/Phalcon/Forms/Manager.php +++ b/src/Phalcon/Forms/Manager.php @@ -59,5 +59,4 @@ public function has(string $name): bool public function set(string $name, Form $form): Manager { } - } diff --git a/src/Phalcon/Helper/Arr.php b/src/Phalcon/Helper/Arr.php index 03ef41ca..9c318c2f 100644 --- a/src/Phalcon/Helper/Arr.php +++ b/src/Phalcon/Helper/Arr.php @@ -278,5 +278,4 @@ final public static function validateAny(array $collection, $method = null): boo final public static function whiteList(array $collection, array $whiteList): array { } - } diff --git a/src/Phalcon/Helper/Fs.php b/src/Phalcon/Helper/Fs.php index ada075bd..b0ad9265 100644 --- a/src/Phalcon/Helper/Fs.php +++ b/src/Phalcon/Helper/Fs.php @@ -28,5 +28,4 @@ class Fs final public static function basename(string $uri, $suffix = null): string { } - } diff --git a/src/Phalcon/Helper/Json.php b/src/Phalcon/Helper/Json.php index 110f3160..26699f9e 100644 --- a/src/Phalcon/Helper/Json.php +++ b/src/Phalcon/Helper/Json.php @@ -40,7 +40,7 @@ class Json * * @return mixed * - * @throws \InvalidArgumentException if the JSON cannot be decoded. + * @throws InvalidArgumentException if the JSON cannot be decoded. * @link http://www.php.net/manual/en/function.json-decode.php */ final public static function decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) @@ -69,11 +69,10 @@ final public static function decode(string $data, bool $associative = false, int * * @return mixed * - * @throws \InvalidArgumentException if the JSON cannot be encoded. + * @throws InvalidArgumentException if the JSON cannot be encoded. * @link http://www.php.net/manual/en/function.json-encode.php */ final public static function encode($data, int $options = 0, int $depth = 512): string { } - } diff --git a/src/Phalcon/Helper/Number.php b/src/Phalcon/Helper/Number.php index be55148b..09e62a95 100644 --- a/src/Phalcon/Helper/Number.php +++ b/src/Phalcon/Helper/Number.php @@ -28,5 +28,4 @@ class Number final public static function between(int $value, int $from, int $to): bool { } - } diff --git a/src/Phalcon/Helper/Str.php b/src/Phalcon/Helper/Str.php index ac750bc7..ad3c8119 100644 --- a/src/Phalcon/Helper/Str.php +++ b/src/Phalcon/Helper/Str.php @@ -464,5 +464,4 @@ final public static function underscore(string $text): string final public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/Html/Attributes.php b/src/Phalcon/Html/Attributes.php index 41d7c774..b7053c2c 100644 --- a/src/Phalcon/Html/Attributes.php +++ b/src/Phalcon/Html/Attributes.php @@ -16,7 +16,7 @@ /** * This class helps to work with HTML Attributes */ -class Attributes extends Collection implements \Phalcon\Html\Attributes\RenderInterface +class Attributes extends Collection implements RenderInterface { /** @@ -36,5 +36,4 @@ public function render(): string public function __toString(): string { } - } diff --git a/src/Phalcon/Html/Attributes/AttributesInterface.php b/src/Phalcon/Html/Attributes/AttributesInterface.php index b0cb7391..c5a8cc33 100644 --- a/src/Phalcon/Html/Attributes/AttributesInterface.php +++ b/src/Phalcon/Html/Attributes/AttributesInterface.php @@ -29,9 +29,8 @@ public function getAttributes(): Attributes; /** * Set Attributes * - * @param \Phalcon\Html\Attributes $attributes + * @param Attributes $attributes * @return AttributesInterface */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface; - + public function setAttributes(Attributes $attributes): AttributesInterface; } diff --git a/src/Phalcon/Html/Attributes/RenderInterface.php b/src/Phalcon/Html/Attributes/RenderInterface.php index d2a71e41..7fb01f6a 100644 --- a/src/Phalcon/Html/Attributes/RenderInterface.php +++ b/src/Phalcon/Html/Attributes/RenderInterface.php @@ -23,5 +23,4 @@ interface RenderInterface * @return string */ public function render(): string; - } diff --git a/src/Phalcon/Html/Breadcrumbs.php b/src/Phalcon/Html/Breadcrumbs.php index 49a526d3..5b4b9d9b 100644 --- a/src/Phalcon/Html/Breadcrumbs.php +++ b/src/Phalcon/Html/Breadcrumbs.php @@ -130,5 +130,4 @@ public function render(): string public function toArray(): array { } - } diff --git a/src/Phalcon/Html/Helper/AbstractHelper.php b/src/Phalcon/Html/Helper/AbstractHelper.php index ce3a79af..9acb013a 100644 --- a/src/Phalcon/Html/Helper/AbstractHelper.php +++ b/src/Phalcon/Html/Helper/AbstractHelper.php @@ -28,9 +28,9 @@ abstract class AbstractHelper /** * Constructor * - * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param EscaperInterface $escaper */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) + public function __construct(EscaperInterface $escaper) { } @@ -89,5 +89,4 @@ protected function renderAttributes(array $attributes): string protected function selfClose(string $tag, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Anchor.php b/src/Phalcon/Html/Helper/Anchor.php index 6730b1fc..f4cebb00 100644 --- a/src/Phalcon/Html/Helper/Anchor.php +++ b/src/Phalcon/Html/Helper/Anchor.php @@ -14,7 +14,7 @@ * * Creates an anchor */ -class Anchor extends \Phalcon\Html\Helper\AbstractHelper +class Anchor extends AbstractHelper { /** @@ -26,5 +26,4 @@ class Anchor extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/AnchorRaw.php b/src/Phalcon/Html/Helper/AnchorRaw.php index 91a80136..190b1631 100644 --- a/src/Phalcon/Html/Helper/AnchorRaw.php +++ b/src/Phalcon/Html/Helper/AnchorRaw.php @@ -14,7 +14,7 @@ * * Creates a raw anchor */ -class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper +class AnchorRaw extends AbstractHelper { /** @@ -26,5 +26,4 @@ class AnchorRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $href, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Body.php b/src/Phalcon/Html/Helper/Body.php index e2233f65..c5d75d52 100644 --- a/src/Phalcon/Html/Helper/Body.php +++ b/src/Phalcon/Html/Helper/Body.php @@ -14,7 +14,7 @@ * * Creates a body tag */ -class Body extends \Phalcon\Html\Helper\AbstractHelper +class Body extends AbstractHelper { /** @@ -24,5 +24,4 @@ class Body extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Button.php b/src/Phalcon/Html/Helper/Button.php index d1b38b84..d777d6aa 100644 --- a/src/Phalcon/Html/Helper/Button.php +++ b/src/Phalcon/Html/Helper/Button.php @@ -14,7 +14,7 @@ * * Creates a button tag */ -class Button extends \Phalcon\Html\Helper\AbstractHelper +class Button extends AbstractHelper { /** @@ -25,5 +25,4 @@ class Button extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Close.php b/src/Phalcon/Html/Helper/Close.php index 741496f8..1cfd1b89 100644 --- a/src/Phalcon/Html/Helper/Close.php +++ b/src/Phalcon/Html/Helper/Close.php @@ -14,7 +14,7 @@ * * Creates a closing tag */ -class Close extends \Phalcon\Html\Helper\AbstractHelper +class Close extends AbstractHelper { /** @@ -25,5 +25,4 @@ class Close extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag): string { } - } diff --git a/src/Phalcon/Html/Helper/Element.php b/src/Phalcon/Html/Helper/Element.php index ea372eda..d7e41795 100644 --- a/src/Phalcon/Html/Helper/Element.php +++ b/src/Phalcon/Html/Helper/Element.php @@ -14,7 +14,7 @@ * * Creates an element */ -class Element extends \Phalcon\Html\Helper\AbstractHelper +class Element extends AbstractHelper { /** @@ -26,5 +26,4 @@ class Element extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/ElementRaw.php b/src/Phalcon/Html/Helper/ElementRaw.php index 13ad5f4b..3131133f 100644 --- a/src/Phalcon/Html/Helper/ElementRaw.php +++ b/src/Phalcon/Html/Helper/ElementRaw.php @@ -16,7 +16,7 @@ * * Creates an element raw */ -class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper +class ElementRaw extends AbstractHelper { /** @@ -30,5 +30,4 @@ class ElementRaw extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $tag, string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Form.php b/src/Phalcon/Html/Helper/Form.php index 57a5fb31..7962f26d 100644 --- a/src/Phalcon/Html/Helper/Form.php +++ b/src/Phalcon/Html/Helper/Form.php @@ -14,7 +14,7 @@ * * Creates a form opening tag */ -class Form extends \Phalcon\Html\Helper\AbstractHelper +class Form extends AbstractHelper { /** @@ -24,5 +24,4 @@ class Form extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Img.php b/src/Phalcon/Html/Helper/Img.php index 0faa56b8..e13cbc34 100644 --- a/src/Phalcon/Html/Helper/Img.php +++ b/src/Phalcon/Html/Helper/Img.php @@ -16,7 +16,7 @@ * * Creates am img tag */ -class Img extends \Phalcon\Html\Helper\AbstractHelper +class Img extends AbstractHelper { /** @@ -29,5 +29,4 @@ class Img extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $src, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/Label.php b/src/Phalcon/Html/Helper/Label.php index 773932c4..646521a6 100644 --- a/src/Phalcon/Html/Helper/Label.php +++ b/src/Phalcon/Html/Helper/Label.php @@ -16,7 +16,7 @@ * * Creates a label */ -class Label extends \Phalcon\Html\Helper\AbstractHelper +class Label extends AbstractHelper { /** @@ -28,5 +28,4 @@ class Label extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Helper/TextArea.php b/src/Phalcon/Html/Helper/TextArea.php index 50c632ce..fdc0460c 100644 --- a/src/Phalcon/Html/Helper/TextArea.php +++ b/src/Phalcon/Html/Helper/TextArea.php @@ -14,7 +14,7 @@ * * Creates a textarea tag */ -class TextArea extends \Phalcon\Html\Helper\AbstractHelper +class TextArea extends AbstractHelper { /** @@ -25,5 +25,4 @@ class TextArea extends \Phalcon\Html\Helper\AbstractHelper public function __invoke(string $text, array $attributes = array()): string { } - } diff --git a/src/Phalcon/Html/Link/EvolvableLink.php b/src/Phalcon/Html/Link/EvolvableLink.php index 787dfbf9..7c7021be 100644 --- a/src/Phalcon/Html/Link/EvolvableLink.php +++ b/src/Phalcon/Html/Link/EvolvableLink.php @@ -19,7 +19,7 @@ * @property array rels * @property bool templated */ -class EvolvableLink extends \Phalcon\Html\Link\Link implements \Psr\Link\EvolvableLinkInterface +class EvolvableLink extends Link implements EvolvableLinkInterface { /** @@ -98,5 +98,4 @@ public function withoutAttribute($attribute) public function withoutRel($rel) { } - } diff --git a/src/Phalcon/Html/Link/EvolvableLinkProvider.php b/src/Phalcon/Html/Link/EvolvableLinkProvider.php index 0846b9ca..b71635a0 100644 --- a/src/Phalcon/Html/Link/EvolvableLinkProvider.php +++ b/src/Phalcon/Html/Link/EvolvableLinkProvider.php @@ -17,7 +17,7 @@ * * @property LinkInterface[] links */ -class EvolvableLinkProvider extends \Phalcon\Html\Link\LinkProvider implements \Psr\Link\EvolvableLinkProviderInterface +class EvolvableLinkProvider extends LinkProvider implements EvolvableLinkProviderInterface { /** @@ -31,7 +31,7 @@ class EvolvableLinkProvider extends \Phalcon\Html\Link\LinkProvider implements \ * * @return static */ - public function withLink(\Psr\Link\LinkInterface $link) + public function withLink(LinkInterface $link) { } @@ -46,8 +46,7 @@ public function withLink(\Psr\Link\LinkInterface $link) * * @return static */ - public function withoutLink(\Psr\Link\LinkInterface $link) + public function withoutLink(LinkInterface $link) { } - } diff --git a/src/Phalcon/Html/Link/Link.php b/src/Phalcon/Html/Link/Link.php index 94eed4c7..cd43bba5 100644 --- a/src/Phalcon/Html/Link/Link.php +++ b/src/Phalcon/Html/Link/Link.php @@ -20,7 +20,7 @@ * @property array rels * @property bool templated */ -class Link implements \Psr\Link\LinkInterface +class Link implements LinkInterface { /** * @var Collection @@ -115,5 +115,4 @@ public function isTemplated() protected function hrefIsTemplated(string $href): bool { } - } diff --git a/src/Phalcon/Html/Link/LinkProvider.php b/src/Phalcon/Html/Link/LinkProvider.php index 7b6a0adb..8628404d 100644 --- a/src/Phalcon/Html/Link/LinkProvider.php +++ b/src/Phalcon/Html/Link/LinkProvider.php @@ -11,13 +11,14 @@ use Psr\Link\LinkInterface; use Psr\Link\LinkProviderInterface; +use Traversable; /** * Class Phalcon\Http\Link\LinkProvider * * @property LinkInterface[] links */ -class LinkProvider implements \Psr\Link\LinkProviderInterface +class LinkProvider implements LinkProviderInterface { /** * @var LinkInterface[] @@ -40,7 +41,7 @@ public function __construct(array $links = array()) * The iterable may be an array or any PHP \Traversable object. If no links * are available, an empty array or \Traversable MUST be returned. * - * @return LinkInterface[]|\Traversable + * @return LinkInterface[]|Traversable */ public function getLinks() { @@ -67,8 +68,7 @@ public function getLinksByRel($rel) * @param LinkInterface $link * * @return string */ - protected function getKey(\Psr\Link\LinkInterface $link): string + protected function getKey(LinkInterface $link): string { } - } diff --git a/src/Phalcon/Html/Link/Serializer/Header.php b/src/Phalcon/Html/Link/Serializer/Header.php index 9efafa8f..91576e35 100644 --- a/src/Phalcon/Html/Link/Serializer/Header.php +++ b/src/Phalcon/Html/Link/Serializer/Header.php @@ -14,7 +14,7 @@ /** * Class Phalcon\Http\Link\Serializer\Header */ -class Header implements \Phalcon\Html\Link\Serializer\SerializerInterface +class Header implements SerializerInterface { /** @@ -26,5 +26,4 @@ class Header implements \Phalcon\Html\Link\Serializer\SerializerInterface public function serialize(array $links): ?string { } - } diff --git a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php index 9b922a51..d2804463 100644 --- a/src/Phalcon/Html/Link/Serializer/SerializerInterface.php +++ b/src/Phalcon/Html/Link/Serializer/SerializerInterface.php @@ -22,5 +22,4 @@ interface SerializerInterface * @return string|null */ public function serialize(array $links): ?string; - } diff --git a/src/Phalcon/Html/TagFactory.php b/src/Phalcon/Html/TagFactory.php index ede1e8ce..e58eae95 100644 --- a/src/Phalcon/Html/TagFactory.php +++ b/src/Phalcon/Html/TagFactory.php @@ -27,10 +27,10 @@ class TagFactory extends AbstractFactory /** * TagFactory constructor. * - * @param \Phalcon\Escaper\EscaperInterface $escaper + * @param EscaperInterface $escaper * @param array $services */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper, array $services = array()) + public function __construct(EscaperInterface $escaper, array $services = array()) { } @@ -49,5 +49,4 @@ public function newInstance(string $name) protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Http/Cookie.php b/src/Phalcon/Http/Cookie.php index 14792c37..e1bc8f3c 100644 --- a/src/Phalcon/Http/Cookie.php +++ b/src/Phalcon/Http/Cookie.php @@ -22,7 +22,7 @@ /** * Provide OO wrappers to manage a HTTP cookie. */ -class Cookie extends AbstractInjectionAware implements \Phalcon\Http\Cookie\CookieInterface +class Cookie extends AbstractInjectionAware implements CookieInterface { /** * @var string @@ -298,10 +298,10 @@ public function setSecure(bool $secure): CookieInterface * * Use NULL to disable cookie signing. * - * @see \Phalcon\Security\Random - * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey * @return CookieInterface + *@throws CookieException + * @see \Phalcon\Security\Random */ public function setSignKey(string $signKey = null): CookieInterface { @@ -330,12 +330,11 @@ public function useEncryption(bool $useEncryption): CookieInterface /** * Assert the cookie's key is enough long. * - * @throws \Phalcon\Http\Cookie\Exception * @param string $signKey * @return void + *@throws CookieException */ protected function assertSignKeyIsLongEnough(string $signKey) { } - } diff --git a/src/Phalcon/Http/Cookie/CookieInterface.php b/src/Phalcon/Http/Cookie/CookieInterface.php index e1be940d..5fa14d63 100644 --- a/src/Phalcon/Http/Cookie/CookieInterface.php +++ b/src/Phalcon/Http/Cookie/CookieInterface.php @@ -157,5 +157,4 @@ public function setValue($value): CookieInterface; * @return CookieInterface */ public function useEncryption(bool $useEncryption): CookieInterface; - } diff --git a/src/Phalcon/Http/Message/AbstractCommon.php b/src/Phalcon/Http/Message/AbstractCommon.php index 0bb36e48..e2b49ac6 100644 --- a/src/Phalcon/Http/Message/AbstractCommon.php +++ b/src/Phalcon/Http/Message/AbstractCommon.php @@ -51,5 +51,4 @@ final protected function checkStringParameter($element) final protected function processWith($element, string $property) { } - } diff --git a/src/Phalcon/Http/Message/AbstractMessage.php b/src/Phalcon/Http/Message/AbstractMessage.php index 22907bad..51d055ff 100644 --- a/src/Phalcon/Http/Message/AbstractMessage.php +++ b/src/Phalcon/Http/Message/AbstractMessage.php @@ -17,7 +17,7 @@ /** * Message methods */ -abstract class AbstractMessage extends \Phalcon\Http\Message\AbstractCommon +abstract class AbstractMessage extends AbstractCommon { /** * Gets the body of the message. @@ -203,7 +203,7 @@ public function withAddedHeader($name, $value) * @throws InvalidArgumentException When the body is not valid. * */ - public function withBody(\Psr\Http\Message\StreamInterface $body) + public function withBody(StreamInterface $body) { } @@ -276,7 +276,7 @@ public function withoutHeader($name) * * @return Collection */ - final protected function checkHeaderHost(\Phalcon\Collection $collection): Collection + final protected function checkHeaderHost(Collection $collection): Collection { } @@ -359,7 +359,7 @@ final protected function getHeaderValue($values): array * * @return string */ - final protected function getUriHost(\Psr\Http\Message\UriInterface $uri): string + final protected function getUriHost(UriInterface $uri): string { } @@ -406,5 +406,4 @@ final protected function processHeaders($headers): Collection final protected function processProtocol($protocol = ''): string { } - } diff --git a/src/Phalcon/Http/Message/AbstractRequest.php b/src/Phalcon/Http/Message/AbstractRequest.php index afebdec7..7d34aff6 100644 --- a/src/Phalcon/Http/Message/AbstractRequest.php +++ b/src/Phalcon/Http/Message/AbstractRequest.php @@ -16,7 +16,7 @@ /** * Request methods */ -abstract class AbstractRequest extends \Phalcon\Http\Message\AbstractMessage +abstract class AbstractRequest extends AbstractMessage { /** * Retrieves the HTTP method of the request. @@ -158,7 +158,7 @@ public function withRequestTarget($requestTarget) * * @return object */ - public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false) + public function withUri(UriInterface $uri, $preserveHost = false) { } @@ -183,5 +183,4 @@ final protected function processMethod($method = ''): string final protected function processUri($uri): UriInterface { } - } diff --git a/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php index 9ceabc76..22146596 100644 --- a/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php +++ b/src/Phalcon/Http/Message/Exception/InvalidArgumentException.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class InvalidArgumentException extends \InvalidArgumentException implements \Throwable +class InvalidArgumentException extends \InvalidArgumentException implements Throwable { } diff --git a/src/Phalcon/Http/Message/Request.php b/src/Phalcon/Http/Message/Request.php index 7f4190ab..e74d9cc2 100644 --- a/src/Phalcon/Http/Message/Request.php +++ b/src/Phalcon/Http/Message/Request.php @@ -18,7 +18,7 @@ /** * PSR-7 Request */ -final class Request extends AbstractRequest implements \Psr\Http\Message\RequestInterface +final class Request extends AbstractRequest implements RequestInterface { /** @@ -32,5 +32,4 @@ final class Request extends AbstractRequest implements \Psr\Http\Message\Request public function __construct(string $method = 'GET', $uri = null, $body = 'php://memory', $headers = array()) { } - } diff --git a/src/Phalcon/Http/Message/RequestFactory.php b/src/Phalcon/Http/Message/RequestFactory.php index a1964d55..f4afc838 100644 --- a/src/Phalcon/Http/Message/RequestFactory.php +++ b/src/Phalcon/Http/Message/RequestFactory.php @@ -16,7 +16,7 @@ /** * PSR-17 RequestFactory */ -final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface +final class RequestFactory implements RequestFactoryInterface { /** @@ -30,5 +30,4 @@ final class RequestFactory implements \Psr\Http\Message\RequestFactoryInterface public function createRequest(string $method, $uri): RequestInterface { } - } diff --git a/src/Phalcon/Http/Message/Response.php b/src/Phalcon/Http/Message/Response.php index 2d5c9fe7..260d8a0a 100644 --- a/src/Phalcon/Http/Message/Response.php +++ b/src/Phalcon/Http/Message/Response.php @@ -17,7 +17,7 @@ /** * PSR-7 Response */ -final class Response extends AbstractMessage implements \Psr\Http\Message\ResponseInterface +final class Response extends AbstractMessage implements ResponseInterface { /** * Gets the response reason phrase associated with the status code. @@ -149,5 +149,4 @@ private function getPhrases(): array private function processCode($code, $phrase = '') { } - } diff --git a/src/Phalcon/Http/Message/ResponseFactory.php b/src/Phalcon/Http/Message/ResponseFactory.php index 12802988..f3339e3e 100644 --- a/src/Phalcon/Http/Message/ResponseFactory.php +++ b/src/Phalcon/Http/Message/ResponseFactory.php @@ -15,7 +15,7 @@ /** * PSR-17 ResponseFactory */ -final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterface +final class ResponseFactory implements ResponseFactoryInterface { /** @@ -32,5 +32,4 @@ final class ResponseFactory implements \Psr\Http\Message\ResponseFactoryInterfac public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface { } - } diff --git a/src/Phalcon/Http/Message/ServerRequest.php b/src/Phalcon/Http/Message/ServerRequest.php index d37bac89..d8241d01 100644 --- a/src/Phalcon/Http/Message/ServerRequest.php +++ b/src/Phalcon/Http/Message/ServerRequest.php @@ -20,7 +20,7 @@ /** * PSR-7 ServerRequest */ -final class ServerRequest extends \Phalcon\Http\Message\AbstractRequest implements \Psr\Http\Message\ServerRequestInterface +final class ServerRequest extends AbstractRequest implements ServerRequestInterface { /** * @var Collection @@ -365,5 +365,4 @@ public function withoutAttribute($name): ServerRequest private function checkUploadedFiles(array $files) { } - } diff --git a/src/Phalcon/Http/Message/ServerRequestFactory.php b/src/Phalcon/Http/Message/ServerRequestFactory.php index d0daf697..6e028873 100644 --- a/src/Phalcon/Http/Message/ServerRequestFactory.php +++ b/src/Phalcon/Http/Message/ServerRequestFactory.php @@ -20,7 +20,7 @@ /** * PSR-17 ServerRequestFactory */ -class ServerRequestFactory implements \Psr\Http\Message\ServerRequestFactoryInterface +class ServerRequestFactory implements ServerRequestFactoryInterface { /** @@ -84,7 +84,7 @@ protected function getHeaders() * * @return array */ - private function calculateUriHost(\Phalcon\Collection $server, \Phalcon\Collection $headers): array + private function calculateUriHost(Collection $server, Collection $headers): array { } @@ -107,7 +107,7 @@ private function calculateUriHostFromHeader(string $host): array * * @return string */ - private function calculateUriPath(\Phalcon\Collection $server): string + private function calculateUriPath(Collection $server): string { } @@ -118,7 +118,7 @@ private function calculateUriPath(\Phalcon\Collection $server): string * * @return string */ - private function calculateUriQuery(\Phalcon\Collection $server): string + private function calculateUriQuery(Collection $server): string { } @@ -130,7 +130,7 @@ private function calculateUriQuery(\Phalcon\Collection $server): string * * @return string */ - private function calculateUriScheme(\Phalcon\Collection $server, \Phalcon\Collection $headers): string + private function calculateUriScheme(Collection $server, Collection $headers): string { } @@ -168,7 +168,7 @@ private function createUploadedFile(array $file): UploadedFile * * @return mixed|string */ - private function getHeader(\Phalcon\Collection $headers, string $name, $defaultValue = null) + private function getHeader(Collection $headers, string $name, $defaultValue = null) { } @@ -191,7 +191,7 @@ private function parseCookieHeader(string $cookieHeader): array * * @return Collection */ - private function parseHeaders(\Phalcon\Collection $server): Collection + private function parseHeaders(Collection $server): Collection { } @@ -202,7 +202,7 @@ private function parseHeaders(\Phalcon\Collection $server): Collection * * @return string */ - private function parseProtocol(\Phalcon\Collection $server): string + private function parseProtocol(Collection $server): string { } @@ -239,8 +239,7 @@ private function parseUploadedFiles(array $files): Collection * * @return Uri */ - private function parseUri(\Phalcon\Collection $server, \Phalcon\Collection $headers): Uri + private function parseUri(Collection $server, Collection $headers): Uri { } - } diff --git a/src/Phalcon/Http/Message/Stream.php b/src/Phalcon/Http/Message/Stream.php index 9f0aa50c..147729bb 100644 --- a/src/Phalcon/Http/Message/Stream.php +++ b/src/Phalcon/Http/Message/Stream.php @@ -17,7 +17,7 @@ /** * PSR-7 Stream */ -class Stream implements \Psr\Http\Message\StreamInterface +class Stream implements StreamInterface { /** * @var resource | null @@ -253,5 +253,4 @@ private function checkSeekable() private function checkWritable() { } - } diff --git a/src/Phalcon/Http/Message/Stream/Input.php b/src/Phalcon/Http/Message/Stream/Input.php index bb33507f..2e3f6696 100644 --- a/src/Phalcon/Http/Message/Stream/Input.php +++ b/src/Phalcon/Http/Message/Stream/Input.php @@ -89,5 +89,4 @@ public function isWritable(): bool public function read($length): string { } - } diff --git a/src/Phalcon/Http/Message/Stream/Memory.php b/src/Phalcon/Http/Message/Stream/Memory.php index 2f83336f..efa30ca4 100644 --- a/src/Phalcon/Http/Message/Stream/Memory.php +++ b/src/Phalcon/Http/Message/Stream/Memory.php @@ -29,5 +29,4 @@ class Memory extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/Http/Message/Stream/Temp.php b/src/Phalcon/Http/Message/Stream/Temp.php index bd28c2f7..13dc1d8c 100644 --- a/src/Phalcon/Http/Message/Stream/Temp.php +++ b/src/Phalcon/Http/Message/Stream/Temp.php @@ -29,5 +29,4 @@ class Temp extends Stream public function __construct($mode = 'rb') { } - } diff --git a/src/Phalcon/Http/Message/StreamFactory.php b/src/Phalcon/Http/Message/StreamFactory.php index 5cdb0cb8..ed5c5f7e 100644 --- a/src/Phalcon/Http/Message/StreamFactory.php +++ b/src/Phalcon/Http/Message/StreamFactory.php @@ -16,7 +16,7 @@ /** * PSR-17 StreamFactory */ -final class StreamFactory implements \Psr\Http\Message\StreamFactoryInterface +final class StreamFactory implements StreamFactoryInterface { /** @@ -62,5 +62,4 @@ public function createStreamFromFile(string $filename, string $mode = 'r+b'): St public function createStreamFromResource($phpResource): StreamInterface { } - } diff --git a/src/Phalcon/Http/Message/UploadedFile.php b/src/Phalcon/Http/Message/UploadedFile.php index 69d28aca..7f76ed9c 100644 --- a/src/Phalcon/Http/Message/UploadedFile.php +++ b/src/Phalcon/Http/Message/UploadedFile.php @@ -20,7 +20,7 @@ /** * PSR-7 UploadedFile */ -final class UploadedFile implements \Psr\Http\Message\UploadedFileInterface +final class UploadedFile implements UploadedFileInterface { /** * If the file has already been moved, we hold that status here @@ -274,5 +274,4 @@ private function getErrorDescription(int $error): string private function storeFile(string $targetPath) { } - } diff --git a/src/Phalcon/Http/Message/UploadedFileFactory.php b/src/Phalcon/Http/Message/UploadedFileFactory.php index 093f89d5..8d9f9bc6 100644 --- a/src/Phalcon/Http/Message/UploadedFileFactory.php +++ b/src/Phalcon/Http/Message/UploadedFileFactory.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Http\Message; +use InvalidArgumentException; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileFactoryInterface; @@ -16,7 +17,7 @@ /** * PSR-17 UploadedFileFactory */ -final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactoryInterface +final class UploadedFileFactory implements UploadedFileFactoryInterface { /** @@ -35,11 +36,10 @@ final class UploadedFileFactory implements \Psr\Http\Message\UploadedFileFactory * @param string $clientFilename The filename as provided by the client, if any. * @param string $clientMediaType The media type as provided by the client, if any. * - * @throws \InvalidArgumentException If the file resource is not readable. + * @throws InvalidArgumentException If the file resource is not readable. * @return UploadedFileInterface */ - public function createUploadedFile(\Psr\Http\Message\StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface + public function createUploadedFile(StreamInterface $stream, int $size = null, int $error = 0, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface { } - } diff --git a/src/Phalcon/Http/Message/Uri.php b/src/Phalcon/Http/Message/Uri.php index 6f7bfdad..8b8351c3 100644 --- a/src/Phalcon/Http/Message/Uri.php +++ b/src/Phalcon/Http/Message/Uri.php @@ -17,7 +17,7 @@ /** * PSR-7 Uri */ -final class Uri extends \Phalcon\Http\Message\AbstractCommon implements \Psr\Http\Message\UriInterface +final class Uri extends AbstractCommon implements UriInterface { /** * Returns the fragment of the URL @@ -474,5 +474,4 @@ private function filterScheme(string $scheme): string private function splitQueryValue(string $element): array { } - } diff --git a/src/Phalcon/Http/Message/UriFactory.php b/src/Phalcon/Http/Message/UriFactory.php index 81168be2..ba42c217 100644 --- a/src/Phalcon/Http/Message/UriFactory.php +++ b/src/Phalcon/Http/Message/UriFactory.php @@ -15,7 +15,7 @@ /** * PSR-17 UriFactory */ -final class UriFactory implements \Psr\Http\Message\UriFactoryInterface +final class UriFactory implements UriFactoryInterface { /** @@ -28,5 +28,4 @@ final class UriFactory implements \Psr\Http\Message\UriFactoryInterface public function createUri(string $uri = ''): UriInterface { } - } diff --git a/src/Phalcon/Http/Request.php b/src/Phalcon/Http/Request.php index b69a60d7..0031f311 100644 --- a/src/Phalcon/Http/Request.php +++ b/src/Phalcon/Http/Request.php @@ -46,7 +46,7 @@ * $request->getLanguages(); * ``` */ -class Request extends AbstractInjectionAware implements \Phalcon\Http\RequestInterface +class Request extends AbstractInjectionAware implements RequestInterface { private $filterService; @@ -487,7 +487,7 @@ public function getServerName(): string * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] + * @return array|FileInterface[] */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array { @@ -870,5 +870,4 @@ private function getFilterService(): FilterInterface private function getServerArray(): array { } - } diff --git a/src/Phalcon/Http/Request/File.php b/src/Phalcon/Http/Request/File.php index e9e9d497..63bfbd7a 100644 --- a/src/Phalcon/Http/Request/File.php +++ b/src/Phalcon/Http/Request/File.php @@ -32,7 +32,7 @@ * } * ``` */ -class File implements \Phalcon\Http\Request\FileInterface +class File implements FileInterface { /** * @var string|null @@ -160,5 +160,4 @@ public function isUploadedFile(): bool public function moveTo(string $destination): bool { } - } diff --git a/src/Phalcon/Http/Request/FileInterface.php b/src/Phalcon/Http/Request/FileInterface.php index 5568443b..87883513 100644 --- a/src/Phalcon/Http/Request/FileInterface.php +++ b/src/Phalcon/Http/Request/FileInterface.php @@ -67,5 +67,4 @@ public function getType(): string; * @return bool */ public function moveTo(string $destination): bool; - } diff --git a/src/Phalcon/Http/RequestInterface.php b/src/Phalcon/Http/RequestInterface.php index 70034d4e..58a3a666 100644 --- a/src/Phalcon/Http/RequestInterface.php +++ b/src/Phalcon/Http/RequestInterface.php @@ -344,7 +344,7 @@ public function getServerName(): string; * * @param bool $onlySuccessful * @param bool $namedKeys - * @return array|\Phalcon\Http\Request\FileInterface[] + * @return array|FileInterface[] */ public function getUploadedFiles(bool $onlySuccessful = false, bool $namedKeys = false): array; @@ -511,5 +511,4 @@ public function isTrace(): bool; * @return int */ public function numFiles(bool $onlySuccessful = false): int; - } diff --git a/src/Phalcon/Http/Response.php b/src/Phalcon/Http/Response.php index 51b425b0..d2e3b6fe 100644 --- a/src/Phalcon/Http/Response.php +++ b/src/Phalcon/Http/Response.php @@ -39,7 +39,7 @@ * $response->send(); * ``` */ -class Response implements \Phalcon\Http\ResponseInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Response implements ResponseInterface, InjectionAwareInterface, EventsAwareInterface { protected $container; @@ -322,20 +322,20 @@ public function setContentType(string $contentType, $charset = null): ResponseIn /** * Sets a cookies bag for the response externally * - * @param \Phalcon\Http\Response\CookiesInterface $cookies + * @param CookiesInterface $cookies * @return ResponseInterface */ - public function setCookies(\Phalcon\Http\Response\CookiesInterface $cookies): ResponseInterface + public function setCookies(CookiesInterface $cookies): ResponseInterface { } /** * Sets the dependency injector * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -366,20 +366,20 @@ public function setEtag(string $etag): ResponseInterface * ); * ``` * - * @param \DateTime $datetime + * @param DateTime $datetime * @return ResponseInterface */ - public function setExpires(\DateTime $datetime): ResponseInterface + public function setExpires(DateTime $datetime): ResponseInterface { } /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -413,10 +413,10 @@ public function setHeader(string $name, $value): ResponseInterface /** * Sets a headers bag for the response externally * - * @param \Phalcon\Http\Response\HeadersInterface $headers + * @param HeadersInterface $headers * @return ResponseInterface */ - public function setHeaders(\Phalcon\Http\Response\HeadersInterface $headers): ResponseInterface + public function setHeaders(HeadersInterface $headers): ResponseInterface { } @@ -450,10 +450,10 @@ public function setJsonContent($content, int $jsonOptions = 0, int $depth = 512) * ); * ``` * - * @param \DateTime $datetime + * @param DateTime $datetime * @return ResponseInterface */ - public function setLastModified(\DateTime $datetime): ResponseInterface + public function setLastModified(DateTime $datetime): ResponseInterface { } @@ -494,5 +494,4 @@ public function setStatusCode(int $code, string $message = null): ResponseInterf public function setRawHeader(string $header): ResponseInterface { } - } diff --git a/src/Phalcon/Http/Response/Cookies.php b/src/Phalcon/Http/Response/Cookies.php index a9c4d819..881cbda8 100644 --- a/src/Phalcon/Http/Response/Cookies.php +++ b/src/Phalcon/Http/Response/Cookies.php @@ -62,7 +62,7 @@ * ); * ``` */ -class Cookies extends AbstractInjectionAware implements \Phalcon\Http\Response\CookiesInterface +class Cookies extends AbstractInjectionAware implements CookiesInterface { protected $cookies = array(); @@ -218,5 +218,4 @@ public function setSignKey(string $signKey = null): CookieInterface public function useEncryption(bool $useEncryption): CookiesInterface { } - } diff --git a/src/Phalcon/Http/Response/CookiesInterface.php b/src/Phalcon/Http/Response/CookiesInterface.php index e3596d4f..03442829 100644 --- a/src/Phalcon/Http/Response/CookiesInterface.php +++ b/src/Phalcon/Http/Response/CookiesInterface.php @@ -87,5 +87,4 @@ public function set(string $name, $value = null, int $expire = 0, string $path = * @return CookiesInterface */ public function useEncryption(bool $useEncryption): CookiesInterface; - } diff --git a/src/Phalcon/Http/Response/Headers.php b/src/Phalcon/Http/Response/Headers.php index 9f181adb..707b88a6 100644 --- a/src/Phalcon/Http/Response/Headers.php +++ b/src/Phalcon/Http/Response/Headers.php @@ -14,7 +14,7 @@ * * This class is a bag to manage the response headers */ -class Headers implements \Phalcon\Http\Response\HeadersInterface +class Headers implements HeadersInterface { protected $headers = array(); @@ -95,5 +95,4 @@ public function setRaw(string $header): HeadersInterface public function toArray(): array { } - } diff --git a/src/Phalcon/Http/Response/HeadersInterface.php b/src/Phalcon/Http/Response/HeadersInterface.php index c72a5305..471b9471 100644 --- a/src/Phalcon/Http/Response/HeadersInterface.php +++ b/src/Phalcon/Http/Response/HeadersInterface.php @@ -59,5 +59,4 @@ public function set(string $name, string $value); * @param string $header */ public function setRaw(string $header); - } diff --git a/src/Phalcon/Http/ResponseInterface.php b/src/Phalcon/Http/ResponseInterface.php index 3b2d9ba0..3ac6e603 100644 --- a/src/Phalcon/Http/ResponseInterface.php +++ b/src/Phalcon/Http/ResponseInterface.php @@ -109,10 +109,10 @@ public function setContentType(string $contentType, $charset = null): ResponseIn /** * Sets output expire time header * - * @param \DateTime $datetime + * @param DateTime $datetime * @return ResponseInterface */ - public function setExpires(\DateTime $datetime): ResponseInterface; + public function setExpires(DateTime $datetime): ResponseInterface; /** * Sets an attached file to be sent at the end of the request @@ -192,5 +192,4 @@ public function sendCookies(): ResponseInterface; * @return mixed */ public function sendHeaders(); - } diff --git a/src/Phalcon/Http/Server/AbstractMiddleware.php b/src/Phalcon/Http/Server/AbstractMiddleware.php index ff970f7b..b3a2593b 100644 --- a/src/Phalcon/Http/Server/AbstractMiddleware.php +++ b/src/Phalcon/Http/Server/AbstractMiddleware.php @@ -21,7 +21,7 @@ * by acting on the request, generating the response, or forwarding the * request to a subsequent middleware and possibly acting on its response. */ -abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterface +abstract class AbstractMiddleware implements MiddlewareInterface { /** @@ -31,10 +31,9 @@ abstract class AbstractMiddleware implements \Psr\Http\Server\MiddlewareInterfac * If unable to produce the response itself, it may delegate to the provided * request handler to do so. * - * @param \Psr\Http\Message\ServerRequestInterface $request - * @param \Psr\Http\Server\RequestHandlerInterface $handler + * @param ServerRequestInterface $request + * @param RequestHandlerInterface $handler * @return ResponseInterface */ - abstract public function process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): ResponseInterface; - + abstract public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface; } diff --git a/src/Phalcon/Http/Server/AbstractRequestHandler.php b/src/Phalcon/Http/Server/AbstractRequestHandler.php index b74a5596..a8361e2d 100644 --- a/src/Phalcon/Http/Server/AbstractRequestHandler.php +++ b/src/Phalcon/Http/Server/AbstractRequestHandler.php @@ -19,7 +19,7 @@ * An HTTP request handler process an HTTP request in order to produce an * HTTP response. */ -abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandlerInterface +abstract class AbstractRequestHandler implements RequestHandlerInterface { /** @@ -27,9 +27,8 @@ abstract class AbstractRequestHandler implements \Psr\Http\Server\RequestHandler * * May call other collaborating code to generate the response. * - * @param \Psr\Http\Message\ServerRequestInterface $request + * @param ServerRequestInterface $request * @return ResponseInterface */ - abstract public function handle(\Psr\Http\Message\ServerRequestInterface $request): ResponseInterface; - + abstract public function handle(ServerRequestInterface $request): ResponseInterface; } diff --git a/src/Phalcon/Image/Adapter/AbstractAdapter.php b/src/Phalcon/Image/Adapter/AbstractAdapter.php index 9543cd65..e6047746 100644 --- a/src/Phalcon/Image/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Image/Adapter/AbstractAdapter.php @@ -17,10 +17,10 @@ * * All image adapters must use this class */ -abstract class AbstractAdapter implements \Phalcon\Image\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { - static protected $checked = false; + protected static $checked = false; protected $file; @@ -282,5 +282,4 @@ public function text(string $text, $offsetX = false, $offsetY = false, int $opac public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface { } - } diff --git a/src/Phalcon/Image/Adapter/AdapterInterface.php b/src/Phalcon/Image/Adapter/AdapterInterface.php index 4325b26a..a2bff6a5 100644 --- a/src/Phalcon/Image/Adapter/AdapterInterface.php +++ b/src/Phalcon/Image/Adapter/AdapterInterface.php @@ -124,5 +124,4 @@ public function text(string $text, int $offsetX = 0, int $offsetY = 0, int $opac * @return AdapterInterface */ public function watermark(AdapterInterface $watermark, int $offsetX = 0, int $offsetY = 0, int $opacity = 100): AdapterInterface; - } diff --git a/src/Phalcon/Image/Adapter/Gd.php b/src/Phalcon/Image/Adapter/Gd.php index b5b83264..cd1a006b 100644 --- a/src/Phalcon/Image/Adapter/Gd.php +++ b/src/Phalcon/Image/Adapter/Gd.php @@ -20,10 +20,10 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Gd extends \Phalcon\Image\Adapter\AbstractAdapter +class Gd extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; /** @@ -181,5 +181,4 @@ protected function processText(string $text, int $offsetX, int $offsetY, int $op protected function processWatermark(AdapterInterface $watermark, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/Image/Adapter/Imagick.php b/src/Phalcon/Image/Adapter/Imagick.php index cae0b80e..347aee06 100644 --- a/src/Phalcon/Image/Adapter/Imagick.php +++ b/src/Phalcon/Image/Adapter/Imagick.php @@ -28,13 +28,13 @@ * } * ``` */ -class Imagick extends \Phalcon\Image\Adapter\AbstractAdapter +class Imagick extends AbstractAdapter { - static protected $checked = false; + protected static $checked = false; - static protected $version = 0; + protected static $version = 0; /** @@ -245,5 +245,4 @@ protected function processText(string $text, $offsetX, $offsetY, int $opacity, i protected function processWatermark(AdapterInterface $image, int $offsetX, int $offsetY, int $opacity) { } - } diff --git a/src/Phalcon/Image/Enum.php b/src/Phalcon/Image/Enum.php index f059d608..f3c5503d 100644 --- a/src/Phalcon/Image/Enum.php +++ b/src/Phalcon/Image/Enum.php @@ -45,6 +45,4 @@ class Enum const VERTICAL = 12; - - } diff --git a/src/Phalcon/Image/ImageFactory.php b/src/Phalcon/Image/ImageFactory.php index 2a242657..2627333d 100644 --- a/src/Phalcon/Image/ImageFactory.php +++ b/src/Phalcon/Image/ImageFactory.php @@ -32,7 +32,7 @@ public function __construct(array $services = array()) /** * Factory to create an instace from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array|Config $config = [ * 'adapter' => 'gd', * 'file' => 'image.jpg', * 'height' => null, @@ -63,5 +63,4 @@ public function newInstance(string $name, string $file, int $width = null, int $ protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Kernel.php b/src/Phalcon/Kernel.php index e0c058b9..6450c1fc 100644 --- a/src/Phalcon/Kernel.php +++ b/src/Phalcon/Kernel.php @@ -25,5 +25,4 @@ class Kernel public static function preComputeHashKey(string $key) { } - } diff --git a/src/Phalcon/Loader.php b/src/Phalcon/Loader.php index a3bd45e4..fe9ab626 100644 --- a/src/Phalcon/Loader.php +++ b/src/Phalcon/Loader.php @@ -39,7 +39,7 @@ * $adapter = new \Example\Adapter\Some(); * ``` */ -class Loader implements \Phalcon\Events\EventsAwareInterface +class Loader implements EventsAwareInterface { protected $checkedPath = null; @@ -235,10 +235,10 @@ public function registerNamespaces(array $namespaces, bool $merge = false): Load /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -291,5 +291,4 @@ public function unregister(): Loader protected function prepareNamespace(array $namespaceName): array { } - } diff --git a/src/Phalcon/Logger.php b/src/Phalcon/Logger.php index 247fe81f..30f1ba4e 100644 --- a/src/Phalcon/Logger.php +++ b/src/Phalcon/Logger.php @@ -47,7 +47,7 @@ * ->info('This does not go to the "manager" logger); * ``` */ -class Logger implements \Psr\Log\LoggerInterface +class Logger implements LoggerInterface { const ALERT = 2; @@ -129,7 +129,7 @@ public function __construct(string $name, array $adapters = array()) * @param AdapterInterface $adapter The adapter to add to the stack * @return Logger */ - public function addAdapter(string $name, \Phalcon\Logger\Adapter\AdapterInterface $adapter): Logger + public function addAdapter(string $name, AdapterInterface $adapter): Logger { } @@ -347,5 +347,4 @@ protected function getLevels(): array private function getLevelNumber($level): int { } - } diff --git a/src/Phalcon/Logger/Adapter/AbstractAdapter.php b/src/Phalcon/Logger/Adapter/AbstractAdapter.php index 92b8b1d5..88133dda 100644 --- a/src/Phalcon/Logger/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Logger/Adapter/AbstractAdapter.php @@ -22,7 +22,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Logger\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * Name of the default formatter class @@ -63,10 +63,10 @@ public function __destruct() /** * Adds a message to the queue * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return AdapterInterface */ - public function add(\Phalcon\Logger\Item $item): AdapterInterface + public function add(Item $item): AdapterInterface { } @@ -107,10 +107,10 @@ public function inTransaction(): bool /** * Processes the message in the adapter * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return void */ - abstract public function process(\Phalcon\Logger\Item $item); + abstract public function process(Item $item); /** * Rollbacks the internal transaction @@ -124,11 +124,10 @@ public function rollback(): AdapterInterface /** * Sets the message formatter * - * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter + * @param FormatterInterface $formatter * @return AdapterInterface */ - public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface + public function setFormatter(FormatterInterface $formatter): AdapterInterface { } - } diff --git a/src/Phalcon/Logger/Adapter/AdapterInterface.php b/src/Phalcon/Logger/Adapter/AdapterInterface.php index 84dbb44b..2be6ec31 100644 --- a/src/Phalcon/Logger/Adapter/AdapterInterface.php +++ b/src/Phalcon/Logger/Adapter/AdapterInterface.php @@ -23,10 +23,10 @@ interface AdapterInterface /** * Adds a message in the queue * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return AdapterInterface */ - public function add(\Phalcon\Logger\Item $item): AdapterInterface; + public function add(Item $item): AdapterInterface; /** * Starts a transaction @@ -67,10 +67,10 @@ public function inTransaction(): bool; /** * Processes the message in the adapter * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item); + public function process(Item $item); /** * Rollbacks the internal transaction @@ -82,9 +82,8 @@ public function rollback(): AdapterInterface; /** * Sets the message formatter * - * @param \Phalcon\Logger\Formatter\FormatterInterface $formatter + * @param FormatterInterface $formatter * @return AdapterInterface */ - public function setFormatter(\Phalcon\Logger\Formatter\FormatterInterface $formatter): AdapterInterface; - + public function setFormatter(FormatterInterface $formatter): AdapterInterface; } diff --git a/src/Phalcon/Logger/Adapter/Noop.php b/src/Phalcon/Logger/Adapter/Noop.php index 42cf96fa..e65bdb56 100644 --- a/src/Phalcon/Logger/Adapter/Noop.php +++ b/src/Phalcon/Logger/Adapter/Noop.php @@ -25,7 +25,7 @@ * $logger->close(); * ``` */ -class Noop extends \Phalcon\Logger\Adapter\AbstractAdapter +class Noop extends AbstractAdapter { /** @@ -40,11 +40,10 @@ public function close(): bool /** * Processes the message i.e. writes it to the file * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(Item $item) { } - } diff --git a/src/Phalcon/Logger/Adapter/Stream.php b/src/Phalcon/Logger/Adapter/Stream.php index 55667f7d..ddaa147f 100644 --- a/src/Phalcon/Logger/Adapter/Stream.php +++ b/src/Phalcon/Logger/Adapter/Stream.php @@ -30,7 +30,7 @@ * $logger->close(); * ``` */ -class Stream extends \Phalcon\Logger\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * Stream handler resource @@ -94,11 +94,10 @@ public function close(): bool /** * Processes the message i.e. writes it to the file * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(Item $item) { } - } diff --git a/src/Phalcon/Logger/Adapter/Syslog.php b/src/Phalcon/Logger/Adapter/Syslog.php index 553491c1..03d4d8c9 100644 --- a/src/Phalcon/Logger/Adapter/Syslog.php +++ b/src/Phalcon/Logger/Adapter/Syslog.php @@ -40,7 +40,7 @@ * $logger->error("This is another error"); * ``` */ -class Syslog extends \Phalcon\Logger\Adapter\AbstractAdapter +class Syslog extends AbstractAdapter { /** * Name of the default formatter class @@ -95,10 +95,10 @@ public function close(): bool /** * Processes the message i.e. writes it to the syslog * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return void */ - public function process(\Phalcon\Logger\Item $item) + public function process(Item $item) { } @@ -111,5 +111,4 @@ public function process(\Phalcon\Logger\Item $item) private function logLevelToSyslog(int $level): int { } - } diff --git a/src/Phalcon/Logger/AdapterFactory.php b/src/Phalcon/Logger/AdapterFactory.php index c6cc1b36..b2cb8c05 100644 --- a/src/Phalcon/Logger/AdapterFactory.php +++ b/src/Phalcon/Logger/AdapterFactory.php @@ -50,5 +50,4 @@ public function newInstance(string $name, string $fileName, array $options = arr protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Logger/Formatter/AbstractFormatter.php b/src/Phalcon/Logger/Formatter/AbstractFormatter.php index bb51f898..7486fbc6 100644 --- a/src/Phalcon/Logger/Formatter/AbstractFormatter.php +++ b/src/Phalcon/Logger/Formatter/AbstractFormatter.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterInterface +abstract class AbstractFormatter implements FormatterInterface { /** @@ -32,5 +32,4 @@ abstract class AbstractFormatter implements \Phalcon\Logger\Formatter\FormatterI public function interpolate(string $message, $context = null) { } - } diff --git a/src/Phalcon/Logger/Formatter/FormatterInterface.php b/src/Phalcon/Logger/Formatter/FormatterInterface.php index 11f4d6f9..e8d2a123 100644 --- a/src/Phalcon/Logger/Formatter/FormatterInterface.php +++ b/src/Phalcon/Logger/Formatter/FormatterInterface.php @@ -22,9 +22,8 @@ interface FormatterInterface /** * Applies a format to an item * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return string|array */ - public function format(\Phalcon\Logger\Item $item); - + public function format(Item $item); } diff --git a/src/Phalcon/Logger/Formatter/Json.php b/src/Phalcon/Logger/Formatter/Json.php index d0d4495e..e1abb40e 100644 --- a/src/Phalcon/Logger/Formatter/Json.php +++ b/src/Phalcon/Logger/Formatter/Json.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Logger\Formatter; -use Phalcon\Helper\Json; use Phalcon\Logger\Item; /** @@ -17,7 +16,7 @@ * * Formats messages using JSON encoding */ -class Json extends \Phalcon\Logger\Formatter\AbstractFormatter +class Json extends AbstractFormatter { /** * Default date format @@ -57,11 +56,10 @@ public function __construct(string $dateFormat = 'c') /** * Applies a format to a message before sent it to the internal log * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return string */ - public function format(\Phalcon\Logger\Item $item): string + public function format(Item $item): string { } - } diff --git a/src/Phalcon/Logger/Formatter/Line.php b/src/Phalcon/Logger/Formatter/Line.php index b82b22d7..cc870f29 100644 --- a/src/Phalcon/Logger/Formatter/Line.php +++ b/src/Phalcon/Logger/Formatter/Line.php @@ -16,7 +16,7 @@ * * Formats messages using an one-line string */ -class Line extends \Phalcon\Logger\Formatter\AbstractFormatter +class Line extends AbstractFormatter { /** * Default date format @@ -82,11 +82,10 @@ public function __construct(string $format = '[%date%][%type%] %message%', strin /** * Applies a format to a message before sent it to the internal log * - * @param \Phalcon\Logger\Item $item + * @param Item $item * @return string */ - public function format(\Phalcon\Logger\Item $item): string + public function format(Item $item): string { } - } diff --git a/src/Phalcon/Logger/Item.php b/src/Phalcon/Logger/Item.php index 9b1b4d4f..015de099 100644 --- a/src/Phalcon/Logger/Item.php +++ b/src/Phalcon/Logger/Item.php @@ -101,5 +101,4 @@ public function getType() public function __construct(string $message, string $name, int $type, int $time = 0, $context = array()) { } - } diff --git a/src/Phalcon/Logger/LoggerFactory.php b/src/Phalcon/Logger/LoggerFactory.php index 47fad313..b03dc06f 100644 --- a/src/Phalcon/Logger/LoggerFactory.php +++ b/src/Phalcon/Logger/LoggerFactory.php @@ -36,7 +36,7 @@ public function __construct(AdapterFactory $factory) /** * Factory to create an instace from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array|Config $config = [ * 'name' => 'messages', * 'adapters' => [ * 'adapter' => 'stream', @@ -65,5 +65,4 @@ public function load($config): Logger public function newInstance(string $name, array $adapters = array()): Logger { } - } diff --git a/src/Phalcon/Messages/Message.php b/src/Phalcon/Messages/Message.php index ab4889af..f05af7af 100644 --- a/src/Phalcon/Messages/Message.php +++ b/src/Phalcon/Messages/Message.php @@ -16,7 +16,7 @@ * * Stores a message from various components */ -class Message implements \Phalcon\Messages\MessageInterface, \JsonSerializable +class Message implements MessageInterface, JsonSerializable { /** * @var int @@ -159,5 +159,4 @@ public function setMetaData(array $metaData): MessageInterface public function setType(string $type): MessageInterface { } - } diff --git a/src/Phalcon/Messages/MessageInterface.php b/src/Phalcon/Messages/MessageInterface.php index 14a99d06..3f964f8f 100644 --- a/src/Phalcon/Messages/MessageInterface.php +++ b/src/Phalcon/Messages/MessageInterface.php @@ -98,5 +98,4 @@ public function setMetaData(array $metaData): MessageInterface; * @return MessageInterface */ public function setType(string $type): MessageInterface; - } diff --git a/src/Phalcon/Messages/Messages.php b/src/Phalcon/Messages/Messages.php index e41a1564..5135e8b0 100644 --- a/src/Phalcon/Messages/Messages.php +++ b/src/Phalcon/Messages/Messages.php @@ -17,7 +17,7 @@ /** * Represents a collection of messages */ -class Messages implements \ArrayAccess, \Countable, \Iterator, \JsonSerializable +class Messages implements ArrayAccess, Countable, Iterator, JsonSerializable { /** * @var int @@ -61,9 +61,9 @@ public function appendMessage(MessageInterface $message) * $messages->appendMessages($messagesArray); * ``` * - * @param \Phalcon\Messages\MessageInterface[] messages + * @param MessageInterface[] messages * @param mixed $messages - * @param \Phalcon\Messages\MessageInterface [] messages + * @param MessageInterface[] messages */ public function appendMessages($messages) { @@ -169,7 +169,7 @@ public function offsetGet($index) * $messages[0] = new \Phalcon\Messages\Message("This is a message"); * ``` * - * @param \Phalcon\Messages\Message $message + * @param Message $message * @param mixed $index * @return void */ @@ -208,5 +208,4 @@ public function rewind() public function valid(): bool { } - } diff --git a/src/Phalcon/Mvc/Application.php b/src/Phalcon/Mvc/Application.php index 8204c247..3c8bdbd9 100644 --- a/src/Phalcon/Mvc/Application.php +++ b/src/Phalcon/Mvc/Application.php @@ -116,5 +116,4 @@ public function sendHeadersOnHandleRequest(bool $sendHeaders): Application public function useImplicitView(bool $implicitView): Application { } - } diff --git a/src/Phalcon/Mvc/Controller.php b/src/Phalcon/Mvc/Controller.php index 0bdb95f1..42f6e959 100644 --- a/src/Phalcon/Mvc/Controller.php +++ b/src/Phalcon/Mvc/Controller.php @@ -51,7 +51,7 @@ * } * ``` */ -abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerInterface +abstract class Controller extends Injectable implements ControllerInterface { /** @@ -60,5 +60,4 @@ abstract class Controller extends Injectable implements \Phalcon\Mvc\ControllerI final public function __construct() { } - } diff --git a/src/Phalcon/Mvc/Controller/BindModelInterface.php b/src/Phalcon/Mvc/Controller/BindModelInterface.php index 1d8c0bfb..e53bf305 100644 --- a/src/Phalcon/Mvc/Controller/BindModelInterface.php +++ b/src/Phalcon/Mvc/Controller/BindModelInterface.php @@ -23,5 +23,4 @@ interface BindModelInterface * @return string */ public static function getModelName(): string; - } diff --git a/src/Phalcon/Mvc/Dispatcher.php b/src/Phalcon/Mvc/Dispatcher.php index 2806fd28..f41a590b 100644 --- a/src/Phalcon/Mvc/Dispatcher.php +++ b/src/Phalcon/Mvc/Dispatcher.php @@ -34,7 +34,7 @@ * $controller = $dispatcher->dispatch(); * ``` */ -class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phalcon\Mvc\DispatcherInterface +class Dispatcher extends BaseDispatcher implements DispatcherInterface { protected $defaultAction = 'index'; @@ -219,5 +219,4 @@ protected function handleException(\Exception $exception) protected function throwDispatchException(string $message, int $exceptionCode = 0) { } - } diff --git a/src/Phalcon/Mvc/DispatcherInterface.php b/src/Phalcon/Mvc/DispatcherInterface.php index 4d239253..b3c8103c 100644 --- a/src/Phalcon/Mvc/DispatcherInterface.php +++ b/src/Phalcon/Mvc/DispatcherInterface.php @@ -60,5 +60,4 @@ public function setControllerName(string $controllerName); * @param string $controllerName */ public function setDefaultController(string $controllerName); - } diff --git a/src/Phalcon/Mvc/EntityInterface.php b/src/Phalcon/Mvc/EntityInterface.php index b530459d..6056f3a6 100644 --- a/src/Phalcon/Mvc/EntityInterface.php +++ b/src/Phalcon/Mvc/EntityInterface.php @@ -32,5 +32,4 @@ public function readAttribute(string $attribute); * @param mixed $value */ public function writeAttribute(string $attribute, $value); - } diff --git a/src/Phalcon/Mvc/Micro.php b/src/Phalcon/Mvc/Micro.php index c92e1c24..b942e0ed 100644 --- a/src/Phalcon/Mvc/Micro.php +++ b/src/Phalcon/Mvc/Micro.php @@ -48,7 +48,7 @@ * $app->handle("/say/welcome/Phalcon"); * ``` */ -class Micro extends Injectable implements \ArrayAccess, \Phalcon\Events\EventsAwareInterface +class Micro extends Injectable implements ArrayAccess, EventsAwareInterface { protected $activeHandler; @@ -99,9 +99,9 @@ class Micro extends Injectable implements \ArrayAccess, \Phalcon\Events\EventsAw /** * Phalcon\Mvc\Micro constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) + public function __construct(DiInterface $container = null) { } @@ -208,10 +208,10 @@ public function getEventsManager(): ?ManagerInterface /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -316,10 +316,10 @@ public function map(string $routePattern, $handler): RouteInterface /** * Mounts a collection of handlers * - * @param \Phalcon\Mvc\Micro\CollectionInterface $collection + * @param CollectionInterface $collection * @return Micro */ - public function mount(\Phalcon\Mvc\Micro\CollectionInterface $collection): Micro + public function mount(CollectionInterface $collection): Micro { } @@ -445,10 +445,10 @@ public function setActiveHandler($activeHandler) /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -464,11 +464,11 @@ public function setDI(\Phalcon\Di\DiInterface $container) * ); * ``` * - * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder + * @param BinderInterface $modelBinder * @param mixed $cache * @return Micro */ - public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, $cache = null): Micro + public function setModelBinder(BinderInterface $modelBinder, $cache = null): Micro { } @@ -502,5 +502,4 @@ public function setService(string $serviceName, $definition, bool $shared = fals public function stop() { } - } diff --git a/src/Phalcon/Mvc/Micro/Collection.php b/src/Phalcon/Mvc/Micro/Collection.php index 21b72524..9abf0dd5 100644 --- a/src/Phalcon/Mvc/Micro/Collection.php +++ b/src/Phalcon/Mvc/Micro/Collection.php @@ -28,7 +28,7 @@ * $app->mount($collection); * ``` */ -class Collection implements \Phalcon\Mvc\Micro\CollectionInterface +class Collection implements CollectionInterface { protected $handler; @@ -240,5 +240,4 @@ public function setPrefix(string $prefix): CollectionInterface protected function addMap($method, string $routePattern, $handler, string $name) { } - } diff --git a/src/Phalcon/Mvc/Micro/CollectionInterface.php b/src/Phalcon/Mvc/Micro/CollectionInterface.php index 6b685496..a0b3d42a 100644 --- a/src/Phalcon/Mvc/Micro/CollectionInterface.php +++ b/src/Phalcon/Mvc/Micro/CollectionInterface.php @@ -149,5 +149,4 @@ public function setLazy(bool $lazy): CollectionInterface; * @return CollectionInterface */ public function setPrefix(string $prefix): CollectionInterface; - } diff --git a/src/Phalcon/Mvc/Micro/LazyLoader.php b/src/Phalcon/Mvc/Micro/LazyLoader.php index a520cc8c..3a9d5baf 100644 --- a/src/Phalcon/Mvc/Micro/LazyLoader.php +++ b/src/Phalcon/Mvc/Micro/LazyLoader.php @@ -43,12 +43,11 @@ public function __construct(string $definition) * Calling __call method * * @param array $arguments - * @return mixed * @param string $method - * @param \Phalcon\Mvc\Model\BinderInterface $modelBinder + * @param BinderInterface $modelBinder + * @return mixed */ - public function callMethod(string $method, $arguments, \Phalcon\Mvc\Model\BinderInterface $modelBinder = null) + public function callMethod(string $method, $arguments, BinderInterface $modelBinder = null) { } - } diff --git a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php index d304f082..0e6d47f6 100644 --- a/src/Phalcon/Mvc/Micro/MiddlewareInterface.php +++ b/src/Phalcon/Mvc/Micro/MiddlewareInterface.php @@ -20,8 +20,7 @@ interface MiddlewareInterface /** * Calls the middleware * - * @param \Phalcon\Mvc\Micro $application + * @param Micro $application */ - public function call(\Phalcon\Mvc\Micro $application); - + public function call(Micro $application); } diff --git a/src/Phalcon/Mvc/Model.php b/src/Phalcon/Mvc/Model.php index d8598cec..3d3e38ab 100644 --- a/src/Phalcon/Mvc/Model.php +++ b/src/Phalcon/Mvc/Model.php @@ -34,9 +34,11 @@ use Phalcon\Mvc\Model\QueryInterface; use Phalcon\Mvc\Model\ResultInterface; use Phalcon\Mvc\Model\Resultset; +use Phalcon\Mvc\Model\Resultset\Simple; use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\Relation; use Phalcon\Mvc\Model\RelationInterface; +use Phalcon\Mvc\Model\Row; use Phalcon\Mvc\Model\TransactionInterface; use Phalcon\Mvc\Model\ValidationFailed; use Phalcon\Mvc\ModelInterface; @@ -80,7 +82,7 @@ * } * ``` */ -abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable +abstract class Model extends AbstractInjectionAware implements EntityInterface, \Phalcon\Mvc\ModelInterface, ResultInterface, Serializable, JsonSerializable { const DIRTY_STATE_DETACHED = 2; @@ -166,20 +168,20 @@ public function getTransaction() * Phalcon\Mvc\Model constructor * * @param mixed $data - * @param \Phalcon\Di\DiInterface $container - * @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager + * @param DiInterface $container + * @param ManagerInterface $modelsManager */ - final public function __construct($data = null, \Phalcon\Di\DiInterface $container = null, \Phalcon\Mvc\Model\ManagerInterface $modelsManager = null) + final public function __construct($data = null, DiInterface $container = null, ManagerInterface $modelsManager = null) { } /** * Handles method calls when a method is not implemented * - * @return mixed - * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments + *@return mixed + * @throws Exception If the method doesn't exist */ public function __call(string $method, array $arguments) { @@ -188,10 +190,10 @@ public function __call(string $method, array $arguments) /** * Handles method calls when a static method is not implemented * - * @return mixed - * @throws \Phalcon\Mvc\Model\Exception If the method doesn't exist * @param string $method * @param array $arguments + *@return mixed + * @throws Exception If the method doesn't exist */ public static function __callStatic(string $method, array $arguments) { @@ -253,10 +255,10 @@ public function __set(string $property, $value) * } * ``` * - * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior + * @param BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) + public function addBehavior(BehaviorInterface $behavior) { } @@ -282,10 +284,10 @@ public function addBehavior(\Phalcon\Mvc\Model\BehaviorInterface $behavior) * } * ``` * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ModelInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface + public function appendMessage(MessageInterface $message): ModelInterface { } @@ -411,7 +413,7 @@ public static function cloneResult(\Phalcon\Mvc\ModelInterface $base, array $dat * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface|Row $base * @param array $columnMap * @param array $data * @param int $dirtyState @@ -884,7 +886,7 @@ public function getEventsManager(): EventsManagerInterface * ``` * * @param mixed $filter - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages($filter = null): array { @@ -950,7 +952,7 @@ final public function getReadConnectionService(): string * Returns related records based on defined relations * * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @return Simple|Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias */ public function getRelated(string $alias, $arguments = null) @@ -1181,10 +1183,10 @@ public static function minimum($parameters = null) /** * Create a criteria for a specific model * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return CriteriaInterface */ - public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface + public static function query(DiInterface $container = null): CriteriaInterface { } @@ -1281,9 +1283,9 @@ public function setDirtyState(int $dirtyState) /** * Sets a custom events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param EventsManagerInterface $eventsManager */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(EventsManagerInterface $eventsManager) { } @@ -1361,10 +1363,10 @@ public function setSnapshotData(array $data, $columnMap = null) * } * ``` * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return ModelInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface + public function setTransaction(TransactionInterface $transaction): ModelInterface { } @@ -1517,11 +1519,11 @@ final protected function _checkForeignKeysReverseRestrict(): bool * * @param string|array $table * @param bool|string $identityField - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param MetaDataInterface $metaData + * @param AdapterInterface $connection * @return bool */ - protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table, $identityField): bool + protected function _doLowInsert(MetaDataInterface $metaData, AdapterInterface $connection, $table, $identityField): bool { } @@ -1529,22 +1531,22 @@ protected function _doLowInsert(\Phalcon\Mvc\Model\MetaDataInterface $metaData, * Sends a pre-build UPDATE SQL statement to the relational database system * * @param string|array $table - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param MetaDataInterface $metaData + * @param AdapterInterface $connection * @return bool */ - protected function _doLowUpdate(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection, $table): bool + protected function _doLowUpdate(MetaDataInterface $metaData, AdapterInterface $connection, $table): bool { } /** * Checks whether the current record already exists * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData - * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param MetaDataInterface $metaData + * @param AdapterInterface $connection * @return bool */ - protected function _exists(\Phalcon\Mvc\Model\MetaDataInterface $metaData, \Phalcon\Db\Adapter\AdapterInterface $connection): bool + protected function _exists(MetaDataInterface $metaData, AdapterInterface $connection): bool { } @@ -1580,7 +1582,7 @@ protected static function _groupResult(string $functionName, string $alias, $par * @param string $method * @param array $arguments */ - protected final static function _invokeFinder(string $method, array $arguments) + final protected static function _invokeFinder(string $method, array $arguments) { } @@ -1598,12 +1600,12 @@ final protected function _possibleSetter(string $property, $value): bool /** * Executes internal hooks before save a record * - * @param \Phalcon\Mvc\Model\MetaDataInterface $metaData + * @param MetaDataInterface $metaData * @param bool $exists * @param mixed $identityField * @return bool */ - protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool $exists, $identityField): bool + protected function _preSave(MetaDataInterface $metaData, bool $exists, $identityField): bool { } @@ -1611,12 +1613,12 @@ protected function _preSave(\Phalcon\Mvc\Model\MetaDataInterface $metaData, bool * Saves related records that must be stored prior to save the master record * * @param \Phalcon\Mvc\ModelInterface[] related - * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param AdapterInterface $connection * @param mixed $related * @param \Phalcon\Mvc\ModelInterface [] related * @return bool */ - protected function _preSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool + protected function _preSaveRelatedRecords(AdapterInterface $connection, $related): bool { } @@ -1635,12 +1637,12 @@ protected function _postSave(bool $success, bool $exists): bool * Save the related records assigned in the has-one/has-many relations * * @param Phalcon\Mvc\ModelInterface[] related - * @param \Phalcon\Db\Adapter\AdapterInterface $connection + * @param AdapterInterface $connection * @param mixed $related * @param Phalcon\Mvc\ModelInterface [] related * @return bool */ - protected function _postSaveRelatedRecords(\Phalcon\Db\Adapter\AdapterInterface $connection, $related): bool + protected function _postSaveRelatedRecords(AdapterInterface $connection, $related): bool { } @@ -2108,10 +2110,10 @@ protected function useDynamicUpdate(bool $dynamicUpdate) * } * ``` * - * @param \Phalcon\Validation\ValidationInterface $validator + * @param ValidationInterface $validator * @return bool */ - protected function validate(\Phalcon\Validation\ValidationInterface $validator): bool + protected function validate(ValidationInterface $validator): bool { } @@ -2162,5 +2164,4 @@ public function validationHasFailed(): bool private static function caseInsensitiveColumnMap($columnMap, $key): string { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior.php b/src/Phalcon/Mvc/Model/Behavior.php index 85560583..6ff5733d 100644 --- a/src/Phalcon/Mvc/Model/Behavior.php +++ b/src/Phalcon/Mvc/Model/Behavior.php @@ -16,7 +16,7 @@ * * This is an optional base class for ORM behaviors */ -abstract class Behavior implements \Phalcon\Mvc\Model\BehaviorInterface +abstract class Behavior implements BehaviorInterface { /** * @var array @@ -46,11 +46,11 @@ protected function getOptions(string $eventName = null) /** * Acts as fallbacks when a missing method is called on the model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $method * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()) + public function missingMethod(ModelInterface $model, string $method, array $arguments = array()) { } @@ -68,10 +68,9 @@ protected function mustTakeAction(string $eventName): bool * This method receives the notifications from the EventsManager * * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + public function notify(string $type, ModelInterface $model) { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php index 5c7a483a..b57dc36a 100644 --- a/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php +++ b/src/Phalcon/Mvc/Model/Behavior/SoftDelete.php @@ -26,10 +26,9 @@ class SoftDelete extends Behavior * Listens for notifications from the models manager * * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + public function notify(string $type, ModelInterface $model) { } - } diff --git a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php index 3347e329..72bdae2b 100644 --- a/src/Phalcon/Mvc/Model/Behavior/Timestampable.php +++ b/src/Phalcon/Mvc/Model/Behavior/Timestampable.php @@ -27,9 +27,9 @@ class Timestampable extends Behavior * Listens for notifications from the models manager * * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) + public function notify(string $type, ModelInterface $model) { } @@ -39,5 +39,4 @@ public function notify(string $type, \Phalcon\Mvc\ModelInterface $model) private function getTimestamp(array $options) { } - } diff --git a/src/Phalcon/Mvc/Model/BehaviorInterface.php b/src/Phalcon/Mvc/Model/BehaviorInterface.php index 818e8054..76cae412 100644 --- a/src/Phalcon/Mvc/Model/BehaviorInterface.php +++ b/src/Phalcon/Mvc/Model/BehaviorInterface.php @@ -22,18 +22,17 @@ interface BehaviorInterface /** * Calls a method when it's missing in the model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $method * @param array $arguments */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $method, array $arguments = array()); + public function missingMethod(ModelInterface $model, string $method, array $arguments = array()); /** * This method receives the notifications from the EventsManager * * @param string $type - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notify(string $type, \Phalcon\Mvc\ModelInterface $model); - + public function notify(string $type, ModelInterface $model); } diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php index 8ac878f0..c4344ea6 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -21,7 +21,7 @@ * * This is an class for binding models into params for handler */ -class Binder implements \Phalcon\Mvc\Model\BinderInterface +class Binder implements BinderInterface { /** * Array for storing active bound models @@ -65,9 +65,9 @@ public function getOriginalValues() /** * Phalcon\Mvc\Model\Binder constructor * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param AdapterInterface $cache */ - public function __construct(\Phalcon\Cache\Adapter\AdapterInterface $cache = null) + public function __construct(AdapterInterface $cache = null) { } @@ -130,11 +130,10 @@ protected function getParamsFromReflection($handler, array $params, string $cach /** * Gets cache instance * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param AdapterInterface $cache * @return BinderInterface */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface + public function setCache(AdapterInterface $cache): BinderInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php index f8d4bafb..f37da24c 100644 --- a/src/Phalcon/Mvc/Model/Binder/BindableInterface.php +++ b/src/Phalcon/Mvc/Model/Binder/BindableInterface.php @@ -24,5 +24,4 @@ interface BindableInterface * @return string|array */ public function getModelName(); - } diff --git a/src/Phalcon/Mvc/Model/BinderInterface.php b/src/Phalcon/Mvc/Model/BinderInterface.php index 29a7e408..7c0ee131 100644 --- a/src/Phalcon/Mvc/Model/BinderInterface.php +++ b/src/Phalcon/Mvc/Model/BinderInterface.php @@ -47,9 +47,8 @@ public function getCache(): AdapterInterface; /** * Sets cache instance * - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param AdapterInterface $cache * @return BinderInterface */ - public function setCache(\Phalcon\Cache\Adapter\AdapterInterface $cache): BinderInterface; - + public function setCache(AdapterInterface $cache): BinderInterface; } diff --git a/src/Phalcon/Mvc/Model/Criteria.php b/src/Phalcon/Mvc/Model/Criteria.php index cfb8cdcb..d5d1dcd4 100644 --- a/src/Phalcon/Mvc/Model/Criteria.php +++ b/src/Phalcon/Mvc/Model/Criteria.php @@ -32,7 +32,7 @@ * ->execute(); * ``` */ -class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\InjectionAwareInterface +class Criteria implements CriteriaInterface, InjectionAwareInterface { protected $bindParams; @@ -53,10 +53,10 @@ class Criteria implements \Phalcon\Mvc\Model\CriteriaInterface, \Phalcon\Di\Inje /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -505,13 +505,13 @@ public function getParams(): array /** * Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param string $modelName * @param array $data * @param string $operator * @return CriteriaInterface */ - public static function fromInput(\Phalcon\Di\DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface + public static function fromInput(DiInterface $container, string $modelName, array $data, string $operator = 'AND'): CriteriaInterface { } @@ -539,5 +539,4 @@ public function createBuilder(): BuilderInterface public function execute(): ResultsetInterface { } - } diff --git a/src/Phalcon/Mvc/Model/CriteriaInterface.php b/src/Phalcon/Mvc/Model/CriteriaInterface.php index a746186a..7879a64c 100644 --- a/src/Phalcon/Mvc/Model/CriteriaInterface.php +++ b/src/Phalcon/Mvc/Model/CriteriaInterface.php @@ -331,5 +331,4 @@ public function sharedLock(bool $sharedLock = true): CriteriaInterface; * @return CriteriaInterface */ public function where(string $conditions): CriteriaInterface; - } diff --git a/src/Phalcon/Mvc/Model/Manager.php b/src/Phalcon/Mvc/Model/Manager.php index 91280193..c85e9682 100644 --- a/src/Phalcon/Mvc/Model/Manager.php +++ b/src/Phalcon/Mvc/Model/Manager.php @@ -48,7 +48,7 @@ * $robot = new Robots($di); * ``` */ -class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\InjectionAwareInterface, \Phalcon\Events\EventsAwareInterface +class Manager implements \Phalcon\Mvc\Model\ManagerInterface, InjectionAwareInterface, EventsAwareInterface { protected $aliases = array(); @@ -167,10 +167,10 @@ class Manager implements \Phalcon\Mvc\Model\ManagerInterface, \Phalcon\Di\Inject /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -186,10 +186,10 @@ public function getDI(): DiInterface /** * Sets a global events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param EventsManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(EventsManagerInterface $eventsManager) { } @@ -205,31 +205,31 @@ public function getEventsManager(): EventsManagerInterface /** * Sets a custom events manager for a specific model * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ModelInterface $model + * @param EventsManagerInterface $eventsManager * @return void */ - public function setCustomEventsManager(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Events\ManagerInterface $eventsManager) + public function setCustomEventsManager(ModelInterface $model, EventsManagerInterface $eventsManager) { } /** * Returns a custom events manager related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return mixed */ - public function getCustomEventsManager(\Phalcon\Mvc\ModelInterface $model) + public function getCustomEventsManager(ModelInterface $model) { } /** * Initializes a model in the model manager * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return bool */ - public function initialize(\Phalcon\Mvc\ModelInterface $model): bool + public function initialize(ModelInterface $model): bool { } @@ -303,11 +303,11 @@ public function getModelPrefix(): string /** * Sets the mapped source for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $source * @return void */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source) + public function setModelSource(ModelInterface $model, string $source) { } @@ -321,126 +321,126 @@ public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $sourc * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $property * @return bool */ - final public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool + final public function isVisibleModelProperty(ModelInterface $model, string $property): bool { } /** * Returns the mapped source for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string + public function getModelSource(ModelInterface $model): string { } /** * Sets the mapped schema for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $schema * @return void */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema) + public function setModelSchema(ModelInterface $model, string $schema) { } /** * Returns the mapped schema for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string + public function getModelSchema(ModelInterface $model): string { } /** * Sets both write and read connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService * @return void */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setConnectionService(ModelInterface $model, string $connectionService) { } /** * Sets write connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService * @return void */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setWriteConnectionService(ModelInterface $model, string $connectionService) { } /** * Sets read connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService * @return void */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService) + public function setReadConnectionService(ModelInterface $model, string $connectionService) { } /** * Returns the connection to read data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface + public function getReadConnection(ModelInterface $model): AdapterInterface { } /** * Returns the connection to write data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface + public function getWriteConnection(ModelInterface $model): AdapterInterface { } /** * Returns the connection to read or write data related to a model depending on the connection services. * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $connectionServices * @return AdapterInterface */ - protected function _getConnection(\Phalcon\Mvc\ModelInterface $model, $connectionServices): AdapterInterface + protected function _getConnection(ModelInterface $model, $connectionServices): AdapterInterface { } /** * Returns the connection service name used to read data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string + public function getReadConnectionService(ModelInterface $model): string { } /** * Returns the connection service name used to write data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string + public function getWriteConnectionService(ModelInterface $model): string { } @@ -448,11 +448,11 @@ public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): s * Returns the connection service name used to read or write data related to * a model depending on the connection services * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $connectionServices * @return string */ - public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $connectionServices): string + public function _getConnectionService(ModelInterface $model, $connectionServices): string { } @@ -462,9 +462,9 @@ public function _getConnectionService(\Phalcon\Mvc\ModelInterface $model, $conne * the model * * @param string $eventName - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model) + public function notifyEvent(string $eventName, ModelInterface $model) { } @@ -473,64 +473,64 @@ public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $mode * This method expects that the endpoint listeners/behaviors returns true * meaning that a least one was implemented * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $eventName * @param mixed $data */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data) + public function missingMethod(ModelInterface $model, string $eventName, $data) { } /** * Binds a behavior to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param \Phalcon\Mvc\Model\BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior) + public function addBehavior(ModelInterface $model, \Phalcon\Mvc\Model\BehaviorInterface $behavior) { } /** * Sets if a model must keep snapshots * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param bool $keepSnapshots * @return void */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots) + public function keepSnapshots(ModelInterface $model, bool $keepSnapshots) { } /** * Checks if a model is keeping snapshots for the queried records * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool + public function isKeepingSnapshots(ModelInterface $model): bool { } /** * Sets if a model must use dynamic update instead of the all-field update * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param bool $dynamicUpdate * @return void */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate) + public function useDynamicUpdate(ModelInterface $model, bool $dynamicUpdate) { } /** * Checks if a model is using dynamic update instead of all-field update * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool + public function isUsingDynamicUpdate(ModelInterface $model): bool { } @@ -538,13 +538,13 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool * Setup a 1-1 relation between two models * * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields * @return RelationInterface */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + public function addHasOne(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } @@ -556,12 +556,12 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r * @param string $intermediateReferencedFields * @param string $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $intermediateModel * @param string $referencedModel * @return RelationInterface */ - public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface + public function addHasOneThrough(ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } @@ -569,13 +569,13 @@ public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, st * Setup a relation reverse many to one between two models * * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $fields * @param string $referencedModel * @param mixed $referencedFields * @return RelationInterface */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + public function addBelongsTo(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } @@ -584,12 +584,12 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string * * @param mixed $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $fields * @param string $referencedModel * @return RelationInterface */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface + public function addHasMany(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } @@ -601,12 +601,12 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ * @param string $intermediateReferencedFields * @param string $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $intermediateModel * @param string $referencedModel * @return RelationInterface */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface + public function addHasManyToMany(ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface { } @@ -690,13 +690,13 @@ final protected function _mergeFindParameters($findParamsOne, $findParamsTwo): a /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param RelationInterface $relation - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @param mixed $parameters * @param string $method + *@return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + public function getRelationRecords(RelationInterface $relation, ModelInterface $record, $parameters = null, string $method = null) { } @@ -736,12 +736,12 @@ public function clearReusableObjects() * * @param string $modelName * @param string $modelRelation - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @param mixed $parameters * @param string $method * @return mixed */ - public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + public function getBelongsToRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null) { } @@ -750,12 +750,12 @@ public function getBelongsToRecords(string $modelName, string $modelRelation, \P * * @param string $modelName * @param string $modelRelation - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @param mixed $parameters * @param string $method * @return mixed */ - public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + public function getHasManyRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null) { } @@ -764,12 +764,12 @@ public function getHasManyRecords(string $modelName, string $modelRelation, \Pha * * @param string $modelName * @param string $modelRelation - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @param mixed $parameters * @param string $method * @return mixed */ - public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null) + public function getHasOneRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null) { } @@ -782,60 +782,60 @@ public function getHasOneRecords(string $modelName, string $modelRelation, \Phal * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array + public function getBelongsTo(ModelInterface $model): array { } /** * Gets hasMany relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array + public function getHasMany(ModelInterface $model): array { } /** * Gets hasOne relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array + public function getHasOne(ModelInterface $model): array { } /** * Gets hasOneThrough relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array + public function getHasOneThrough(ModelInterface $model): array { } /** * Gets hasManyToMany relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array + public function getHasManyToMany(ModelInterface $model): array { } /** * Gets hasOne relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array + public function getHasOneAndHasMany(ModelInterface $model): array { } @@ -907,5 +907,4 @@ public function getLastQuery(): QueryInterface public function __destruct() { } - } diff --git a/src/Phalcon/Mvc/Model/ManagerInterface.php b/src/Phalcon/Mvc/Model/ManagerInterface.php index b53b9bf0..bf520baf 100644 --- a/src/Phalcon/Mvc/Model/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/ManagerInterface.php @@ -25,11 +25,11 @@ interface ManagerInterface /** * Binds a behavior to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param BehaviorInterface $behavior * @return void */ - public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterface $behavior); + public function addBehavior(ModelInterface $model, BehaviorInterface $behavior); /** * Setup a relation reverse 1-1 between two models @@ -37,11 +37,11 @@ public function addBehavior(\Phalcon\Mvc\ModelInterface $model, BehaviorInterfac * @param mixed $fields * @param mixed $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $referencedModel * @return RelationInterface */ - public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function addBelongsTo(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** * Setup a relation 1-n between two models @@ -49,11 +49,11 @@ public function addBelongsTo(\Phalcon\Mvc\ModelInterface $model, $fields, string * @param mixed $fields * @param mixed $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $referencedModel * @return RelationInterface */ - public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function addHasMany(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** * Setup a 1-1 relation between two models @@ -61,11 +61,11 @@ public function addHasMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $ * @param mixed $fields * @param mixed $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $referencedModel * @return RelationInterface */ - public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function addHasOne(ModelInterface $model, $fields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** * Setups a 1-1 relation between two models using an intermediate table @@ -75,12 +75,12 @@ public function addHasOne(\Phalcon\Mvc\ModelInterface $model, $fields, string $r * @param string $intermediateReferencedFields * @param string $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $intermediateModel * @param string $referencedModel * @return RelationInterface */ - public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function addHasOneThrough(ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** * Setups a relation n-m between two models @@ -90,12 +90,12 @@ public function addHasOneThrough(\Phalcon\Mvc\ModelInterface $model, $fields, st * @param string $intermediateReferencedFields * @param string $referencedFields * @param array $options - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $intermediateModel * @param string $referencedModel * @return RelationInterface */ - public function addHasManyToMany(\Phalcon\Mvc\ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; + public function addHasManyToMany(ModelInterface $model, $fields, string $intermediateModel, $intermediateFields, $intermediateReferencedFields, string $referencedModel, $referencedFields, $options = null): RelationInterface; /** * Creates a Phalcon\Mvc\Model\Query\Builder @@ -170,10 +170,10 @@ public function existsHasManyToMany(string $modelName, string $modelRelation): b /** * Gets belongsTo relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; + public function getBelongsTo(ModelInterface $model): array; /** * Gets belongsTo related records from a model @@ -185,15 +185,15 @@ public function getBelongsTo(\Phalcon\Mvc\ModelInterface $model): array; * @param string|null $method * @return mixed */ - public function getBelongsToRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getBelongsToRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null); /** * Gets hasMany relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; + public function getHasMany(ModelInterface $model): array; /** * Gets hasMany related records from a model @@ -205,39 +205,39 @@ public function getHasMany(\Phalcon\Mvc\ModelInterface $model): array; * @param string|null $method * @return mixed */ - public function getHasManyRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getHasManyRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null); /** * Gets hasManyToMany relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasManyToMany(\Phalcon\Mvc\ModelInterface $model): array; + public function getHasManyToMany(ModelInterface $model): array; /** * Gets hasOne relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasOne(\Phalcon\Mvc\ModelInterface $model): array; + public function getHasOne(ModelInterface $model): array; /** * Gets hasOneThrough relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasOneThrough(\Phalcon\Mvc\ModelInterface $model): array; + public function getHasOneThrough(ModelInterface $model): array; /** * Gets hasOne relations defined on a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|RelationInterface[] */ - public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; + public function getHasOneAndHasMany(ModelInterface $model): array; /** * Gets hasOne related records from a model @@ -249,7 +249,7 @@ public function getHasOneAndHasMany(\Phalcon\Mvc\ModelInterface $model): array; * @param string|null $method * @return mixed */ - public function getHasOneRecords(string $modelName, string $modelRelation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getHasOneRecords(string $modelName, string $modelRelation, ModelInterface $record, $parameters = null, string $method = null); /** * Get last initialized model @@ -268,34 +268,34 @@ public function getLastQuery(): QueryInterface; /** * Returns the mapped schema for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getModelSchema(\Phalcon\Mvc\ModelInterface $model): string; + public function getModelSchema(ModelInterface $model): string; /** * Returns the mapped source for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getModelSource(\Phalcon\Mvc\ModelInterface $model): string; + public function getModelSource(ModelInterface $model): string; /** * Returns the connection to read data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return AdapterInterface */ - public function getReadConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + public function getReadConnection(ModelInterface $model): AdapterInterface; /** * Returns the connection service name used to read data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getReadConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + public function getReadConnectionService(ModelInterface $model): string; /** * Returns a relation by its alias @@ -309,13 +309,13 @@ public function getRelationByAlias(string $modelName, string $alias); /** * Helper method to query records based on a relation definition * - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false * @param RelationInterface $relation - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @param mixed $parameters * @param string $method + *@return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false */ - public function getRelationRecords(RelationInterface $relation, \Phalcon\Mvc\ModelInterface $record, $parameters = null, string $method = null); + public function getRelationRecords(RelationInterface $relation, ModelInterface $record, $parameters = null, string $method = null); /** * Query all the relationships defined on a model @@ -337,18 +337,18 @@ public function getRelationsBetween(string $first, string $second); /** * Returns the connection to write data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return AdapterInterface */ - public function getWriteConnection(\Phalcon\Mvc\ModelInterface $model): AdapterInterface; + public function getWriteConnection(ModelInterface $model): AdapterInterface; /** * Returns the connection service name used to write data related to a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string */ - public function getWriteConnectionService(\Phalcon\Mvc\ModelInterface $model): string; + public function getWriteConnectionService(ModelInterface $model): string; /** * Loads a model throwing an exception if it doesn't exist @@ -361,9 +361,9 @@ public function load(string $modelName): ModelInterface; /** * Initializes a model in the model manager * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function initialize(\Phalcon\Mvc\ModelInterface $model); + public function initialize(ModelInterface $model); /** * Check of a model is already initialized @@ -376,18 +376,18 @@ public function isInitialized(string $className): bool; /** * Checks if a model is keeping snapshots for the queried records * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return bool */ - public function isKeepingSnapshots(\Phalcon\Mvc\ModelInterface $model): bool; + public function isKeepingSnapshots(ModelInterface $model): bool; /** * Checks if a model is using dynamic update instead of all-field update * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return bool */ - public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; + public function isUsingDynamicUpdate(ModelInterface $model): bool; /** * Check whether a model property is declared as public. @@ -399,20 +399,20 @@ public function isUsingDynamicUpdate(\Phalcon\Mvc\ModelInterface $model): bool; * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $property * @return bool */ - public function isVisibleModelProperty(\Phalcon\Mvc\ModelInterface $model, string $property): bool; + public function isVisibleModelProperty(ModelInterface $model, string $property): bool; /** * Sets if a model must keep snapshots * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param bool $keepSnapshots * @return void */ - public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnapshots); + public function keepSnapshots(ModelInterface $model, bool $keepSnapshots); /** * Dispatch an event to the listeners and behaviors @@ -420,72 +420,71 @@ public function keepSnapshots(\Phalcon\Mvc\ModelInterface $model, bool $keepSnap * meaning that a least one is implemented * * @param array $data - * @return bool - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $eventName + *@return bool */ - public function missingMethod(\Phalcon\Mvc\ModelInterface $model, string $eventName, $data); + public function missingMethod(ModelInterface $model, string $eventName, $data); /** * Receives events generated in the models and dispatches them to an events-manager if available * Notify the behaviors that are listening in the model * * @param string $eventName - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function notifyEvent(string $eventName, \Phalcon\Mvc\ModelInterface $model); + public function notifyEvent(string $eventName, ModelInterface $model); /** * Sets both write and read connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService * @return void */ - public function setConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function setConnectionService(ModelInterface $model, string $connectionService); /** * Sets read connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService * @return void */ - public function setReadConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function setReadConnectionService(ModelInterface $model, string $connectionService); /** * Sets the mapped schema for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $schema * @return void */ - public function setModelSchema(\Phalcon\Mvc\ModelInterface $model, string $schema); + public function setModelSchema(ModelInterface $model, string $schema); /** * Sets the mapped source for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $source * @return void */ - public function setModelSource(\Phalcon\Mvc\ModelInterface $model, string $source); + public function setModelSource(ModelInterface $model, string $source); /** * Sets write connection service for a model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $connectionService */ - public function setWriteConnectionService(\Phalcon\Mvc\ModelInterface $model, string $connectionService); + public function setWriteConnectionService(ModelInterface $model, string $connectionService); /** * Sets if a model must use dynamic update instead of the all-field update * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param bool $dynamicUpdate * @return void */ - public function useDynamicUpdate(\Phalcon\Mvc\ModelInterface $model, bool $dynamicUpdate); - + public function useDynamicUpdate(ModelInterface $model, bool $dynamicUpdate); } diff --git a/src/Phalcon/Mvc/Model/MetaData.php b/src/Phalcon/Mvc/Model/MetaData.php index 019ed6e1..0a1a2c5d 100644 --- a/src/Phalcon/Mvc/Model/MetaData.php +++ b/src/Phalcon/Mvc/Model/MetaData.php @@ -36,7 +36,7 @@ * print_r($attributes); * ``` */ -abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon\Mvc\Model\MetaDataInterface +abstract class MetaData implements InjectionAwareInterface, MetaDataInterface { const MODELS_ATTRIBUTES = 0; @@ -115,10 +115,10 @@ abstract class MetaData implements \Phalcon\Di\InjectionAwareInterface, \Phalcon * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getAttributes(ModelInterface $model): array { } @@ -133,10 +133,10 @@ public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getAutomaticCreateAttributes(ModelInterface $model): array { } @@ -151,10 +151,10 @@ public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model) * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getAutomaticUpdateAttributes(ModelInterface $model): array { } @@ -169,10 +169,10 @@ public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model) * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array + public function getBindTypes(ModelInterface $model): array { } @@ -187,10 +187,10 @@ public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array + public function getColumnMap(ModelInterface $model): array { } @@ -205,10 +205,10 @@ public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array + public function getDefaultValues(ModelInterface $model): array { } @@ -223,10 +223,10 @@ public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array + public function getDataTypes(ModelInterface $model): array { } @@ -241,10 +241,10 @@ public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array + public function getDataTypesNumeric(ModelInterface $model): array { } @@ -268,10 +268,10 @@ public function getDI(): DiInterface * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getEmptyStringAttributes(ModelInterface $model): array { } @@ -286,10 +286,10 @@ public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): ar * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string + public function getIdentityField(ModelInterface $model): ?string { } @@ -304,10 +304,10 @@ public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getNonPrimaryKeyAttributes(ModelInterface $model): array { } @@ -322,10 +322,10 @@ public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getNotNullAttributes(ModelInterface $model): array { } @@ -340,10 +340,10 @@ public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array + public function getPrimaryKeyAttributes(ModelInterface $model): array { } @@ -358,10 +358,10 @@ public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): arr * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array + public function getReverseColumnMap(ModelInterface $model): array { } @@ -386,11 +386,11 @@ public function getStrategy(): StrategyInterface * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $attribute * @return bool */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool + public function hasAttribute(ModelInterface $model, string $attribute): bool { } @@ -430,10 +430,10 @@ public function read(string $key): ?array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|null */ - final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array + final public function readColumnMap(ModelInterface $model): ?array { } @@ -449,10 +449,10 @@ final public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index */ - final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index) + final public function readColumnMapIndex(ModelInterface $model, int $index) { } @@ -467,10 +467,10 @@ final public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array + final public function readMetaData(ModelInterface $model): array { } @@ -486,10 +486,10 @@ final public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index */ - final public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index) + final public function readMetaDataIndex(ModelInterface $model, int $index) { } @@ -518,11 +518,11 @@ public function reset() * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes * @return void */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setAutomaticCreateAttributes(ModelInterface $model, array $attributes) { } @@ -538,11 +538,11 @@ public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes * @return void */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setAutomaticUpdateAttributes(ModelInterface $model, array $attributes) { } @@ -558,31 +558,31 @@ public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes * @return void */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes) + public function setEmptyStringAttributes(ModelInterface $model, array $attributes) { } /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } /** * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy + * @param StrategyInterface $strategy * @return void */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy) + public function setStrategy(StrategyInterface $strategy) { } @@ -612,24 +612,24 @@ public function write(string $key, array $data) * ); * ``` * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index * @param mixed $data * @return void */ - final public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data) + final public function writeMetaDataIndex(ModelInterface $model, int $index, $data) { } /** * Initialize the metadata for certain table * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param mixed $key * @param mixed $table * @param mixed $schema */ - final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $table, $schema) + final protected function initialize(ModelInterface $model, $key, $table, $schema) { } @@ -642,5 +642,4 @@ final protected function initialize(\Phalcon\Mvc\ModelInterface $model, $key, $t private function throwWriteException($option) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Apcu.php b/src/Phalcon/Mvc/Model/MetaData/Apcu.php index ea123946..3ef7370f 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Apcu.php +++ b/src/Phalcon/Mvc/Model/MetaData/Apcu.php @@ -39,10 +39,9 @@ class Apcu extends MetaData * Phalcon\Mvc\Model\MetaData\Apcu constructor * * @param array $options - * @param \Phalcon\Cache\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = null) + public function __construct(AdapterFactory $factory, array $options = null) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php index 2190420c..61352d2e 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php +++ b/src/Phalcon/Mvc/Model/MetaData/Libmemcached.php @@ -28,9 +28,9 @@ class Libmemcached extends MetaData * Phalcon\Mvc\Model\MetaData\Libmemcached constructor * * @param array $options - * @param \Phalcon\Cache\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + public function __construct(AdapterFactory $factory, array $options = array()) { } @@ -42,5 +42,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Memory.php b/src/Phalcon/Mvc/Model/MetaData/Memory.php index 2fb40c00..2f749e5c 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Memory.php +++ b/src/Phalcon/Mvc/Model/MetaData/Memory.php @@ -49,5 +49,4 @@ public function read(string $key): ?array public function write(string $key, array $data) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Redis.php b/src/Phalcon/Mvc/Model/MetaData/Redis.php index 0c78cbe1..fee61ff1 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Redis.php +++ b/src/Phalcon/Mvc/Model/MetaData/Redis.php @@ -41,9 +41,9 @@ class Redis extends MetaData * Phalcon\Mvc\Model\MetaData\Redis constructor * * @param array $options - * @param \Phalcon\Cache\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $options = array()) + public function __construct(AdapterFactory $factory, array $options = array()) { } @@ -55,5 +55,4 @@ public function __construct(\Phalcon\Cache\AdapterFactory $factory, array $optio public function reset() { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php index 511a53f7..a5b20c91 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Annotations.php @@ -23,29 +23,28 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Annotations implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +class Annotations implements StrategyInterface { /** * Read the model's column map, this can't be inferred * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + final public function getColumnMaps(ModelInterface $model, DiInterface $container): array { } /** * The meta-data is obtained by reading the column descriptions from the database information schema * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + final public function getMetaData(ModelInterface $model, DiInterface $container): array { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php index 7284f45f..3f98780f 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/Introspection.php @@ -21,29 +21,28 @@ * * Queries the table meta-data in order to introspect the model's metadata */ -class Introspection implements \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface +class Introspection implements StrategyInterface { /** * Read the model's column map, this can't be inferred * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array */ - final public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + final public function getColumnMaps(ModelInterface $model, DiInterface $container): array { } /** * The meta-data is obtained by reading the column descriptions from the database information schema * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array */ - final public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array + final public function getMetaData(ModelInterface $model, DiInterface $container): array { } - } diff --git a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php index 1ca28cf0..865b6996 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php +++ b/src/Phalcon/Mvc/Model/MetaData/Strategy/StrategyInterface.php @@ -26,20 +26,19 @@ interface StrategyInterface /** * Read the model's column map, this can't be inferred * - * @todo Not implemented - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array + *@todo Not implemented */ - public function getColumnMaps(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; + public function getColumnMaps(ModelInterface $model, DiInterface $container): array; /** * The meta-data is obtained by reading the column descriptions from the database information schema * - * @param \Phalcon\Mvc\ModelInterface $model - * @param \Phalcon\Di\DiInterface $container + * @param ModelInterface $model + * @param DiInterface $container * @return array */ - public function getMetaData(\Phalcon\Mvc\ModelInterface $model, \Phalcon\Di\DiInterface $container): array; - + public function getMetaData(ModelInterface $model, DiInterface $container): array; } diff --git a/src/Phalcon/Mvc/Model/MetaData/Stream.php b/src/Phalcon/Mvc/Model/MetaData/Stream.php index 73bcd537..be7d92f5 100644 --- a/src/Phalcon/Mvc/Model/MetaData/Stream.php +++ b/src/Phalcon/Mvc/Model/MetaData/Stream.php @@ -70,5 +70,4 @@ public function write(string $key, array $data) private function throwWriteException($option) { } - } diff --git a/src/Phalcon/Mvc/Model/MetaDataInterface.php b/src/Phalcon/Mvc/Model/MetaDataInterface.php index 405e2024..c4551619 100644 --- a/src/Phalcon/Mvc/Model/MetaDataInterface.php +++ b/src/Phalcon/Mvc/Model/MetaDataInterface.php @@ -23,114 +23,114 @@ interface MetaDataInterface /** * Returns table attributes names (fields) * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getAttributes(ModelInterface $model): array; /** * Returns attributes that must be ignored from the INSERT SQL generation * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getAutomaticCreateAttributes(ModelInterface $model): array; /** * Returns attributes that must be ignored from the UPDATE SQL generation * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getAutomaticUpdateAttributes(ModelInterface $model): array; /** * Returns attributes and their bind data types * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getBindTypes(\Phalcon\Mvc\ModelInterface $model): array; + public function getBindTypes(ModelInterface $model): array; /** * Returns the column map if any * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getColumnMap(\Phalcon\Mvc\ModelInterface $model): array; + public function getColumnMap(ModelInterface $model): array; /** * Returns attributes (which have default values) and their default values * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDefaultValues(\Phalcon\Mvc\ModelInterface $model): array; + public function getDefaultValues(ModelInterface $model): array; /** * Returns attributes and their data types * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDataTypes(\Phalcon\Mvc\ModelInterface $model): array; + public function getDataTypes(ModelInterface $model): array; /** * Returns attributes which types are numerical * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getDataTypesNumeric(\Phalcon\Mvc\ModelInterface $model): array; + public function getDataTypesNumeric(ModelInterface $model): array; /** * Returns attributes allow empty strings * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getEmptyStringAttributes(ModelInterface $model): array; /** * Returns the name of identity field (if one is present) * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return string|null */ - public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string; + public function getIdentityField(ModelInterface $model): ?string; /** * Returns an array of fields which are not part of the primary key * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getNonPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getNonPrimaryKeyAttributes(ModelInterface $model): array; /** * Returns an array of not null attributes * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getNotNullAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getNotNullAttributes(ModelInterface $model): array; /** * Returns an array of fields which are part of the primary key * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getPrimaryKeyAttributes(\Phalcon\Mvc\ModelInterface $model): array; + public function getPrimaryKeyAttributes(ModelInterface $model): array; /** * Returns the reverse column map if any * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function getReverseColumnMap(\Phalcon\Mvc\ModelInterface $model): array; + public function getReverseColumnMap(ModelInterface $model): array; /** * Return the strategy to obtain the meta-data @@ -142,11 +142,11 @@ public function getStrategy(): StrategyInterface; /** * Check if a model has certain attribute * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param string $attribute * @return bool */ - public function hasAttribute(\Phalcon\Mvc\ModelInterface $model, string $attribute): bool; + public function hasAttribute(ModelInterface $model, string $attribute): bool; /** * Checks if the internal meta-data container is empty @@ -166,35 +166,35 @@ public function read(string $key): ?array; /** * Reads the ordered/reversed column map for certain model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array|null */ - public function readColumnMap(\Phalcon\Mvc\ModelInterface $model): ?array; + public function readColumnMap(ModelInterface $model): ?array; /** * Reads column-map information for certain model using a MODEL_ constant * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index */ - public function readColumnMapIndex(\Phalcon\Mvc\ModelInterface $model, int $index); + public function readColumnMapIndex(ModelInterface $model, int $index); /** * Reads meta-data for certain model * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @return array */ - public function readMetaData(\Phalcon\Mvc\ModelInterface $model): array; + public function readMetaData(ModelInterface $model): array; /** * Reads meta-data for certain model using a MODEL_ constant * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index * @return mixed */ - public function readMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index); + public function readMetaDataIndex(ModelInterface $model, int $index); /** * Resets internal meta-data in order to regenerate it @@ -204,43 +204,43 @@ public function reset(); /** * Set the attributes that must be ignored from the INSERT SQL generation * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes */ - public function setAutomaticCreateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function setAutomaticCreateAttributes(ModelInterface $model, array $attributes); /** * Set the attributes that must be ignored from the UPDATE SQL generation * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes */ - public function setAutomaticUpdateAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function setAutomaticUpdateAttributes(ModelInterface $model, array $attributes); /** * Set the attributes that allow empty string values * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $attributes * @return void */ - public function setEmptyStringAttributes(\Phalcon\Mvc\ModelInterface $model, array $attributes); + public function setEmptyStringAttributes(ModelInterface $model, array $attributes); /** * Writes meta-data for certain model using a MODEL_ constant * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param int $index * @param mixed $data */ - public function writeMetaDataIndex(\Phalcon\Mvc\ModelInterface $model, int $index, $data); + public function writeMetaDataIndex(ModelInterface $model, int $index, $data); /** * Set the meta-data extraction strategy * - * @param \Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy + * @param StrategyInterface $strategy */ - public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterface $strategy); + public function setStrategy(StrategyInterface $strategy); /** * Writes meta-data to the adapter @@ -250,5 +250,4 @@ public function setStrategy(\Phalcon\Mvc\Model\MetaData\Strategy\StrategyInterfa * @return void */ public function write(string $key, array $data); - } diff --git a/src/Phalcon/Mvc/Model/Query.php b/src/Phalcon/Mvc/Model/Query.php index 67868bd0..0056a959 100644 --- a/src/Phalcon/Mvc/Model/Query.php +++ b/src/Phalcon/Mvc/Model/Query.php @@ -75,7 +75,7 @@ * $resultWithOutEntries = $queryWithTransaction->execute(); * ``` */ -class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionAwareInterface +class Query implements QueryInterface, InjectionAwareInterface { const TYPE_DELETE = 303; @@ -156,7 +156,7 @@ class Query implements \Phalcon\Mvc\Model\QueryInterface, \Phalcon\Di\InjectionA protected $uniqueRow; - static protected $_irPhqlCache; + protected static $_irPhqlCache; /** * TransactionInterface so that the query can wrap a transaction @@ -182,20 +182,20 @@ public function getTransaction() * Phalcon\Mvc\Model\Query constructor * * @param string $phql - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param array $options */ - public function __construct(string $phql = null, \Phalcon\Di\DiInterface $container = null, array $options = array()) + public function __construct(string $phql = null, DiInterface $container = null, array $options = array()) { } /** * Sets the dependency injection container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -510,13 +510,13 @@ final protected function _executeDelete(array $intermediate, array $bindParams, /** * Query the records on which the UPDATE/DELETE operation will be done * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return ResultsetInterface */ - final protected function _getRelatedRecords(\Phalcon\Mvc\ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface + final protected function _getRelatedRecords(ModelInterface $model, array $intermediate, array $bindParams, array $bindTypes): ResultsetInterface { } @@ -672,13 +672,13 @@ public static function clean() * Gets the read connection from the model if there is no transaction set * inside the query object * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return AdapterInterface */ - protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + protected function getReadConnection(ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface { } @@ -686,13 +686,13 @@ protected function getReadConnection(\Phalcon\Mvc\ModelInterface $model, array $ * Gets the write connection from the model if there is no transaction * inside the query object * - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return AdapterInterface */ - protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface + protected function getWriteConnection(ModelInterface $model, array $intermediate = null, array $bindParams = array(), array $bindTypes = array()): AdapterInterface { } @@ -705,5 +705,4 @@ protected function getWriteConnection(\Phalcon\Mvc\ModelInterface $model, array public function setTransaction(TransactionInterface $transaction): QueryInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Query/Builder.php b/src/Phalcon/Mvc/Model/Query/Builder.php index da85cd9c..715a747b 100644 --- a/src/Phalcon/Mvc/Model/Query/Builder.php +++ b/src/Phalcon/Mvc/Model/Query/Builder.php @@ -53,7 +53,7 @@ * $queryBuilder = new \Phalcon\Mvc\Model\Query\Builder($params); * ``` */ -class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\InjectionAwareInterface +class Builder implements BuilderInterface, InjectionAwareInterface { protected $bindParams; @@ -110,9 +110,9 @@ class Builder implements \Phalcon\Mvc\Model\Query\BuilderInterface, \Phalcon\Di\ * Phalcon\Mvc\Model\Query\Builder constructor * * @param mixed $params - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function __construct($params = null, \Phalcon\Di\DiInterface $container = null) + public function __construct($params = null, DiInterface $container = null) { } @@ -836,10 +836,10 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -922,5 +922,4 @@ protected function conditionNotBetween(string $clause, string $operator, string protected function conditionNotIn(string $clause, string $operator, string $expr, array $values): BuilderInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php index 5ecec31b..d9b86f9b 100644 --- a/src/Phalcon/Mvc/Model/Query/BuilderInterface.php +++ b/src/Phalcon/Mvc/Model/Query/BuilderInterface.php @@ -350,5 +350,4 @@ public function setBindTypes(array $bindTypes, bool $merge = false): BuilderInte * @return BuilderInterface */ public function where(string $conditions, array $bindParams = array(), array $bindTypes = array()): BuilderInterface; - } diff --git a/src/Phalcon/Mvc/Model/Query/Lang.php b/src/Phalcon/Mvc/Model/Query/Lang.php index f87716d1..1877eef5 100644 --- a/src/Phalcon/Mvc/Model/Query/Lang.php +++ b/src/Phalcon/Mvc/Model/Query/Lang.php @@ -42,5 +42,4 @@ abstract class Lang public static function parsePHQL(string $phql): array { } - } diff --git a/src/Phalcon/Mvc/Model/Query/Status.php b/src/Phalcon/Mvc/Model/Query/Status.php index eb5cc544..24d7ec08 100644 --- a/src/Phalcon/Mvc/Model/Query/Status.php +++ b/src/Phalcon/Mvc/Model/Query/Status.php @@ -39,7 +39,7 @@ * } * ``` */ -class Status implements \Phalcon\Mvc\Model\Query\StatusInterface +class Status implements StatusInterface { protected $model; @@ -52,16 +52,16 @@ class Status implements \Phalcon\Mvc\Model\Query\StatusInterface * Phalcon\Mvc\Model\Query\Status * * @param bool $success - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model */ - public function __construct(bool $success, \Phalcon\Mvc\ModelInterface $model = null) + public function __construct(bool $success, ModelInterface $model = null) { } /** * Returns the messages produced because of a failed operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages(): array { @@ -84,5 +84,4 @@ public function getModel(): ModelInterface public function success(): bool { } - } diff --git a/src/Phalcon/Mvc/Model/Query/StatusInterface.php b/src/Phalcon/Mvc/Model/Query/StatusInterface.php index f788b95f..fdbdf9b3 100644 --- a/src/Phalcon/Mvc/Model/Query/StatusInterface.php +++ b/src/Phalcon/Mvc/Model/Query/StatusInterface.php @@ -23,7 +23,7 @@ interface StatusInterface /** * Returns the messages produced by an operation failed * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages(): array; @@ -40,5 +40,4 @@ public function getModel(): ModelInterface; * @return bool */ public function success(): bool; - } diff --git a/src/Phalcon/Mvc/Model/QueryInterface.php b/src/Phalcon/Mvc/Model/QueryInterface.php index d6dc6696..23e22e87 100644 --- a/src/Phalcon/Mvc/Model/QueryInterface.php +++ b/src/Phalcon/Mvc/Model/QueryInterface.php @@ -121,5 +121,4 @@ public function setSharedLock(bool $sharedLock = false): QueryInterface; * @return QueryInterface */ public function setUniqueRow(bool $uniqueRow): QueryInterface; - } diff --git a/src/Phalcon/Mvc/Model/Relation.php b/src/Phalcon/Mvc/Model/Relation.php index a11d2579..39caf395 100644 --- a/src/Phalcon/Mvc/Model/Relation.php +++ b/src/Phalcon/Mvc/Model/Relation.php @@ -14,7 +14,7 @@ * * This class represents a relationship between two models */ -class Relation implements \Phalcon\Mvc\Model\RelationInterface +class Relation implements RelationInterface { const ACTION_CASCADE = 2; @@ -215,5 +215,4 @@ public function isReusable(): bool public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields) { } - } diff --git a/src/Phalcon/Mvc/Model/RelationInterface.php b/src/Phalcon/Mvc/Model/RelationInterface.php index 724df960..ed33aa25 100644 --- a/src/Phalcon/Mvc/Model/RelationInterface.php +++ b/src/Phalcon/Mvc/Model/RelationInterface.php @@ -124,5 +124,4 @@ public function isThrough(): bool; * @param string $intermediateModel */ public function setIntermediateRelation($intermediateFields, string $intermediateModel, $intermediateReferencedFields); - } diff --git a/src/Phalcon/Mvc/Model/ResultInterface.php b/src/Phalcon/Mvc/Model/ResultInterface.php index 79830bcc..c4fa0b86 100644 --- a/src/Phalcon/Mvc/Model/ResultInterface.php +++ b/src/Phalcon/Mvc/Model/ResultInterface.php @@ -26,5 +26,4 @@ interface ResultInterface * @return mixed */ public function setDirtyState(int $dirtyState); - } diff --git a/src/Phalcon/Mvc/Model/Resultset.php b/src/Phalcon/Mvc/Model/Resultset.php index 56022edb..ec71b0d5 100644 --- a/src/Phalcon/Mvc/Model/Resultset.php +++ b/src/Phalcon/Mvc/Model/Resultset.php @@ -64,7 +64,7 @@ * } * ``` */ -abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable +abstract class Resultset implements ResultsetInterface, Iterator, SeekableIterator, Countable, ArrayAccess, Serializable, JsonSerializable { const HYDRATE_ARRAYS = 1; @@ -118,9 +118,9 @@ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iter * Phalcon\Mvc\Model\Resultset constructor * * @param \Phalcon\Db\ResultInterface|false $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param AdapterInterface $cache */ - public function __construct($result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + public function __construct($result, AdapterInterface $cache = null) { } @@ -136,10 +136,10 @@ final public function count(): int /** * Deletes every record in the resultset * - * @param \Closure $conditionCallback + * @param Closure $conditionCallback * @return bool */ - public function delete(\Closure $conditionCallback = null): bool + public function delete(Closure $conditionCallback = null): bool { } @@ -157,7 +157,7 @@ public function delete(\Closure $conditionCallback = null): bool * ``` * * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] + * @return array|ModelInterface[] */ public function filter($filter): array { @@ -202,7 +202,7 @@ public function getLast(): ?ModelInterface /** * Returns the error messages produced by a batch operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages(): array { @@ -284,7 +284,7 @@ public function offsetExists($index): bool * Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @param ModelInterface $value * @return void */ public function offsetSet($index, $value) @@ -345,10 +345,10 @@ public function setIsFresh(bool $isFresh): ResultsetInterface * Updates every record in the resultset * * @param array $data - * @param \Closure $conditionCallback + * @param Closure $conditionCallback * @return bool */ - public function update($data, \Closure $conditionCallback = null): bool + public function update($data, Closure $conditionCallback = null): bool { } @@ -360,5 +360,4 @@ public function update($data, \Closure $conditionCallback = null): bool public function valid(): bool { } - } diff --git a/src/Phalcon/Mvc/Model/Resultset/Complex.php b/src/Phalcon/Mvc/Model/Resultset/Complex.php index ed6314da..7a2550e5 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Complex.php +++ b/src/Phalcon/Mvc/Model/Resultset/Complex.php @@ -28,7 +28,7 @@ * Complex resultsets may include complete objects and scalar values. * This class builds every complex row as it is required */ -class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface +class Complex extends Resultset implements ResultsetInterface { protected $columnTypes; @@ -44,10 +44,10 @@ class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface * Phalcon\Mvc\Model\Resultset\Complex constructor * * @param array $columnTypes - * @param \Phalcon\Db\ResultInterface $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param ResultInterface $result + * @param AdapterInterface $cache */ - public function __construct($columnTypes, \Phalcon\Db\ResultInterface $result = null, \Phalcon\Cache\Adapter\AdapterInterface $cache = null) + public function __construct($columnTypes, ResultInterface $result = null, AdapterInterface $cache = null) { } @@ -88,5 +88,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Mvc/Model/Resultset/Simple.php b/src/Phalcon/Mvc/Model/Resultset/Simple.php index a27f66b0..927501b0 100644 --- a/src/Phalcon/Mvc/Model/Resultset/Simple.php +++ b/src/Phalcon/Mvc/Model/Resultset/Simple.php @@ -42,12 +42,12 @@ class Simple extends Resultset * Phalcon\Mvc\Model\Resultset\Simple constructor * * @param array $columnMap - * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $model + * @param ModelInterface|Phalcon\Mvc\Model\Row $model * @param mixed $result - * @param \Phalcon\Cache\Adapter\AdapterInterface $cache + * @param AdapterInterface $cache * @param bool $keepSnapshots */ - public function __construct($columnMap, $model, $result, \Phalcon\Cache\Adapter\AdapterInterface $cache = null, bool $keepSnapshots = null) + public function __construct($columnMap, $model, $result, AdapterInterface $cache = null, bool $keepSnapshots = null) { } @@ -92,5 +92,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Mvc/Model/ResultsetInterface.php b/src/Phalcon/Mvc/Model/ResultsetInterface.php index 6e57b01a..77993d7c 100644 --- a/src/Phalcon/Mvc/Model/ResultsetInterface.php +++ b/src/Phalcon/Mvc/Model/ResultsetInterface.php @@ -25,10 +25,10 @@ interface ResultsetInterface /** * Deletes every record in the resultset * - * @param \Closure $conditionCallback + * @param Closure $conditionCallback * @return bool */ - public function delete(\Closure $conditionCallback = null): bool; + public function delete(Closure $conditionCallback = null): bool; /** * Filters a resultset returning only those the developer requires @@ -44,7 +44,7 @@ public function delete(\Closure $conditionCallback = null): bool; * ``` * * @param callable $filter - * @return array|\Phalcon\Mvc\ModelInterface[] + * @return array|ModelInterface[] */ public function filter($filter): array; @@ -79,7 +79,7 @@ public function getLast(): ?ModelInterface; /** * Returns the error messages produced by a batch operation * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages(): array; @@ -125,9 +125,8 @@ public function toArray(): array; * Updates every record in the resultset * * @param array $data - * @param \Closure $conditionCallback + * @param Closure $conditionCallback * @return bool */ - public function update($data, \Closure $conditionCallback = null): bool; - + public function update($data, Closure $conditionCallback = null): bool; } diff --git a/src/Phalcon/Mvc/Model/Row.php b/src/Phalcon/Mvc/Model/Row.php index 1f28c01a..97721568 100644 --- a/src/Phalcon/Mvc/Model/Row.php +++ b/src/Phalcon/Mvc/Model/Row.php @@ -20,7 +20,7 @@ * This component allows Phalcon\Mvc\Model to return rows without an associated entity. * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. */ -class Row implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\Model\ResultInterface, \ArrayAccess, \JsonSerializable +class Row implements EntityInterface, ResultInterface, ArrayAccess, JsonSerializable { /** @@ -56,7 +56,7 @@ public function offsetExists($index): bool * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface * * @param string|int $index - * @param \Phalcon\Mvc\ModelInterface $value + * @param ModelInterface $value * @return void */ public function offsetSet($index, $value) @@ -120,5 +120,4 @@ public function toArray(): array public function writeAttribute(string $attribute, $value) { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction.php b/src/Phalcon/Mvc/Model/Transaction.php index 88a1802b..20ec902d 100644 --- a/src/Phalcon/Mvc/Model/Transaction.php +++ b/src/Phalcon/Mvc/Model/Transaction.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Di\DiInterface; use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Transaction\Failed as TxFailed; @@ -89,11 +90,11 @@ class Transaction implements \Phalcon\Mvc\Model\TransactionInterface /** * Phalcon\Mvc\Model\Transaction constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @param bool $autoBegin * @param string $service */ - public function __construct(\Phalcon\Di\DiInterface $container, bool $autoBegin = false, string $service = 'db') + public function __construct(DiInterface $container, bool $autoBegin = false, string $service = 'db') { } @@ -118,9 +119,9 @@ public function commit(): bool /** * Returns the connection related to transaction * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface + public function getConnection(): AdapterInterface { } @@ -155,10 +156,10 @@ public function isValid(): bool * Rollbacks the transaction * * @param string $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord + * @param ModelInterface $rollbackRecord * @return bool */ - public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool + public function rollback(string $rollbackMessage = null, ModelInterface $rollbackRecord = null): bool { } @@ -185,20 +186,20 @@ public function setRollbackOnAbort(bool $rollbackOnAbort) /** * Sets object which generates rollback action * - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @return void */ - public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record) + public function setRollbackedRecord(ModelInterface $record) { } /** * Sets transaction manager related to the transaction * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + * @param ManagerInterface $manager * @return void */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager) + public function setTransactionManager(ManagerInterface $manager) { } @@ -211,5 +212,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte public function throwRollbackException(bool $status): TransactionInterface { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/Failed.php b/src/Phalcon/Mvc/Model/Transaction/Failed.php index 24590b59..6045fdf9 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Failed.php +++ b/src/Phalcon/Mvc/Model/Transaction/Failed.php @@ -17,7 +17,7 @@ * * This class will be thrown to exit a try/catch block for isolated transactions */ -class Failed extends \Phalcon\Mvc\Model\Transaction\Exception +class Failed extends Exception { protected $record = null; @@ -27,9 +27,9 @@ class Failed extends \Phalcon\Mvc\Model\Transaction\Exception * Phalcon\Mvc\Model\Transaction\Failed constructor * * @param string $message - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record */ - public function __construct(string $message, \Phalcon\Mvc\ModelInterface $record = null) + public function __construct(string $message, ModelInterface $record = null) { } @@ -45,10 +45,9 @@ public function getRecord(): ModelInterface /** * Returns validation record messages which stop the transaction * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getRecordMessages(): array { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/Manager.php b/src/Phalcon/Mvc/Model/Transaction/Manager.php index 9949b381..157ba1a1 100644 --- a/src/Phalcon/Mvc/Model/Transaction/Manager.php +++ b/src/Phalcon/Mvc/Model/Transaction/Manager.php @@ -62,7 +62,7 @@ * } * ``` */ -class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalcon\Di\InjectionAwareInterface +class Manager implements ManagerInterface, InjectionAwareInterface { protected $container; @@ -88,9 +88,9 @@ class Manager implements \Phalcon\Mvc\Model\Transaction\ManagerInterface, \Phalc /** * Phalcon\Mvc\Model\Transaction\Manager constructor * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function __construct(\Phalcon\Di\DiInterface $container = null) + public function __construct(DiInterface $container = null) { } @@ -171,20 +171,20 @@ public function has(): bool /** * Notifies the manager about a committed transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction) + public function notifyCommit(TransactionInterface $transaction) { } /** * Notifies the manager about a rollbacked transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction) + public function notifyRollback(TransactionInterface $transaction) { } @@ -221,10 +221,10 @@ public function setDbService(string $service): ManagerInterface /** * Sets the dependency injection container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -242,11 +242,10 @@ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface /** * Removes transactions from the TransactionManager * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - protected function collectTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction) + protected function collectTransaction(TransactionInterface $transaction) { } - } diff --git a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php index 7bde20da..600b3ba8 100644 --- a/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php +++ b/src/Phalcon/Mvc/Model/Transaction/ManagerInterface.php @@ -63,18 +63,18 @@ public function has(): bool; /** * Notifies the manager about a committed transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyCommit(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function notifyCommit(TransactionInterface $transaction); /** * Notifies the manager about a rollbacked transaction * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return void */ - public function notifyRollback(\Phalcon\Mvc\Model\TransactionInterface $transaction); + public function notifyRollback(TransactionInterface $transaction); /** * Rollbacks active transactions within the manager @@ -107,5 +107,4 @@ public function setDbService(string $service): ManagerInterface; * @return ManagerInterface */ public function setRollbackPendent(bool $rollbackPendent): ManagerInterface; - } diff --git a/src/Phalcon/Mvc/Model/TransactionInterface.php b/src/Phalcon/Mvc/Model/TransactionInterface.php index 8f5268b6..01ab543a 100644 --- a/src/Phalcon/Mvc/Model/TransactionInterface.php +++ b/src/Phalcon/Mvc/Model/TransactionInterface.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Mvc\Model; +use Phalcon\Db\Adapter\AdapterInterface; use Phalcon\Mvc\ModelInterface; use Phalcon\Mvc\Model\Transaction\ManagerInterface; @@ -37,9 +38,9 @@ public function commit(): bool; /** * Returns connection related to transaction * - * @return \Phalcon\Db\Adapter\AdapterInterface + * @return AdapterInterface */ - public function getConnection(): \Phalcon\Db\Adapter\AdapterInterface; + public function getConnection(): AdapterInterface; /** * Returns validations messages from last save try @@ -66,10 +67,10 @@ public function isValid(): bool; * Rollbacks the transaction * * @param string $rollbackMessage - * @param \Phalcon\Mvc\ModelInterface $rollbackRecord + * @param ModelInterface $rollbackRecord * @return bool */ - public function rollback(string $rollbackMessage = null, \Phalcon\Mvc\ModelInterface $rollbackRecord = null): bool; + public function rollback(string $rollbackMessage = null, ModelInterface $rollbackRecord = null): bool; /** * Sets if is a reused transaction or new once @@ -90,18 +91,18 @@ public function setRollbackOnAbort(bool $rollbackOnAbort); /** * Sets object which generates rollback action * - * @param \Phalcon\Mvc\ModelInterface $record + * @param ModelInterface $record * @return void */ - public function setRollbackedRecord(\Phalcon\Mvc\ModelInterface $record); + public function setRollbackedRecord(ModelInterface $record); /** * Sets transaction manager related to the transaction * - * @param \Phalcon\Mvc\Model\Transaction\ManagerInterface $manager + * @param ManagerInterface $manager * @return void */ - public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInterface $manager); + public function setTransactionManager(ManagerInterface $manager); /** * Enables throwing exception @@ -110,5 +111,4 @@ public function setTransactionManager(\Phalcon\Mvc\Model\Transaction\ManagerInte * @return TransactionInterface */ public function throwRollbackException(bool $status): TransactionInterface; - } diff --git a/src/Phalcon/Mvc/Model/ValidationFailed.php b/src/Phalcon/Mvc/Model/ValidationFailed.php index fec0d493..dbe051a3 100644 --- a/src/Phalcon/Mvc/Model/ValidationFailed.php +++ b/src/Phalcon/Mvc/Model/ValidationFailed.php @@ -17,7 +17,7 @@ * This exception is generated when a model fails to save a record * Phalcon\Mvc\Model must be set up to have this behavior */ -class ValidationFailed extends \Phalcon\Mvc\Model\Exception +class ValidationFailed extends Exception { protected $messages; @@ -30,11 +30,11 @@ class ValidationFailed extends \Phalcon\Mvc\Model\Exception * Phalcon\Mvc\Model\ValidationFailed constructor * * @param Message[] validationMessages - * @param \Phalcon\Mvc\ModelInterface $model + * @param ModelInterface $model * @param array $validationMessages * @param Message [] validationMessages */ - public function __construct(\Phalcon\Mvc\ModelInterface $model, array $validationMessages) + public function __construct(ModelInterface $model, array $validationMessages) { } @@ -55,5 +55,4 @@ public function getMessages(): array public function getModel(): ModelInterface { } - } diff --git a/src/Phalcon/Mvc/ModelInterface.php b/src/Phalcon/Mvc/ModelInterface.php index b856049b..80537a70 100644 --- a/src/Phalcon/Mvc/ModelInterface.php +++ b/src/Phalcon/Mvc/ModelInterface.php @@ -14,6 +14,7 @@ use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\MetaDataInterface; +use Phalcon\Mvc\Model\Resultset\Simple; use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\TransactionInterface; @@ -28,10 +29,10 @@ interface ModelInterface /** * Appends a customized message on the validation process * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ModelInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ModelInterface; + public function appendMessage(MessageInterface $message): ModelInterface; /** * Assigns values to a model from an array @@ -66,12 +67,12 @@ public static function cloneResult(ModelInterface $base, array $data, int $dirty /** * Assigns values to a model from an array returning a new model * - * @param \Phalcon\Mvc\Model $base + * @param Model $base * @param array $columnMap - * @return \Phalcon\Mvc\Model result * @param array $data * @param int $dirtyState * @param bool $keepSnapshots + *@return Model result */ public static function cloneResultMap($base, array $data, $columnMap, int $dirtyState = 0, bool $keepSnapshots = null): ModelInterface; @@ -154,7 +155,7 @@ public function getDirtyState(): int; /** * Returns array of validation messages * - * @return array|\Phalcon\Messages\MessageInterface[] + * @return array|MessageInterface[] */ public function getMessages(): array; @@ -191,7 +192,7 @@ public function getReadConnectionService(): string; * Returns related records based on defined relations * * @param array $arguments - * @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|false + * @return Simple|Phalcon\Mvc\Model\Resultset\Simple|false * @param string $alias */ public function getRelated(string $alias, $arguments = null); @@ -245,10 +246,10 @@ public static function minimum($parameters = null); /** * Create a criteria for a specific model * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return CriteriaInterface */ - public static function query(\Phalcon\Di\DiInterface $container = null): CriteriaInterface; + public static function query(DiInterface $container = null): CriteriaInterface; /** * Refreshes the model attributes re-querying the record from the database @@ -303,10 +304,10 @@ public function setSnapshotData(array $data, $columnMap = null); /** * Sets a transaction related to the Model instance * - * @param \Phalcon\Mvc\Model\TransactionInterface $transaction + * @param TransactionInterface $transaction * @return ModelInterface */ - public function setTransaction(\Phalcon\Mvc\Model\TransactionInterface $transaction): ModelInterface; + public function setTransaction(TransactionInterface $transaction): ModelInterface; /** * Sets the DependencyInjection connection service used to write data @@ -347,5 +348,4 @@ public function validationHasFailed(): bool; * @return bool */ public function update(): bool; - } diff --git a/src/Phalcon/Mvc/ModuleDefinitionInterface.php b/src/Phalcon/Mvc/ModuleDefinitionInterface.php index 2d445b56..e4804a86 100644 --- a/src/Phalcon/Mvc/ModuleDefinitionInterface.php +++ b/src/Phalcon/Mvc/ModuleDefinitionInterface.php @@ -22,15 +22,14 @@ interface ModuleDefinitionInterface /** * Registers an autoloader related to the module * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function registerAutoloaders(\Phalcon\Di\DiInterface $container = null); + public function registerAutoloaders(DiInterface $container = null); /** * Registers services related to the module * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container */ - public function registerServices(\Phalcon\Di\DiInterface $container); - + public function registerServices(DiInterface $container); } diff --git a/src/Phalcon/Mvc/Router.php b/src/Phalcon/Mvc/Router.php index 65c6e7ef..b02608d7 100644 --- a/src/Phalcon/Mvc/Router.php +++ b/src/Phalcon/Mvc/Router.php @@ -47,7 +47,7 @@ * echo $router->getControllerName(); * ``` */ -class Router extends AbstractInjectionAware implements \Phalcon\Mvc\RouterInterface, \Phalcon\Events\EventsAwareInterface +class Router extends AbstractInjectionAware implements RouterInterface, EventsAwareInterface { const POSITION_FIRST = 0; @@ -376,11 +376,11 @@ public function addTrace(string $pattern, $paths = null, $position = Router::POS * ); * ``` * - * @param \Phalcon\Mvc\Router\RouteInterface $route + * @param RouteInterface $route * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface + public function attach(RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface { } @@ -488,7 +488,7 @@ public function getRouteByName(string $name) /** * Returns all the routes defined in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array|RouteInterface[] */ public function getRoutes(): array { @@ -521,10 +521,10 @@ public function isExactControllerName(): bool /** * Mounts a group of routes in the router * - * @param \Phalcon\Mvc\Router\GroupInterface $group + * @param GroupInterface $group * @return RouterInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface + public function mount(GroupInterface $group): RouterInterface { } @@ -622,10 +622,10 @@ public function getDefaults(): array /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -637,5 +637,4 @@ public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager public function wasMatched(): bool { } - } diff --git a/src/Phalcon/Mvc/Router/Annotations.php b/src/Phalcon/Mvc/Router/Annotations.php index db4b9579..58958b68 100644 --- a/src/Phalcon/Mvc/Router/Annotations.php +++ b/src/Phalcon/Mvc/Router/Annotations.php @@ -102,9 +102,9 @@ public function handle(string $uri) * @param string $namespaceName * @param string $controller * @param string $action - * @param \Phalcon\Annotations\Annotation $annotation + * @param Annotation $annotation */ - public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, \Phalcon\Annotations\Annotation $annotation) + public function processActionAnnotation(string $module, string $namespaceName, string $controller, string $action, Annotation $annotation) { } @@ -112,9 +112,9 @@ public function processActionAnnotation(string $module, string $namespaceName, s * Checks for annotations in the controller docblock * * @param string $handler - * @param \Phalcon\Annotations\Annotation $annotation + * @param Annotation $annotation */ - public function processControllerAnnotation(string $handler, \Phalcon\Annotations\Annotation $annotation) + public function processControllerAnnotation(string $handler, Annotation $annotation) { } @@ -135,5 +135,4 @@ public function setActionSuffix(string $actionSuffix) public function setControllerSuffix(string $controllerSuffix) { } - } diff --git a/src/Phalcon/Mvc/Router/Group.php b/src/Phalcon/Mvc/Router/Group.php index 907eebd9..6250c89b 100644 --- a/src/Phalcon/Mvc/Router/Group.php +++ b/src/Phalcon/Mvc/Router/Group.php @@ -57,7 +57,7 @@ * $router->mount($blog); * ``` */ -class Group implements \Phalcon\Mvc\Router\GroupInterface +class Group implements GroupInterface { protected $beforeMatch; @@ -377,5 +377,4 @@ public function setPrefix(string $prefix): GroupInterface protected function addRoute(string $pattern, $paths = null, $httpMethods = null): RouteInterface { } - } diff --git a/src/Phalcon/Mvc/Router/GroupInterface.php b/src/Phalcon/Mvc/Router/GroupInterface.php index 7a86d77e..2ed4c526 100644 --- a/src/Phalcon/Mvc/Router/GroupInterface.php +++ b/src/Phalcon/Mvc/Router/GroupInterface.php @@ -237,5 +237,4 @@ public function setPaths($paths): GroupInterface; * @return GroupInterface */ public function setPrefix(string $prefix): GroupInterface; - } diff --git a/src/Phalcon/Mvc/Router/Route.php b/src/Phalcon/Mvc/Router/Route.php index 19f95622..7b1aac76 100644 --- a/src/Phalcon/Mvc/Router/Route.php +++ b/src/Phalcon/Mvc/Router/Route.php @@ -14,7 +14,7 @@ * * This class represents every route added to the router */ -class Route implements \Phalcon\Mvc\Router\RouteInterface +class Route implements RouteInterface { protected $beforeMatch; @@ -50,7 +50,7 @@ class Route implements \Phalcon\Mvc\Router\RouteInterface protected $pattern; - static protected $uniqueId = 0; + protected static $uniqueId = 0; @@ -374,5 +374,4 @@ public function setName(string $name): RouteInterface public function via($httpMethods): RouteInterface { } - } diff --git a/src/Phalcon/Mvc/Router/RouteInterface.php b/src/Phalcon/Mvc/Router/RouteInterface.php index c8930254..830cf72e 100644 --- a/src/Phalcon/Mvc/Router/RouteInterface.php +++ b/src/Phalcon/Mvc/Router/RouteInterface.php @@ -137,5 +137,4 @@ public static function reset(); * @return RouteInterface */ public function via($httpMethods): RouteInterface; - } diff --git a/src/Phalcon/Mvc/RouterInterface.php b/src/Phalcon/Mvc/RouterInterface.php index eae83087..ccc95fa9 100644 --- a/src/Phalcon/Mvc/RouterInterface.php +++ b/src/Phalcon/Mvc/RouterInterface.php @@ -31,11 +31,11 @@ public function add(string $pattern, $paths = null, $httpMethods = null): RouteI /** * Attach Route object to the routes stack. * - * @param \Phalcon\Mvc\Router\RouteInterface $route + * @param RouteInterface $route * @param mixed $position * @return RouterInterface */ - public function attach(\Phalcon\Mvc\Router\RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; + public function attach(RouteInterface $route, $position = Router::POSITION_LAST): RouterInterface; /** * Adds a route to the router that only match if the HTTP method is CONNECT @@ -187,7 +187,7 @@ public function getParams(): array; /** * Return all the routes defined in the router * - * @return array|\Phalcon\Mvc\Router\RouteInterface[] + * @return array|RouteInterface[] */ public function getRoutes(): array; @@ -218,10 +218,10 @@ public function handle(string $uri); /** * Mounts a group of routes in the router * - * @param \Phalcon\Mvc\Router\GroupInterface $group + * @param GroupInterface $group * @return RouterInterface */ - public function mount(\Phalcon\Mvc\Router\GroupInterface $group): RouterInterface; + public function mount(GroupInterface $group): RouterInterface; /** * Sets the default action name @@ -261,5 +261,4 @@ public function setDefaults(array $defaults): RouterInterface; * @return bool */ public function wasMatched(): bool; - } diff --git a/src/Phalcon/Mvc/View.php b/src/Phalcon/Mvc/View.php index 18898661..856ab359 100644 --- a/src/Phalcon/Mvc/View.php +++ b/src/Phalcon/Mvc/View.php @@ -45,7 +45,7 @@ * echo $view->getContent(); * ``` */ -class View extends Injectable implements \Phalcon\Mvc\ViewInterface, \Phalcon\Events\EventsAwareInterface +class View extends Injectable implements ViewInterface, EventsAwareInterface { /** * Render Level: To the action view @@ -597,10 +597,10 @@ public function setContent(string $content): View /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -828,5 +828,4 @@ protected function loadTemplateEngines(): array public function processRender(string $controllerName, string $actionName, array $params = array(), bool $fireEvents = true): bool { } - } diff --git a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php index 2255dab1..a3d8e5bd 100644 --- a/src/Phalcon/Mvc/View/Engine/AbstractEngine.php +++ b/src/Phalcon/Mvc/View/Engine/AbstractEngine.php @@ -17,7 +17,7 @@ * All the template engine adapters must inherit this class. This provides * basic interfacing between the engine and the Phalcon\Mvc\View component. */ -abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\Engine\EngineInterface +abstract class AbstractEngine extends Injectable implements EngineInterface { protected $view; @@ -26,10 +26,10 @@ abstract class AbstractEngine extends Injectable implements \Phalcon\Mvc\View\En /** * Phalcon\Mvc\View\Engine constructor * - * @param \Phalcon\Mvc\ViewBaseInterface $view - * @param \Phalcon\Di\DiInterface $container + * @param ViewBaseInterface $view + * @param DiInterface $container */ - public function __construct(\Phalcon\Mvc\ViewBaseInterface $view, \Phalcon\Di\DiInterface $container = null) + public function __construct(ViewBaseInterface $view, DiInterface $container = null) { } @@ -61,5 +61,4 @@ public function getView(): ViewBaseInterface public function partial(string $partialPath, $params = null) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/EngineInterface.php b/src/Phalcon/Mvc/View/Engine/EngineInterface.php index b0d283c7..78012e02 100644 --- a/src/Phalcon/Mvc/View/Engine/EngineInterface.php +++ b/src/Phalcon/Mvc/View/Engine/EngineInterface.php @@ -39,5 +39,4 @@ public function partial(string $partialPath, $params = null); * @param bool $mustClean */ public function render(string $path, $params, bool $mustClean = false); - } diff --git a/src/Phalcon/Mvc/View/Engine/Php.php b/src/Phalcon/Mvc/View/Engine/Php.php index a8b2ac61..283f1802 100644 --- a/src/Phalcon/Mvc/View/Engine/Php.php +++ b/src/Phalcon/Mvc/View/Engine/Php.php @@ -12,7 +12,7 @@ /** * Adapter to use PHP itself as templating engine */ -class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine +class Php extends AbstractEngine { /** @@ -25,5 +25,4 @@ class Php extends \Phalcon\Mvc\View\Engine\AbstractEngine public function render(string $path, $params, bool $mustClean = false) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt.php b/src/Phalcon/Mvc/View/Engine/Volt.php index b2ec3a84..4c6958a6 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt.php +++ b/src/Phalcon/Mvc/View/Engine/Volt.php @@ -18,7 +18,7 @@ /** * Designer friendly and fast template engine for PHP written in Zephir/C */ -class Volt extends \Phalcon\Mvc\View\Engine\AbstractEngine implements \Phalcon\Events\EventsAwareInterface +class Volt extends AbstractEngine implements EventsAwareInterface { protected $compiler; @@ -118,10 +118,10 @@ public function render(string $templatePath, $params, bool $mustClean = false) /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -154,5 +154,4 @@ public function slice($value, int $start = 0, $end = null) public function sort(array $value): array { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php index 11a65a55..439123aa 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Compiler.php @@ -25,7 +25,7 @@ * require $compiler->getCompiledTemplatePath(); * ``` */ -class Compiler implements \Phalcon\Di\InjectionAwareInterface +class Compiler implements InjectionAwareInterface { protected $autoescape = false; @@ -94,9 +94,9 @@ class Compiler implements \Phalcon\Di\InjectionAwareInterface /** * Phalcon\Mvc\View\Engine\Volt\Compiler * - * @param \Phalcon\Mvc\ViewBaseInterface $view + * @param ViewBaseInterface $view */ - public function __construct(\Phalcon\Mvc\ViewBaseInterface $view = null) + public function __construct(ViewBaseInterface $view = null) { } @@ -493,10 +493,10 @@ public function resolveTest(array $test, string $left): string /** * Sets the dependency injector * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } @@ -580,5 +580,4 @@ final protected function statementList(array $statements, bool $extendsMode = fa final protected function statementListOrExtends($statements) { } - } diff --git a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php index a89fdba6..cd92fc12 100644 --- a/src/Phalcon/Mvc/View/Engine/Volt/Exception.php +++ b/src/Phalcon/Mvc/View/Engine/Volt/Exception.php @@ -14,7 +14,7 @@ /** * Class for exceptions thrown by Phalcon\Mvc\View */ -class Exception extends \Phalcon\Mvc\View\Exception +class Exception extends BaseException { protected $statement; @@ -38,5 +38,4 @@ public function __construct(string $message = '', array $statement = array(), in public function getStatement(): array { } - } diff --git a/src/Phalcon/Mvc/View/Simple.php b/src/Phalcon/Mvc/View/Simple.php index 67af0f56..f38154eb 100644 --- a/src/Phalcon/Mvc/View/Simple.php +++ b/src/Phalcon/Mvc/View/Simple.php @@ -47,7 +47,7 @@ * ); * ``` */ -class Simple extends Injectable implements \Phalcon\Mvc\ViewBaseInterface, \Phalcon\Events\EventsAwareInterface +class Simple extends Injectable implements ViewBaseInterface, EventsAwareInterface { protected $activeRenderPath; @@ -252,10 +252,10 @@ public function setContent(string $content): Simple /** * Sets the events manager * - * @param \Phalcon\Events\ManagerInterface $eventsManager + * @param ManagerInterface $eventsManager * @return void */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager) { } @@ -336,5 +336,4 @@ protected function loadTemplateEngines(): array final protected function internalRender(string $path, $params) { } - } diff --git a/src/Phalcon/Mvc/ViewBaseInterface.php b/src/Phalcon/Mvc/ViewBaseInterface.php index c01d2115..fc7f446f 100644 --- a/src/Phalcon/Mvc/ViewBaseInterface.php +++ b/src/Phalcon/Mvc/ViewBaseInterface.php @@ -78,5 +78,4 @@ public function setVar(string $key, $value); * @param string $viewsDir */ public function setViewsDir(string $viewsDir); - } diff --git a/src/Phalcon/Mvc/ViewInterface.php b/src/Phalcon/Mvc/ViewInterface.php index ed02efdb..f7a7ac71 100644 --- a/src/Phalcon/Mvc/ViewInterface.php +++ b/src/Phalcon/Mvc/ViewInterface.php @@ -14,7 +14,7 @@ * * Interface for Phalcon\Mvc\View */ -interface ViewInterface extends \Phalcon\Mvc\ViewBaseInterface +interface ViewInterface extends ViewBaseInterface { /** @@ -202,5 +202,4 @@ public function setTemplateBefore($templateBefore); * Starts rendering process enabling the output buffering */ public function start(); - } diff --git a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php index 351fe3a2..035b9cf6 100644 --- a/src/Phalcon/Paginator/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Paginator/Adapter/AbstractAdapter.php @@ -16,7 +16,7 @@ /** * Phalcon\Paginator\Adapter\AbstractAdapter */ -abstract class AbstractAdapter implements \Phalcon\Paginator\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * Configuration of paginator @@ -82,10 +82,10 @@ public function setLimit(int $limitRows): AdapterInterface /** * Sets current repository for pagination * - * @param \Phalcon\Paginator\RepositoryInterface $repository + * @param RepositoryInterface $repository * @return AdapterInterface */ - public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository): AdapterInterface + public function setRepository(RepositoryInterface $repository): AdapterInterface { } @@ -98,5 +98,4 @@ public function setRepository(\Phalcon\Paginator\RepositoryInterface $repository protected function getRepository(array $properties = null): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/AdapterInterface.php b/src/Phalcon/Paginator/Adapter/AdapterInterface.php index e4136ebe..b39e5b27 100644 --- a/src/Phalcon/Paginator/Adapter/AdapterInterface.php +++ b/src/Phalcon/Paginator/Adapter/AdapterInterface.php @@ -46,5 +46,4 @@ public function setCurrentPage(int $page); * @param int $limit */ public function setLimit(int $limit); - } diff --git a/src/Phalcon/Paginator/Adapter/Model.php b/src/Phalcon/Paginator/Adapter/Model.php index f692741c..de87027a 100644 --- a/src/Phalcon/Paginator/Adapter/Model.php +++ b/src/Phalcon/Paginator/Adapter/Model.php @@ -79,7 +79,7 @@ * $paginate = $paginator->paginate(); * ``` */ -class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter +class Model extends AbstractAdapter { /** @@ -90,5 +90,4 @@ class Model extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/NativeArray.php b/src/Phalcon/Paginator/Adapter/NativeArray.php index fef477e5..b244a004 100644 --- a/src/Phalcon/Paginator/Adapter/NativeArray.php +++ b/src/Phalcon/Paginator/Adapter/NativeArray.php @@ -35,7 +35,7 @@ * ); * ``` */ -class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter +class NativeArray extends AbstractAdapter { /** @@ -46,5 +46,4 @@ class NativeArray extends \Phalcon\Paginator\Adapter\AbstractAdapter public function paginate(): RepositoryInterface { } - } diff --git a/src/Phalcon/Paginator/Adapter/QueryBuilder.php b/src/Phalcon/Paginator/Adapter/QueryBuilder.php index e01a2b48..a96864d8 100644 --- a/src/Phalcon/Paginator/Adapter/QueryBuilder.php +++ b/src/Phalcon/Paginator/Adapter/QueryBuilder.php @@ -36,7 +36,7 @@ * ); * ``` */ -class QueryBuilder extends \Phalcon\Paginator\Adapter\AbstractAdapter +class QueryBuilder extends AbstractAdapter { /** * Paginator's data @@ -92,11 +92,10 @@ public function paginate(): RepositoryInterface /** * Set query builder object * - * @param \Phalcon\Mvc\Model\Query\Builder $builder + * @param Builder $builder * @return QueryBuilder */ - public function setQueryBuilder(\Phalcon\Mvc\Model\Query\Builder $builder): QueryBuilder + public function setQueryBuilder(Builder $builder): QueryBuilder { } - } diff --git a/src/Phalcon/Paginator/PaginatorFactory.php b/src/Phalcon/Paginator/PaginatorFactory.php index 1509b5b4..b25e340c 100644 --- a/src/Phalcon/Paginator/PaginatorFactory.php +++ b/src/Phalcon/Paginator/PaginatorFactory.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Paginator; +use Phalcon\Config; use Phalcon\Paginator\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; use Phalcon\Helper\Arr; @@ -56,14 +57,14 @@ public function __construct(array $services = array()) * $paginator = (new PaginatorFactory())->load($options); * ``` * - * @param array|\Phalcon\Config = [ + * @param array|Config = [ * 'adapter' => 'queryBuilder', * 'limit' => 20, * 'page' => 1, * 'builder' => null * ] * @param mixed $config - * @param array|\Phalcon\Config = [ + * @param array|Config = [ * 'adapter' => 'queryBuilder', * 'limit' => 20, * 'page' => 1, @@ -92,5 +93,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Paginator/Repository.php b/src/Phalcon/Paginator/Repository.php index 332c90a8..00a8a85e 100644 --- a/src/Phalcon/Paginator/Repository.php +++ b/src/Phalcon/Paginator/Repository.php @@ -17,7 +17,7 @@ * * Repository of current state Phalcon\Paginator\AdapterInterface::paginate() */ -class Repository implements \Phalcon\Paginator\RepositoryInterface, \JsonSerializable +class Repository implements RepositoryInterface, JsonSerializable { /** * @var array @@ -170,5 +170,4 @@ protected function getProperty(string $property, $defaultValue = null) protected function getRealNameProperty(string $property): string { } - } diff --git a/src/Phalcon/Paginator/RepositoryInterface.php b/src/Phalcon/Paginator/RepositoryInterface.php index 37835568..921f0c17 100644 --- a/src/Phalcon/Paginator/RepositoryInterface.php +++ b/src/Phalcon/Paginator/RepositoryInterface.php @@ -120,5 +120,4 @@ public function setAliases(array $aliases): RepositoryInterface; * @return RepositoryInterface */ public function setProperties(array $properties): RepositoryInterface; - } diff --git a/src/Phalcon/Registry.php b/src/Phalcon/Registry.php index b78f5d0e..dccd5ec9 100644 --- a/src/Phalcon/Registry.php +++ b/src/Phalcon/Registry.php @@ -61,7 +61,7 @@ * are implemented using object handlers or similar techniques: this allows to * bypass relatively slow method calls. */ -final class Registry extends \Phalcon\Collection +final class Registry extends Collection { /** @@ -294,5 +294,4 @@ final public function toJson(int $options = 79): string final public function unserialize($serialized) { } - } diff --git a/src/Phalcon/Security.php b/src/Phalcon/Security.php index cc55e3ed..24e2a653 100644 --- a/src/Phalcon/Security.php +++ b/src/Phalcon/Security.php @@ -131,10 +131,10 @@ public function getWorkFactor(): int /** * Phalcon\Security constructor * - * @param \Phalcon\Session\ManagerInterface $session - * @param \Phalcon\Http\RequestInterface $request + * @param SessionInterface $session + * @param RequestInterface $request */ - public function __construct(\Phalcon\Session\ManagerInterface $session = null, \Phalcon\Http\RequestInterface $request = null) + public function __construct(SessionInterface $session = null, RequestInterface $request = null) { } @@ -328,5 +328,4 @@ private function getLocalRequest(): ?RequestInterface private function getLocalSession(): ?SessionInterface { } - } diff --git a/src/Phalcon/Security/Random.php b/src/Phalcon/Security/Random.php index ea9b65f9..0c309003 100644 --- a/src/Phalcon/Security/Random.php +++ b/src/Phalcon/Security/Random.php @@ -282,5 +282,4 @@ public function uuid(): string protected function base(string $alphabet, int $base, $n = null): string { } - } diff --git a/src/Phalcon/Session/Adapter/AbstractAdapter.php b/src/Phalcon/Session/Adapter/AbstractAdapter.php index c563515c..773edbed 100644 --- a/src/Phalcon/Session/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Session/Adapter/AbstractAdapter.php @@ -20,7 +20,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \SessionHandlerInterface +abstract class AbstractAdapter implements SessionHandlerInterface { /** * @var AdapterInterface @@ -88,5 +88,4 @@ public function open($savePath, $sessionName): bool public function write($id, $data): bool { } - } diff --git a/src/Phalcon/Session/Adapter/Libmemcached.php b/src/Phalcon/Session/Adapter/Libmemcached.php index d5588187..6c8ddc0f 100644 --- a/src/Phalcon/Session/Adapter/Libmemcached.php +++ b/src/Phalcon/Session/Adapter/Libmemcached.php @@ -14,7 +14,7 @@ /** * Phalcon\Session\Adapter\Libmemcached */ -class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter +class Libmemcached extends AbstractAdapter { /** @@ -34,10 +34,9 @@ class Libmemcached extends \Phalcon\Session\Adapter\AbstractAdapter * 'serializer' => null, * 'prefix' => 'sess-memc-' * ] - * @param \Phalcon\Storage\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + public function __construct(AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/Session/Adapter/Noop.php b/src/Phalcon/Session/Adapter/Noop.php index 0eeda75f..61b7802b 100644 --- a/src/Phalcon/Session/Adapter/Noop.php +++ b/src/Phalcon/Session/Adapter/Noop.php @@ -27,7 +27,7 @@ * $session->setAdapter(new Noop()); * ``` */ -class Noop implements \SessionHandlerInterface +class Noop implements SessionHandlerInterface { /** * The connection of some adapters @@ -137,5 +137,4 @@ public function write($id, $data): bool protected function getPrefixedName($name): string { } - } diff --git a/src/Phalcon/Session/Adapter/Redis.php b/src/Phalcon/Session/Adapter/Redis.php index fea8ac0d..031979a9 100644 --- a/src/Phalcon/Session/Adapter/Redis.php +++ b/src/Phalcon/Session/Adapter/Redis.php @@ -14,7 +14,7 @@ /** * Phalcon\Session\Adapter\Redis */ -class Redis extends \Phalcon\Session\Adapter\AbstractAdapter +class Redis extends AbstractAdapter { /** @@ -29,10 +29,9 @@ class Redis extends \Phalcon\Session\Adapter\AbstractAdapter * 'auth' => '', * 'socket' => '' * ] - * @param \Phalcon\Storage\AdapterFactory $factory + * @param AdapterFactory $factory */ - public function __construct(\Phalcon\Storage\AdapterFactory $factory, array $options = array()) + public function __construct(AdapterFactory $factory, array $options = array()) { } - } diff --git a/src/Phalcon/Session/Adapter/Stream.php b/src/Phalcon/Session/Adapter/Stream.php index 87b0943e..fe7961e0 100644 --- a/src/Phalcon/Session/Adapter/Stream.php +++ b/src/Phalcon/Session/Adapter/Stream.php @@ -32,7 +32,7 @@ * $session->setAdapter($files); * ``` */ -class Stream extends \Phalcon\Session\Adapter\Noop +class Stream extends Noop { /** * @var string @@ -95,5 +95,4 @@ public function read($id): string public function write($id, $data): bool { } - } diff --git a/src/Phalcon/Session/Bag.php b/src/Phalcon/Session/Bag.php index b8ed5bc5..a7b7b8a8 100644 --- a/src/Phalcon/Session/Bag.php +++ b/src/Phalcon/Session/Bag.php @@ -28,7 +28,7 @@ * $user->age = 22; * ``` */ -class Bag extends Collection implements \Phalcon\Di\InjectionAwareInterface +class Bag extends Collection implements InjectionAwareInterface { private $container; @@ -101,11 +101,10 @@ public function set(string $element, $value) /** * Sets the DependencyInjector container * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public function setDI(\Phalcon\Di\DiInterface $container) + public function setDI(DiInterface $container) { } - } diff --git a/src/Phalcon/Session/Manager.php b/src/Phalcon/Session/Manager.php index 8941957a..0ee34f4a 100644 --- a/src/Phalcon/Session/Manager.php +++ b/src/Phalcon/Session/Manager.php @@ -21,7 +21,7 @@ * * Session manager class */ -class Manager extends AbstractInjectionAware implements \Phalcon\Session\ManagerInterface +class Manager extends AbstractInjectionAware implements ManagerInterface { /** * @var SessionHandlerInterface|null @@ -206,10 +206,10 @@ public function set(string $key, $value) /** * Set the adapter for the session * - * @param \SessionHandlerInterface $adapter + * @param SessionHandlerInterface $adapter * @return ManagerInterface */ - public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface + public function setAdapter(SessionHandlerInterface $adapter): ManagerInterface { } @@ -274,5 +274,4 @@ public function status(): int private function getUniqueKey(string $key): string { } - } diff --git a/src/Phalcon/Session/ManagerInterface.php b/src/Phalcon/Session/ManagerInterface.php index 9fd46ea0..b6827cd5 100644 --- a/src/Phalcon/Session/ManagerInterface.php +++ b/src/Phalcon/Session/ManagerInterface.php @@ -143,10 +143,10 @@ public function set(string $key, $value); /** * Set the adapter for the session * - * @param \SessionHandlerInterface $adapter + * @param SessionHandlerInterface $adapter * @return ManagerInterface */ - public function setAdapter(\SessionHandlerInterface $adapter): ManagerInterface; + public function setAdapter(SessionHandlerInterface $adapter): ManagerInterface; /** * Set session Id @@ -196,5 +196,4 @@ public function start(): bool; * @return ManagerInterface */ public function regenerateId($deleteOldSession = true): ManagerInterface; - } diff --git a/src/Phalcon/Storage/Adapter/AbstractAdapter.php b/src/Phalcon/Storage/Adapter/AbstractAdapter.php index 7159cc00..d12f6e82 100644 --- a/src/Phalcon/Storage/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Storage/Adapter/AbstractAdapter.php @@ -25,7 +25,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractAdapter implements \Phalcon\Storage\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * @var mixed @@ -100,9 +100,9 @@ public function getPrefix(): string * 'serializer' => null, * 'prefix' => '' * ] - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory */ - protected function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + protected function __construct(SerializerFactory $factory, array $options = array()) { } @@ -244,5 +244,4 @@ protected function getUnserializedData($content, $defaultValue = null) protected function initSerializer() { } - } diff --git a/src/Phalcon/Storage/Adapter/AdapterInterface.php b/src/Phalcon/Storage/Adapter/AdapterInterface.php index 3260213e..37c2324b 100644 --- a/src/Phalcon/Storage/Adapter/AdapterInterface.php +++ b/src/Phalcon/Storage/Adapter/AdapterInterface.php @@ -99,5 +99,4 @@ public function increment(string $key, int $value = 1); * @return bool */ public function set(string $key, $value, $ttl = null): bool; - } diff --git a/src/Phalcon/Storage/Adapter/Apcu.php b/src/Phalcon/Storage/Adapter/Apcu.php index c3150976..bf32c876 100644 --- a/src/Phalcon/Storage/Adapter/Apcu.php +++ b/src/Phalcon/Storage/Adapter/Apcu.php @@ -18,7 +18,7 @@ /** * Apcu adapter */ -class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter +class Apcu extends AbstractAdapter { /** * @var array @@ -35,9 +35,9 @@ class Apcu extends \Phalcon\Storage\Adapter\AbstractAdapter * 'serializer' => null, * 'prefix' => '' * ] - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(SerializerFactory $factory, array $options = array()) { } @@ -140,5 +140,4 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/Storage/Adapter/Libmemcached.php b/src/Phalcon/Storage/Adapter/Libmemcached.php index 8e600278..c7d09d15 100644 --- a/src/Phalcon/Storage/Adapter/Libmemcached.php +++ b/src/Phalcon/Storage/Adapter/Libmemcached.php @@ -9,6 +9,7 @@ */ namespace Phalcon\Storage\Adapter; +use Memcached; use Phalcon\Helper\Arr; use Phalcon\Storage\Exception; use Phalcon\Storage\SerializerFactory; @@ -17,7 +18,7 @@ /** * Libmemcached adapter */ -class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter +class Libmemcached extends AbstractAdapter { /** * @var array @@ -41,9 +42,9 @@ class Libmemcached extends \Phalcon\Storage\Adapter\AbstractAdapter * 'serializer' => null, * 'prefix' => '' * ] - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(SerializerFactory $factory, array $options = array()) { } @@ -97,7 +98,7 @@ public function get(string $key, $defaultValue = null) * Returns the already connected adapter or connects to the Memcached * server(s) * - * @return \Memcached + * @return Memcached * @throws Exception */ public function getAdapter() @@ -157,10 +158,9 @@ public function set(string $key, $value, $ttl = null): bool * Checks the serializer. If it is a supported one it is set, otherwise * the custom one is set. * - * @param \Memcached $connection + * @param Memcached $connection */ - private function setSerializer(\Memcached $connection) + private function setSerializer(Memcached $connection) { } - } diff --git a/src/Phalcon/Storage/Adapter/Memory.php b/src/Phalcon/Storage/Adapter/Memory.php index b32d4d38..4dff9050 100644 --- a/src/Phalcon/Storage/Adapter/Memory.php +++ b/src/Phalcon/Storage/Adapter/Memory.php @@ -18,7 +18,7 @@ /** * Memory adapter */ -class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter +class Memory extends AbstractAdapter { /** * @var Collection @@ -40,9 +40,9 @@ class Memory extends \Phalcon\Storage\Adapter\AbstractAdapter * 'serializer' => null, * 'prefix' => '' * ] - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(SerializerFactory $factory, array $options = array()) { } @@ -144,5 +144,4 @@ public function increment(string $key, int $value = 1) public function set(string $key, $value, $ttl = null): bool { } - } diff --git a/src/Phalcon/Storage/Adapter/Redis.php b/src/Phalcon/Storage/Adapter/Redis.php index b49fcb40..3cc267ae 100644 --- a/src/Phalcon/Storage/Adapter/Redis.php +++ b/src/Phalcon/Storage/Adapter/Redis.php @@ -17,7 +17,7 @@ /** * Redis adapter */ -class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter +class Redis extends AbstractAdapter { /** * @var array @@ -40,9 +40,9 @@ class Redis extends \Phalcon\Storage\Adapter\AbstractAdapter * 'serializer' => null, * 'prefix' => '' * ] - * @param \Phalcon\Storage\SerializerFactory $factory + * @param SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(SerializerFactory $factory, array $options = array()) { } @@ -164,5 +164,4 @@ public function set(string $key, $value, $ttl = null): bool private function setSerializer(\Redis $connection) { } - } diff --git a/src/Phalcon/Storage/Adapter/Stream.php b/src/Phalcon/Storage/Adapter/Stream.php index a15bf621..3af80979 100644 --- a/src/Phalcon/Storage/Adapter/Stream.php +++ b/src/Phalcon/Storage/Adapter/Stream.php @@ -22,7 +22,7 @@ /** * Stream adapter */ -class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter +class Stream extends AbstractAdapter { /** * @var string @@ -46,10 +46,10 @@ class Stream extends \Phalcon\Storage\Adapter\AbstractAdapter * 'prefix' => '' * ] * + * @param SerializerFactory $factory * @throws Exception - * @param \Phalcon\Storage\SerializerFactory $factory */ - public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $options = array()) + public function __construct(SerializerFactory $factory, array $options = array()) { } @@ -207,5 +207,4 @@ private function getPayload(string $filepath): array private function isExpired(array $payload): bool { } - } diff --git a/src/Phalcon/Storage/AdapterFactory.php b/src/Phalcon/Storage/AdapterFactory.php index e458a7ad..a27a2eb1 100644 --- a/src/Phalcon/Storage/AdapterFactory.php +++ b/src/Phalcon/Storage/AdapterFactory.php @@ -74,5 +74,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Storage/Serializer/AbstractSerializer.php b/src/Phalcon/Storage/Serializer/AbstractSerializer.php index ba8429ec..2ed0e256 100644 --- a/src/Phalcon/Storage/Serializer/AbstractSerializer.php +++ b/src/Phalcon/Storage/Serializer/AbstractSerializer.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractSerializer implements \Phalcon\Storage\Serializer\SerializerInterface +abstract class AbstractSerializer implements SerializerInterface { /** * @var mixed @@ -60,5 +60,4 @@ public function getData() public function setData($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Base64.php b/src/Phalcon/Storage/Serializer/Base64.php index 5956f3c3..9a1b1bfe 100644 --- a/src/Phalcon/Storage/Serializer/Base64.php +++ b/src/Phalcon/Storage/Serializer/Base64.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Base64 extends \Phalcon\Storage\Serializer\AbstractSerializer +class Base64 extends AbstractSerializer { /** @@ -40,5 +40,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Igbinary.php b/src/Phalcon/Storage/Serializer/Igbinary.php index 975beca9..978bc964 100644 --- a/src/Phalcon/Storage/Serializer/Igbinary.php +++ b/src/Phalcon/Storage/Serializer/Igbinary.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Igbinary extends \Phalcon\Storage\Serializer\AbstractSerializer +class Igbinary extends AbstractSerializer { /** @@ -38,5 +38,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Json.php b/src/Phalcon/Storage/Serializer/Json.php index f82e5310..072ceec7 100644 --- a/src/Phalcon/Storage/Serializer/Json.php +++ b/src/Phalcon/Storage/Serializer/Json.php @@ -11,7 +11,6 @@ use InvalidArgumentException; use JsonSerializable; -use Phalcon\Helper\Json; /** * This file is part of the Phalcon Framework. @@ -21,7 +20,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Json extends \Phalcon\Storage\Serializer\AbstractSerializer +class Json extends AbstractSerializer { /** @@ -42,5 +41,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Msgpack.php b/src/Phalcon/Storage/Serializer/Msgpack.php index 65fb50a4..d5fa20a7 100644 --- a/src/Phalcon/Storage/Serializer/Msgpack.php +++ b/src/Phalcon/Storage/Serializer/Msgpack.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Msgpack extends \Phalcon\Storage\Serializer\AbstractSerializer +class Msgpack extends AbstractSerializer { /** @@ -38,5 +38,4 @@ public function serialize(): ?string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/None.php b/src/Phalcon/Storage/Serializer/None.php index 2b8f83c4..46a0444a 100644 --- a/src/Phalcon/Storage/Serializer/None.php +++ b/src/Phalcon/Storage/Serializer/None.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class None extends \Phalcon\Storage\Serializer\AbstractSerializer +class None extends AbstractSerializer { /** @@ -40,5 +40,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/Php.php b/src/Phalcon/Storage/Serializer/Php.php index fbfb563c..1a79c0d9 100644 --- a/src/Phalcon/Storage/Serializer/Php.php +++ b/src/Phalcon/Storage/Serializer/Php.php @@ -20,7 +20,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class Php extends \Phalcon\Storage\Serializer\AbstractSerializer +class Php extends AbstractSerializer { /** @@ -41,5 +41,4 @@ public function serialize(): string public function unserialize($data) { } - } diff --git a/src/Phalcon/Storage/Serializer/SerializerInterface.php b/src/Phalcon/Storage/Serializer/SerializerInterface.php index 747a10c6..fb2c07df 100644 --- a/src/Phalcon/Storage/Serializer/SerializerInterface.php +++ b/src/Phalcon/Storage/Serializer/SerializerInterface.php @@ -19,7 +19,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -interface SerializerInterface extends \Serializable +interface SerializerInterface extends Serializable { /** @@ -32,5 +32,4 @@ public function getData(); * @return void */ public function setData($data); - } diff --git a/src/Phalcon/Storage/SerializerFactory.php b/src/Phalcon/Storage/SerializerFactory.php index bf753855..0ae0be18 100644 --- a/src/Phalcon/Storage/SerializerFactory.php +++ b/src/Phalcon/Storage/SerializerFactory.php @@ -47,5 +47,4 @@ public function newInstance(string $name): SerializerInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Tag.php b/src/Phalcon/Tag.php index 9c261da4..50ecb40b 100644 --- a/src/Phalcon/Tag.php +++ b/src/Phalcon/Tag.php @@ -56,40 +56,40 @@ class Tag const XHTML5 = 11; - static protected $autoEscape = true; + protected static $autoEscape = true; /** * DI Container */ - static protected $container; + protected static $container; /** * Pre-assigned values for components */ - static protected $displayValues; + protected static $displayValues; - static protected $documentAppendTitle = null; + protected static $documentAppendTitle = null; - static protected $documentPrependTitle = null; + protected static $documentPrependTitle = null; /** * HTML document title */ - static protected $documentTitle = null; + protected static $documentTitle = null; - static protected $documentTitleSeparator = null; + protected static $documentTitleSeparator = null; - static protected $documentType = 11; + protected static $documentType = 11; - static protected $escaperService = null; + protected static $escaperService = null; - static protected $urlService = null; + protected static $urlService = null; /** @@ -652,10 +652,10 @@ public static function setDefaults(array $values, bool $merge = false) /** * Sets the dependency injector container. * - * @param \Phalcon\Di\DiInterface $container + * @param DiInterface $container * @return void */ - public static function setDI(\Phalcon\Di\DiInterface $container) + public static function setDI(DiInterface $container) { } @@ -843,7 +843,7 @@ public static function weekField($parameters): string * @param bool $asValue * @return string */ - static final protected function inputField(string $type, $parameters, bool $asValue = false): string + final protected static function inputField(string $type, $parameters, bool $asValue = false): string { } @@ -854,8 +854,7 @@ static final protected function inputField(string $type, $parameters, bool $asVa * @param mixed $parameters * @return string */ - static final protected function inputFieldChecked(string $type, $parameters): string + final protected static function inputFieldChecked(string $type, $parameters): string { } - } diff --git a/src/Phalcon/Tag/Select.php b/src/Phalcon/Tag/Select.php index 4e2f9ffe..46309340 100644 --- a/src/Phalcon/Tag/Select.php +++ b/src/Phalcon/Tag/Select.php @@ -56,13 +56,12 @@ private static function optionsFromArray(array $data, $value, string $closeOptio * Generate the OPTION tags based on a resultset * * @param array $using - * @param \Phalcon\Mvc\Model\ResultsetInterface $resultset + * @param ResultsetInterface $resultset * @param mixed $value * @param string $closeOption * @return string */ - private static function optionsFromResultset(\Phalcon\Mvc\Model\ResultsetInterface $resultset, $using, $value, string $closeOption): string + private static function optionsFromResultset(ResultsetInterface $resultset, $using, $value, string $closeOption): string { } - } diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 1b145995..78975e85 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -278,5 +278,4 @@ public static function underscore(string $text): string public static function upper(string $text, string $encoding = 'UTF-8'): string { } - } diff --git a/src/Phalcon/Translate/Adapter/AbstractAdapter.php b/src/Phalcon/Translate/Adapter/AbstractAdapter.php index e70d672a..004dccd1 100644 --- a/src/Phalcon/Translate/Adapter/AbstractAdapter.php +++ b/src/Phalcon/Translate/Adapter/AbstractAdapter.php @@ -18,7 +18,7 @@ * * Base class for Phalcon\Translate adapters */ -abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInterface +abstract class AbstractAdapter implements AdapterInterface { /** * @var string @@ -32,10 +32,10 @@ abstract class AbstractAdapter implements \Phalcon\Translate\Adapter\AdapterInte /** - * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param InterpolatorFactory $interpolator * @param array $options */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + public function __construct(InterpolatorFactory $interpolator, array $options) { } @@ -112,5 +112,4 @@ public function t(string $translateKey, array $placeholders = array()): string protected function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Adapter/AdapterInterface.php b/src/Phalcon/Translate/Adapter/AdapterInterface.php index 4dc387dc..214bb99f 100644 --- a/src/Phalcon/Translate/Adapter/AdapterInterface.php +++ b/src/Phalcon/Translate/Adapter/AdapterInterface.php @@ -42,5 +42,4 @@ public function query(string $translateKey, array $placeholders = array()): stri * @return string */ public function t(string $translateKey, array $placeholders = array()): string; - } diff --git a/src/Phalcon/Translate/Adapter/Csv.php b/src/Phalcon/Translate/Adapter/Csv.php index 95ad3cd6..40a947ad 100644 --- a/src/Phalcon/Translate/Adapter/Csv.php +++ b/src/Phalcon/Translate/Adapter/Csv.php @@ -18,7 +18,7 @@ * * Allows to define translation lists using CSV file */ -class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Csv extends AbstractAdapter implements ArrayAccess { /** * @var array @@ -34,9 +34,9 @@ class Csv extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAc * 'delimiter' => ';', * 'enclosure' => '"' * ] - * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param InterpolatorFactory $interpolator */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + public function __construct(InterpolatorFactory $interpolator, array $options) { } @@ -73,5 +73,4 @@ public function query(string $index, array $placeholders = array()): string private function load(string $file, int $length, string $delimiter, string $enclosure) { } - } diff --git a/src/Phalcon/Translate/Adapter/Gettext.php b/src/Phalcon/Translate/Adapter/Gettext.php index befad680..dcb74aa0 100644 --- a/src/Phalcon/Translate/Adapter/Gettext.php +++ b/src/Phalcon/Translate/Adapter/Gettext.php @@ -31,7 +31,7 @@ * * Allows translate using gettext */ -class Gettext extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class Gettext extends AbstractAdapter implements ArrayAccess { /** * @var int @@ -91,9 +91,9 @@ public function getLocale(): string * 'directory' => '', * 'category' => '' * ] - * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param InterpolatorFactory $interpolator */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + public function __construct(InterpolatorFactory $interpolator, array $options) { } @@ -227,5 +227,4 @@ protected function getOptionsDefault(): array protected function prepareOptions(array $options) { } - } diff --git a/src/Phalcon/Translate/Adapter/NativeArray.php b/src/Phalcon/Translate/Adapter/NativeArray.php index f56d3935..24fea267 100644 --- a/src/Phalcon/Translate/Adapter/NativeArray.php +++ b/src/Phalcon/Translate/Adapter/NativeArray.php @@ -18,7 +18,7 @@ * * Allows to define translation lists using PHP arrays */ -class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class NativeArray extends AbstractAdapter implements ArrayAccess { /** * @var array @@ -38,9 +38,9 @@ class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements * 'content' => '', * 'triggerError' => false * ] - * @param \Phalcon\Translate\InterpolatorFactory $interpolator + * @param InterpolatorFactory $interpolator */ - public function __construct(\Phalcon\Translate\InterpolatorFactory $interpolator, array $options) + public function __construct(InterpolatorFactory $interpolator, array $options) { } @@ -74,5 +74,4 @@ public function notFound(string $index): string public function query(string $index, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/AssociativeArray.php b/src/Phalcon/Translate/Interpolator/AssociativeArray.php index 026b5fda..0b4e7954 100644 --- a/src/Phalcon/Translate/Interpolator/AssociativeArray.php +++ b/src/Phalcon/Translate/Interpolator/AssociativeArray.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface +class AssociativeArray implements InterpolatorInterface { /** @@ -30,5 +30,4 @@ class AssociativeArray implements \Phalcon\Translate\Interpolator\InterpolatorIn public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/IndexedArray.php b/src/Phalcon/Translate/Interpolator/IndexedArray.php index dab117e5..d7ff26c2 100644 --- a/src/Phalcon/Translate/Interpolator/IndexedArray.php +++ b/src/Phalcon/Translate/Interpolator/IndexedArray.php @@ -17,7 +17,7 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterface +class IndexedArray implements InterpolatorInterface { /** @@ -30,5 +30,4 @@ class IndexedArray implements \Phalcon\Translate\Interpolator\InterpolatorInterf public function replacePlaceholders(string $translation, array $placeholders = array()): string { } - } diff --git a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php index 157fa7b4..e3ab9ade 100644 --- a/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php +++ b/src/Phalcon/Translate/Interpolator/InterpolatorInterface.php @@ -25,5 +25,4 @@ interface InterpolatorInterface * @return string */ public function replacePlaceholders(string $translation, array $placeholders = array()): string; - } diff --git a/src/Phalcon/Translate/InterpolatorFactory.php b/src/Phalcon/Translate/InterpolatorFactory.php index d5894d24..1a2657ba 100644 --- a/src/Phalcon/Translate/InterpolatorFactory.php +++ b/src/Phalcon/Translate/InterpolatorFactory.php @@ -58,5 +58,4 @@ public function newInstance(string $name): AdapterInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Translate/TranslateFactory.php b/src/Phalcon/Translate/TranslateFactory.php index 6cee0418..7ff9804e 100644 --- a/src/Phalcon/Translate/TranslateFactory.php +++ b/src/Phalcon/Translate/TranslateFactory.php @@ -43,7 +43,7 @@ public function __construct(InterpolatorFactory $interpolator, array $services = /** * Factory to create an instace from a Config object * - * @param array|\Phalcon\Config = [ + * @param array|Config = [ * 'adapter' => 'ini, * 'options' => [ * 'content' => '', @@ -57,7 +57,7 @@ public function __construct(InterpolatorFactory $interpolator, array $services = * ] * ] * @param mixed $config - * @param array|\Phalcon\Config = [ + * @param array|Config = [ * 'adapter' => 'ini, * 'options' => [ * 'content' => '', @@ -93,5 +93,4 @@ public function newInstance(string $name, array $options = array()): AdapterInte protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Url.php b/src/Phalcon/Url.php index 875d25a9..01f4367b 100644 --- a/src/Phalcon/Url.php +++ b/src/Phalcon/Url.php @@ -33,7 +33,7 @@ * ); * ``` */ -class Url extends AbstractInjectionAware implements \Phalcon\Url\UrlInterface +class Url extends AbstractInjectionAware implements UrlInterface { /** * @var null | string @@ -57,9 +57,9 @@ class Url extends AbstractInjectionAware implements \Phalcon\Url\UrlInterface /** - * @param \Phalcon\Mvc\RouterInterface $router + * @param RouterInterface $router */ - public function __construct(\Phalcon\Mvc\RouterInterface $router = null) + public function __construct(RouterInterface $router = null) { } @@ -212,5 +212,4 @@ public function setStaticBaseUri(string $staticBaseUri): UrlInterface public function path(string $path = null): string { } - } diff --git a/src/Phalcon/Url/UrlInterface.php b/src/Phalcon/Url/UrlInterface.php index 7f5c8764..3a25a9f8 100644 --- a/src/Phalcon/Url/UrlInterface.php +++ b/src/Phalcon/Url/UrlInterface.php @@ -62,5 +62,4 @@ public function setBaseUri(string $baseUri): UrlInterface; * @return string */ public function path(string $path = null): string; - } diff --git a/src/Phalcon/Validation.php b/src/Phalcon/Validation.php index febe1975..a3814dba 100644 --- a/src/Phalcon/Validation.php +++ b/src/Phalcon/Validation.php @@ -22,7 +22,7 @@ /** * Allows to validate data using custom or built-in validators */ -class Validation extends Injectable implements \Phalcon\Validation\ValidationInterface +class Validation extends Injectable implements ValidationInterface { protected $combinedFieldsValidators; @@ -74,20 +74,20 @@ public function __construct(array $validators = array()) * Adds a validator to a field * * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ValidationInterface */ - public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + public function add($field, ValidatorInterface $validator): ValidationInterface { } /** * Appends a message to the messages list * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ValidationInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface + public function appendMessage(MessageInterface $message): ValidationInterface { } @@ -164,10 +164,10 @@ public function getValue(string $field) * Alias of `add` method * * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return ValidationInterface */ - public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + public function rule($field, ValidatorInterface $validator): ValidationInterface { } @@ -228,11 +228,10 @@ public function validate($data = null, $entity = null): Messages * Internal validations, if it returns true, then skip the current validator * * @param mixed $field - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param ValidatorInterface $validator * @return bool */ - protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool + protected function preChecking($field, ValidatorInterface $validator): bool { } - } diff --git a/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php b/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php index f75e0a48..1516dc24 100644 --- a/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php +++ b/src/Phalcon/Validation/AbstractCombinedFieldsValidator.php @@ -12,7 +12,7 @@ /** * This is a base class for combined fields validators */ -abstract class AbstractCombinedFieldsValidator extends \Phalcon\Validation\AbstractValidator +abstract class AbstractCombinedFieldsValidator extends AbstractValidator { } diff --git a/src/Phalcon/Validation/AbstractValidator.php b/src/Phalcon/Validation/AbstractValidator.php index 8536952d..9be71ded 100644 --- a/src/Phalcon/Validation/AbstractValidator.php +++ b/src/Phalcon/Validation/AbstractValidator.php @@ -17,7 +17,7 @@ /** * This is a base class for validators */ -abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface +abstract class AbstractValidator implements ValidatorInterface { /** * Message template @@ -122,11 +122,11 @@ public function setOption(string $key, $value) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - abstract public function validate(\Phalcon\Validation $validation, $field): bool; + abstract public function validate(Validation $validation, $field): bool; /** * Prepares a validation code. @@ -141,26 +141,25 @@ protected function prepareCode(string $field): ?int /** * Prepares a label for the field. * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param string $field * @return mixed */ - protected function prepareLabel(\Phalcon\Validation $validation, string $field) + protected function prepareLabel(Validation $validation, string $field) { } /** * Create a default message by factory * - * @return Message - * - * @throw Exception - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @param array $replacements + *@return Message + * + * @throw Exception */ - public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = array()): Message + public function messageFactory(Validation $validation, $field, array $replacements = array()): Message { } - } diff --git a/src/Phalcon/Validation/AbstractValidatorComposite.php b/src/Phalcon/Validation/AbstractValidatorComposite.php index e325eab1..ea1a6734 100644 --- a/src/Phalcon/Validation/AbstractValidatorComposite.php +++ b/src/Phalcon/Validation/AbstractValidatorComposite.php @@ -14,7 +14,7 @@ /** * This is a base class for combined fields validators */ -abstract class AbstractValidatorComposite extends \Phalcon\Validation\AbstractValidator implements \Phalcon\Validation\ValidatorCompositeInterface +abstract class AbstractValidatorComposite extends AbstractValidator implements ValidatorCompositeInterface { /** * @var array @@ -32,12 +32,11 @@ public function getValidators(): array /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/ValidationInterface.php b/src/Phalcon/Validation/ValidationInterface.php index dab50ee1..be5ee432 100644 --- a/src/Phalcon/Validation/ValidationInterface.php +++ b/src/Phalcon/Validation/ValidationInterface.php @@ -31,10 +31,10 @@ public function add(string $field, ValidatorInterface $validator): ValidationInt /** * Appends a message to the messages list * - * @param \Phalcon\Messages\MessageInterface $message + * @param MessageInterface $message * @return ValidationInterface */ - public function appendMessage(\Phalcon\Messages\MessageInterface $message): ValidationInterface; + public function appendMessage(MessageInterface $message): ValidationInterface; /** * Assigns the data to an entity @@ -134,5 +134,4 @@ public function setLabels(array $labels); * @return Messages */ public function validate($data = null, $entity = null): Messages; - } diff --git a/src/Phalcon/Validation/Validator/Alnum.php b/src/Phalcon/Validation/Validator/Alnum.php index 5c75c81a..484a068e 100644 --- a/src/Phalcon/Validation/Validator/Alnum.php +++ b/src/Phalcon/Validation/Validator/Alnum.php @@ -68,12 +68,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Alpha.php b/src/Phalcon/Validation/Validator/Alpha.php index 7dbe8266..610840f4 100644 --- a/src/Phalcon/Validation/Validator/Alpha.php +++ b/src/Phalcon/Validation/Validator/Alpha.php @@ -69,12 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Between.php b/src/Phalcon/Validation/Validator/Between.php index 756725af..e823290b 100644 --- a/src/Phalcon/Validation/Validator/Between.php +++ b/src/Phalcon/Validation/Validator/Between.php @@ -82,12 +82,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Callback.php b/src/Phalcon/Validation/Validator/Callback.php index 9525d5fe..d94e75b5 100644 --- a/src/Phalcon/Validation/Validator/Callback.php +++ b/src/Phalcon/Validation/Validator/Callback.php @@ -81,12 +81,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Confirmation.php b/src/Phalcon/Validation/Validator/Confirmation.php index 49619823..f776cb1e 100644 --- a/src/Phalcon/Validation/Validator/Confirmation.php +++ b/src/Phalcon/Validation/Validator/Confirmation.php @@ -78,11 +78,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } @@ -96,5 +96,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool final protected function compare(string $a, string $b): bool { } - } diff --git a/src/Phalcon/Validation/Validator/CreditCard.php b/src/Phalcon/Validation/Validator/CreditCard.php index 7402871d..7e9fa1cb 100644 --- a/src/Phalcon/Validation/Validator/CreditCard.php +++ b/src/Phalcon/Validation/Validator/CreditCard.php @@ -69,11 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } @@ -87,5 +87,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function verifyByLuhnAlgorithm(string $number): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Date.php b/src/Phalcon/Validation/Validator/Date.php index 78b221dc..90d9fb95 100644 --- a/src/Phalcon/Validation/Validator/Date.php +++ b/src/Phalcon/Validation/Validator/Date.php @@ -76,11 +76,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } @@ -92,5 +92,4 @@ public function validate(\Phalcon\Validation $validation, $field): bool private function checkDate($value, $format): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Digit.php b/src/Phalcon/Validation/Validator/Digit.php index aded9a84..be43ddde 100644 --- a/src/Phalcon/Validation/Validator/Digit.php +++ b/src/Phalcon/Validation/Validator/Digit.php @@ -69,12 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Email.php b/src/Phalcon/Validation/Validator/Email.php index c8a9b38a..02f2e718 100644 --- a/src/Phalcon/Validation/Validator/Email.php +++ b/src/Phalcon/Validation/Validator/Email.php @@ -69,12 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/ExclusionIn.php b/src/Phalcon/Validation/Validator/ExclusionIn.php index 4826637c..c578655a 100644 --- a/src/Phalcon/Validation/Validator/ExclusionIn.php +++ b/src/Phalcon/Validation/Validator/ExclusionIn.php @@ -83,12 +83,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File.php b/src/Phalcon/Validation/Validator/File.php index a05933d3..db50a308 100644 --- a/src/Phalcon/Validation/Validator/File.php +++ b/src/Phalcon/Validation/Validator/File.php @@ -119,5 +119,4 @@ class File extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/Validation/Validator/File/AbstractFile.php b/src/Phalcon/Validation/Validator/File/AbstractFile.php index 30383155..aa9d39ed 100644 --- a/src/Phalcon/Validation/Validator/File/AbstractFile.php +++ b/src/Phalcon/Validation/Validator/File/AbstractFile.php @@ -125,7 +125,7 @@ public function setMessageValid($messageValid) * @param string $field * @return bool */ - public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool + public function isAllowEmpty(Validation $validation, string $field): bool { } @@ -136,7 +136,7 @@ public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bo * @param mixed $field * @return bool */ - public function checkUpload(\Phalcon\Validation $validation, $field): bool + public function checkUpload(Validation $validation, $field): bool { } @@ -147,7 +147,7 @@ public function checkUpload(\Phalcon\Validation $validation, $field): bool * @param mixed $field * @return boolean */ - public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool + public function checkUploadMaxSize(Validation $validation, $field): bool { } @@ -158,7 +158,7 @@ public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): boo * @param mixed $field * @return boolean */ - public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool + public function checkUploadIsEmpty(Validation $validation, $field): bool { } @@ -169,7 +169,7 @@ public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): boo * @param mixed $field * @return boolean */ - public function checkUploadIsValid(\Phalcon\Validation $validation, $field): bool + public function checkUploadIsValid(Validation $validation, $field): bool { } @@ -182,5 +182,4 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo public function getFileSizeInBytes(string $size): float { } - } diff --git a/src/Phalcon/Validation/Validator/File/MimeType.php b/src/Phalcon/Validation/Validator/File/MimeType.php index eb0d6f28..ad51c377 100644 --- a/src/Phalcon/Validation/Validator/File/MimeType.php +++ b/src/Phalcon/Validation/Validator/File/MimeType.php @@ -61,7 +61,7 @@ * ); * ``` */ -class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile +class MimeType extends AbstractFile { protected $template = 'File :field must be of type: :types'; @@ -74,8 +74,7 @@ class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php index cf672b6f..c2bc6a2e 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Equal.php @@ -74,12 +74,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Max.php b/src/Phalcon/Validation/Validator/File/Resolution/Max.php index b8e350c9..4680e9fd 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Max.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Max.php @@ -80,12 +80,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Resolution/Min.php b/src/Phalcon/Validation/Validator/File/Resolution/Min.php index 9b4f170f..23917c64 100644 --- a/src/Phalcon/Validation/Validator/File/Resolution/Min.php +++ b/src/Phalcon/Validation/Validator/File/Resolution/Min.php @@ -80,12 +80,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Equal.php b/src/Phalcon/Validation/Validator/File/Size/Equal.php index b5f968a5..84411a3b 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Equal.php +++ b/src/Phalcon/Validation/Validator/File/Size/Equal.php @@ -79,12 +79,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Max.php b/src/Phalcon/Validation/Validator/File/Size/Max.php index 3f993d32..70a94d55 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Max.php +++ b/src/Phalcon/Validation/Validator/File/Size/Max.php @@ -80,12 +80,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/File/Size/Min.php b/src/Phalcon/Validation/Validator/File/Size/Min.php index 44aa8a05..ac0f30e5 100644 --- a/src/Phalcon/Validation/Validator/File/Size/Min.php +++ b/src/Phalcon/Validation/Validator/File/Size/Min.php @@ -80,12 +80,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Identical.php b/src/Phalcon/Validation/Validator/Identical.php index 35a09e7e..8bebbcca 100644 --- a/src/Phalcon/Validation/Validator/Identical.php +++ b/src/Phalcon/Validation/Validator/Identical.php @@ -76,12 +76,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/InclusionIn.php b/src/Phalcon/Validation/Validator/InclusionIn.php index 24b67f83..ff8f5ef2 100644 --- a/src/Phalcon/Validation/Validator/InclusionIn.php +++ b/src/Phalcon/Validation/Validator/InclusionIn.php @@ -77,12 +77,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Ip.php b/src/Phalcon/Validation/Validator/Ip.php index 10d0a19e..a9f78614 100644 --- a/src/Phalcon/Validation/Validator/Ip.php +++ b/src/Phalcon/Validation/Validator/Ip.php @@ -94,12 +94,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Numericality.php b/src/Phalcon/Validation/Validator/Numericality.php index 1213fee8..59b55de1 100644 --- a/src/Phalcon/Validation/Validator/Numericality.php +++ b/src/Phalcon/Validation/Validator/Numericality.php @@ -69,12 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/PresenceOf.php b/src/Phalcon/Validation/Validator/PresenceOf.php index 55e318cd..0b3c970b 100644 --- a/src/Phalcon/Validation/Validator/PresenceOf.php +++ b/src/Phalcon/Validation/Validator/PresenceOf.php @@ -69,12 +69,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Regex.php b/src/Phalcon/Validation/Validator/Regex.php index 7aa942be..8e9e29e8 100644 --- a/src/Phalcon/Validation/Validator/Regex.php +++ b/src/Phalcon/Validation/Validator/Regex.php @@ -75,12 +75,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength.php b/src/Phalcon/Validation/Validator/StringLength.php index e8fcb442..438ce622 100644 --- a/src/Phalcon/Validation/Validator/StringLength.php +++ b/src/Phalcon/Validation/Validator/StringLength.php @@ -98,5 +98,4 @@ class StringLength extends AbstractValidatorComposite public function __construct(array $options = array()) { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength/Max.php b/src/Phalcon/Validation/Validator/StringLength/Max.php index 620efd97..987e003d 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Max.php +++ b/src/Phalcon/Validation/Validator/StringLength/Max.php @@ -84,12 +84,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/StringLength/Min.php b/src/Phalcon/Validation/Validator/StringLength/Min.php index 34fa22db..24dd58a9 100644 --- a/src/Phalcon/Validation/Validator/StringLength/Min.php +++ b/src/Phalcon/Validation/Validator/StringLength/Min.php @@ -84,12 +84,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/Validator/Uniqueness.php b/src/Phalcon/Validation/Validator/Uniqueness.php index c91f3525..ec307653 100644 --- a/src/Phalcon/Validation/Validator/Uniqueness.php +++ b/src/Phalcon/Validation/Validator/Uniqueness.php @@ -114,11 +114,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } @@ -134,11 +134,11 @@ protected function getColumnNameReal($record, string $field): string } /** - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - protected function isUniqueness(\Phalcon\Validation $validation, $field): bool + protected function isUniqueness(Validation $validation, $field): bool { } @@ -152,5 +152,4 @@ protected function isUniqueness(\Phalcon\Validation $validation, $field): bool protected function isUniquenessModel($record, array $field, array $values) { } - } diff --git a/src/Phalcon/Validation/Validator/Url.php b/src/Phalcon/Validation/Validator/Url.php index a05abd4c..62849361 100644 --- a/src/Phalcon/Validation/Validator/Url.php +++ b/src/Phalcon/Validation/Validator/Url.php @@ -70,12 +70,11 @@ public function __construct(array $options = array()) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(Validation $validation, $field): bool { } - } diff --git a/src/Phalcon/Validation/ValidatorCompositeInterface.php b/src/Phalcon/Validation/ValidatorCompositeInterface.php index 28bacbca..95acbd8f 100644 --- a/src/Phalcon/Validation/ValidatorCompositeInterface.php +++ b/src/Phalcon/Validation/ValidatorCompositeInterface.php @@ -27,10 +27,9 @@ public function getValidators(): array; /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool; - + public function validate(Validation $validation, $field): bool; } diff --git a/src/Phalcon/Validation/ValidatorFactory.php b/src/Phalcon/Validation/ValidatorFactory.php index 818f4c54..e19a54d1 100644 --- a/src/Phalcon/Validation/ValidatorFactory.php +++ b/src/Phalcon/Validation/ValidatorFactory.php @@ -49,5 +49,4 @@ public function newInstance(string $name): ValidatorInterface protected function getAdapters(): array { } - } diff --git a/src/Phalcon/Validation/ValidatorInterface.php b/src/Phalcon/Validation/ValidatorInterface.php index 03bde84b..2ab3248e 100644 --- a/src/Phalcon/Validation/ValidatorInterface.php +++ b/src/Phalcon/Validation/ValidatorInterface.php @@ -39,11 +39,11 @@ public function hasOption(string $key): bool; /** * Executes the validation * - * @return boolean - * @param \Phalcon\Validation $validation + * @param Validation $validation * @param mixed $field + *@return boolean */ - public function validate(\Phalcon\Validation $validation, $field): bool; + public function validate(Validation $validation, $field): bool; /** * Get the template message @@ -76,5 +76,4 @@ public function setTemplates(array $templates): ValidatorInterface; * @param string $template */ public function setTemplate(string $template): ValidatorInterface; - } diff --git a/src/Phalcon/Version.php b/src/Phalcon/Version.php index 07b80a6b..f9904425 100644 --- a/src/Phalcon/Version.php +++ b/src/Phalcon/Version.php @@ -92,7 +92,7 @@ protected static function _getVersion(): array * @param int $special * @return string */ - protected final static function _getSpecial(int $special): string + final protected static function _getSpecial(int $special): string { } @@ -138,5 +138,4 @@ public static function getId(): string public static function getPart(int $part): string { } - } diff --git a/test/scan.php b/test/scan.php new file mode 100644 index 00000000..13da1fe6 --- /dev/null +++ b/test/scan.php @@ -0,0 +1,28 @@ +errors[$file] = $str; + } + + public function scanFile($file) { + $content = str_replace("scanFile("test.php"); +print_r($handler->errors);